his_api_controller.go 812KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "math"
  6. //"crypto/x509/pkix"
  7. "encoding/json"
  8. "fmt"
  9. //"github.com/tjfoc/gmsm/sm2"
  10. //"github.com/tjfoc/gmsm/sm3"
  11. "gdyb/controllers"
  12. "gdyb/enums"
  13. "gdyb/models"
  14. "gdyb/service"
  15. "gdyb/utils"
  16. "github.com/astaxie/beego"
  17. "github.com/axgle/mahonia"
  18. "github.com/gorilla/websocket"
  19. "github.com/jinzhu/gorm"
  20. "github.com/shopspring/decimal"
  21. "io"
  22. "io/ioutil"
  23. //"math"
  24. "math/rand"
  25. "net/http"
  26. "net/url"
  27. "os"
  28. "path/filepath"
  29. "regexp"
  30. "strconv"
  31. "strings"
  32. "syscall"
  33. "time"
  34. "unsafe"
  35. )
  36. type HisApiController struct {
  37. controllers.BaseAuthAPIController
  38. }
  39. func HisManagerApiRegistRouters() {
  40. //挂号
  41. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  42. //上传就诊信息-上传明细-结算
  43. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  44. //查询
  45. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  46. //对总账
  47. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  48. //对明细
  49. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  50. //退费,退明细
  51. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  52. //退号
  53. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  54. //退明细
  55. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  56. //上传就诊信息-上传明细-预结算
  57. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  58. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  59. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  60. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  61. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  62. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  63. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  64. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  65. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  66. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  67. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  68. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  69. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  70. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  71. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  72. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  73. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  74. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  75. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  76. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  77. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  78. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  79. beego.Router("/api/check", &HisApiController{}, "get:Check")
  80. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  81. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  82. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  83. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  84. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  85. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  86. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  87. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  88. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  89. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  90. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  91. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  92. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  93. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  94. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  95. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  96. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  97. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  98. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  99. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  100. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  101. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  102. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  103. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  104. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  105. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  106. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  107. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  108. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  109. //beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  110. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  111. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  112. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  113. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  114. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  115. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  116. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  117. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  118. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  119. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  120. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  121. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  122. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  123. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  124. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  125. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  126. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  127. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  128. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  129. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  130. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  131. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  132. }
  133. //func (c *HisApiController)CancleDia(){
  134. //
  135. // id, _ := c.GetInt64("id")
  136. // record_time := c.GetString("record_time")
  137. // his_patient_id, _ := c.GetInt64("his_patient_id")
  138. //
  139. // admin_user_id, _ := c.GetInt64("admin_user_id")
  140. //
  141. // diagnosis_id := c.GetString("diagnosis")
  142. // sick_type, _ := c.GetInt64("sick_type")
  143. // reg_type, _ := c.GetInt64("p_type")
  144. // begin_time := c.GetString("begin_time")
  145. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  146. //
  147. //
  148. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  149. //
  150. // fmt.Println(acct_used_flag)
  151. //
  152. //
  153. // timeLayout := "2006-01-02"
  154. // loc, _ := time.LoadLocation("Local")
  155. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  156. // if err != nil {
  157. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  158. // return
  159. // }
  160. // recordDateTime := theTime.Unix()
  161. // adminUser := c.GetAdminUserInfo()
  162. //
  163. //
  164. //
  165. //
  166. //
  167. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  168. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  169. // var patientPrescription models.HisPrescriptionInfo
  170. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  171. // if patientPrescription.ID == 0 {
  172. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  173. // }
  174. // //if patientPrescription.Do
  175. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  176. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  177. //
  178. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  179. //
  180. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  181. //
  182. // var config []*models.HisXtDiagnoseConfig
  183. // for _, item := range diagnosis_ids {
  184. // id, _ := strconv.ParseInt(item, 10, 64)
  185. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  186. // config = append(config, &diagnosisConfig)
  187. // }
  188. //
  189. // sickConfig, _ := service.FindSickById(sick_type)
  190. //
  191. //
  192. // data := make(map[string]interface{})
  193. // client := &http.Client{}
  194. // data["psn_no"] = his.PsnNo
  195. // data["mdtrt_id"] = his.Number
  196. // data["doctor"] = roles.UserName
  197. // data["department"] = department.Name
  198. // data["org_name"] = miConfig.OrgName
  199. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  200. // data["doctor_id"] = doctor_info.DoctorNumber
  201. // data["new_doctor_name"] = doctor_info.UserName
  202. // data["fixmedins_code"] = miConfig.Code
  203. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  204. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  205. // data["secret_key"] = miConfig.SecretKey
  206. // data["sick_code"] = sickConfig.CountryCode
  207. // data["sick_name"] = sickConfig.ClassName
  208. // data["url"] = miConfig.Url
  209. // data["ak"] = miConfig.AccessKey
  210. // data["begin_time"] = begin_time
  211. // data["cainfo"] = miConfig.Cainfo
  212. // data["is_vaild"] = "0"
  213. //
  214. // data["dept"] = strconv.FormatInt(department.ID, 10)
  215. // data["config"] = config
  216. // bytesData, _ := json.Marshal(data)
  217. //
  218. // var req *http.Request
  219. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  220. // resp, _ := client.Do(req)
  221. // defer resp.Body.Close()
  222. // body, ioErr := ioutil.ReadAll(resp.Body)
  223. // if ioErr != nil {
  224. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  225. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  226. // return
  227. // }
  228. // var respJSON map[string]interface{}
  229. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  230. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  231. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  232. // return
  233. // }
  234. //
  235. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  236. // userJSONBytes, _ := json.Marshal(respJSON)
  237. // fmt.Println("log")
  238. // fmt.Println(string(userJSONBytes))
  239. //
  240. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  241. // utils.ErrorLog("解析失败:%v", err)
  242. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  243. // return
  244. // }
  245. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  246. // res2.Output = ressix10265.Output
  247. // res2.ErrMsg = ressix10265.ErrMsg
  248. // res2.Cainfo = ressix10265.Cainfo
  249. // res2.WarnMsg = ressix10265.WarnMsg
  250. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  251. // res2.Infcode = infocode
  252. //
  253. //}
  254. func (c *HisApiController) Get4102() {
  255. order_id, _ := c.GetInt64("order_id")
  256. admin_user_id, _ := c.GetInt64("admin_user_id")
  257. stas_type := c.GetString("stas_type")
  258. order, _ := service.GetHisOrderByIDTwo(order_id)
  259. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  260. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  261. var pp models.PublicParams
  262. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  263. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  264. pp.FixmedinsName = miConfig.OrgName
  265. pp.FixmedinsCode = miConfig.Code
  266. pp.RequestUrl = miConfig.Url
  267. pp.Cainfo = miConfig.Cainfo
  268. pp.SecretKey = miConfig.SecretKey
  269. pp.AccessKey = miConfig.AccessKey
  270. pp.OpterName = curRoles.UserName
  271. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  272. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  273. saveLog(result, request, "4102", "清单确认")
  274. var dat map[string]interface{}
  275. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  276. fmt.Println(dat)
  277. } else {
  278. fmt.Println(err)
  279. }
  280. var empty ResultFourteen
  281. userJSONBytes, _ := json.Marshal(dat)
  282. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  283. utils.ErrorLog("解析失败:%v", err)
  284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  285. return
  286. }
  287. if empty.Infcode == 0 {
  288. c.ServeSuccessJSON(map[string]interface{}{
  289. "msg": "确认成功",
  290. })
  291. return
  292. }
  293. }
  294. // 对账权限查询
  295. func (c *HisApiController) Get3260() {
  296. admin_user_id, _ := c.GetInt64("admin_user_id")
  297. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  298. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  299. var api string
  300. var res models.JSResult3260
  301. if miConfig.MdtrtareaAdmvs == "320921" {
  302. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  303. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  304. } else {
  305. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  306. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  307. }
  308. resp, requestErr := http.Get(api)
  309. if requestErr != nil {
  310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  311. return
  312. }
  313. body, ioErr := ioutil.ReadAll(resp.Body)
  314. if ioErr != nil {
  315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  317. return
  318. }
  319. var respJSON map[string]interface{}
  320. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  323. return
  324. }
  325. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  326. result, _ := json.Marshal(respJSON)
  327. if err := json.Unmarshal([]byte(result), &res); err != nil {
  328. utils.ErrorLog("解析失败:%v", err)
  329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  330. return
  331. }
  332. if res.Infcode == "0" {
  333. c.ServeSuccessJSON(map[string]interface{}{
  334. "result": res.Output.Data,
  335. })
  336. } else {
  337. c.ServeSuccessJSON(map[string]interface{}{
  338. "failed_code": -10,
  339. "msg": res.ErrMsg,
  340. })
  341. return
  342. }
  343. }
  344. func (c *HisApiController) Get3261() {
  345. admin_user_id, _ := c.GetInt64("admin_user_id")
  346. //month := c.GetString("month")
  347. startTime := c.GetString("start_time")
  348. //endTime, _ := c.GetString("end_time")
  349. times := strings.Split(startTime, "-")
  350. stmt_mon := times[0] + times[1]
  351. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  352. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  353. var api string
  354. var res models.JSResult3261
  355. //var res10265 Result5301For10265
  356. if miConfig.MdtrtareaAdmvs == "320921" {
  357. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  358. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  359. } else {
  360. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  361. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  362. }
  363. resp, requestErr := http.Get(api)
  364. if requestErr != nil {
  365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  366. return
  367. }
  368. body, ioErr := ioutil.ReadAll(resp.Body)
  369. if ioErr != nil {
  370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  372. return
  373. }
  374. var respJSON map[string]interface{}
  375. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  378. return
  379. }
  380. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  381. result, _ := json.Marshal(respJSON)
  382. if err := json.Unmarshal([]byte(result), &res); err != nil {
  383. utils.ErrorLog("解析失败:%v", err)
  384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  385. return
  386. }
  387. if res.Infcode == "0" {
  388. c.ServeSuccessJSON(map[string]interface{}{
  389. "result": res.Output,
  390. })
  391. } else {
  392. c.ServeSuccessJSON(map[string]interface{}{
  393. "failed_code": -10,
  394. "msg": res.ErrMsg,
  395. })
  396. return
  397. }
  398. }
  399. type TempFun struct {
  400. FundKey string
  401. FundCode string
  402. }
  403. func (c *HisApiController) Get3262() {
  404. admin_user_id, _ := c.GetInt64("admin_user_id")
  405. startTime := c.GetString("start_time")
  406. endTime := c.GetString("end_time")
  407. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  408. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  409. //timeLayout := "2006-01-02"
  410. //loc, _ := time.LoadLocation("Local")
  411. //var theStartTIme int64
  412. //if len(startTime) > 0 {
  413. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  414. // if err != nil {
  415. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  416. // return
  417. // }
  418. // theStartTIme = theTime.Unix()
  419. //}
  420. //var theEndtTIme int64
  421. //if len(endTime) > 0 {
  422. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  423. // if err != nil {
  424. // utils.ErrorLog(err.Error())
  425. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  426. // return
  427. // }
  428. // theEndtTIme = theTime.Unix()
  429. //}
  430. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  431. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  432. for _, team := range datas {
  433. fmt.Println(team.PsnTime)
  434. for _, team_two := range datas_two {
  435. fmt.Println(team_two.PsnTime)
  436. if team.FundKey == team_two.FundKey {
  437. fmt.Println(team_two.PsnTime)
  438. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  439. fmt.Println(team.PsnTime)
  440. }
  441. }
  442. }
  443. fmt.Println("1111")
  444. fmt.Println(datas)
  445. fmt.Println("1111")
  446. var twos []models.FixMonRecDetailFileInTwo
  447. for _, team := range datas {
  448. var two models.FixMonRecDetailFileInTwo
  449. two.MedType = team.MedType
  450. two.Insutype = team.Insutype
  451. two.PsnType = team.PsnType
  452. two.MedType = team.MedType
  453. two.FixBlngAdmdvs = "999999"
  454. two.InsuAdmdvs = "555555"
  455. two.PsnTime = team.PsnTime
  456. two.PsnCnt = team.PsnCnt
  457. two.FundKey = team.FundKey
  458. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  459. fps, _ := strconv.ParseFloat(team.Fund, 64)
  460. ia, _ := strconv.ParseFloat(team.Amt, 64)
  461. two.MedfeeSumAmt = ms
  462. two.InscpAmt = ia
  463. two.FundPaySumAmt = fps
  464. twos = append(twos, two)
  465. }
  466. //startTime := c.GetString("start_time")
  467. //endTime, _ := c.GetString("end_time")
  468. times := strings.Split(startTime, "-")
  469. stmt_mon := times[0] + times[1]
  470. var funs []models.FundDetail
  471. for _, item := range datas {
  472. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  473. funs = append(funs, fun...)
  474. }
  475. var funInfos []models.Fund
  476. for _, item := range funs {
  477. var rf []models.FundInfo
  478. json.Unmarshal([]byte(item.SetlDetail), &rf)
  479. for _, subitem := range rf {
  480. var fund models.Fund
  481. fund.FundCode = subitem.FundPayType
  482. fund.FundName = subitem.FundPayTypeName
  483. fund.FundAmt = subitem.FundPayAmt
  484. fund.FundKey = item.FundKey
  485. fund.InsuAdmdvs = "555555"
  486. fund.FixBlngAdmdvs = "999999"
  487. funInfos = append(funInfos, fund)
  488. }
  489. }
  490. var tempFuns []TempFun
  491. for _, funInfo := range funInfos {
  492. var tempFun TempFun
  493. tempFun.FundKey = funInfo.FundKey
  494. tempFun.FundCode = funInfo.FundCode
  495. tempFuns = append(tempFuns, tempFun)
  496. }
  497. tempFuns = RemoveRepeatedFunElement(tempFuns)
  498. fmt.Println(tempFuns)
  499. var funInfosTwo []models.Fund
  500. decimal.DivisionPrecision = 2
  501. for _, item := range tempFuns {
  502. var fund models.Fund
  503. for _, subItem := range funInfos {
  504. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  505. fund.FundKey = subItem.FundKey
  506. fund.InsuAdmdvs = subItem.InsuAdmdvs
  507. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  508. fund.FundName = subItem.FundName
  509. fund.FundCode = subItem.FundCode
  510. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  511. }
  512. }
  513. funInfosTwo = append(funInfosTwo, fund)
  514. }
  515. fmt.Println("funInfosTwo")
  516. fmt.Println(funInfosTwo)
  517. var upld_btch string
  518. var empty models.JSResultEmpty
  519. data := make(map[string]interface{})
  520. data["org_name"] = miConfig.OrgName
  521. data["doctor"] = curRoles.UserName
  522. data["doctor_name"] = curRoles.UserName
  523. data["fixmedins_code"] = miConfig.Code
  524. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  525. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  526. data["secret_key"] = miConfig.SecretKey
  527. data["url"] = miConfig.Url
  528. data["ak"] = miConfig.AccessKey
  529. data["cainfo"] = miConfig.Cainfo
  530. data["datas"] = twos
  531. data["fund"] = funInfosTwo
  532. fmt.Println(twos)
  533. month := time.Unix(1557042972, 0).Format("1")
  534. year := time.Now().Format("2006")
  535. month = time.Now().Format("01")
  536. day := time.Now().Format("02")
  537. hour := time.Now().Format("15")
  538. min := time.Now().Format("04")
  539. sec := time.Now().Format("05")
  540. fix_fill_date := year + month + day + hour + min + sec
  541. data["fix_fill_dept"] = miConfig.OrgName
  542. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  543. data["fix_fill_psn"] = curRoles.UserName
  544. data["fix_fill_date"] = fix_fill_date
  545. data["stmt_loc"] = "2"
  546. data["setl_mon"] = stmt_mon
  547. upld_btch = "0"
  548. data["upld_btch"] = upld_btch
  549. //fmt.Println(data)
  550. client := &http.Client{}
  551. bytesData, _ := json.Marshal(data)
  552. var req *http.Request
  553. if miConfig.MdtrtareaAdmvs == "320921" {
  554. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  555. } else {
  556. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  557. }
  558. resp, _ := client.Do(req)
  559. defer resp.Body.Close()
  560. body, ioErr := ioutil.ReadAll(resp.Body)
  561. if ioErr != nil {
  562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  564. }
  565. var respJSON map[string]interface{}
  566. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  569. }
  570. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  571. //fmt.Println(respJSON)
  572. result, _ := json.Marshal(respJSON)
  573. //fmt.Println(result)
  574. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  575. utils.ErrorLog("解析失败:%v", err)
  576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  577. }
  578. if empty.Infcode != "0" {
  579. c.ServeSuccessJSON(map[string]interface{}{
  580. "failed_code": -10,
  581. "msg": empty.ErrMsg,
  582. })
  583. return
  584. } else {
  585. c.ServeSuccessJSON(map[string]interface{}{
  586. "msg": "上传成功",
  587. })
  588. return
  589. }
  590. }
  591. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  592. newArr = make([]TempFun, 0)
  593. for i := 0; i < len(arr); i++ {
  594. repeat := false
  595. for j := i + 1; j < len(arr); j++ {
  596. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  597. repeat = true
  598. break
  599. }
  600. }
  601. if !repeat {
  602. newArr = append(newArr, arr[i])
  603. }
  604. }
  605. return
  606. }
  607. func (c *HisApiController) Get3263() {
  608. admin_user_id, _ := c.GetInt64("admin_user_id")
  609. startTime := c.GetString("start_time")
  610. //endTime, _ := c.GetString("end_time")
  611. times := strings.Split(startTime, "-")
  612. setl_mon := times[0] + times[1]
  613. upld_btch := "0"
  614. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  615. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  616. var result3263 models.JSResult3263
  617. data := make(map[string]interface{})
  618. data["org_name"] = miConfig.OrgName
  619. data["doctor"] = curRoles.UserName
  620. data["doctor_name"] = curRoles.UserName
  621. data["fixmedins_code"] = miConfig.Code
  622. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  623. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  624. data["secret_key"] = miConfig.SecretKey
  625. data["url"] = miConfig.Url
  626. data["ak"] = miConfig.AccessKey
  627. data["cainfo"] = miConfig.Cainfo
  628. data["setl_mon"] = setl_mon
  629. data["stmt_loc"] = "2"
  630. data["upld_btch"] = upld_btch
  631. client := &http.Client{}
  632. bytesData, _ := json.Marshal(data)
  633. var req *http.Request
  634. if miConfig.MdtrtareaAdmvs == "320921" {
  635. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  636. } else {
  637. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  638. }
  639. resp, _ := client.Do(req)
  640. defer resp.Body.Close()
  641. body, ioErr := ioutil.ReadAll(resp.Body)
  642. if ioErr != nil {
  643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  645. }
  646. var respJSON map[string]interface{}
  647. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  650. }
  651. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  652. fmt.Println(respJSON)
  653. result, _ := json.Marshal(respJSON)
  654. fmt.Println(result)
  655. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  656. utils.ErrorLog("解析失败:%v", err)
  657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  658. }
  659. if result3263.Infcode != "0" {
  660. c.ServeSuccessJSON(map[string]interface{}{
  661. "failed_code": -10,
  662. "msg": result3263.ErrMsg,
  663. })
  664. return
  665. } else {
  666. c.ServeSuccessJSON(map[string]interface{}{
  667. "list": result3263.Output,
  668. })
  669. return
  670. }
  671. }
  672. func (c *HisApiController) Get3264() {
  673. admin_user_id, _ := c.GetInt64("admin_user_id")
  674. startTime := c.GetString("start_time")
  675. //endTime, _ := c.GetString("end_time")
  676. times := strings.Split(startTime, "-")
  677. setl_mon := times[0] + times[1]
  678. upld_btch := "0"
  679. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  680. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  681. //solidify_id := []
  682. var result3263 models.JSResult3263
  683. data := make(map[string]interface{})
  684. data["org_name"] = miConfig.OrgName
  685. data["doctor"] = curRoles.UserName
  686. data["doctor_name"] = curRoles.UserName
  687. data["fixmedins_code"] = miConfig.Code
  688. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  689. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  690. data["secret_key"] = miConfig.SecretKey
  691. data["url"] = miConfig.Url
  692. data["ak"] = miConfig.AccessKey
  693. data["cainfo"] = miConfig.Cainfo
  694. data["setl_mon"] = setl_mon
  695. data["stmt_loc"] = "2"
  696. data["upld_btch"] = upld_btch
  697. client := &http.Client{}
  698. bytesData, _ := json.Marshal(data)
  699. var req3263 *http.Request
  700. if miConfig.MdtrtareaAdmvs == "320921" {
  701. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  702. } else {
  703. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  704. }
  705. resp, _ := client.Do(req3263)
  706. defer resp.Body.Close()
  707. body, ioErr := ioutil.ReadAll(resp.Body)
  708. if ioErr != nil {
  709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  711. }
  712. var respJSON3263 map[string]interface{}
  713. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  716. }
  717. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  718. fmt.Println(respJSON3263)
  719. result, _ := json.Marshal(respJSON3263)
  720. fmt.Println(result)
  721. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  722. utils.ErrorLog("解析失败:%v", err)
  723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  724. }
  725. var ids []string
  726. for _, item := range result3263.Output {
  727. ids = append(ids, item.SolidifyID)
  728. }
  729. var empty models.JSResultEmpty
  730. data2 := make(map[string]interface{})
  731. data2["org_name"] = miConfig.OrgName
  732. data2["doctor"] = curRoles.UserName
  733. data2["doctor_name"] = curRoles.UserName
  734. data2["fixmedins_code"] = miConfig.Code
  735. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  736. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  737. data2["secret_key"] = miConfig.SecretKey
  738. data2["url"] = miConfig.Url
  739. data2["ak"] = miConfig.AccessKey
  740. data2["cainfo"] = miConfig.Cainfo
  741. data2["setl_mon"] = setl_mon
  742. data2["stmt_loc"] = "2"
  743. data2["upld_btch"] = upld_btch
  744. data2["solidify_id"] = ids
  745. client2 := &http.Client{}
  746. bytesData2, _ := json.Marshal(data2)
  747. var req *http.Request
  748. if miConfig.MdtrtareaAdmvs == "320921" {
  749. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  750. } else {
  751. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  752. }
  753. resp2, _ := client2.Do(req)
  754. defer resp.Body.Close()
  755. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  756. if ioErr2 != nil {
  757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  759. }
  760. var respJSON map[string]interface{}
  761. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  764. }
  765. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  766. fmt.Println(respJSON)
  767. result2, _ := json.Marshal(respJSON)
  768. fmt.Println(result2)
  769. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  770. utils.ErrorLog("解析失败:%v", err)
  771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  772. }
  773. if empty.Infcode != "0" {
  774. c.ServeSuccessJSON(map[string]interface{}{
  775. "failed_code": -10,
  776. "msg": empty.ErrMsg,
  777. })
  778. return
  779. } else {
  780. c.ServeSuccessJSON(map[string]interface{}{
  781. "msg": "",
  782. })
  783. return
  784. }
  785. }
  786. func (c *HisApiController) Get3265() {
  787. admin_user_id, _ := c.GetInt64("admin_user_id")
  788. startTime := c.GetString("start_time")
  789. //endTime, _ := c.GetString("end_time")
  790. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  791. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  792. times := strings.Split(startTime, "-")
  793. setl_mon := times[0] + times[1]
  794. var upld_btch string
  795. upld_btch = "0"
  796. //var empty models.JSResultEmpty
  797. var result3265 models.JSResult3264
  798. var result3263 models.JSResult3263
  799. data2 := make(map[string]interface{})
  800. data2["org_name"] = miConfig.OrgName
  801. data2["doctor"] = curRoles.UserName
  802. data2["doctor_name"] = curRoles.UserName
  803. data2["fixmedins_code"] = miConfig.Code
  804. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  805. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  806. data2["secret_key"] = miConfig.SecretKey
  807. data2["url"] = miConfig.Url
  808. data2["ak"] = miConfig.AccessKey
  809. data2["cainfo"] = miConfig.Cainfo
  810. data2["setl_mon"] = setl_mon
  811. data2["stmt_loc"] = "2"
  812. data2["upld_btch"] = upld_btch
  813. client2 := &http.Client{}
  814. bytesData2, _ := json.Marshal(data2)
  815. var req3263 *http.Request
  816. if miConfig.MdtrtareaAdmvs == "320921" {
  817. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  818. } else {
  819. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  820. }
  821. resp2, _ := client2.Do(req3263)
  822. defer resp2.Body.Close()
  823. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  824. if ioErr2 != nil {
  825. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  827. }
  828. var respJSON3263 map[string]interface{}
  829. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  832. }
  833. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  834. fmt.Println(respJSON3263)
  835. result2, _ := json.Marshal(respJSON3263)
  836. fmt.Println(result2)
  837. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  838. utils.ErrorLog("解析失败:%v", err)
  839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  840. }
  841. var ids []string
  842. for _, item := range result3263.Output {
  843. ids = append(ids, item.SolidifyID)
  844. }
  845. data := make(map[string]interface{})
  846. data["org_name"] = miConfig.OrgName
  847. data["doctor"] = curRoles.UserName
  848. data["doctor_name"] = curRoles.UserName
  849. data["fixmedins_code"] = miConfig.Code
  850. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  851. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  852. data["secret_key"] = miConfig.SecretKey
  853. data["url"] = miConfig.Url
  854. data["ak"] = miConfig.AccessKey
  855. data["cainfo"] = miConfig.Cainfo
  856. data["setl_mon"] = setl_mon
  857. data["solidify_id"] = ids
  858. month := time.Unix(1557042972, 0).Format("1")
  859. year := time.Now().Format("2006")
  860. month = time.Now().Format("01")
  861. day := time.Now().Format("02")
  862. hour := time.Now().Format("15")
  863. min := time.Now().Format("04")
  864. sec := time.Now().Format("05")
  865. fix_fill_date := year + month + day + hour + min + sec
  866. data["fix_fill_dept"] = miConfig.OrgName
  867. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  868. data["fix_fill_psn"] = curRoles.UserName
  869. data["fix_fill_date"] = fix_fill_date
  870. data["stmt_loc"] = "2"
  871. data["upld_btch"] = upld_btch
  872. client := &http.Client{}
  873. bytesData, _ := json.Marshal(data)
  874. var req *http.Request
  875. if miConfig.MdtrtareaAdmvs == "320921" {
  876. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  877. } else {
  878. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  879. }
  880. resp, _ := client.Do(req)
  881. defer resp.Body.Close()
  882. body, ioErr := ioutil.ReadAll(resp.Body)
  883. if ioErr != nil {
  884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  886. }
  887. var respJSON map[string]interface{}
  888. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  891. }
  892. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  893. fmt.Println(respJSON)
  894. result, _ := json.Marshal(respJSON)
  895. fmt.Println(result)
  896. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  897. utils.ErrorLog("解析失败:%v", err)
  898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  899. }
  900. if result3265.Infcode != "0" {
  901. c.ServeSuccessJSON(map[string]interface{}{
  902. "failed_code": -10,
  903. "msg": result3265.ErrMsg,
  904. })
  905. return
  906. } else {
  907. c.ServeSuccessJSON(map[string]interface{}{
  908. "info": result3265.Output,
  909. })
  910. return
  911. }
  912. }
  913. func (c *HisApiController) Get3266() {
  914. admin_user_id, _ := c.GetInt64("admin_user_id")
  915. startTime := c.GetString("start_time")
  916. //endTime, _ := c.GetString("end_time")
  917. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  918. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  919. times := strings.Split(startTime, "-")
  920. stmt_mon := times[0] + times[1]
  921. var upld_btch string
  922. //var empty models.JSResultEmpty
  923. var result3265 models.JSResult3264
  924. data := make(map[string]interface{})
  925. data["org_name"] = miConfig.OrgName
  926. data["doctor"] = curRoles.UserName
  927. data["doctor_name"] = curRoles.UserName
  928. data["fixmedins_code"] = miConfig.Code
  929. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  930. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  931. data["secret_key"] = miConfig.SecretKey
  932. data["url"] = miConfig.Url
  933. data["ak"] = miConfig.AccessKey
  934. data["cainfo"] = miConfig.Cainfo
  935. data["setl_mon"] = stmt_mon
  936. month := time.Unix(1557042972, 0).Format("1")
  937. year := time.Now().Format("2006")
  938. month = time.Now().Format("01")
  939. day := time.Now().Format("02")
  940. hour := time.Now().Format("15")
  941. min := time.Now().Format("04")
  942. sec := time.Now().Format("05")
  943. fix_fill_date := year + month + day + hour + min + sec
  944. data["fix_fill_dept"] = miConfig.OrgName
  945. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  946. data["fix_fill_psn"] = curRoles.UserName
  947. data["fix_fill_date"] = fix_fill_date
  948. data["stmt_loc"] = "2"
  949. upld_btch = "0"
  950. data["upld_btch"] = upld_btch
  951. client := &http.Client{}
  952. bytesData, _ := json.Marshal(data)
  953. var req *http.Request
  954. if miConfig.MdtrtareaAdmvs == "320921" {
  955. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  956. } else {
  957. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  958. }
  959. resp, _ := client.Do(req)
  960. defer resp.Body.Close()
  961. body, ioErr := ioutil.ReadAll(resp.Body)
  962. if ioErr != nil {
  963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  965. }
  966. var respJSON map[string]interface{}
  967. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  970. }
  971. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  972. fmt.Println(respJSON)
  973. result, _ := json.Marshal(respJSON)
  974. fmt.Println(result)
  975. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  976. utils.ErrorLog("解析失败:%v", err)
  977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  978. }
  979. if result3265.Infcode != "0" {
  980. c.ServeSuccessJSON(map[string]interface{}{
  981. "failed_code": -10,
  982. "msg": result3265.ErrMsg,
  983. })
  984. return
  985. } else {
  986. c.ServeSuccessJSON(map[string]interface{}{
  987. "info": result3265.Output,
  988. })
  989. return
  990. }
  991. }
  992. func (c *HisApiController) Get3267() {
  993. admin_user_id, _ := c.GetInt64("admin_user_id")
  994. startTime := c.GetString("start_time")
  995. //endTime, _ := c.GetString("end_time")
  996. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  997. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  998. times := strings.Split(startTime, "-")
  999. setl_mon := times[0] + times[1]
  1000. var upld_btch string
  1001. //var empty models.JSResultEmpty
  1002. var result3265 models.JSResult3264
  1003. upld_btch = "0"
  1004. data := make(map[string]interface{})
  1005. data["org_name"] = miConfig.OrgName
  1006. data["doctor"] = curRoles.UserName
  1007. data["doctor_name"] = curRoles.UserName
  1008. data["fixmedins_code"] = miConfig.Code
  1009. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1010. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1011. data["secret_key"] = miConfig.SecretKey
  1012. data["url"] = miConfig.Url
  1013. data["ak"] = miConfig.AccessKey
  1014. data["cainfo"] = miConfig.Cainfo
  1015. data["setl_mon"] = setl_mon
  1016. data["stmt_loc"] = "2"
  1017. data["upld_btch"] = upld_btch
  1018. client := &http.Client{}
  1019. bytesData, _ := json.Marshal(data)
  1020. var req *http.Request
  1021. if miConfig.MdtrtareaAdmvs == "320921" {
  1022. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1023. } else {
  1024. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1025. }
  1026. resp, _ := client.Do(req)
  1027. defer resp.Body.Close()
  1028. body, ioErr := ioutil.ReadAll(resp.Body)
  1029. if ioErr != nil {
  1030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1032. }
  1033. var respJSON map[string]interface{}
  1034. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1037. }
  1038. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1039. fmt.Println(respJSON)
  1040. result, _ := json.Marshal(respJSON)
  1041. fmt.Println(result)
  1042. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1043. utils.ErrorLog("解析失败:%v", err)
  1044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1045. }
  1046. if result3265.Infcode != "0" {
  1047. c.ServeSuccessJSON(map[string]interface{}{
  1048. "failed_code": -10,
  1049. "msg": result3265.ErrMsg,
  1050. })
  1051. return
  1052. } else {
  1053. c.ServeSuccessJSON(map[string]interface{}{
  1054. "info": result3265.Output.Data,
  1055. })
  1056. return
  1057. }
  1058. }
  1059. func (c *HisApiController) Get3268() {
  1060. admin_user_id, _ := c.GetInt64("admin_user_id")
  1061. startTime := c.GetString("start_time")
  1062. endTime := c.GetString("end_time")
  1063. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1064. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1065. times := strings.Split(startTime, "-")
  1066. setl_mon := times[0] + times[1]
  1067. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1068. var twos []models.FixMonRecDetailFileInTwo
  1069. var funs []models.FundDetail
  1070. for _, item := range datas {
  1071. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1072. funs = append(funs, fun...)
  1073. }
  1074. var funInfos []models.Fund
  1075. for _, item := range funs {
  1076. var rf []models.FundInfo
  1077. json.Unmarshal([]byte(item.SetlDetail), &rf)
  1078. for _, subitem := range rf {
  1079. var fund models.Fund
  1080. fund.FundCode = subitem.FundPayType
  1081. fund.FundName = subitem.FundPayTypeName
  1082. fund.FundAmt = subitem.FundPayAmt
  1083. fund.FundKey = item.FundKey
  1084. fund.InsuAdmdvs = "555555"
  1085. fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  1086. funInfos = append(funInfos, fund)
  1087. }
  1088. }
  1089. for _, team := range datas {
  1090. var two models.FixMonRecDetailFileInTwo
  1091. two.SetlDate = time.Now().Format("2006-01-02")
  1092. two.MedType = team.MedType
  1093. two.Insutype = team.Insutype
  1094. two.PsnType = team.PsnType
  1095. two.MedType = team.MedType
  1096. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  1097. two.InsuAdmdvs = team.InsuAdmdvs
  1098. two.PsnTime = team.PsnTime
  1099. two.PsnCnt = team.PsnCnt
  1100. two.FundKey = team.FundKey
  1101. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1102. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1103. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1104. two.MedfeeSumAmt = ms
  1105. two.InscpAmt = ia
  1106. two.FundPaySumAmt = fps
  1107. twos = append(twos, two)
  1108. }
  1109. var upld_btch string
  1110. upld_btch = "0"
  1111. var empty models.JSResultEmpty
  1112. data := make(map[string]interface{})
  1113. data["org_name"] = miConfig.OrgName
  1114. data["doctor"] = curRoles.UserName
  1115. data["doctor_name"] = curRoles.UserName
  1116. data["fixmedins_code"] = miConfig.Code
  1117. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1118. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1119. data["secret_key"] = miConfig.SecretKey
  1120. data["url"] = miConfig.Url
  1121. data["ak"] = miConfig.AccessKey
  1122. data["cainfo"] = miConfig.Cainfo
  1123. data["datas"] = twos
  1124. data["fund"] = funInfos
  1125. data["setl_mon"] = setl_mon
  1126. month := time.Unix(1557042972, 0).Format("1")
  1127. year := time.Now().Format("2006")
  1128. month = time.Now().Format("01")
  1129. day := time.Now().Format("02")
  1130. hour := time.Now().Format("15")
  1131. min := time.Now().Format("04")
  1132. sec := time.Now().Format("05")
  1133. fix_fill_date := year + month + day + hour + min + sec
  1134. data["fix_fill_dept"] = miConfig.OrgName
  1135. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1136. data["fix_fill_psn"] = curRoles.UserName
  1137. data["fix_fill_date"] = fix_fill_date
  1138. data["stmt_loc"] = "2"
  1139. data["upld_btch"] = upld_btch
  1140. client := &http.Client{}
  1141. bytesData, _ := json.Marshal(data)
  1142. var req *http.Request
  1143. if miConfig.MdtrtareaAdmvs == "320921" {
  1144. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1145. } else {
  1146. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1147. }
  1148. resp, _ := client.Do(req)
  1149. defer resp.Body.Close()
  1150. body, ioErr := ioutil.ReadAll(resp.Body)
  1151. if ioErr != nil {
  1152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1154. }
  1155. var respJSON map[string]interface{}
  1156. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1159. }
  1160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1161. fmt.Println(respJSON)
  1162. result, _ := json.Marshal(respJSON)
  1163. fmt.Println(result)
  1164. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1165. utils.ErrorLog("解析失败:%v", err)
  1166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1167. }
  1168. if empty.Infcode != "0" {
  1169. c.ServeSuccessJSON(map[string]interface{}{
  1170. "failed_code": -10,
  1171. "msg": empty.ErrMsg,
  1172. })
  1173. return
  1174. } else {
  1175. c.ServeSuccessJSON(map[string]interface{}{
  1176. "msg": "上传成功",
  1177. })
  1178. return
  1179. }
  1180. }
  1181. func (c *HisApiController) Get3269() {
  1182. admin_user_id, _ := c.GetInt64("admin_user_id")
  1183. startTime := c.GetString("start_time")
  1184. //endTime, _ := c.GetString("end_time")
  1185. times := strings.Split(startTime, "-")
  1186. setl_mon := times[0] + times[1]
  1187. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1188. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1189. var result3263 models.JSResult3263
  1190. data := make(map[string]interface{})
  1191. data["org_name"] = miConfig.OrgName
  1192. data["doctor"] = curRoles.UserName
  1193. data["doctor_name"] = curRoles.UserName
  1194. data["fixmedins_code"] = miConfig.Code
  1195. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1196. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1197. data["secret_key"] = miConfig.SecretKey
  1198. data["url"] = miConfig.Url
  1199. data["ak"] = miConfig.AccessKey
  1200. data["cainfo"] = miConfig.Cainfo
  1201. data["setl_mon"] = setl_mon
  1202. data["stmt_loc"] = "2"
  1203. client := &http.Client{}
  1204. bytesData, _ := json.Marshal(data)
  1205. var req *http.Request
  1206. if miConfig.MdtrtareaAdmvs == "320921" {
  1207. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1208. } else {
  1209. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1210. }
  1211. resp, _ := client.Do(req)
  1212. defer resp.Body.Close()
  1213. body, ioErr := ioutil.ReadAll(resp.Body)
  1214. if ioErr != nil {
  1215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1217. }
  1218. var respJSON map[string]interface{}
  1219. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1222. }
  1223. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1224. fmt.Println(respJSON)
  1225. result, _ := json.Marshal(respJSON)
  1226. fmt.Println(result)
  1227. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1228. utils.ErrorLog("解析失败:%v", err)
  1229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1230. }
  1231. if result3263.Infcode != "0" {
  1232. c.ServeSuccessJSON(map[string]interface{}{
  1233. "failed_code": -10,
  1234. "msg": result3263.ErrMsg,
  1235. })
  1236. return
  1237. } else {
  1238. c.ServeSuccessJSON(map[string]interface{}{
  1239. "msg": "上传成功",
  1240. })
  1241. return
  1242. }
  1243. }
  1244. func (c *HisApiController) Get3270() {
  1245. admin_user_id, _ := c.GetInt64("admin_user_id")
  1246. startTime := c.GetString("start_time")
  1247. //endTime, _ := c.GetString("end_time")
  1248. times := strings.Split(startTime, "-")
  1249. setl_mon := times[0] + times[1]
  1250. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1251. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1252. var result3263 models.JSResult3263
  1253. data2 := make(map[string]interface{})
  1254. data2["org_name"] = miConfig.OrgName
  1255. data2["doctor"] = curRoles.UserName
  1256. data2["doctor_name"] = curRoles.UserName
  1257. data2["fixmedins_code"] = miConfig.Code
  1258. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1259. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1260. data2["secret_key"] = miConfig.SecretKey
  1261. data2["url"] = miConfig.Url
  1262. data2["ak"] = miConfig.AccessKey
  1263. data2["cainfo"] = miConfig.Cainfo
  1264. data2["setl_mon"] = setl_mon
  1265. data2["stmt_loc"] = "2"
  1266. client2 := &http.Client{}
  1267. bytesData2, _ := json.Marshal(data2)
  1268. var req3263 *http.Request
  1269. if miConfig.MdtrtareaAdmvs == "320921" {
  1270. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1271. } else {
  1272. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1273. }
  1274. resp2, _ := client2.Do(req3263)
  1275. defer resp2.Body.Close()
  1276. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1277. if ioErr2 != nil {
  1278. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1280. }
  1281. var respJSON3263 map[string]interface{}
  1282. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1285. }
  1286. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1287. fmt.Println(respJSON3263)
  1288. result2, _ := json.Marshal(respJSON3263)
  1289. fmt.Println(result2)
  1290. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1291. utils.ErrorLog("解析失败:%v", err)
  1292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1293. }
  1294. var ids []string
  1295. for _, item := range result3263.Output {
  1296. ids = append(ids, item.SolidifyID)
  1297. }
  1298. var result3264 models.JSResult3264
  1299. data := make(map[string]interface{})
  1300. data["org_name"] = miConfig.OrgName
  1301. data["doctor"] = curRoles.UserName
  1302. data["doctor_name"] = curRoles.UserName
  1303. data["fixmedins_code"] = miConfig.Code
  1304. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1305. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1306. data["secret_key"] = miConfig.SecretKey
  1307. data["url"] = miConfig.Url
  1308. data["ak"] = miConfig.AccessKey
  1309. data["cainfo"] = miConfig.Cainfo
  1310. data["setl_mon"] = setl_mon
  1311. data["stmt_loc"] = "2"
  1312. data["solidify_id"] = ids
  1313. client := &http.Client{}
  1314. bytesData, _ := json.Marshal(data)
  1315. var req *http.Request
  1316. if miConfig.MdtrtareaAdmvs == "320921" {
  1317. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  1318. } else {
  1319. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  1320. }
  1321. resp, _ := client.Do(req)
  1322. defer resp.Body.Close()
  1323. body, ioErr := ioutil.ReadAll(resp.Body)
  1324. if ioErr != nil {
  1325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1327. }
  1328. var respJSON map[string]interface{}
  1329. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1332. }
  1333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1334. fmt.Println(respJSON)
  1335. result, _ := json.Marshal(respJSON)
  1336. fmt.Println(result)
  1337. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  1338. utils.ErrorLog("解析失败:%v", err)
  1339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1340. }
  1341. if result3264.Infcode != "0" {
  1342. c.ServeSuccessJSON(map[string]interface{}{
  1343. "failed_code": -10,
  1344. "msg": result3264.ErrMsg,
  1345. })
  1346. return
  1347. } else {
  1348. c.ServeSuccessJSON(map[string]interface{}{
  1349. "info": result3264.Output,
  1350. })
  1351. return
  1352. }
  1353. }
  1354. func (c *HisApiController) Get3271() {
  1355. admin_user_id, _ := c.GetInt64("admin_user_id")
  1356. startTime := c.GetString("start_time")
  1357. //endTime, _ := c.GetString("end_time")
  1358. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1359. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1360. times := strings.Split(startTime, "-")
  1361. setl_mon := times[0] + times[1]
  1362. //var empty models.JSResultEmpty
  1363. var result3265 models.JSResult3264
  1364. var result3263 models.JSResult3263
  1365. data2 := make(map[string]interface{})
  1366. data2["org_name"] = miConfig.OrgName
  1367. data2["doctor"] = curRoles.UserName
  1368. data2["doctor_name"] = curRoles.UserName
  1369. data2["fixmedins_code"] = miConfig.Code
  1370. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1371. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1372. data2["secret_key"] = miConfig.SecretKey
  1373. data2["url"] = miConfig.Url
  1374. data2["ak"] = miConfig.AccessKey
  1375. data2["cainfo"] = miConfig.Cainfo
  1376. data2["setl_mon"] = setl_mon
  1377. data2["stmt_loc"] = "2"
  1378. client2 := &http.Client{}
  1379. bytesData2, _ := json.Marshal(data2)
  1380. var req3263 *http.Request
  1381. if miConfig.MdtrtareaAdmvs == "320921" {
  1382. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1383. } else {
  1384. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1385. }
  1386. resp2, _ := client2.Do(req3263)
  1387. defer resp2.Body.Close()
  1388. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1389. if ioErr2 != nil {
  1390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1392. }
  1393. var respJSON3263 map[string]interface{}
  1394. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1397. }
  1398. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1399. fmt.Println(respJSON3263)
  1400. result2, _ := json.Marshal(respJSON3263)
  1401. fmt.Println(result2)
  1402. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1403. utils.ErrorLog("解析失败:%v", err)
  1404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1405. }
  1406. var ids []string
  1407. for _, item := range result3263.Output {
  1408. ids = append(ids, item.SolidifyID)
  1409. }
  1410. data := make(map[string]interface{})
  1411. data["org_name"] = miConfig.OrgName
  1412. data["doctor"] = curRoles.UserName
  1413. data["doctor_name"] = curRoles.UserName
  1414. data["fixmedins_code"] = miConfig.Code
  1415. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1416. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1417. data["secret_key"] = miConfig.SecretKey
  1418. data["url"] = miConfig.Url
  1419. data["ak"] = miConfig.AccessKey
  1420. data["cainfo"] = miConfig.Cainfo
  1421. data["setl_mon"] = setl_mon
  1422. data["solidify_id"] = ids
  1423. month := time.Unix(1557042972, 0).Format("1")
  1424. year := time.Now().Format("2006")
  1425. month = time.Now().Format("01")
  1426. day := time.Now().Format("02")
  1427. hour := time.Now().Format("15")
  1428. min := time.Now().Format("04")
  1429. sec := time.Now().Format("05")
  1430. fix_fill_date := year + month + day + hour + min + sec
  1431. data["fix_fill_dept"] = miConfig.OrgName
  1432. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1433. data["fix_fill_psn"] = curRoles.UserName
  1434. data["fix_fill_date"] = fix_fill_date
  1435. data["stmt_loc"] = "2"
  1436. client := &http.Client{}
  1437. bytesData, _ := json.Marshal(data)
  1438. var req *http.Request
  1439. if miConfig.MdtrtareaAdmvs == "320921" {
  1440. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  1441. } else {
  1442. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  1443. }
  1444. resp, _ := client.Do(req)
  1445. defer resp.Body.Close()
  1446. body, ioErr := ioutil.ReadAll(resp.Body)
  1447. if ioErr != nil {
  1448. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1450. }
  1451. var respJSON map[string]interface{}
  1452. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1455. }
  1456. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1457. fmt.Println(respJSON)
  1458. result, _ := json.Marshal(respJSON)
  1459. fmt.Println(result)
  1460. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1461. utils.ErrorLog("解析失败:%v", err)
  1462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1463. }
  1464. if result3265.Infcode != "0" {
  1465. c.ServeSuccessJSON(map[string]interface{}{
  1466. "failed_code": -10,
  1467. "msg": result3265.ErrMsg,
  1468. })
  1469. return
  1470. } else {
  1471. c.ServeSuccessJSON(map[string]interface{}{
  1472. "info": result3265.Output.Data,
  1473. })
  1474. return
  1475. }
  1476. }
  1477. func (c *HisApiController) Get3272() {
  1478. admin_user_id, _ := c.GetInt64("admin_user_id")
  1479. startTime := c.GetString("start_time")
  1480. //endTime, _ := c.GetString("end_time")
  1481. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1482. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1483. times := strings.Split(startTime, "-")
  1484. setl_mon := times[0] + times[1]
  1485. var upld_btch string
  1486. //var empty models.JSResultEmpty
  1487. var result3265 models.JSResult3264
  1488. data := make(map[string]interface{})
  1489. data["org_name"] = miConfig.OrgName
  1490. data["doctor"] = curRoles.UserName
  1491. data["doctor_name"] = curRoles.UserName
  1492. data["fixmedins_code"] = miConfig.Code
  1493. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1494. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1495. data["secret_key"] = miConfig.SecretKey
  1496. data["url"] = miConfig.Url
  1497. data["ak"] = miConfig.AccessKey
  1498. data["cainfo"] = miConfig.Cainfo
  1499. data["setl_mon"] = setl_mon
  1500. month := time.Unix(1557042972, 0).Format("1")
  1501. year := time.Now().Format("2006")
  1502. month = time.Now().Format("01")
  1503. day := time.Now().Format("02")
  1504. hour := time.Now().Format("15")
  1505. min := time.Now().Format("04")
  1506. sec := time.Now().Format("05")
  1507. fix_fill_date := year + month + day + hour + min + sec
  1508. data["fix_fill_dept"] = miConfig.OrgName
  1509. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1510. data["fix_fill_psn"] = curRoles.UserName
  1511. data["fix_fill_date"] = fix_fill_date
  1512. data["stmt_loc"] = "2"
  1513. data["upld_btch"] = upld_btch
  1514. client := &http.Client{}
  1515. bytesData, _ := json.Marshal(data)
  1516. var req *http.Request
  1517. if miConfig.MdtrtareaAdmvs == "320921" {
  1518. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1519. } else {
  1520. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1521. }
  1522. resp, _ := client.Do(req)
  1523. defer resp.Body.Close()
  1524. body, ioErr := ioutil.ReadAll(resp.Body)
  1525. if ioErr != nil {
  1526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1528. }
  1529. var respJSON map[string]interface{}
  1530. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1533. }
  1534. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1535. fmt.Println(respJSON)
  1536. result, _ := json.Marshal(respJSON)
  1537. fmt.Println(result)
  1538. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1539. utils.ErrorLog("解析失败:%v", err)
  1540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1541. }
  1542. if result3265.Infcode != "0" {
  1543. c.ServeSuccessJSON(map[string]interface{}{
  1544. "failed_code": -10,
  1545. "msg": result3265.ErrMsg,
  1546. })
  1547. return
  1548. } else {
  1549. c.ServeSuccessJSON(map[string]interface{}{
  1550. "info": result3265.Output,
  1551. })
  1552. return
  1553. }
  1554. }
  1555. func (c *HisApiController) Get3273() {
  1556. admin_user_id, _ := c.GetInt64("admin_user_id")
  1557. startTime := c.GetString("start_time")
  1558. //endTime, _ := c.GetString("end_time")
  1559. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1560. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1561. times := strings.Split(startTime, "-")
  1562. setl_mon := times[0] + times[1]
  1563. var result3265 models.JSResult3264
  1564. data := make(map[string]interface{})
  1565. data["org_name"] = miConfig.OrgName
  1566. data["doctor"] = curRoles.UserName
  1567. data["doctor_name"] = curRoles.UserName
  1568. data["fixmedins_code"] = miConfig.Code
  1569. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1570. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1571. data["secret_key"] = miConfig.SecretKey
  1572. data["url"] = miConfig.Url
  1573. data["ak"] = miConfig.AccessKey
  1574. data["cainfo"] = miConfig.Cainfo
  1575. data["setl_mon"] = setl_mon
  1576. data["stmt_loc"] = "2"
  1577. client := &http.Client{}
  1578. bytesData, _ := json.Marshal(data)
  1579. var req *http.Request
  1580. if miConfig.MdtrtareaAdmvs == "320921" {
  1581. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1582. } else {
  1583. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1584. }
  1585. resp, _ := client.Do(req)
  1586. defer resp.Body.Close()
  1587. body, ioErr := ioutil.ReadAll(resp.Body)
  1588. if ioErr != nil {
  1589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1591. }
  1592. var respJSON map[string]interface{}
  1593. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1596. }
  1597. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1598. fmt.Println(respJSON)
  1599. result, _ := json.Marshal(respJSON)
  1600. fmt.Println(result)
  1601. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1602. utils.ErrorLog("解析失败:%v", err)
  1603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1604. }
  1605. if result3265.Infcode != "0" {
  1606. c.ServeSuccessJSON(map[string]interface{}{
  1607. "failed_code": -10,
  1608. "msg": result3265.ErrMsg,
  1609. })
  1610. return
  1611. } else {
  1612. c.ServeSuccessJSON(map[string]interface{}{
  1613. "info": result3265.Output.Data,
  1614. })
  1615. return
  1616. }
  1617. }
  1618. func (c *HisApiController) Get3274() {
  1619. //if miConfig.MdtrtareaAdmvs == "320921" {
  1620. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1621. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1622. // "&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
  1623. //
  1624. //} else {
  1625. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1626. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1627. // "&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
  1628. //
  1629. //}
  1630. }
  1631. func (c *HisApiController) Get3275() {
  1632. //if miConfig.MdtrtareaAdmvs == "320921" {
  1633. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1634. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1635. // "&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
  1636. //
  1637. //} else {
  1638. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  1639. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  1640. // "&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
  1641. //
  1642. //}
  1643. }
  1644. func (c *HisApiController) Get3276() {
  1645. //admin_user_id, _ := c.GetInt64("admin_user_id")
  1646. //month := c.GetString("month")
  1647. //
  1648. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1649. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1650. //var api string
  1651. //var res Result5301
  1652. //
  1653. //if miConfig.MdtrtareaAdmvs == "320921" {
  1654. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1655. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1656. //} else {
  1657. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1658. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1659. //}
  1660. //
  1661. //resp, requestErr := http.Get(api)
  1662. //if requestErr != nil {
  1663. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1664. // return
  1665. //}
  1666. //
  1667. //body, ioErr := ioutil.ReadAll(resp.Body)
  1668. //if ioErr != nil {
  1669. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1671. // return
  1672. //}
  1673. //var respJSON map[string]interface{}
  1674. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1675. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1677. // return
  1678. //}
  1679. //
  1680. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1681. //result, _ := json.Marshal(respJSON)
  1682. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1683. // utils.ErrorLog("解析失败:%v", err)
  1684. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1685. // return
  1686. //}
  1687. }
  1688. func (c *HisApiController) Get3277() {
  1689. //admin_user_id, _ := c.GetInt64("admin_user_id")
  1690. //month := c.GetString("month")
  1691. //
  1692. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1693. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1694. //var api string
  1695. //var res Result5301
  1696. //
  1697. //if miConfig.MdtrtareaAdmvs == "320921" {
  1698. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1699. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1700. //} else {
  1701. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1702. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  1703. //}
  1704. //
  1705. //resp, requestErr := http.Get(api)
  1706. //if requestErr != nil {
  1707. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1708. // return
  1709. //}
  1710. //
  1711. //body, ioErr := ioutil.ReadAll(resp.Body)
  1712. //if ioErr != nil {
  1713. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1714. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1715. // return
  1716. //}
  1717. //var respJSON map[string]interface{}
  1718. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1719. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1720. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1721. // return
  1722. //}
  1723. //
  1724. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1725. //result, _ := json.Marshal(respJSON)
  1726. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1727. // utils.ErrorLog("解析失败:%v", err)
  1728. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1729. // return
  1730. //}
  1731. }
  1732. func (c *HisApiController) GetCFYLJG001() {
  1733. admin_user_id, _ := c.GetInt64("admin_user_id")
  1734. patient_id, _ := c.GetInt64("patient_id")
  1735. his_patient_id, _ := c.GetInt64("his_patient_id")
  1736. record_time := c.GetString("record_time")
  1737. admin_user_id = 3626
  1738. patient_id = 19424
  1739. his_patient_id = 238932
  1740. record_time = "2023-07-03"
  1741. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1742. psn, _ := service.GetPsnByPatientId(patient_id)
  1743. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  1744. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  1745. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1746. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1747. var cFYLJG001 models.CFYLJG001
  1748. timeLayout := "2006-01-02"
  1749. loc, _ := time.LoadLocation("Local")
  1750. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1751. if err != nil {
  1752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1753. return
  1754. }
  1755. recordDateTime := theTime.Unix()
  1756. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  1757. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  1758. for _, item := range prescriptions {
  1759. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  1760. if his.IdCardType == 1 {
  1761. bas := strings.Split(psn.CardInfo, "|")
  1762. basNumber := bas[1]
  1763. fmt.Println(basNumber)
  1764. card_sn := bas[3]
  1765. card_no := bas[2]
  1766. cFYLJG001.MdtrtCertType = "03"
  1767. cFYLJG001.CardSn = card_sn
  1768. cFYLJG001.MdtrtCertNo = card_no
  1769. cFYLJG001.EcToken = ""
  1770. cFYLJG001.AuthNo = ""
  1771. } else if his.IdCardType == 2 {
  1772. cFYLJG001.MdtrtCertType = "02"
  1773. cFYLJG001.CardSn = ""
  1774. cFYLJG001.MdtrtCertNo = his.IdCardNo
  1775. cFYLJG001.EcToken = ""
  1776. cFYLJG001.AuthNo = ""
  1777. } else if his.IdCardType == 4 {
  1778. cFYLJG001.MdtrtCertType = "01"
  1779. cFYLJG001.CardSn = ""
  1780. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  1781. cFYLJG001.EcToken = psn.VerifyNumber
  1782. cFYLJG001.AuthNo = ""
  1783. }
  1784. cFYLJG001.BizTypeCode = "01"
  1785. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  1786. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  1787. cFYLJG001.RxTypeCode = "1"
  1788. tempTime := time.Unix(item.PreTime, 0)
  1789. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1790. cFYLJG001.PrscTime = timeFormatOne
  1791. var count float64
  1792. if item.Type == 1 {
  1793. for _, sumItem := range item.HisDoctorAdviceInfo {
  1794. count = count + sumItem.PrescribingNumber
  1795. }
  1796. }
  1797. cFYLJG001.RxDrugCnt = count
  1798. cFYLJG001.ValiDays = "5"
  1799. ts := time.Unix(item.PreTime, 0)
  1800. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  1801. tempTime3 := time.Unix(record_time2, 0)
  1802. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  1803. cFYLJG001.ValiEndTime = timeFormat3
  1804. cFYLJG001.RxCotnFlag = "0"
  1805. for _, subItem := range item.HisDoctorAdviceInfo {
  1806. var drug models.RxDrug
  1807. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  1808. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  1809. drug.RxItemTypeCode = "11"
  1810. drug.DrugDosform = "乳膏剂" //TODO
  1811. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  1812. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  1813. }
  1814. drug.MedcWayDscr = subItem.DeliveryWay
  1815. tempTime2 := time.Unix(subItem.StartTime, 0)
  1816. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  1817. drug.MedcBegntime = timeFormatTwo
  1818. if subItem.Day > 0 {
  1819. ts := time.Unix(subItem.StartTime, 0)
  1820. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  1821. tempTime4 := time.Unix(record_time, 0)
  1822. timeFormat5 := tempTime4.Format("2006-01-02") + " 23:59:00"
  1823. drug.MedcEndtime = timeFormat5
  1824. } else {
  1825. tempTime2 := time.Unix(subItem.StartTime, 0)
  1826. timeFormatTwo := tempTime2.Format("2006-01-02") + " 23:59:00"
  1827. drug.MedcEndtime = timeFormatTwo
  1828. }
  1829. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  1830. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  1831. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  1832. drug.DrugCnt = subItem.PrescribingNumber
  1833. drug.DrugDosunt = subItem.PrescribingNumberUnit
  1834. drug.DrugGenname = subItem.AdviceName
  1835. drug.MedcWayCodg = subItem.DeliveryWay
  1836. //drug.DrugTotlcnt = subItem.PrescribingNumber
  1837. drug.SinDoscnt = subItem.SingleDose
  1838. drug.SinDosunt = subItem.SingleDoseUnit
  1839. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  1840. drug.UsedFrquName = subItem.ExecutionFrequency
  1841. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1842. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  1843. drug.HospApprFlag = "1"
  1844. cFYLJG001.List = append(cFYLJG001.List, drug)
  1845. }
  1846. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  1847. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  1848. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  1849. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  1850. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  1851. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  1852. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  1853. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  1854. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  1855. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  1856. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  1857. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  1858. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  1859. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  1860. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  1861. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  1862. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  1863. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  1864. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  1865. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  1866. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  1867. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  1868. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  1869. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  1870. tempTime2 := time.Now().Unix()
  1871. tempTime6 := time.Unix(tempTime2, 0)
  1872. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  1873. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  1874. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  1875. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  1876. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  1877. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  1878. memo := make(map[string]interface{})
  1879. memo["insutype"] = his.Insutype
  1880. bytesData, _ := json.Marshal(memo)
  1881. cFYLJG001.Mdtrtinfo.Extras = string(bytesData)
  1882. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  1883. var config []*models.HisXtDiagnoseConfig
  1884. for _, item := range diagnosis_ids {
  1885. id, _ := strconv.ParseInt(item, 10, 64)
  1886. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1887. config = append(config, &diagnosisConfig)
  1888. }
  1889. for index, subitem := range config {
  1890. if index == 0 {
  1891. var dia models.DiseInfo
  1892. dia.DiagType = "1"
  1893. dia.MaindiagFlag = "1"
  1894. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  1895. dia.DiagCode = subitem.CountryCode
  1896. dia.DiagName = subitem.ClassName
  1897. dia.DiagDept = "肾内科"
  1898. dia.DiagDrNo = doctor.DoctorNumber
  1899. dia.DiagDrName = doctor.UserName
  1900. tempTime3 := time.Unix(item.PreTime, 0)
  1901. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  1902. dia.DiagTime = timeFormatTwo
  1903. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  1904. } else {
  1905. var dia models.DiseInfo
  1906. dia.DiagType = "1"
  1907. dia.MaindiagFlag = "0"
  1908. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  1909. dia.DiagCode = subitem.CountryCode
  1910. dia.DiagName = subitem.ClassName
  1911. dia.DiagDept = "肾内科"
  1912. dia.DiagDrNo = doctor.DoctorNumber
  1913. dia.DiagDrName = doctor.UserName
  1914. tempTime3 := time.Unix(item.PreTime, 0)
  1915. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  1916. dia.DiagTime = timeFormatTwo
  1917. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  1918. }
  1919. }
  1920. fmt.Println(cFYLJG001)
  1921. service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001)
  1922. }
  1923. }
  1924. func (c *HisApiController) GetCFYLJG002() {
  1925. admin_user_id, _ := c.GetInt64("admin_user_id")
  1926. id, _ := c.GetInt64("id")
  1927. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1928. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1929. flow, _ := service.Getflow(id)
  1930. his, _ := service.GetHisPatientByNumber(flow.MID)
  1931. inputData := make(map[string]interface{})
  1932. inputData["rxtracecode"] = flow.RxTraceCode
  1933. inputData["hirxno"] = flow.HiRxno
  1934. inputData["mdtrtid"] = flow.MID
  1935. inputData["patnname"] = his.PsnName
  1936. inputData["psncerttype"] = his.PsnCertType
  1937. inputData["certno"] = his.Certno
  1938. inputData["fixmedinsname"] = miConfig.OrgName
  1939. inputData["fixmedinscode"] = miConfig.Code
  1940. inputData["drcode"] = ""
  1941. inputData["prscdrname"] = ""
  1942. inputData["phardeptname"] = ""
  1943. inputData["phardeptcode"] = ""
  1944. inputData["pharprofttlcodg"] = ""
  1945. inputData["pharprofttlname"] = ""
  1946. inputData["pharcode"] = ""
  1947. inputData["rxfrquname"] = ""
  1948. inputData["pharcerttype"] = ""
  1949. inputData["pharcertno"] = ""
  1950. inputData["pharname"] = ""
  1951. inputData["pharpraccertno"] = ""
  1952. inputData["pharchktime"] = ""
  1953. bytesData, _ := json.Marshal(inputData)
  1954. fmt.Println(bytesData)
  1955. //// 使用 SM3 计算 JSON 数据的哈希值
  1956. //hash := sm3.New()
  1957. //hash.Write(bytesData)
  1958. //hashValue := hash.Sum(nil)
  1959. //
  1960. //// 加载 SM2 私钥
  1961. //privateKeyBytes, err := ioutil.ReadFile("path/to/private_key.pem")
  1962. //if err != nil {
  1963. // fmt.Println("Failed to read private key file:", err)
  1964. // return
  1965. //}
  1966. //privateKey, err := sm2.ParsePKCS8PrivateKey(privateKeyBytes)
  1967. //if err != nil {
  1968. // fmt.Println("Failed to parse private key:", err)
  1969. // return
  1970. //}
  1971. //
  1972. //// 使用私钥对哈希值进行签名
  1973. //r, s, err := sm2.Sign(rand.Reader, privateKey.(*sm2.PrivateKey), hashValue, nil)
  1974. //if err != nil {
  1975. // fmt.Println("Failed to sign data:", err)
  1976. // return
  1977. //}
  1978. //signature, err := syntax.EncodeSM2Signature(r, s)
  1979. //if err != nil {
  1980. // fmt.Println("Failed to encode signature:", err)
  1981. // return
  1982. //}
  1983. //
  1984. //// 构建 CMS/PKCS#7 Detached 数据结构
  1985. //// 这里只包含签名值和原始数据
  1986. //signedData := &pkix.ContentInfo{
  1987. // ContentType: pkix.SignedDataOID,
  1988. // Content: &pkix.SignedData{
  1989. // Version: 3,
  1990. // DigestAlgorithms: []pkix.AlgorithmIdentifier{{Algorithm: sm3.OID}},
  1991. // EncapContentInfo: pkix.EncapContentInfo{
  1992. // EContentType: pkix.DataOID,
  1993. // EContent: jsonBytes,
  1994. // },
  1995. // Certificates: []pkix.Certificate{},
  1996. // CRLs: []pkix.CertificateList{},
  1997. // SignerInfos: []pkix.SignerInfo{},
  1998. // DigestEncryptionAlgorithm: pkix.AlgorithmIdentifier{
  1999. // Algorithm: sm2.SignAlgorithmSM2WithSM3,
  2000. // },
  2001. // EncryptedDigest: signature,
  2002. // },
  2003. //}
  2004. //
  2005. //// 使用 DER 编码进行序列化
  2006. //derBytes, err := syntax.Marshal(signedData)
  2007. //if err != nil {
  2008. // fmt.Println("Failed to marshal CMS/PKCS#7 data:", err)
  2009. // return
  2010. //}
  2011. service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "", "", "")
  2012. }
  2013. func (c *HisApiController) GetCFYLJG003() {
  2014. admin_user_id, _ := c.GetInt64("admin_user_id")
  2015. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2016. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2017. var cFYLJG003 models.CFYLJG003
  2018. service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  2019. }
  2020. func (c *HisApiController) GetCFYLJG004() {
  2021. admin_user_id, _ := c.GetInt64("admin_user_id")
  2022. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2023. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2024. var cFYLJG004 models.CFYLJG004
  2025. service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  2026. }
  2027. func (c *HisApiController) GetCFYLJG005() {
  2028. admin_user_id, _ := c.GetInt64("admin_user_id")
  2029. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2030. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2031. var cFYLJG005 models.CFYLJG005
  2032. service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  2033. }
  2034. func (c *HisApiController) GetCFYLJG006() {
  2035. admin_user_id, _ := c.GetInt64("admin_user_id")
  2036. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2037. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2038. var cFYLJG006 models.CFYLJG006
  2039. service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  2040. }
  2041. func (c *HisApiController) GetCFYLJG007() {
  2042. admin_user_id, _ := c.GetInt64("admin_user_id")
  2043. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2044. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2045. var cFYLJG007 models.CFYLJG007
  2046. service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  2047. }
  2048. func (c *HisApiController) GetBL4201A() {
  2049. order_id, _ := c.GetInt64("order_id")
  2050. admin_user_id, _ := c.GetInt64("admin_user_id")
  2051. order, _ := service.GetHisOrderByIDTwo(order_id)
  2052. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2053. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  2054. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  2055. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2056. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2057. department, _ := service.GetDepartMentDetail(his.Departments)
  2058. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  2059. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  2060. if order.ID == 0 {
  2061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2062. return
  2063. }
  2064. var struct4201A models.Struct4201A
  2065. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  2066. for _, items := range order_info {
  2067. memo := make(map[string]interface{})
  2068. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2069. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2070. fsiOPFLD.MedType = "14"
  2071. fsiOPFLD.BkkpSn = items.FeedetlSn
  2072. fsiOPFLD.FixmedinsCode = miConfig.Code
  2073. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2074. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2075. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2076. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2077. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2078. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2079. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2080. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2081. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2082. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2083. fsiOPFLD.BilgDeptName = department.Name
  2084. fsiOPFLD.BilgDeptCodg = department.Number
  2085. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2086. fsiOPFLD.BilgDrName = doctor.UserName
  2087. fsiOPFLD.MedChrgitmType = "09"
  2088. memo["hosp_appr_flag"] = "1"
  2089. memo["invoice_no"] = order.MdtrtId
  2090. memo["memo"] = "自费"
  2091. bytesData, _ := json.Marshal(memo)
  2092. fsiOPFLD.Memo = string(bytesData)
  2093. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2094. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2095. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2096. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2097. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2098. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2099. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2100. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2101. fsiOPFLD.BilgDeptName = department.Name
  2102. fsiOPFLD.BilgDeptCodg = department.Number
  2103. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2104. fsiOPFLD.BilgDrName = doctor.UserName
  2105. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2106. case 0:
  2107. break
  2108. case 1:
  2109. fsiOPFLD.MedChrgitmType = "14"
  2110. break
  2111. case 2:
  2112. fsiOPFLD.MedChrgitmType = "05"
  2113. break
  2114. case 3:
  2115. fsiOPFLD.MedChrgitmType = "03"
  2116. break
  2117. case 4:
  2118. fsiOPFLD.MedChrgitmType = "03"
  2119. break
  2120. case 5:
  2121. fsiOPFLD.MedChrgitmType = "08"
  2122. break
  2123. case 6:
  2124. fsiOPFLD.MedChrgitmType = "14"
  2125. break
  2126. case 7:
  2127. fsiOPFLD.MedChrgitmType = "14"
  2128. break
  2129. case 8:
  2130. fsiOPFLD.MedChrgitmType = "03"
  2131. break
  2132. case 9:
  2133. fsiOPFLD.MedChrgitmType = "14"
  2134. break
  2135. case 10:
  2136. fsiOPFLD.MedChrgitmType = "14"
  2137. break
  2138. case 11:
  2139. fsiOPFLD.MedChrgitmType = "06"
  2140. break
  2141. case 12:
  2142. fsiOPFLD.MedChrgitmType = "12"
  2143. break
  2144. case 13:
  2145. fsiOPFLD.MedChrgitmType = "01"
  2146. break
  2147. case 14:
  2148. fsiOPFLD.MedChrgitmType = "04"
  2149. break
  2150. case 15:
  2151. fsiOPFLD.MedChrgitmType = "14"
  2152. break
  2153. }
  2154. memo["hosp_appr_flag"] = "1"
  2155. memo["invoice_no"] = order.MdtrtId
  2156. memo["memo"] = "自费"
  2157. bytesData, _ := json.Marshal(memo)
  2158. fsiOPFLD.Memo = string(bytesData)
  2159. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2160. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  2161. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2162. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2163. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2164. fsiOPFLD.BilgDeptName = department.Name
  2165. fsiOPFLD.BilgDeptCodg = department.Number
  2166. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2167. fsiOPFLD.BilgDrName = doctor.UserName
  2168. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2169. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2170. fsiOPFLD.MedChrgitmType = "08"
  2171. memo["hosp_appr_flag"] = "1"
  2172. memo["invoice_no"] = order.MdtrtId
  2173. memo["memo"] = "自费"
  2174. bytesData, _ := json.Marshal(memo)
  2175. fsiOPFLD.Memo = string(bytesData)
  2176. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2177. }
  2178. }
  2179. }
  2180. for _, items := range order_info_two {
  2181. memo := make(map[string]interface{})
  2182. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2183. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2184. fsiOPFLD.MedType = "14"
  2185. fsiOPFLD.BkkpSn = items.FeedetlSn
  2186. fsiOPFLD.FixmedinsCode = miConfig.Code
  2187. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2188. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2189. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2190. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2191. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2192. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2193. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2194. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2195. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2196. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2197. fsiOPFLD.BilgDeptName = department.Name
  2198. fsiOPFLD.BilgDeptCodg = department.Number
  2199. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2200. fsiOPFLD.BilgDrName = doctor.UserName
  2201. fsiOPFLD.MedChrgitmType = "09"
  2202. memo["hosp_appr_flag"] = "1"
  2203. memo["invoice_no"] = order.MdtrtId
  2204. memo["memo"] = "自费"
  2205. bytesData, _ := json.Marshal(memo)
  2206. fsiOPFLD.Memo = string(bytesData)
  2207. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2208. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2209. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2210. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2211. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2212. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2213. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2214. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2215. fsiOPFLD.BilgDeptName = department.Name
  2216. fsiOPFLD.BilgDeptCodg = department.Number
  2217. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2218. fsiOPFLD.BilgDrName = doctor.UserName
  2219. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2220. case 0:
  2221. break
  2222. case 1:
  2223. fsiOPFLD.MedChrgitmType = "14"
  2224. break
  2225. case 2:
  2226. fsiOPFLD.MedChrgitmType = "05"
  2227. break
  2228. case 3:
  2229. fsiOPFLD.MedChrgitmType = "03"
  2230. break
  2231. case 4:
  2232. fsiOPFLD.MedChrgitmType = "03"
  2233. break
  2234. case 5:
  2235. fsiOPFLD.MedChrgitmType = "08"
  2236. break
  2237. case 6:
  2238. fsiOPFLD.MedChrgitmType = "14"
  2239. break
  2240. case 7:
  2241. fsiOPFLD.MedChrgitmType = "14"
  2242. break
  2243. case 8:
  2244. fsiOPFLD.MedChrgitmType = "03"
  2245. break
  2246. case 9:
  2247. fsiOPFLD.MedChrgitmType = "14"
  2248. break
  2249. case 10:
  2250. fsiOPFLD.MedChrgitmType = "14"
  2251. break
  2252. case 11:
  2253. fsiOPFLD.MedChrgitmType = "06"
  2254. break
  2255. case 12:
  2256. fsiOPFLD.MedChrgitmType = "12"
  2257. break
  2258. case 13:
  2259. fsiOPFLD.MedChrgitmType = "01"
  2260. break
  2261. case 14:
  2262. fsiOPFLD.MedChrgitmType = "04"
  2263. break
  2264. case 15:
  2265. fsiOPFLD.MedChrgitmType = "14"
  2266. break
  2267. }
  2268. memo["hosp_appr_flag"] = "1"
  2269. memo["invoice_no"] = order.MdtrtId
  2270. memo["memo"] = "自费"
  2271. bytesData, _ := json.Marshal(memo)
  2272. fsiOPFLD.Memo = string(bytesData)
  2273. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2274. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  2275. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2276. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2277. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2278. fsiOPFLD.BilgDeptName = department.Name
  2279. fsiOPFLD.BilgDeptCodg = department.Number
  2280. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2281. fsiOPFLD.BilgDrName = doctor.UserName
  2282. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2283. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2284. fsiOPFLD.MedChrgitmType = "08"
  2285. memo["hosp_appr_flag"] = "1"
  2286. memo["invoice_no"] = order.MdtrtId
  2287. memo["memo"] = "自费"
  2288. bytesData, _ := json.Marshal(memo)
  2289. fsiOPFLD.Memo = string(bytesData)
  2290. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2291. }
  2292. }
  2293. }
  2294. fmt.Println(fsiOPFLDs)
  2295. struct4201A.Fopfd = fsiOPFLDs
  2296. fmt.Println(struct4201A.Fopfd)
  2297. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  2298. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  2299. var res2 ResultSix
  2300. var respJSON2 map[string]interface{}
  2301. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2304. return
  2305. }
  2306. userJSONBytes2, _ := json.Marshal(respJSON2)
  2307. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2308. utils.ErrorLog("解析失败:%v", err)
  2309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2310. return
  2311. }
  2312. if res2.Infcode != 0 {
  2313. c.ServeSuccessJSON(map[string]interface{}{
  2314. "failed_code": -10,
  2315. "msg": res2.ErrMsg,
  2316. })
  2317. return
  2318. } else {
  2319. order.IsUploadOrderInfo = 1
  2320. service.UpdateOrder(order)
  2321. c.ServeSuccessJSON(map[string]interface{}{
  2322. "msg": "上传成功",
  2323. })
  2324. }
  2325. }
  2326. func (c *HisApiController) Get2505() {
  2327. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  2328. service.Gdyb2505("44120000000010585742", "高慧裕", miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2022-12-23 09:00:00", "2023-12-31 23:00:00")
  2329. }
  2330. func (c *HisApiController) Get4201A() {
  2331. order_id, _ := c.GetInt64("order_id")
  2332. admin_user_id, _ := c.GetInt64("admin_user_id")
  2333. order, _ := service.GetHisOrderByIDTwo(order_id)
  2334. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2335. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  2336. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  2337. //order_info = append(order_info, order_info_two...)
  2338. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2339. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2340. department, _ := service.GetDepartMentDetail(his.Departments)
  2341. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  2342. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  2343. if order.ID == 0 {
  2344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2345. return
  2346. }
  2347. var struct4201A models.Struct4201A
  2348. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  2349. for _, items := range order_info {
  2350. memo := make(map[string]interface{})
  2351. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2352. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2353. fsiOPFLD.MedType = "14"
  2354. fsiOPFLD.BkkpSn = items.FeedetlSn
  2355. fsiOPFLD.FixmedinsCode = miConfig.Code
  2356. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2357. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2358. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2359. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2360. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2361. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2362. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2363. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2364. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2365. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2366. fsiOPFLD.BilgDeptName = department.Name
  2367. fsiOPFLD.BilgDeptCodg = department.Number
  2368. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2369. fsiOPFLD.BilgDrName = doctor.UserName
  2370. fsiOPFLD.MedChrgitmType = "09"
  2371. memo["hosp_appr_flag"] = "1"
  2372. memo["invoice_no"] = order.MdtrtId
  2373. memo["memo"] = "自费"
  2374. bytesData, _ := json.Marshal(memo)
  2375. fsiOPFLD.Memo = string(bytesData)
  2376. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2377. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2378. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2379. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2380. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2381. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2382. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2383. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2384. fsiOPFLD.BilgDeptName = department.Name
  2385. fsiOPFLD.BilgDeptCodg = department.Number
  2386. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2387. fsiOPFLD.BilgDrName = doctor.UserName
  2388. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2389. case 0:
  2390. break
  2391. case 1:
  2392. fsiOPFLD.MedChrgitmType = "14"
  2393. break
  2394. case 2:
  2395. fsiOPFLD.MedChrgitmType = "05"
  2396. break
  2397. case 3:
  2398. fsiOPFLD.MedChrgitmType = "03"
  2399. break
  2400. case 4:
  2401. fsiOPFLD.MedChrgitmType = "03"
  2402. break
  2403. case 5:
  2404. fsiOPFLD.MedChrgitmType = "08"
  2405. break
  2406. case 6:
  2407. fsiOPFLD.MedChrgitmType = "14"
  2408. break
  2409. case 7:
  2410. fsiOPFLD.MedChrgitmType = "14"
  2411. break
  2412. case 8:
  2413. fsiOPFLD.MedChrgitmType = "03"
  2414. break
  2415. case 9:
  2416. fsiOPFLD.MedChrgitmType = "14"
  2417. break
  2418. case 10:
  2419. fsiOPFLD.MedChrgitmType = "14"
  2420. break
  2421. case 11:
  2422. fsiOPFLD.MedChrgitmType = "06"
  2423. break
  2424. case 12:
  2425. fsiOPFLD.MedChrgitmType = "12"
  2426. break
  2427. case 13:
  2428. fsiOPFLD.MedChrgitmType = "01"
  2429. break
  2430. case 14:
  2431. fsiOPFLD.MedChrgitmType = "04"
  2432. break
  2433. case 15:
  2434. fsiOPFLD.MedChrgitmType = "14"
  2435. break
  2436. }
  2437. memo["hosp_appr_flag"] = "1"
  2438. memo["invoice_no"] = order.MdtrtId
  2439. memo["memo"] = "自费"
  2440. bytesData, _ := json.Marshal(memo)
  2441. fsiOPFLD.Memo = string(bytesData)
  2442. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2443. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  2444. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2445. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2446. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2447. fsiOPFLD.BilgDeptName = department.Name
  2448. fsiOPFLD.BilgDeptCodg = department.Number
  2449. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2450. fsiOPFLD.BilgDrName = doctor.UserName
  2451. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2452. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2453. fsiOPFLD.MedChrgitmType = "08"
  2454. memo["hosp_appr_flag"] = "1"
  2455. memo["invoice_no"] = order.MdtrtId
  2456. memo["memo"] = "自费"
  2457. bytesData, _ := json.Marshal(memo)
  2458. fsiOPFLD.Memo = string(bytesData)
  2459. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2460. }
  2461. }
  2462. }
  2463. for _, items := range order_info_two {
  2464. memo := make(map[string]interface{})
  2465. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2466. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2467. fsiOPFLD.MedType = "14"
  2468. fsiOPFLD.BkkpSn = items.FeedetlSn
  2469. fsiOPFLD.FixmedinsCode = miConfig.Code
  2470. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2471. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2472. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2473. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2474. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2475. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2476. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2477. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2478. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2479. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2480. fsiOPFLD.BilgDeptName = department.Name
  2481. fsiOPFLD.BilgDeptCodg = department.Number
  2482. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2483. fsiOPFLD.BilgDrName = doctor.UserName
  2484. fsiOPFLD.MedChrgitmType = "09"
  2485. memo["hosp_appr_flag"] = "1"
  2486. memo["invoice_no"] = order.MdtrtId
  2487. memo["memo"] = "自费"
  2488. bytesData, _ := json.Marshal(memo)
  2489. fsiOPFLD.Memo = string(bytesData)
  2490. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2491. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2492. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2493. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2494. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2495. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2496. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2497. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2498. fsiOPFLD.BilgDeptName = department.Name
  2499. fsiOPFLD.BilgDeptCodg = department.Number
  2500. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2501. fsiOPFLD.BilgDrName = doctor.UserName
  2502. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2503. case 0:
  2504. break
  2505. case 1:
  2506. fsiOPFLD.MedChrgitmType = "14"
  2507. break
  2508. case 2:
  2509. fsiOPFLD.MedChrgitmType = "05"
  2510. break
  2511. case 3:
  2512. fsiOPFLD.MedChrgitmType = "03"
  2513. break
  2514. case 4:
  2515. fsiOPFLD.MedChrgitmType = "03"
  2516. break
  2517. case 5:
  2518. fsiOPFLD.MedChrgitmType = "08"
  2519. break
  2520. case 6:
  2521. fsiOPFLD.MedChrgitmType = "14"
  2522. break
  2523. case 7:
  2524. fsiOPFLD.MedChrgitmType = "14"
  2525. break
  2526. case 8:
  2527. fsiOPFLD.MedChrgitmType = "03"
  2528. break
  2529. case 9:
  2530. fsiOPFLD.MedChrgitmType = "14"
  2531. break
  2532. case 10:
  2533. fsiOPFLD.MedChrgitmType = "14"
  2534. break
  2535. case 11:
  2536. fsiOPFLD.MedChrgitmType = "06"
  2537. break
  2538. case 12:
  2539. fsiOPFLD.MedChrgitmType = "12"
  2540. break
  2541. case 13:
  2542. fsiOPFLD.MedChrgitmType = "01"
  2543. break
  2544. case 14:
  2545. fsiOPFLD.MedChrgitmType = "04"
  2546. break
  2547. case 15:
  2548. fsiOPFLD.MedChrgitmType = "14"
  2549. break
  2550. }
  2551. memo["hosp_appr_flag"] = "1"
  2552. memo["invoice_no"] = order.MdtrtId
  2553. memo["memo"] = "自费"
  2554. bytesData, _ := json.Marshal(memo)
  2555. fsiOPFLD.Memo = string(bytesData)
  2556. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2557. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  2558. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2559. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2560. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2561. fsiOPFLD.BilgDeptName = department.Name
  2562. fsiOPFLD.BilgDeptCodg = department.Number
  2563. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2564. fsiOPFLD.BilgDrName = doctor.UserName
  2565. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2566. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2567. fsiOPFLD.MedChrgitmType = "08"
  2568. memo["hosp_appr_flag"] = "1"
  2569. memo["invoice_no"] = order.MdtrtId
  2570. memo["memo"] = "自费"
  2571. bytesData, _ := json.Marshal(memo)
  2572. fsiOPFLD.Memo = string(bytesData)
  2573. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2574. }
  2575. }
  2576. }
  2577. fmt.Println(fsiOPFLDs)
  2578. struct4201A.Fopfd = fsiOPFLDs
  2579. fmt.Println(struct4201A.Fopfd)
  2580. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  2581. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  2582. var res2 ResultSix
  2583. var respJSON2 map[string]interface{}
  2584. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2587. return
  2588. }
  2589. userJSONBytes2, _ := json.Marshal(respJSON2)
  2590. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2591. utils.ErrorLog("解析失败:%v", err)
  2592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2593. return
  2594. }
  2595. if res2.Infcode != 0 {
  2596. c.ServeSuccessJSON(map[string]interface{}{
  2597. "failed_code": -10,
  2598. "msg": res2.ErrMsg,
  2599. })
  2600. return
  2601. } else {
  2602. order.IsUploadOrderInfo = 1
  2603. service.UpdateOrder(order)
  2604. c.ServeSuccessJSON(map[string]interface{}{
  2605. "msg": "上传成功",
  2606. })
  2607. }
  2608. }
  2609. func (c *HisApiController) Get4202() {
  2610. order_id, _ := c.GetInt64("order_id")
  2611. admin_user_id, _ := c.GetInt64("admin_user_id")
  2612. order, _ := service.GetHisOrderByIDTwo(order_id)
  2613. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2614. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2615. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2616. if order.ID == 0 {
  2617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2618. return
  2619. }
  2620. var struct4202 models.Struct4202
  2621. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  2622. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  2623. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  2624. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  2625. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  2626. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  2627. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  2628. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  2629. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  2630. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2631. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2632. var config []*models.HisXtDiagnoseConfig
  2633. for _, item := range diagnosis_ids {
  2634. id, _ := strconv.ParseInt(item, 10, 64)
  2635. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2636. config = append(config, &diagnosisConfig)
  2637. }
  2638. var tempDiaginfos []models.OwnPayPatnDiagListD
  2639. for index, item := range config {
  2640. if index == 0 {
  2641. var tempDiaginfo models.OwnPayPatnDiagListD
  2642. tempDiaginfo.InoutDiagType = "1"
  2643. tempDiaginfo.DiagCode = item.CountryCode
  2644. tempDiaginfo.DiagName = item.CountryContentName
  2645. tempDiaginfo.DiagType = "1"
  2646. tempDiaginfo.DiagSrtNo = "1"
  2647. tempDiaginfo.MaindiagFlag = "1"
  2648. tempDiaginfo.ValiFlag = "1"
  2649. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2650. } else {
  2651. var tempDiaginfo models.OwnPayPatnDiagListD
  2652. tempDiaginfo.DiagCode = item.CountryCode
  2653. tempDiaginfo.DiagName = item.CountryContentName
  2654. tempDiaginfo.DiagType = "2"
  2655. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2656. tempDiaginfo.MaindiagFlag = "0"
  2657. tempDiaginfo.ValiFlag = "1"
  2658. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2659. }
  2660. }
  2661. struct4202.ODiagListD = tempDiaginfos
  2662. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  2663. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  2664. var res2 ResultSix
  2665. var respJSON2 map[string]interface{}
  2666. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2669. return
  2670. }
  2671. userJSONBytes2, _ := json.Marshal(respJSON2)
  2672. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2673. utils.ErrorLog("解析失败:%v", err)
  2674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2675. return
  2676. }
  2677. if res2.Infcode != 0 {
  2678. c.ServeSuccessJSON(map[string]interface{}{
  2679. "failed_code": -10,
  2680. "msg": res2.ErrMsg,
  2681. })
  2682. return
  2683. } else {
  2684. order.IsUploadDiagnose = 1
  2685. service.UpdateOrder(order)
  2686. c.ServeSuccessJSON(map[string]interface{}{
  2687. "msg": "上传成功",
  2688. })
  2689. }
  2690. }
  2691. func (c *HisApiController) Get4203() {
  2692. admin_user_id, _ := c.GetInt64("admin_user_id")
  2693. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2694. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2695. order_id, _ := c.GetInt64("order_id")
  2696. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  2697. number := ""
  2698. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2699. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2700. if his.ID == 0 {
  2701. number = hospital.Number
  2702. } else {
  2703. number = his.Number
  2704. }
  2705. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  2706. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  2707. var res2 ResultSix
  2708. var respJSON2 map[string]interface{}
  2709. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2712. return
  2713. }
  2714. userJSONBytes2, _ := json.Marshal(respJSON2)
  2715. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2716. utils.ErrorLog("解析失败:%v", err)
  2717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2718. return
  2719. }
  2720. if res2.Infcode != 0 {
  2721. c.ServeSuccessJSON(map[string]interface{}{
  2722. "failed_code": -10,
  2723. "msg": res2.ErrMsg,
  2724. })
  2725. return
  2726. } else {
  2727. order.IsUploadSuccess = 1
  2728. service.UpdateOrderTwo(order)
  2729. c.ServeSuccessJSON(map[string]interface{}{
  2730. "msg": "上传成功",
  2731. })
  2732. }
  2733. }
  2734. func (c *HisApiController) Get4205() {
  2735. order_id, _ := c.GetInt64("order_id")
  2736. admin_user_id, _ := c.GetInt64("admin_user_id")
  2737. fapiao_code := c.GetString("fapiao_code")
  2738. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  2739. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2740. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2741. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2742. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  2743. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  2744. //order_info = append(order_info, order_info_two...)
  2745. department, _ := service.GetDepartMentDetail(his.Departments)
  2746. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  2747. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  2748. if order.ID == 0 {
  2749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2750. return
  2751. }
  2752. var struct4201A models.Struct4201A
  2753. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  2754. for _, items := range order_info {
  2755. memo := make(map[string]interface{})
  2756. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2757. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2758. fsiOPFLD.MedType = pre.MedType
  2759. fsiOPFLD.FixmedinsCode = miConfig.Code
  2760. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2761. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2762. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2763. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2764. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2765. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2766. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2767. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  2768. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2769. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2770. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2771. fsiOPFLD.BilgDeptName = department.Name
  2772. fsiOPFLD.BilgDeptCodg = department.Number
  2773. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2774. fsiOPFLD.BilgDrName = doctor.UserName
  2775. fsiOPFLD.MedChrgitmType = "09"
  2776. memo["hosp_appr_flag"] = "1"
  2777. memo["invoice_no"] = fapiao_code
  2778. memo["memo"] = "自费"
  2779. bytesData, _ := json.Marshal(memo)
  2780. fsiOPFLD.Memo = string(bytesData)
  2781. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2782. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2783. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  2784. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2785. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2786. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2787. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2788. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2789. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2790. fsiOPFLD.BilgDeptName = department.Name
  2791. fsiOPFLD.BilgDeptCodg = department.Number
  2792. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2793. fsiOPFLD.BilgDrName = doctor.UserName
  2794. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2795. case 0:
  2796. break
  2797. case 1:
  2798. fsiOPFLD.MedChrgitmType = "14"
  2799. break
  2800. case 2:
  2801. fsiOPFLD.MedChrgitmType = "05"
  2802. break
  2803. case 3:
  2804. fsiOPFLD.MedChrgitmType = "03"
  2805. break
  2806. case 4:
  2807. fsiOPFLD.MedChrgitmType = "03"
  2808. break
  2809. case 5:
  2810. fsiOPFLD.MedChrgitmType = "08"
  2811. break
  2812. case 6:
  2813. fsiOPFLD.MedChrgitmType = "14"
  2814. break
  2815. case 7:
  2816. fsiOPFLD.MedChrgitmType = "14"
  2817. break
  2818. case 8:
  2819. fsiOPFLD.MedChrgitmType = "03"
  2820. break
  2821. case 9:
  2822. fsiOPFLD.MedChrgitmType = "14"
  2823. break
  2824. case 10:
  2825. fsiOPFLD.MedChrgitmType = "14"
  2826. break
  2827. case 11:
  2828. fsiOPFLD.MedChrgitmType = "06"
  2829. break
  2830. case 12:
  2831. fsiOPFLD.MedChrgitmType = "12"
  2832. break
  2833. case 13:
  2834. fsiOPFLD.MedChrgitmType = "01"
  2835. break
  2836. case 14:
  2837. fsiOPFLD.MedChrgitmType = "04"
  2838. break
  2839. case 15:
  2840. fsiOPFLD.MedChrgitmType = "14"
  2841. break
  2842. }
  2843. memo["hosp_appr_flag"] = "1"
  2844. memo["invoice_no"] = fapiao_code
  2845. memo["memo"] = "自费"
  2846. bytesData, _ := json.Marshal(memo)
  2847. fsiOPFLD.Memo = string(bytesData)
  2848. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2849. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  2850. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2851. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2852. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2853. fsiOPFLD.BilgDeptName = department.Name
  2854. fsiOPFLD.BilgDeptCodg = department.Number
  2855. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2856. fsiOPFLD.BilgDrName = doctor.UserName
  2857. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2858. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2859. fsiOPFLD.MedChrgitmType = "08"
  2860. memo["hosp_appr_flag"] = "1"
  2861. memo["invoice_no"] = fapiao_code
  2862. memo["memo"] = "自费"
  2863. bytesData, _ := json.Marshal(memo)
  2864. fsiOPFLD.Memo = string(bytesData)
  2865. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2866. }
  2867. }
  2868. }
  2869. for _, items := range order_info_two {
  2870. memo := make(map[string]interface{})
  2871. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2872. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2873. fsiOPFLD.MedType = pre.MedType
  2874. fsiOPFLD.BkkpSn = items.FeedetlSn
  2875. fsiOPFLD.FixmedinsCode = miConfig.Code
  2876. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2877. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2878. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2879. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2880. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2881. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2882. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2883. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2884. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2885. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2886. fsiOPFLD.BilgDeptName = department.Name
  2887. fsiOPFLD.BilgDeptCodg = department.Number
  2888. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2889. fsiOPFLD.BilgDrName = doctor.UserName
  2890. fsiOPFLD.MedChrgitmType = "09"
  2891. memo["hosp_appr_flag"] = "1"
  2892. memo["invoice_no"] = fapiao_code
  2893. memo["memo"] = "自费"
  2894. bytesData, _ := json.Marshal(memo)
  2895. fsiOPFLD.Memo = string(bytesData)
  2896. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2897. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2898. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  2899. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2900. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2901. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2902. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2903. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2904. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2905. fsiOPFLD.BilgDeptName = department.Name
  2906. fsiOPFLD.BilgDeptCodg = department.Number
  2907. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2908. fsiOPFLD.BilgDrName = doctor.UserName
  2909. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2910. case 0:
  2911. break
  2912. case 1:
  2913. fsiOPFLD.MedChrgitmType = "14"
  2914. break
  2915. case 2:
  2916. fsiOPFLD.MedChrgitmType = "05"
  2917. break
  2918. case 3:
  2919. fsiOPFLD.MedChrgitmType = "03"
  2920. break
  2921. case 4:
  2922. fsiOPFLD.MedChrgitmType = "03"
  2923. break
  2924. case 5:
  2925. fsiOPFLD.MedChrgitmType = "08"
  2926. break
  2927. case 6:
  2928. fsiOPFLD.MedChrgitmType = "14"
  2929. break
  2930. case 7:
  2931. fsiOPFLD.MedChrgitmType = "14"
  2932. break
  2933. case 8:
  2934. fsiOPFLD.MedChrgitmType = "03"
  2935. break
  2936. case 9:
  2937. fsiOPFLD.MedChrgitmType = "14"
  2938. break
  2939. case 10:
  2940. fsiOPFLD.MedChrgitmType = "14"
  2941. break
  2942. case 11:
  2943. fsiOPFLD.MedChrgitmType = "06"
  2944. break
  2945. case 12:
  2946. fsiOPFLD.MedChrgitmType = "12"
  2947. break
  2948. case 13:
  2949. fsiOPFLD.MedChrgitmType = "01"
  2950. break
  2951. case 14:
  2952. fsiOPFLD.MedChrgitmType = "04"
  2953. break
  2954. case 15:
  2955. fsiOPFLD.MedChrgitmType = "14"
  2956. break
  2957. }
  2958. memo["hosp_appr_flag"] = "1"
  2959. memo["invoice_no"] = fapiao_code
  2960. memo["memo"] = "自费"
  2961. bytesData, _ := json.Marshal(memo)
  2962. fsiOPFLD.Memo = string(bytesData)
  2963. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2964. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  2965. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2966. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2967. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2968. fsiOPFLD.BilgDeptName = department.Name
  2969. fsiOPFLD.BilgDeptCodg = department.Number
  2970. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2971. fsiOPFLD.BilgDrName = doctor.UserName
  2972. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2973. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2974. fsiOPFLD.MedChrgitmType = "08"
  2975. memo["hosp_appr_flag"] = "1"
  2976. memo["invoice_no"] = fapiao_code
  2977. memo["memo"] = "自费"
  2978. bytesData, _ := json.Marshal(memo)
  2979. fsiOPFLD.Memo = string(bytesData)
  2980. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2981. }
  2982. }
  2983. }
  2984. fmt.Println(fsiOPFLDs)
  2985. struct4201A.Fopfd = fsiOPFLDs
  2986. fmt.Println(struct4201A.Fopfd)
  2987. var struct4202 models.Struct4202
  2988. timeLayout := "2006-01-02 15:04:05"
  2989. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  2990. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  2991. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  2992. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  2993. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  2994. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  2995. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  2996. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  2997. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  2998. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  2999. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3000. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3001. var config []*models.HisXtDiagnoseConfig
  3002. for _, item := range diagnosis_ids {
  3003. id, _ := strconv.ParseInt(item, 10, 64)
  3004. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3005. config = append(config, &diagnosisConfig)
  3006. }
  3007. var tempDiaginfos []models.OwnPayPatnDiagListD
  3008. for index, item := range config {
  3009. if index == 0 {
  3010. var tempDiaginfo models.OwnPayPatnDiagListD
  3011. tempDiaginfo.InoutDiagType = "1"
  3012. tempDiaginfo.DiagCode = item.CountryCode
  3013. tempDiaginfo.DiagName = item.CountryContentName
  3014. tempDiaginfo.DiagType = "1"
  3015. tempDiaginfo.DiagSrtNo = "1"
  3016. tempDiaginfo.MaindiagFlag = "1"
  3017. tempDiaginfo.ValiFlag = "1"
  3018. tempDiaginfo.DiagDrName = doctor.UserName
  3019. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  3020. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  3021. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3022. } else {
  3023. var tempDiaginfo models.OwnPayPatnDiagListD
  3024. tempDiaginfo.DiagCode = item.CountryCode
  3025. tempDiaginfo.DiagName = item.CountryContentName
  3026. tempDiaginfo.DiagType = "2"
  3027. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3028. tempDiaginfo.MaindiagFlag = "0"
  3029. tempDiaginfo.ValiFlag = "1"
  3030. tempDiaginfo.DiagDrName = doctor.UserName
  3031. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  3032. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  3033. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3034. }
  3035. }
  3036. struct4202.ODiagListD = tempDiaginfos
  3037. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  3038. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  3039. var res2 ResultSix
  3040. var respJSON2 map[string]interface{}
  3041. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3044. return
  3045. }
  3046. userJSONBytes2, _ := json.Marshal(respJSON2)
  3047. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3048. utils.ErrorLog("解析失败:%v", err)
  3049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3050. return
  3051. }
  3052. if res2.Infcode != 0 {
  3053. c.ServeSuccessJSON(map[string]interface{}{
  3054. "failed_code": -10,
  3055. "msg": res2.ErrMsg,
  3056. })
  3057. return
  3058. } else {
  3059. order.IsUploadDiagnose = 1
  3060. order.IsUploadOrderInfo = 1
  3061. service.UpdateOrderTwo(order)
  3062. c.ServeSuccessJSON(map[string]interface{}{
  3063. "msg": "上传成功",
  3064. })
  3065. }
  3066. }
  3067. func (c *HisApiController) Get4207() {
  3068. admin_user_id, _ := c.GetInt64("admin_user_id")
  3069. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3070. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3071. order_id, _ := c.GetInt64("order_id")
  3072. order, _ := service.GetHisOrderByIDTwo(order_id)
  3073. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3074. var struct4207 models.Struct4207
  3075. struct4207.PageNum = "1"
  3076. struct4207.PageSize = "1000"
  3077. struct4207.FixmedinsCode = miConfig.Code
  3078. struct4207.FixmedinsMdtrtID = order.Number
  3079. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  3080. saveLog(result, requestLog, "4207", "查询")
  3081. var res2 ResultSix
  3082. var respJSON2 map[string]interface{}
  3083. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3086. return
  3087. }
  3088. userJSONBytes2, _ := json.Marshal(respJSON2)
  3089. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3090. utils.ErrorLog("解析失败:%v", err)
  3091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3092. return
  3093. }
  3094. if res2.Infcode != 0 {
  3095. c.ServeSuccessJSON(map[string]interface{}{
  3096. "failed_code": -10,
  3097. "msg": res2.ErrMsg,
  3098. })
  3099. return
  3100. } else {
  3101. c.ServeSuccessJSON(map[string]interface{}{
  3102. "msg": "查询成功",
  3103. })
  3104. }
  3105. }
  3106. func (c *HisApiController) Get4208() {
  3107. admin_user_id, _ := c.GetInt64("admin_user_id")
  3108. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3109. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3110. order_id, _ := c.GetInt64("order_id")
  3111. order, _ := service.GetHisOrderByIDTwo(order_id)
  3112. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3113. var struct4208 models.Struct4208
  3114. struct4208.PageNum = "1"
  3115. struct4208.PageSize = "1000"
  3116. struct4208.PsnCertType = "01"
  3117. struct4208.Certno = his.Certno
  3118. struct4208.MedType = order.MedType
  3119. struct4208.PsnName = his.Name
  3120. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  3121. saveLog(result, requestLog, "4208", "查询")
  3122. var res2 ResultSix
  3123. var respJSON2 map[string]interface{}
  3124. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3127. return
  3128. }
  3129. userJSONBytes2, _ := json.Marshal(respJSON2)
  3130. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3131. utils.ErrorLog("解析失败:%v", err)
  3132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3133. return
  3134. }
  3135. if res2.Infcode != 0 {
  3136. c.ServeSuccessJSON(map[string]interface{}{
  3137. "failed_code": -10,
  3138. "msg": res2.ErrMsg,
  3139. })
  3140. return
  3141. } else {
  3142. c.ServeSuccessJSON(map[string]interface{}{
  3143. "msg": "查询成功",
  3144. })
  3145. }
  3146. }
  3147. func (c *HisApiController) Get4209() {
  3148. admin_user_id, _ := c.GetInt64("admin_user_id")
  3149. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3150. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3151. order_id, _ := c.GetInt64("order_id")
  3152. order, _ := service.GetHisOrderByIDTwo(order_id)
  3153. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3154. var struct4209 models.Struct4209
  3155. struct4209.FixmedinsMdtrtID = order.Number
  3156. struct4209.FixmedinsCode = miConfig.Code
  3157. struct4209.PageSize = "1000"
  3158. struct4209.PageNum = "1"
  3159. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  3160. saveLog(result, requestLog, "4209", "查询")
  3161. var res2 ResultSix
  3162. var respJSON2 map[string]interface{}
  3163. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3166. return
  3167. }
  3168. userJSONBytes2, _ := json.Marshal(respJSON2)
  3169. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3170. utils.ErrorLog("解析失败:%v", err)
  3171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3172. return
  3173. }
  3174. if res2.Infcode != 0 {
  3175. c.ServeSuccessJSON(map[string]interface{}{
  3176. "failed_code": -10,
  3177. "msg": res2.ErrMsg,
  3178. })
  3179. return
  3180. } else {
  3181. c.ServeSuccessJSON(map[string]interface{}{
  3182. "msg": "查询成功",
  3183. })
  3184. }
  3185. }
  3186. type Result3101 struct {
  3187. Infcode string `json:"infcode"`
  3188. InfRefmsgid string `json:"inf_refmsgid"`
  3189. RefmsgTime string `json:"refmsg_time"`
  3190. RespondTime string `json:"respond_time"`
  3191. Enctype string `json:"enctype"`
  3192. Signtype string `json:"signtype"`
  3193. ErrMsg string `json:"err_msg"`
  3194. Output struct {
  3195. Result []struct {
  3196. JudgeResultDetailDtos []struct {
  3197. VolaItemType string `json:"vola_item_type"`
  3198. MdtrtID string `json:"mdtrt_id"`
  3199. JrdID string `json:"jrd_id"`
  3200. PatnID string `json:"patn_id"`
  3201. RxID string `json:"rx_id"`
  3202. VolaAmt interface{} `json:"vola_amt"`
  3203. } `json:"judge_result_detail_dtos"`
  3204. RuleID string `json:"rule_id"`
  3205. VolaEvid string `json:"vola_evid"`
  3206. MdtrtID string `json:"mdtrt_id"`
  3207. RuleName string `json:"rule_name"`
  3208. VolaAmtStas string `json:"vola_amt_stas"`
  3209. JrID string `json:"jr_id"`
  3210. PatnID string `json:"patn_id"`
  3211. SevDeg string `json:"sev_deg"`
  3212. VolaAmt float64 `json:"vola_amt"`
  3213. VolaBhvrType string `json:"vola_bhvr_type"`
  3214. VolaCont string `json:"vola_cont"`
  3215. } `json:"result"`
  3216. } `json:"output"`
  3217. }
  3218. func (c *HisApiController) ReadEleToken() {
  3219. admin_user_id, _ := c.GetInt64("admin_user_id")
  3220. his_patient_id, _ := c.GetInt64("his_patient_id")
  3221. adminUser := c.GetAdminUserInfo()
  3222. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3223. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3224. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3225. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3226. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  3227. if len(tokens) > 0 {
  3228. c.ServeSuccessJSON(map[string]interface{}{
  3229. "msg": "读取成功",
  3230. })
  3231. } else {
  3232. c.ServeSuccessJSON(map[string]interface{}{
  3233. "failed_code": -10,
  3234. "msg": "读取失败",
  3235. })
  3236. }
  3237. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3238. var api string
  3239. 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 +
  3240. "&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"
  3241. resp, requestErr := http.Get(api)
  3242. if requestErr != nil {
  3243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3244. }
  3245. body, ioErr := ioutil.ReadAll(resp.Body)
  3246. if ioErr != nil {
  3247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3249. }
  3250. var respJSON map[string]interface{}
  3251. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3254. return
  3255. }
  3256. var status string
  3257. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3258. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3259. var token string
  3260. var res ResultTwo //1101结果
  3261. var res10265 ResultTwo10265 //1101结果
  3262. if status == "0" { //读卡成功
  3263. var card_info string //卡信息
  3264. var busi_card_info string
  3265. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3266. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3267. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3268. fmt.Println(card_info)
  3269. fmt.Println(busi_card_info)
  3270. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3271. result, _ := json.Marshal(respJSON)
  3272. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3273. utils.ErrorLog("解析失败:%v", err)
  3274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3275. return
  3276. }
  3277. res.ErrMsg = res10265.ErrMsg
  3278. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3279. res.Infcode = infocode
  3280. res.Output = res10265.Output
  3281. res.InfRefmsgid = res10265.InfRefmsgid
  3282. if res.Infcode == 0 {
  3283. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3284. if err == gorm.ErrRecordNotFound {
  3285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3286. return
  3287. } else if err != nil {
  3288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3289. return
  3290. } else {
  3291. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3292. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3293. infoStr := string(Iinfos)
  3294. idetinfoStr := string(Idetinfos)
  3295. psn := &models.HisPsn{
  3296. PsnNo: res.Output.Baseinfo.PsnNo,
  3297. Age: res.Output.Baseinfo.Age,
  3298. PatientId: patient.ID,
  3299. Certno: res.Output.Baseinfo.Certno,
  3300. Brdy: res.Output.Baseinfo.Brdy,
  3301. Gend: res.Output.Baseinfo.Gend,
  3302. Naty: res.Output.Baseinfo.Naty,
  3303. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3304. PsnName: res.Output.Baseinfo.PsnName,
  3305. Idetinfo: idetinfoStr,
  3306. Insuinfo: infoStr,
  3307. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3308. CardInfo: card_info,
  3309. VerifyNumber: token,
  3310. IdCardType: 4,
  3311. }
  3312. var rf []*ResultFive
  3313. json.Unmarshal([]byte(infoStr), &rf)
  3314. var insutypes []*ResultFive
  3315. var insutype string
  3316. var is390 int = 0
  3317. var is310 int = 0
  3318. for _, item := range rf {
  3319. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3320. insutypes = append(insutypes, item)
  3321. }
  3322. }
  3323. if len(insutypes) == 1 {
  3324. insutype = insutypes[0].Insutype
  3325. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3326. } else {
  3327. for _, i := range insutypes {
  3328. if i.Insutype == "390" {
  3329. is390 = 1
  3330. }
  3331. if i.Insutype == "310" {
  3332. is310 = 1
  3333. }
  3334. }
  3335. }
  3336. if is390 == 1 {
  3337. insutype = "390"
  3338. }
  3339. if is310 == 1 {
  3340. insutype = "310"
  3341. }
  3342. if len(insutypes) == 0 {
  3343. insutype = "310"
  3344. }
  3345. service.CreateHisPsn(psn)
  3346. c.ServeSuccessJSON(map[string]interface{}{
  3347. "patient": patient,
  3348. "number": token,
  3349. "insutype": insutype,
  3350. })
  3351. }
  3352. } else {
  3353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3354. return
  3355. }
  3356. } else { //读卡失败
  3357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3358. return
  3359. }
  3360. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3361. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  3362. if len(errMsg) == 0 {
  3363. type ELeData struct {
  3364. Data struct {
  3365. IdNo string `json:"idNo"`
  3366. IdType string `json:"idType"`
  3367. UserName string `json:"userName"`
  3368. EcToken string `json:"ecToken"`
  3369. InsuOrg string `json:"insuOrg"`
  3370. Gender string `json:"gender"`
  3371. Birthday string `json:"birthday"`
  3372. Nationality string `json:"nationality"`
  3373. Email string `json:"email"`
  3374. Extra string `json:"extra"`
  3375. } `json:"data"`
  3376. Code int `json:"code"`
  3377. Message string `json:"message"`
  3378. }
  3379. var ele ELeData
  3380. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3381. if err != nil {
  3382. utils.ErrorLog("解析失败:%v", err)
  3383. }
  3384. token := ele.Data.EcToken
  3385. if len(token) > 0 {
  3386. psn := &models.HisPsn{
  3387. PsnNo: his.PsnNo,
  3388. Age: 0,
  3389. PatientId: his.PatientId,
  3390. Certno: his.Certno,
  3391. Brdy: his.Brdy,
  3392. Gend: his.Gend,
  3393. Naty: his.Naty,
  3394. PsnCertType: his.PsnCertType,
  3395. PsnName: his.PsnName,
  3396. Idetinfo: his.Idetinfo,
  3397. Insuinfo: his.Iinfo,
  3398. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3399. CardInfo: outPutInfo,
  3400. VerifyNumber: token,
  3401. }
  3402. service.CreateHisPsn(psn)
  3403. }
  3404. if len(token) > 0 {
  3405. c.ServeSuccessJSON(map[string]interface{}{
  3406. "msg": "读取成功",
  3407. })
  3408. } else {
  3409. c.ServeSuccessJSON(map[string]interface{}{
  3410. "failed_code": -10,
  3411. "msg": "读取失败",
  3412. })
  3413. }
  3414. }
  3415. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3416. if initFlag == 0 {
  3417. c.TestGetJiangXiBasBaseInit()
  3418. }
  3419. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3420. type ELeData struct {
  3421. Data struct {
  3422. IdNo string `json:"idNo"`
  3423. IdType string `json:"idType"`
  3424. UserName string `json:"userName"`
  3425. EcToken string `json:"ecToken"`
  3426. InsuOrg string `json:"insuOrg"`
  3427. Gender string `json:"gender"`
  3428. Birthday string `json:"birthday"`
  3429. Nationality string `json:"nationality"`
  3430. Email string `json:"email"`
  3431. Extra string `json:"extra"`
  3432. } `json:"data"`
  3433. Code int `json:"code"`
  3434. Message string `json:"message"`
  3435. }
  3436. var ele ELeData
  3437. err := json.Unmarshal([]byte(json_result), &ele)
  3438. if err != nil {
  3439. utils.ErrorLog("解析失败:%v", err)
  3440. }
  3441. token := ele.Data.EcToken
  3442. token = Remove0000(token)
  3443. fmt.Println(ele.Data.UserName)
  3444. 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)
  3445. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3446. var res ResultTwo
  3447. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3448. utils.ErrorLog("解析失败:%v", err)
  3449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3450. return
  3451. }
  3452. if res.Infcode == 0 {
  3453. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3454. if err == gorm.ErrRecordNotFound {
  3455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3456. return
  3457. } else if err != nil {
  3458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3459. return
  3460. } else {
  3461. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3462. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3463. infoStr := string(Iinfos)
  3464. idetinfoStr := string(Idetinfos)
  3465. psn := &models.HisPsn{
  3466. PsnNo: res.Output.Baseinfo.PsnNo,
  3467. Age: res.Output.Baseinfo.Age,
  3468. PatientId: patient.ID,
  3469. Certno: res.Output.Baseinfo.Certno,
  3470. Brdy: res.Output.Baseinfo.Brdy,
  3471. Gend: res.Output.Baseinfo.Gend,
  3472. Naty: res.Output.Baseinfo.Naty,
  3473. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3474. PsnName: res.Output.Baseinfo.PsnName,
  3475. Idetinfo: idetinfoStr,
  3476. Insuinfo: infoStr,
  3477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3478. CardInfo: "",
  3479. VerifyNumber: token,
  3480. }
  3481. service.CreateHisPsn(psn)
  3482. c.ServeSuccessJSON(map[string]interface{}{
  3483. "patient": patient,
  3484. "number": token,
  3485. })
  3486. }
  3487. } else {
  3488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3489. return
  3490. }
  3491. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3492. idNo := c.GetString("idNo")
  3493. userName := c.GetString("userName")
  3494. ecToken := c.GetString("ecToken")
  3495. insuOrg := c.GetString("insuOrg")
  3496. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  3497. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3498. var res ResultTwo
  3499. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3500. utils.ErrorLog("解析失败:%v", err)
  3501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3502. return
  3503. }
  3504. if res.Infcode == 0 {
  3505. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3506. if err == gorm.ErrRecordNotFound {
  3507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3508. return
  3509. } else if err != nil {
  3510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3511. return
  3512. } else {
  3513. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3514. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3515. infoStr := string(Iinfos)
  3516. idetinfoStr := string(Idetinfos)
  3517. psn := &models.HisPsn{
  3518. PsnNo: res.Output.Baseinfo.PsnNo,
  3519. Age: res.Output.Baseinfo.Age,
  3520. PatientId: patient.ID,
  3521. Certno: res.Output.Baseinfo.Certno,
  3522. Brdy: res.Output.Baseinfo.Brdy,
  3523. Gend: res.Output.Baseinfo.Gend,
  3524. Naty: res.Output.Baseinfo.Naty,
  3525. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3526. PsnName: res.Output.Baseinfo.PsnName,
  3527. Idetinfo: idetinfoStr,
  3528. Insuinfo: infoStr,
  3529. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3530. CardInfo: "",
  3531. VerifyNumber: ecToken,
  3532. InsuplcAdmdvs: insuOrg,
  3533. }
  3534. service.CreateHisPsn(psn)
  3535. c.ServeSuccessJSON(map[string]interface{}{
  3536. "patient": patient,
  3537. "number": ecToken,
  3538. })
  3539. }
  3540. } else {
  3541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3542. return
  3543. }
  3544. } else {
  3545. //if initFlag == 0 {
  3546. // c.TestGetBasBaseInit()
  3547. //}
  3548. //token := c.GetEleBaseInfo()
  3549. //token = Remove0000(token)
  3550. type ELeData struct {
  3551. Code string `json:"code"`
  3552. Data struct {
  3553. Aac002 string `json:"aac002"`
  3554. Aaz500 string `json:"aaz500"`
  3555. ActCardNo string `json:"actCardNo"`
  3556. Bab520 string `json:"bab520"`
  3557. Bkz543 string `json:"bkz543"`
  3558. BusinessType string `json:"businessType"`
  3559. CertfCodg string `json:"certfCodg"`
  3560. EcIndexNo string `json:"ecIndexNo"`
  3561. EcToken string `json:"ecToken"`
  3562. ID0000 string `json:"id0000"`
  3563. IDNo string `json:"idNo"`
  3564. IDType string `json:"idType"`
  3565. Idcode string `json:"idcode"`
  3566. IdentityToken string `json:"identity_token"`
  3567. InsuOrg string `json:"insuOrg"`
  3568. OfficeID string `json:"officeId"`
  3569. OfficeName string `json:"officeName"`
  3570. OperatorID string `json:"operatorId"`
  3571. OperatorName string `json:"operatorName"`
  3572. OrgID string `json:"orgId"`
  3573. UserName string `json:"userName"`
  3574. } `json:"data"`
  3575. Infno interface{} `json:"infno"`
  3576. Message string `json:"message"`
  3577. OrgID string `json:"orgId"`
  3578. TransType string `json:"transType"`
  3579. }
  3580. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  3581. fmt.Println(result)
  3582. outPutInfo := Remove0000(result)
  3583. fmt.Println(outPutInfo)
  3584. var ele ELeData
  3585. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3586. if err != nil {
  3587. utils.ErrorLog("解析失败:%v", err)
  3588. }
  3589. token := ele.Data.EcToken
  3590. if len(token) > 0 {
  3591. result2, requestLog2 := service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  3592. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3593. var res ResultTwo
  3594. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3595. utils.ErrorLog("解析失败:%v", err)
  3596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3597. return
  3598. }
  3599. if res.Infcode == 0 {
  3600. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3601. if err == gorm.ErrRecordNotFound {
  3602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3603. return
  3604. } else if err != nil {
  3605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3606. return
  3607. } else {
  3608. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3609. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3610. infoStr := string(Iinfos)
  3611. idetinfoStr := string(Idetinfos)
  3612. psn := &models.HisPsn{
  3613. PsnNo: res.Output.Baseinfo.PsnNo,
  3614. Age: res.Output.Baseinfo.Age,
  3615. PatientId: patient.ID,
  3616. Certno: res.Output.Baseinfo.Certno,
  3617. Brdy: res.Output.Baseinfo.Brdy,
  3618. Gend: res.Output.Baseinfo.Gend,
  3619. Naty: res.Output.Baseinfo.Naty,
  3620. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3621. PsnName: res.Output.Baseinfo.PsnName,
  3622. Idetinfo: idetinfoStr,
  3623. Insuinfo: infoStr,
  3624. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3625. CardInfo: "",
  3626. VerifyNumber: token,
  3627. }
  3628. service.CreateHisPsn(psn)
  3629. c.ServeSuccessJSON(map[string]interface{}{
  3630. "msg": "读取成功",
  3631. })
  3632. }
  3633. } else {
  3634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3635. return
  3636. }
  3637. } else {
  3638. c.ServeSuccessJSON(map[string]interface{}{
  3639. "failed_code": -10,
  3640. "msg": "读取失败",
  3641. })
  3642. }
  3643. }
  3644. }
  3645. func (c *HisApiController) Get9001() {
  3646. adminUser := c.GetAdminUserInfo()
  3647. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3648. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  3649. if miConfig.MdtrtareaAdmvs == "350500" {
  3650. service.GetFjAuthorizationInfo(miConfig.Code)
  3651. } else if miConfig.MdtrtareaAdmvs == "131023" {
  3652. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  3653. var dat map[string]interface{}
  3654. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3655. fmt.Println(dat)
  3656. } else {
  3657. fmt.Println(err)
  3658. }
  3659. userJSONBytes, _ := json.Marshal(dat)
  3660. var res models.Result9001
  3661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3662. utils.ErrorLog("解析失败:%v", err)
  3663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3664. return
  3665. }
  3666. } else {
  3667. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  3668. var dat map[string]interface{}
  3669. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3670. fmt.Println(dat)
  3671. } else {
  3672. fmt.Println(err)
  3673. }
  3674. userJSONBytes, _ := json.Marshal(dat)
  3675. var res models.Result9001
  3676. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3677. utils.ErrorLog("解析失败:%v", err)
  3678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3679. return
  3680. }
  3681. }
  3682. }
  3683. 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) {
  3684. var res Result3101
  3685. adminUser := c.GetAdminUserInfo()
  3686. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3687. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3688. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3689. //record_time := c.GetString("record_time")
  3690. //trig_scen := c.GetString("trig_scen")
  3691. timeLayout := "2006-01-02"
  3692. loc, _ := time.LoadLocation("Local")
  3693. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3694. if err != nil {
  3695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3696. return res
  3697. }
  3698. recordDateTime := theTime.Unix()
  3699. var patientPrescription models.HisPrescriptionInfo
  3700. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3701. //if patientPrescription.ID == 0 {
  3702. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3703. //}
  3704. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3705. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3706. //
  3707. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  3708. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3709. var pp models.PublicParams
  3710. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3711. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3712. pp.FixmedinsName = miConfig.OrgName
  3713. pp.FixmedinsCode = miConfig.Code
  3714. pp.RequestUrl = miConfig.Url
  3715. pp.Cainfo = miConfig.Cainfo
  3716. pp.SecretKey = miConfig.SecretKey
  3717. pp.AccessKey = miConfig.AccessKey
  3718. pp.OpterName = roles.UserName
  3719. var config []*models.HisXtDiagnoseConfig
  3720. for _, item := range diagnosis_ids {
  3721. id, _ := strconv.ParseInt(item, 10, 64)
  3722. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3723. config = append(config, &diagnosisConfig)
  3724. }
  3725. var pd models.PatientDtos
  3726. pd.PatnID = his.PsnNo
  3727. pd.PatnName = his.Name
  3728. pd.Gend = his.Gend
  3729. pd.Brdy = his.Brdy
  3730. pd.Poolarea = miConfig.MdtrtareaAdmvs
  3731. pd.CurrMdtrtID = his.Number
  3732. var fed models.FsiEncounterDtos
  3733. fed.MdtrtID = his.Number
  3734. fed.MedinsID = miConfig.Code
  3735. fed.MedinsName = miConfig.OrgName
  3736. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  3737. fed.MedMdtrtType = "1"
  3738. fed.MedinsType = "1"
  3739. fed.MedinsLv = "11"
  3740. tm := time.Unix(his.RecordDate, 0)
  3741. s_tm := tm.Format("2006-01-02 15:04:05")
  3742. fed.AdmDate = s_tm
  3743. fed.DscgDate = s_tm
  3744. fed.DscgMainDiseCodg = config[0].CountryCode
  3745. fed.DscgMainDiseName = config[0].CountryContentName
  3746. //诊断信息
  3747. var fdds []*models.FsiDiagnoseDtos
  3748. for index, item := range config {
  3749. if index == 0 {
  3750. var fdd models.FsiDiagnoseDtos
  3751. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3752. fdd.InoutDiseType = "1"
  3753. fdd.MaindiseFlag = "1"
  3754. fdd.DiseDate = s_tm
  3755. fdd.DiasSrtNo = "1"
  3756. fdd.DiseName = item.CountryContentName
  3757. fdd.DiseCodg = item.CountryCode
  3758. fdds = append(fdds, &fdd)
  3759. } else {
  3760. var fdd models.FsiDiagnoseDtos
  3761. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  3762. fdd.InoutDiseType = "1"
  3763. fdd.MaindiseFlag = "1"
  3764. fdd.DiseDate = s_tm
  3765. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  3766. fdd.DiseName = item.CountryContentName
  3767. fdd.DiseCodg = item.CountryCode
  3768. fdds = append(fdds, &fdd)
  3769. }
  3770. }
  3771. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  3772. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  3773. fed.AdmDeptName = department.Name
  3774. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  3775. fed.DscgDeptName = department.Name
  3776. fed.MedMdtrtType = "1"
  3777. fed.MedType = "11"
  3778. //if his.Insutype == "390" {
  3779. // fed.MedType = "1402"
  3780. //} else {
  3781. // fed.MedType = "9933"
  3782. //}
  3783. var orders []*models.FsiOrderDtos
  3784. if trig_scen == "2" {
  3785. //处方医嘱信息
  3786. for _, item := range prescriptions {
  3787. for _, subItem := range item.HisDoctorAdviceInfo {
  3788. var order models.FsiOrderDtos
  3789. order.RxID = strconv.FormatInt(item.ID, 10)
  3790. order.Rxno = strconv.FormatInt(item.ID, 10)
  3791. order.LongDrordFlag = "0"
  3792. order.HilistType = "1"
  3793. order.ChrgType = "1"
  3794. order.DrordBhvr = "-"
  3795. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3796. order.HosplistName = subItem.BaseDrugLib.DrugName
  3797. order.HilistLv = "1"
  3798. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3799. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  3800. order.HosplistName = subItem.BaseDrugLib.DrugName
  3801. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  3802. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3803. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  3804. order.OwnpayAmt = ""
  3805. order.SelfpayAmt = ""
  3806. order.Spec = ""
  3807. order.SpecUnt = ""
  3808. order.DrordBegnDate = s_tm
  3809. order.DrordStopDate = ""
  3810. order.DrordDrCodg = "1"
  3811. order.DrordDeptName = department.Name
  3812. order.DrordDrCodg = "1"
  3813. order.DrordDrName = doctor_info.UserName
  3814. order.DrordDrProfttl = ""
  3815. order.CurrDrordFlag = "1"
  3816. orders = append(orders, &order)
  3817. }
  3818. for _, subItem := range item.HisPrescriptionProject {
  3819. if subItem.Type == 2 {
  3820. var order models.FsiOrderDtos
  3821. order.RxID = strconv.FormatInt(item.ID, 10)
  3822. order.Rxno = strconv.FormatInt(item.ID, 10)
  3823. order.LongDrordFlag = "0"
  3824. order.HilistType = "1"
  3825. order.ChrgType = "1"
  3826. order.DrordBhvr = "-"
  3827. order.HilistCode = subItem.HisProject.MedicalCode
  3828. order.HosplistName = subItem.HisProject.ProjectName
  3829. order.HilistLv = "1"
  3830. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3831. order.HosplistCode = subItem.HisProject.MedicalCode
  3832. order.HosplistName = subItem.HisProject.ProjectName
  3833. order.Cnt = subItem.Count
  3834. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3835. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3836. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3837. order.OwnpayAmt = ""
  3838. order.SelfpayAmt = ""
  3839. order.Spec = ""
  3840. order.SpecUnt = ""
  3841. order.DrordBegnDate = s_tm
  3842. order.DrordStopDate = ""
  3843. order.DrordDrCodg = "1"
  3844. order.DrordDeptName = department.Name
  3845. order.DrordDrCodg = "1"
  3846. order.DrordDrName = doctor_info.UserName
  3847. order.DrordDrProfttl = ""
  3848. order.CurrDrordFlag = "1"
  3849. orders = append(orders, &order)
  3850. }
  3851. if subItem.Type == 3 {
  3852. var order models.FsiOrderDtos
  3853. order.RxID = strconv.FormatInt(item.ID, 10)
  3854. order.Rxno = strconv.FormatInt(item.ID, 10)
  3855. order.LongDrordFlag = "0"
  3856. order.HilistType = "1"
  3857. order.ChrgType = "1"
  3858. order.DrordBhvr = "-"
  3859. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3860. order.HosplistName = subItem.GoodInfo.GoodName
  3861. order.HilistLv = "1"
  3862. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3863. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3864. order.HosplistName = subItem.GoodInfo.GoodName
  3865. order.Cnt = subItem.Count
  3866. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3867. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3868. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3869. order.OwnpayAmt = ""
  3870. order.SelfpayAmt = ""
  3871. order.Spec = ""
  3872. order.SpecUnt = ""
  3873. order.DrordBegnDate = s_tm
  3874. order.DrordStopDate = ""
  3875. order.DrordDrCodg = "1"
  3876. order.DrordDeptName = department.Name
  3877. order.DrordDrCodg = "1"
  3878. order.DrordDrName = doctor_info.UserName
  3879. order.DrordDrProfttl = ""
  3880. order.CurrDrordFlag = "1"
  3881. orders = append(orders, &order)
  3882. }
  3883. }
  3884. }
  3885. //处方医嘱信息
  3886. }
  3887. fed.MatnStas = "0"
  3888. fed.MedfeeSumamt = "0"
  3889. fed.OwnpayAmt = "0"
  3890. fed.SelfpayAmt = "0"
  3891. fed.AcctPayamt = "0"
  3892. fed.MaAmt = "0"
  3893. fed.HifpPayamt = "0"
  3894. fed.SetlTotlnum = "1"
  3895. fed.Insutype = his.Insutype
  3896. fed.ReimFlag = "0"
  3897. fed.OutSetlFlag = "0"
  3898. var fopd []*models.FsiOperationDtosData
  3899. data := make(map[string]interface{})
  3900. data["fed"] = fed
  3901. data["fdd"] = fdds
  3902. data["fod"] = orders
  3903. data["pd"] = pd
  3904. data["pp"] = pp
  3905. data["fopd"] = fopd
  3906. data["trig_scen"] = trig_scen
  3907. fmt.Println(data)
  3908. fmt.Println(fed)
  3909. fmt.Println(fdds)
  3910. fmt.Println(orders)
  3911. fmt.Println(pd)
  3912. fmt.Println(pp)
  3913. fmt.Println(fopd)
  3914. client := &http.Client{}
  3915. bytesData, _ := json.Marshal(data)
  3916. var req *http.Request
  3917. if miConfig.MdtrtareaAdmvs == "320921" {
  3918. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  3919. } else {
  3920. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  3921. }
  3922. resp, _ := client.Do(req)
  3923. defer resp.Body.Close()
  3924. body, ioErr := ioutil.ReadAll(resp.Body)
  3925. if ioErr != nil {
  3926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3928. return res
  3929. }
  3930. var respJSON map[string]interface{}
  3931. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3934. return res
  3935. }
  3936. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3937. fmt.Println(respJSON)
  3938. result, _ := json.Marshal(respJSON)
  3939. fmt.Println(result)
  3940. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3941. utils.ErrorLog("解析失败:%v", err)
  3942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3943. return res
  3944. }
  3945. return res
  3946. }
  3947. 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) {
  3948. adminUser := c.GetAdminUserInfo()
  3949. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3950. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3951. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3952. //record_time := c.GetString("record_time")
  3953. //trig_scen := c.GetString("trig_scen")
  3954. timeLayout := "2006-01-02"
  3955. loc, _ := time.LoadLocation("Local")
  3956. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3957. if err != nil {
  3958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3959. return res
  3960. }
  3961. recordDateTime := theTime.Unix()
  3962. var patientPrescription models.HisPrescriptionInfo
  3963. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3964. if patientPrescription.ID == 0 {
  3965. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3966. }
  3967. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3968. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3969. //
  3970. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  3971. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3972. var pp models.PublicParams
  3973. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3974. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3975. pp.FixmedinsName = miConfig.OrgName
  3976. pp.FixmedinsCode = miConfig.Code
  3977. pp.RequestUrl = miConfig.Url
  3978. pp.Cainfo = miConfig.Cainfo
  3979. pp.SecretKey = miConfig.SecretKey
  3980. pp.AccessKey = miConfig.AccessKey
  3981. pp.OpterName = roles.UserName
  3982. var config []*models.HisXtDiagnoseConfig
  3983. for _, item := range diagnosis_ids {
  3984. id, _ := strconv.ParseInt(item, 10, 64)
  3985. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3986. config = append(config, &diagnosisConfig)
  3987. }
  3988. var pd models.PatientDtos
  3989. pd.PatnID = his.PsnNo
  3990. pd.PatnName = his.Name
  3991. pd.Gend = his.Gend
  3992. pd.Brdy = his.Brdy
  3993. pd.Poolarea = his.InsuplcAdmdvs
  3994. pd.CurrMdtrtID = his.Number
  3995. var fed models.FsiEncounterDtos
  3996. fed.MdtrtID = his.Number
  3997. fed.MedinsID = miConfig.Code
  3998. fed.MedinsName = miConfig.OrgName
  3999. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  4000. fed.MedMdtrtType = "1"
  4001. fed.MedinsType = "1"
  4002. fed.MedinsLv = "11"
  4003. tm := time.Unix(his.RecordDate, 0)
  4004. s_tm := tm.Format("2006-01-02 15:04:05")
  4005. fed.AdmDate = s_tm
  4006. fed.DscgDate = s_tm
  4007. fed.DscgMainDiseCodg = config[0].CountryCode
  4008. fed.DscgMainDiseName = config[0].CountryContentName
  4009. //诊断信息
  4010. var fdds []*models.FsiDiagnoseDtos
  4011. for index, item := range config {
  4012. if index == 0 {
  4013. var fdd models.FsiDiagnoseDtos
  4014. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4015. fdd.InoutDiseType = "1"
  4016. fdd.MaindiseFlag = "1"
  4017. fdd.DiseDate = s_tm
  4018. fdd.DiasSrtNo = "1"
  4019. fdd.DiseName = item.CountryContentName
  4020. fdd.DiseCodg = item.CountryCode
  4021. fdds = append(fdds, &fdd)
  4022. } else {
  4023. var fdd models.FsiDiagnoseDtos
  4024. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4025. fdd.InoutDiseType = "1"
  4026. fdd.MaindiseFlag = "1"
  4027. fdd.DiseDate = s_tm
  4028. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  4029. fdd.DiseName = item.CountryContentName
  4030. fdd.DiseCodg = item.CountryCode
  4031. fdds = append(fdds, &fdd)
  4032. }
  4033. }
  4034. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  4035. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  4036. fed.AdmDeptName = department.Name
  4037. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  4038. fed.DscgDeptName = department.Name
  4039. fed.MedMdtrtType = "1"
  4040. fed.MedType = "11"
  4041. //if his.Insutype == "390" {
  4042. // fed.MedType = "1402"
  4043. //} else {
  4044. // fed.MedType = "9933"
  4045. //}
  4046. var orders []*models.FsiOrderDtos
  4047. if trig_scen == "2" {
  4048. //处方医嘱信息
  4049. for _, item := range prescriptions {
  4050. for _, subItem := range item.HisDoctorAdviceInfo {
  4051. var order models.FsiOrderDtos
  4052. order.RxID = strconv.FormatInt(item.ID, 10)
  4053. order.Rxno = strconv.FormatInt(item.ID, 10)
  4054. order.LongDrordFlag = "0"
  4055. order.HilistType = "1"
  4056. order.ChrgType = "1"
  4057. order.DrordBhvr = "-"
  4058. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4059. order.HosplistName = subItem.BaseDrugLib.DrugName
  4060. order.HilistLv = "1"
  4061. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4062. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4063. order.HosplistName = subItem.BaseDrugLib.DrugName
  4064. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  4065. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4066. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  4067. order.OwnpayAmt = ""
  4068. order.SelfpayAmt = ""
  4069. order.Spec = ""
  4070. order.SpecUnt = ""
  4071. order.DrordBegnDate = s_tm
  4072. order.DrordStopDate = ""
  4073. order.DrordDrCodg = "1"
  4074. order.DrordDeptName = department.Name
  4075. order.DrordDrCodg = "1"
  4076. order.DrordDrName = doctor_info.UserName
  4077. order.DrordDrProfttl = ""
  4078. order.CurrDrordFlag = "1"
  4079. orders = append(orders, &order)
  4080. }
  4081. for _, subItem := range item.HisPrescriptionProject {
  4082. if subItem.Type == 2 {
  4083. var order models.FsiOrderDtos
  4084. order.RxID = strconv.FormatInt(item.ID, 10)
  4085. order.Rxno = strconv.FormatInt(item.ID, 10)
  4086. order.LongDrordFlag = "0"
  4087. order.HilistType = "1"
  4088. order.ChrgType = "1"
  4089. order.DrordBhvr = "-"
  4090. order.HilistCode = subItem.HisProject.MedicalCode
  4091. order.HosplistName = subItem.HisProject.ProjectName
  4092. order.HilistLv = "1"
  4093. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4094. order.HosplistCode = subItem.HisProject.MedicalCode
  4095. order.HosplistName = subItem.HisProject.ProjectName
  4096. order.Cnt = subItem.Count
  4097. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4098. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4099. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4100. order.OwnpayAmt = ""
  4101. order.SelfpayAmt = ""
  4102. order.Spec = ""
  4103. order.SpecUnt = ""
  4104. order.DrordBegnDate = s_tm
  4105. order.DrordStopDate = ""
  4106. order.DrordDrCodg = "1"
  4107. order.DrordDeptName = department.Name
  4108. order.DrordDrCodg = "1"
  4109. order.DrordDrName = doctor_info.UserName
  4110. order.DrordDrProfttl = ""
  4111. order.CurrDrordFlag = "1"
  4112. orders = append(orders, &order)
  4113. }
  4114. if subItem.Type == 3 {
  4115. var order models.FsiOrderDtos
  4116. order.RxID = strconv.FormatInt(item.ID, 10)
  4117. order.Rxno = strconv.FormatInt(item.ID, 10)
  4118. order.LongDrordFlag = "0"
  4119. order.HilistType = "1"
  4120. order.ChrgType = "1"
  4121. order.DrordBhvr = "-"
  4122. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4123. order.HosplistName = subItem.GoodInfo.GoodName
  4124. order.HilistLv = "1"
  4125. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4126. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4127. order.HosplistName = subItem.GoodInfo.GoodName
  4128. order.Cnt = subItem.Count
  4129. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4130. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4131. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4132. order.OwnpayAmt = ""
  4133. order.SelfpayAmt = ""
  4134. order.Spec = ""
  4135. order.SpecUnt = ""
  4136. order.DrordBegnDate = s_tm
  4137. order.DrordStopDate = ""
  4138. order.DrordDrCodg = "1"
  4139. order.DrordDeptName = department.Name
  4140. order.DrordDrCodg = "1"
  4141. order.DrordDrName = doctor_info.UserName
  4142. order.DrordDrProfttl = ""
  4143. order.CurrDrordFlag = "1"
  4144. orders = append(orders, &order)
  4145. }
  4146. }
  4147. }
  4148. //处方医嘱信息
  4149. }
  4150. fed.MatnStas = "0"
  4151. fed.MedfeeSumamt = "0"
  4152. fed.OwnpayAmt = "0"
  4153. fed.SelfpayAmt = "0"
  4154. fed.AcctPayamt = "0"
  4155. fed.MaAmt = "0"
  4156. fed.HifpPayamt = "0"
  4157. fed.SetlTotlnum = "1"
  4158. fed.Insutype = his.Insutype
  4159. fed.ReimFlag = "0"
  4160. fed.OutSetlFlag = "0"
  4161. var fopd []*models.FsiOperationDtosData
  4162. data := make(map[string]interface{})
  4163. data["fed"] = fed
  4164. data["fdd"] = fdds
  4165. data["fod"] = orders
  4166. data["pd"] = pd
  4167. data["pp"] = pp
  4168. data["fopd"] = fopd
  4169. data["trig_scen"] = trig_scen
  4170. fmt.Println(data)
  4171. fmt.Println(fed)
  4172. fmt.Println(fdds)
  4173. fmt.Println(orders)
  4174. fmt.Println(pd)
  4175. fmt.Println(pp)
  4176. fmt.Println(fopd)
  4177. client := &http.Client{}
  4178. bytesData, _ := json.Marshal(data)
  4179. var req *http.Request
  4180. if miConfig.MdtrtareaAdmvs == "320921" {
  4181. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  4182. } else {
  4183. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  4184. }
  4185. resp, _ := client.Do(req)
  4186. defer resp.Body.Close()
  4187. body, ioErr := ioutil.ReadAll(resp.Body)
  4188. if ioErr != nil {
  4189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4191. return res
  4192. }
  4193. var respJSON map[string]interface{}
  4194. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4197. return res
  4198. }
  4199. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4200. result, _ := json.Marshal(respJSON)
  4201. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4202. utils.ErrorLog("解析失败:%v", err)
  4203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4204. return res
  4205. }
  4206. return res
  4207. }
  4208. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  4209. ////patient_id, _ := c.GetInt64("patient_id")
  4210. //order_id, _ := c.GetInt64("order_id")
  4211. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  4212. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  4213. //trig_scen := c.GetString("trig_scen")
  4214. adminUser := c.GetAdminUserInfo()
  4215. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4216. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4217. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4218. record_time := c.GetString("record_time")
  4219. order, _ := service.GetHisOrderByID(order_id)
  4220. timeLayout := "2006-01-02"
  4221. loc, _ := time.LoadLocation("Local")
  4222. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4223. if err != nil {
  4224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4225. return
  4226. }
  4227. recordDateTime := theTime.Unix()
  4228. var patientPrescription models.HisPrescriptionInfo
  4229. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4230. if patientPrescription.ID == 0 {
  4231. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4232. }
  4233. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4234. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4235. //
  4236. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4237. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4238. var pp models.PublicParams
  4239. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4240. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4241. pp.FixmedinsName = miConfig.OrgName
  4242. pp.FixmedinsCode = miConfig.Code
  4243. pp.RequestUrl = miConfig.Url
  4244. pp.Cainfo = miConfig.Cainfo
  4245. pp.SecretKey = miConfig.SecretKey
  4246. pp.AccessKey = miConfig.AccessKey
  4247. pp.OpterName = roles.UserName
  4248. var config []*models.HisXtDiagnoseConfig
  4249. for _, item := range diagnosis_ids {
  4250. id, _ := strconv.ParseInt(item, 10, 64)
  4251. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4252. config = append(config, &diagnosisConfig)
  4253. }
  4254. var pd models.PatientDtos
  4255. pd.PatnID = his.PsnNo
  4256. pd.PatnName = his.Name
  4257. pd.Gend = his.Gend
  4258. pd.Brdy = his.Brdy
  4259. pd.Poolarea = his.InsuplcAdmdvs
  4260. pd.CurrMdtrtID = his.Number
  4261. var fed models.FsiEncounterDtos
  4262. fed.MdtrtID = his.Number
  4263. fed.MedinsID = miConfig.Code
  4264. fed.MedinsName = miConfig.OrgName
  4265. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  4266. fed.MedMdtrtType = "1"
  4267. fed.MedinsType = "1"
  4268. fed.MedinsLv = "11"
  4269. tm := time.Unix(his.RecordDate, 0)
  4270. s_tm := tm.Format("2006-01-02 15:04:05")
  4271. fed.AdmDate = s_tm
  4272. fed.DscgDate = s_tm
  4273. fed.DscgMainDiseCodg = config[0].CountryCode
  4274. fed.DscgMainDiseName = config[0].CountryContentName
  4275. //诊断信息
  4276. var fdds []*models.FsiDiagnoseDtos
  4277. for index, item := range config {
  4278. if index == 0 {
  4279. var fdd models.FsiDiagnoseDtos
  4280. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4281. fdd.InoutDiseType = "1"
  4282. fdd.MaindiseFlag = "1"
  4283. fdd.DiseDate = s_tm
  4284. fdd.DiasSrtNo = "1"
  4285. fdd.DiseName = item.CountryContentName
  4286. fdd.DiseCodg = item.CountryCode
  4287. fdds = append(fdds, &fdd)
  4288. } else {
  4289. var fdd models.FsiDiagnoseDtos
  4290. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4291. fdd.InoutDiseType = "1"
  4292. fdd.MaindiseFlag = "1"
  4293. fdd.DiseDate = s_tm
  4294. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  4295. fdd.DiseName = item.CountryContentName
  4296. fdd.DiseCodg = item.CountryCode
  4297. fdds = append(fdds, &fdd)
  4298. }
  4299. }
  4300. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  4301. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  4302. fed.AdmDeptName = department.Name
  4303. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  4304. fed.DscgDeptName = department.Name
  4305. fed.MedType = order.MedType
  4306. //处方医嘱信息
  4307. var orders []*models.FsiOrderDtos
  4308. //for _, item := range prescriptions {
  4309. // for _, subItem := range item.HisDoctorAdviceInfo {
  4310. // var order models.FsiOrderDtos
  4311. // order.RxID = strconv.FormatInt(item.ID, 10)
  4312. // order.Rxno = strconv.FormatInt(item.ID, 10)
  4313. // order.LongDrordFlag = "0"
  4314. // order.HilistType = "1"
  4315. // order.ChrgType = "1"
  4316. // order.DrordBhvr = "-"
  4317. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4318. // order.HosplistName = subItem.BaseDrugLib.DrugName
  4319. // order.HilistLv = "1"
  4320. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4321. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4322. // order.HosplistName = subItem.BaseDrugLib.DrugName
  4323. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  4324. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4325. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  4326. // order.OwnpayAmt = ""
  4327. // order.SelfpayAmt = ""
  4328. // order.Spec = ""
  4329. // order.SpecUnt = ""
  4330. // order.DrordBegnDate = s_tm
  4331. // order.DrordStopDate = ""
  4332. // order.DrordDrCodg = "1"
  4333. // order.DrordDeptName = department.Name
  4334. // order.DrordDrCodg = "1"
  4335. // order.DrordDrName = doctor_info.UserName
  4336. // order.DrordDrProfttl = ""
  4337. // order.CurrDrordFlag = "1"
  4338. // orders = append(orders, &order)
  4339. // }
  4340. // for _, subItem := range item.HisPrescriptionProject {
  4341. // if subItem.Type == 2 {
  4342. // var order models.FsiOrderDtos
  4343. // order.RxID = strconv.FormatInt(item.ID, 10)
  4344. // order.Rxno = strconv.FormatInt(item.ID, 10)
  4345. // order.LongDrordFlag = "0"
  4346. // order.HilistType = "1"
  4347. // order.ChrgType = "1"
  4348. // order.DrordBhvr = "-"
  4349. // order.HilistCode = subItem.HisProject.MedicalCode
  4350. // order.HosplistName = subItem.HisProject.ProjectName
  4351. // order.HilistLv = "1"
  4352. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4353. // order.HosplistCode = subItem.HisProject.MedicalCode
  4354. // order.HosplistName = subItem.HisProject.ProjectName
  4355. // order.Cnt = subItem.Count
  4356. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4357. //
  4358. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4359. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  4360. // order.OwnpayAmt = ""
  4361. // order.SelfpayAmt = ""
  4362. // order.Spec = ""
  4363. // order.SpecUnt = ""
  4364. // order.DrordBegnDate = s_tm
  4365. // order.DrordStopDate = ""
  4366. // order.DrordDrCodg = "1"
  4367. // order.DrordDeptName = department.Name
  4368. // order.DrordDrCodg = "1"
  4369. // order.DrordDrName = doctor_info.UserName
  4370. // order.DrordDrProfttl = ""
  4371. // order.CurrDrordFlag = "1"
  4372. // orders = append(orders, &order)
  4373. //
  4374. // }
  4375. // if subItem.Type == 3 {
  4376. //
  4377. // var order models.FsiOrderDtos
  4378. // order.RxID = strconv.FormatInt(item.ID, 10)
  4379. // order.Rxno = strconv.FormatInt(item.ID, 10)
  4380. // order.LongDrordFlag = "0"
  4381. // order.HilistType = "1"
  4382. // order.ChrgType = "1"
  4383. // order.DrordBhvr = "-"
  4384. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4385. // order.HosplistName = subItem.GoodInfo.GoodName
  4386. // order.HilistLv = "1"
  4387. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4388. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4389. // order.HosplistName = subItem.GoodInfo.GoodName
  4390. // order.Cnt = subItem.Count
  4391. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4392. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  4393. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  4394. // order.OwnpayAmt = ""
  4395. // order.SelfpayAmt = ""
  4396. // order.Spec = ""
  4397. // order.SpecUnt = ""
  4398. // order.DrordBegnDate = s_tm
  4399. // order.DrordStopDate = ""
  4400. // order.DrordDrCodg = "1"
  4401. // order.DrordDeptName = department.Name
  4402. // order.DrordDrCodg = "1"
  4403. // order.DrordDrName = doctor_info.UserName
  4404. // order.DrordDrProfttl = ""
  4405. // order.CurrDrordFlag = "1"
  4406. // orders = append(orders, &order)
  4407. //
  4408. // }
  4409. // }
  4410. //}
  4411. for _, item := range prescriptions {
  4412. for _, subItem := range item.HisDoctorAdviceInfo {
  4413. var order models.FsiOrderDtos
  4414. order.RxID = strconv.FormatInt(item.ID, 10)
  4415. order.Rxno = strconv.FormatInt(item.ID, 10)
  4416. order.LongDrordFlag = "0"
  4417. order.HilistType = "1"
  4418. order.ChrgType = "1"
  4419. order.DrordBhvr = "-"
  4420. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4421. order.HosplistName = subItem.BaseDrugLib.DrugName
  4422. order.HilistLv = "1"
  4423. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4424. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4425. order.HosplistName = subItem.BaseDrugLib.DrugName
  4426. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  4427. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4428. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  4429. order.OwnpayAmt = ""
  4430. order.SelfpayAmt = ""
  4431. order.Spec = ""
  4432. order.SpecUnt = ""
  4433. order.DrordBegnDate = s_tm
  4434. order.DrordStopDate = ""
  4435. order.DrordDrCodg = "1"
  4436. order.DrordDeptName = department.Name
  4437. order.DrordDrCodg = "1"
  4438. order.DrordDrName = doctor_info.UserName
  4439. order.DrordDrProfttl = ""
  4440. order.CurrDrordFlag = "1"
  4441. orders = append(orders, &order)
  4442. }
  4443. for _, subItem := range item.HisPrescriptionProject {
  4444. if subItem.Type == 2 {
  4445. var order models.FsiOrderDtos
  4446. order.RxID = strconv.FormatInt(item.ID, 10)
  4447. order.Rxno = strconv.FormatInt(item.ID, 10)
  4448. order.LongDrordFlag = "0"
  4449. order.HilistType = "1"
  4450. order.ChrgType = "1"
  4451. order.DrordBhvr = "-"
  4452. order.HilistCode = subItem.HisProject.MedicalCode
  4453. order.HosplistName = subItem.HisProject.ProjectName
  4454. order.HilistLv = "1"
  4455. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4456. order.HosplistCode = subItem.HisProject.MedicalCode
  4457. order.HosplistName = subItem.HisProject.ProjectName
  4458. order.Cnt = subItem.Count
  4459. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4460. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4461. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4462. order.OwnpayAmt = ""
  4463. order.SelfpayAmt = ""
  4464. order.Spec = ""
  4465. order.SpecUnt = ""
  4466. order.DrordBegnDate = s_tm
  4467. order.DrordStopDate = ""
  4468. order.DrordDrCodg = "1"
  4469. order.DrordDeptName = department.Name
  4470. order.DrordDrCodg = "1"
  4471. order.DrordDrName = doctor_info.UserName
  4472. order.DrordDrProfttl = ""
  4473. order.CurrDrordFlag = "1"
  4474. orders = append(orders, &order)
  4475. }
  4476. if subItem.Type == 3 {
  4477. var order models.FsiOrderDtos
  4478. order.RxID = strconv.FormatInt(item.ID, 10)
  4479. order.Rxno = strconv.FormatInt(item.ID, 10)
  4480. order.LongDrordFlag = "0"
  4481. order.HilistType = "1"
  4482. order.ChrgType = "1"
  4483. order.DrordBhvr = "-"
  4484. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4485. order.HosplistName = subItem.GoodInfo.GoodName
  4486. order.HilistLv = "1"
  4487. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4488. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4489. order.HosplistName = subItem.GoodInfo.GoodName
  4490. order.Cnt = subItem.Count
  4491. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4492. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4493. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4494. order.OwnpayAmt = ""
  4495. order.SelfpayAmt = ""
  4496. order.Spec = ""
  4497. order.SpecUnt = ""
  4498. order.DrordBegnDate = s_tm
  4499. order.DrordStopDate = ""
  4500. order.DrordDrCodg = "1"
  4501. order.DrordDeptName = department.Name
  4502. order.DrordDrCodg = "1"
  4503. order.DrordDrName = doctor_info.UserName
  4504. order.DrordDrProfttl = ""
  4505. order.CurrDrordFlag = "1"
  4506. orders = append(orders, &order)
  4507. }
  4508. }
  4509. }
  4510. //处方医嘱信息
  4511. fed.MatnStas = "0"
  4512. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4513. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  4514. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  4515. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  4516. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  4517. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  4518. fed.SetlTotlnum = "1"
  4519. fed.Insutype = his.Insutype
  4520. fed.ReimFlag = "0"
  4521. fed.OutSetlFlag = "0"
  4522. var fopd []*models.FsiOperationDtosData
  4523. data := make(map[string]interface{})
  4524. data["fed"] = fed
  4525. data["fdd"] = fdds
  4526. data["fod"] = orders
  4527. data["pd"] = pd
  4528. data["pp"] = pp
  4529. data["fopd"] = fopd
  4530. data["trig_scen"] = trig_scen
  4531. client := &http.Client{}
  4532. bytesData, _ := json.Marshal(data)
  4533. var req *http.Request
  4534. if miConfig.MdtrtareaAdmvs == "320921" {
  4535. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  4536. } else {
  4537. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  4538. }
  4539. resp, _ := client.Do(req)
  4540. defer resp.Body.Close()
  4541. body, ioErr := ioutil.ReadAll(resp.Body)
  4542. if ioErr != nil {
  4543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4545. return res
  4546. }
  4547. var respJSON map[string]interface{}
  4548. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4551. return res
  4552. }
  4553. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4554. result, _ := json.Marshal(respJSON)
  4555. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4556. utils.ErrorLog("解析失败:%v", err)
  4557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4558. return res
  4559. }
  4560. return res
  4561. //手术操作集合
  4562. //手术操作集合
  4563. }
  4564. func (c *HisApiController) Check() {
  4565. psn_no := c.GetString("psn_no")
  4566. in := c.GetString("in")
  4567. mt := c.GetString("mt")
  4568. baseParams := models.BaseParams{
  4569. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  4570. FixmedinsCode: "H15049901371",
  4571. InsuplcAdmdvs: "150499",
  4572. MdtrtareaAdmvs: "150499",
  4573. OrgName: "赤峰费森血液透析中心",
  4574. Doctor: "1111",
  4575. }
  4576. service.Gdyb2001(baseParams, psn_no, in, mt)
  4577. }
  4578. func (c *HisApiController) GetPsnNcdsInfo() {
  4579. admin_user_id, _ := c.GetInt64("admin_user_id")
  4580. patient_id, _ := c.GetInt64("patient_id")
  4581. id, _ := c.GetInt64("id")
  4582. adminUser := c.GetAdminUserInfo()
  4583. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4584. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4585. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  4586. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4587. psn_record, _ := service.GetPsnNCDSRecordById(id)
  4588. //
  4589. //if psn_record.ID == 0 {
  4590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  4591. // return
  4592. //}
  4593. var res Result5301
  4594. var res10265 Result5301For10265
  4595. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4596. psn_info, _ := service.GetPsnByPatientId(patient_id)
  4597. var api string
  4598. if miConfig.MdtrtareaAdmvs == "320921" {
  4599. 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 +
  4600. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  4601. } else {
  4602. 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 +
  4603. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  4604. }
  4605. resp, requestErr := http.Get(api)
  4606. if requestErr != nil {
  4607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4608. return
  4609. }
  4610. body, ioErr := ioutil.ReadAll(resp.Body)
  4611. if ioErr != nil {
  4612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4614. return
  4615. }
  4616. var respJSON map[string]interface{}
  4617. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4620. return
  4621. }
  4622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4623. result, _ := json.Marshal(respJSON)
  4624. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4625. utils.ErrorLog("解析失败:%v", err)
  4626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4627. return
  4628. }
  4629. res.ErrMsg = res10265.ErrMsg
  4630. res.Output = res10265.Output
  4631. res.InfRefmsgid = res10265.InfRefmsgid
  4632. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4633. res.Infcode = infocode
  4634. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4635. p, _ := service.GetHisPatientById(patient_id)
  4636. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  4637. var dat map[string]interface{}
  4638. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4639. fmt.Println(dat)
  4640. } else {
  4641. fmt.Println(err)
  4642. }
  4643. userJSONBytes, _ := json.Marshal(dat)
  4644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4645. utils.ErrorLog("解析失败:%v", err)
  4646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4647. return
  4648. }
  4649. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4650. p, _ := service.GetHisPatientById(patient_id)
  4651. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  4652. var dat map[string]interface{}
  4653. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4654. fmt.Println(dat)
  4655. } else {
  4656. fmt.Println(err)
  4657. }
  4658. userJSONBytes, _ := json.Marshal(dat)
  4659. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4660. utils.ErrorLog("解析失败:%v", err)
  4661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4662. return
  4663. }
  4664. } else {
  4665. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4666. var dat map[string]interface{}
  4667. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4668. fmt.Println(dat)
  4669. } else {
  4670. fmt.Println(err)
  4671. }
  4672. userJSONBytes, _ := json.Marshal(dat)
  4673. if miConfig.Code == "H15049901371" {
  4674. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  4675. utils.ErrorLog("解析失败:%v", err)
  4676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4677. return
  4678. }
  4679. res.InfRefmsgid = res10265.InfRefmsgid
  4680. res.Output = res10265.Output
  4681. res.ErrMsg = res10265.ErrMsg
  4682. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4683. res.Infcode = infocode
  4684. } else {
  4685. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4686. utils.ErrorLog("解析失败:%v", err)
  4687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4688. return
  4689. }
  4690. }
  4691. }
  4692. if res.Infcode == 0 {
  4693. c.ServeSuccessJSON(map[string]interface{}{
  4694. "result": res.Output.Result,
  4695. })
  4696. }
  4697. }
  4698. func (c *HisApiController) CheckInsutype() {
  4699. his_patient_id, _ := c.GetInt64("his_patient_id")
  4700. admin_user_id, _ := c.GetInt64("admin_user_id")
  4701. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4702. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4703. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4704. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4705. var dat map[string]interface{}
  4706. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4707. fmt.Println(dat)
  4708. } else {
  4709. fmt.Println(err)
  4710. }
  4711. userJSONBytes, _ := json.Marshal(dat)
  4712. var res Result90100
  4713. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4714. utils.ErrorLog("解析失败:%v", err)
  4715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4716. return
  4717. }
  4718. if res.Infcode != 0 {
  4719. c.ServeSuccessJSON(map[string]interface{}{
  4720. "failed_code": -10,
  4721. "msg": res.ErrMsg,
  4722. })
  4723. return
  4724. } else {
  4725. fmt.Println(res)
  4726. }
  4727. }
  4728. func (c *HisApiController) CheckCardPWD() {
  4729. card_pwd := c.GetString("card_pwd")
  4730. his_patient_id, _ := c.GetInt64("his_patient_id")
  4731. admin_user_id, _ := c.GetInt64("admin_user_id")
  4732. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4733. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4734. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4735. psn, _ := service.GetPsnByPatientId(his.PatientId)
  4736. bas := strings.Split(psn.CardInfo, "|")
  4737. basNumber := bas[2]
  4738. if psn.InsuplcAdmdvs[:4] == "4403" {
  4739. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  4740. var dat map[string]interface{}
  4741. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4742. fmt.Println(dat)
  4743. } else {
  4744. fmt.Println(err)
  4745. }
  4746. userJSONBytes, _ := json.Marshal(dat)
  4747. var res Result90991
  4748. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4749. utils.ErrorLog("解析失败:%v", err)
  4750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4751. return
  4752. }
  4753. if res.Infcode != 0 {
  4754. c.ServeSuccessJSON(map[string]interface{}{
  4755. "failed_code": -10,
  4756. "msg": res.ErrMsg,
  4757. })
  4758. return
  4759. } else {
  4760. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  4761. var msg string
  4762. switch res.Output.Result.CardStat {
  4763. case "00":
  4764. msg = "未激活"
  4765. break
  4766. case "10":
  4767. msg = "激活"
  4768. break
  4769. case "20":
  4770. msg = "窗口挂失"
  4771. break
  4772. case "21":
  4773. msg = "电话挂失"
  4774. break
  4775. case "22":
  4776. msg = "单位网上申报挂失"
  4777. break
  4778. case "23":
  4779. msg = "保健办挂失"
  4780. break
  4781. case "24":
  4782. msg = "个人网上挂失"
  4783. break
  4784. case "25":
  4785. msg = "网上服务大厅挂失"
  4786. break
  4787. case "30":
  4788. msg = "注销"
  4789. break
  4790. case "40":
  4791. msg = "回收"
  4792. break
  4793. case "99":
  4794. msg = "制卡中(无效卡)"
  4795. break
  4796. }
  4797. c.ServeSuccessJSON(map[string]interface{}{
  4798. "failed_code": -10,
  4799. "msg": msg,
  4800. })
  4801. return
  4802. } else {
  4803. c.ServeSuccessJSON(map[string]interface{}{
  4804. "msg": "校验成功",
  4805. })
  4806. return
  4807. }
  4808. }
  4809. } else {
  4810. c.ServeSuccessJSON(map[string]interface{}{
  4811. "msg": "校验成功",
  4812. })
  4813. return
  4814. }
  4815. }
  4816. func (c *HisApiController) CheckCardPWDTwo() {
  4817. //card_pwd := c.GetString("card_pwd")
  4818. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4819. admin_user_id, _ := c.GetInt64("admin_user_id")
  4820. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4821. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4822. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  4823. var dat map[string]interface{}
  4824. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4825. fmt.Println(dat)
  4826. } else {
  4827. fmt.Println(err)
  4828. }
  4829. userJSONBytes, _ := json.Marshal(dat)
  4830. var res Result90991
  4831. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4832. utils.ErrorLog("解析失败:%v", err)
  4833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4834. return
  4835. }
  4836. if res.Infcode != 0 {
  4837. c.ServeSuccessJSON(map[string]interface{}{
  4838. "failed_code": -10,
  4839. "msg": res.ErrMsg,
  4840. })
  4841. return
  4842. } else {
  4843. if res.Output.Result.SscnoCheckStat == "0" {
  4844. var msg string
  4845. switch res.Output.Result.CardStat {
  4846. case "00":
  4847. msg = "未激活"
  4848. break
  4849. case "10":
  4850. msg = "激活"
  4851. break
  4852. case "20":
  4853. msg = "窗口挂失"
  4854. break
  4855. case "21":
  4856. msg = "电话挂失"
  4857. break
  4858. case "22":
  4859. msg = "单位网上申报挂失"
  4860. break
  4861. case "23":
  4862. msg = "保健办挂失"
  4863. break
  4864. case "24":
  4865. msg = "个人网上挂失"
  4866. break
  4867. case "25":
  4868. msg = "网上服务大厅挂失"
  4869. break
  4870. case "30":
  4871. msg = "注销"
  4872. break
  4873. case "40":
  4874. msg = "回收"
  4875. break
  4876. case "99":
  4877. msg = "制卡中(无效卡)"
  4878. break
  4879. }
  4880. c.ServeSuccessJSON(map[string]interface{}{
  4881. "failed_code": -10,
  4882. "msg": msg,
  4883. })
  4884. return
  4885. } else {
  4886. c.ServeSuccessJSON(map[string]interface{}{
  4887. "msg": "校验成功",
  4888. })
  4889. return
  4890. }
  4891. }
  4892. }
  4893. type ELeCertData struct {
  4894. Data struct {
  4895. Extra string `json:"extra"`
  4896. IDNo string `json:"idNo"`
  4897. IDType string `json:"idType"`
  4898. EcToken string `json:"ecToken"`
  4899. InsuOrg string `json:"insuOrg"`
  4900. UserName string `json:"userName"`
  4901. EcIndexNo string `json:"ecIndexNo"`
  4902. Gender string `json:"gender"`
  4903. Birthday string `json:"birthday"`
  4904. Nationality string `json:"nationality"`
  4905. Email string `json:"email"`
  4906. } `json:"OutData"`
  4907. }
  4908. func (c *HisApiController) ReadCard() {
  4909. id_card_type, _ := c.GetInt64("id_card_type")
  4910. admin_user_id, _ := c.GetInt64("admin_user_id")
  4911. certificates, _ := c.GetInt64("certificates")
  4912. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  4913. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4914. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4915. switch id_card_type {
  4916. case 1:
  4917. if miConfig.MdtrtareaAdmvs == "421300" {
  4918. var res ResultTwo
  4919. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  4920. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4921. "&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)
  4922. resp, requestErr := http.Get(api)
  4923. if requestErr != nil {
  4924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4925. return
  4926. }
  4927. body, ioErr := ioutil.ReadAll(resp.Body)
  4928. if ioErr != nil {
  4929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4931. return
  4932. }
  4933. var respJSON map[string]interface{}
  4934. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4937. return
  4938. }
  4939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4940. result, _ := json.Marshal(respJSON)
  4941. fmt.Println("log")
  4942. fmt.Println(string(result))
  4943. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4944. utils.ErrorLog("解析失败:%v", err)
  4945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4946. return
  4947. }
  4948. if res.Infcode == 0 {
  4949. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4950. if err == gorm.ErrRecordNotFound {
  4951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4952. return
  4953. } else if err != nil {
  4954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4955. return
  4956. } else {
  4957. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4958. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4959. infoStr := string(Iinfos)
  4960. idetinfoStr := string(Idetinfos)
  4961. psn := &models.HisPsn{
  4962. PsnNo: res.Output.Baseinfo.PsnNo,
  4963. Age: res.Output.Baseinfo.Age,
  4964. PatientId: patient.ID,
  4965. Certno: res.Output.Baseinfo.Certno,
  4966. Brdy: res.Output.Baseinfo.Brdy,
  4967. Gend: res.Output.Baseinfo.Gend,
  4968. Naty: res.Output.Baseinfo.Naty,
  4969. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4970. PsnName: res.Output.Baseinfo.PsnName,
  4971. Idetinfo: idetinfoStr,
  4972. Insuinfo: infoStr,
  4973. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4974. }
  4975. service.CreateHisPsn(psn)
  4976. c.ServeSuccessJSON(map[string]interface{}{
  4977. "patient": patient,
  4978. "number": res.Output.Baseinfo.Certno,
  4979. })
  4980. }
  4981. } else {
  4982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4983. return
  4984. }
  4985. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4986. var api string
  4987. if miConfig.MdtrtareaAdmvs == "320921" {
  4988. 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 +
  4989. "&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
  4990. fmt.Println(api)
  4991. } else {
  4992. 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 +
  4993. "&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)
  4994. }
  4995. resp, requestErr := http.Get(api)
  4996. if requestErr != nil {
  4997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4998. return
  4999. }
  5000. body, ioErr := ioutil.ReadAll(resp.Body)
  5001. if ioErr != nil {
  5002. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5004. return
  5005. }
  5006. var respJSON map[string]interface{}
  5007. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5010. return
  5011. }
  5012. var status string
  5013. status = respJSON["data"].(map[string]interface{})["status"].(string)
  5014. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  5015. //console.log()
  5016. fmt.Println("type===")
  5017. fmt.Println(card_type)
  5018. var token string
  5019. var res ResultTwo //1101结果
  5020. var res10265 ResultTwo10265 //1101结果
  5021. var card_info string //卡信息
  5022. var busi_card_info string
  5023. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  5024. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5025. if status == "0" { //读卡成功
  5026. if card_type == "1" {
  5027. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5028. result, _ := json.Marshal(respJSON)
  5029. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5030. utils.ErrorLog("解析失败:%v", err)
  5031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5032. return
  5033. }
  5034. res.ErrMsg = res10265.ErrMsg
  5035. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5036. res.Infcode = infocode
  5037. res.Output = res10265.Output
  5038. res.InfRefmsgid = res10265.InfRefmsgid
  5039. } else {
  5040. //var card_info string //卡信息
  5041. //var busi_card_info string
  5042. token = respJSON["data"].(map[string]interface{})["token"].(string)
  5043. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5044. //fmt.Println(card_info)
  5045. //fmt.Println(busi_card_info)
  5046. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5047. result, _ := json.Marshal(respJSON)
  5048. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5049. utils.ErrorLog("解析失败:%v", err)
  5050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5051. return
  5052. }
  5053. res.ErrMsg = res10265.ErrMsg
  5054. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5055. res.Infcode = infocode
  5056. res.Output = res10265.Output
  5057. res.InfRefmsgid = res10265.InfRefmsgid
  5058. }
  5059. if res.Infcode == 0 {
  5060. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5061. if err == gorm.ErrRecordNotFound {
  5062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5063. return
  5064. } else if err != nil {
  5065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5066. return
  5067. } else {
  5068. if card_type == "1" {
  5069. bas := strings.Split(card_info, "|")
  5070. basNumber := bas[2]
  5071. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5072. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5073. infoStr := string(Iinfos)
  5074. idetinfoStr := string(Idetinfos)
  5075. psn := &models.HisPsn{
  5076. PsnNo: res.Output.Baseinfo.PsnNo,
  5077. Age: res.Output.Baseinfo.Age,
  5078. PatientId: patient.ID,
  5079. Certno: res.Output.Baseinfo.Certno,
  5080. Brdy: res.Output.Baseinfo.Brdy,
  5081. Gend: res.Output.Baseinfo.Gend,
  5082. Naty: res.Output.Baseinfo.Naty,
  5083. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5084. PsnName: res.Output.Baseinfo.PsnName,
  5085. Idetinfo: idetinfoStr,
  5086. Insuinfo: infoStr,
  5087. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5088. CardInfo: card_info,
  5089. VerifyNumber: busi_card_info,
  5090. }
  5091. service.CreateHisPsn(psn)
  5092. var rf []*ResultFive
  5093. json.Unmarshal([]byte(infoStr), &rf)
  5094. var insutypes []*ResultFive
  5095. var insutype string
  5096. var is390 int = 0
  5097. var is310 int = 0
  5098. for _, item := range rf {
  5099. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5100. insutypes = append(insutypes, item)
  5101. }
  5102. }
  5103. if len(insutypes) == 1 {
  5104. insutype = insutypes[0].Insutype
  5105. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5106. } else {
  5107. for _, i := range insutypes {
  5108. if i.Insutype == "390" {
  5109. is390 = 1
  5110. }
  5111. if i.Insutype == "310" {
  5112. is310 = 1
  5113. }
  5114. }
  5115. }
  5116. if is390 == 1 {
  5117. insutype = "390"
  5118. }
  5119. if is310 == 1 {
  5120. insutype = "310"
  5121. }
  5122. if len(insutypes) == 0 {
  5123. insutype = "310"
  5124. }
  5125. c.ServeSuccessJSON(map[string]interface{}{
  5126. "patient": patient,
  5127. "number": basNumber,
  5128. "insutype": insutype,
  5129. })
  5130. } else {
  5131. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5132. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5133. infoStr := string(Iinfos)
  5134. idetinfoStr := string(Idetinfos)
  5135. psn := &models.HisPsn{
  5136. PsnNo: res.Output.Baseinfo.PsnNo,
  5137. Age: res.Output.Baseinfo.Age,
  5138. PatientId: patient.ID,
  5139. Certno: res.Output.Baseinfo.Certno,
  5140. Brdy: res.Output.Baseinfo.Brdy,
  5141. Gend: res.Output.Baseinfo.Gend,
  5142. Naty: res.Output.Baseinfo.Naty,
  5143. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5144. PsnName: res.Output.Baseinfo.PsnName,
  5145. Idetinfo: idetinfoStr,
  5146. Insuinfo: infoStr,
  5147. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5148. CardInfo: card_info,
  5149. VerifyNumber: token,
  5150. }
  5151. service.CreateHisPsn(psn)
  5152. c.ServeSuccessJSON(map[string]interface{}{
  5153. "patient": patient,
  5154. "number": token,
  5155. })
  5156. }
  5157. }
  5158. } else {
  5159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5160. return
  5161. }
  5162. } else { //读卡失败
  5163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5164. return
  5165. }
  5166. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5167. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  5168. cardnum = DeleteExtraSpaceTwo(cardnum)
  5169. cardCode = DeleteExtraSpaceTwo(cardCode)
  5170. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  5171. name = DeleteExtraSpaceTwo(name)
  5172. errmsg = DeleteExtraSpaceTwo(errmsg)
  5173. cardnum = Remove0000(cardnum)
  5174. cardCode = Remove0000(cardCode)
  5175. id_card_no = Remove0000(id_card_no)
  5176. name = Remove0000(name)
  5177. errmsg = Remove0000(errmsg)
  5178. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  5179. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  5180. //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)
  5181. //fmt.Println(result2)
  5182. //fmt.Println(requestLog2)
  5183. //fmt.Println(errMsgLog2)
  5184. 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)
  5185. saveLog(result, requestLog, "1101", "获取人员信息")
  5186. fmt.Println(errMsgLog)
  5187. if len(errMsgLog) > 0 {
  5188. } else {
  5189. var dat map[string]interface{}
  5190. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5191. fmt.Println(dat)
  5192. } else {
  5193. fmt.Println(err)
  5194. }
  5195. userJSONBytes, _ := json.Marshal(dat)
  5196. var res ResultTwo
  5197. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5198. utils.ErrorLog("解析失败:%v", err)
  5199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5200. return
  5201. }
  5202. res.ErrMsg = errMsgLog
  5203. if res.Infcode == 0 {
  5204. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  5205. if err == gorm.ErrRecordNotFound {
  5206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5207. return
  5208. } else if err != nil {
  5209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5210. return
  5211. } else {
  5212. fmt.Println(res)
  5213. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5214. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5215. infoStr := string(Iinfos)
  5216. idetinfoStr := string(Idetinfos)
  5217. var rf []*ResultFive
  5218. json.Unmarshal([]byte(infoStr), &rf)
  5219. var insutypes []*ResultFive
  5220. var insutype string
  5221. var is390 int = 0
  5222. var is310 int = 0
  5223. for _, item := range rf {
  5224. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5225. insutypes = append(insutypes, item)
  5226. }
  5227. }
  5228. if len(insutypes) == 1 {
  5229. insutype = insutypes[0].Insutype
  5230. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5231. } else {
  5232. for _, i := range insutypes {
  5233. if i.Insutype == "390" {
  5234. is390 = 1
  5235. }
  5236. if i.Insutype == "310" {
  5237. is310 = 1
  5238. }
  5239. }
  5240. }
  5241. if is390 == 1 {
  5242. insutype = "390"
  5243. }
  5244. if is310 == 1 {
  5245. insutype = "310"
  5246. }
  5247. if len(insutypes) == 0 {
  5248. insutype = "390"
  5249. }
  5250. var insuplc_admdvs string
  5251. for _, item := range rf {
  5252. if item.Insutype == insutype {
  5253. insuplc_admdvs = item.InsuplcAdmdvs
  5254. }
  5255. }
  5256. psn := &models.HisPsn{
  5257. PsnNo: res.Output.Baseinfo.PsnNo,
  5258. Age: res.Output.Baseinfo.Age,
  5259. PatientId: patient.ID,
  5260. Certno: res.Output.Baseinfo.Certno,
  5261. Brdy: res.Output.Baseinfo.Brdy,
  5262. Gend: res.Output.Baseinfo.Gend,
  5263. Naty: res.Output.Baseinfo.Naty,
  5264. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5265. PsnName: res.Output.Baseinfo.PsnName,
  5266. Idetinfo: idetinfoStr,
  5267. Insuinfo: infoStr,
  5268. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5269. CardInfo: basStr,
  5270. VerifyNumber: "",
  5271. InsuplcAdmdvs: insuplc_admdvs,
  5272. }
  5273. service.CreateHisPsn(psn)
  5274. c.ServeSuccessJSON(map[string]interface{}{
  5275. "patient": patient,
  5276. "number": cardnum,
  5277. "insutype": insutype,
  5278. })
  5279. }
  5280. } else {
  5281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5282. return
  5283. }
  5284. }
  5285. } else if miConfig.MdtrtareaAdmvs == "360399" {
  5286. fmt.Println(initFlag)
  5287. fmt.Println("initFlag")
  5288. if initFlag == 0 {
  5289. c.TestGetJiangXiBasBaseInit()
  5290. }
  5291. basStr := c.GetBasBaseInfo()
  5292. if len(basStr) == 0 {
  5293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5294. return
  5295. }
  5296. fmt.Println(basStr)
  5297. bas := strings.Split(basStr, "|")
  5298. basNumber := bas[1]
  5299. fmt.Println(basNumber)
  5300. card_sn := bas[3]
  5301. fmt.Println(card_sn)
  5302. 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, "")
  5303. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  5304. var dat map[string]interface{}
  5305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5306. fmt.Println(dat)
  5307. } else {
  5308. fmt.Println(err)
  5309. }
  5310. userJSONBytes, _ := json.Marshal(dat)
  5311. var res ResultTwo
  5312. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5313. utils.ErrorLog("解析失败:%v", err)
  5314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5315. return
  5316. }
  5317. if res.Infcode == 0 {
  5318. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  5319. if err == gorm.ErrRecordNotFound {
  5320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5321. return
  5322. } else if err != nil {
  5323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5324. return
  5325. } else {
  5326. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5327. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5328. infoStr := string(Iinfos)
  5329. idetinfoStr := string(Idetinfos)
  5330. psn := &models.HisPsn{
  5331. PsnNo: res.Output.Baseinfo.PsnNo,
  5332. Age: res.Output.Baseinfo.Age,
  5333. PatientId: patient.ID,
  5334. Certno: res.Output.Baseinfo.Certno,
  5335. Brdy: res.Output.Baseinfo.Brdy,
  5336. Gend: res.Output.Baseinfo.Gend,
  5337. Naty: res.Output.Baseinfo.Naty,
  5338. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5339. PsnName: res.Output.Baseinfo.PsnName,
  5340. Idetinfo: idetinfoStr,
  5341. Insuinfo: infoStr,
  5342. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5343. CardInfo: basStr,
  5344. VerifyNumber: "",
  5345. }
  5346. service.CreateHisPsn(psn)
  5347. var rf []*ResultFive
  5348. json.Unmarshal([]byte(infoStr), &rf)
  5349. var insutypes []*ResultFive
  5350. var insutype string
  5351. var is390 int = 0
  5352. var is310 int = 0
  5353. for _, item := range rf {
  5354. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5355. insutypes = append(insutypes, item)
  5356. }
  5357. }
  5358. if len(insutypes) == 1 {
  5359. insutype = insutypes[0].Insutype
  5360. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5361. } else {
  5362. for _, i := range insutypes {
  5363. if i.Insutype == "390" {
  5364. is390 = 1
  5365. }
  5366. if i.Insutype == "310" {
  5367. is310 = 1
  5368. }
  5369. }
  5370. }
  5371. if is390 == 1 {
  5372. insutype = "390"
  5373. }
  5374. if is310 == 1 {
  5375. insutype = "310"
  5376. }
  5377. if len(insutypes) == 0 {
  5378. insutype = "310"
  5379. }
  5380. c.ServeSuccessJSON(map[string]interface{}{
  5381. "patient": patient,
  5382. "number": basNumber,
  5383. "insutype": insutype,
  5384. })
  5385. }
  5386. } else {
  5387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5388. return
  5389. }
  5390. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5391. fmt.Println(initFlag)
  5392. fmt.Println("initFlag")
  5393. if initFlag == 0 {
  5394. c.TestGetHnBasBaseInit()
  5395. }
  5396. basStr := c.GetBasBaseInfo()
  5397. if len(basStr) == 0 {
  5398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5399. return
  5400. }
  5401. fmt.Println(basStr)
  5402. bas := strings.Split(basStr, "|")
  5403. basNumber := bas[1]
  5404. fmt.Println(basNumber)
  5405. card_sn := bas[3]
  5406. card_no := bas[2]
  5407. fmt.Println(card_sn)
  5408. name := bas[4]
  5409. name = ConvertToString(name, "gbk", "utf-8")
  5410. 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)
  5411. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  5412. var dat map[string]interface{}
  5413. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5414. fmt.Println(dat)
  5415. } else {
  5416. fmt.Println(err)
  5417. }
  5418. userJSONBytes, _ := json.Marshal(dat)
  5419. var res ResultTwo
  5420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5421. utils.ErrorLog("解析失败:%v", err)
  5422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5423. return
  5424. }
  5425. if res.Infcode == 0 {
  5426. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  5427. if err == gorm.ErrRecordNotFound {
  5428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5429. return
  5430. } else if err != nil {
  5431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5432. return
  5433. } else {
  5434. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5435. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5436. infoStr := string(Iinfos)
  5437. idetinfoStr := string(Idetinfos)
  5438. psn := &models.HisPsn{
  5439. PsnNo: res.Output.Baseinfo.PsnNo,
  5440. Age: res.Output.Baseinfo.Age,
  5441. PatientId: patient.ID,
  5442. Certno: res.Output.Baseinfo.Certno,
  5443. Brdy: res.Output.Baseinfo.Brdy,
  5444. Gend: res.Output.Baseinfo.Gend,
  5445. Naty: res.Output.Baseinfo.Naty,
  5446. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5447. PsnName: res.Output.Baseinfo.PsnName,
  5448. Idetinfo: idetinfoStr,
  5449. Insuinfo: infoStr,
  5450. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5451. CardInfo: basStr,
  5452. VerifyNumber: "",
  5453. }
  5454. service.CreateHisPsn(psn)
  5455. var rf []*ResultFive
  5456. json.Unmarshal([]byte(infoStr), &rf)
  5457. var insutypes []*ResultFive
  5458. var insutype string
  5459. var is390 int = 0
  5460. var is310 int = 0
  5461. for _, item := range rf {
  5462. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5463. insutypes = append(insutypes, item)
  5464. }
  5465. }
  5466. if len(insutypes) == 1 {
  5467. insutype = insutypes[0].Insutype
  5468. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5469. } else {
  5470. for _, i := range insutypes {
  5471. if i.Insutype == "390" {
  5472. is390 = 1
  5473. }
  5474. if i.Insutype == "310" {
  5475. is310 = 1
  5476. }
  5477. }
  5478. }
  5479. if is390 == 1 {
  5480. insutype = "390"
  5481. }
  5482. if is310 == 1 {
  5483. insutype = "310"
  5484. }
  5485. if len(insutypes) == 0 {
  5486. insutype = "310"
  5487. }
  5488. c.ServeSuccessJSON(map[string]interface{}{
  5489. "patient": patient,
  5490. "number": basNumber,
  5491. "insutype": insutype,
  5492. })
  5493. }
  5494. } else {
  5495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5496. return
  5497. }
  5498. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5499. var api string
  5500. 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 +
  5501. "&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
  5502. fmt.Println(api)
  5503. resp, requestErr := http.Get(api)
  5504. if requestErr != nil {
  5505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5506. return
  5507. }
  5508. body, ioErr := ioutil.ReadAll(resp.Body)
  5509. if ioErr != nil {
  5510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5512. return
  5513. }
  5514. var respJSON map[string]interface{}
  5515. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5518. return
  5519. }
  5520. var res ResultTwo //1101结果
  5521. var res10265 ResultTwo10265 //1101结果
  5522. var card_info string //卡信息
  5523. token := respJSON["data"].(map[string]interface{})["token"].(string)
  5524. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5525. result, _ := json.Marshal(respJSON)
  5526. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5527. utils.ErrorLog("解析失败:%v", err)
  5528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5529. return
  5530. }
  5531. res.ErrMsg = res10265.ErrMsg
  5532. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5533. res.Infcode = infocode
  5534. res.Output = res10265.Output
  5535. res.InfRefmsgid = res10265.InfRefmsgid
  5536. if res.Infcode == 0 {
  5537. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5538. if err == gorm.ErrRecordNotFound {
  5539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5540. return
  5541. } else if err != nil {
  5542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5543. return
  5544. } else {
  5545. bas := strings.Split(card_info, "|")
  5546. basNumber := bas[2]
  5547. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5548. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5549. infoStr := string(Iinfos)
  5550. idetinfoStr := string(Idetinfos)
  5551. psn := &models.HisPsn{
  5552. PsnNo: res.Output.Baseinfo.PsnNo,
  5553. Age: res.Output.Baseinfo.Age,
  5554. PatientId: patient.ID,
  5555. Certno: res.Output.Baseinfo.Certno,
  5556. Brdy: res.Output.Baseinfo.Brdy,
  5557. Gend: res.Output.Baseinfo.Gend,
  5558. Naty: res.Output.Baseinfo.Naty,
  5559. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5560. PsnName: res.Output.Baseinfo.PsnName,
  5561. Idetinfo: idetinfoStr,
  5562. Insuinfo: infoStr,
  5563. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5564. CardInfo: card_info,
  5565. VerifyNumber: token,
  5566. }
  5567. service.CreateHisPsn(psn)
  5568. var rf []*ResultFive
  5569. json.Unmarshal([]byte(infoStr), &rf)
  5570. var insutypes []*ResultFive
  5571. var insutype string
  5572. var is390 int = 0
  5573. var is310 int = 0
  5574. for _, item := range rf {
  5575. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5576. insutypes = append(insutypes, item)
  5577. }
  5578. }
  5579. if len(insutypes) == 1 {
  5580. insutype = insutypes[0].Insutype
  5581. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5582. } else {
  5583. for _, i := range insutypes {
  5584. if i.Insutype == "390" {
  5585. is390 = 1
  5586. }
  5587. if i.Insutype == "310" {
  5588. is310 = 1
  5589. }
  5590. }
  5591. }
  5592. if is390 == 1 {
  5593. insutype = "390"
  5594. }
  5595. if is310 == 1 {
  5596. insutype = "310"
  5597. }
  5598. if len(insutypes) == 0 {
  5599. insutype = "310"
  5600. }
  5601. c.ServeSuccessJSON(map[string]interface{}{
  5602. "patient": patient,
  5603. "number": basNumber,
  5604. "insutype": insutype,
  5605. })
  5606. }
  5607. } else {
  5608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5609. return
  5610. }
  5611. } else {
  5612. if initFlag == 0 {
  5613. c.TestGetBasBaseInit()
  5614. }
  5615. basStr := c.GetBasBaseInfo()
  5616. if len(basStr) == 0 {
  5617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5618. return
  5619. }
  5620. fmt.Println(basStr)
  5621. bas := strings.Split(basStr, "|")
  5622. basNumber := bas[1]
  5623. fmt.Println(basNumber)
  5624. card_sn := bas[3]
  5625. fmt.Println(card_sn)
  5626. cardNumber := bas[2]
  5627. fmt.Println(cardNumber)
  5628. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  5629. var result string
  5630. if bas[0][:2] == "44" {
  5631. 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)
  5632. } else {
  5633. 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)
  5634. }
  5635. var dat map[string]interface{}
  5636. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5637. fmt.Println(dat)
  5638. } else {
  5639. fmt.Println(err)
  5640. }
  5641. userJSONBytes, _ := json.Marshal(dat)
  5642. var res ResultTwo
  5643. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5644. utils.ErrorLog("解析失败:%v", err)
  5645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5646. return
  5647. }
  5648. if res.Infcode == 0 {
  5649. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  5650. if err == gorm.ErrRecordNotFound {
  5651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5652. return
  5653. } else if err != nil {
  5654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5655. return
  5656. } else {
  5657. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5658. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5659. infoStr := string(Iinfos)
  5660. idetinfoStr := string(Idetinfos)
  5661. var rf []*ResultFive
  5662. json.Unmarshal([]byte(infoStr), &rf)
  5663. var insutypes []*ResultFive
  5664. var insutype string
  5665. var is390 int = 0
  5666. var is310 int = 0
  5667. var insuplc_admdvs string
  5668. for _, item := range rf {
  5669. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5670. insutypes = append(insutypes, item)
  5671. }
  5672. }
  5673. if len(insutypes) == 1 {
  5674. insutype = insutypes[0].Insutype
  5675. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5676. } else {
  5677. for _, i := range insutypes {
  5678. if i.Insutype == "390" {
  5679. is390 = 1
  5680. }
  5681. if i.Insutype == "310" {
  5682. is310 = 1
  5683. }
  5684. }
  5685. }
  5686. if is390 == 1 {
  5687. insutype = "390"
  5688. }
  5689. if is310 == 1 {
  5690. insutype = "310"
  5691. }
  5692. if len(insutypes) == 0 {
  5693. insutype = "310"
  5694. }
  5695. for _, item := range rf {
  5696. if item.Insutype == insutype {
  5697. insuplc_admdvs = item.InsuplcAdmdvs
  5698. }
  5699. }
  5700. psn := &models.HisPsn{
  5701. PsnNo: res.Output.Baseinfo.PsnNo,
  5702. Age: res.Output.Baseinfo.Age,
  5703. PatientId: patient.ID,
  5704. Certno: res.Output.Baseinfo.Certno,
  5705. Brdy: res.Output.Baseinfo.Brdy,
  5706. Gend: res.Output.Baseinfo.Gend,
  5707. Naty: res.Output.Baseinfo.Naty,
  5708. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5709. PsnName: res.Output.Baseinfo.PsnName,
  5710. Idetinfo: idetinfoStr,
  5711. Insuinfo: infoStr,
  5712. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5713. CardInfo: basStr,
  5714. VerifyNumber: "",
  5715. InsuplcAdmdvs: insuplc_admdvs,
  5716. }
  5717. service.CreateHisPsn(psn)
  5718. c.ServeSuccessJSON(map[string]interface{}{
  5719. "patient": patient,
  5720. "number": basNumber,
  5721. })
  5722. }
  5723. } else {
  5724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5725. return
  5726. }
  5727. break
  5728. }
  5729. case 2:
  5730. if miConfig.MdtrtareaAdmvs == "430800" {
  5731. if initFlag == 0 {
  5732. c.TestGetHnBasBaseInit()
  5733. }
  5734. SFZStr := c.GetSFZBaseInfo()
  5735. if len(SFZStr) == 0 {
  5736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5737. return
  5738. }
  5739. fmt.Println(SFZStr)
  5740. id_card_str := strings.Split(SFZStr, "^")
  5741. card_no := id_card_str[0]
  5742. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  5743. //name := id_card_str[1]
  5744. //name = ConvertToString(name, "gbk", "utf-8")
  5745. 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)
  5746. var dat map[string]interface{}
  5747. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5748. fmt.Println(dat)
  5749. } else {
  5750. fmt.Println(err)
  5751. }
  5752. userJSONBytes, _ := json.Marshal(dat)
  5753. var res ResultTwo
  5754. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5755. utils.ErrorLog("解析失败:%v", err)
  5756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5757. return
  5758. }
  5759. if res.Infcode == 0 {
  5760. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  5761. if err == gorm.ErrRecordNotFound {
  5762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5763. return
  5764. } else if err != nil {
  5765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5766. return
  5767. } else {
  5768. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5769. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5770. infoStr := string(Iinfos)
  5771. idetinfoStr := string(Idetinfos)
  5772. psn := &models.HisPsn{
  5773. PsnNo: res.Output.Baseinfo.PsnNo,
  5774. Age: res.Output.Baseinfo.Age,
  5775. PatientId: patient.ID,
  5776. Certno: res.Output.Baseinfo.Certno,
  5777. Brdy: res.Output.Baseinfo.Brdy,
  5778. Gend: res.Output.Baseinfo.Gend,
  5779. Naty: res.Output.Baseinfo.Naty,
  5780. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5781. PsnName: res.Output.Baseinfo.PsnName,
  5782. Idetinfo: idetinfoStr,
  5783. Insuinfo: infoStr,
  5784. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5785. CardInfo: SFZStr,
  5786. VerifyNumber: "",
  5787. }
  5788. service.CreateHisPsn(psn)
  5789. var rf []*ResultFive
  5790. json.Unmarshal([]byte(infoStr), &rf)
  5791. var insutypes []*ResultFive
  5792. var insutype string
  5793. var is390 int = 0
  5794. var is310 int = 0
  5795. for _, item := range rf {
  5796. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5797. insutypes = append(insutypes, item)
  5798. }
  5799. }
  5800. if len(insutypes) == 1 {
  5801. insutype = insutypes[0].Insutype
  5802. } else {
  5803. for _, i := range insutypes {
  5804. if i.Insutype == "390" {
  5805. is390 = 1
  5806. }
  5807. if i.Insutype == "310" {
  5808. is310 = 1
  5809. }
  5810. }
  5811. }
  5812. if is390 == 1 {
  5813. insutype = "390"
  5814. }
  5815. if is310 == 1 {
  5816. insutype = "310"
  5817. }
  5818. if len(insutypes) == 0 {
  5819. insutype = "310"
  5820. }
  5821. c.ServeSuccessJSON(map[string]interface{}{
  5822. "patient": patient,
  5823. "number": card_no,
  5824. "insutype": insutype,
  5825. })
  5826. }
  5827. } else {
  5828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5829. return
  5830. }
  5831. } else {
  5832. SFZStr := c.GetSFZBaseInfo()
  5833. id_card_str := strings.Split(SFZStr, "^")
  5834. id_card_number := id_card_str[0]
  5835. card_sn := ""
  5836. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "")
  5837. var dat map[string]interface{}
  5838. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5839. fmt.Println(dat)
  5840. } else {
  5841. fmt.Println(err)
  5842. }
  5843. userJSONBytes, _ := json.Marshal(dat)
  5844. var res ResultTwo
  5845. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5846. utils.ErrorLog("解析失败:%v", err)
  5847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5848. return
  5849. }
  5850. if res.Infcode == 0 {
  5851. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  5852. if err == gorm.ErrRecordNotFound {
  5853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5854. return
  5855. } else if err != nil {
  5856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5857. return
  5858. } else {
  5859. c.ServeSuccessJSON(map[string]interface{}{
  5860. "patient": patient,
  5861. "number": id_card_number,
  5862. })
  5863. }
  5864. } else {
  5865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5866. return
  5867. }
  5868. }
  5869. break
  5870. case 3:
  5871. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5872. var api string
  5873. if miConfig.MdtrtareaAdmvs == "320921" {
  5874. 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 +
  5875. "&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
  5876. fmt.Println(api)
  5877. } else {
  5878. 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 +
  5879. "&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)
  5880. }
  5881. resp, requestErr := http.Get(api)
  5882. if requestErr != nil {
  5883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5884. return
  5885. }
  5886. body, ioErr := ioutil.ReadAll(resp.Body)
  5887. if ioErr != nil {
  5888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5890. return
  5891. }
  5892. var respJSON map[string]interface{}
  5893. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5896. return
  5897. }
  5898. var status string
  5899. status = respJSON["data"].(map[string]interface{})["status"].(string)
  5900. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  5901. var token string
  5902. var res ResultTwo //1101结果
  5903. var res10265 ResultTwo10265 //1101结果
  5904. var card_info string //卡信息
  5905. var busi_card_info string
  5906. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  5907. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5908. if status == "0" { //读卡成功
  5909. if card_type == "1" {
  5910. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5911. result, _ := json.Marshal(respJSON)
  5912. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5913. utils.ErrorLog("解析失败:%v", err)
  5914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5915. return
  5916. }
  5917. res.ErrMsg = res10265.ErrMsg
  5918. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5919. res.Infcode = infocode
  5920. res.Output = res10265.Output
  5921. res.InfRefmsgid = res10265.InfRefmsgid
  5922. } else {
  5923. //var card_info string //卡信息
  5924. //var busi_card_info string
  5925. token = respJSON["data"].(map[string]interface{})["token"].(string)
  5926. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5927. //fmt.Println(card_info)
  5928. //fmt.Println(busi_card_info)
  5929. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5930. result, _ := json.Marshal(respJSON)
  5931. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5932. utils.ErrorLog("解析失败:%v", err)
  5933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5934. return
  5935. }
  5936. res.ErrMsg = res10265.ErrMsg
  5937. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5938. res.Infcode = infocode
  5939. res.Output = res10265.Output
  5940. res.InfRefmsgid = res10265.InfRefmsgid
  5941. }
  5942. if res.Infcode == 0 {
  5943. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5944. if err == gorm.ErrRecordNotFound {
  5945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5946. return
  5947. } else if err != nil {
  5948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5949. return
  5950. } else {
  5951. if card_type == "1" {
  5952. bas := strings.Split(card_info, "|")
  5953. basNumber := bas[2]
  5954. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5955. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5956. infoStr := string(Iinfos)
  5957. idetinfoStr := string(Idetinfos)
  5958. psn := &models.HisPsn{
  5959. PsnNo: res.Output.Baseinfo.PsnNo,
  5960. Age: res.Output.Baseinfo.Age,
  5961. PatientId: patient.ID,
  5962. Certno: res.Output.Baseinfo.Certno,
  5963. Brdy: res.Output.Baseinfo.Brdy,
  5964. Gend: res.Output.Baseinfo.Gend,
  5965. Naty: res.Output.Baseinfo.Naty,
  5966. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5967. PsnName: res.Output.Baseinfo.PsnName,
  5968. Idetinfo: idetinfoStr,
  5969. Insuinfo: infoStr,
  5970. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5971. CardInfo: card_info,
  5972. VerifyNumber: busi_card_info,
  5973. }
  5974. service.CreateHisPsn(psn)
  5975. c.ServeSuccessJSON(map[string]interface{}{
  5976. "patient": patient,
  5977. "number": basNumber,
  5978. })
  5979. } else {
  5980. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5981. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5982. infoStr := string(Iinfos)
  5983. idetinfoStr := string(Idetinfos)
  5984. psn := &models.HisPsn{
  5985. PsnNo: res.Output.Baseinfo.PsnNo,
  5986. Age: res.Output.Baseinfo.Age,
  5987. PatientId: patient.ID,
  5988. Certno: res.Output.Baseinfo.Certno,
  5989. Brdy: res.Output.Baseinfo.Brdy,
  5990. Gend: res.Output.Baseinfo.Gend,
  5991. Naty: res.Output.Baseinfo.Naty,
  5992. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5993. PsnName: res.Output.Baseinfo.PsnName,
  5994. Idetinfo: idetinfoStr,
  5995. Insuinfo: infoStr,
  5996. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5997. CardInfo: card_info,
  5998. VerifyNumber: token,
  5999. }
  6000. service.CreateHisPsn(psn)
  6001. var rf []*ResultFive
  6002. json.Unmarshal([]byte(infoStr), &rf)
  6003. var insutypes []*ResultFive
  6004. var insutype string
  6005. var is390 int = 0
  6006. var is310 int = 0
  6007. for _, item := range rf {
  6008. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6009. insutypes = append(insutypes, item)
  6010. }
  6011. }
  6012. if len(insutypes) == 1 {
  6013. insutype = insutypes[0].Insutype
  6014. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6015. } else {
  6016. for _, i := range insutypes {
  6017. if i.Insutype == "390" {
  6018. is390 = 1
  6019. }
  6020. if i.Insutype == "310" {
  6021. is310 = 1
  6022. }
  6023. }
  6024. }
  6025. if is390 == 1 {
  6026. insutype = "390"
  6027. }
  6028. if is310 == 1 {
  6029. insutype = "310"
  6030. }
  6031. if len(insutypes) == 0 {
  6032. insutype = "310"
  6033. }
  6034. c.ServeSuccessJSON(map[string]interface{}{
  6035. "patient": patient,
  6036. "number": token,
  6037. "insutype": insutype,
  6038. })
  6039. }
  6040. }
  6041. } else {
  6042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6043. return
  6044. }
  6045. } else { //读卡失败
  6046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6047. return
  6048. }
  6049. }
  6050. break
  6051. case 4:
  6052. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6053. var api string
  6054. if miConfig.MdtrtareaAdmvs == "320921" {
  6055. 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 +
  6056. "&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
  6057. fmt.Println(api)
  6058. } else {
  6059. 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 +
  6060. "&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)
  6061. }
  6062. resp, requestErr := http.Get(api)
  6063. if requestErr != nil {
  6064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6065. return
  6066. }
  6067. body, ioErr := ioutil.ReadAll(resp.Body)
  6068. if ioErr != nil {
  6069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6071. return
  6072. }
  6073. var respJSON map[string]interface{}
  6074. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6077. return
  6078. }
  6079. var status string
  6080. status = respJSON["data"].(map[string]interface{})["status"].(string)
  6081. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  6082. var token string
  6083. var res ResultTwo //1101结果
  6084. var res10265 ResultTwo10265 //1101结果
  6085. if status == "0" { //读卡成功
  6086. var card_info string //卡信息
  6087. var busi_card_info string
  6088. token = respJSON["data"].(map[string]interface{})["token"].(string)
  6089. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  6090. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  6091. fmt.Println(card_info)
  6092. fmt.Println(busi_card_info)
  6093. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  6094. result, _ := json.Marshal(respJSON)
  6095. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6096. utils.ErrorLog("解析失败:%v", err)
  6097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6098. return
  6099. }
  6100. res.ErrMsg = res10265.ErrMsg
  6101. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6102. res.Infcode = infocode
  6103. res.Output = res10265.Output
  6104. res.InfRefmsgid = res10265.InfRefmsgid
  6105. if res.Infcode == 0 {
  6106. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6107. if err == gorm.ErrRecordNotFound {
  6108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6109. return
  6110. } else if err != nil {
  6111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6112. return
  6113. } else {
  6114. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6115. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6116. infoStr := string(Iinfos)
  6117. idetinfoStr := string(Idetinfos)
  6118. psn := &models.HisPsn{
  6119. PsnNo: res.Output.Baseinfo.PsnNo,
  6120. Age: res.Output.Baseinfo.Age,
  6121. PatientId: patient.ID,
  6122. Certno: res.Output.Baseinfo.Certno,
  6123. Brdy: res.Output.Baseinfo.Brdy,
  6124. Gend: res.Output.Baseinfo.Gend,
  6125. Naty: res.Output.Baseinfo.Naty,
  6126. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6127. PsnName: res.Output.Baseinfo.PsnName,
  6128. Idetinfo: idetinfoStr,
  6129. Insuinfo: infoStr,
  6130. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6131. CardInfo: card_info,
  6132. VerifyNumber: token,
  6133. }
  6134. var rf []*ResultFive
  6135. json.Unmarshal([]byte(infoStr), &rf)
  6136. var insutypes []*ResultFive
  6137. var insutype string
  6138. var is390 int = 0
  6139. var is310 int = 0
  6140. for _, item := range rf {
  6141. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6142. insutypes = append(insutypes, item)
  6143. }
  6144. }
  6145. if len(insutypes) == 1 {
  6146. insutype = insutypes[0].Insutype
  6147. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6148. } else {
  6149. for _, i := range insutypes {
  6150. if i.Insutype == "390" {
  6151. is390 = 1
  6152. }
  6153. if i.Insutype == "310" {
  6154. is310 = 1
  6155. }
  6156. }
  6157. }
  6158. if is390 == 1 {
  6159. insutype = "390"
  6160. }
  6161. if is310 == 1 {
  6162. insutype = "310"
  6163. }
  6164. if len(insutypes) == 0 {
  6165. insutype = "310"
  6166. }
  6167. service.CreateHisPsn(psn)
  6168. c.ServeSuccessJSON(map[string]interface{}{
  6169. "patient": patient,
  6170. "number": token,
  6171. "insutype": insutype,
  6172. })
  6173. }
  6174. } else {
  6175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6176. return
  6177. }
  6178. } else { //读卡失败
  6179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6180. return
  6181. }
  6182. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6183. idNo := c.GetString("idNo")
  6184. userName := c.GetString("userName")
  6185. ecToken := c.GetString("ecToken")
  6186. insuOrg := c.GetString("insuOrg")
  6187. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  6188. saveLog(result2, requestLog2, "1101", "获取人员信息")
  6189. var res ResultTwo
  6190. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  6191. utils.ErrorLog("解析失败:%v", err)
  6192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6193. return
  6194. }
  6195. if res.Infcode == 0 {
  6196. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6197. if err == gorm.ErrRecordNotFound {
  6198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6199. return
  6200. } else if err != nil {
  6201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6202. return
  6203. } else {
  6204. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6205. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6206. infoStr := string(Iinfos)
  6207. idetinfoStr := string(Idetinfos)
  6208. psn := &models.HisPsn{
  6209. PsnNo: res.Output.Baseinfo.PsnNo,
  6210. Age: res.Output.Baseinfo.Age,
  6211. PatientId: patient.ID,
  6212. Certno: res.Output.Baseinfo.Certno,
  6213. Brdy: res.Output.Baseinfo.Brdy,
  6214. Gend: res.Output.Baseinfo.Gend,
  6215. Naty: res.Output.Baseinfo.Naty,
  6216. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6217. PsnName: res.Output.Baseinfo.PsnName,
  6218. Idetinfo: idetinfoStr,
  6219. Insuinfo: infoStr,
  6220. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6221. CardInfo: "",
  6222. Stage: "1",
  6223. VerifyNumber: ecToken,
  6224. InsuplcAdmdvs: insuOrg,
  6225. }
  6226. service.CreateHisPsn(psn)
  6227. var rf []*ResultFive
  6228. json.Unmarshal([]byte(infoStr), &rf)
  6229. var insutypes []*ResultFive
  6230. var insutype string
  6231. var is390 int = 0
  6232. var is310 int = 0
  6233. for _, item := range rf {
  6234. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6235. insutypes = append(insutypes, item)
  6236. }
  6237. }
  6238. if len(insutypes) == 1 {
  6239. insutype = insutypes[0].Insutype
  6240. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6241. } else {
  6242. for _, i := range insutypes {
  6243. if i.Insutype == "390" {
  6244. is390 = 1
  6245. }
  6246. if i.Insutype == "310" {
  6247. is310 = 1
  6248. }
  6249. }
  6250. }
  6251. if is390 == 1 {
  6252. insutype = "390"
  6253. }
  6254. if is310 == 1 {
  6255. insutype = "310"
  6256. }
  6257. if len(insutypes) == 0 {
  6258. insutype = "310"
  6259. }
  6260. c.ServeSuccessJSON(map[string]interface{}{
  6261. "patient": patient,
  6262. "number": ecToken,
  6263. "insutype": insutype,
  6264. })
  6265. }
  6266. } else {
  6267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6268. return
  6269. }
  6270. } else if miConfig.MdtrtareaAdmvs == "360399" {
  6271. //if initFlag == 0 {
  6272. c.TestGetJiangXiBasBaseInit()
  6273. //}
  6274. //if initEleFlag == 0 {
  6275. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  6276. //}
  6277. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  6278. type ELeData struct {
  6279. Data struct {
  6280. IdNo string `json:"idNo"`
  6281. IdType string `json:"idType"`
  6282. UserName string `json:"userName"`
  6283. EcToken string `json:"ecToken"`
  6284. InsuOrg string `json:"insuOrg"`
  6285. Gender string `json:"gender"`
  6286. Birthday string `json:"birthday"`
  6287. Nationality string `json:"nationality"`
  6288. Email string `json:"email"`
  6289. Extra string `json:"extra"`
  6290. } `json:"data"`
  6291. Code int `json:"code"`
  6292. Message string `json:"message"`
  6293. }
  6294. var ele ELeData
  6295. err := json.Unmarshal([]byte(json_result), &ele)
  6296. if err != nil {
  6297. utils.ErrorLog("解析失败:%v", err)
  6298. }
  6299. token := ele.Data.EcToken
  6300. token = Remove0000(token)
  6301. 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)
  6302. saveLog(result2, requestLog2, "1101", "获取人员信息")
  6303. var res ResultTwo
  6304. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  6305. utils.ErrorLog("解析失败:%v", err)
  6306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6307. return
  6308. }
  6309. if res.Infcode == 0 {
  6310. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6311. if err == gorm.ErrRecordNotFound {
  6312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6313. return
  6314. } else if err != nil {
  6315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6316. return
  6317. } else {
  6318. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6319. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6320. infoStr := string(Iinfos)
  6321. idetinfoStr := string(Idetinfos)
  6322. psn := &models.HisPsn{
  6323. PsnNo: res.Output.Baseinfo.PsnNo,
  6324. Age: res.Output.Baseinfo.Age,
  6325. PatientId: patient.ID,
  6326. Certno: res.Output.Baseinfo.Certno,
  6327. Brdy: res.Output.Baseinfo.Brdy,
  6328. Gend: res.Output.Baseinfo.Gend,
  6329. Naty: res.Output.Baseinfo.Naty,
  6330. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6331. PsnName: res.Output.Baseinfo.PsnName,
  6332. Idetinfo: idetinfoStr,
  6333. Insuinfo: infoStr,
  6334. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6335. CardInfo: "",
  6336. //RecordDate:
  6337. VerifyNumber: token,
  6338. }
  6339. service.CreateHisPsn(psn)
  6340. var rf []*ResultFive
  6341. json.Unmarshal([]byte(infoStr), &rf)
  6342. var insutypes []*ResultFive
  6343. var insutype string
  6344. var is390 int = 0
  6345. var is310 int = 0
  6346. for _, item := range rf {
  6347. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6348. insutypes = append(insutypes, item)
  6349. }
  6350. }
  6351. if len(insutypes) == 1 {
  6352. insutype = insutypes[0].Insutype
  6353. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6354. } else {
  6355. for _, i := range insutypes {
  6356. if i.Insutype == "390" {
  6357. is390 = 1
  6358. }
  6359. if i.Insutype == "310" {
  6360. is310 = 1
  6361. }
  6362. }
  6363. }
  6364. if is390 == 1 {
  6365. insutype = "390"
  6366. }
  6367. if is310 == 1 {
  6368. insutype = "310"
  6369. }
  6370. if len(insutypes) == 0 {
  6371. insutype = "310"
  6372. }
  6373. c.ServeSuccessJSON(map[string]interface{}{
  6374. "patient": patient,
  6375. "number": token,
  6376. "insutype": insutype,
  6377. })
  6378. }
  6379. } else {
  6380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6381. return
  6382. }
  6383. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6384. //if initFlag == 0 {
  6385. c.TestGetJiangXiBasBaseInit()
  6386. //}
  6387. //if initEleFlag == 0 {
  6388. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  6389. //}
  6390. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  6391. type ELeData struct {
  6392. Data struct {
  6393. IdNo string `json:"idNo"`
  6394. IdType string `json:"idType"`
  6395. UserName string `json:"userName"`
  6396. EcToken string `json:"ecToken"`
  6397. InsuOrg string `json:"insuOrg"`
  6398. Gender string `json:"gender"`
  6399. Birthday string `json:"birthday"`
  6400. Nationality string `json:"nationality"`
  6401. Email string `json:"email"`
  6402. Extra string `json:"extra"`
  6403. } `json:"data"`
  6404. Code int `json:"code"`
  6405. Message string `json:"message"`
  6406. }
  6407. var ele ELeData
  6408. err := json.Unmarshal([]byte(json_result), &ele)
  6409. if err != nil {
  6410. utils.ErrorLog("解析失败:%v", err)
  6411. }
  6412. token := ele.Data.EcToken
  6413. token = Remove0000(token)
  6414. 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)
  6415. saveLog(result2, requestLog2, "1101", "获取人员信息")
  6416. var res ResultTwo
  6417. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  6418. utils.ErrorLog("解析失败:%v", err)
  6419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6420. return
  6421. }
  6422. if res.Infcode == 0 {
  6423. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6424. if err == gorm.ErrRecordNotFound {
  6425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6426. return
  6427. } else if err != nil {
  6428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6429. return
  6430. } else {
  6431. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6432. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6433. infoStr := string(Iinfos)
  6434. idetinfoStr := string(Idetinfos)
  6435. psn := &models.HisPsn{
  6436. PsnNo: res.Output.Baseinfo.PsnNo,
  6437. Age: res.Output.Baseinfo.Age,
  6438. PatientId: patient.ID,
  6439. Certno: res.Output.Baseinfo.Certno,
  6440. Brdy: res.Output.Baseinfo.Brdy,
  6441. Gend: res.Output.Baseinfo.Gend,
  6442. Naty: res.Output.Baseinfo.Naty,
  6443. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6444. PsnName: res.Output.Baseinfo.PsnName,
  6445. Idetinfo: idetinfoStr,
  6446. Insuinfo: infoStr,
  6447. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6448. CardInfo: "",
  6449. VerifyNumber: token,
  6450. }
  6451. service.CreateHisPsn(psn)
  6452. var rf []*ResultFive
  6453. json.Unmarshal([]byte(infoStr), &rf)
  6454. var insutypes []*ResultFive
  6455. var insutype string
  6456. var is390 int = 0
  6457. var is310 int = 0
  6458. for _, item := range rf {
  6459. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6460. insutypes = append(insutypes, item)
  6461. }
  6462. }
  6463. if len(insutypes) == 1 {
  6464. insutype = insutypes[0].Insutype
  6465. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6466. } else {
  6467. for _, i := range insutypes {
  6468. if i.Insutype == "390" {
  6469. is390 = 1
  6470. }
  6471. if i.Insutype == "310" {
  6472. is310 = 1
  6473. }
  6474. }
  6475. }
  6476. if is390 == 1 {
  6477. insutype = "390"
  6478. }
  6479. if is310 == 1 {
  6480. insutype = "310"
  6481. }
  6482. if len(insutypes) == 0 {
  6483. insutype = "310"
  6484. }
  6485. c.ServeSuccessJSON(map[string]interface{}{
  6486. "patient": patient,
  6487. "number": token,
  6488. "insutype": insutype,
  6489. })
  6490. }
  6491. } else {
  6492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6493. return
  6494. }
  6495. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6496. type ELeData struct {
  6497. Code string `json:"code"`
  6498. Data struct {
  6499. Aac002 string `json:"aac002"`
  6500. Aaz500 string `json:"aaz500"`
  6501. ActCardNo string `json:"actCardNo"`
  6502. Bab520 string `json:"bab520"`
  6503. Bkz543 string `json:"bkz543"`
  6504. BusinessType string `json:"businessType"`
  6505. CertfCodg string `json:"certfCodg"`
  6506. EcIndexNo string `json:"ecIndexNo"`
  6507. EcToken string `json:"ecToken"`
  6508. ID0000 string `json:"id0000"`
  6509. IDNo string `json:"idNo"`
  6510. IDType string `json:"idType"`
  6511. Idcode string `json:"idcode"`
  6512. IdentityToken string `json:"identity_token"`
  6513. InsuOrg string `json:"insuOrg"`
  6514. OfficeID string `json:"officeId"`
  6515. OfficeName string `json:"officeName"`
  6516. OperatorID string `json:"operatorId"`
  6517. OperatorName string `json:"operatorName"`
  6518. OrgID string `json:"orgId"`
  6519. UserName string `json:"userName"`
  6520. } `json:"data"`
  6521. Infno interface{} `json:"infno"`
  6522. Message string `json:"message"`
  6523. OrgID string `json:"orgId"`
  6524. TransType string `json:"transType"`
  6525. }
  6526. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  6527. outPutInfo = Remove0000(outPutInfo)
  6528. if len(outPutInfo) > 0 {
  6529. var ele ELeData
  6530. err := json.Unmarshal([]byte(outPutInfo), &ele)
  6531. if err != nil {
  6532. utils.ErrorLog("解析失败:%v", err)
  6533. }
  6534. token := ele.Data.EcToken
  6535. fmt.Println(inputInfo)
  6536. fmt.Println(outPutInfo)
  6537. 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)
  6538. saveLog(result, requestLog, "1101", "获取人员信息")
  6539. var dat map[string]interface{}
  6540. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6541. fmt.Println(dat)
  6542. } else {
  6543. fmt.Println(err)
  6544. }
  6545. userJSONBytes, _ := json.Marshal(dat)
  6546. var res ResultTwo
  6547. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6548. utils.ErrorLog("解析失败:%v", err)
  6549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6550. return
  6551. }
  6552. res.ErrMsg = errMsgLog
  6553. if res.Infcode == 0 {
  6554. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  6555. if err == gorm.ErrRecordNotFound {
  6556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6557. return
  6558. } else if err != nil {
  6559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6560. return
  6561. } else {
  6562. fmt.Println(res)
  6563. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6564. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6565. infoStr := string(Iinfos)
  6566. idetinfoStr := string(Idetinfos)
  6567. psn := &models.HisPsn{
  6568. PsnNo: res.Output.Baseinfo.PsnNo,
  6569. Age: res.Output.Baseinfo.Age,
  6570. PatientId: patient.ID,
  6571. Certno: res.Output.Baseinfo.Certno,
  6572. Brdy: res.Output.Baseinfo.Brdy,
  6573. Gend: res.Output.Baseinfo.Gend,
  6574. Naty: res.Output.Baseinfo.Naty,
  6575. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6576. PsnName: res.Output.Baseinfo.PsnName,
  6577. Idetinfo: idetinfoStr,
  6578. Insuinfo: infoStr,
  6579. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6580. CardInfo: outPutInfo,
  6581. VerifyNumber: token,
  6582. InsuplcAdmdvs: ele.Data.InsuOrg,
  6583. }
  6584. service.CreateHisPsn(psn)
  6585. var rf []*ResultFive
  6586. json.Unmarshal([]byte(infoStr), &rf)
  6587. var insutypes []*ResultFive
  6588. var insutype string
  6589. var is390 int = 0
  6590. var is310 int = 0
  6591. for _, item := range rf {
  6592. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6593. insutypes = append(insutypes, item)
  6594. }
  6595. }
  6596. if len(insutypes) == 1 {
  6597. insutype = insutypes[0].Insutype
  6598. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6599. } else {
  6600. for _, i := range insutypes {
  6601. if i.Insutype == "390" {
  6602. is390 = 1
  6603. }
  6604. if i.Insutype == "310" {
  6605. is310 = 1
  6606. }
  6607. }
  6608. }
  6609. if is390 == 1 {
  6610. insutype = "390"
  6611. }
  6612. if is310 == 1 {
  6613. insutype = "310"
  6614. }
  6615. if len(insutypes) == 0 {
  6616. insutype = "310"
  6617. }
  6618. c.ServeSuccessJSON(map[string]interface{}{
  6619. "patient": patient,
  6620. "number": token,
  6621. "insutype": insutype,
  6622. })
  6623. }
  6624. } else {
  6625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6626. return
  6627. }
  6628. }
  6629. } else if miConfig.MdtrtareaAdmvs == "150499" {
  6630. var api string
  6631. 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 +
  6632. "&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
  6633. resp, requestErr := http.Get(api)
  6634. if requestErr != nil {
  6635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6636. return
  6637. }
  6638. body, ioErr := ioutil.ReadAll(resp.Body)
  6639. if ioErr != nil {
  6640. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6642. return
  6643. }
  6644. var respJSON map[string]interface{}
  6645. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6646. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6648. return
  6649. }
  6650. var status string
  6651. status = respJSON["data"].(map[string]interface{})["status"].(string)
  6652. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  6653. var token string
  6654. var res ResultTwo //1101结果
  6655. var res10265 ResultTwo10265 //1101结果
  6656. if status == "0" { //读卡成功
  6657. var card_info string //卡信息
  6658. var busi_card_info string
  6659. token = respJSON["data"].(map[string]interface{})["token"].(string)
  6660. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  6661. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  6662. fmt.Println(card_info)
  6663. fmt.Println(busi_card_info)
  6664. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  6665. result, _ := json.Marshal(respJSON)
  6666. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6667. utils.ErrorLog("解析失败:%v", err)
  6668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6669. return
  6670. }
  6671. res.ErrMsg = res10265.ErrMsg
  6672. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6673. res.Infcode = infocode
  6674. res.Output = res10265.Output
  6675. res.InfRefmsgid = res10265.InfRefmsgid
  6676. if res.Infcode == 0 {
  6677. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6678. if err == gorm.ErrRecordNotFound {
  6679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6680. return
  6681. } else if err != nil {
  6682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6683. return
  6684. } else {
  6685. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6686. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6687. infoStr := string(Iinfos)
  6688. idetinfoStr := string(Idetinfos)
  6689. psn := &models.HisPsn{
  6690. PsnNo: res.Output.Baseinfo.PsnNo,
  6691. Age: res.Output.Baseinfo.Age,
  6692. PatientId: patient.ID,
  6693. Certno: res.Output.Baseinfo.Certno,
  6694. Brdy: res.Output.Baseinfo.Brdy,
  6695. Gend: res.Output.Baseinfo.Gend,
  6696. Naty: res.Output.Baseinfo.Naty,
  6697. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6698. PsnName: res.Output.Baseinfo.PsnName,
  6699. Idetinfo: idetinfoStr,
  6700. Insuinfo: infoStr,
  6701. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6702. CardInfo: card_info,
  6703. VerifyNumber: token,
  6704. }
  6705. var rf []*ResultFive
  6706. json.Unmarshal([]byte(infoStr), &rf)
  6707. var insutypes []*ResultFive
  6708. var insutype string
  6709. var is390 int = 0
  6710. var is310 int = 0
  6711. for _, item := range rf {
  6712. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6713. insutypes = append(insutypes, item)
  6714. }
  6715. }
  6716. if len(insutypes) == 1 {
  6717. insutype = insutypes[0].Insutype
  6718. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6719. } else {
  6720. for _, i := range insutypes {
  6721. if i.Insutype == "390" {
  6722. is390 = 1
  6723. }
  6724. if i.Insutype == "310" {
  6725. is310 = 1
  6726. }
  6727. }
  6728. }
  6729. if is390 == 1 {
  6730. insutype = "390"
  6731. }
  6732. if is310 == 1 {
  6733. insutype = "310"
  6734. }
  6735. if len(insutypes) == 0 {
  6736. insutype = "310"
  6737. }
  6738. service.CreateHisPsn(psn)
  6739. c.ServeSuccessJSON(map[string]interface{}{
  6740. "patient": patient,
  6741. "number": token,
  6742. "insutype": insutype,
  6743. })
  6744. }
  6745. } else {
  6746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6747. return
  6748. }
  6749. } else { //读卡失败
  6750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6751. return
  6752. }
  6753. } else {
  6754. type ELeData struct {
  6755. Code string `json:"code"`
  6756. Data struct {
  6757. Aac002 string `json:"aac002"`
  6758. Aaz500 string `json:"aaz500"`
  6759. ActCardNo string `json:"actCardNo"`
  6760. Bab520 string `json:"bab520"`
  6761. Bkz543 string `json:"bkz543"`
  6762. BusinessType string `json:"businessType"`
  6763. CertfCodg string `json:"certfCodg"`
  6764. EcIndexNo string `json:"ecIndexNo"`
  6765. EcToken string `json:"ecToken"`
  6766. ID0000 string `json:"id0000"`
  6767. IDNo string `json:"idNo"`
  6768. IDType string `json:"idType"`
  6769. Idcode string `json:"idcode"`
  6770. IdentityToken string `json:"identity_token"`
  6771. InsuOrg string `json:"insuOrg"`
  6772. OfficeID string `json:"officeId"`
  6773. OfficeName string `json:"officeName"`
  6774. OperatorID string `json:"operatorId"`
  6775. OperatorName string `json:"operatorName"`
  6776. OrgID string `json:"orgId"`
  6777. UserName string `json:"userName"`
  6778. } `json:"data"`
  6779. Infno interface{} `json:"infno"`
  6780. Message string `json:"message"`
  6781. OrgID string `json:"orgId"`
  6782. TransType string `json:"transType"`
  6783. }
  6784. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  6785. fmt.Println(result)
  6786. outPutInfo := Remove0000(result)
  6787. fmt.Println(outPutInfo)
  6788. if len(outPutInfo) > 0 {
  6789. var ele ELeData
  6790. err := json.Unmarshal([]byte(outPutInfo), &ele)
  6791. if err != nil {
  6792. utils.ErrorLog("解析失败:%v", err)
  6793. }
  6794. token := ele.Data.EcToken
  6795. fmt.Println(outPutInfo)
  6796. result, requestLog := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  6797. saveLog(result, requestLog, "1101", "获取人员信息")
  6798. var dat map[string]interface{}
  6799. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6800. fmt.Println(dat)
  6801. } else {
  6802. fmt.Println(err)
  6803. }
  6804. userJSONBytes, _ := json.Marshal(dat)
  6805. var res ResultTwo
  6806. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6807. utils.ErrorLog("解析失败:%v", err)
  6808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6809. return
  6810. }
  6811. if res.Infcode == 0 {
  6812. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  6813. if err == gorm.ErrRecordNotFound {
  6814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6815. return
  6816. } else if err != nil {
  6817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6818. return
  6819. } else {
  6820. fmt.Println(res)
  6821. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6822. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6823. infoStr := string(Iinfos)
  6824. idetinfoStr := string(Idetinfos)
  6825. psn := &models.HisPsn{
  6826. PsnNo: res.Output.Baseinfo.PsnNo,
  6827. Age: res.Output.Baseinfo.Age,
  6828. PatientId: patient.ID,
  6829. Certno: res.Output.Baseinfo.Certno,
  6830. Brdy: res.Output.Baseinfo.Brdy,
  6831. Gend: res.Output.Baseinfo.Gend,
  6832. Naty: res.Output.Baseinfo.Naty,
  6833. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6834. PsnName: res.Output.Baseinfo.PsnName,
  6835. Idetinfo: idetinfoStr,
  6836. Insuinfo: infoStr,
  6837. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6838. CardInfo: outPutInfo,
  6839. VerifyNumber: token,
  6840. InsuplcAdmdvs: ele.Data.InsuOrg,
  6841. }
  6842. service.CreateHisPsn(psn)
  6843. var rf []*ResultFive
  6844. json.Unmarshal([]byte(infoStr), &rf)
  6845. var insutypes []*ResultFive
  6846. var insutype string
  6847. var is390 int = 0
  6848. var is310 int = 0
  6849. for _, item := range rf {
  6850. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6851. insutypes = append(insutypes, item)
  6852. }
  6853. }
  6854. if len(insutypes) == 1 {
  6855. insutype = insutypes[0].Insutype
  6856. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6857. } else {
  6858. for _, i := range insutypes {
  6859. if i.Insutype == "390" {
  6860. is390 = 1
  6861. }
  6862. if i.Insutype == "310" {
  6863. is310 = 1
  6864. }
  6865. }
  6866. }
  6867. if is390 == 1 {
  6868. insutype = "390"
  6869. }
  6870. if is310 == 1 {
  6871. insutype = "310"
  6872. }
  6873. if len(insutypes) == 0 {
  6874. insutype = "310"
  6875. }
  6876. c.ServeSuccessJSON(map[string]interface{}{
  6877. "patient": patient,
  6878. "number": token,
  6879. "insutype": insutype,
  6880. })
  6881. }
  6882. } else {
  6883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6884. return
  6885. }
  6886. }
  6887. //fmt.Println(result)
  6888. //
  6889. //if initFlag == 0 {
  6890. // c.TestGetBasBaseInit()
  6891. //}
  6892. //token := c.GetEleBaseInfo()
  6893. //
  6894. //token = Remove0000(token)
  6895. //
  6896. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  6897. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  6898. ////
  6899. //var res ResultTwo
  6900. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  6901. // utils.ErrorLog("解析失败:%v", err)
  6902. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6903. // return
  6904. //}
  6905. //
  6906. //if res.Infcode == 0 {
  6907. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6908. // if err == gorm.ErrRecordNotFound {
  6909. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6910. // return
  6911. // } else if err != nil {
  6912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6913. // return
  6914. //
  6915. // } else {
  6916. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6917. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6918. // infoStr := string(Iinfos)
  6919. // idetinfoStr := string(Idetinfos)
  6920. //
  6921. //
  6922. //
  6923. //
  6924. // var rf []*ResultFive
  6925. // json.Unmarshal([]byte(infoStr), &rf)
  6926. //
  6927. // var insutypes []*ResultFive
  6928. // var insutype string
  6929. // var is390 int = 0
  6930. // var is310 int = 0
  6931. // var insuplc_admdvs string
  6932. //
  6933. // for _, item := range rf {
  6934. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6935. // insutypes = append(insutypes, item)
  6936. // }
  6937. // }
  6938. //
  6939. // if len(insutypes) == 1 {
  6940. // insutype = insutypes[0].Insutype
  6941. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6942. // } else {
  6943. // for _, i := range insutypes {
  6944. // if i.Insutype == "390" {
  6945. // is390 = 1
  6946. // }
  6947. //
  6948. // if i.Insutype == "310" {
  6949. // is310 = 1
  6950. // }
  6951. // }
  6952. // }
  6953. // if is390 == 1 {
  6954. // insutype = "390"
  6955. // }
  6956. //
  6957. // if is310 == 1 {
  6958. // insutype = "310"
  6959. // }
  6960. // if len(insutypes) == 0 {
  6961. // insutype = "310"
  6962. // }
  6963. // for _, item := range rf {
  6964. // if item.Insutype == insutype {
  6965. // insuplc_admdvs = item.InsuplcAdmdvs
  6966. // }
  6967. // }
  6968. // psn := &models.HisPsn{
  6969. // PsnNo: res.Output.Baseinfo.PsnNo,
  6970. // Age: res.Output.Baseinfo.Age,
  6971. // PatientId: patient.ID,
  6972. // Certno: res.Output.Baseinfo.Certno,
  6973. // Brdy: res.Output.Baseinfo.Brdy,
  6974. // Gend: res.Output.Baseinfo.Gend,
  6975. // Naty: res.Output.Baseinfo.Naty,
  6976. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  6977. // PsnName: res.Output.Baseinfo.PsnName,
  6978. // Idetinfo: idetinfoStr,
  6979. // Insuinfo: infoStr,
  6980. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6981. // CardInfo: "",
  6982. // VerifyNumber: token,
  6983. // InsuplcAdmdvs: insuplc_admdvs,
  6984. // }
  6985. // service.CreateHisPsn(psn)
  6986. //
  6987. // c.ServeSuccessJSON(map[string]interface{}{
  6988. // "patient": patient,
  6989. // "number": token,
  6990. // })
  6991. // }
  6992. //} else {
  6993. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6994. // return
  6995. //}
  6996. }
  6997. break
  6998. }
  6999. }
  7000. var initFlag int64 = 0
  7001. var initEleFlag int64 = 0
  7002. func (c *HisApiController) TestGetBasBaseInit() {
  7003. DllDef := syscall.MustLoadDLL("SSCard.dll")
  7004. Iinit := DllDef.MustFindProc("Init")
  7005. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7006. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  7007. if ret != 0 {
  7008. fmt.Println("SSCard的报错原因:", err)
  7009. fmt.Println("SSCard的运算结果为:", ret)
  7010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  7011. return
  7012. }
  7013. result := int(ret)
  7014. fmt.Println("SSCard的运算结果为1:", result)
  7015. initFlag = 1
  7016. return
  7017. }
  7018. func (c *HisApiController) HandleJiangXiReadCard() {
  7019. fmt.Println("~~~~~~")
  7020. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7021. admin_user_id, _ := c.GetInt64("admin_user_id")
  7022. id_card_type, _ := c.GetInt64("id_card_type")
  7023. //certificates, _ := c.GetInt64("certificates")
  7024. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7025. if initFlag == 0 {
  7026. c.TestGetJiangXiBasBaseInit()
  7027. }
  7028. basStr := c.GetBasBaseInfo()
  7029. if len(basStr) == 0 {
  7030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  7031. return
  7032. }
  7033. fmt.Println(basStr)
  7034. bas := strings.Split(basStr, "|")
  7035. basNumber := bas[1]
  7036. fmt.Println(basNumber)
  7037. card_sn := bas[3]
  7038. fmt.Println(card_sn)
  7039. 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, "")
  7040. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  7041. var dat map[string]interface{}
  7042. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7043. fmt.Println(dat)
  7044. } else {
  7045. fmt.Println(err)
  7046. }
  7047. userJSONBytes, _ := json.Marshal(dat)
  7048. var res ResultTwo
  7049. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7050. utils.ErrorLog("解析失败:%v", err)
  7051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7052. return
  7053. }
  7054. if res.Infcode == 0 {
  7055. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  7056. if err == gorm.ErrRecordNotFound {
  7057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7058. return
  7059. } else if err != nil {
  7060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7061. return
  7062. } else {
  7063. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7064. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7065. infoStr := string(Iinfos)
  7066. idetinfoStr := string(Idetinfos)
  7067. psn := &models.HisPsn{
  7068. PsnNo: res.Output.Baseinfo.PsnNo,
  7069. Age: res.Output.Baseinfo.Age,
  7070. PatientId: patient.ID,
  7071. Certno: res.Output.Baseinfo.Certno,
  7072. Brdy: res.Output.Baseinfo.Brdy,
  7073. Gend: res.Output.Baseinfo.Gend,
  7074. Naty: res.Output.Baseinfo.Naty,
  7075. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7076. PsnName: res.Output.Baseinfo.PsnName,
  7077. Idetinfo: idetinfoStr,
  7078. Insuinfo: infoStr,
  7079. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7080. CardInfo: basStr,
  7081. VerifyNumber: "",
  7082. }
  7083. service.CreateHisPsn(psn)
  7084. c.ServeSuccessJSON(map[string]interface{}{
  7085. "patient": patient,
  7086. "number": basNumber,
  7087. })
  7088. }
  7089. } else {
  7090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7091. return
  7092. }
  7093. }
  7094. func (c *HisApiController) TestGetHnBasBaseInit() {
  7095. DllDef := syscall.MustLoadDLL("SSCard.dll")
  7096. Iinit := DllDef.MustFindProc("Init")
  7097. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7098. //http://10.77.211.236/CSB/hsa-fsi-1303
  7099. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  7100. if ret != 0 {
  7101. fmt.Println("SSCard的报错原因:", err)
  7102. fmt.Println("SSCard的运算结果为:", ret)
  7103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  7104. return
  7105. }
  7106. result := int(ret)
  7107. fmt.Println("SSCard的运算结果为1:", result)
  7108. initFlag = 1
  7109. return
  7110. }
  7111. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  7112. DllDef := syscall.MustLoadDLL("SSCard.dll")
  7113. Iinit := DllDef.MustFindProc("Init")
  7114. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7115. //http://10.77.211.236/CSB/hsa-fsi-1303
  7116. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  7117. if ret != 0 {
  7118. fmt.Println("SSCard的报错原因:", err)
  7119. fmt.Println("SSCard的运算结果为:", ret)
  7120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  7121. return
  7122. }
  7123. result := int(ret)
  7124. fmt.Println("SSCard的运算结果为1:", result)
  7125. initFlag = 1
  7126. return
  7127. }
  7128. func (c *HisApiController) GetSFZBaseInfo() string {
  7129. DllDef := syscall.MustLoadDLL("SSCard.dll")
  7130. readCard := DllDef.MustFindProc("ReadSFZ")
  7131. if readCard == nil {
  7132. fmt.Println("readcard is nil")
  7133. readCard = DllDef.MustFindProc("ReadSFZ")
  7134. }
  7135. str := make([]byte, 8096)
  7136. str1 := make([]byte, 8096)
  7137. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  7138. fmt.Println(r)
  7139. return Remove0000(string(str))
  7140. }
  7141. func (c *HisApiController) GetEleBaseInfo() string {
  7142. DllDef := syscall.MustLoadDLL("SSCard.dll")
  7143. readCard := DllDef.MustFindProc("GetQRBase")
  7144. fmt.Println(readCard)
  7145. if readCard == nil {
  7146. fmt.Println("readcard is nil")
  7147. readCard = DllDef.MustFindProc("GetQRBase")
  7148. }
  7149. str := make([]byte, 1024)
  7150. str1 := make([]byte, 1024)
  7151. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  7152. fmt.Println(ret2)
  7153. fmt.Println(string(str1))
  7154. fmt.Println(string(str))
  7155. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  7156. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  7157. if ret2 != 0 {
  7158. return ""
  7159. }
  7160. return string(str)
  7161. }
  7162. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  7163. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  7164. readCard := DllDef.MustFindProc("NationEcTrans")
  7165. fmt.Println(readCard)
  7166. fmt.Println("!!!!!")
  7167. pBusiCardInfo := make([]byte, 2048)
  7168. input := make(map[string]interface{})
  7169. inputData := make(map[string]interface{})
  7170. inputData["orgId"] = code
  7171. inputData["businessType"] = "01101"
  7172. inputData["operatorId"] = "1"
  7173. inputData["operatorName"] = "admin"
  7174. inputData["officeId"] = "001"
  7175. inputData["officeName"] = "血透室"
  7176. inputData["deviceType"] = ""
  7177. input["data"] = inputData
  7178. input["orgId"] = code
  7179. input["transType"] = "ec.query"
  7180. bytesData, _ := json.Marshal(input)
  7181. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  7182. fmt.Println(ret2)
  7183. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  7184. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  7185. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  7186. }
  7187. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  7188. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  7189. readCard := DllDef.MustFindProc("NationEcTrans")
  7190. fmt.Println(readCard)
  7191. fmt.Println("!!!!!")
  7192. pBusiCardInfo := make([]byte, 2048)
  7193. input := make(map[string]interface{})
  7194. inputData := make(map[string]interface{})
  7195. inputData["orgId"] = code
  7196. inputData["businessType"] = "01101"
  7197. inputData["operatorId"] = "9"
  7198. inputData["operatorName"] = "admin"
  7199. inputData["officeId"] = "001"
  7200. inputData["officeName"] = "血透室"
  7201. inputData["deviceType"] = ""
  7202. input["data"] = inputData
  7203. input["orgId"] = code
  7204. input["transType"] = "ec.query"
  7205. bytesData, _ := json.Marshal(input)
  7206. 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])))
  7207. fmt.Println(ret2)
  7208. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  7209. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  7210. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  7211. }
  7212. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  7213. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  7214. readCard := DllDef.MustFindProc("NationEcTrans")
  7215. fmt.Println(readCard)
  7216. fmt.Println("!!!!!")
  7217. pBusiCardInfo := make([]byte, 2048)
  7218. input := make(map[string]interface{})
  7219. inputData := make(map[string]interface{})
  7220. inputData["orgId"] = code
  7221. inputData["businessType"] = "01301"
  7222. inputData["operatorId"] = "9"
  7223. inputData["operatorName"] = "admin"
  7224. inputData["officeId"] = "001"
  7225. inputData["officeName"] = "血透室"
  7226. inputData["deviceType"] = ""
  7227. input["data"] = inputData
  7228. input["orgId"] = code
  7229. input["transType"] = "ec.query"
  7230. bytesData, _ := json.Marshal(input)
  7231. 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])))
  7232. fmt.Println(ret2)
  7233. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  7234. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  7235. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  7236. }
  7237. func GetJxEleBaseInfo(org_id int64) string {
  7238. DllDef := syscall.MustLoadDLL("SSCard.dll")
  7239. readCard := DllDef.MustFindProc("NationEcTrans")
  7240. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  7241. if readCard == nil {
  7242. fmt.Println("readcard is nil")
  7243. readCard = DllDef.MustFindProc("NationEcTrans")
  7244. }
  7245. str1 := make([]byte, 1024)
  7246. data := make(map[string]interface{})
  7247. inputData := make(map[string]interface{})
  7248. inputData["orgId"] = miConfig.Code
  7249. inputData["businessType"] = "01101"
  7250. inputData["operatorId"] = "test001"
  7251. inputData["operatorName"] = "cn"
  7252. inputData["officeId"] = "32760"
  7253. inputData["officeName"] = "waike"
  7254. inputData["deviceType"] = ""
  7255. data["data"] = inputData
  7256. data["transType"] = "ec.query"
  7257. data["extra "] = ""
  7258. data["orgId"] = miConfig.Code
  7259. bytesData, _ := json.Marshal(data)
  7260. //bytesData, _ := json.Marshal(data)
  7261. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  7262. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  7263. fmt.Println(ret2)
  7264. fmt.Println(string(str1))
  7265. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  7266. if ret2 != 0 {
  7267. return ""
  7268. }
  7269. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  7270. }
  7271. func GetJxEleBaseInitInfo(org_id int64) string {
  7272. DllDef := syscall.MustLoadDLL("SSCard.dll")
  7273. readCard := DllDef.MustFindProc("NationEcTrans")
  7274. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  7275. if readCard == nil {
  7276. fmt.Println("readcard is nil")
  7277. readCard = DllDef.MustFindProc("NationEcTrans")
  7278. }
  7279. str1 := make([]byte, 2048)
  7280. data := make(map[string]interface{})
  7281. inputData := make(map[string]interface{})
  7282. inputData["orgId"] = miConfig.Code
  7283. inputData["businessType"] = "01101"
  7284. inputData["operatorId"] = "1"
  7285. inputData["operatorName"] = "huangchuang"
  7286. inputData["officeId"] = "101"
  7287. inputData["officeName"] = "xuetou"
  7288. inputData["deviceType"] = ""
  7289. data["data"] = inputData
  7290. data["transType"] = "ec.query"
  7291. data["orgId"] = miConfig.Code
  7292. bytesData, _ := json.Marshal(data)
  7293. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  7294. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  7295. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  7296. fmt.Println(ret2)
  7297. fmt.Println(string(str1))
  7298. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  7299. if ret2 != 0 {
  7300. return ""
  7301. }
  7302. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  7303. initEleFlag = 1
  7304. }
  7305. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  7306. }
  7307. func (c *HisApiController) GetBasBaseInfo() string {
  7308. DllDef := syscall.MustLoadDLL("SSCard.dll")
  7309. readCard := DllDef.MustFindProc("ReadCardBas")
  7310. if readCard == nil {
  7311. fmt.Println("readcard is nil")
  7312. readCard = DllDef.MustFindProc("ReadCardBas")
  7313. }
  7314. str := make([]byte, 1024)
  7315. str1 := make([]byte, 1024)
  7316. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  7317. fmt.Println(string(str1))
  7318. fmt.Println(string(str))
  7319. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  7320. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  7321. if ret2 != 0 {
  7322. return ""
  7323. }
  7324. return string(str)
  7325. }
  7326. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  7327. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  7328. readCard := DllDef.MustFindProc("read_cardinfo")
  7329. if readCard == nil {
  7330. fmt.Println("readcard is nil")
  7331. readCard = DllDef.MustFindProc("read_cardinfo")
  7332. }
  7333. str := make([]byte, 1024) //卡号
  7334. str1 := make([]byte, 1024) //卡识别码
  7335. str2 := make([]byte, 1024) //身份证号
  7336. str3 := make([]byte, 1024) //姓名
  7337. str4 := make([]byte, 1024) //错误信息
  7338. 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])))
  7339. fmt.Println(string(str1))
  7340. fmt.Println(string(str))
  7341. fmt.Println(string(str2))
  7342. fmt.Println(string(str3))
  7343. fmt.Println(string(str4))
  7344. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  7345. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  7346. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  7347. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  7348. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  7349. if ret2 != 0 {
  7350. return "", "", "", "", ""
  7351. }
  7352. return string(str), string(str1), string(str2), string(str3), string(str4)
  7353. }
  7354. type CustomFundPay struct {
  7355. FundPayType string `json:"fund_pay_type"`
  7356. FundPayamt float64 `json:"fund_payamt"`
  7357. }
  7358. func (c *HisApiController) GetSettleList() {
  7359. order_id, _ := c.GetInt64("order_id")
  7360. admin_user_id, _ := c.GetInt64("admin_user_id")
  7361. order, _ := service.GetHisOrderByIDTwo(order_id)
  7362. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  7363. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7364. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  7365. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7366. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  7367. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7368. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  7369. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  7370. if order.ID == 0 {
  7371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7372. return
  7373. }
  7374. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  7375. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  7376. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  7377. //fmt.Println(count)
  7378. //var zero string
  7379. //number := count + 1
  7380. //if number >= 1000 {
  7381. // zero = "0000" + strconv.FormatInt(number, 10)
  7382. //} else if number >= 10000 {
  7383. // zero = "000" + strconv.FormatInt(number, 10)
  7384. //} else if number >= 100000 {
  7385. // zero = "00" + strconv.FormatInt(number, 10)
  7386. //} else if number >= 1000000 {
  7387. // zero = "0" + strconv.FormatInt(number, 10)
  7388. //} else {
  7389. // zero = strconv.FormatInt(number, 10)
  7390. //}
  7391. //fmt.Println(zero)
  7392. struct4101 := service.Struct4101{
  7393. PsnNo: order.PsnNo,
  7394. MdtrtId: order.MdtrtId,
  7395. SetlId: order.SetlId,
  7396. PsnName: order.PsnName,
  7397. Gend: order.Gend,
  7398. Brdy: his.Brdy,
  7399. Age: his.Age,
  7400. Naty: order.Naty,
  7401. PatnCertType: "01",
  7402. Certno: order.Certno,
  7403. Prfs: "90",
  7404. ConerName: roles[0].UserName,
  7405. PatnRlts: "99",
  7406. ConerAddr: miConfig.OrgName,
  7407. ConerTel: admin.Mobile,
  7408. HiType: order.Insutype,
  7409. Insuplc: miConfig.InsuplcAdmdvs,
  7410. MaindiagFlag: "1",
  7411. BillCode: order.SetlId,
  7412. BillNo: order.SetlId,
  7413. BizSn: order.Number,
  7414. PsnSelfPay: order.PsnPartAmt,
  7415. PsnOwnPay: order.PsnPartAmt,
  7416. AcctPay: order.AcctPay,
  7417. PsnCashpay: order.PsnCashPay,
  7418. HiPaymtd: "1",
  7419. Hsorg: miConfig.InsuplcAdmdvs,
  7420. HsorgOpter: miConfig.InsuplcAdmdvs,
  7421. MedinsFillPsn: curRoles.UserName,
  7422. MedinsFillDept: miConfig.OrgName,
  7423. IptMedType: "2",
  7424. }
  7425. struct4101.SetlBegnDate = order.SetlTime
  7426. struct4101.SetlEndDate = order.SetlTime
  7427. time_arr := strings.Split(order.SetlTime, " ")
  7428. struct4101.AdmTime = time_arr[0]
  7429. struct4101.AdmEndTime = time_arr[0]
  7430. var rf []CustomFundPay
  7431. json.Unmarshal([]byte(order.SetlDetail), &rf)
  7432. var tempFunPays []service.CustomStruct
  7433. for _, item := range rf {
  7434. var tempFunPay service.CustomStruct
  7435. tempFunPay.FundPayamt = item.FundPayamt
  7436. tempFunPay.FundPayType = item.FundPayType
  7437. tempFunPays = append(tempFunPays, tempFunPay)
  7438. }
  7439. struct4101.CustomStruct = tempFunPays
  7440. var tempDiaginfos []service.DiaginfoStructTwo
  7441. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  7442. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  7443. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7444. var config []*models.HisXtDiagnoseConfig
  7445. for _, item := range diagnosis_ids {
  7446. id, _ := strconv.ParseInt(item, 10, 64)
  7447. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7448. config = append(config, &diagnosisConfig)
  7449. }
  7450. for index, item := range config {
  7451. if index == 0 {
  7452. var tempDiaginfo service.DiaginfoStructTwo
  7453. tempDiaginfo.DiagCode = item.CountryCode
  7454. tempDiaginfo.DiagName = item.CountryContentName
  7455. tempDiaginfo.DiagType = "1"
  7456. tempDiaginfo.MaindiagFlag = "1"
  7457. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7458. } else {
  7459. var tempDiaginfo service.DiaginfoStructTwo
  7460. tempDiaginfo.DiagCode = item.CountryCode
  7461. tempDiaginfo.DiagName = item.CountryContentName
  7462. tempDiaginfo.DiagType = "2"
  7463. tempDiaginfo.MaindiagFlag = "0"
  7464. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  7465. }
  7466. }
  7467. struct4101.Diseinfo = tempDiaginfos
  7468. sickConfigTwo, _ := service.FindSickById(his.SickType)
  7469. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  7470. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  7471. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  7472. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  7473. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  7474. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  7475. var iteminfo service.IteminfoStruct
  7476. var bedCostTotal float64 = 0 //床位总费
  7477. var bedCostSelfTotal float64 = 0 //床位自费
  7478. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7479. var operationCostTotal float64 = 0 //手术费
  7480. var operationCostSelfTotal float64 = 0 //手术费
  7481. var operationCostPartSelfTotal float64 = 0 //手术费
  7482. var otherCostTotal float64 = 0 //其他费用
  7483. var otherCostSelfTotal float64 = 0 //其他费用
  7484. var otherCostPartSelfTotal float64 = 0 //其他费用
  7485. var materialCostTotal float64 = 0 //材料费
  7486. var materialCostSelfTotal float64 = 0 //材料费
  7487. var materialCostPartSelfTotal float64 = 0 //材料费
  7488. var westernMedicineCostTotal float64 = 0 //西药费
  7489. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7490. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7491. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7492. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7493. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7494. var checkCostTotal float64 = 0 //检查费
  7495. var checkCostSelfTotal float64 = 0 //检查费
  7496. var checkCostPartSelfTotal float64 = 0 //检查费
  7497. var laboratoryCostTotal float64 = 0 //化验费
  7498. var laboratoryCostSelfTotal float64 = 0 //化验费
  7499. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7500. var treatCostTotal float64 = 0 //治疗费用
  7501. var treatCostSelfTotal float64 = 0 //治疗费用
  7502. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7503. decimal.DivisionPrecision = 2
  7504. var bed_fulamt_ownpay_amt float64 = 0
  7505. var operation_fulamt_ownpay_amt float64 = 0
  7506. var other_fulamt_ownpay_amt float64 = 0
  7507. var westernMedicine_fulamt_ownpay_amt float64 = 0
  7508. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  7509. var check_fulamt_ownpay_amt float64 = 0
  7510. var material_fulamt_ownpay_amt float64 = 0
  7511. var laboratory_fulamt_ownpay_amt float64 = 0
  7512. var treat_fulamt_ownpay_amt float64 = 0
  7513. var bed_claa_sunmfee float64 = 0
  7514. var bed_clab_amt float64 = 0
  7515. var bed_other_amt float64 = 0
  7516. var operation_claa_sunmfee float64 = 0
  7517. var operation_clab_amt float64 = 0
  7518. var operation_other_amt float64 = 0
  7519. var other_claa_sunmfee float64 = 0
  7520. var other_clab_amt float64 = 0
  7521. var other_other_amt float64 = 0
  7522. var westernMedicine_claa_sunmfee float64 = 0
  7523. var westernMedicine_clab_amt float64 = 0
  7524. var westernMedicine_other_amt float64 = 0
  7525. var chineseTraditional_claa_sunmfee float64 = 0
  7526. var chineseTraditional_clab_amt float64 = 0
  7527. var chineseTraditional_other_amt float64 = 0
  7528. var check_claa_sunmfee float64 = 0
  7529. var check_clab_amt float64 = 0
  7530. var check_other_amt float64 = 0
  7531. var material_claa_sunmfee float64 = 0
  7532. var material_clab_amt float64 = 0
  7533. var material_other_amt float64 = 0
  7534. var laboratory_claa_sunmfee float64 = 0
  7535. var laboratory_clab_amt float64 = 0
  7536. var laboratory_other_amt float64 = 0
  7537. var treat_claa_sunmfee float64 = 0
  7538. var treat_clab_amt float64 = 0
  7539. var treat_other_amt float64 = 0
  7540. for _, item := range order.HisOrderInfo {
  7541. if item.MedChrgitmType == "01" { //床位费
  7542. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7543. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7544. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7545. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7546. if item.ChrgitmLv == "1" {
  7547. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7548. }
  7549. if item.ChrgitmLv == "2" {
  7550. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7551. }
  7552. if item.ChrgitmLv == "3" {
  7553. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7554. }
  7555. }
  7556. if item.MedChrgitmType == "03" { //检查费
  7557. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7558. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7559. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7560. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7561. if item.ChrgitmLv == "1" {
  7562. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7563. }
  7564. if item.ChrgitmLv == "2" {
  7565. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7566. }
  7567. if item.ChrgitmLv == "3" {
  7568. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7569. }
  7570. }
  7571. if item.MedChrgitmType == "04" { //化验费
  7572. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7573. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7574. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7575. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7576. if item.ChrgitmLv == "1" {
  7577. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7578. }
  7579. if item.ChrgitmLv == "2" {
  7580. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7581. }
  7582. if item.ChrgitmLv == "3" {
  7583. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7584. }
  7585. }
  7586. if item.MedChrgitmType == "05" { //治疗费
  7587. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7588. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7589. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7590. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7591. if item.ChrgitmLv == "1" {
  7592. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7593. }
  7594. if item.ChrgitmLv == "2" {
  7595. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7596. }
  7597. if item.ChrgitmLv == "3" {
  7598. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7599. }
  7600. }
  7601. if item.MedChrgitmType == "06" { //手术费
  7602. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7603. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7604. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7605. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7606. if item.ChrgitmLv == "1" {
  7607. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7608. }
  7609. if item.ChrgitmLv == "2" {
  7610. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7611. }
  7612. if item.ChrgitmLv == "3" {
  7613. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7614. }
  7615. }
  7616. if item.MedChrgitmType == "08" { //材料费
  7617. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7618. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7619. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7620. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7621. if item.ChrgitmLv == "1" {
  7622. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7623. }
  7624. if item.ChrgitmLv == "2" {
  7625. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7626. }
  7627. if item.ChrgitmLv == "3" {
  7628. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7629. }
  7630. }
  7631. if item.MedChrgitmType == "09" { //西药费
  7632. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7633. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7634. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7635. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7636. if item.ChrgitmLv == "1" {
  7637. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7638. }
  7639. if item.ChrgitmLv == "2" {
  7640. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7641. }
  7642. if item.ChrgitmLv == "3" {
  7643. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7644. }
  7645. }
  7646. if item.MedChrgitmType == "11" { //中成费
  7647. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7648. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7649. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7650. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7651. if item.ChrgitmLv == "1" {
  7652. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7653. }
  7654. if item.ChrgitmLv == "2" {
  7655. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7656. }
  7657. if item.ChrgitmLv == "3" {
  7658. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7659. }
  7660. }
  7661. if item.MedChrgitmType == "14" { //其他费
  7662. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7663. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7664. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7665. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7666. if item.ChrgitmLv == "1" {
  7667. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7668. }
  7669. if item.ChrgitmLv == "2" {
  7670. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7671. }
  7672. if item.ChrgitmLv == "3" {
  7673. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7674. }
  7675. }
  7676. }
  7677. var iteminfoStructs []service.IteminfoStruct
  7678. if bedCostTotal != 0 {
  7679. iteminfo.MedChrgitm = "01"
  7680. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  7681. iteminfo.Amt = bedCostTotal
  7682. iteminfo.ClaaSumfee = bed_claa_sunmfee
  7683. iteminfo.ClabAmt = bed_clab_amt
  7684. iteminfo.OthAmt = bed_other_amt
  7685. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7686. }
  7687. if checkCostTotal != 0 {
  7688. iteminfo.MedChrgitm = "03"
  7689. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  7690. iteminfo.Amt = checkCostTotal
  7691. iteminfo.ClaaSumfee = check_claa_sunmfee
  7692. iteminfo.ClabAmt = check_clab_amt
  7693. iteminfo.OthAmt = check_other_amt
  7694. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7695. }
  7696. if laboratoryCostTotal != 0 {
  7697. iteminfo.MedChrgitm = "04"
  7698. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  7699. iteminfo.Amt = laboratoryCostTotal
  7700. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  7701. iteminfo.ClabAmt = laboratory_clab_amt
  7702. iteminfo.OthAmt = laboratory_other_amt
  7703. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7704. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7705. }
  7706. if treatCostTotal != 0 {
  7707. iteminfo.MedChrgitm = "05"
  7708. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  7709. iteminfo.Amt = treatCostTotal
  7710. iteminfo.ClaaSumfee = treat_claa_sunmfee
  7711. iteminfo.ClabAmt = treat_clab_amt
  7712. iteminfo.OthAmt = treat_other_amt
  7713. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7714. //(struct4101.IteminfoStruct, iteminfo)
  7715. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7716. }
  7717. if operationCostTotal != 0 {
  7718. iteminfo.MedChrgitm = "06"
  7719. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  7720. iteminfo.Amt = operationCostTotal
  7721. iteminfo.ClaaSumfee = operation_claa_sunmfee
  7722. iteminfo.ClabAmt = operation_clab_amt
  7723. iteminfo.OthAmt = operation_other_amt
  7724. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7725. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7726. }
  7727. if materialCostTotal != 0 {
  7728. iteminfo.MedChrgitm = "08"
  7729. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  7730. iteminfo.Amt = materialCostTotal
  7731. iteminfo.ClaaSumfee = material_claa_sunmfee
  7732. iteminfo.ClabAmt = material_clab_amt
  7733. iteminfo.OthAmt = material_other_amt
  7734. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7735. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7736. }
  7737. if westernMedicineCostTotal != 0 {
  7738. iteminfo.MedChrgitm = "09"
  7739. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  7740. iteminfo.Amt = westernMedicineCostTotal
  7741. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  7742. iteminfo.ClabAmt = westernMedicine_clab_amt
  7743. iteminfo.OthAmt = westernMedicine_other_amt
  7744. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7745. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7746. }
  7747. if chineseTraditionalMedicineCostTotal != 0 {
  7748. iteminfo.MedChrgitm = "11"
  7749. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  7750. iteminfo.Amt = westernMedicineCostTotal
  7751. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  7752. iteminfo.ClabAmt = westernMedicine_clab_amt
  7753. iteminfo.OthAmt = westernMedicine_other_amt
  7754. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7755. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7756. }
  7757. if otherCostTotal != 0 {
  7758. iteminfo.MedChrgitm = "14"
  7759. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  7760. iteminfo.Amt = otherCostTotal
  7761. iteminfo.ClaaSumfee = other_claa_sunmfee
  7762. iteminfo.ClabAmt = other_clab_amt
  7763. iteminfo.OthAmt = other_other_amt
  7764. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7765. iteminfoStructs = append(iteminfoStructs, iteminfo)
  7766. }
  7767. struct4101.IteminfoStruct = iteminfoStructs
  7768. struct4101.Ntly = "中国"
  7769. struct4101.AdmCaty = "A03.06"
  7770. struct4101.DoctorName = doctor.UserName
  7771. struct4101.DoctorCode = doctor.DoctorNumber
  7772. var res ResultSeventeen
  7773. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7774. struct4101.BillCode = order.Number
  7775. struct4101.BillNo = order.SetlId
  7776. var resOther ResultSeventeenOther
  7777. var pp models.PublicParams
  7778. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7779. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7780. pp.FixmedinsName = miConfig.OrgName
  7781. pp.FixmedinsCode = miConfig.Code
  7782. pp.RequestUrl = miConfig.Url
  7783. pp.Cainfo = miConfig.Cainfo
  7784. pp.SecretKey = miConfig.SecretKey
  7785. pp.AccessKey = miConfig.AccessKey
  7786. pp.OpterName = curRoles.UserName
  7787. client := &http.Client{}
  7788. var req *http.Request
  7789. data := make(map[string]interface{})
  7790. data["struct4101"] = struct4101
  7791. data["pp"] = pp
  7792. bytesData, _ := json.Marshal(data)
  7793. if miConfig.MdtrtareaAdmvs == "320921" {
  7794. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  7795. } else {
  7796. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  7797. }
  7798. resp, _ := client.Do(req)
  7799. defer resp.Body.Close()
  7800. body, ioErr := ioutil.ReadAll(resp.Body)
  7801. if ioErr != nil {
  7802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7804. return
  7805. }
  7806. var respJSON map[string]interface{}
  7807. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7810. return
  7811. }
  7812. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7813. userJSONBytes, _ := json.Marshal(respJSON)
  7814. fmt.Println("log")
  7815. fmt.Println(string(userJSONBytes))
  7816. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  7817. utils.ErrorLog("解析失败:%v", err)
  7818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7819. return
  7820. }
  7821. res.InfRefmsgid = resOther.InfRefmsgid
  7822. res.Output = resOther.Output
  7823. res.ErrMsg = resOther.ErrMsg
  7824. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  7825. res.Infcode = infocode
  7826. } else if miConfig.MdtrtareaAdmvs == "360399" {
  7827. var pp models.PublicParams
  7828. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7829. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7830. pp.FixmedinsName = miConfig.OrgName
  7831. pp.FixmedinsCode = miConfig.Code
  7832. pp.RequestUrl = miConfig.Url
  7833. pp.Cainfo = miConfig.Cainfo
  7834. pp.SecretKey = miConfig.SecretKey
  7835. pp.AccessKey = miConfig.AccessKey
  7836. pp.OpterName = curRoles.UserName
  7837. result, _ := service.Jxyb4101(struct4101, pp)
  7838. var dat map[string]interface{}
  7839. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7840. fmt.Println(dat)
  7841. } else {
  7842. fmt.Println(err)
  7843. }
  7844. userJSONBytes, _ := json.Marshal(dat)
  7845. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7846. utils.ErrorLog("解析失败:%v", err)
  7847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7848. return
  7849. }
  7850. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7851. var pp models.PublicParams
  7852. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7853. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7854. pp.FixmedinsName = miConfig.OrgName
  7855. pp.FixmedinsCode = miConfig.Code
  7856. pp.RequestUrl = miConfig.Url
  7857. pp.Cainfo = miConfig.Cainfo
  7858. pp.SecretKey = miConfig.SecretKey
  7859. pp.AccessKey = miConfig.AccessKey
  7860. pp.OpterName = curRoles.UserName
  7861. result, _ := service.Hnyb4101(struct4101, pp)
  7862. var dat map[string]interface{}
  7863. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7864. fmt.Println(dat)
  7865. } else {
  7866. fmt.Println(err)
  7867. }
  7868. userJSONBytes, _ := json.Marshal(dat)
  7869. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7870. utils.ErrorLog("解析失败:%v", err)
  7871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7872. return
  7873. }
  7874. } else {
  7875. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  7876. var dat map[string]interface{}
  7877. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7878. fmt.Println(dat)
  7879. } else {
  7880. fmt.Println(err)
  7881. }
  7882. userJSONBytes, _ := json.Marshal(dat)
  7883. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7884. utils.ErrorLog("解析失败:%v", err)
  7885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7886. return
  7887. }
  7888. }
  7889. if res.Infcode != 0 {
  7890. c.ServeSuccessJSON(map[string]interface{}{
  7891. "failed_code": -10,
  7892. "msg": res.ErrMsg,
  7893. })
  7894. return
  7895. } else {
  7896. //order.FaPiaoNumber = zero
  7897. //order.FaPiaoCode = last_order.FaPiaoCode
  7898. //service.UpdateOrder(order)
  7899. hisFundSettleListResult := &models.HisFundSettleListResult{
  7900. Number: res.Output.SetlListId,
  7901. Status: 1,
  7902. Ctime: time.Now().Unix(),
  7903. Mtime: time.Now().Unix(),
  7904. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7905. IsUpload: 1,
  7906. OrderId: order_id,
  7907. }
  7908. service.CreateUploadRecord(hisFundSettleListResult)
  7909. c.ServeSuccessJSON(map[string]interface{}{
  7910. "msg": "上传成功",
  7911. "result": hisFundSettleListResult,
  7912. })
  7913. return
  7914. }
  7915. }
  7916. func (c *HisApiController) GetSettleListHospital() {
  7917. order_id, _ := c.GetInt64("order_id")
  7918. admin_user_id, _ := c.GetInt64("admin_user_id")
  7919. order, _ := service.GetHisOrderByIDTwo(order_id)
  7920. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  7921. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7922. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  7923. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7924. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  7925. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7926. if order.ID == 0 {
  7927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  7928. return
  7929. }
  7930. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  7931. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  7932. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  7933. fmt.Println(count)
  7934. var zero string
  7935. number := count + 1
  7936. if number >= 1000 {
  7937. zero = "0000" + strconv.FormatInt(number, 10)
  7938. } else if number >= 10000 {
  7939. zero = "000" + strconv.FormatInt(number, 10)
  7940. } else if number >= 100000 {
  7941. zero = "00" + strconv.FormatInt(number, 10)
  7942. } else if number >= 1000000 {
  7943. zero = "0" + strconv.FormatInt(number, 10)
  7944. } else {
  7945. zero = strconv.FormatInt(number, 10)
  7946. }
  7947. fmt.Println(zero)
  7948. struct4101 := service.Struct4101{
  7949. PsnNo: order.PsnNo,
  7950. MdtrtId: order.MdtrtId,
  7951. SetlId: order.SetlId,
  7952. PsnName: order.PsnName,
  7953. Gend: order.Gend,
  7954. Brdy: his.Brdy,
  7955. Age: int64(order.Age),
  7956. Naty: order.Naty,
  7957. PatnCertType: "01",
  7958. Certno: order.Certno,
  7959. Prfs: "90",
  7960. ConerName: roles[0].UserName,
  7961. PatnRlts: "99",
  7962. ConerAddr: miConfig.OrgName,
  7963. ConerTel: admin.Mobile,
  7964. HiType: order.Insutype,
  7965. Insuplc: miConfig.InsuplcAdmdvs,
  7966. MaindiagFlag: "1",
  7967. BillCode: order.SetlId,
  7968. BillNo: order.SetlId,
  7969. BizSn: order.Number,
  7970. PsnSelfPay: order.PsnPartAmt,
  7971. PsnOwnPay: order.PsnPartAmt,
  7972. AcctPay: order.AcctPay,
  7973. PsnCashpay: order.PsnCashPay,
  7974. HiPaymtd: "1",
  7975. Hsorg: miConfig.InsuplcAdmdvs,
  7976. HsorgOpter: miConfig.InsuplcAdmdvs,
  7977. MedinsFillPsn: curRoles.UserName,
  7978. MedinsFillDept: depart.Name,
  7979. IptMedType: "2",
  7980. AdmTime: his.InHosptialTime,
  7981. AdmEndTime: his.OutHosptialTime,
  7982. }
  7983. struct4101.SetlBegnDate = order.SetlTime
  7984. struct4101.SetlEndDate = order.SetlTime
  7985. var rf []CustomFundPay
  7986. json.Unmarshal([]byte(order.SetlDetail), &rf)
  7987. var tempFunPays []service.CustomStruct
  7988. for _, item := range rf {
  7989. var tempFunPay service.CustomStruct
  7990. tempFunPay.FundPayamt = item.FundPayamt
  7991. tempFunPay.FundPayType = item.FundPayType
  7992. tempFunPays = append(tempFunPays, tempFunPay)
  7993. }
  7994. struct4101.CustomStruct = tempFunPays
  7995. var tempDiaginfos []service.DiaginfoStructTwo
  7996. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  7997. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  7998. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7999. var config []*models.HisXtDiagnoseConfig
  8000. for _, item := range diagnosis_ids {
  8001. id, _ := strconv.ParseInt(item, 10, 64)
  8002. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8003. config = append(config, &diagnosisConfig)
  8004. }
  8005. for index, item := range config {
  8006. if index == 0 {
  8007. var tempDiaginfo service.DiaginfoStructTwo
  8008. tempDiaginfo.DiagCode = item.CountryCode
  8009. tempDiaginfo.DiagName = item.CountryContentName
  8010. tempDiaginfo.DiagType = "1"
  8011. tempDiaginfo.MaindiagFlag = "1"
  8012. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8013. } else {
  8014. var tempDiaginfo service.DiaginfoStructTwo
  8015. tempDiaginfo.DiagCode = item.CountryCode
  8016. tempDiaginfo.DiagName = item.CountryContentName
  8017. tempDiaginfo.DiagType = "2"
  8018. tempDiaginfo.MaindiagFlag = "0"
  8019. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8020. }
  8021. }
  8022. struct4101.Diseinfo = tempDiaginfos
  8023. sickConfigTwo, _ := service.FindSickById(his.SickType)
  8024. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  8025. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  8026. tempOpspdiseinfo2.OprnOprtCode = ""
  8027. tempOpspdiseinfo2.OprnOprtName = ""
  8028. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  8029. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  8030. var iteminfo service.IteminfoStruct
  8031. var bedCostTotal float64 = 0 //床位总费
  8032. var bedCostSelfTotal float64 = 0 //床位自费
  8033. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8034. var operationCostTotal float64 = 0 //手术费
  8035. var operationCostSelfTotal float64 = 0 //手术费
  8036. var operationCostPartSelfTotal float64 = 0 //手术费
  8037. var otherCostTotal float64 = 0 //其他费用
  8038. var otherCostSelfTotal float64 = 0 //其他费用
  8039. var otherCostPartSelfTotal float64 = 0 //其他费用
  8040. var materialCostTotal float64 = 0 //材料费
  8041. var materialCostSelfTotal float64 = 0 //材料费
  8042. var materialCostPartSelfTotal float64 = 0 //材料费
  8043. var westernMedicineCostTotal float64 = 0 //西药费
  8044. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8045. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8046. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8047. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8048. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8049. var checkCostTotal float64 = 0 //检查费
  8050. var checkCostSelfTotal float64 = 0 //检查费
  8051. var checkCostPartSelfTotal float64 = 0 //检查费
  8052. var laboratoryCostTotal float64 = 0 //化验费
  8053. var laboratoryCostSelfTotal float64 = 0 //化验费
  8054. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8055. var treatCostTotal float64 = 0 //治疗费用
  8056. var treatCostSelfTotal float64 = 0 //治疗费用
  8057. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8058. decimal.DivisionPrecision = 2
  8059. var bed_fulamt_ownpay_amt float64 = 0
  8060. var operation_fulamt_ownpay_amt float64 = 0
  8061. var other_fulamt_ownpay_amt float64 = 0
  8062. var westernMedicine_fulamt_ownpay_amt float64 = 0
  8063. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  8064. var check_fulamt_ownpay_amt float64 = 0
  8065. var material_fulamt_ownpay_amt float64 = 0
  8066. var laboratory_fulamt_ownpay_amt float64 = 0
  8067. var treat_fulamt_ownpay_amt float64 = 0
  8068. var bed_claa_sunmfee float64 = 0
  8069. var bed_clab_amt float64 = 0
  8070. var bed_other_amt float64 = 0
  8071. var operation_claa_sunmfee float64 = 0
  8072. var operation_clab_amt float64 = 0
  8073. var operation_other_amt float64 = 0
  8074. var other_claa_sunmfee float64 = 0
  8075. var other_clab_amt float64 = 0
  8076. var other_other_amt float64 = 0
  8077. var westernMedicine_claa_sunmfee float64 = 0
  8078. var westernMedicine_clab_amt float64 = 0
  8079. var westernMedicine_other_amt float64 = 0
  8080. var chineseTraditional_claa_sunmfee float64 = 0
  8081. var chineseTraditional_clab_amt float64 = 0
  8082. var chineseTraditional_other_amt float64 = 0
  8083. var check_claa_sunmfee float64 = 0
  8084. var check_clab_amt float64 = 0
  8085. var check_other_amt float64 = 0
  8086. var material_claa_sunmfee float64 = 0
  8087. var material_clab_amt float64 = 0
  8088. var material_other_amt float64 = 0
  8089. var laboratory_claa_sunmfee float64 = 0
  8090. var laboratory_clab_amt float64 = 0
  8091. var laboratory_other_amt float64 = 0
  8092. var treat_claa_sunmfee float64 = 0
  8093. var treat_clab_amt float64 = 0
  8094. var treat_other_amt float64 = 0
  8095. for _, item := range order.HisOrderInfo {
  8096. if item.MedChrgitmType == "01" { //床位费
  8097. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8098. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8099. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8100. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8101. if item.ChrgitmLv == "1" {
  8102. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8103. }
  8104. if item.ChrgitmLv == "2" {
  8105. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8106. }
  8107. if item.ChrgitmLv == "3" {
  8108. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8109. }
  8110. }
  8111. if item.MedChrgitmType == "03" { //检查费
  8112. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8113. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8114. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8115. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8116. if item.ChrgitmLv == "1" {
  8117. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8118. }
  8119. if item.ChrgitmLv == "2" {
  8120. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8121. }
  8122. if item.ChrgitmLv == "3" {
  8123. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8124. }
  8125. }
  8126. if item.MedChrgitmType == "04" { //化验费
  8127. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8128. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8129. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8130. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8131. if item.ChrgitmLv == "1" {
  8132. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8133. }
  8134. if item.ChrgitmLv == "2" {
  8135. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8136. }
  8137. if item.ChrgitmLv == "3" {
  8138. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8139. }
  8140. }
  8141. if item.MedChrgitmType == "05" { //治疗费
  8142. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8143. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8144. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8145. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8146. if item.ChrgitmLv == "1" {
  8147. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8148. }
  8149. if item.ChrgitmLv == "2" {
  8150. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8151. }
  8152. if item.ChrgitmLv == "3" {
  8153. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8154. }
  8155. }
  8156. if item.MedChrgitmType == "06" { //手术费
  8157. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8158. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8159. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8160. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8161. if item.ChrgitmLv == "1" {
  8162. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8163. }
  8164. if item.ChrgitmLv == "2" {
  8165. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8166. }
  8167. if item.ChrgitmLv == "3" {
  8168. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8169. }
  8170. }
  8171. if item.MedChrgitmType == "08" { //材料费
  8172. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8173. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8174. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8175. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8176. if item.ChrgitmLv == "1" {
  8177. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8178. }
  8179. if item.ChrgitmLv == "2" {
  8180. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8181. }
  8182. if item.ChrgitmLv == "3" {
  8183. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8184. }
  8185. }
  8186. if item.MedChrgitmType == "09" { //西药费
  8187. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8188. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8189. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8190. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8191. if item.ChrgitmLv == "1" {
  8192. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8193. }
  8194. if item.ChrgitmLv == "2" {
  8195. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8196. }
  8197. if item.ChrgitmLv == "3" {
  8198. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8199. }
  8200. }
  8201. if item.MedChrgitmType == "11" { //中成费
  8202. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8203. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8204. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8205. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8206. if item.ChrgitmLv == "1" {
  8207. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8208. }
  8209. if item.ChrgitmLv == "2" {
  8210. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8211. }
  8212. if item.ChrgitmLv == "3" {
  8213. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8214. }
  8215. }
  8216. if item.MedChrgitmType == "14" { //其他费
  8217. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8218. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8219. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8220. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8221. if item.ChrgitmLv == "1" {
  8222. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8223. }
  8224. if item.ChrgitmLv == "2" {
  8225. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8226. }
  8227. if item.ChrgitmLv == "3" {
  8228. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8229. }
  8230. }
  8231. }
  8232. var iteminfoStructs []service.IteminfoStruct
  8233. if bedCostTotal != 0 {
  8234. iteminfo.MedChrgitm = "01"
  8235. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  8236. iteminfo.Amt = bedCostTotal
  8237. iteminfo.ClaaSumfee = bed_claa_sunmfee
  8238. iteminfo.ClabAmt = bed_clab_amt
  8239. iteminfo.OthAmt = bed_other_amt
  8240. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8241. }
  8242. if checkCostTotal != 0 {
  8243. iteminfo.MedChrgitm = "03"
  8244. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  8245. iteminfo.Amt = checkCostTotal
  8246. iteminfo.ClaaSumfee = check_claa_sunmfee
  8247. iteminfo.ClabAmt = check_clab_amt
  8248. iteminfo.OthAmt = check_other_amt
  8249. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8250. }
  8251. if laboratoryCostTotal != 0 {
  8252. iteminfo.MedChrgitm = "04"
  8253. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  8254. iteminfo.Amt = laboratoryCostTotal
  8255. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  8256. iteminfo.ClabAmt = laboratory_clab_amt
  8257. iteminfo.OthAmt = laboratory_other_amt
  8258. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8259. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8260. }
  8261. if treatCostTotal != 0 {
  8262. iteminfo.MedChrgitm = "05"
  8263. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  8264. iteminfo.Amt = treatCostTotal
  8265. iteminfo.ClaaSumfee = treat_claa_sunmfee
  8266. iteminfo.ClabAmt = treat_clab_amt
  8267. iteminfo.OthAmt = treat_other_amt
  8268. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8269. //(struct4101.IteminfoStruct, iteminfo)
  8270. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8271. }
  8272. if operationCostTotal != 0 {
  8273. iteminfo.MedChrgitm = "06"
  8274. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  8275. iteminfo.Amt = operationCostTotal
  8276. iteminfo.ClaaSumfee = operation_claa_sunmfee
  8277. iteminfo.ClabAmt = operation_clab_amt
  8278. iteminfo.OthAmt = operation_other_amt
  8279. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8280. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8281. }
  8282. if materialCostTotal != 0 {
  8283. iteminfo.MedChrgitm = "08"
  8284. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  8285. iteminfo.Amt = materialCostTotal
  8286. iteminfo.ClaaSumfee = material_claa_sunmfee
  8287. iteminfo.ClabAmt = material_clab_amt
  8288. iteminfo.OthAmt = material_other_amt
  8289. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8290. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8291. }
  8292. if westernMedicineCostTotal != 0 {
  8293. iteminfo.MedChrgitm = "09"
  8294. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  8295. iteminfo.Amt = westernMedicineCostTotal
  8296. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  8297. iteminfo.ClabAmt = westernMedicine_clab_amt
  8298. iteminfo.OthAmt = westernMedicine_other_amt
  8299. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8300. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8301. }
  8302. if chineseTraditionalMedicineCostTotal != 0 {
  8303. iteminfo.MedChrgitm = "11"
  8304. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  8305. iteminfo.Amt = westernMedicineCostTotal
  8306. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  8307. iteminfo.ClabAmt = westernMedicine_clab_amt
  8308. iteminfo.OthAmt = westernMedicine_other_amt
  8309. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8310. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8311. }
  8312. if otherCostTotal != 0 {
  8313. iteminfo.MedChrgitm = "14"
  8314. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  8315. iteminfo.Amt = otherCostTotal
  8316. iteminfo.ClaaSumfee = other_claa_sunmfee
  8317. iteminfo.ClabAmt = other_clab_amt
  8318. iteminfo.OthAmt = other_other_amt
  8319. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8320. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8321. }
  8322. struct4101.IteminfoStruct = iteminfoStructs
  8323. struct4101.Ntly = "中国"
  8324. struct4101.AdmCaty = "A03.06"
  8325. var resOther ResultSeventeenOther
  8326. var res ResultSeventeen
  8327. if miConfig.MdtrtareaAdmvs == "150499" {
  8328. var pp models.PublicParams
  8329. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  8330. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  8331. pp.FixmedinsName = miConfig.OrgName
  8332. pp.FixmedinsCode = miConfig.Code
  8333. pp.RequestUrl = miConfig.Url
  8334. pp.Cainfo = miConfig.Cainfo
  8335. pp.SecretKey = miConfig.SecretKey
  8336. pp.AccessKey = miConfig.AccessKey
  8337. pp.OpterName = curRoles.UserName
  8338. client := &http.Client{}
  8339. var req *http.Request
  8340. data := make(map[string]interface{})
  8341. data["struct4101"] = struct4101
  8342. data["pp"] = pp
  8343. bytesData, _ := json.Marshal(data)
  8344. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  8345. resp, _ := client.Do(req)
  8346. defer resp.Body.Close()
  8347. body, ioErr := ioutil.ReadAll(resp.Body)
  8348. if ioErr != nil {
  8349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8351. return
  8352. }
  8353. var respJSON map[string]interface{}
  8354. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8357. return
  8358. }
  8359. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8360. userJSONBytes, _ := json.Marshal(respJSON)
  8361. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  8362. utils.ErrorLog("解析失败:%v", err)
  8363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8364. return
  8365. }
  8366. res.InfRefmsgid = resOther.InfRefmsgid
  8367. res.Output = resOther.Output
  8368. res.ErrMsg = resOther.ErrMsg
  8369. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  8370. res.Infcode = infocode
  8371. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8372. var pp models.PublicParams
  8373. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  8374. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  8375. pp.FixmedinsName = miConfig.OrgName
  8376. pp.FixmedinsCode = miConfig.Code
  8377. pp.RequestUrl = miConfig.Url
  8378. pp.Cainfo = miConfig.Cainfo
  8379. pp.SecretKey = miConfig.SecretKey
  8380. pp.AccessKey = miConfig.AccessKey
  8381. pp.OpterName = curRoles.UserName
  8382. result, _ := service.Jxyb4101(struct4101, pp)
  8383. var dat map[string]interface{}
  8384. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8385. fmt.Println(dat)
  8386. } else {
  8387. fmt.Println(err)
  8388. }
  8389. userJSONBytes, _ := json.Marshal(dat)
  8390. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8391. utils.ErrorLog("解析失败:%v", err)
  8392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8393. return
  8394. }
  8395. } else {
  8396. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  8397. var dat map[string]interface{}
  8398. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8399. fmt.Println(dat)
  8400. } else {
  8401. fmt.Println(err)
  8402. }
  8403. userJSONBytes, _ := json.Marshal(dat)
  8404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8405. utils.ErrorLog("解析失败:%v", err)
  8406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8407. return
  8408. }
  8409. }
  8410. if res.Infcode != 0 {
  8411. c.ServeSuccessJSON(map[string]interface{}{
  8412. "failed_code": -10,
  8413. "msg": res.ErrMsg,
  8414. })
  8415. return
  8416. } else {
  8417. if miConfig.MdtrtareaAdmvs != "150499" {
  8418. order.FaPiaoNumber = zero
  8419. order.FaPiaoCode = last_order.FaPiaoCode
  8420. service.UpdateOrder(order)
  8421. }
  8422. hisFundSettleListResult := &models.HisFundSettleListResult{
  8423. Number: res.Output.SetlListId,
  8424. Status: 1,
  8425. Ctime: time.Now().Unix(),
  8426. Mtime: time.Now().Unix(),
  8427. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8428. IsUpload: 1,
  8429. OrderId: order_id,
  8430. }
  8431. service.CreateUploadRecord(hisFundSettleListResult)
  8432. c.ServeSuccessJSON(map[string]interface{}{
  8433. "msg": "上传成功",
  8434. "result": hisFundSettleListResult,
  8435. })
  8436. return
  8437. }
  8438. }
  8439. func (c *HisApiController) GetBatchSettleList() {
  8440. orders, _ := service.GetAllHisOrder(10106)
  8441. for _, item := range orders {
  8442. order_id := item.ID
  8443. order, _ := service.GetHisOrderByIDTwo(order_id)
  8444. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  8445. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8446. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  8447. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  8448. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  8449. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8450. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8451. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8452. if order.ID == 0 {
  8453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8454. return
  8455. }
  8456. if his.BalanceAccountsType == 2 {
  8457. continue
  8458. }
  8459. struct4101 := service.Struct4101{
  8460. PsnNo: order.PsnNo,
  8461. MdtrtId: order.MdtrtId,
  8462. SetlId: order.SetlId,
  8463. PsnName: order.PsnName,
  8464. Gend: order.Gend,
  8465. Brdy: his.Brdy,
  8466. Age: his.Age,
  8467. Naty: order.Naty,
  8468. PatnCertType: "01",
  8469. Certno: order.Certno,
  8470. Prfs: "90",
  8471. ConerName: roles[0].UserName,
  8472. PatnRlts: "99",
  8473. ConerAddr: miConfig.OrgName,
  8474. ConerTel: admin.Mobile,
  8475. HiType: order.Insutype,
  8476. Insuplc: his.InsuplcAdmdvs,
  8477. MaindiagFlag: "1",
  8478. BillCode: order.SetlId,
  8479. BillNo: order.SetlId,
  8480. BizSn: order.Number,
  8481. PsnSelfPay: order.PsnPartAmt,
  8482. PsnOwnPay: order.PsnPartAmt,
  8483. AcctPay: order.AcctPay,
  8484. PsnCashpay: order.PsnCashPay,
  8485. HiPaymtd: "1",
  8486. Hsorg: his.InsuplcAdmdvs,
  8487. HsorgOpter: his.InsuplcAdmdvs,
  8488. MedinsFillPsn: curRoles.UserName,
  8489. MedinsFillDept: depart.Name,
  8490. IptMedType: "2",
  8491. }
  8492. struct4101.SetlBegnDate = order.SetlTime
  8493. struct4101.SetlEndDate = order.SetlTime
  8494. //if order.SettleType == 1 {
  8495. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  8496. // dateStr := t.Format("2006-01-02")
  8497. // struct4101.SetlBegnDate = dateStr
  8498. // struct4101.SetlEndDate = dateStr
  8499. //} else {
  8500. // t := time.Unix(int64(order.SettleStartTime), 0)
  8501. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  8502. // dateStartStr := t.Format("2006-01-02")
  8503. // dateEndStr := t2.Format("2006-01-02")
  8504. // struct4101.SetlBegnDate = dateStartStr
  8505. // struct4101.SetlEndDate = dateEndStr
  8506. //}
  8507. var rf []CustomFundPay
  8508. json.Unmarshal([]byte(order.SetlDetail), &rf)
  8509. var tempFunPays []service.CustomStruct
  8510. var tempFunPay610100 service.CustomStruct
  8511. for _, item := range rf {
  8512. if item.FundPayType == "610100" {
  8513. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  8514. tempFunPay610100.FundPayType = item.FundPayType
  8515. } else {
  8516. var tempFunPay service.CustomStruct
  8517. tempFunPay.FundPayamt = item.FundPayamt
  8518. tempFunPay.FundPayType = item.FundPayType
  8519. tempFunPays = append(tempFunPays, tempFunPay)
  8520. }
  8521. }
  8522. tempFunPays = append(tempFunPays, tempFunPay610100)
  8523. struct4101.CustomStruct = tempFunPays
  8524. var tempDiaginfos []service.DiaginfoStructTwo
  8525. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  8526. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  8527. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  8528. var config []*models.HisXtDiagnoseConfig
  8529. for _, item := range diagnosis_ids {
  8530. id, _ := strconv.ParseInt(item, 10, 64)
  8531. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8532. config = append(config, &diagnosisConfig)
  8533. }
  8534. for index, item := range config {
  8535. if index == 0 {
  8536. var tempDiaginfo service.DiaginfoStructTwo
  8537. tempDiaginfo.DiagCode = item.CountryCode
  8538. tempDiaginfo.DiagName = item.CountryContentName
  8539. tempDiaginfo.DiagType = "1"
  8540. tempDiaginfo.MaindiagFlag = "1"
  8541. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8542. } else {
  8543. var tempDiaginfo service.DiaginfoStructTwo
  8544. tempDiaginfo.DiagCode = item.CountryCode
  8545. tempDiaginfo.DiagName = item.CountryContentName
  8546. tempDiaginfo.DiagType = "2"
  8547. tempDiaginfo.MaindiagFlag = "0"
  8548. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  8549. }
  8550. }
  8551. struct4101.Diseinfo = tempDiaginfos
  8552. sickConfigTwo, _ := service.FindSickById(his.SickType)
  8553. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  8554. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  8555. tempOpspdiseinfo2.OprnOprtCode = ""
  8556. tempOpspdiseinfo2.OprnOprtName = ""
  8557. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  8558. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  8559. var iteminfo service.IteminfoStruct
  8560. var bedCostTotal float64 = 0 //床位总费
  8561. var bedCostSelfTotal float64 = 0 //床位自费
  8562. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8563. var examineCostTotal float64 = 0 //诊查总费
  8564. var examineCostSelfTotal float64 = 0 //诊查自费
  8565. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  8566. var nursingCostTotal float64 = 0 //护理总费
  8567. var nursingCostSelfTotal float64 = 0 //护理自费
  8568. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  8569. var chineseMedicineCostTotal float64 = 0 //中成药
  8570. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  8571. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  8572. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  8573. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  8574. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  8575. var registerCostTotal float64 = 0 //一般诊疗费
  8576. var registerCostSelfTotal float64 = 0 //一般诊疗费
  8577. var registerPartSelfTotal float64 = 0 //一般诊疗费
  8578. var operationCostTotal float64 = 0 //手术费
  8579. var operationCostSelfTotal float64 = 0 //手术费
  8580. var operationCostPartSelfTotal float64 = 0 //手术费
  8581. var otherCostTotal float64 = 0 //其他费用
  8582. var otherCostSelfTotal float64 = 0 //其他费用
  8583. var otherCostPartSelfTotal float64 = 0 //其他费用
  8584. var materialCostTotal float64 = 0 //材料费
  8585. var materialCostSelfTotal float64 = 0 //材料费
  8586. var materialCostPartSelfTotal float64 = 0 //材料费
  8587. var westernMedicineCostTotal float64 = 0 //西药费
  8588. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8589. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8590. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8591. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8592. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8593. var checkCostTotal float64 = 0 //检查费
  8594. var checkCostSelfTotal float64 = 0 //检查费
  8595. var checkCostPartSelfTotal float64 = 0 //检查费
  8596. var laboratoryCostTotal float64 = 0 //化验费
  8597. var laboratoryCostSelfTotal float64 = 0 //化验费
  8598. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8599. var treatCostTotal float64 = 0 //治疗费用
  8600. var treatCostSelfTotal float64 = 0 //治疗费用
  8601. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8602. decimal.DivisionPrecision = 2
  8603. var bed_fulamt_ownpay_amt float64 = 0
  8604. var examine_fulamt_ownpay_amt float64 = 0
  8605. var nursing_fulamt_ownpay_amt float64 = 0
  8606. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  8607. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  8608. var register_fulamt_ownpay_amt float64 = 0
  8609. var operation_fulamt_ownpay_amt float64 = 0
  8610. var other_fulamt_ownpay_amt float64 = 0
  8611. var westernMedicine_fulamt_ownpay_amt float64 = 0
  8612. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  8613. var check_fulamt_ownpay_amt float64 = 0
  8614. var material_fulamt_ownpay_amt float64 = 0
  8615. var laboratory_fulamt_ownpay_amt float64 = 0
  8616. var treat_fulamt_ownpay_amt float64 = 0
  8617. var bed_claa_sunmfee float64 = 0
  8618. var bed_clab_amt float64 = 0
  8619. var bed_other_amt float64 = 0
  8620. var examine_claa_sunmfee float64 = 0
  8621. var examine_clab_amt float64 = 0
  8622. var examine_other_amt float64 = 0
  8623. var nursing_claa_sunmfee float64 = 0
  8624. var nursing_clab_amt float64 = 0
  8625. var nursing_other_amt float64 = 0
  8626. var chinese_medicine_claa_sunmfee float64 = 0
  8627. var chinese_medicine_clab_amt float64 = 0
  8628. var chinese_medicine_other_amt float64 = 0
  8629. var commonly_treatment_claa_sunmfee float64 = 0
  8630. var commonly_treatment_clab_amt float64 = 0
  8631. var commonly_treatment_other_amt float64 = 0
  8632. var operation_claa_sunmfee float64 = 0
  8633. var operation_clab_amt float64 = 0
  8634. var operation_other_amt float64 = 0
  8635. var other_claa_sunmfee float64 = 0
  8636. var other_clab_amt float64 = 0
  8637. var other_other_amt float64 = 0
  8638. var westernMedicine_claa_sunmfee float64 = 0
  8639. var westernMedicine_clab_amt float64 = 0
  8640. var westernMedicine_other_amt float64 = 0
  8641. var chineseTraditional_claa_sunmfee float64 = 0
  8642. var chineseTraditional_clab_amt float64 = 0
  8643. var chineseTraditional_other_amt float64 = 0
  8644. var check_claa_sunmfee float64 = 0
  8645. var check_clab_amt float64 = 0
  8646. var check_other_amt float64 = 0
  8647. var material_claa_sunmfee float64 = 0
  8648. var material_clab_amt float64 = 0
  8649. var material_other_amt float64 = 0
  8650. var laboratory_claa_sunmfee float64 = 0
  8651. var laboratory_clab_amt float64 = 0
  8652. var laboratory_other_amt float64 = 0
  8653. var treat_claa_sunmfee float64 = 0
  8654. var treat_clab_amt float64 = 0
  8655. var treat_other_amt float64 = 0
  8656. var register_claa_sunmfee float64 = 0
  8657. var register_clab_amt float64 = 0
  8658. var register_other_amt float64 = 0
  8659. for _, item := range order.HisOrderInfo {
  8660. if item.MedChrgitmType == "01" { //床位费
  8661. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8662. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8663. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8664. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8665. if item.ChrgitmLv == "1" {
  8666. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8667. }
  8668. if item.ChrgitmLv == "2" {
  8669. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8670. }
  8671. if item.ChrgitmLv == "3" {
  8672. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8673. }
  8674. }
  8675. if item.MedChrgitmType == "02" { //诊查
  8676. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8677. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8678. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8679. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8680. if item.ChrgitmLv == "1" {
  8681. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8682. }
  8683. if item.ChrgitmLv == "2" {
  8684. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8685. }
  8686. if item.ChrgitmLv == "3" {
  8687. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8688. }
  8689. }
  8690. if item.MedChrgitmType == "03" { //检查费
  8691. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8692. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8693. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8694. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8695. if item.ChrgitmLv == "1" {
  8696. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8697. }
  8698. if item.ChrgitmLv == "2" {
  8699. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8700. }
  8701. if item.ChrgitmLv == "3" {
  8702. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8703. }
  8704. }
  8705. if item.MedChrgitmType == "04" { //化验费
  8706. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8707. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8708. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8709. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8710. if item.ChrgitmLv == "1" {
  8711. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8712. }
  8713. if item.ChrgitmLv == "2" {
  8714. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8715. }
  8716. if item.ChrgitmLv == "3" {
  8717. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8718. }
  8719. }
  8720. if item.MedChrgitmType == "05" { //治疗费
  8721. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8722. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8723. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8724. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8725. if item.ChrgitmLv == "1" {
  8726. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8727. }
  8728. if item.ChrgitmLv == "2" {
  8729. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8730. }
  8731. if item.ChrgitmLv == "3" {
  8732. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8733. }
  8734. }
  8735. if item.MedChrgitmType == "06" { //手术费
  8736. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8737. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8738. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8739. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8740. if item.ChrgitmLv == "1" {
  8741. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8742. }
  8743. if item.ChrgitmLv == "2" {
  8744. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8745. }
  8746. if item.ChrgitmLv == "3" {
  8747. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8748. }
  8749. }
  8750. if item.MedChrgitmType == "07" { //手术费
  8751. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8752. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8753. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8754. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8755. if item.ChrgitmLv == "1" {
  8756. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8757. }
  8758. if item.ChrgitmLv == "2" {
  8759. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8760. }
  8761. if item.ChrgitmLv == "3" {
  8762. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8763. }
  8764. }
  8765. if item.MedChrgitmType == "08" { //材料费
  8766. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8767. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8768. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8769. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8770. if item.ChrgitmLv == "1" {
  8771. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8772. }
  8773. if item.ChrgitmLv == "2" {
  8774. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8775. }
  8776. if item.ChrgitmLv == "3" {
  8777. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8778. }
  8779. }
  8780. if item.MedChrgitmType == "09" { //西药费
  8781. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8782. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8783. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8784. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8785. if item.ChrgitmLv == "1" {
  8786. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8787. }
  8788. if item.ChrgitmLv == "2" {
  8789. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8790. }
  8791. if item.ChrgitmLv == "3" {
  8792. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8793. }
  8794. }
  8795. if item.MedChrgitmType == "10" { //中药饮片
  8796. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8797. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8798. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8799. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8800. if item.ChrgitmLv == "1" {
  8801. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8802. }
  8803. if item.ChrgitmLv == "2" {
  8804. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8805. }
  8806. if item.ChrgitmLv == "3" {
  8807. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8808. }
  8809. }
  8810. if item.MedChrgitmType == "11" { //中成费
  8811. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8812. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8813. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8814. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8815. if item.ChrgitmLv == "1" {
  8816. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8817. }
  8818. if item.ChrgitmLv == "2" {
  8819. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8820. }
  8821. if item.ChrgitmLv == "3" {
  8822. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8823. }
  8824. }
  8825. if item.MedChrgitmType == "12" { //中成费
  8826. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8827. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8828. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8829. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8830. if item.ChrgitmLv == "1" {
  8831. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8832. }
  8833. if item.ChrgitmLv == "2" {
  8834. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8835. }
  8836. if item.ChrgitmLv == "3" {
  8837. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8838. }
  8839. }
  8840. if item.MedChrgitmType == "13" { //中成费
  8841. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8842. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8843. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8844. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8845. if item.ChrgitmLv == "1" {
  8846. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8847. }
  8848. if item.ChrgitmLv == "2" {
  8849. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8850. }
  8851. if item.ChrgitmLv == "3" {
  8852. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8853. }
  8854. }
  8855. if item.MedChrgitmType == "14" { //其他费
  8856. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8857. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8858. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8859. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  8860. if item.ChrgitmLv == "1" {
  8861. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8862. }
  8863. if item.ChrgitmLv == "2" {
  8864. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8865. }
  8866. if item.ChrgitmLv == "3" {
  8867. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8868. }
  8869. }
  8870. }
  8871. var iteminfoStructs []service.IteminfoStruct
  8872. if bedCostTotal != 0 {
  8873. iteminfo.MedChrgitm = "01"
  8874. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  8875. iteminfo.Amt = bedCostTotal
  8876. iteminfo.ClaaSumfee = bed_claa_sunmfee
  8877. iteminfo.ClabAmt = bed_clab_amt
  8878. iteminfo.OthAmt = bed_other_amt
  8879. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8880. }
  8881. if examineCostTotal != 0 {
  8882. iteminfo.MedChrgitm = "02"
  8883. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  8884. iteminfo.Amt = examineCostTotal
  8885. iteminfo.ClaaSumfee = examine_claa_sunmfee
  8886. iteminfo.ClabAmt = examine_clab_amt
  8887. iteminfo.OthAmt = examine_other_amt
  8888. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8889. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8890. }
  8891. if checkCostTotal != 0 {
  8892. iteminfo.MedChrgitm = "03"
  8893. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  8894. iteminfo.Amt = checkCostTotal
  8895. iteminfo.ClaaSumfee = check_claa_sunmfee
  8896. iteminfo.ClabAmt = check_clab_amt
  8897. iteminfo.OthAmt = check_other_amt
  8898. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8899. }
  8900. if laboratoryCostTotal != 0 {
  8901. iteminfo.MedChrgitm = "04"
  8902. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  8903. iteminfo.Amt = laboratoryCostTotal
  8904. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  8905. iteminfo.ClabAmt = laboratory_clab_amt
  8906. iteminfo.OthAmt = laboratory_other_amt
  8907. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8908. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8909. }
  8910. if treatCostTotal != 0 {
  8911. iteminfo.MedChrgitm = "05"
  8912. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  8913. iteminfo.Amt = treatCostTotal
  8914. iteminfo.ClaaSumfee = treat_claa_sunmfee
  8915. iteminfo.ClabAmt = treat_clab_amt
  8916. iteminfo.OthAmt = treat_other_amt
  8917. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8918. //(struct4101.IteminfoStruct, iteminfo)
  8919. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8920. }
  8921. if operationCostTotal != 0 {
  8922. iteminfo.MedChrgitm = "06"
  8923. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  8924. iteminfo.Amt = operationCostTotal
  8925. iteminfo.ClaaSumfee = operation_claa_sunmfee
  8926. iteminfo.ClabAmt = operation_clab_amt
  8927. iteminfo.OthAmt = operation_other_amt
  8928. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8929. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8930. }
  8931. if nursingCostTotal != 0 {
  8932. iteminfo.MedChrgitm = "07"
  8933. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  8934. iteminfo.Amt = nursingCostTotal
  8935. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  8936. iteminfo.ClabAmt = nursing_clab_amt
  8937. iteminfo.OthAmt = nursing_other_amt
  8938. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8939. }
  8940. if materialCostTotal != 0 {
  8941. iteminfo.MedChrgitm = "08"
  8942. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  8943. iteminfo.Amt = materialCostTotal
  8944. iteminfo.ClaaSumfee = material_claa_sunmfee
  8945. iteminfo.ClabAmt = material_clab_amt
  8946. iteminfo.OthAmt = material_other_amt
  8947. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8948. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8949. }
  8950. if westernMedicineCostTotal != 0 {
  8951. iteminfo.MedChrgitm = "09"
  8952. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  8953. iteminfo.Amt = westernMedicineCostTotal
  8954. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  8955. iteminfo.ClabAmt = westernMedicine_clab_amt
  8956. iteminfo.OthAmt = westernMedicine_other_amt
  8957. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8958. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8959. }
  8960. if chineseMedicineCostTotal != 0 {
  8961. iteminfo.MedChrgitm = "10"
  8962. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  8963. iteminfo.Amt = chineseMedicineCostTotal
  8964. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  8965. iteminfo.ClabAmt = chinese_medicine_clab_amt
  8966. iteminfo.OthAmt = chinese_medicine_other_amt
  8967. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8968. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8969. }
  8970. if chineseTraditionalMedicineCostTotal != 0 {
  8971. iteminfo.MedChrgitm = "11"
  8972. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  8973. iteminfo.Amt = westernMedicineCostTotal
  8974. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  8975. iteminfo.ClabAmt = westernMedicine_clab_amt
  8976. iteminfo.OthAmt = westernMedicine_other_amt
  8977. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8978. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8979. }
  8980. if commonlyTreatmentCostTotal != 0 {
  8981. iteminfo.MedChrgitm = "12"
  8982. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  8983. iteminfo.Amt = commonlyTreatmentCostTotal
  8984. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  8985. iteminfo.ClabAmt = commonly_treatment_clab_amt
  8986. iteminfo.OthAmt = commonly_treatment_other_amt
  8987. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8988. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8989. }
  8990. if registerCostTotal != 0 {
  8991. iteminfo.MedChrgitm = "13"
  8992. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  8993. iteminfo.Amt = registerCostTotal
  8994. iteminfo.ClaaSumfee = register_claa_sunmfee
  8995. iteminfo.ClabAmt = register_clab_amt
  8996. iteminfo.OthAmt = register_other_amt
  8997. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  8998. iteminfoStructs = append(iteminfoStructs, iteminfo)
  8999. }
  9000. if otherCostTotal != 0 {
  9001. iteminfo.MedChrgitm = "14"
  9002. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  9003. iteminfo.Amt = otherCostTotal
  9004. iteminfo.ClaaSumfee = other_claa_sunmfee
  9005. iteminfo.ClabAmt = other_clab_amt
  9006. iteminfo.OthAmt = other_other_amt
  9007. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  9008. iteminfoStructs = append(iteminfoStructs, iteminfo)
  9009. }
  9010. struct4101.IteminfoStruct = iteminfoStructs
  9011. time_arr := strings.Split(order.SetlTime, " ")
  9012. struct4101.AdmTime = time_arr[0]
  9013. struct4101.AdmEndTime = time_arr[0]
  9014. struct4101.DoctorName = doctor.UserName
  9015. struct4101.DoctorCode = doctor.DoctorNumber
  9016. struct4101.Ntly = "中国"
  9017. struct4101.AdmCaty = "A03.06"
  9018. var res ResultSeventeen
  9019. if miConfig.MdtrtareaAdmvs == "421300" {
  9020. data := make(map[string]interface{})
  9021. data["struct4101"] = struct4101
  9022. data["secret_key"] = miConfig.SecretKey
  9023. data["org_name"] = miConfig.OrgName
  9024. data["opera"] = curRoles.UserName
  9025. data["code"] = miConfig.Code
  9026. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  9027. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9028. client := &http.Client{}
  9029. bytesData, _ := json.Marshal(data)
  9030. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  9031. resp, _ := client.Do(req)
  9032. defer resp.Body.Close()
  9033. body, ioErr := ioutil.ReadAll(resp.Body)
  9034. if ioErr != nil {
  9035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9037. return
  9038. }
  9039. var respJSON map[string]interface{}
  9040. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9043. return
  9044. }
  9045. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9046. userJSONBytes, _ := json.Marshal(respJSON)
  9047. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9048. utils.ErrorLog("解析失败:%v", err)
  9049. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9050. adminUser := c.GetAdminUserInfo()
  9051. errlog := &models.HisOrderError{
  9052. UserOrgId: adminUser.CurrentOrgId,
  9053. Ctime: time.Now().Unix(),
  9054. Mtime: time.Now().Unix(),
  9055. ErrMsg: res.ErrMsg + "解析失败",
  9056. Status: 1,
  9057. PatientId: order_id,
  9058. Stage: 10088,
  9059. }
  9060. service.CreateErrMsgLog(errlog)
  9061. continue
  9062. }
  9063. } else {
  9064. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  9065. fmt.Println(result)
  9066. var dat map[string]interface{}
  9067. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9068. fmt.Println(dat)
  9069. } else {
  9070. fmt.Println(err)
  9071. }
  9072. userJSONBytes, _ := json.Marshal(dat)
  9073. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9074. utils.ErrorLog("解析失败:%v", err)
  9075. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9076. adminUser := c.GetAdminUserInfo()
  9077. errlog := &models.HisOrderError{
  9078. UserOrgId: adminUser.CurrentOrgId,
  9079. Ctime: time.Now().Unix(),
  9080. Mtime: time.Now().Unix(),
  9081. ErrMsg: res.ErrMsg + "解析失败",
  9082. Status: 1,
  9083. PatientId: order_id,
  9084. Stage: 10106,
  9085. }
  9086. service.CreateErrMsgLog(errlog)
  9087. continue
  9088. }
  9089. }
  9090. if res.Infcode != 0 {
  9091. adminUser := c.GetAdminUserInfo()
  9092. errlog := &models.HisOrderError{
  9093. UserOrgId: adminUser.CurrentOrgId,
  9094. Ctime: time.Now().Unix(),
  9095. Mtime: time.Now().Unix(),
  9096. ErrMsg: res.ErrMsg,
  9097. Status: 1,
  9098. PatientId: order_id,
  9099. Stage: 10106,
  9100. }
  9101. service.CreateErrMsgLog(errlog)
  9102. continue
  9103. } else {
  9104. hisFundSettleListResult := &models.HisFundSettleListResult{
  9105. Number: res.Output.SetlListId,
  9106. Status: 1,
  9107. Ctime: time.Now().Unix(),
  9108. Mtime: time.Now().Unix(),
  9109. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9110. IsUpload: 1,
  9111. OrderId: order_id,
  9112. }
  9113. service.CreateUploadRecord(hisFundSettleListResult)
  9114. continue
  9115. }
  9116. }
  9117. }
  9118. func (c *HisApiController) GetOrgInfo() {
  9119. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  9120. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  9121. }
  9122. func (c *HisApiController) GetHisPatientInfo() {
  9123. medical_insurance_card := c.GetString("medical_insurance_card")
  9124. id_card_type, _ := c.GetInt64("id_card_type")
  9125. id_card := c.GetString("id_card")
  9126. adminInfo := c.GetAdminUserInfo()
  9127. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9128. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9129. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  9130. IdCardNo := ""
  9131. if id_card_type == 1 {
  9132. IdCardNo = medical_insurance_card
  9133. } else if id_card_type == 2 {
  9134. IdCardNo = id_card
  9135. }
  9136. if config.IsOpen == 1 {
  9137. 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
  9138. resp, requestErr := http.Get(api)
  9139. if requestErr != nil {
  9140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9141. return
  9142. }
  9143. defer resp.Body.Close()
  9144. body, ioErr := ioutil.ReadAll(resp.Body)
  9145. if ioErr != nil {
  9146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9148. return
  9149. }
  9150. var respJSON map[string]interface{}
  9151. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9154. return
  9155. }
  9156. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9157. userJSONBytes, _ := json.Marshal(userJSON)
  9158. var res ResultTwo
  9159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9160. utils.ErrorLog("解析失败:%v", err)
  9161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9162. return
  9163. }
  9164. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9165. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9166. infoStr := string(Iinfos)
  9167. idetinfoStr := string(Idetinfos)
  9168. if res.Infcode == 0 {
  9169. his := models.VMHisPatient{
  9170. Status: 1,
  9171. Ctime: time.Now().Unix(),
  9172. Mtime: time.Now().Unix(),
  9173. PsnNo: res.Output.Baseinfo.PsnNo,
  9174. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9175. Certno: res.Output.Baseinfo.Certno,
  9176. PsnName: res.Output.Baseinfo.PsnName,
  9177. Gend: res.Output.Baseinfo.Gend,
  9178. Naty: res.Output.Baseinfo.Naty,
  9179. Brdy: res.Output.Baseinfo.Brdy,
  9180. Age: res.Output.Baseinfo.Age,
  9181. Iinfo: infoStr,
  9182. Idetinfo: idetinfoStr,
  9183. UserOrgId: adminInfo.CurrentOrgId,
  9184. IsReturn: 1,
  9185. IdCardType: id_card_type,
  9186. }
  9187. c.ServeSuccessJSON(map[string]interface{}{
  9188. "info": his,
  9189. })
  9190. } else {
  9191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9192. return
  9193. }
  9194. }
  9195. }
  9196. //func GetBasBaseInfo() (jsonStr string, err error) {
  9197. //
  9198. // handle := syscall.NewLazyDLL("SSCard.dll")
  9199. // add := handle.NewProc("ReadCardBas")
  9200. // str := make([]byte, 1024)
  9201. // str1 := make([]byte, 1024)
  9202. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  9203. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  9204. //
  9205. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  9206. //
  9207. // fmt.Println("> Add(4,5)的结果为:", ret)
  9208. // handle.Release()
  9209. //
  9210. // return "", nil
  9211. //
  9212. //}
  9213. //func GetQRBaseInfo() (jsonStr string, err error) {
  9214. // handle := syscall.LoadDLL("SSCard.dll")
  9215. // ReadCardBas := handle.FindProc("GetQRBase")
  9216. //
  9217. // str := make([]byte, 256)
  9218. // str1 := make([]byte, 256)
  9219. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  9220. //
  9221. // fmt.Println(string(str))
  9222. // fmt.Println(r)
  9223. // return string(str), nil
  9224. //}
  9225. //func CardInit() int {
  9226. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  9227. // add := DllTestDef.MustFindProc("Init")
  9228. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  9229. // if err != nil {
  9230. // fmt.Println("SSCard的运算结果为:", ret)
  9231. // }
  9232. // result := int(ret)
  9233. // return result
  9234. //}
  9235. //func CardInit() int {
  9236. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  9237. // if err != nil {
  9238. // fmt.Println("SSCard的运算结果为:", ret)
  9239. // }
  9240. // fmt.Println(err)
  9241. // result := int(ret)
  9242. // return result
  9243. //}
  9244. func IntPtr(n int) uintptr {
  9245. return uintptr(n)
  9246. }
  9247. func StrPtr(s string) uintptr {
  9248. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  9249. }
  9250. type Result2001 struct {
  9251. Cainfo interface{} `json:"cainfo"`
  9252. ErrMsg string `json:"err_msg"`
  9253. InfRefmsgid string `json:"inf_refmsgid"`
  9254. Infcode int64 `json:"infcode"`
  9255. Output struct {
  9256. Trtinfo struct {
  9257. PsnNo string `json:"psn_no"`
  9258. TrtChkType string `json:"trt_chk_type"`
  9259. FundPayType string `json:"fund_pay_type"`
  9260. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  9261. Begndate string `json:"begndate"`
  9262. Enddate string `json:"enddate"`
  9263. TrtChkRslt string `json:"trt_chk_rslt"`
  9264. } `json:"trtinfo"`
  9265. } `json:"output"`
  9266. RefmsgTime string `json:"refmsg_time"`
  9267. RespondTime string `json:"respond_time"`
  9268. Signtype interface{} `json:"signtype"`
  9269. WarnMsg interface{} `json:"warn_msg"`
  9270. }
  9271. type Result2001Org10265 struct {
  9272. Cainfo interface{} `json:"cainfo"`
  9273. ErrMsg string `json:"err_msg"`
  9274. InfRefmsgid string `json:"inf_refmsgid"`
  9275. Infcode string `json:"infcode"`
  9276. Output struct {
  9277. Trtinfo struct {
  9278. PsnNo string `json:"psn_no"`
  9279. TrtChkType string `json:"trt_chk_type"`
  9280. FundPayType string `json:"fund_pay_type"`
  9281. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  9282. Begndate string `json:"begndate"`
  9283. Enddate string `json:"enddate"`
  9284. TrtChkRslt string `json:"trt_chk_rslt"`
  9285. } `json:"trtinfo"`
  9286. } `json:"output"`
  9287. RefmsgTime string `json:"refmsg_time"`
  9288. RespondTime string `json:"respond_time"`
  9289. Signtype interface{} `json:"signtype"`
  9290. WarnMsg interface{} `json:"warn_msg"`
  9291. }
  9292. type ResultTwo struct {
  9293. ErrMsg string `json:"err_msg"`
  9294. InfRefmsgid string `json:"inf_refmsgid"`
  9295. Infcode int64 `json:"infcode"`
  9296. Output struct {
  9297. Baseinfo struct {
  9298. Age float64 `json:"age"`
  9299. Brdy string `json:"brdy"`
  9300. Certno string `json:"certno"`
  9301. Gend string `json:"gend"`
  9302. Naty string `json:"naty"`
  9303. PsnCertType string `json:"psn_cert_type"`
  9304. PsnName string `json:"psn_name"`
  9305. PsnNo string `json:"psn_no"`
  9306. } `json:"baseinfo"`
  9307. Idetinfo []interface{} `json:"idetinfo"`
  9308. Iinfo []struct {
  9309. Balc float64 `json:"balc"`
  9310. CvlservFlag string `json:"cvlserv_flag"`
  9311. EmpName string `json:"emp_name"`
  9312. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  9313. Insutype string `json:"insutype"`
  9314. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  9315. PausInsuDate string `json:"paus_insu_date"`
  9316. PsnInsuDate string `json:"psn_insu_date"`
  9317. PsnInsuStas string `json:"psn_insu_stas"`
  9318. PsnType string `json:"psn_type"`
  9319. } `json:"insuinfo"`
  9320. } `json:"output"`
  9321. RefmsgTime string `json:"refmsg_time"`
  9322. RespondTime string `json:"respond_time"`
  9323. Signtype interface{} `json:"signtype"`
  9324. WarnInfo interface{} `json:"warn_info"`
  9325. }
  9326. type ResultTwo10265 struct {
  9327. ErrMsg string `json:"err_msg"`
  9328. InfRefmsgid string `json:"inf_refmsgid"`
  9329. Infcode string `json:"infcode"`
  9330. Output struct {
  9331. Baseinfo struct {
  9332. Age float64 `json:"age"`
  9333. Brdy string `json:"brdy"`
  9334. Certno string `json:"certno"`
  9335. Gend string `json:"gend"`
  9336. Naty string `json:"naty"`
  9337. PsnCertType string `json:"psn_cert_type"`
  9338. PsnName string `json:"psn_name"`
  9339. PsnNo string `json:"psn_no"`
  9340. } `json:"baseinfo"`
  9341. Idetinfo []interface{} `json:"idetinfo"`
  9342. Iinfo []struct {
  9343. Balc float64 `json:"balc"`
  9344. CvlservFlag string `json:"cvlserv_flag"`
  9345. EmpName string `json:"emp_name"`
  9346. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  9347. Insutype string `json:"insutype"`
  9348. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  9349. PausInsuDate string `json:"paus_insu_date"`
  9350. PsnInsuDate string `json:"psn_insu_date"`
  9351. PsnInsuStas string `json:"psn_insu_stas"`
  9352. PsnType string `json:"psn_type"`
  9353. } `json:"insuinfo"`
  9354. } `json:"output"`
  9355. RefmsgTime string `json:"refmsg_time"`
  9356. RespondTime string `json:"respond_time"`
  9357. Signtype interface{} `json:"signtype"`
  9358. WarnInfo interface{} `json:"warn_info"`
  9359. }
  9360. type ResultThree struct {
  9361. Cainfo interface{} `json:"cainfo"`
  9362. ErrMsg string `json:"err_msg"`
  9363. InfRefmsgid string `json:"inf_refmsgid"`
  9364. Infcode int64 `json:"infcode"`
  9365. Output struct {
  9366. Data struct {
  9367. IptOtpNo string `json:"ipt_otp_no"`
  9368. MdtrtID string `json:"mdtrt_id"`
  9369. PsnNo string `json:"psn_no"`
  9370. } `json:"data"`
  9371. } `json:"output"`
  9372. RefmsgTime string `json:"refmsg_time"`
  9373. RespondTime string `json:"respond_time"`
  9374. Signtype interface{} `json:"signtype"`
  9375. WarnMsg interface{} `json:"warn_msg"`
  9376. }
  9377. type ResultThree10265 struct {
  9378. Cainfo interface{} `json:"cainfo"`
  9379. ErrMsg string `json:"err_msg"`
  9380. InfRefmsgid string `json:"inf_refmsgid"`
  9381. Infcode string `json:"infcode"`
  9382. Output struct {
  9383. Data struct {
  9384. IptOtpNo string `json:"ipt_otp_no"`
  9385. MdtrtID string `json:"mdtrt_id"`
  9386. PsnNo string `json:"psn_no"`
  9387. } `json:"data"`
  9388. } `json:"output"`
  9389. RefmsgTime string `json:"refmsg_time"`
  9390. RespondTime string `json:"respond_time"`
  9391. Signtype interface{} `json:"signtype"`
  9392. WarnMsg interface{} `json:"warn_msg"`
  9393. }
  9394. type ResultFour struct {
  9395. Cainfo string `json:"cainfo"`
  9396. ErrMsg string `json:"err_msg"`
  9397. InfRefmsgid string `json:"inf_refmsgid"`
  9398. Infcode int64 `json:"infcode"`
  9399. Output struct {
  9400. Result []struct {
  9401. BasMednFlag string `json:"bas_medn_flag"`
  9402. ChldMedcFlag string `json:"chld_medc_flag"`
  9403. ChrgitmLv string `json:"chrgitm_lv"`
  9404. Cnt float64 `json:"cnt"`
  9405. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  9406. DrtReimFlag string `json:"drt_reim_flag"`
  9407. FeedetlSn string `json:"feedetl_sn"`
  9408. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9409. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  9410. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9411. ListSpItemFlag string `json:"list_sp_item_flag"`
  9412. LmtUsedFlag string `json:"lmt_used_flag"`
  9413. MedChrgitmType string `json:"med_chrgitm_type"`
  9414. Memo string `json:"memo"`
  9415. OverlmtAmt float64 `json:"overlmt_amt"`
  9416. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9417. Pric float64 `json:"pric"`
  9418. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  9419. SelfpayProp float64 `json:"selfpay_prop"`
  9420. } `json:"result"`
  9421. } `json:"output"`
  9422. RefmsgTime string `json:"refmsg_time"`
  9423. RespondTime string `json:"respond_time"`
  9424. Signtype string `json:"signtype"`
  9425. WarnMsg string `json:"warn_msg"`
  9426. }
  9427. type ResultFour10265 struct {
  9428. Cainfo string `json:"cainfo"`
  9429. ErrMsg string `json:"err_msg"`
  9430. InfRefmsgid string `json:"inf_refmsgid"`
  9431. Infcode string `json:"infcode"`
  9432. Output struct {
  9433. Result []struct {
  9434. BasMednFlag string `json:"bas_medn_flag"`
  9435. ChldMedcFlag string `json:"chld_medc_flag"`
  9436. ChrgitmLv string `json:"chrgitm_lv"`
  9437. Cnt float64 `json:"cnt"`
  9438. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  9439. DrtReimFlag string `json:"drt_reim_flag"`
  9440. FeedetlSn string `json:"feedetl_sn"`
  9441. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9442. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  9443. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9444. ListSpItemFlag string `json:"list_sp_item_flag"`
  9445. LmtUsedFlag string `json:"lmt_used_flag"`
  9446. MedChrgitmType string `json:"med_chrgitm_type"`
  9447. Memo string `json:"memo"`
  9448. OverlmtAmt float64 `json:"overlmt_amt"`
  9449. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9450. Pric float64 `json:"pric"`
  9451. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  9452. SelfpayProp float64 `json:"selfpay_prop"`
  9453. } `json:"result"`
  9454. } `json:"output"`
  9455. RefmsgTime string `json:"refmsg_time"`
  9456. RespondTime string `json:"respond_time"`
  9457. Signtype string `json:"signtype"`
  9458. WarnMsg string `json:"warn_msg"`
  9459. }
  9460. type ResultMemo struct {
  9461. InsuAdmdvs string `json:"insuAdmdvs"`
  9462. }
  9463. // [{"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}]
  9464. type ResultIDInfo struct {
  9465. Begntime string `json:"begntime"`
  9466. Endtime string `json:"endtime"`
  9467. Memo string `json:"memo"`
  9468. }
  9469. type ResultFive struct {
  9470. Balc float64 `json:"balc"`
  9471. CvlservFlag string `json:"cvlserv_flag"`
  9472. EmpName string `json:"emp_name"`
  9473. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  9474. Insutype string `json:"insutype"`
  9475. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  9476. PausInsuDate string `json:"paus_insu_date"`
  9477. PsnInsuDate string `json:"psn_insu_date"`
  9478. PsnInsuStas string `json:"psn_insu_stas"`
  9479. PsnType string `json:"psn_type"`
  9480. }
  9481. type ResultSix struct {
  9482. Cainfo interface{} `json:"cainfo"`
  9483. ErrMsg string `json:"err_msg"`
  9484. InfRefmsgid string `json:"inf_refmsgid"`
  9485. Infcode int64 `json:"infcode"`
  9486. Output struct {
  9487. } `json:"output"`
  9488. RefmsgTime string `json:"refmsg_time"`
  9489. RespondTime string `json:"respond_time"`
  9490. Signtype interface{} `json:"signtype"`
  9491. WarnMsg interface{} `json:"warn_msg"`
  9492. }
  9493. type ResultSix10265 struct {
  9494. Cainfo interface{} `json:"cainfo"`
  9495. ErrMsg string `json:"err_msg"`
  9496. InfRefmsgid string `json:"inf_refmsgid"`
  9497. Infcode string `json:"infcode"`
  9498. Output struct {
  9499. } `json:"output"`
  9500. RefmsgTime string `json:"refmsg_time"`
  9501. RespondTime string `json:"respond_time"`
  9502. Signtype interface{} `json:"signtype"`
  9503. WarnMsg interface{} `json:"warn_msg"`
  9504. }
  9505. type ResultSeven struct {
  9506. Cainfo string `json:"cainfo"`
  9507. ErrMsg string `json:"err_msg"`
  9508. InfRefmsgid string `json:"inf_refmsgid"`
  9509. Infcode int64 `json:"infcode"`
  9510. Output struct {
  9511. Setldetail []interface{} `json:"setldetail"`
  9512. Setlinfo struct {
  9513. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  9514. AcctPay float64 `json:"acct_pay"`
  9515. ActPayDedc float64 `json:"act_pay_dedc"`
  9516. Age float64 `json:"age"`
  9517. Balc float64 `json:"balc"`
  9518. Brdy string `json:"brdy"`
  9519. Certno string `json:"certno"`
  9520. ClrOptins string `json:"clr_optins"`
  9521. ClrType string `json:"clr_type"`
  9522. ClrWay string `json:"clr_way"`
  9523. CvlservFlag string `json:"cvlserv_flag"`
  9524. CvlservPay float64 `json:"cvlserv_pay"`
  9525. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9526. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9527. Gend string `json:"gend"`
  9528. HifesPay float64 `json:"hifes_pay"`
  9529. HifmiPay float64 `json:"hifmi_pay"`
  9530. HifpPay float64 `json:"hifp_pay"`
  9531. HospPartAmt float64 `json:"hosp_part_amt"`
  9532. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9533. Insutype string `json:"insutype"`
  9534. MafPay float64 `json:"maf_pay"`
  9535. MdtrtCertType string `json:"mdtrt_cert_type"`
  9536. HifobPay float64 `json:"hifob_pay"`
  9537. MdtrtID string `json:"mdtrt_id"`
  9538. MedType string `json:"med_type"`
  9539. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9540. MedinsSetlID string `json:"medins_setl_id"`
  9541. Naty string `json:"naty"`
  9542. OthPay float64 `json:"oth_pay"`
  9543. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9544. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9545. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9546. PsnCashPay float64 `json:"psn_cash_pay"`
  9547. PsnCertType string `json:"psn_cert_type"`
  9548. PsnName string `json:"psn_name"`
  9549. PsnNo string `json:"psn_no"`
  9550. PsnPartAmt float64 `json:"psn_part_amt"`
  9551. PsnType string `json:"psn_type"`
  9552. SetlID string `json:"setl_id"`
  9553. SetlTime string `json:"setl_time"`
  9554. } `json:"setlinfo"`
  9555. } `json:"output"`
  9556. RefmsgTime string `json:"refmsg_time"`
  9557. RespondTime string `json:"respond_time"`
  9558. Signtype interface{} `json:"signtype"`
  9559. WarnMsg interface{} `json:"warn_msg"`
  9560. }
  9561. type ResultSeven10265 struct {
  9562. Cainfo string `json:"cainfo"`
  9563. ErrMsg string `json:"err_msg"`
  9564. InfRefmsgid string `json:"inf_refmsgid"`
  9565. Infcode string `json:"infcode"`
  9566. Output struct {
  9567. Setldetail []interface{} `json:"setldetail"`
  9568. Setlinfo struct {
  9569. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  9570. AcctPay float64 `json:"acct_pay"`
  9571. ActPayDedc float64 `json:"act_pay_dedc"`
  9572. Age float64 `json:"age"`
  9573. Balc float64 `json:"balc"`
  9574. Brdy string `json:"brdy"`
  9575. Certno string `json:"certno"`
  9576. ClrOptins string `json:"clr_optins"`
  9577. ClrType string `json:"clr_type"`
  9578. ClrWay string `json:"clr_way"`
  9579. CvlservFlag string `json:"cvlserv_flag"`
  9580. CvlservPay float64 `json:"cvlserv_pay"`
  9581. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9582. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9583. Gend string `json:"gend"`
  9584. HifesPay float64 `json:"hifes_pay"`
  9585. HifmiPay float64 `json:"hifmi_pay"`
  9586. HifpPay float64 `json:"hifp_pay"`
  9587. HospPartAmt float64 `json:"hosp_part_amt"`
  9588. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9589. Insutype string `json:"insutype"`
  9590. MafPay float64 `json:"maf_pay"`
  9591. MdtrtCertType string `json:"mdtrt_cert_type"`
  9592. HifobPay float64 `json:"hifob_pay"`
  9593. MdtrtID string `json:"mdtrt_id"`
  9594. MedType string `json:"med_type"`
  9595. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9596. MedinsSetlID string `json:"medins_setl_id"`
  9597. Naty string `json:"naty"`
  9598. OthPay float64 `json:"oth_pay"`
  9599. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9600. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9601. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9602. PsnCashPay float64 `json:"psn_cash_pay"`
  9603. PsnCertType string `json:"psn_cert_type"`
  9604. PsnName string `json:"psn_name"`
  9605. PsnNo string `json:"psn_no"`
  9606. PsnPartAmt float64 `json:"psn_part_amt"`
  9607. PsnType string `json:"psn_type"`
  9608. SetlID string `json:"setl_id"`
  9609. SetlTime string `json:"setl_time"`
  9610. } `json:"setlinfo"`
  9611. } `json:"output"`
  9612. RefmsgTime string `json:"refmsg_time"`
  9613. RespondTime string `json:"respond_time"`
  9614. Signtype interface{} `json:"signtype"`
  9615. WarnMsg interface{} `json:"warn_msg"`
  9616. }
  9617. type ResultSeven10265Two struct {
  9618. Cainfo string `json:"cainfo"`
  9619. ErrMsg string `json:"err_msg"`
  9620. InfRefmsgid string `json:"inf_refmsgid"`
  9621. Infcode string `json:"infcode"`
  9622. Output struct {
  9623. Setldetail []interface{} `json:"setldetail"`
  9624. Setlinfo struct {
  9625. AcctMulaidPay string `json:"acct_mulaid_pay"`
  9626. AcctPay float64 `json:"acct_pay"`
  9627. ActPayDedc float64 `json:"act_pay_dedc"`
  9628. Age float64 `json:"age"`
  9629. Balc float64 `json:"balc"`
  9630. Brdy string `json:"brdy"`
  9631. Certno string `json:"certno"`
  9632. ClrOptins string `json:"clr_optins"`
  9633. ClrType string `json:"clr_type"`
  9634. ClrWay string `json:"clr_way"`
  9635. CvlservFlag string `json:"cvlserv_flag"`
  9636. CvlservPay float64 `json:"cvlserv_pay"`
  9637. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9638. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9639. Gend string `json:"gend"`
  9640. HifesPay float64 `json:"hifes_pay"`
  9641. HifmiPay float64 `json:"hifmi_pay"`
  9642. HifpPay float64 `json:"hifp_pay"`
  9643. HospPartAmt string `json:"hosp_part_amt"`
  9644. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9645. Insutype string `json:"insutype"`
  9646. MafPay float64 `json:"maf_pay"`
  9647. MdtrtCertType string `json:"mdtrt_cert_type"`
  9648. HifobPay float64 `json:"hifob_pay"`
  9649. MdtrtID string `json:"mdtrt_id"`
  9650. MedType string `json:"med_type"`
  9651. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9652. MedinsSetlID string `json:"medins_setl_id"`
  9653. Naty string `json:"naty"`
  9654. OthPay float64 `json:"oth_pay"`
  9655. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9656. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  9657. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9658. PsnCashPay float64 `json:"psn_cash_pay"`
  9659. PsnCertType string `json:"psn_cert_type"`
  9660. PsnName string `json:"psn_name"`
  9661. PsnNo string `json:"psn_no"`
  9662. PsnPartAmt float64 `json:"psn_part_amt"`
  9663. PsnType string `json:"psn_type"`
  9664. SetlID string `json:"setl_id"`
  9665. SetlTime string `json:"setl_time"`
  9666. } `json:"setlinfo"`
  9667. } `json:"output"`
  9668. RefmsgTime string `json:"refmsg_time"`
  9669. RespondTime string `json:"respond_time"`
  9670. Signtype interface{} `json:"signtype"`
  9671. WarnMsg interface{} `json:"warn_msg"`
  9672. }
  9673. type ResultEight struct {
  9674. Cainfo string `json:"cainfo"`
  9675. ErrMsg string `json:"err_msg"`
  9676. InfRefmsgid string `json:"inf_refmsgid"`
  9677. Infcode int64 `json:"infcode"`
  9678. Output struct {
  9679. Stmtinfo struct {
  9680. SetlOptins string `json:"setl_optins"`
  9681. StmtRslt string `json:"stmt_rslt"`
  9682. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  9683. } `json:"stmtinfo"`
  9684. } `json:"output"`
  9685. RefmsgTime string `json:"refmsg_time"`
  9686. RespondTime string `json:"respond_time"`
  9687. Signtype interface{} `json:"signtype"`
  9688. WarnMsg interface{} `json:"warn_msg"`
  9689. }
  9690. type ResultEightFor10188 struct {
  9691. Cainfo string `json:"cainfo"`
  9692. ErrMsg string `json:"err_msg"`
  9693. InfRefmsgid string `json:"inf_refmsgid"`
  9694. Infcode string `json:"infcode"`
  9695. Output struct {
  9696. Stmtinfo struct {
  9697. SetlOptins string `json:"setl_optins"`
  9698. StmtRslt string `json:"stmt_rslt"`
  9699. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  9700. } `json:"stmtinfo"`
  9701. } `json:"output"`
  9702. RefmsgTime string `json:"refmsg_time"`
  9703. RespondTime string `json:"respond_time"`
  9704. Signtype interface{} `json:"signtype"`
  9705. WarnMsg interface{} `json:"warn_msg"`
  9706. }
  9707. type ResultNine struct {
  9708. Cainfo string `json:"cainfo"`
  9709. ErrMsg string `json:"err_msg"`
  9710. InfRefmsgid string `json:"inf_refmsgid"`
  9711. Infcode int64 `json:"infcode"`
  9712. Output struct {
  9713. FileQuryNo string `json:"file_qury_no"`
  9714. } `json:"output"`
  9715. RefmsgTime string `json:"refmsg_time"`
  9716. RespondTime string `json:"respond_time"`
  9717. Signtype interface{} `json:"signtype"`
  9718. WarnMsg interface{} `json:"warn_msg"`
  9719. }
  9720. type ResultTen struct {
  9721. Cainfo string `json:"cainfo"`
  9722. ErrMsg string `json:"err_msg"`
  9723. InfRefmsgid string `json:"inf_refmsgid"`
  9724. Infcode int64 `json:"infcode"`
  9725. Output struct {
  9726. DldEndtime string `json:"dld_endtime"`
  9727. FileQuryNo string `json:"file_qury_no"`
  9728. Filename string `json:"filename"`
  9729. } `json:"output"`
  9730. RefmsgTime string `json:"refmsg_time"`
  9731. RespondTime string `json:"respond_time"`
  9732. Signtype interface{} `json:"signtype"`
  9733. WarnMsg interface{} `json:"warn_msg"`
  9734. }
  9735. //type Autogenerated struct {
  9736. // Output struct {
  9737. // Setlinfo struct {
  9738. // SetlTime string `json:"setl_time"`
  9739. // CvlservPay float64 `json:"cvlserv_pay"`
  9740. // Year string `json:"year"`
  9741. // MedType string `json:"med_type"`
  9742. // PsnPay float64 `json:"psn_pay"`
  9743. // OpterID string `json:"opter_id"`
  9744. // Begndate string `json:"begndate"`
  9745. // FlxempeFlag string `json:"flxempe_flag"`
  9746. // HifmiPay float64 `json:"hifmi_pay"`
  9747. // PsnNo string `json:"psn_no"`
  9748. // ActPayDedc float64 `json:"act_pay_dedc"`
  9749. // MedinsSetlID interface{} `json:"medins_setl_id"`
  9750. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  9751. // ClrWay string `json:"clr_way"`
  9752. // OthPay float64 `json:"oth_pay"`
  9753. // Gend string `json:"gend"`
  9754. // MdtrtID string `json:"mdtrt_id"`
  9755. // AcctPay float64 `json:"acct_pay"`
  9756. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  9757. // Insutype string `json:"insutype"`
  9758. // Invono interface{} `json:"invono"`
  9759. // Enddate string `json:"enddate"`
  9760. // CashPayamt float64 `json:"cash_payamt"`
  9761. // PsnType string `json:"psn_type"`
  9762. // FixmedinsName string `json:"fixmedins_name"`
  9763. // HifpPay float64 `json:"hifp_pay"`
  9764. // NewFlag interface{} `json:"new_flag"`
  9765. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9766. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  9767. // PayLoc string `json:"pay_loc"`
  9768. // ClrType string `json:"clr_type"`
  9769. // RefdSetlFlag string `json:"refd_setl_flag"`
  9770. // CvlservFlag string `json:"cvlserv_flag"`
  9771. // EmpName string `json:"emp_name"`
  9772. // Brdy string `json:"brdy"`
  9773. // Naty string `json:"naty"`
  9774. // Certno string `json:"certno"`
  9775. // DiseCode string `json:"dise_code"`
  9776. // FixmedinsCode string `json:"fixmedins_code"`
  9777. // DedcHospLv string `json:"dedc_hosp_lv"`
  9778. // OpterName string `json:"opter_name"`
  9779. // Balc float64 `json:"balc"`
  9780. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  9781. // PsnCertType string `json:"psn_cert_type"`
  9782. // HifobPay float64 `json:"hifob_pay"`
  9783. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  9784. // HifesPay float64 `json:"hifes_pay"`
  9785. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9786. // OptTime string `json:"opt_time"`
  9787. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9788. // SetlID string `json:"setl_id"`
  9789. // MafPay float64 `json:"maf_pay"`
  9790. // PsnName string `json:"psn_name"`
  9791. // InsuOptins interface{} `json:"insu_optins"`
  9792. // PrefFundPay interface{} `json:"pref_fund_pay"`
  9793. // ClrOptins string `json:"clr_optins"`
  9794. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9795. // DiseName string `json:"dise_name"`
  9796. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  9797. // Age float64 `json:"age"`
  9798. // DtrtCertType string `json:"dtrt_cert_type"`
  9799. // HospLv string `json:"hosp_lv"`
  9800. // } `json:"setlinfo"`
  9801. // Setldetail []struct {
  9802. // FundPayType string `json:"fund_pay_type"`
  9803. // FundPayamt float64 `json:"fund_payamt"`
  9804. // SetlProcInfo interface{} `json:"setl_proc_info"`
  9805. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  9806. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  9807. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  9808. // PrefFundPay interface{} `json:"pref_fund_pay"`
  9809. // } `json:"setldetail"`
  9810. // } `json:"output"`
  9811. // Infcode int `json:"infcode"`
  9812. // WarnMsg interface{} `json:"warn_msg"`
  9813. // Cainfo interface{} `json:"cainfo"`
  9814. // ErrMsg interface{} `json:"err_msg"`
  9815. // RefmsgTime string `json:"refmsg_time"`
  9816. // Signtype interface{} `json:"signtype"`
  9817. // RespondTime string `json:"respond_time"`
  9818. // InfRefmsgid string `json:"inf_refmsgid"`
  9819. //}
  9820. type ResultEleven struct {
  9821. Cainfo string `json:"cainfo"`
  9822. ErrMsg string `json:"err_msg"`
  9823. InfRefmsgid string `json:"inf_refmsgid"`
  9824. Infcode int64 `json:"infcode"`
  9825. Output struct {
  9826. Setlinfo struct {
  9827. SetlTime string `json:"setl_time"`
  9828. CvlservPay float64 `json:"cvlserv_pay"`
  9829. Year string `json:"year"`
  9830. MedType string `json:"med_type"`
  9831. PsnPay float64 `json:"psn_pay"`
  9832. OpterID string `json:"opter_id"`
  9833. Begndate string `json:"begndate"`
  9834. FlxempeFlag string `json:"flxempe_flag"`
  9835. HifmiPay float64 `json:"hifmi_pay"`
  9836. PsnNo string `json:"psn_no"`
  9837. ActPayDedc float64 `json:"act_pay_dedc"`
  9838. MedinsSetlID interface{} `json:"medins_setl_id"`
  9839. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  9840. ClrWay string `json:"clr_way"`
  9841. OthPay float64 `json:"oth_pay"`
  9842. Gend string `json:"gend"`
  9843. MdtrtID string `json:"mdtrt_id"`
  9844. AcctPay float64 `json:"acct_pay"`
  9845. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9846. Insutype string `json:"insutype"`
  9847. Invono interface{} `json:"invono"`
  9848. Enddate string `json:"enddate"`
  9849. CashPayamt float64 `json:"cash_payamt"`
  9850. PsnType string `json:"psn_type"`
  9851. FixmedinsName string `json:"fixmedins_name"`
  9852. HifpPay float64 `json:"hifp_pay"`
  9853. NewFlag interface{} `json:"new_flag"`
  9854. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9855. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9856. PayLoc string `json:"pay_loc"`
  9857. ClrType string `json:"clr_type"`
  9858. RefdSetlFlag string `json:"refd_setl_flag"`
  9859. CvlservFlag string `json:"cvlserv_flag"`
  9860. EmpName string `json:"emp_name"`
  9861. Brdy string `json:"brdy"`
  9862. Naty string `json:"naty"`
  9863. Certno string `json:"certno"`
  9864. DiseCode string `json:"dise_code"`
  9865. FixmedinsCode string `json:"fixmedins_code"`
  9866. DedcHospLv string `json:"dedc_hosp_lv"`
  9867. OpterName string `json:"opter_name"`
  9868. Balc float64 `json:"balc"`
  9869. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  9870. PsnCertType string `json:"psn_cert_type"`
  9871. HifobPay float64 `json:"hifob_pay"`
  9872. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9873. HifesPay float64 `json:"hifes_pay"`
  9874. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9875. OptTime string `json:"opt_time"`
  9876. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9877. SetlID string `json:"setl_id"`
  9878. MafPay float64 `json:"maf_pay"`
  9879. PsnName string `json:"psn_name"`
  9880. InsuOptins interface{} `json:"insu_optins"`
  9881. PrefFundPay interface{} `json:"pref_fund_pay"`
  9882. ClrOptins string `json:"clr_optins"`
  9883. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9884. DiseName string `json:"dise_name"`
  9885. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  9886. Age float64 `json:"age"`
  9887. DtrtCertType string `json:"dtrt_cert_type"`
  9888. HospLv string `json:"hosp_lv"`
  9889. PsnCashPay float64
  9890. } `json:"setlinfo"`
  9891. } `json:"output"`
  9892. RefmsgTime string `json:"refmsg_time"`
  9893. RespondTime string `json:"respond_time"`
  9894. Signtype interface{} `json:"signtype"`
  9895. WarnMsg interface{} `json:"warn_msg"`
  9896. }
  9897. type ResultEleven10265 struct {
  9898. Cainfo string `json:"cainfo"`
  9899. ErrMsg string `json:"err_msg"`
  9900. InfRefmsgid string `json:"inf_refmsgid"`
  9901. Infcode string `json:"infcode"`
  9902. Output struct {
  9903. Setlinfo struct {
  9904. SetlTime string `json:"setl_time"`
  9905. CvlservPay float64 `json:"cvlserv_pay"`
  9906. Year string `json:"year"`
  9907. MedType string `json:"med_type"`
  9908. PsnPay float64 `json:"psn_pay"`
  9909. OpterID string `json:"opter_id"`
  9910. Begndate string `json:"begndate"`
  9911. FlxempeFlag string `json:"flxempe_flag"`
  9912. HifmiPay float64 `json:"hifmi_pay"`
  9913. PsnNo string `json:"psn_no"`
  9914. ActPayDedc float64 `json:"act_pay_dedc"`
  9915. MedinsSetlID interface{} `json:"medins_setl_id"`
  9916. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  9917. ClrWay string `json:"clr_way"`
  9918. OthPay float64 `json:"oth_pay"`
  9919. Gend string `json:"gend"`
  9920. MdtrtID string `json:"mdtrt_id"`
  9921. AcctPay float64 `json:"acct_pay"`
  9922. InscpScpAmt float64 `json:"inscp_scp_amt"`
  9923. Insutype string `json:"insutype"`
  9924. Invono interface{} `json:"invono"`
  9925. Enddate string `json:"enddate"`
  9926. CashPayamt float64 `json:"cash_payamt"`
  9927. PsnType string `json:"psn_type"`
  9928. FixmedinsName string `json:"fixmedins_name"`
  9929. HifpPay float64 `json:"hifp_pay"`
  9930. NewFlag interface{} `json:"new_flag"`
  9931. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  9932. PreselfpayAmt float64 `json:"preselfpay_amt"`
  9933. PayLoc string `json:"pay_loc"`
  9934. ClrType string `json:"clr_type"`
  9935. RefdSetlFlag string `json:"refd_setl_flag"`
  9936. CvlservFlag string `json:"cvlserv_flag"`
  9937. EmpName string `json:"emp_name"`
  9938. Brdy string `json:"brdy"`
  9939. Naty string `json:"naty"`
  9940. Certno string `json:"certno"`
  9941. DiseCode string `json:"dise_code"`
  9942. FixmedinsCode string `json:"fixmedins_code"`
  9943. DedcHospLv string `json:"dedc_hosp_lv"`
  9944. OpterName string `json:"opter_name"`
  9945. Balc float64 `json:"balc"`
  9946. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  9947. PsnCertType string `json:"psn_cert_type"`
  9948. HifobPay float64 `json:"hifob_pay"`
  9949. MedfeeSumamt float64 `json:"medfee_sumamt"`
  9950. HifesPay float64 `json:"hifes_pay"`
  9951. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  9952. OptTime string `json:"opt_time"`
  9953. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  9954. SetlID string `json:"setl_id"`
  9955. MafPay float64 `json:"maf_pay"`
  9956. PsnName string `json:"psn_name"`
  9957. InsuOptins interface{} `json:"insu_optins"`
  9958. PrefFundPay interface{} `json:"pref_fund_pay"`
  9959. ClrOptins string `json:"clr_optins"`
  9960. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  9961. DiseName string `json:"dise_name"`
  9962. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  9963. Age float64 `json:"age"`
  9964. DtrtCertType string `json:"dtrt_cert_type"`
  9965. HospLv string `json:"hosp_lv"`
  9966. PsnCashPay float64
  9967. } `json:"setlinfo"`
  9968. } `json:"output"`
  9969. RefmsgTime string `json:"refmsg_time"`
  9970. RespondTime string `json:"respond_time"`
  9971. Signtype interface{} `json:"signtype"`
  9972. WarnMsg interface{} `json:"warn_msg"`
  9973. }
  9974. type ResultTwelve struct {
  9975. Cainfo string `json:"cainfo"`
  9976. ErrMsg string `json:"err_msg"`
  9977. InfRefmsgid string `json:"inf_refmsgid"`
  9978. Infcode int64 `json:"infcode"`
  9979. Output struct {
  9980. MdtrtId string `json:"mdtrt_id"`
  9981. ChrgBchno string `json:"chrg_bchno"`
  9982. PsnNo string `json:"psn_no"`
  9983. } `json:"output"`
  9984. RefmsgTime string `json:"refmsg_time"`
  9985. RespondTime string `json:"respond_time"`
  9986. Signtype interface{} `json:"signtype"`
  9987. WarnMsg interface{} `json:"warn_msg"`
  9988. }
  9989. type ResultThirteen struct {
  9990. ErrMsg string `json:"err_msg"`
  9991. InfRefmsgid string `json:"inf_refmsgid"`
  9992. Infcode int64 `json:"infcode"`
  9993. Output struct {
  9994. Result struct {
  9995. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  9996. } `json:"result"`
  9997. } `json:"output"`
  9998. RefmsgTime string `json:"refmsg_time"`
  9999. RespondTime string `json:"respond_time"`
  10000. Signtype interface{} `json:"signtype"`
  10001. WarnInfo interface{} `json:"warn_info"`
  10002. }
  10003. type ResultThirteen10265 struct {
  10004. ErrMsg string `json:"err_msg"`
  10005. InfRefmsgid string `json:"inf_refmsgid"`
  10006. Infcode string `json:"infcode"`
  10007. Output struct {
  10008. Result struct {
  10009. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  10010. } `json:"result"`
  10011. } `json:"output"`
  10012. RefmsgTime string `json:"refmsg_time"`
  10013. RespondTime string `json:"respond_time"`
  10014. Signtype interface{} `json:"signtype"`
  10015. WarnInfo interface{} `json:"warn_info"`
  10016. }
  10017. type ResultFourteen struct {
  10018. ErrMsg string `json:"err_msg"`
  10019. InfRefmsgid string `json:"inf_refmsgid"`
  10020. Infcode int64 `json:"infcode"`
  10021. Output struct {
  10022. } `json:"output"`
  10023. RefmsgTime string `json:"refmsg_time"`
  10024. RespondTime string `json:"respond_time"`
  10025. Signtype interface{} `json:"signtype"`
  10026. WarnInfo interface{} `json:"warn_info"`
  10027. }
  10028. type ResultFourteen10265 struct {
  10029. ErrMsg string `json:"err_msg"`
  10030. InfRefmsgid string `json:"inf_refmsgid"`
  10031. Infcode string `json:"infcode"`
  10032. Output struct {
  10033. } `json:"output"`
  10034. RefmsgTime string `json:"refmsg_time"`
  10035. RespondTime string `json:"respond_time"`
  10036. Signtype interface{} `json:"signtype"`
  10037. WarnInfo interface{} `json:"warn_info"`
  10038. }
  10039. type ResultSixteen struct {
  10040. Cainfo string `json:"cainfo"`
  10041. ErrMsg string `json:"err_msg"`
  10042. InfRefmsgid string `json:"inf_refmsgid"`
  10043. Infcode int64 `json:"infcode"`
  10044. Output struct {
  10045. Setldetail []interface{} `json:"setldetail"`
  10046. Setlinfo struct {
  10047. MdtrtID string `json:"mdtrt_id"`
  10048. SetlID string `json:"setl_id"`
  10049. ClrOptins string `json:"clr_optins"`
  10050. SetlTime string `json:"setl_time"`
  10051. MedfeeSumamt float64 `json:"medfee_sumamt"`
  10052. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  10053. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  10054. PreselfpayAmt float64 `json:"preselfpay_amt"`
  10055. InscpScpAmt float64 `json:"inscp_scp_amt"`
  10056. ActPayDedc float64 `json:"act_pay_dedc"`
  10057. HifpPay float64 `json:"hifp_pay"`
  10058. PoolPropSe float64 `json:"pool_prop_selfpay"`
  10059. Lfpay float64 `json:"selfpay"`
  10060. CvlservPay float64 `json:"cvlserv_pay"`
  10061. HifesPay float64 `json:"hifes_pay"`
  10062. HifmiPay float64 `json:"hifmi_pay"`
  10063. HifobPay float64 `json:"hifob_pay"`
  10064. MafPay float64 `json:"maf_pay"`
  10065. OthPay float64 `json:"oth_pay"`
  10066. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  10067. PsnPartAmt float64 `json:"psn_part_amt"`
  10068. AcctPay float64 `json:"acct_pay"`
  10069. Balc float64 `json:"balc"`
  10070. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  10071. HospPartAmt float64 `json:"hosp_part_amt"`
  10072. MedinsSetlID string `json:"medins_setl_id"`
  10073. PdnCashPay string `json:"pdn_cash_pay"`
  10074. } `json:"setlinfo"`
  10075. } `json:"output"`
  10076. RefmsgTime string `json:"refmsg_time"`
  10077. RespondTime string `json:"respond_time"`
  10078. Signtype interface{} `json:"signtype"`
  10079. WarnMsg interface{} `json:"warn_msg"`
  10080. }
  10081. type ResultSixteen10265 struct {
  10082. Cainfo string `json:"cainfo"`
  10083. ErrMsg string `json:"err_msg"`
  10084. InfRefmsgid string `json:"inf_refmsgid"`
  10085. Infcode string `json:"infcode"`
  10086. Output struct {
  10087. Setldetail []interface{} `json:"setldetail"`
  10088. Setlinfo struct {
  10089. MdtrtID string `json:"mdtrt_id"`
  10090. SetlID string `json:"setl_id"`
  10091. ClrOptins string `json:"clr_optins"`
  10092. SetlTime string `json:"setl_time"`
  10093. MedfeeSumamt float64 `json:"medfee_sumamt"`
  10094. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  10095. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  10096. PreselfpayAmt float64 `json:"preselfpay_amt"`
  10097. InscpScpAmt float64 `json:"inscp_scp_amt"`
  10098. ActPayDedc float64 `json:"act_pay_dedc"`
  10099. HifpPay float64 `json:"hifp_pay"`
  10100. PoolPropSe float64 `json:"pool_prop_selfpay"`
  10101. Lfpay float64 `json:"selfpay"`
  10102. CvlservPay float64 `json:"cvlserv_pay"`
  10103. HifesPay float64 `json:"hifes_pay"`
  10104. HifmiPay float64 `json:"hifmi_pay"`
  10105. HifobPay float64 `json:"hifob_pay"`
  10106. MafPay float64 `json:"maf_pay"`
  10107. OthPay float64 `json:"oth_pay"`
  10108. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  10109. PsnPartAmt float64 `json:"psn_part_amt"`
  10110. AcctPay float64 `json:"acct_pay"`
  10111. Balc float64 `json:"balc"`
  10112. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  10113. HospPartAmt float64 `json:"hosp_part_amt"`
  10114. MedinsSetlID string `json:"medins_setl_id"`
  10115. PdnCashPay string `json:"pdn_cash_pay"`
  10116. } `json:"setlinfo"`
  10117. } `json:"output"`
  10118. RefmsgTime string `json:"refmsg_time"`
  10119. RespondTime string `json:"respond_time"`
  10120. Signtype interface{} `json:"signtype"`
  10121. WarnMsg interface{} `json:"warn_msg"`
  10122. }
  10123. type ResultSixteen10265Two struct {
  10124. Cainfo string `json:"cainfo"`
  10125. ErrMsg string `json:"err_msg"`
  10126. InfRefmsgid string `json:"inf_refmsgid"`
  10127. Infcode string `json:"infcode"`
  10128. Output struct {
  10129. Setldetail []interface{} `json:"setldetail"`
  10130. Setlinfo interface{} `json:"setlinfo"`
  10131. } `json:"output"`
  10132. RefmsgTime string `json:"refmsg_time"`
  10133. RespondTime string `json:"respond_time"`
  10134. Signtype interface{} `json:"signtype"`
  10135. WarnMsg interface{} `json:"warn_msg"`
  10136. }
  10137. type ResultSeventeen struct {
  10138. ErrMsg string `json:"err_msg"`
  10139. InfRefmsgid string `json:"inf_refmsgid"`
  10140. Infcode int64 `json:"infcode"`
  10141. Output struct {
  10142. SetlListId string `json:"setl_list_id"`
  10143. } `json:"output"`
  10144. RefmsgTime string `json:"refmsg_time"`
  10145. RespondTime string `json:"respond_time"`
  10146. Signtype string `json:"signtype"`
  10147. WarnInfo string `json:"warn_info"`
  10148. }
  10149. type ResultSeventeenOther struct {
  10150. ErrMsg string `json:"err_msg"`
  10151. InfRefmsgid string `json:"inf_refmsgid"`
  10152. Infcode string `json:"infcode"`
  10153. Output struct {
  10154. SetlListId string `json:"setl_list_id"`
  10155. } `json:"output"`
  10156. RefmsgTime string `json:"refmsg_time"`
  10157. RespondTime string `json:"respond_time"`
  10158. Signtype string `json:"signtype"`
  10159. WarnInfo string `json:"warn_info"`
  10160. }
  10161. type Result90991 struct {
  10162. ErrMsg string `json:"err_msg"`
  10163. InfRefmsgid string `json:"inf_refmsgid"`
  10164. Infcode int64 `json:"infcode"`
  10165. Output struct {
  10166. Result struct {
  10167. PsnNo string `json:"psn_no"`
  10168. CardStat string `json:"card_stat"`
  10169. Certno string `json:"certno"`
  10170. PsnName string `json:"psn_name"`
  10171. CheckStat string `json:"check_stat"`
  10172. SscnoCheckStat string `json:"sscno_check_stat"`
  10173. } `json:"result"`
  10174. } `json:"output"`
  10175. RefmsgTime string `json:"refmsg_time"`
  10176. RespondTime string `json:"respond_time"`
  10177. Signtype interface{} `json:"signtype"`
  10178. WarnInfo interface{} `json:"warn_info"`
  10179. }
  10180. type Result90100 struct {
  10181. ErrMsg string `json:"err_msg"`
  10182. InfRefmsgid string `json:"inf_refmsgid"`
  10183. Infcode int64 `json:"infcode"`
  10184. Output struct {
  10185. PoolareaNo string `json:"poolarea_no"`
  10186. PoolareaNoName string `json:"poolarea_no_name"`
  10187. Insutype string `json:"insutype"`
  10188. InsutypeName string `json:"insutype_name"`
  10189. ClctType string `json:"clct_type"`
  10190. ClctTypeName string `json:"clct_type_name"`
  10191. ClctFlag string `json:"clct_flag"`
  10192. ClctFlagName string `json:"clct_flag_name"`
  10193. AccrymBegn string `json:"accrym_begn"`
  10194. AccrymEnd string `json:"accrym_end"`
  10195. ClctTime string `json:"clct_time"`
  10196. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  10197. } `json:"output"`
  10198. RefmsgTime string `json:"refmsg_time"`
  10199. RespondTime string `json:"respond_time"`
  10200. Signtype interface{} `json:"signtype"`
  10201. WarnInfo interface{} `json:"warn_info"`
  10202. }
  10203. type Custom struct {
  10204. DetItemFeeSumamt string
  10205. Cut string
  10206. FeedetlSn string
  10207. Price string
  10208. MedListCodg string
  10209. Type int64
  10210. AdviceId int64
  10211. ProjectId int64
  10212. ItemId int64
  10213. }
  10214. type Result5301 struct {
  10215. ErrMsg string `json:"err_msg"`
  10216. InfRefmsgid string `json:"inf_refmsgid"`
  10217. Infcode int64 `json:"infcode"`
  10218. Output struct {
  10219. Result []struct {
  10220. OpspDiseCode string `json:"opsp_dise_code"`
  10221. OpspDiseName string `json:"opsp_dise_name"`
  10222. Begndate string `json:"begndate"`
  10223. Enddate string `json:"enddate"`
  10224. } `json:"feedetail"`
  10225. } `json:"output"`
  10226. RefmsgTime string `json:"refmsg_time"`
  10227. RespondTime string `json:"respond_time"`
  10228. Signtype interface{} `json:"signtype"`
  10229. WarnInfo interface{} `json:"warn_info"`
  10230. }
  10231. type Result5301For10265 struct {
  10232. ErrMsg string `json:"err_msg"`
  10233. InfRefmsgid string `json:"inf_refmsgid"`
  10234. Infcode string `json:"infcode"`
  10235. Output struct {
  10236. Result []struct {
  10237. OpspDiseCode string `json:"opsp_dise_code"`
  10238. OpspDiseName string `json:"opsp_dise_name"`
  10239. Begndate string `json:"begndate"`
  10240. Enddate string `json:"enddate"`
  10241. } `json:"feedetail"`
  10242. } `json:"output"`
  10243. RefmsgTime string `json:"refmsg_time"`
  10244. RespondTime string `json:"respond_time"`
  10245. Signtype interface{} `json:"signtype"`
  10246. WarnInfo interface{} `json:"warn_info"`
  10247. }
  10248. //获取个人信息----挂号-----上传就诊信息
  10249. func (c *HisApiController) GetRegisterInfo() {
  10250. id, _ := c.GetInt64("id")
  10251. record_time := c.GetString("record_time")
  10252. settlementValue, _ := c.GetInt64("settlement_value")
  10253. medical_insurance_card := c.GetString("medical_insurance_card")
  10254. name := c.GetString("name")
  10255. id_card_type, _ := c.GetInt64("id_card_type")
  10256. certificates, _ := c.GetInt64("certificates")
  10257. medical_care, _ := c.GetInt64("medical_care")
  10258. birthday := c.GetString("birthday")
  10259. id_card := c.GetString("id_card")
  10260. register_type, _ := c.GetInt64("register")
  10261. doctor, _ := c.GetInt64("doctor")
  10262. department, _ := c.GetInt64("department")
  10263. gender, _ := c.GetInt64("sex")
  10264. registration_fee, _ := c.GetFloat("registration_fee")
  10265. medical_expenses, _ := c.GetFloat("medical_expenses")
  10266. social_type, _ := c.GetInt64("social_type")
  10267. admin_user_id, _ := c.GetInt64("admin_user_id")
  10268. insuplc_admdvs := c.GetString("insuplc_admdvs")
  10269. mdtrt_type := c.GetString("mdtrt_type")
  10270. timeLayout := "2006-01-02"
  10271. loc, _ := time.LoadLocation("Local")
  10272. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  10273. birthUnix := birthdays.Unix()
  10274. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10275. if err != nil {
  10276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10277. return
  10278. }
  10279. recordDateTime := theTime.Unix()
  10280. adminInfo := c.GetAdminUserInfo()
  10281. var patient service.Patients
  10282. if id == 0 {
  10283. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  10284. } else {
  10285. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  10286. }
  10287. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10288. if patientPrescription.ID == 0 {
  10289. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  10290. }
  10291. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  10292. if patient.ID == 0 {
  10293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10294. return
  10295. }
  10296. if len(patient.IdCardNo) == 0 {
  10297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  10298. return
  10299. }
  10300. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  10301. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  10302. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  10303. //就诊结算未完成,不能进行二次挂号
  10304. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  10305. if len(his) >= 1 {
  10306. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  10307. if len(his) >= 1 && order.ID == 0 {
  10308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  10309. return
  10310. }
  10311. }
  10312. //var register_log string
  10313. if config.IsOpen == 1 {
  10314. var res ResultTwo
  10315. var res10265 ResultTwo10265
  10316. var PsnNo string
  10317. var PsnCertType string
  10318. var Certno string
  10319. var PsnName string
  10320. var Gend string
  10321. var Naty string
  10322. var Brdy string
  10323. var Age float64
  10324. var infoStr string
  10325. var idetinfoStr string
  10326. var infocode int64
  10327. var verify_number string
  10328. fmt.Println(verify_number)
  10329. if miConfig.MdtrtareaAdmvs == "421300" {
  10330. psn_info, _ := service.GetPsnByPatientId(id)
  10331. PsnNo = psn_info.PsnNo
  10332. PsnCertType = psn_info.PsnCertType
  10333. Certno = psn_info.Certno
  10334. PsnName = psn_info.PsnName
  10335. Gend = psn_info.Gend
  10336. Naty = psn_info.Naty
  10337. Brdy = psn_info.Brdy
  10338. Age = psn_info.Age
  10339. infoStr = psn_info.Insuinfo
  10340. idetinfoStr = psn_info.Idetinfo
  10341. infocode = 0
  10342. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10343. psn_info, _ := service.GetPsnByPatientId(id)
  10344. PsnNo = psn_info.PsnNo
  10345. PsnCertType = psn_info.PsnCertType
  10346. Certno = psn_info.Certno
  10347. PsnName = psn_info.PsnName
  10348. Gend = psn_info.Gend
  10349. Naty = psn_info.Naty
  10350. Brdy = psn_info.Brdy
  10351. Age = psn_info.Age
  10352. infoStr = psn_info.Insuinfo
  10353. idetinfoStr = psn_info.Idetinfo
  10354. infocode = 0
  10355. verify_number = psn_info.VerifyNumber
  10356. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10357. if id_card_type == 2 {
  10358. //请求内网数据
  10359. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  10360. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10361. "&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
  10362. resp, requestErr := http.Get(api)
  10363. if requestErr != nil {
  10364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10365. return
  10366. }
  10367. body, ioErr := ioutil.ReadAll(resp.Body)
  10368. if ioErr != nil {
  10369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10371. return
  10372. }
  10373. var respJSON map[string]interface{}
  10374. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10377. return
  10378. }
  10379. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10380. result_byte, _ := json.Marshal(respJSON)
  10381. result := string(result_byte)
  10382. var dat map[string]interface{}
  10383. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10384. fmt.Println(dat)
  10385. } else {
  10386. fmt.Println(err)
  10387. }
  10388. userJSONBytes, _ := json.Marshal(dat)
  10389. var res ResultTwo
  10390. var resTwo10265 ResultTwo10265
  10391. if miConfig.Code == "H15049901371" {
  10392. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  10393. utils.ErrorLog("解析失败:%v", err)
  10394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10395. return
  10396. }
  10397. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  10398. res.Infcode = Infcode
  10399. res.ErrMsg = resTwo10265.ErrMsg
  10400. res.Output = resTwo10265.Output
  10401. res.InfRefmsgid = resTwo10265.InfRefmsgid
  10402. res.RespondTime = resTwo10265.RespondTime
  10403. res.WarnInfo = resTwo10265.WarnInfo
  10404. } else {
  10405. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10406. utils.ErrorLog("解析失败:%v", err)
  10407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10408. return
  10409. }
  10410. }
  10411. //var insutypes []string
  10412. //var insutype string
  10413. //var is390 int = 0
  10414. //var is310 int = 0
  10415. //for _, item := range res.Output.Iinfo {
  10416. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10417. // insutypes = append(insutypes, item.Insutype)
  10418. // }
  10419. //}
  10420. //if len(insutypes) == 1 {
  10421. // insutype = insutypes[0]
  10422. //} else {
  10423. // for _, i := range insutypes {
  10424. // if i == "390" {
  10425. // is390 = 1
  10426. // }
  10427. //
  10428. // if i == "310" {
  10429. // is310 = 1
  10430. // }
  10431. // }
  10432. //}
  10433. //if is390 == 1 {
  10434. // insutype = "390"
  10435. //}
  10436. //if is310 == 1 {
  10437. // insutype = "310"
  10438. //}
  10439. //if len(insutypes) == 0 {
  10440. // insutype = "310"
  10441. //}
  10442. PsnNo = res.Output.Baseinfo.PsnNo
  10443. PsnCertType = res.Output.Baseinfo.PsnCertType
  10444. Certno = res.Output.Baseinfo.Certno
  10445. PsnName = res.Output.Baseinfo.PsnName
  10446. Gend = res.Output.Baseinfo.Gend
  10447. Naty = res.Output.Baseinfo.Naty
  10448. Brdy = res.Output.Baseinfo.Brdy
  10449. Age = res.Output.Baseinfo.Age
  10450. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10451. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10452. infoStr = string(Iinfos)
  10453. idetinfoStr = string(Idetinfos)
  10454. infocode = res.Infcode
  10455. //infocode = 0
  10456. //verify_number = psn_info.VerifyNumber
  10457. } else {
  10458. psn_info, _ := service.GetPsnByPatientId(id)
  10459. PsnNo = psn_info.PsnNo
  10460. PsnCertType = psn_info.PsnCertType
  10461. Certno = psn_info.Certno
  10462. PsnName = psn_info.PsnName
  10463. Gend = psn_info.Gend
  10464. Naty = psn_info.Naty
  10465. Brdy = psn_info.Brdy
  10466. Age = psn_info.Age
  10467. infoStr = psn_info.Insuinfo
  10468. idetinfoStr = psn_info.Idetinfo
  10469. infocode = 0
  10470. verify_number = psn_info.VerifyNumber
  10471. }
  10472. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10473. if id_card_type == 1 {
  10474. psn_info, _ := service.GetPsnByPatientId(id)
  10475. PsnNo = psn_info.PsnNo
  10476. PsnCertType = psn_info.PsnCertType
  10477. Certno = psn_info.Certno
  10478. PsnName = psn_info.PsnName
  10479. Gend = psn_info.Gend
  10480. Naty = psn_info.Naty
  10481. Brdy = psn_info.Brdy
  10482. Age = psn_info.Age
  10483. infoStr = psn_info.Insuinfo
  10484. idetinfoStr = psn_info.Idetinfo
  10485. infocode = 0
  10486. verify_number = psn_info.VerifyNumber
  10487. } else if id_card_type == 2 {
  10488. 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)
  10489. fmt.Println(errMsgLog)
  10490. saveLog(result, requestLog, "1101", "人员基本信息获取")
  10491. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10492. utils.ErrorLog("解析失败:%v", err)
  10493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10494. return
  10495. }
  10496. PsnNo = res.Output.Baseinfo.PsnNo
  10497. PsnCertType = res.Output.Baseinfo.PsnCertType
  10498. Certno = res.Output.Baseinfo.Certno
  10499. PsnName = res.Output.Baseinfo.PsnName
  10500. Gend = res.Output.Baseinfo.Gend
  10501. Naty = res.Output.Baseinfo.Naty
  10502. Brdy = res.Output.Baseinfo.Brdy
  10503. Age = res.Output.Baseinfo.Age
  10504. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10505. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10506. infoStr = string(Iinfos)
  10507. idetinfoStr = string(Idetinfos)
  10508. infocode = res.Infcode
  10509. }
  10510. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10511. if id_card_type == 1 {
  10512. psn_info, _ := service.GetPsnByPatientId(id)
  10513. PsnNo = psn_info.PsnNo
  10514. PsnCertType = psn_info.PsnCertType
  10515. Certno = psn_info.Certno
  10516. PsnName = psn_info.PsnName
  10517. Gend = psn_info.Gend
  10518. Naty = psn_info.Naty
  10519. Brdy = psn_info.Brdy
  10520. Age = psn_info.Age
  10521. infoStr = psn_info.Insuinfo
  10522. idetinfoStr = psn_info.Idetinfo
  10523. infocode = 0
  10524. verify_number = psn_info.VerifyNumber
  10525. } else if id_card_type == 2 {
  10526. 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, "")
  10527. saveLog(result, requestLog, "1101", "人员基本信息获取")
  10528. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10529. utils.ErrorLog("解析失败:%v", err)
  10530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10531. return
  10532. }
  10533. PsnNo = res.Output.Baseinfo.PsnNo
  10534. PsnCertType = res.Output.Baseinfo.PsnCertType
  10535. Certno = res.Output.Baseinfo.Certno
  10536. PsnName = res.Output.Baseinfo.PsnName
  10537. Gend = res.Output.Baseinfo.Gend
  10538. Naty = res.Output.Baseinfo.Naty
  10539. Brdy = res.Output.Baseinfo.Brdy
  10540. Age = res.Output.Baseinfo.Age
  10541. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10542. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10543. infoStr = string(Iinfos)
  10544. idetinfoStr = string(Idetinfos)
  10545. infocode = res.Infcode
  10546. }
  10547. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10548. if id_card_type == 1 {
  10549. psn_info, _ := service.GetPsnByPatientId(id)
  10550. PsnNo = psn_info.PsnNo
  10551. PsnCertType = psn_info.PsnCertType
  10552. Certno = psn_info.Certno
  10553. PsnName = psn_info.PsnName
  10554. Gend = psn_info.Gend
  10555. Naty = psn_info.Naty
  10556. Brdy = psn_info.Brdy
  10557. Age = psn_info.Age
  10558. infoStr = psn_info.Insuinfo
  10559. idetinfoStr = psn_info.Idetinfo
  10560. infocode = 0
  10561. verify_number = psn_info.VerifyNumber
  10562. } else if id_card_type == 2 {
  10563. 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)
  10564. saveLog(result, requestLog, "1101", "人员基本信息获取")
  10565. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10566. utils.ErrorLog("解析失败:%v", err)
  10567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10568. return
  10569. }
  10570. PsnNo = res.Output.Baseinfo.PsnNo
  10571. PsnCertType = res.Output.Baseinfo.PsnCertType
  10572. Certno = res.Output.Baseinfo.Certno
  10573. PsnName = res.Output.Baseinfo.PsnName
  10574. Gend = res.Output.Baseinfo.Gend
  10575. Naty = res.Output.Baseinfo.Naty
  10576. Brdy = res.Output.Baseinfo.Brdy
  10577. Age = res.Output.Baseinfo.Age
  10578. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10579. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10580. infoStr = string(Iinfos)
  10581. idetinfoStr = string(Idetinfos)
  10582. infocode = res.Infcode
  10583. } else if id_card_type == 4 {
  10584. psn_info, _ := service.GetPsnByPatientId(id)
  10585. PsnNo = psn_info.PsnNo
  10586. PsnCertType = psn_info.PsnCertType
  10587. Certno = psn_info.Certno
  10588. PsnName = psn_info.PsnName
  10589. Gend = psn_info.Gend
  10590. Naty = psn_info.Naty
  10591. Brdy = psn_info.Brdy
  10592. Age = psn_info.Age
  10593. infoStr = psn_info.Insuinfo
  10594. idetinfoStr = psn_info.Idetinfo
  10595. infocode = 0
  10596. verify_number = psn_info.VerifyNumber
  10597. }
  10598. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10599. var result string
  10600. var requestLog string
  10601. 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), "")
  10602. if id_card_type == 4 {
  10603. psn_info, _ := service.GetPsnByPatientId(id)
  10604. PsnNo = psn_info.PsnNo
  10605. PsnCertType = psn_info.PsnCertType
  10606. Certno = psn_info.Certno
  10607. PsnName = psn_info.PsnName
  10608. Gend = psn_info.Gend
  10609. Naty = psn_info.Naty
  10610. Brdy = psn_info.Brdy
  10611. Age = psn_info.Age
  10612. infoStr = psn_info.Insuinfo
  10613. idetinfoStr = psn_info.Idetinfo
  10614. infocode = 0
  10615. verify_number = psn_info.VerifyNumber
  10616. } else {
  10617. saveLog(result, requestLog, "1101", "人员基本信息获取")
  10618. if miConfig.Code == "H15049901371" {
  10619. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10620. utils.ErrorLog("解析失败:%v", err)
  10621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10622. return
  10623. }
  10624. res.ErrMsg = res10265.ErrMsg
  10625. res.Output = res10265.Output
  10626. res.InfRefmsgid = res10265.InfRefmsgid
  10627. } else {
  10628. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10629. utils.ErrorLog("解析失败:%v", err)
  10630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10631. return
  10632. }
  10633. }
  10634. PsnNo = res.Output.Baseinfo.PsnNo
  10635. PsnCertType = res.Output.Baseinfo.PsnCertType
  10636. Certno = res.Output.Baseinfo.Certno
  10637. PsnName = res.Output.Baseinfo.PsnName
  10638. Gend = res.Output.Baseinfo.Gend
  10639. Naty = res.Output.Baseinfo.Naty
  10640. Brdy = res.Output.Baseinfo.Brdy
  10641. Age = res.Output.Baseinfo.Age
  10642. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10643. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10644. infoStr = string(Iinfos)
  10645. idetinfoStr = string(Idetinfos)
  10646. if miConfig.Code == "H15049901371" {
  10647. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  10648. } else {
  10649. infocode = res.Infcode
  10650. }
  10651. }
  10652. } else {
  10653. var result string
  10654. var requestLog string
  10655. //if miConfig.UserOrgId == 10138 {
  10656. if id_card_type != 4 || id_card_type != 1 {
  10657. var insa string
  10658. if len(patient.InsuplcAdmdvs) > 0 {
  10659. insa = patient.InsuplcAdmdvs
  10660. } else {
  10661. insa = miConfig.InsuplcAdmdvs
  10662. }
  10663. //psn_info, _ := service.GetPsnByPatientId(id)
  10664. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  10665. 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)
  10666. }
  10667. //}
  10668. //else {
  10669. // var insa string
  10670. // if len(patient.InsuplcAdmdvs) > 0 {
  10671. // insa = patient.InsuplcAdmdvs
  10672. // } else {
  10673. // insa = miConfig.InsuplcAdmdvs
  10674. // }
  10675. // 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)
  10676. //}
  10677. if id_card_type == 4 || id_card_type == 1 {
  10678. psn_info, _ := service.GetPsnByPatientId(id)
  10679. PsnNo = psn_info.PsnNo
  10680. PsnCertType = psn_info.PsnCertType
  10681. Certno = psn_info.Certno
  10682. PsnName = psn_info.PsnName
  10683. Gend = psn_info.Gend
  10684. Naty = psn_info.Naty
  10685. Brdy = psn_info.Brdy
  10686. Age = psn_info.Age
  10687. infoStr = psn_info.Insuinfo
  10688. idetinfoStr = psn_info.Idetinfo
  10689. infocode = 0
  10690. verify_number = psn_info.VerifyNumber
  10691. } else {
  10692. saveLog(result, requestLog, "1101", "人员基本信息获取")
  10693. if miConfig.Code == "H15049901371" {
  10694. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10695. utils.ErrorLog("解析失败:%v", err)
  10696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10697. return
  10698. }
  10699. res.ErrMsg = res10265.ErrMsg
  10700. res.Output = res10265.Output
  10701. res.InfRefmsgid = res10265.InfRefmsgid
  10702. } else {
  10703. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10704. utils.ErrorLog("解析失败:%v", err)
  10705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10706. return
  10707. }
  10708. }
  10709. PsnNo = res.Output.Baseinfo.PsnNo
  10710. PsnCertType = res.Output.Baseinfo.PsnCertType
  10711. Certno = res.Output.Baseinfo.Certno
  10712. PsnName = res.Output.Baseinfo.PsnName
  10713. Gend = res.Output.Baseinfo.Gend
  10714. Naty = res.Output.Baseinfo.Naty
  10715. Brdy = res.Output.Baseinfo.Brdy
  10716. Age = res.Output.Baseinfo.Age
  10717. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10718. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10719. infoStr = string(Iinfos)
  10720. idetinfoStr = string(Idetinfos)
  10721. if miConfig.Code == "H15049901371" {
  10722. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  10723. } else {
  10724. infocode = res.Infcode
  10725. }
  10726. }
  10727. }
  10728. if infocode == 0 {
  10729. his := models.VMHisPatient{
  10730. Name: name,
  10731. Gender: gender,
  10732. Birthday: birthUnix,
  10733. MedicalTreatmentType: medical_care,
  10734. IdType: certificates,
  10735. IdCardNo: id_card,
  10736. BalanceAccountsType: settlementValue,
  10737. SocialType: social_type,
  10738. MedicalInsuranceNumber: medical_insurance_card,
  10739. RegisterType: register_type,
  10740. RegisterCost: registration_fee,
  10741. TreatmentCost: medical_expenses,
  10742. Status: 1,
  10743. Ctime: time.Now().Unix(),
  10744. Mtime: time.Now().Unix(),
  10745. PsnNo: PsnNo,
  10746. PsnCertType: PsnCertType,
  10747. Certno: Certno,
  10748. PsnName: PsnName,
  10749. Gend: Gend,
  10750. Naty: Naty,
  10751. Brdy: Brdy,
  10752. Age: Age,
  10753. Iinfo: infoStr,
  10754. Idetinfo: idetinfoStr,
  10755. PatientId: patient.ID,
  10756. RecordDate: theTime.Unix(),
  10757. UserOrgId: adminInfo.CurrentOrgId,
  10758. AdminUserId: admin_user_id,
  10759. IsReturn: 1,
  10760. IdCardType: id_card_type,
  10761. Doctor: doctor,
  10762. Departments: department,
  10763. MdtrtGrpType: mdtrt_type,
  10764. }
  10765. timestamp := time.Now().Unix()
  10766. tempTime := time.Unix(timestamp, 0)
  10767. timeFormat := tempTime.Format("20060102150405")
  10768. chrgBchno := rand.Intn(100000) + 10000
  10769. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  10770. his.Number = ipt_otp_no
  10771. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  10772. department, _ := service.GetDepartMentDetail(department)
  10773. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  10774. IdCardNo := ""
  10775. if id_card_type == 1 {
  10776. // IdCardNo = medical_insurance_card
  10777. IdCardNo = patient.IdCardNo
  10778. } else {
  10779. IdCardNo = patient.IdCardNo
  10780. }
  10781. var rf []*ResultFive
  10782. json.Unmarshal([]byte(his.Iinfo), &rf)
  10783. var insutypes []*ResultFive
  10784. var insutype string
  10785. var insuplc_admdvs_temp string
  10786. var is390 int = 0
  10787. var is310 int = 0
  10788. for _, item := range rf {
  10789. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10790. insutypes = append(insutypes, item)
  10791. }
  10792. }
  10793. if len(insutypes) == 1 {
  10794. insutype = insutypes[0].Insutype
  10795. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10796. } else {
  10797. for _, i := range insutypes {
  10798. if i.Insutype == "390" {
  10799. is390 = 1
  10800. }
  10801. if i.Insutype == "310" {
  10802. is310 = 1
  10803. }
  10804. }
  10805. }
  10806. if is390 == 1 {
  10807. insutype = "390"
  10808. }
  10809. if is310 == 1 {
  10810. insutype = "310"
  10811. }
  10812. fmt.Println(social_type)
  10813. if social_type > 0 {
  10814. insutype = strconv.FormatInt(social_type, 10)
  10815. }
  10816. var infocode int64
  10817. var resThree ResultThree
  10818. var resThree10265 ResultThree10265
  10819. if len(insuplc_admdvs) == 0 {
  10820. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  10821. } else {
  10822. insuplc_admdvs_temp = insuplc_admdvs
  10823. }
  10824. if miConfig.MdtrtareaAdmvs == "421300" {
  10825. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  10826. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  10827. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  10828. "&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
  10829. resp, requestErr := http.Get(api)
  10830. if requestErr != nil {
  10831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10832. return
  10833. }
  10834. body, ioErr := ioutil.ReadAll(resp.Body)
  10835. if ioErr != nil {
  10836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10838. return
  10839. }
  10840. var respJSON map[string]interface{}
  10841. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10844. return
  10845. }
  10846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10847. result, _ := json.Marshal(respJSON)
  10848. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10849. utils.ErrorLog("解析失败:%v", err)
  10850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10851. return
  10852. }
  10853. infocode = resThree.Infcode
  10854. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10855. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  10856. psn_info, _ := service.GetPsnByPatientId(id)
  10857. var verify_number string
  10858. if id_card_type == 4 {
  10859. verify_number = psn_info.VerifyNumber
  10860. } else if id_card_type == 1 {
  10861. bas := strings.Split(psn_info.CardInfo, "|")
  10862. cardNumber := bas[2]
  10863. verify_number = cardNumber
  10864. }
  10865. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  10866. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  10867. "&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
  10868. resp, requestErr := http.Get(api)
  10869. if requestErr != nil {
  10870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10871. return
  10872. }
  10873. body, ioErr := ioutil.ReadAll(resp.Body)
  10874. if ioErr != nil {
  10875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10877. return
  10878. }
  10879. var respJSON map[string]interface{}
  10880. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10883. return
  10884. }
  10885. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10886. result, _ := json.Marshal(respJSON)
  10887. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  10888. // utils.ErrorLog("解析失败:%v", err)
  10889. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10890. // return
  10891. //}
  10892. //infocode = resThree.Infcode
  10893. //result, _ := json.Marshal(respJSON)
  10894. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  10895. utils.ErrorLog("解析失败:%v", err)
  10896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10897. return
  10898. }
  10899. resThree.ErrMsg = resThree10265.ErrMsg
  10900. resThree.Output = resThree10265.Output
  10901. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  10902. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  10903. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10904. psn_info, _ := service.GetPsnByPatientId(id)
  10905. his.PsnNo = psn_info.PsnNo
  10906. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  10907. var cert_no string
  10908. if id_card_type == 3 {
  10909. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  10910. cert_no = IdCardNo
  10911. } else if id_card_type == 4 {
  10912. cert_no = IdCardNo
  10913. psn_info.VerifyNumber = psn_info.VerifyNumber
  10914. } else {
  10915. bas := strings.Split(psn_info.CardInfo, "|")
  10916. cert_no = bas[2]
  10917. }
  10918. var hisPrescription []*models.HisPrescription
  10919. for _, item := range rf {
  10920. if item.Insutype == insutype {
  10921. //insuplc_admdvs = item.InsuplcAdmdvs
  10922. his.InsuplcAdmdvs = insuplc_admdvs
  10923. }
  10924. }
  10925. his.Insutype = insutype
  10926. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  10927. fmt.Println(res3101)
  10928. fmt.Println(res3101.Infcode)
  10929. if res3101.Infcode == "0" {
  10930. fmt.Println("33333333")
  10931. if len(res3101.Output.Result) > 0 {
  10932. fmt.Println("222222")
  10933. for _, item := range res3101.Output.Result {
  10934. if len(res3101.ErrMsg) == 0 {
  10935. res3101.ErrMsg = item.VolaCont
  10936. } else {
  10937. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  10938. }
  10939. }
  10940. c.ServeSuccessJSON(map[string]interface{}{
  10941. "failed_code": -10,
  10942. "msg": res3101.ErrMsg,
  10943. })
  10944. return
  10945. } else {
  10946. fmt.Println("11111")
  10947. var api string
  10948. if miConfig.MdtrtareaAdmvs == "320921" {
  10949. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  10950. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  10951. "&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
  10952. } else {
  10953. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  10954. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  10955. "&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
  10956. }
  10957. resp, requestErr := http.Get(api)
  10958. if requestErr != nil {
  10959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10960. return
  10961. }
  10962. body, ioErr := ioutil.ReadAll(resp.Body)
  10963. if ioErr != nil {
  10964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10966. return
  10967. }
  10968. var respJSON map[string]interface{}
  10969. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10972. return
  10973. }
  10974. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10975. result, _ := json.Marshal(respJSON)
  10976. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  10977. utils.ErrorLog("解析失败:%v", err)
  10978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10979. return
  10980. }
  10981. resThree.ErrMsg = resThree10265.ErrMsg
  10982. resThree.Output = resThree10265.Output
  10983. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  10984. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  10985. }
  10986. } else if res3101.Infcode != "0" {
  10987. c.ServeSuccessJSON(map[string]interface{}{
  10988. "failed_code": -10,
  10989. "msg": res3101.ErrMsg,
  10990. })
  10991. return
  10992. }
  10993. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10994. psn_info, _ := service.GetPsnByPatientId(id)
  10995. var cert_no string
  10996. if id_card_type == 1 {
  10997. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10998. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  10999. } else if id_card_type == 4 {
  11000. cert_no = psn_info.VerifyNumber
  11001. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  11002. } else {
  11003. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  11004. cert_no = psn_info.VerifyNumber
  11005. }
  11006. 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)
  11007. saveLog(result, requestLog, "2201", "挂号")
  11008. if miConfig.Code == "H15049901371" {
  11009. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  11010. utils.ErrorLog("解析失败:%v", err)
  11011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11012. return
  11013. }
  11014. resThree.ErrMsg = resThree10265.ErrMsg
  11015. resThree.Output = resThree10265.Output
  11016. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  11017. } else {
  11018. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  11019. utils.ErrorLog("解析失败:%v", err)
  11020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11021. return
  11022. }
  11023. }
  11024. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  11025. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  11026. psn_info, _ := service.GetPsnByPatientId(id)
  11027. var result string
  11028. var requestLog string
  11029. if id_card_type == 1 {
  11030. bas := strings.Split(psn_info.CardInfo, "|")
  11031. basNumber := bas[2]
  11032. card_sn := bas[3]
  11033. result, requestLog = service.Jxyb2201(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)
  11034. saveLog(result, requestLog, "2201A", "挂号")
  11035. } else if id_card_type == 2 {
  11036. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "")
  11037. saveLog(result, requestLog, "2201A", "挂号")
  11038. } else {
  11039. 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, "", "")
  11040. saveLog(result, requestLog, "2201A", "挂号")
  11041. }
  11042. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  11043. utils.ErrorLog("解析失败:%v", err)
  11044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11045. return
  11046. }
  11047. infocode = resThree.Infcode
  11048. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  11049. psn_info, _ := service.GetPsnByPatientId(id)
  11050. var result string
  11051. var requestLog string
  11052. if id_card_type == 1 {
  11053. bas := strings.Split(psn_info.CardInfo, "|")
  11054. basNumber := bas[2]
  11055. card_sn := bas[3]
  11056. 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)
  11057. saveLog(result, requestLog, "2201A", "挂号")
  11058. } else if id_card_type == 2 {
  11059. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "")
  11060. saveLog(result, requestLog, "2201A", "挂号")
  11061. } else {
  11062. 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, "", "")
  11063. saveLog(result, requestLog, "2201A", "挂号")
  11064. }
  11065. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  11066. utils.ErrorLog("解析失败:%v", err)
  11067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11068. return
  11069. }
  11070. infocode = resThree.Infcode
  11071. } else if miConfig.MdtrtareaAdmvs == "131023" {
  11072. psn_info, _ := service.GetPsnByPatientId(id)
  11073. 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)
  11074. saveLog(result, requestLog, "2201A", "挂号")
  11075. if miConfig.Code == "H15049901371" {
  11076. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  11077. utils.ErrorLog("解析失败:%v", err)
  11078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11079. return
  11080. }
  11081. resThree.ErrMsg = resThree10265.ErrMsg
  11082. resThree.Output = resThree10265.Output
  11083. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  11084. } else {
  11085. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  11086. utils.ErrorLog("解析失败:%v", err)
  11087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11088. return
  11089. }
  11090. }
  11091. if miConfig.Code == "H15049901371" {
  11092. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  11093. } else {
  11094. infocode = resThree.Infcode
  11095. }
  11096. } else {
  11097. psn_info, _ := service.GetPsnByPatientId(id)
  11098. if id_card_type == 4 || id_card_type == 1 {
  11099. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  11100. }
  11101. var rf []*ResultFive
  11102. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  11103. var insutypes []*ResultFive
  11104. var insutype string
  11105. var is390 int = 0
  11106. var is310 int = 0
  11107. for _, item := range rf {
  11108. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11109. insutypes = append(insutypes, item)
  11110. }
  11111. }
  11112. if len(insutypes) == 1 {
  11113. insutype = insutypes[0].Insutype
  11114. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11115. } else {
  11116. for _, i := range insutypes {
  11117. if i.Insutype == "390" {
  11118. is390 = 1
  11119. }
  11120. if i.Insutype == "310" {
  11121. is310 = 1
  11122. }
  11123. }
  11124. }
  11125. if is390 == 1 {
  11126. insutype = "390"
  11127. }
  11128. if is310 == 1 {
  11129. insutype = "310"
  11130. }
  11131. fmt.Println(len(insutypes))
  11132. if len(insutypes) == 0 {
  11133. for index, item := range rf {
  11134. if index == 0 {
  11135. insutype = item.Insutype
  11136. insuplc_admdvs = item.InsuplcAdmdvs
  11137. }
  11138. }
  11139. fmt.Println(insutype)
  11140. fmt.Println(insuplc_admdvs)
  11141. }
  11142. if social_type > 0 {
  11143. insutype = strconv.FormatInt(social_type, 10)
  11144. }
  11145. fmt.Println("--------")
  11146. fmt.Println(psn_info)
  11147. fmt.Println(psn_info.PsnNo)
  11148. 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, psn_info.VerifyNumber)
  11149. saveLog(result, requestLog, "2201A", "挂号")
  11150. if miConfig.Code == "H15049901371" {
  11151. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  11152. utils.ErrorLog("解析失败:%v", err)
  11153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11154. return
  11155. }
  11156. resThree.ErrMsg = resThree10265.ErrMsg
  11157. resThree.Output = resThree10265.Output
  11158. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  11159. } else {
  11160. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  11161. utils.ErrorLog("解析失败:%v", err)
  11162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11163. return
  11164. }
  11165. }
  11166. if miConfig.Code == "H15049901371" {
  11167. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  11168. } else {
  11169. infocode = resThree.Infcode
  11170. }
  11171. }
  11172. if infocode != 0 {
  11173. adminUser := c.GetAdminUserInfo()
  11174. errlog := &models.HisOrderError{
  11175. UserOrgId: adminUser.CurrentOrgId,
  11176. Ctime: time.Now().Unix(),
  11177. Mtime: time.Now().Unix(),
  11178. ErrMsg: resThree.ErrMsg,
  11179. Status: 1,
  11180. PatientId: id,
  11181. RecordTime: recordDateTime,
  11182. Stage: 2,
  11183. }
  11184. service.CreateErrMsgLog(errlog)
  11185. c.ServeSuccessJSON(map[string]interface{}{
  11186. "failed_code": -10,
  11187. "msg": resThree.ErrMsg,
  11188. })
  11189. return
  11190. }
  11191. his.Number = resThree.Output.Data.MdtrtID
  11192. his.PsnNo = resThree.Output.Data.PsnNo
  11193. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  11194. his.IdCardNo = patient.IdCardNo
  11195. his.PhoneNumber = patient.Phone
  11196. his.UserOrgId = adminInfo.CurrentOrgId
  11197. his.Insutype = insutype
  11198. his.Ctime = time.Now().Unix()
  11199. his.Mtime = time.Now().Unix()
  11200. his.InsuplcAdmdvs = insuplc_admdvs_temp
  11201. his.Status = 1
  11202. his.MdtrtGrpType = mdtrt_type
  11203. service.UpdateHisPatientStatus(&his)
  11204. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  11205. c.ServeSuccessJSON(map[string]interface{}{
  11206. "his_info": his,
  11207. })
  11208. } else {
  11209. adminUser := c.GetAdminUserInfo()
  11210. errlog := &models.HisOrderError{
  11211. UserOrgId: adminUser.CurrentOrgId,
  11212. Ctime: time.Now().Unix(),
  11213. Mtime: time.Now().Unix(),
  11214. ErrMsg: res.ErrMsg,
  11215. Status: 1,
  11216. PatientId: id,
  11217. RecordTime: recordDateTime,
  11218. Stage: 1,
  11219. }
  11220. service.CreateErrMsgLog(errlog)
  11221. c.ServeSuccessJSON(map[string]interface{}{
  11222. "failed_code": -10,
  11223. "msg": res.ErrMsg,
  11224. })
  11225. return
  11226. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  11227. }
  11228. }
  11229. }
  11230. func (c *HisApiController) GetUploadInfo() {
  11231. id, _ := c.GetInt64("id")
  11232. record_time := c.GetString("record_time")
  11233. his_patient_id, _ := c.GetInt64("his_patient_id")
  11234. order_id, _ := c.GetInt64("order_id")
  11235. pay_way, _ := c.GetInt64("pay_way")
  11236. pay_ways := c.GetString("pay_ways")
  11237. oth_desc := c.GetString("oth_desc")
  11238. pay_price, _ := c.GetFloat("pay_price")
  11239. pay_card_no := c.GetString("pay_card_no")
  11240. discount_price, _ := c.GetFloat("discount_price")
  11241. preferential_price, _ := c.GetFloat("preferential_price")
  11242. reality_price, _ := c.GetFloat("reality_price")
  11243. found_price, _ := c.GetFloat("found_price")
  11244. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  11245. private_price, _ := c.GetFloat("private_price")
  11246. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  11247. admin_user_id, _ := c.GetInt64("admin_user_id")
  11248. fapiao_code := c.GetString("fapiao_code")
  11249. fapiao_number := c.GetString("fapiao_number")
  11250. diagnosis_id := c.GetString("diagnosis")
  11251. sick_type, _ := c.GetInt64("sick_type")
  11252. reg_type, _ := c.GetInt64("p_type")
  11253. begin_time := c.GetString("begin_time")
  11254. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  11255. cash_pay := c.GetString("cash_pay")
  11256. band_card_pay := c.GetString("band_card_pay")
  11257. wechat_pay := c.GetString("wechat_pay")
  11258. ali_pay := c.GetString("ali_pay")
  11259. jifen_pay := c.GetString("jifen_pay")
  11260. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  11261. fmt.Println(acct_used_flag)
  11262. id_str := c.GetString("ids")
  11263. ids_arr := strings.Split(id_str, ",")
  11264. timeLayout := "2006-01-02"
  11265. loc, _ := time.LoadLocation("Local")
  11266. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11267. if err != nil {
  11268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11269. return
  11270. }
  11271. recordDateTime := theTime.Unix()
  11272. adminUser := c.GetAdminUserInfo()
  11273. var tempOrder models.HisOrder
  11274. tempOrder, _ = service.GetHisOrderByID(order_id)
  11275. var prescriptions []*models.HisPrescription
  11276. var start_time int64
  11277. var end_time int64
  11278. //押金模块
  11279. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  11280. tmp_decimal := c.GetString("tmp_decimal")
  11281. var decimal float64 //本次使用的押金
  11282. var errmsg error
  11283. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  11284. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  11285. return
  11286. }
  11287. if len(tmp_decimal) > 0 {
  11288. if tmp_decimal[0] == 45 {
  11289. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  11290. return
  11291. }
  11292. }
  11293. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  11294. fmt.Println(errs)
  11295. decimal = tt
  11296. //if adminUser.CurrentOrgId == 10106{
  11297. // if len(fapiao_code) == 0{
  11298. // fapiao_code = "144072080589"
  11299. // }
  11300. // if len(fapiao_number) == 0{
  11301. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  11302. // if order.ID == 0{
  11303. // fapiao_number = "00001520"
  11304. // }else{
  11305. // //fapiao_code = "00001520"
  11306. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  11307. // var zero string
  11308. // if fpNumber >= 1000{
  11309. // zero = "0000" + strconv.Itoa(fpNumber)
  11310. // }else if fpNumber >= 10000{
  11311. // zero = "000" + strconv.Itoa(fpNumber)
  11312. // } else if fpNumber >= 100000{
  11313. // zero = "00" + strconv.Itoa(fpNumber)
  11314. // } else if fpNumber >= 1000000{
  11315. // zero = "0" + strconv.Itoa(fpNumber)
  11316. // }else {
  11317. // zero = strconv.Itoa(fpNumber)
  11318. // }
  11319. // fapiao_number = zero
  11320. // }
  11321. // }
  11322. //}
  11323. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11324. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11325. var patientPrescription models.HisPrescriptionInfo
  11326. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11327. if patientPrescription.ID == 0 {
  11328. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  11329. }
  11330. //if patientPrescription.Do
  11331. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11332. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11333. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11334. diagnosis_ids := strings.Split(diagnosis_id, ",")
  11335. var config []*models.HisXtDiagnoseConfig
  11336. for _, item := range diagnosis_ids {
  11337. id, _ := strconv.ParseInt(item, 10, 64)
  11338. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11339. config = append(config, &diagnosisConfig)
  11340. }
  11341. sickConfig, _ := service.FindSickById(sick_type)
  11342. //if tempOrder.ID == 0 {
  11343. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  11344. //}
  11345. if tempOrder.ID == 0 {
  11346. var result string
  11347. var requestLog string
  11348. var res2 ResultSix
  11349. var ressix10265 ResultSix10265
  11350. if miConfig.MdtrtareaAdmvs == "421300" {
  11351. data := make(map[string]interface{})
  11352. client := &http.Client{}
  11353. data["psn_no"] = his.PsnNo
  11354. data["mdtrt_id"] = his.Number
  11355. data["opter"] = roles.UserName
  11356. data["org_name"] = miConfig.OrgName
  11357. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11358. data["doctor_id"] = doctor_info.DoctorNumber
  11359. data["doctor_name"] = doctor_info.UserName
  11360. data["department"] = department.Name
  11361. data["fixmedins_code"] = miConfig.Code
  11362. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11363. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11364. data["secret_key"] = miConfig.SecretKey
  11365. data["sick_code"] = sickConfig.CountryCode
  11366. data["sick_name"] = sickConfig.ClassName
  11367. data["dept"] = strconv.FormatInt(department.ID, 10)
  11368. data["config"] = config
  11369. data["begin_time"] = begin_time
  11370. bytesData, _ := json.Marshal(data)
  11371. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  11372. resp, _ := client.Do(req)
  11373. defer resp.Body.Close()
  11374. body, ioErr := ioutil.ReadAll(resp.Body)
  11375. if ioErr != nil {
  11376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11378. return
  11379. }
  11380. var respJSON map[string]interface{}
  11381. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11384. return
  11385. }
  11386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11387. userJSONBytes, _ := json.Marshal(respJSON)
  11388. fmt.Println("log")
  11389. fmt.Println(string(userJSONBytes))
  11390. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11391. utils.ErrorLog("解析失败:%v", err)
  11392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11393. return
  11394. }
  11395. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11396. data := make(map[string]interface{})
  11397. client := &http.Client{}
  11398. data["psn_no"] = his.PsnNo
  11399. data["mdtrt_id"] = his.Number
  11400. data["doctor"] = roles.UserName
  11401. data["department"] = department.Name
  11402. data["org_name"] = miConfig.OrgName
  11403. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11404. data["doctor_id"] = doctor_info.DoctorNumber
  11405. data["new_doctor_name"] = doctor_info.UserName
  11406. data["fixmedins_code"] = miConfig.Code
  11407. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11408. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11409. data["secret_key"] = miConfig.SecretKey
  11410. data["sick_code"] = sickConfig.CountryCode
  11411. data["sick_name"] = sickConfig.ClassName
  11412. data["url"] = miConfig.Url
  11413. data["ak"] = miConfig.AccessKey
  11414. data["begin_time"] = begin_time
  11415. data["cainfo"] = miConfig.Cainfo
  11416. data["dept"] = strconv.FormatInt(department.ID, 10)
  11417. data["config"] = config
  11418. bytesData, _ := json.Marshal(data)
  11419. var req *http.Request
  11420. if miConfig.MdtrtareaAdmvs == "320921" {
  11421. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  11422. //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 +
  11423. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  11424. } else {
  11425. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  11426. }
  11427. resp, _ := client.Do(req)
  11428. defer resp.Body.Close()
  11429. body, ioErr := ioutil.ReadAll(resp.Body)
  11430. if ioErr != nil {
  11431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11433. return
  11434. }
  11435. var respJSON map[string]interface{}
  11436. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11439. return
  11440. }
  11441. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11442. userJSONBytes, _ := json.Marshal(respJSON)
  11443. fmt.Println("log")
  11444. fmt.Println(string(userJSONBytes))
  11445. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  11446. utils.ErrorLog("解析失败:%v", err)
  11447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11448. return
  11449. }
  11450. res2.InfRefmsgid = ressix10265.InfRefmsgid
  11451. res2.Output = ressix10265.Output
  11452. res2.ErrMsg = ressix10265.ErrMsg
  11453. res2.Cainfo = ressix10265.Cainfo
  11454. res2.WarnMsg = ressix10265.WarnMsg
  11455. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  11456. res2.Infcode = infocode
  11457. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11458. data := make(map[string]interface{})
  11459. client := &http.Client{}
  11460. data["psn_no"] = his.PsnNo
  11461. data["mdtrt_id"] = his.Number
  11462. data["doctor"] = roles.UserName
  11463. data["department"] = department.Name
  11464. data["org_name"] = miConfig.OrgName
  11465. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11466. data["doctor_id"] = doctor_info.DoctorNumber
  11467. data["new_doctor_name"] = doctor_info.UserName
  11468. data["fixmedins_code"] = miConfig.Code
  11469. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11470. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11471. data["secret_key"] = miConfig.SecretKey
  11472. data["sick_code"] = sickConfig.CountryCode
  11473. data["sick_name"] = sickConfig.ClassName
  11474. data["url"] = miConfig.Url
  11475. data["ak"] = miConfig.AccessKey
  11476. data["begin_time"] = begin_time
  11477. data["cainfo"] = miConfig.Cainfo
  11478. data["dept"] = strconv.FormatInt(department.ID, 10)
  11479. data["config"] = config
  11480. bytesData, _ := json.Marshal(data)
  11481. var req *http.Request
  11482. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  11483. resp, _ := client.Do(req)
  11484. defer resp.Body.Close()
  11485. body, ioErr := ioutil.ReadAll(resp.Body)
  11486. if ioErr != nil {
  11487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11489. return
  11490. }
  11491. var respJSON map[string]interface{}
  11492. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11495. return
  11496. }
  11497. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11498. userJSONBytes, _ := json.Marshal(respJSON)
  11499. fmt.Println("log")
  11500. fmt.Println(string(userJSONBytes))
  11501. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  11502. utils.ErrorLog("解析失败:%v", err)
  11503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11504. return
  11505. }
  11506. res2.InfRefmsgid = ressix10265.InfRefmsgid
  11507. res2.Output = ressix10265.Output
  11508. res2.ErrMsg = ressix10265.ErrMsg
  11509. res2.Cainfo = ressix10265.Cainfo
  11510. res2.WarnMsg = ressix10265.WarnMsg
  11511. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  11512. res2.Infcode = infocode
  11513. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11514. 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)
  11515. saveLog(result, requestLog, "2203", "上传就诊信息")
  11516. var respJSON2 map[string]interface{}
  11517. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11520. return
  11521. }
  11522. userJSONBytes2, _ := json.Marshal(respJSON2)
  11523. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11524. utils.ErrorLog("解析失败:%v", err)
  11525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11526. return
  11527. }
  11528. 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)
  11529. fmt.Println(result2)
  11530. fmt.Println(src_request)
  11531. } else {
  11532. if miConfig.MdtrtareaAdmvs == "440781" { //
  11533. 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)
  11534. } else {
  11535. if miConfig.Code == "H15049901371" {
  11536. //赤峰地区国家医保医疗类别
  11537. //职工透析:医疗类别选特殊情况门诊990502
  11538. //居民定额血透门慢: 医疗类别选门诊慢病140104
  11539. var med_type string
  11540. if his.Insutype == "390" {
  11541. if reg_type == 14 {
  11542. med_type = "9933"
  11543. } else if reg_type == 11 {
  11544. med_type = "11"
  11545. }
  11546. } else if his.Insutype == "310" {
  11547. if reg_type == 14 {
  11548. med_type = "990502"
  11549. } else if reg_type == 11 {
  11550. med_type = "11"
  11551. }
  11552. }
  11553. 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)
  11554. } else {
  11555. 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)
  11556. }
  11557. }
  11558. saveLog(result, requestLog, "2203", "上传就诊信息")
  11559. var respJSON2 map[string]interface{}
  11560. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11563. return
  11564. }
  11565. userJSONBytes2, _ := json.Marshal(respJSON2)
  11566. if miConfig.Code == "H15049901371" {
  11567. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  11568. utils.ErrorLog("解析失败:%v", err)
  11569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11570. return
  11571. }
  11572. res2.InfRefmsgid = ressix10265.InfRefmsgid
  11573. res2.Output = ressix10265.Output
  11574. res2.ErrMsg = ressix10265.ErrMsg
  11575. res2.Cainfo = ressix10265.Cainfo
  11576. res2.WarnMsg = ressix10265.WarnMsg
  11577. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  11578. res2.Infcode = infocode
  11579. } else {
  11580. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11581. utils.ErrorLog("解析失败:%v", err)
  11582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11583. return
  11584. }
  11585. }
  11586. }
  11587. if res2.Infcode != 0 {
  11588. adminUser := c.GetAdminUserInfo()
  11589. errlog := &models.HisOrderError{
  11590. UserOrgId: adminUser.CurrentOrgId,
  11591. Ctime: time.Now().Unix(),
  11592. Mtime: time.Now().Unix(),
  11593. ErrMsg: res2.ErrMsg,
  11594. Status: 1,
  11595. PatientId: id,
  11596. RecordTime: recordDateTime,
  11597. Stage: 3,
  11598. }
  11599. service.CreateErrMsgLog(errlog)
  11600. c.ServeSuccessJSON(map[string]interface{}{
  11601. "failed_code": -10,
  11602. "msg": res2.ErrMsg,
  11603. })
  11604. return
  11605. } else {
  11606. his.Diagnosis = diagnosis_id
  11607. his.SickType = sickConfig.ID
  11608. //var p_type int64
  11609. //if reg_type == 1111 || reg_type == 1112 {
  11610. // p_type = 11
  11611. //
  11612. //}
  11613. his.PType = fmt.Sprintf("%d", reg_type)
  11614. service.UpdateHisPatientThree(&his)
  11615. data := make(map[string]interface{})
  11616. if settle_accounts_type == 1 { //日结
  11617. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  11618. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  11619. } else {
  11620. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  11621. }
  11622. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  11623. data["pre"] = prescriptions
  11624. } else { //月结
  11625. start_time_str := c.GetString("start_time")
  11626. end_time_str := c.GetString("end_time")
  11627. timeLayout := "2006-01-02"
  11628. loc, _ := time.LoadLocation("Local")
  11629. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  11630. if err != nil {
  11631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11632. return
  11633. }
  11634. recordStartTime := theStartTime.Unix()
  11635. start_time = recordStartTime
  11636. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  11637. if err != nil {
  11638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11639. return
  11640. }
  11641. recordEndTime := theEndTime.Unix()
  11642. end_time = recordEndTime
  11643. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  11644. data["pre"] = prescriptions
  11645. }
  11646. timestamp := time.Now().Unix()
  11647. tempTime := time.Unix(timestamp, 0)
  11648. timeFormat := tempTime.Format("20060102150405")
  11649. chrgBchno := rand.Intn(100000) + 10000
  11650. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  11651. strconv.FormatInt(his.PatientId, 10)
  11652. client := &http.Client{}
  11653. data["psn_no"] = his.PsnNo
  11654. data["mdtrt_id"] = his.Number
  11655. data["chrg_bchno"] = chrg_bchno
  11656. data["org_name"] = miConfig.OrgName
  11657. data["doctor"] = doctor_info.UserName
  11658. data["doctor_id"] = doctor_info.DoctorNumber
  11659. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  11660. data["fixmedins_code"] = miConfig.Code
  11661. data["opter"] = roles.UserName
  11662. data["dept_code"] = department.Number
  11663. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11664. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11665. data["secret_key"] = miConfig.SecretKey
  11666. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  11667. data["url"] = miConfig.Url
  11668. data["ak"] = miConfig.AccessKey
  11669. data["new_doctor_name"] = patientPrescription.Doctor
  11670. data["diag_code"] = sickConfig.CountryCode
  11671. data["cainfo"] = miConfig.Cainfo
  11672. data["opter"] = roles.UserName
  11673. var ids []int64
  11674. for _, item := range prescriptions {
  11675. ids = append(ids, item.ID)
  11676. }
  11677. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11678. if config.IsOpen == 1 { //对接了医保,走医保流程
  11679. var res ResultFour
  11680. var resFour10265 ResultFour10265
  11681. if miConfig.MdtrtareaAdmvs == "421300" {
  11682. bytesData, _ := json.Marshal(data)
  11683. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  11684. resp, _ := client.Do(req)
  11685. defer resp.Body.Close()
  11686. body, ioErr := ioutil.ReadAll(resp.Body)
  11687. if ioErr != nil {
  11688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11690. return
  11691. }
  11692. var respJSON map[string]interface{}
  11693. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11696. return
  11697. }
  11698. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11699. userJSONBytes, _ := json.Marshal(respJSON)
  11700. fmt.Println("log")
  11701. fmt.Println(string(userJSONBytes))
  11702. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11703. utils.ErrorLog("解析失败:%v", err)
  11704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11705. return
  11706. }
  11707. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11708. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  11709. if result3101.Infcode == "0" {
  11710. if len(result3101.Output.Result) > 0 {
  11711. var errMsgs []string
  11712. for _, item := range result3101.Output.Result {
  11713. errMsgs = append(errMsgs, item.VolaCont)
  11714. }
  11715. c.ServeSuccessJSON(map[string]interface{}{
  11716. "failed_code": -10,
  11717. "msg": errMsgs,
  11718. })
  11719. return
  11720. }
  11721. }
  11722. if miConfig.MdtrtareaAdmvs == "320921" {
  11723. data["doctor_id"] = "D320923012139"
  11724. } else {
  11725. data["doctor_id"] = "D371621008686"
  11726. }
  11727. bytesData, _ := json.Marshal(data)
  11728. var req *http.Request
  11729. if miConfig.MdtrtareaAdmvs == "320921" {
  11730. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11731. } else {
  11732. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11733. }
  11734. resp, _ := client.Do(req)
  11735. defer resp.Body.Close()
  11736. body, ioErr := ioutil.ReadAll(resp.Body)
  11737. if ioErr != nil {
  11738. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11740. return
  11741. }
  11742. var respJSON map[string]interface{}
  11743. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11746. return
  11747. }
  11748. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11749. userJSONBytes, _ := json.Marshal(respJSON)
  11750. fmt.Println("log")
  11751. fmt.Println(string(userJSONBytes))
  11752. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11753. utils.ErrorLog("解析失败:%v", err)
  11754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11755. return
  11756. }
  11757. res.InfRefmsgid = resFour10265.InfRefmsgid
  11758. res.Output = resFour10265.Output
  11759. res.ErrMsg = resFour10265.ErrMsg
  11760. res.Cainfo = resFour10265.Cainfo
  11761. res.WarnMsg = resFour10265.WarnMsg
  11762. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11763. res.Infcode = infocode
  11764. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11765. data["doctor_id"] = doctor_info.DoctorNumber
  11766. bytesData, _ := json.Marshal(data)
  11767. var req *http.Request
  11768. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  11769. resp, _ := client.Do(req)
  11770. defer resp.Body.Close()
  11771. body, ioErr := ioutil.ReadAll(resp.Body)
  11772. if ioErr != nil {
  11773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11775. return
  11776. }
  11777. var respJSON map[string]interface{}
  11778. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11781. return
  11782. }
  11783. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11784. userJSONBytes, _ := json.Marshal(respJSON)
  11785. fmt.Println("log")
  11786. fmt.Println(string(userJSONBytes))
  11787. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11788. utils.ErrorLog("解析失败:%v", err)
  11789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11790. return
  11791. }
  11792. res.InfRefmsgid = resFour10265.InfRefmsgid
  11793. res.Output = resFour10265.Output
  11794. res.ErrMsg = resFour10265.ErrMsg
  11795. res.Cainfo = resFour10265.Cainfo
  11796. res.WarnMsg = resFour10265.WarnMsg
  11797. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11798. res.Infcode = infocode
  11799. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11800. 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)
  11801. var dat map[string]interface{}
  11802. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11803. fmt.Println(dat)
  11804. } else {
  11805. fmt.Println(err)
  11806. }
  11807. saveLog(result, request_log, "2204", "上传费用明细")
  11808. userJSONBytes, _ := json.Marshal(dat)
  11809. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11810. utils.ErrorLog("解析失败:%v", err)
  11811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11812. return
  11813. }
  11814. res.InfRefmsgid = resFour10265.InfRefmsgid
  11815. res.Output = resFour10265.Output
  11816. res.ErrMsg = resFour10265.ErrMsg
  11817. res.Cainfo = resFour10265.Cainfo
  11818. res.WarnMsg = resFour10265.WarnMsg
  11819. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11820. res.Infcode = infocode
  11821. } else {
  11822. if miConfig.Code == "H15049901371" {
  11823. 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)
  11824. var dat map[string]interface{}
  11825. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11826. fmt.Println(dat)
  11827. } else {
  11828. fmt.Println(err)
  11829. }
  11830. saveLog(result, request_log, "2204", "上传费用明细")
  11831. userJSONBytes, _ := json.Marshal(dat)
  11832. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11833. utils.ErrorLog("解析失败:%v", err)
  11834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11835. return
  11836. }
  11837. res.InfRefmsgid = resFour10265.InfRefmsgid
  11838. res.Output = resFour10265.Output
  11839. res.ErrMsg = resFour10265.ErrMsg
  11840. res.Cainfo = resFour10265.Cainfo
  11841. res.WarnMsg = resFour10265.WarnMsg
  11842. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11843. res.Infcode = infocode
  11844. } else {
  11845. 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)
  11846. var dat map[string]interface{}
  11847. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11848. fmt.Println(dat)
  11849. } else {
  11850. fmt.Println(err)
  11851. }
  11852. saveLog(result, request_log, "2204", "上传费用明细")
  11853. userJSONBytes, _ := json.Marshal(dat)
  11854. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11855. utils.ErrorLog("解析失败:%v", err)
  11856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11857. return
  11858. }
  11859. }
  11860. }
  11861. if res.Infcode == 0 {
  11862. order := &models.HisOrder{
  11863. UserOrgId: adminUser.CurrentOrgId,
  11864. HisPatientId: his.ID,
  11865. PatientId: his.PatientId,
  11866. SettleAccountsDate: recordDateTime,
  11867. MdtrtId: his.Number,
  11868. PsnNo: his.PsnNo,
  11869. MedType: strconv.FormatInt(reg_type, 10),
  11870. Ctime: time.Now().Unix(),
  11871. Mtime: time.Now().Unix(),
  11872. Status: 1,
  11873. Number: chrg_bchno,
  11874. Infcode: res.Infcode,
  11875. WarnMsg: res.WarnMsg,
  11876. Cainfo: res.Cainfo,
  11877. ErrMsg: res.ErrMsg,
  11878. RespondTime: res.RefmsgTime,
  11879. InfRefmsgid: res.InfRefmsgid,
  11880. OrderStatus: 1,
  11881. PayWay: pay_way,
  11882. PayWays: pay_ways,
  11883. OthDesc: oth_desc,
  11884. PayPrice: pay_price,
  11885. PayCardNo: pay_card_no,
  11886. DiscountPrice: discount_price,
  11887. PreferentialPrice: preferential_price,
  11888. RealityPrice: reality_price,
  11889. FoundPrice: found_price,
  11890. MedicalInsurancePrice: medical_insurance_price,
  11891. PrivatePrice: private_price,
  11892. IsMedicineInsurance: 1,
  11893. SettleType: settle_accounts_type,
  11894. SettleStartTime: start_time,
  11895. SettleEndTime: end_time,
  11896. Creator: roles.AdminUserId,
  11897. Modify: roles.AdminUserId,
  11898. FaPiaoNumber: fapiao_number,
  11899. FaPiaoCode: fapiao_code,
  11900. PType: 2,
  11901. Diagnosis: diagnosis_id,
  11902. CashPay: cash_pay,
  11903. WechatPay: wechat_pay,
  11904. AliPay: ali_pay,
  11905. JifenPay: jifen_pay,
  11906. BandCardPay: band_card_pay,
  11907. }
  11908. err = service.CreateOrder(order)
  11909. if err != nil {
  11910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  11911. return
  11912. }
  11913. for _, item := range res.Output.Result {
  11914. temp := strings.Split(item.FeedetlSn, "-")
  11915. var advice_id int64 = 0
  11916. var project_id int64 = 0
  11917. var types int64 = 0
  11918. id, _ := strconv.ParseInt(temp[2], 10, 64)
  11919. types, _ = strconv.ParseInt(temp[1], 10, 64)
  11920. if temp[1] == "1" {
  11921. advice_id = id
  11922. project_id = 0
  11923. } else if temp[1] == "2" {
  11924. advice_id = 0
  11925. project_id = id
  11926. }
  11927. if item.MedChrgitmType == "9" {
  11928. item.MedChrgitmType = "09"
  11929. }
  11930. info := &models.HisOrderInfo{
  11931. OrderNumber: order.Number,
  11932. FeedetlSn: item.FeedetlSn,
  11933. UploadDate: time.Now().Unix(),
  11934. AdviceId: advice_id,
  11935. DetItemFeeSumamt: item.DetItemFeeSumamt,
  11936. Cnt: item.Cnt,
  11937. Pric: float64(item.Pric),
  11938. PatientId: his.PatientId,
  11939. PricUplmtAmt: item.PricUplmtAmt,
  11940. SelfpayProp: item.SelfpayProp,
  11941. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  11942. OverlmtAmt: item.OverlmtAmt,
  11943. PreselfpayAmt: item.PreselfpayAmt,
  11944. BasMednFlag: item.BasMednFlag,
  11945. MedChrgitmType: item.MedChrgitmType,
  11946. HiNegoDrugFlag: item.HiNegoDrugFlag,
  11947. Status: 1,
  11948. Memo: item.Memo,
  11949. Mtime: time.Now().Unix(),
  11950. InscpScpAmt: item.InscpScpAmt,
  11951. DrtReimFlag: item.DrtReimFlag,
  11952. Ctime: time.Now().Unix(),
  11953. ListSpItemFlag: item.ListSpItemFlag,
  11954. ChldMedcFlag: item.ChldMedcFlag,
  11955. LmtUsedFlag: item.LmtUsedFlag,
  11956. ChrgitmLv: item.ChrgitmLv,
  11957. UserOrgId: adminUser.CurrentOrgId,
  11958. HisPatientId: his.ID,
  11959. OrderId: order.ID,
  11960. ProjectId: project_id,
  11961. Type: types,
  11962. }
  11963. service.CreateOrderInfo(info)
  11964. }
  11965. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11966. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  11967. var total float64
  11968. for _, item := range prescriptions {
  11969. if item.Type == 1 { //药品
  11970. for _, subItem := range item.HisDoctorAdviceInfo {
  11971. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  11972. total_one := price * subItem.PrescribingNumber
  11973. total = total + total_one
  11974. }
  11975. }
  11976. if item.Type == 2 { //项目
  11977. for _, subItem := range item.HisPrescriptionProject {
  11978. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11979. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  11980. total_one := price * cnt
  11981. total = total + total_one
  11982. }
  11983. }
  11984. }
  11985. allTotal := fmt.Sprintf("%f", total)
  11986. //if adminUser.CurrentOrgId == 9919 {
  11987. //
  11988. // allTotal = fmt.Sprintf("%.2f", total)
  11989. //
  11990. //} else {
  11991. //
  11992. // allTotal = fmt.Sprintf("%.2f", total)
  11993. //
  11994. //}
  11995. if res.Infcode == 0 {
  11996. var rf []*ResultFive
  11997. json.Unmarshal([]byte(his.Iinfo), &rf)
  11998. chrg_bchno := chrg_bchno
  11999. cert_no := his.Certno
  12000. var insutypes []string
  12001. var insutype string
  12002. var is390 int = 0
  12003. var is310 int = 0
  12004. for _, item := range rf {
  12005. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12006. insutypes = append(insutypes, item.Insutype)
  12007. }
  12008. }
  12009. if len(insutypes) == 1 {
  12010. insutype = insutypes[0]
  12011. } else {
  12012. for _, i := range insutypes {
  12013. if i == "390" {
  12014. is390 = 1
  12015. }
  12016. if i == "310" {
  12017. is310 = 1
  12018. }
  12019. }
  12020. }
  12021. if is390 == 1 {
  12022. insutype = "390"
  12023. }
  12024. if is310 == 1 {
  12025. insutype = "310"
  12026. }
  12027. if len(insutypes) == 0 {
  12028. insutype = "310"
  12029. }
  12030. if len(insutypes) == 2 {
  12031. insutype = strconv.FormatInt(his.SocialType, 10)
  12032. }
  12033. insutype = strconv.FormatInt(his.SocialType, 10)
  12034. //insutype = "390"
  12035. if his.IdCardType == 1 {
  12036. // cert_no = his.MedicalInsuranceNumber
  12037. cert_no = his.Certno
  12038. } else {
  12039. cert_no = his.Certno
  12040. }
  12041. var res ResultSeven
  12042. var resSeven10265 ResultSeven10265
  12043. var src_resquest string
  12044. var result2 string
  12045. if miConfig.MdtrtareaAdmvs == "421300" {
  12046. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12047. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12048. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12049. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12050. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12051. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12052. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  12053. resp, requestErr := http.Get(api)
  12054. if requestErr != nil {
  12055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12056. return
  12057. }
  12058. body, ioErr := ioutil.ReadAll(resp.Body)
  12059. if ioErr != nil {
  12060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12062. return
  12063. }
  12064. var respJSON map[string]interface{}
  12065. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12068. return
  12069. }
  12070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12071. result, _ := json.Marshal(respJSON)
  12072. if miConfig.Code == "H15049901371" {
  12073. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  12074. utils.ErrorLog("解析失败:%v", err)
  12075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12076. return
  12077. }
  12078. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12079. res.Output = resSeven10265.Output
  12080. res.ErrMsg = resSeven10265.ErrMsg
  12081. res.Cainfo = resSeven10265.Cainfo
  12082. res.WarnMsg = resSeven10265.WarnMsg
  12083. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12084. res.Infcode = infocode
  12085. } else {
  12086. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12087. utils.ErrorLog("解析失败:%v", err)
  12088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12089. return
  12090. }
  12091. }
  12092. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12093. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  12094. if result3101.Infcode == "0" {
  12095. if len(result3101.Output.Result) > 0 {
  12096. var errMsgs []string
  12097. for _, item := range result3101.Output.Result {
  12098. errMsgs = append(errMsgs, item.VolaCont)
  12099. }
  12100. c.ServeSuccessJSON(map[string]interface{}{
  12101. "failed_code": -10,
  12102. "msg": errMsgs,
  12103. })
  12104. return
  12105. } else {
  12106. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12107. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  12108. bas := strings.Split(psn_info.CardInfo, "|")
  12109. if his.IdCardType == 1 {
  12110. cert_no = bas[2]
  12111. } else if his.IdCardType == 3 {
  12112. cert_no = his.Certno
  12113. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  12114. } else if his.IdCardType == 4 {
  12115. cert_no = his.Certno
  12116. psn_info.VerifyNumber = psn_info.VerifyNumber
  12117. }
  12118. var api string
  12119. if miConfig.MdtrtareaAdmvs == "320921" {
  12120. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12121. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12122. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12123. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12124. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12125. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12126. "&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
  12127. } else {
  12128. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12129. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12130. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12131. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12132. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12133. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12134. "&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
  12135. }
  12136. resp, requestErr := http.Get(api)
  12137. if requestErr != nil {
  12138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12139. return
  12140. }
  12141. body, ioErr := ioutil.ReadAll(resp.Body)
  12142. if ioErr != nil {
  12143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12145. return
  12146. }
  12147. var respJSON map[string]interface{}
  12148. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12151. return
  12152. }
  12153. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12154. result, _ := json.Marshal(respJSON)
  12155. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  12156. utils.ErrorLog("解析失败:%v", err)
  12157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12158. return
  12159. }
  12160. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12161. res.Output = resSeven10265.Output
  12162. res.ErrMsg = resSeven10265.ErrMsg
  12163. res.Cainfo = resSeven10265.Cainfo
  12164. res.WarnMsg = resSeven10265.WarnMsg
  12165. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12166. res.Infcode = infocode
  12167. }
  12168. }
  12169. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12170. psn_info, _ := service.GetPsnByPatientId(id)
  12171. var verify_number string
  12172. if psn_info.IdCardType == 4 {
  12173. verify_number = psn_info.VerifyNumber
  12174. } else if psn_info.IdCardType == 1 {
  12175. bas := strings.Split(psn_info.CardInfo, "|")
  12176. cardNumber := bas[2]
  12177. verify_number = cardNumber
  12178. } else {
  12179. psn_info.IdCardType = 2
  12180. verify_number = psn_info.Certno
  12181. }
  12182. var api string
  12183. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12184. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12185. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12186. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12187. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12188. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12189. "&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
  12190. resp, requestErr := http.Get(api)
  12191. if requestErr != nil {
  12192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12193. return
  12194. }
  12195. body, ioErr := ioutil.ReadAll(resp.Body)
  12196. if ioErr != nil {
  12197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12199. return
  12200. }
  12201. var respJSON map[string]interface{}
  12202. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12205. return
  12206. }
  12207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12208. result, _ := json.Marshal(respJSON)
  12209. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  12210. utils.ErrorLog("解析失败:%v", err)
  12211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12212. return
  12213. }
  12214. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12215. res.Output = resSeven10265.Output
  12216. res.ErrMsg = resSeven10265.ErrMsg
  12217. res.Cainfo = resSeven10265.Cainfo
  12218. res.WarnMsg = resSeven10265.WarnMsg
  12219. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12220. res.Infcode = infocode
  12221. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12222. var cert_no string
  12223. if his.IdCardType == 4 {
  12224. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12225. cert_no = psn_info.VerifyNumber
  12226. 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)
  12227. } else if his.IdCardType == 1 {
  12228. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12229. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  12230. 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)
  12231. }
  12232. //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)
  12233. var dat map[string]interface{}
  12234. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12235. fmt.Println(dat)
  12236. } else {
  12237. fmt.Println(err)
  12238. }
  12239. saveLog(result2, src_resquest, "2207", "结算")
  12240. userJSONBytes, _ := json.Marshal(dat)
  12241. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  12242. utils.ErrorLog("解析失败:%v", err)
  12243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12244. return
  12245. }
  12246. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12247. res.Output = resSeven10265.Output
  12248. res.ErrMsg = resSeven10265.ErrMsg
  12249. res.Cainfo = resSeven10265.Cainfo
  12250. res.WarnMsg = resSeven10265.WarnMsg
  12251. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12252. res.Infcode = infocode
  12253. } else {
  12254. if miConfig.Code == "H15049901371" {
  12255. //赤峰地区国家医保医疗类别
  12256. //职工透析:医疗类别选特殊情况门诊990502
  12257. //居民定额血透门慢: 医疗类别选门诊慢病140104
  12258. var med_type string
  12259. if his.Insutype == "390" {
  12260. if reg_type == 14 {
  12261. med_type = "9933"
  12262. } else if reg_type == 11 {
  12263. med_type = "11"
  12264. }
  12265. } else if his.Insutype == "310" {
  12266. if reg_type == 14 {
  12267. med_type = "990502"
  12268. } else if reg_type == 11 {
  12269. med_type = "11"
  12270. }
  12271. }
  12272. 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, "")
  12273. } else {
  12274. if his.IdCardType == 4 {
  12275. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12276. var token string
  12277. token = psn_info.VerifyNumber
  12278. 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)
  12279. } else {
  12280. 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, "")
  12281. }
  12282. }
  12283. //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)
  12284. var dat map[string]interface{}
  12285. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12286. fmt.Println(dat)
  12287. } else {
  12288. fmt.Println(err)
  12289. }
  12290. saveLog(result2, src_resquest, "2207", "结算")
  12291. userJSONBytes, _ := json.Marshal(dat)
  12292. if miConfig.Code == "H15049901371" {
  12293. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  12294. utils.ErrorLog("解析失败:%v", err)
  12295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12296. return
  12297. }
  12298. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12299. res.Output = resSeven10265.Output
  12300. res.ErrMsg = resSeven10265.ErrMsg
  12301. res.Cainfo = resSeven10265.Cainfo
  12302. res.WarnMsg = resSeven10265.WarnMsg
  12303. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12304. res.Infcode = infocode
  12305. } else {
  12306. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12307. utils.ErrorLog("解析失败:%v", err)
  12308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12309. return
  12310. }
  12311. }
  12312. }
  12313. if res.Infcode != 0 {
  12314. errlog := &models.HisOrderError{
  12315. UserOrgId: adminUser.CurrentOrgId,
  12316. Ctime: time.Now().Unix(),
  12317. Mtime: time.Now().Unix(),
  12318. Number: chrg_bchno,
  12319. ErrMsg: res.ErrMsg,
  12320. Status: 1,
  12321. PatientId: id,
  12322. RecordTime: recordDateTime,
  12323. Stage: 6,
  12324. }
  12325. service.CreateErrMsgLog(errlog)
  12326. c.ServeSuccessJSON(map[string]interface{}{
  12327. "failed_code": -10,
  12328. "msg": res.ErrMsg,
  12329. })
  12330. return
  12331. } else {
  12332. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  12333. order.OrderStatus = 2
  12334. order.Status = 1
  12335. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  12336. order.SetlId = res.Output.Setlinfo.SetlID
  12337. order.PsnNo = res.Output.Setlinfo.PsnNo
  12338. order.PsnName = res.Output.Setlinfo.PsnName
  12339. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  12340. order.Certno = res.Output.Setlinfo.Certno
  12341. order.Gend = res.Output.Setlinfo.Gend
  12342. order.Naty = res.Output.Setlinfo.Naty
  12343. order.Age = res.Output.Setlinfo.Age
  12344. order.Insutype = res.Output.Setlinfo.Insutype
  12345. order.PsnType = res.Output.Setlinfo.PsnType
  12346. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  12347. order.SetlTime = res.Output.Setlinfo.SetlTime
  12348. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  12349. if res.Output.Setlinfo.MedType == "140101" {
  12350. order.MedType = "14"
  12351. } else {
  12352. order.MedType = res.Output.Setlinfo.MedType
  12353. }
  12354. if reg_type == 1112 {
  12355. order.MedType = "1112"
  12356. }
  12357. if reg_type == 1111 {
  12358. order.MedType = "1111"
  12359. }
  12360. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  12361. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  12362. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  12363. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  12364. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  12365. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  12366. order.HifpPay = res.Output.Setlinfo.HifpPay
  12367. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  12368. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  12369. order.HifesPay = res.Output.Setlinfo.HifesPay
  12370. order.HifobPay = res.Output.Setlinfo.HifobPay
  12371. order.MafPay = res.Output.Setlinfo.MafPay
  12372. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  12373. order.OthPay = res.Output.Setlinfo.OthPay
  12374. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  12375. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  12376. order.AcctPay = res.Output.Setlinfo.AcctPay
  12377. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  12378. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  12379. order.Balc = res.Output.Setlinfo.Balc
  12380. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  12381. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  12382. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  12383. order.ClrType = res.Output.Setlinfo.ClrType
  12384. order.ClrWay = res.Output.Setlinfo.ClrWay
  12385. order.Creator = order.Creator
  12386. order.Modify = roles.AdminUserId
  12387. order.RequestLog = src_resquest
  12388. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  12389. detailStr := string(setlDetail)
  12390. order.SetlDetail = detailStr
  12391. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  12392. err = service.UpDateOrder(order)
  12393. if err == nil {
  12394. //判断是否使用了押金
  12395. if dec_way == "true" {
  12396. tmpstring := strconv.FormatInt(order.ID, 10)
  12397. order.Decimal = decimal
  12398. service.UpDateOrder(order)
  12399. //扣押金
  12400. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  12401. if errmsg != nil {
  12402. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  12403. return
  12404. }
  12405. }
  12406. c.ServeSuccessJSON(map[string]interface{}{
  12407. "msg": "结算成功",
  12408. })
  12409. } else {
  12410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  12411. return
  12412. }
  12413. }
  12414. } else {
  12415. adminUser := c.GetAdminUserInfo()
  12416. errlog := &models.HisOrderError{
  12417. UserOrgId: adminUser.CurrentOrgId,
  12418. Ctime: time.Now().Unix(),
  12419. Mtime: time.Now().Unix(),
  12420. ErrMsg: res.ErrMsg,
  12421. Status: 1,
  12422. PatientId: id,
  12423. RecordTime: recordDateTime,
  12424. Stage: 4,
  12425. }
  12426. service.CreateErrMsgLog(errlog)
  12427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  12428. return
  12429. }
  12430. } else {
  12431. adminUser := c.GetAdminUserInfo()
  12432. errlog := &models.HisOrderError{
  12433. UserOrgId: adminUser.CurrentOrgId,
  12434. Ctime: time.Now().Unix(),
  12435. Mtime: time.Now().Unix(),
  12436. ErrMsg: res.ErrMsg,
  12437. Status: 1,
  12438. PatientId: id,
  12439. RecordTime: recordDateTime,
  12440. Stage: 4,
  12441. }
  12442. service.CreateErrMsgLog(errlog)
  12443. c.ServeSuccessJSON(map[string]interface{}{
  12444. "failed_code": -10,
  12445. "msg": res.ErrMsg,
  12446. })
  12447. return
  12448. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  12449. //return
  12450. }
  12451. }
  12452. }
  12453. } else if tempOrder.ID > 0 {
  12454. if tempOrder.IsPre == 1 {
  12455. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  12456. var rf []*ResultFive
  12457. json.Unmarshal([]byte(his.Iinfo), &rf)
  12458. chrg_bchno := tempOrder.Number
  12459. cert_no := his.Certno
  12460. var insutypes []string
  12461. var insutype string
  12462. var is390 int = 0
  12463. var is310 int = 0
  12464. for _, item := range rf {
  12465. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12466. insutypes = append(insutypes, item.Insutype)
  12467. }
  12468. }
  12469. if len(insutypes) == 1 {
  12470. insutype = insutypes[0]
  12471. } else {
  12472. for _, i := range insutypes {
  12473. if i == "390" {
  12474. is390 = 1
  12475. }
  12476. if i == "310" {
  12477. is310 = 1
  12478. }
  12479. }
  12480. }
  12481. if is390 == 1 {
  12482. insutype = "390"
  12483. }
  12484. if is310 == 1 {
  12485. insutype = "310"
  12486. }
  12487. if len(insutypes) == 0 {
  12488. insutype = "310"
  12489. }
  12490. if len(insutypes) == 2 {
  12491. insutype = strconv.FormatInt(his.SocialType, 10)
  12492. }
  12493. //insutype = "390"
  12494. if his.IdCardType == 1 {
  12495. // cert_no = his.MedicalInsuranceNumber
  12496. cert_no = his.Certno
  12497. } else {
  12498. cert_no = his.Certno
  12499. }
  12500. var res ResultSeven
  12501. var resSeven10265 ResultSeven10265
  12502. var src_resquest string
  12503. var result2 string
  12504. if miConfig.MdtrtareaAdmvs == "421300" {
  12505. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12506. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12507. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12508. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12509. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12510. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12511. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  12512. resp, requestErr := http.Get(api)
  12513. if requestErr != nil {
  12514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12515. return
  12516. }
  12517. body, ioErr := ioutil.ReadAll(resp.Body)
  12518. if ioErr != nil {
  12519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12521. return
  12522. }
  12523. var respJSON map[string]interface{}
  12524. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12527. return
  12528. }
  12529. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12530. result, _ := json.Marshal(respJSON)
  12531. fmt.Println("log")
  12532. fmt.Println(string(result))
  12533. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12534. utils.ErrorLog("解析失败:%v", err)
  12535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12536. return
  12537. }
  12538. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12539. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  12540. if result3101.Infcode == "0" {
  12541. if len(result3101.Output.Result) > 0 {
  12542. var errMsgs []string
  12543. for _, item := range result3101.Output.Result {
  12544. errMsgs = append(errMsgs, item.VolaCont)
  12545. }
  12546. c.ServeSuccessJSON(map[string]interface{}{
  12547. "failed_code": -10,
  12548. "msg": errMsgs,
  12549. })
  12550. return
  12551. } else {
  12552. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12553. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  12554. bas := strings.Split(psn_info.CardInfo, "|")
  12555. if his.IdCardType == 1 {
  12556. cert_no = bas[2]
  12557. } else if his.IdCardType == 3 {
  12558. cert_no = his.Certno
  12559. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  12560. } else if his.IdCardType == 4 {
  12561. cert_no = his.Certno
  12562. psn_info.VerifyNumber = psn_info.VerifyNumber
  12563. }
  12564. //江苏地区国家医保医疗类别
  12565. //职工透析:医疗类别选特殊情况门诊9933
  12566. //居民血透门慢: 医疗类别选门诊慢病1402
  12567. //var med_type string
  12568. //if his.Insutype == "310" {
  12569. // if reg_type == 14 {
  12570. // med_type = "9933"
  12571. // } else if reg_type == 11 {
  12572. // med_type = "11"
  12573. //
  12574. // }
  12575. //} else if his.Insutype == "390" {
  12576. // if reg_type == 14 {
  12577. // med_type = "1402"
  12578. // } else if reg_type == 11 {
  12579. // med_type = "11"
  12580. // }
  12581. //}
  12582. var api string
  12583. if miConfig.MdtrtareaAdmvs == "320921" {
  12584. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12585. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12586. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12587. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12588. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12589. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12590. "&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
  12591. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12592. } else {
  12593. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12594. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12595. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12596. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12597. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12598. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12599. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12600. "&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
  12601. }
  12602. resp, requestErr := http.Get(api)
  12603. if requestErr != nil {
  12604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12605. return
  12606. }
  12607. body, ioErr := ioutil.ReadAll(resp.Body)
  12608. if ioErr != nil {
  12609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12611. return
  12612. }
  12613. var respJSON map[string]interface{}
  12614. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12617. return
  12618. }
  12619. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12620. result, _ := json.Marshal(respJSON)
  12621. fmt.Println("log")
  12622. fmt.Println(string(result))
  12623. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  12624. utils.ErrorLog("解析失败:%v", err)
  12625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12626. return
  12627. }
  12628. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12629. res.Output = resSeven10265.Output
  12630. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12631. res.ErrMsg = resSeven10265.ErrMsg
  12632. res.Cainfo = resSeven10265.Cainfo
  12633. res.WarnMsg = resSeven10265.WarnMsg
  12634. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12635. res.Infcode = infocode
  12636. }
  12637. }
  12638. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12639. psn_info, _ := service.GetPsnByPatientId(id)
  12640. var verify_number string
  12641. if psn_info.IdCardType == 4 {
  12642. verify_number = psn_info.VerifyNumber
  12643. } else if psn_info.IdCardType == 1 {
  12644. bas := strings.Split(psn_info.CardInfo, "|")
  12645. cardNumber := bas[2]
  12646. verify_number = cardNumber
  12647. } else {
  12648. verify_number = psn_info.Certno
  12649. psn_info.IdCardType = 2
  12650. }
  12651. var api string
  12652. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12653. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12654. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12655. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12656. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  12657. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12658. "&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
  12659. resp, requestErr := http.Get(api)
  12660. if requestErr != nil {
  12661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12662. return
  12663. }
  12664. body, ioErr := ioutil.ReadAll(resp.Body)
  12665. if ioErr != nil {
  12666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12668. return
  12669. }
  12670. var respJSON map[string]interface{}
  12671. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12674. return
  12675. }
  12676. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12677. result, _ := json.Marshal(respJSON)
  12678. fmt.Println("log")
  12679. fmt.Println(string(result))
  12680. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  12681. utils.ErrorLog("解析失败:%v", err)
  12682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12683. return
  12684. }
  12685. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12686. res.Output = resSeven10265.Output
  12687. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12688. res.ErrMsg = resSeven10265.ErrMsg
  12689. res.Cainfo = resSeven10265.Cainfo
  12690. res.WarnMsg = resSeven10265.WarnMsg
  12691. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12692. res.Infcode = infocode
  12693. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12694. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12695. var cert_no string
  12696. if his.IdCardType == 1 {
  12697. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  12698. } else {
  12699. cert_no = psn_info.VerifyNumber
  12700. }
  12701. 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)
  12702. var dat map[string]interface{}
  12703. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12704. fmt.Println(dat)
  12705. } else {
  12706. fmt.Println(err)
  12707. }
  12708. saveLog(result2, src_resquest, "2207", "结算")
  12709. userJSONBytes, _ := json.Marshal(dat)
  12710. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12711. utils.ErrorLog("解析失败:%v", err)
  12712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12713. return
  12714. }
  12715. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12716. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12717. var cert_no string
  12718. if his.IdCardType == 1 {
  12719. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  12720. } else if his.IdCardType == 2 {
  12721. cert_no = his.IdCardNo
  12722. } else {
  12723. cert_no = psn_info.VerifyNumber
  12724. }
  12725. 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, "")
  12726. var dat map[string]interface{}
  12727. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12728. fmt.Println(dat)
  12729. } else {
  12730. fmt.Println(err)
  12731. }
  12732. saveLog(result2, src_resquest, "2207", "结算")
  12733. userJSONBytes, _ := json.Marshal(dat)
  12734. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12735. utils.ErrorLog("解析失败:%v", err)
  12736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12737. return
  12738. }
  12739. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12740. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12741. var cert_no string
  12742. if his.IdCardType == 1 {
  12743. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  12744. } else if his.IdCardType == 2 {
  12745. cert_no = his.IdCardNo
  12746. } else {
  12747. cert_no = psn_info.VerifyNumber
  12748. }
  12749. 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, "")
  12750. var dat map[string]interface{}
  12751. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12752. fmt.Println(dat)
  12753. } else {
  12754. fmt.Println(err)
  12755. }
  12756. saveLog(result2, src_resquest, "2207", "结算")
  12757. userJSONBytes, _ := json.Marshal(dat)
  12758. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12759. utils.ErrorLog("解析失败:%v", err)
  12760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12761. return
  12762. }
  12763. } else {
  12764. var src_resquest string
  12765. if miConfig.Code == "H15049901371" {
  12766. //赤峰地区国家医保医疗类别
  12767. //职工透析:医疗类别选特殊情况门诊990502
  12768. //居民定额血透门慢: 医疗类别选门诊慢病140104
  12769. var med_type string
  12770. if his.Insutype == "390" {
  12771. if reg_type == 14 {
  12772. med_type = "9933"
  12773. } else if reg_type == 11 {
  12774. med_type = "11"
  12775. }
  12776. } else if his.Insutype == "310" {
  12777. if reg_type == 14 {
  12778. med_type = "990502"
  12779. } else if reg_type == 11 {
  12780. med_type = "11"
  12781. }
  12782. }
  12783. 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, "")
  12784. } else {
  12785. if his.IdCardType == 4 {
  12786. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12787. token := psn_info.VerifyNumber
  12788. 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)
  12789. } else {
  12790. 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, "")
  12791. }
  12792. }
  12793. var dat map[string]interface{}
  12794. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12795. fmt.Println(dat)
  12796. } else {
  12797. fmt.Println(err)
  12798. }
  12799. saveLog(result2, src_resquest, "2207", "结算")
  12800. userJSONBytes, _ := json.Marshal(dat)
  12801. if miConfig.Code == "H15049901371" {
  12802. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  12803. utils.ErrorLog("解析失败:%v", err)
  12804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12805. return
  12806. }
  12807. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12808. res.Output = resSeven10265.Output
  12809. res.ErrMsg = resSeven10265.ErrMsg
  12810. res.Cainfo = resSeven10265.Cainfo
  12811. res.WarnMsg = resSeven10265.WarnMsg
  12812. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12813. res.Infcode = infocode
  12814. } else {
  12815. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12816. utils.ErrorLog("解析失败:%v", err)
  12817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12818. return
  12819. }
  12820. }
  12821. }
  12822. if res.Infcode != 0 {
  12823. errlog := &models.HisOrderError{
  12824. UserOrgId: adminUser.CurrentOrgId,
  12825. Ctime: time.Now().Unix(),
  12826. Mtime: time.Now().Unix(),
  12827. Number: chrg_bchno,
  12828. ErrMsg: res.ErrMsg,
  12829. Status: 1,
  12830. PatientId: id,
  12831. RecordTime: recordDateTime,
  12832. Stage: 6,
  12833. }
  12834. service.CreateErrMsgLog(errlog)
  12835. c.ServeSuccessJSON(map[string]interface{}{
  12836. "failed_code": -10,
  12837. "msg": res.ErrMsg,
  12838. })
  12839. return
  12840. } else {
  12841. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  12842. order.OrderStatus = 2
  12843. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  12844. order.SetlId = res.Output.Setlinfo.SetlID
  12845. order.PsnNo = res.Output.Setlinfo.PsnNo
  12846. order.PsnName = res.Output.Setlinfo.PsnName
  12847. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  12848. order.Certno = res.Output.Setlinfo.Certno
  12849. order.Gend = res.Output.Setlinfo.Gend
  12850. order.Naty = res.Output.Setlinfo.Naty
  12851. order.Age = res.Output.Setlinfo.Age
  12852. order.Insutype = res.Output.Setlinfo.Insutype
  12853. order.PsnType = res.Output.Setlinfo.PsnType
  12854. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  12855. order.SetlTime = res.Output.Setlinfo.SetlTime
  12856. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  12857. order.PayWays = pay_ways
  12858. order.AcctUsedFlag = acct_used_flag
  12859. order.WechatPay = wechat_pay
  12860. order.AliPay = ali_pay
  12861. order.JifenPay = jifen_pay
  12862. order.BandCardPay = band_card_pay
  12863. order.CashPay = cash_pay
  12864. order.OthDesc = oth_desc
  12865. //order.MedType = res.Output.Setlinfo.MedType
  12866. if reg_type == 1112 {
  12867. order.MedType = "1112"
  12868. }
  12869. if reg_type == 1111 {
  12870. order.MedType = "1111"
  12871. }
  12872. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  12873. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  12874. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  12875. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  12876. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  12877. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  12878. order.HifpPay = res.Output.Setlinfo.HifpPay
  12879. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  12880. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  12881. order.HifesPay = res.Output.Setlinfo.HifesPay
  12882. order.HifobPay = res.Output.Setlinfo.HifobPay
  12883. order.MafPay = res.Output.Setlinfo.MafPay
  12884. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  12885. order.OthPay = res.Output.Setlinfo.OthPay
  12886. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  12887. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  12888. order.AcctPay = res.Output.Setlinfo.AcctPay
  12889. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  12890. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  12891. order.Balc = res.Output.Setlinfo.Balc
  12892. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  12893. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  12894. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  12895. order.ClrWay = res.Output.Setlinfo.ClrWay
  12896. order.Creator = order.Creator
  12897. order.Modify = roles.AdminUserId
  12898. order.RequestLog = src_resquest
  12899. order.Diagnosis = diagnosis_id
  12900. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  12901. detailStr := string(setlDetail)
  12902. order.SetlDetail = detailStr
  12903. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  12904. err = service.UpDateOrder(order)
  12905. if err == nil {
  12906. //判断是否使用了押金
  12907. if dec_way == "true" {
  12908. tmpstring := strconv.FormatInt(order.ID, 10)
  12909. //扣押金
  12910. order.Decimal = decimal
  12911. service.UpDateOrder(order)
  12912. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  12913. if errmsg != nil {
  12914. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  12915. return
  12916. }
  12917. }
  12918. c.ServeSuccessJSON(map[string]interface{}{
  12919. "msg": "结算成功",
  12920. })
  12921. } else {
  12922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  12923. return
  12924. }
  12925. }
  12926. }
  12927. }
  12928. }
  12929. //func (c *HisApiController) GetPreUploadInfo() {
  12930. // id, _ := c.GetInt64("id")
  12931. // record_time := c.GetString("record_time")
  12932. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  12933. // admin_user_id, _ := c.GetInt64("admin_user_id")
  12934. //
  12935. // timeLayout := "2006-01-02"
  12936. // loc, _ := time.LoadLocation("Local")
  12937. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12938. // if err != nil {
  12939. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12940. // return
  12941. // }
  12942. // recordDateTime := theTime.Unix()
  12943. // adminUser := c.GetAdminUserInfo()
  12944. //
  12945. // var prescriptions []*models.HisPrescription
  12946. //
  12947. // var start_time int64
  12948. // var end_time int64
  12949. //
  12950. // data := make(map[string]interface{})
  12951. // if settle_accounts_type == 1 { //日结
  12952. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  12953. // data["pre"] = prescriptions
  12954. //
  12955. // } else { //月结
  12956. // start_time_str := c.GetString("start_time")
  12957. // end_time_str := c.GetString("end_time")
  12958. // timeLayout := "2006-01-02"
  12959. // loc, _ := time.LoadLocation("Local")
  12960. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  12961. // if err != nil {
  12962. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12963. // return
  12964. // }
  12965. // recordStartTime := theStartTime.Unix()
  12966. // start_time = recordStartTime
  12967. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  12968. // if err != nil {
  12969. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12970. // return
  12971. // }
  12972. // recordEndTime := theEndTime.Unix()
  12973. // end_time = recordEndTime
  12974. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  12975. // data["pre"] = prescriptions
  12976. //
  12977. // }
  12978. //
  12979. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12980. //
  12981. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  12982. // timestamp := time.Now().Unix()
  12983. // tempTime := time.Unix(timestamp, 0)
  12984. // timeFormat := tempTime.Format("20060102150405")
  12985. // chrgBchno := rand.Intn(100000) + 10000
  12986. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  12987. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12988. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  12989. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12990. // strconv.FormatInt(his.PatientId, 10)
  12991. // client := &http.Client{}
  12992. // data["psn_no"] = his.PsnNo
  12993. // data["mdtrt_id"] = his.Number
  12994. // data["chrg_bchno"] = chrg_bchno
  12995. // data["org_name"] = miConfig.OrgName
  12996. // data["doctor"] = roles.UserName
  12997. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  12998. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  12999. // data["fixmedins_code"] = miConfig.Code
  13000. // data["dept_code"] = department.Number
  13001. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  13002. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13003. // data["secret_key"] = miConfig.SecretKey
  13004. // var ids []int64
  13005. //
  13006. // for _, item := range prescriptions {
  13007. // ids = append(ids, item.ID)
  13008. // }
  13009. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13010. // if config.IsOpen == 1 { //对接了医保,走医保流程
  13011. // bytesData, _ := json.Marshal(data)
  13012. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  13013. // resp, _ := client.Do(req)
  13014. // defer resp.Body.Close()
  13015. // body, ioErr := ioutil.ReadAll(resp.Body)
  13016. // if ioErr != nil {
  13017. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13018. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13019. // return
  13020. // }
  13021. // var respJSON map[string]interface{}
  13022. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13023. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13024. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13025. // return
  13026. // }
  13027. //
  13028. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13029. // userJSONBytes, _ := json.Marshal(respJSON)
  13030. // var res ResultFour
  13031. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13032. // utils.ErrorLog("解析失败:%v", err)
  13033. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13034. // return
  13035. // }
  13036. //
  13037. // if res.Infcode == 0 {
  13038. // order := &models.HisOrder{
  13039. // UserOrgId: adminUser.CurrentOrgId,
  13040. // HisPatientId: his.ID,
  13041. // PatientId: his.PatientId,
  13042. // SettleAccountsDate: recordDateTime,
  13043. // Ctime: time.Now().Unix(),
  13044. // Mtime: time.Now().Unix(),
  13045. // Status: 1,
  13046. // Number: chrg_bchno,
  13047. // Infcode: res.Infcode,
  13048. // WarnMsg: res.WarnMsg,
  13049. // Cainfo: res.Cainfo,
  13050. // ErrMsg: res.ErrMsg,
  13051. // RespondTime: res.RefmsgTime,
  13052. // InfRefmsgid: res.InfRefmsgid,
  13053. // OrderStatus: 1,
  13054. // IsMedicineInsurance: 1,
  13055. // SettleType: settle_accounts_type,
  13056. // SettleStartTime: start_time,
  13057. // SettleEndTime: end_time,
  13058. // Creator: roles.ID,
  13059. // Modify: roles.ID,
  13060. // PType: 2,
  13061. // }
  13062. // err = service.CreateOrder(order)
  13063. // if err != nil {
  13064. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  13065. // return
  13066. // }
  13067. //
  13068. // for _, item := range res.Output.Result {
  13069. // temp := strings.Split(item.FeedetlSn, "-")
  13070. // var advice_id int64 = 0
  13071. // var project_id int64 = 0
  13072. // var types int64 = 0
  13073. //
  13074. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  13075. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  13076. //
  13077. // if temp[1] == "1" {
  13078. // advice_id = id
  13079. // project_id = 0
  13080. // } else if temp[1] == "2" {
  13081. // advice_id = 0
  13082. // project_id = id
  13083. // }
  13084. //
  13085. // info := &models.HisOrderInfo{
  13086. // OrderNumber: order.Number,
  13087. // FeedetlSn: item.FeedetlSn,
  13088. // UploadDate: time.Now().Unix(),
  13089. // AdviceId: advice_id,
  13090. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  13091. // Cnt: item.Cnt,
  13092. // Pric: float64(item.Pric),
  13093. // PatientId: his.PatientId,
  13094. // PricUplmtAmt: item.PricUplmtAmt,
  13095. // SelfpayProp: item.SelfpayProp,
  13096. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  13097. // OverlmtAmt: item.OverlmtAmt,
  13098. // PreselfpayAmt: item.PreselfpayAmt,
  13099. // BasMednFlag: item.BasMednFlag,
  13100. // MedChrgitmType: item.MedChrgitmType,
  13101. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  13102. // Status: 1,
  13103. // Memo: item.Memo,
  13104. // Mtime: time.Now().Unix(),
  13105. // InscpScpAmt: item.InscpScpAmt,
  13106. // DrtReimFlag: item.DrtReimFlag,
  13107. // Ctime: time.Now().Unix(),
  13108. // ListSpItemFlag: item.ListSpItemFlag,
  13109. // ChldMedcFlag: item.ChldMedcFlag,
  13110. // LmtUsedFlag: item.LmtUsedFlag,
  13111. // ChrgitmLv: item.ChrgitmLv,
  13112. // UserOrgId: adminUser.CurrentOrgId,
  13113. // HisPatientId: his.ID,
  13114. // OrderId: order.ID,
  13115. // ProjectId: project_id,
  13116. // Type: types,
  13117. // }
  13118. // service.CreateOrderInfo(info)
  13119. //
  13120. // }
  13121. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  13122. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  13123. //
  13124. // var total float64
  13125. // for _, item := range prescriptions {
  13126. // if item.Type == 1 { //药品
  13127. // for _, subItem := range item.HisDoctorAdviceInfo {
  13128. // total = total + (subItem.Price * subItem.PrescribingNumber)
  13129. // }
  13130. // }
  13131. // if item.Type == 2 { //项目
  13132. // for _, subItem := range item.HisPrescriptionProject {
  13133. // total = total + (subItem.Price * float64(subItem.Count))
  13134. // }
  13135. // }
  13136. // }
  13137. //
  13138. // for _, item := range prescriptions {
  13139. // for _, subItem := range item.HisAdditionalCharge {
  13140. // total = total + (subItem.Price * float64(subItem.Count))
  13141. // }
  13142. // }
  13143. //
  13144. // allTotal := fmt.Sprintf("%.2f", total)
  13145. // if res.Infcode == 0 {
  13146. // var rf []*ResultFive
  13147. // json.Unmarshal([]byte(his.Iinfo), &rf)
  13148. // psn_no := his.PsnNo
  13149. // mdtrt_id := his.Number
  13150. // chrg_bchno := chrg_bchno
  13151. // cert_no := his.Certno
  13152. // insutype := rf[0].Insutype
  13153. //
  13154. // if his.IdCardType == 1 {
  13155. // cert_no = his.MedicalInsuranceNumber
  13156. //
  13157. // } else {
  13158. //
  13159. // cert_no = his.Certno
  13160. //
  13161. // }
  13162. //
  13163. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  13164. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  13165. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  13166. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  13167. // resp, requestErr := http.Get(api)
  13168. // if requestErr != nil {
  13169. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13170. // return
  13171. // }
  13172. // defer resp.Body.Close()
  13173. // body, ioErr := ioutil.ReadAll(resp.Body)
  13174. // if ioErr != nil {
  13175. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13176. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13177. // return
  13178. // }
  13179. // var respJSON map[string]interface{}
  13180. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13181. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13183. // return
  13184. // }
  13185. // fmt.Println(respJSON)
  13186. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13187. // userJSONBytes, _ := json.Marshal(respJSON)
  13188. // var res ResultSeven
  13189. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13190. // utils.ErrorLog("解析失败:%v", err)
  13191. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13192. // return
  13193. // }
  13194. // if res.Infcode != 0 {
  13195. // errlog := &models.HisOrderError{
  13196. // UserOrgId: adminUser.CurrentOrgId,
  13197. // Ctime: time.Now().Unix(),
  13198. // Mtime: time.Now().Unix(),
  13199. // Number: chrg_bchno,
  13200. // ErrMsg: res.ErrMsg,
  13201. // Status: 1,
  13202. // PatientId: id,
  13203. // RecordTime: recordDateTime,
  13204. // Stage: 7,
  13205. // }
  13206. // service.CreateErrMsgLog(errlog)
  13207. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  13208. // return
  13209. // } else {
  13210. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  13211. // order.OrderStatus = 1
  13212. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  13213. // order.SetlId = res.Output.Setlinfo.SetlID
  13214. // order.PsnNo = res.Output.Setlinfo.PsnNo
  13215. // order.PsnName = res.Output.Setlinfo.PsnName
  13216. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  13217. // order.Certno = res.Output.Setlinfo.Certno
  13218. // order.Gend = res.Output.Setlinfo.Gend
  13219. // order.Naty = res.Output.Setlinfo.Naty
  13220. // order.Age = res.Output.Setlinfo.Age
  13221. // order.Insutype = res.Output.Setlinfo.Insutype
  13222. // order.PsnType = res.Output.Setlinfo.PsnType
  13223. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  13224. // order.SetlTime = res.Output.Setlinfo.SetlTime
  13225. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  13226. // order.MedType = res.Output.Setlinfo.MedType
  13227. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  13228. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  13229. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  13230. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  13231. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  13232. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  13233. // order.HifpPay = res.Output.Setlinfo.HifpPay
  13234. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  13235. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  13236. // order.HifesPay = res.Output.Setlinfo.HifesPay
  13237. // order.HifobPay = res.Output.Setlinfo.HifobPay
  13238. // order.MafPay = res.Output.Setlinfo.MafPay
  13239. // order.OthPay = res.Output.Setlinfo.OthPay
  13240. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  13241. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  13242. // order.AcctPay = res.Output.Setlinfo.AcctPay
  13243. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  13244. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  13245. // order.Balc = res.Output.Setlinfo.Balc
  13246. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  13247. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  13248. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  13249. // order.ClrWay = res.Output.Setlinfo.ClrWay
  13250. // order.Creator = order.Creator
  13251. // order.Modify = roles.ID
  13252. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  13253. // detailStr := string(setlDetail)
  13254. // order.SetlDetail = detailStr
  13255. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  13256. // err = service.UpDateOrder(order)
  13257. // if err == nil {
  13258. // c.ServeSuccessJSON(map[string]interface{}{
  13259. // "msg": "预结算成功",
  13260. // })
  13261. // } else {
  13262. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  13263. // return
  13264. // }
  13265. // }
  13266. // } else {
  13267. // adminUser := c.GetAdminUserInfo()
  13268. // errlog := &models.HisOrderError{
  13269. // UserOrgId: adminUser.CurrentOrgId,
  13270. // Ctime: time.Now().Unix(),
  13271. // Mtime: time.Now().Unix(),
  13272. // ErrMsg: res.ErrMsg,
  13273. // Status: 1,
  13274. // PatientId: id,
  13275. // RecordTime: recordDateTime,
  13276. // Stage: 4,
  13277. // }
  13278. // service.CreateErrMsgLog(errlog)
  13279. //
  13280. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  13281. // return
  13282. // }
  13283. // } else {
  13284. // adminUser := c.GetAdminUserInfo()
  13285. // errlog := &models.HisOrderError{
  13286. // UserOrgId: adminUser.CurrentOrgId,
  13287. // Ctime: time.Now().Unix(),
  13288. // Mtime: time.Now().Unix(),
  13289. // ErrMsg: res.ErrMsg,
  13290. // Status: 1,
  13291. // PatientId: id,
  13292. // RecordTime: recordDateTime,
  13293. // Stage: 4,
  13294. // }
  13295. // service.CreateErrMsgLog(errlog)
  13296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  13297. // return
  13298. // }
  13299. //
  13300. // } else {
  13301. // var total float64
  13302. // for _, item := range prescriptions {
  13303. // if item.Type == 1 { //药品
  13304. // for _, subItem := range item.HisDoctorAdviceInfo {
  13305. // total = total + (subItem.Price * subItem.PrescribingNumber)
  13306. // }
  13307. // }
  13308. // if item.Type == 2 { //项目
  13309. // for _, subItem := range item.HisPrescriptionProject {
  13310. // total = total + (subItem.Price * float64(subItem.Count))
  13311. // }
  13312. // }
  13313. //
  13314. // for _, subItem := range item.HisAdditionalCharge {
  13315. // total = total + (subItem.Price * float64(subItem.Count))
  13316. // }
  13317. // }
  13318. //
  13319. // allTotal := fmt.Sprintf("%.2f", total)
  13320. // totals, _ := strconv.ParseFloat(allTotal, 64)
  13321. // order := &models.HisOrder{
  13322. // UserOrgId: adminUser.CurrentOrgId,
  13323. // HisPatientId: his.ID,
  13324. // PatientId: id,
  13325. // SettleAccountsDate: recordDateTime,
  13326. // Ctime: time.Now().Unix(),
  13327. // Mtime: time.Now().Unix(),
  13328. // Status: 1,
  13329. // OrderStatus: 2,
  13330. // Number: chrg_bchno,
  13331. // MedfeeSumamt: totals,
  13332. // }
  13333. // err = service.CreateOrder(order)
  13334. // if err != nil {
  13335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  13336. // return
  13337. // }
  13338. //
  13339. // var customs []*Custom
  13340. // for _, item := range prescriptions {
  13341. //
  13342. // if item.Type == 1 { //药品
  13343. // for _, subItem := range item.HisDoctorAdviceInfo {
  13344. // cus := &Custom{
  13345. // AdviceId: subItem.ID,
  13346. // ProjectId: 0,
  13347. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  13348. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  13349. // FeedetlSn: subItem.FeedetlSn,
  13350. // Price: fmt.Sprintf("%.2f", subItem.Price),
  13351. // MedListCodg: subItem.MedListCodg,
  13352. // Type: 1,
  13353. // }
  13354. // customs = append(customs, cus)
  13355. // }
  13356. // }
  13357. //
  13358. // if item.Type == 2 { //项目
  13359. // for _, subItem := range item.HisPrescriptionProject {
  13360. //
  13361. // cus := &Custom{
  13362. // AdviceId: 0,
  13363. // ProjectId: subItem.ID,
  13364. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  13365. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  13366. // FeedetlSn: subItem.FeedetlSn,
  13367. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  13368. // MedListCodg: subItem.MedListCodg,
  13369. // Type: 2,
  13370. // }
  13371. //
  13372. // customs = append(customs, cus)
  13373. // }
  13374. // }
  13375. //
  13376. // for _, item := range item.HisAdditionalCharge {
  13377. // cus := &Custom{
  13378. // ItemId: item.ID,
  13379. // AdviceId: 0,
  13380. // ProjectId: 0,
  13381. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  13382. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  13383. // FeedetlSn: item.FeedetlSn,
  13384. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  13385. // MedListCodg: item.XtHisAddtionConfig.Code,
  13386. // Type: 3,
  13387. // }
  13388. //
  13389. // customs = append(customs, cus)
  13390. // }
  13391. //
  13392. // }
  13393. //
  13394. // for _, item := range customs {
  13395. // var advice_id int64 = 0
  13396. // var project_id int64 = 0
  13397. // var item_id int64 = 0
  13398. //
  13399. // var types int64 = 0
  13400. //
  13401. // if item.Type == 1 {
  13402. // advice_id = item.AdviceId
  13403. // project_id = 0
  13404. // item_id = 0
  13405. // } else if item.Type == 2 {
  13406. // advice_id = 0
  13407. // item_id = 0
  13408. //
  13409. // project_id = item.ProjectId
  13410. // } else if item.Type == 3 {
  13411. // advice_id = 0
  13412. // item_id = item.ItemId
  13413. // project_id = 0
  13414. // }
  13415. //
  13416. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  13417. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  13418. // pric, _ := strconv.ParseFloat(item.Price, 32)
  13419. //
  13420. // info := &models.HisOrderInfo{
  13421. // OrderNumber: order.Number,
  13422. // UploadDate: time.Now().Unix(),
  13423. // AdviceId: advice_id,
  13424. // DetItemFeeSumamt: detItemFeeSumamt,
  13425. // Cnt: cut,
  13426. // Pric: pric,
  13427. // PatientId: id,
  13428. // Status: 1,
  13429. // Mtime: time.Now().Unix(),
  13430. // Ctime: time.Now().Unix(),
  13431. // UserOrgId: adminUser.CurrentOrgId,
  13432. // HisPatientId: his.ID,
  13433. // OrderId: order.ID,
  13434. // ProjectId: project_id,
  13435. // Type: types,
  13436. // ItemId: item_id,
  13437. // }
  13438. // service.CreateOrderInfo(info)
  13439. // }
  13440. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  13441. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  13442. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  13443. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  13444. // if err == nil {
  13445. // c.ServeSuccessJSON(map[string]interface{}{
  13446. // "msg": "结算成功",
  13447. // })
  13448. // } else {
  13449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  13450. // return
  13451. // }
  13452. // }
  13453. //}
  13454. // 上传明细-预结算-
  13455. func (c *HisApiController) GetPreUploadInfo() {
  13456. id, _ := c.GetInt64("id")
  13457. record_time := c.GetString("record_time")
  13458. his_patient_id, _ := c.GetInt64("his_patient_id")
  13459. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  13460. admin_user_id, _ := c.GetInt64("admin_user_id")
  13461. diagnosis_id := c.GetString("diagnosis")
  13462. sick_type, _ := c.GetInt64("sick_type")
  13463. reg_type, _ := c.GetInt64("p_type")
  13464. begin_time := c.GetString("begin_time")
  13465. acct_used_flag := c.GetString("acct_used_flag")
  13466. id_str := c.GetString("ids")
  13467. ids_arr := strings.Split(id_str, ",")
  13468. timeLayout := "2006-01-02"
  13469. loc, _ := time.LoadLocation("Local")
  13470. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13471. if err != nil {
  13472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13473. return
  13474. }
  13475. recordDateTime := theTime.Unix()
  13476. adminUser := c.GetAdminUserInfo()
  13477. diagnosis_ids := strings.Split(diagnosis_id, ",")
  13478. var config []*models.HisXtDiagnoseConfig
  13479. for _, item := range diagnosis_ids {
  13480. id, _ := strconv.ParseInt(item, 10, 64)
  13481. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13482. config = append(config, &diagnosisConfig)
  13483. }
  13484. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  13485. sickConfig, _ := service.FindSickById(sick_type)
  13486. var prescriptions []*models.HisPrescription
  13487. var start_time int64
  13488. var end_time int64
  13489. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13490. fmt.Println(his_patient_id)
  13491. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  13492. timestamp := time.Now().Unix()
  13493. tempTime := time.Unix(timestamp, 0)
  13494. timeFormat := tempTime.Format("20060102150405")
  13495. chrgBchno := rand.Intn(100000) + 10000
  13496. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  13497. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13498. var patientPrescription models.HisPrescriptionInfo
  13499. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  13500. if patientPrescription.ID == 0 {
  13501. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  13502. }
  13503. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13504. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  13505. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  13506. strconv.FormatInt(his.PatientId, 10)
  13507. var res2 ResultSix
  13508. var resSix10265 ResultSix10265
  13509. //var time_stamp string
  13510. if miConfig.MdtrtareaAdmvs == "421300" {
  13511. data := make(map[string]interface{})
  13512. client := &http.Client{}
  13513. data["psn_no"] = his.PsnNo
  13514. data["mdtrt_id"] = his.Number
  13515. data["department"] = department.Name
  13516. data["org_name"] = miConfig.OrgName
  13517. data["med_type"] = strconv.FormatInt(reg_type, 10)
  13518. data["doctor_id"] = doctor_info.DoctorNumber
  13519. data["doctor_name"] = roles.UserName
  13520. data["fixmedins_code"] = miConfig.Code
  13521. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  13522. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13523. data["secret_key"] = miConfig.SecretKey
  13524. data["sick_code"] = sickConfig.CountryCode
  13525. data["sick_name"] = sickConfig.ClassName
  13526. data["begin_time"] = begin_time
  13527. data["dept"] = strconv.FormatInt(department.ID, 10)
  13528. data["config"] = config
  13529. data["opter"] = roles.UserName
  13530. fmt.Println(data)
  13531. bytesData, _ := json.Marshal(data)
  13532. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  13533. resp, _ := client.Do(req)
  13534. defer resp.Body.Close()
  13535. body, ioErr := ioutil.ReadAll(resp.Body)
  13536. if ioErr != nil {
  13537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13539. return
  13540. }
  13541. var respJSON map[string]interface{}
  13542. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13545. return
  13546. }
  13547. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13548. userJSONBytes, _ := json.Marshal(respJSON)
  13549. fmt.Println("log")
  13550. fmt.Println(string(userJSONBytes))
  13551. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13552. utils.ErrorLog("解析失败:%v", err)
  13553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13554. return
  13555. }
  13556. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13557. data := make(map[string]interface{})
  13558. client := &http.Client{}
  13559. data["psn_no"] = his.PsnNo
  13560. data["mdtrt_id"] = his.Number
  13561. data["doctor"] = roles.UserName
  13562. data["department"] = department.Name
  13563. data["org_name"] = miConfig.OrgName
  13564. data["med_type"] = strconv.FormatInt(reg_type, 10)
  13565. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  13566. data["fixmedins_code"] = miConfig.Code
  13567. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  13568. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13569. data["secret_key"] = miConfig.SecretKey
  13570. data["sick_code"] = sickConfig.CountryCode
  13571. data["sick_name"] = sickConfig.ClassName
  13572. data["begin_time"] = begin_time
  13573. data["dept"] = strconv.FormatInt(department.ID, 10)
  13574. data["config"] = config
  13575. data["url"] = miConfig.Url
  13576. data["ak"] = miConfig.AccessKey
  13577. data["cainfo"] = miConfig.Cainfo
  13578. bytesData, _ := json.Marshal(data)
  13579. var req *http.Request
  13580. if miConfig.MdtrtareaAdmvs == "320921" {
  13581. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  13582. } else {
  13583. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  13584. }
  13585. resp, _ := client.Do(req)
  13586. defer resp.Body.Close()
  13587. body, ioErr := ioutil.ReadAll(resp.Body)
  13588. if ioErr != nil {
  13589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13591. return
  13592. }
  13593. var respJSON map[string]interface{}
  13594. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13597. return
  13598. }
  13599. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  13600. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  13601. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  13602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13603. userJSONBytes, _ := json.Marshal(respJSON)
  13604. fmt.Println("log")
  13605. fmt.Println(string(userJSONBytes))
  13606. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  13607. utils.ErrorLog("解析失败:%v", err)
  13608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13609. return
  13610. }
  13611. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13612. res2.Output = resSix10265.Output
  13613. res2.ErrMsg = resSix10265.ErrMsg
  13614. res2.Cainfo = resSix10265.Cainfo
  13615. res2.WarnMsg = resSix10265.WarnMsg
  13616. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13617. res2.Infcode = infocode
  13618. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13619. data := make(map[string]interface{})
  13620. client := &http.Client{}
  13621. data["psn_no"] = his.PsnNo
  13622. data["mdtrt_id"] = his.Number
  13623. data["doctor"] = roles.UserName
  13624. data["department"] = department.Name
  13625. data["org_name"] = miConfig.OrgName
  13626. data["med_type"] = strconv.FormatInt(reg_type, 10)
  13627. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  13628. data["fixmedins_code"] = miConfig.Code
  13629. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  13630. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13631. data["secret_key"] = miConfig.SecretKey
  13632. data["sick_code"] = sickConfig.CountryCode
  13633. data["sick_name"] = sickConfig.ClassName
  13634. data["begin_time"] = begin_time
  13635. data["dept"] = strconv.FormatInt(department.ID, 10)
  13636. data["config"] = config
  13637. //data["url"] = miConfig.Url
  13638. //data["ak"] = miConfig.AccessKey
  13639. data["cainfo"] = miConfig.Cainfo
  13640. fmt.Println(data)
  13641. bytesData, _ := json.Marshal(data)
  13642. var req *http.Request
  13643. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  13644. resp, _ := client.Do(req)
  13645. defer resp.Body.Close()
  13646. body, ioErr := ioutil.ReadAll(resp.Body)
  13647. if ioErr != nil {
  13648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13650. return
  13651. }
  13652. var respJSON map[string]interface{}
  13653. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13656. return
  13657. }
  13658. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  13659. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  13660. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  13661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13662. userJSONBytes, _ := json.Marshal(respJSON)
  13663. fmt.Println("log")
  13664. fmt.Println(string(userJSONBytes))
  13665. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  13666. utils.ErrorLog("解析失败:%v", err)
  13667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13668. return
  13669. }
  13670. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13671. res2.Output = resSix10265.Output
  13672. res2.ErrMsg = resSix10265.ErrMsg
  13673. res2.Cainfo = resSix10265.Cainfo
  13674. res2.WarnMsg = resSix10265.WarnMsg
  13675. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13676. res2.Infcode = infocode
  13677. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13678. 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)
  13679. saveLog(result, requestLog, "2203", "上传就诊信息")
  13680. var respJSON2 map[string]interface{}
  13681. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  13682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13684. return
  13685. }
  13686. userJSONBytes2, _ := json.Marshal(respJSON2)
  13687. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13688. utils.ErrorLog("解析失败:%v", err)
  13689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13690. return
  13691. }
  13692. } else if miConfig.MdtrtareaAdmvs == "360399" {
  13693. var result string
  13694. var requestLog string
  13695. 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, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, miConfig.Url, miConfig.AccessKey, "")
  13696. saveLog(result, requestLog, "2203", "上传就诊信息")
  13697. var respJSON2 map[string]interface{}
  13698. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  13699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13701. return
  13702. }
  13703. userJSONBytes2, _ := json.Marshal(respJSON2)
  13704. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13705. utils.ErrorLog("解析失败:%v", err)
  13706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13707. return
  13708. }
  13709. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13710. var result string
  13711. var requestLog string
  13712. 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, "")
  13713. saveLog(result, requestLog, "2203", "上传就诊信息")
  13714. var respJSON2 map[string]interface{}
  13715. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  13716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13718. return
  13719. }
  13720. userJSONBytes2, _ := json.Marshal(respJSON2)
  13721. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13722. utils.ErrorLog("解析失败:%v", err)
  13723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13724. return
  13725. }
  13726. } else {
  13727. var result string
  13728. var requestLog string
  13729. if miConfig.MdtrtareaAdmvs == "440781" { //
  13730. 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)
  13731. } else {
  13732. if miConfig.Code == "H15049901371" {
  13733. //赤峰地区国家医保医疗类别
  13734. //职工透析:医疗类别选特殊情况门诊990502
  13735. //居民定额血透门慢: 医疗类别选门诊慢病140104
  13736. var med_type string
  13737. if his.Insutype == "390" {
  13738. if reg_type == 14 {
  13739. med_type = "9933"
  13740. } else if reg_type == 11 {
  13741. med_type = "11"
  13742. }
  13743. } else if his.Insutype == "310" {
  13744. if reg_type == 14 {
  13745. med_type = "990502"
  13746. } else if reg_type == 11 {
  13747. med_type = "11"
  13748. }
  13749. }
  13750. 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)
  13751. } else {
  13752. 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)
  13753. }
  13754. saveLog(result, requestLog, "2203", "上传就诊信息")
  13755. var respJSON2 map[string]interface{}
  13756. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  13757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13759. return
  13760. }
  13761. userJSONBytes2, _ := json.Marshal(respJSON2)
  13762. if miConfig.Code == "H15049901371" {
  13763. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  13764. utils.ErrorLog("解析失败:%v", err)
  13765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13766. return
  13767. }
  13768. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13769. res2.Output = resSix10265.Output
  13770. res2.ErrMsg = resSix10265.ErrMsg
  13771. res2.Cainfo = resSix10265.Cainfo
  13772. res2.WarnMsg = resSix10265.WarnMsg
  13773. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13774. res2.Infcode = infocode
  13775. } else {
  13776. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13777. utils.ErrorLog("解析失败:%v", err)
  13778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13779. return
  13780. }
  13781. }
  13782. }
  13783. }
  13784. if res2.Infcode != 0 {
  13785. adminUser := c.GetAdminUserInfo()
  13786. errlog := &models.HisOrderError{
  13787. UserOrgId: adminUser.CurrentOrgId,
  13788. Ctime: time.Now().Unix(),
  13789. Mtime: time.Now().Unix(),
  13790. ErrMsg: res2.ErrMsg,
  13791. Status: 1,
  13792. PatientId: id,
  13793. RecordTime: recordDateTime,
  13794. Stage: 3,
  13795. }
  13796. service.CreateErrMsgLog(errlog)
  13797. c.ServeSuccessJSON(map[string]interface{}{
  13798. "failed_code": -10,
  13799. "msg": res2.ErrMsg,
  13800. })
  13801. return
  13802. } else {
  13803. his.Diagnosis = diagnosis_id
  13804. his.SickType = sickConfig.ID
  13805. his.PType = fmt.Sprintf("%d", reg_type)
  13806. service.UpdateHisPatientThree(&his)
  13807. data := make(map[string]interface{})
  13808. if settle_accounts_type == 1 { //日结
  13809. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  13810. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  13811. } else {
  13812. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  13813. }
  13814. data["pre"] = prescriptions
  13815. } else { //月结
  13816. start_time_str := c.GetString("start_time")
  13817. end_time_str := c.GetString("end_time")
  13818. timeLayout := "2006-01-02"
  13819. loc, _ := time.LoadLocation("Local")
  13820. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  13821. if err != nil {
  13822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13823. return
  13824. }
  13825. recordStartTime := theStartTime.Unix()
  13826. start_time = recordStartTime
  13827. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  13828. if err != nil {
  13829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13830. return
  13831. }
  13832. recordEndTime := theEndTime.Unix()
  13833. end_time = recordEndTime
  13834. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  13835. data["pre"] = prescriptions
  13836. }
  13837. client := &http.Client{}
  13838. data["psn_no"] = his.PsnNo
  13839. data["mdtrt_id"] = his.Number
  13840. data["chrg_bchno"] = chrg_bchno
  13841. data["org_name"] = miConfig.OrgName
  13842. data["doctor"] = doctor_info.UserName
  13843. data["doctor_id"] = doctor_info.DoctorNumber
  13844. data["dept"] = department.Name
  13845. data["fixmedins_code"] = miConfig.Code
  13846. data["opter"] = roles.UserName
  13847. data["dept_code"] = department.Number
  13848. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  13849. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13850. data["secret_key"] = miConfig.SecretKey
  13851. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  13852. data["url"] = miConfig.Url
  13853. data["ak"] = miConfig.AccessKey
  13854. data["new_doctor_name"] = patientPrescription.Doctor
  13855. data["diag_code"] = sickConfig.CountryCode
  13856. data["cainfo"] = miConfig.Cainfo
  13857. data["opter"] = roles.UserName
  13858. var ids []int64
  13859. for _, item := range prescriptions {
  13860. ids = append(ids, item.ID)
  13861. }
  13862. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13863. if config.IsOpen == 1 { //对接了医保,走医保流程
  13864. var res ResultFour
  13865. var resFour10265 ResultFour10265
  13866. if miConfig.MdtrtareaAdmvs == "421300" {
  13867. bytesData, _ := json.Marshal(data)
  13868. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  13869. resp, _ := client.Do(req)
  13870. defer resp.Body.Close()
  13871. body, ioErr := ioutil.ReadAll(resp.Body)
  13872. if ioErr != nil {
  13873. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13875. return
  13876. }
  13877. var respJSON map[string]interface{}
  13878. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13881. return
  13882. }
  13883. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13884. userJSONBytes, _ := json.Marshal(respJSON)
  13885. fmt.Println("log")
  13886. fmt.Println(string(userJSONBytes))
  13887. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13888. utils.ErrorLog("解析失败:%v", err)
  13889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13890. return
  13891. }
  13892. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13893. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  13894. if result3101.Infcode == "0" {
  13895. if len(result3101.Output.Result) > 0 {
  13896. var errMsgs []string
  13897. for _, item := range result3101.Output.Result {
  13898. errMsgs = append(errMsgs, item.VolaCont)
  13899. }
  13900. c.ServeSuccessJSON(map[string]interface{}{
  13901. "failed_code": -10,
  13902. "msg": errMsgs,
  13903. })
  13904. return
  13905. } else {
  13906. if miConfig.MdtrtareaAdmvs == "320921" {
  13907. data["doctor_id"] = "D320923012139"
  13908. } else {
  13909. data["doctor_id"] = "D371621008686"
  13910. }
  13911. bytesData, _ := json.Marshal(data)
  13912. var req *http.Request
  13913. if miConfig.MdtrtareaAdmvs == "320921" {
  13914. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13915. } else {
  13916. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13917. }
  13918. resp, _ := client.Do(req)
  13919. defer resp.Body.Close()
  13920. body, ioErr := ioutil.ReadAll(resp.Body)
  13921. if ioErr != nil {
  13922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13924. return
  13925. }
  13926. var respJSON map[string]interface{}
  13927. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13930. return
  13931. }
  13932. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13933. userJSONBytes, _ := json.Marshal(respJSON)
  13934. fmt.Println("log")
  13935. fmt.Println(string(userJSONBytes))
  13936. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  13937. utils.ErrorLog("解析失败:%v", err)
  13938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13939. return
  13940. }
  13941. res.InfRefmsgid = resFour10265.InfRefmsgid
  13942. res.Output = resFour10265.Output
  13943. res.ErrMsg = resFour10265.ErrMsg
  13944. res.Cainfo = resFour10265.Cainfo
  13945. res.WarnMsg = resFour10265.WarnMsg
  13946. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  13947. res.Infcode = infocode
  13948. }
  13949. }
  13950. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13951. data["doctor_id"] = doctor_info.DoctorNumber
  13952. bytesData, _ := json.Marshal(data)
  13953. var req *http.Request
  13954. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  13955. resp, _ := client.Do(req)
  13956. defer resp.Body.Close()
  13957. body, ioErr := ioutil.ReadAll(resp.Body)
  13958. if ioErr != nil {
  13959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13961. return
  13962. }
  13963. var respJSON map[string]interface{}
  13964. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13967. return
  13968. }
  13969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13970. userJSONBytes, _ := json.Marshal(respJSON)
  13971. fmt.Println("log")
  13972. fmt.Println(string(userJSONBytes))
  13973. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  13974. utils.ErrorLog("解析失败:%v", err)
  13975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13976. return
  13977. }
  13978. res.InfRefmsgid = resFour10265.InfRefmsgid
  13979. res.Output = resFour10265.Output
  13980. res.ErrMsg = resFour10265.ErrMsg
  13981. res.Cainfo = resFour10265.Cainfo
  13982. res.WarnMsg = resFour10265.WarnMsg
  13983. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  13984. res.Infcode = infocode
  13985. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13986. 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)
  13987. var dat map[string]interface{}
  13988. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13989. fmt.Println(dat)
  13990. } else {
  13991. fmt.Println(err)
  13992. }
  13993. saveLog(result, request_log, "2204", "上传费用明细")
  13994. userJSONBytes, _ := json.Marshal(dat)
  13995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13996. utils.ErrorLog("解析失败:%v", err)
  13997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13998. return
  13999. }
  14000. } else if miConfig.MdtrtareaAdmvs == "360399" {
  14001. 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, "", "")
  14002. var dat map[string]interface{}
  14003. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14004. fmt.Println(dat)
  14005. } else {
  14006. fmt.Println(err)
  14007. }
  14008. saveLog(result, request_log, "2204", "上传费用明细")
  14009. userJSONBytes, _ := json.Marshal(dat)
  14010. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14011. utils.ErrorLog("解析失败:%v", err)
  14012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14013. return
  14014. }
  14015. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14016. 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, "", "")
  14017. var dat map[string]interface{}
  14018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14019. fmt.Println(dat)
  14020. } else {
  14021. fmt.Println(err)
  14022. }
  14023. saveLog(result, request_log, "2204", "上传费用明细")
  14024. userJSONBytes, _ := json.Marshal(dat)
  14025. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14026. utils.ErrorLog("解析失败:%v", err)
  14027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14028. return
  14029. }
  14030. } else {
  14031. if miConfig.Code == "H15049901371" {
  14032. 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)
  14033. var dat map[string]interface{}
  14034. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14035. fmt.Println(dat)
  14036. } else {
  14037. fmt.Println(err)
  14038. }
  14039. saveLog(result, request_log, "2204", "上传费用明细")
  14040. userJSONBytes, _ := json.Marshal(dat)
  14041. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  14042. utils.ErrorLog("解析失败:%v", err)
  14043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14044. return
  14045. }
  14046. res.InfRefmsgid = resFour10265.InfRefmsgid
  14047. res.Output = resFour10265.Output
  14048. res.ErrMsg = resFour10265.ErrMsg
  14049. res.Cainfo = resFour10265.Cainfo
  14050. res.WarnMsg = resFour10265.WarnMsg
  14051. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  14052. res.Infcode = infocode
  14053. } else {
  14054. 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)
  14055. var dat map[string]interface{}
  14056. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14057. fmt.Println(dat)
  14058. } else {
  14059. fmt.Println(err)
  14060. }
  14061. saveLog(result, request_log, "2204", "上传费用明细")
  14062. userJSONBytes, _ := json.Marshal(dat)
  14063. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14064. utils.ErrorLog("解析失败:%v", err)
  14065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14066. return
  14067. }
  14068. }
  14069. }
  14070. var total_two float64
  14071. if res.Infcode == 0 {
  14072. order := &models.HisOrder{
  14073. UserOrgId: adminUser.CurrentOrgId,
  14074. HisPatientId: his.ID,
  14075. PatientId: his.PatientId,
  14076. SettleAccountsDate: recordDateTime,
  14077. Ctime: time.Now().Unix(),
  14078. Mtime: time.Now().Unix(),
  14079. MdtrtId: his.Number,
  14080. PsnNo: his.PsnNo,
  14081. MedType: strconv.FormatInt(reg_type, 10),
  14082. Status: 1,
  14083. Number: chrg_bchno,
  14084. Infcode: res.Infcode,
  14085. WarnMsg: res.WarnMsg,
  14086. Cainfo: res.Cainfo,
  14087. ErrMsg: res.ErrMsg,
  14088. RespondTime: res.RefmsgTime,
  14089. InfRefmsgid: res.InfRefmsgid,
  14090. OrderStatus: 1,
  14091. IsMedicineInsurance: 1,
  14092. SettleType: settle_accounts_type,
  14093. SettleStartTime: start_time,
  14094. SettleEndTime: end_time,
  14095. Creator: roles.AdminUserId,
  14096. Modify: roles.AdminUserId,
  14097. PType: 2,
  14098. Diagnosis: diagnosis_id,
  14099. }
  14100. err = service.CreateOrder(order)
  14101. if err != nil {
  14102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  14103. return
  14104. }
  14105. for _, item := range res.Output.Result {
  14106. temp := strings.Split(item.FeedetlSn, "-")
  14107. var advice_id int64 = 0
  14108. var project_id int64 = 0
  14109. var types int64 = 0
  14110. id, _ := strconv.ParseInt(temp[2], 10, 64)
  14111. types, _ = strconv.ParseInt(temp[1], 10, 64)
  14112. if temp[1] == "1" {
  14113. advice_id = id
  14114. project_id = 0
  14115. } else if temp[1] == "2" {
  14116. advice_id = 0
  14117. project_id = id
  14118. }
  14119. total_two = total_two + item.DetItemFeeSumamt
  14120. info := &models.HisOrderInfo{
  14121. OrderNumber: order.Number,
  14122. FeedetlSn: item.FeedetlSn,
  14123. UploadDate: time.Now().Unix(),
  14124. AdviceId: advice_id,
  14125. DetItemFeeSumamt: item.DetItemFeeSumamt,
  14126. Cnt: item.Cnt,
  14127. Pric: float64(item.Pric),
  14128. PatientId: his.PatientId,
  14129. PricUplmtAmt: item.PricUplmtAmt,
  14130. SelfpayProp: item.SelfpayProp,
  14131. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  14132. OverlmtAmt: item.OverlmtAmt,
  14133. PreselfpayAmt: item.PreselfpayAmt,
  14134. BasMednFlag: item.BasMednFlag,
  14135. MedChrgitmType: item.MedChrgitmType,
  14136. HiNegoDrugFlag: item.HiNegoDrugFlag,
  14137. Status: 1,
  14138. Memo: item.Memo,
  14139. Mtime: time.Now().Unix(),
  14140. InscpScpAmt: item.InscpScpAmt,
  14141. DrtReimFlag: item.DrtReimFlag,
  14142. Ctime: time.Now().Unix(),
  14143. ListSpItemFlag: item.ListSpItemFlag,
  14144. ChldMedcFlag: item.ChldMedcFlag,
  14145. LmtUsedFlag: item.LmtUsedFlag,
  14146. ChrgitmLv: item.ChrgitmLv,
  14147. UserOrgId: adminUser.CurrentOrgId,
  14148. HisPatientId: his.ID,
  14149. OrderId: order.ID,
  14150. ProjectId: project_id,
  14151. Type: types,
  14152. }
  14153. service.CreateOrderInfo(info)
  14154. }
  14155. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  14156. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  14157. var total float64
  14158. for _, item := range prescriptions {
  14159. if item.Type == 1 { //药品
  14160. for _, subItem := range item.HisDoctorAdviceInfo {
  14161. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  14162. total_one := price * subItem.PrescribingNumber
  14163. fmt.Println("subItem")
  14164. fmt.Println(subItem.Price)
  14165. fmt.Println("price")
  14166. fmt.Println(price)
  14167. fmt.Println("total_one")
  14168. fmt.Println(total_one)
  14169. total = total + total_one
  14170. fmt.Println(total)
  14171. }
  14172. }
  14173. if item.Type == 2 { //项目
  14174. for _, subItem := range item.HisPrescriptionProject {
  14175. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  14176. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  14177. total_one := price * cnt
  14178. total = total + total_one
  14179. }
  14180. }
  14181. }
  14182. allTotal := fmt.Sprintf("%2f", total)
  14183. if res.Infcode == 0 {
  14184. var rf []*ResultFive
  14185. json.Unmarshal([]byte(his.Iinfo), &rf)
  14186. chrg_bchno := chrg_bchno
  14187. cert_no := his.Certno
  14188. var insutypes []string
  14189. var insutype string
  14190. var is390 int = 0
  14191. var is310 int = 0
  14192. for _, item := range rf {
  14193. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14194. insutypes = append(insutypes, item.Insutype)
  14195. }
  14196. }
  14197. if len(insutypes) == 1 {
  14198. insutype = insutypes[0]
  14199. } else {
  14200. for _, i := range insutypes {
  14201. if i == "390" {
  14202. is390 = 1
  14203. }
  14204. if i == "310" {
  14205. is310 = 1
  14206. }
  14207. }
  14208. }
  14209. if is390 == 1 {
  14210. insutype = "390"
  14211. }
  14212. if is310 == 1 {
  14213. insutype = "310"
  14214. }
  14215. if len(insutypes) == 0 {
  14216. insutype = "390"
  14217. }
  14218. if len(insutypes) == 2 {
  14219. insutype = strconv.FormatInt(his.SocialType, 10)
  14220. }
  14221. //insutype = "390"
  14222. if his.IdCardType == 1 {
  14223. cert_no = his.MedicalInsuranceNumber
  14224. } else {
  14225. cert_no = his.Certno
  14226. }
  14227. var res ResultSeven
  14228. var resSeven10265 ResultSeven10265
  14229. var resSeven10265Two ResultSeven10265Two
  14230. if miConfig.MdtrtareaAdmvs == "421300" {
  14231. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  14232. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  14233. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14234. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14235. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  14236. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  14237. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  14238. resp, requestErr := http.Get(api)
  14239. if requestErr != nil {
  14240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14241. return
  14242. }
  14243. body, ioErr := ioutil.ReadAll(resp.Body)
  14244. if ioErr != nil {
  14245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14247. return
  14248. }
  14249. var respJSON map[string]interface{}
  14250. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14253. return
  14254. }
  14255. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14256. result, _ := json.Marshal(respJSON)
  14257. fmt.Println("log")
  14258. fmt.Println(string(result))
  14259. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14260. utils.ErrorLog("解析失败:%v", err)
  14261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14262. return
  14263. }
  14264. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14265. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  14266. if result3101.Infcode == "0" {
  14267. if len(result3101.Output.Result) > 0 {
  14268. var errMsgs []string
  14269. for _, item := range result3101.Output.Result {
  14270. errMsgs = append(errMsgs, item.VolaCont)
  14271. }
  14272. c.ServeSuccessJSON(map[string]interface{}{
  14273. "failed_code": -10,
  14274. "msg": errMsgs,
  14275. })
  14276. return
  14277. } else {
  14278. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14279. if his.IdCardType != 4 {
  14280. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  14281. bas := strings.Split(psn_info.CardInfo, "|")
  14282. if his.IdCardType == 1 {
  14283. cert_no = bas[2]
  14284. } else {
  14285. cert_no = bas[1]
  14286. }
  14287. } else {
  14288. cert_no = his.Certno
  14289. }
  14290. //江苏地区国家医保医疗类别
  14291. //职工透析:医疗类别选特殊情况门诊9933
  14292. //居民血透门慢: 医疗类别选门诊慢病1402
  14293. //var med_type string
  14294. //if his.Insutype == "310" {
  14295. // if reg_type == 14 {
  14296. // med_type = "9933"
  14297. // } else if reg_type == 11 {
  14298. // med_type = "11"
  14299. //
  14300. // }
  14301. //} else if his.Insutype == "390" {
  14302. // if reg_type == 14 {
  14303. // med_type = "1402"
  14304. // } else if reg_type == 11 {
  14305. // med_type = "11"
  14306. // }
  14307. //}
  14308. var api string
  14309. if miConfig.MdtrtareaAdmvs == "320921" {
  14310. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  14311. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  14312. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14313. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14314. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  14315. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  14316. "&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
  14317. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14318. } else {
  14319. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14320. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  14321. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  14322. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14323. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14324. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  14325. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  14326. "&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
  14327. }
  14328. resp, requestErr := http.Get(api)
  14329. if requestErr != nil {
  14330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14331. return
  14332. }
  14333. body, ioErr := ioutil.ReadAll(resp.Body)
  14334. if ioErr != nil {
  14335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14337. return
  14338. }
  14339. var respJSON map[string]interface{}
  14340. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14343. return
  14344. }
  14345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14346. result, _ := json.Marshal(respJSON)
  14347. fmt.Println("log")
  14348. fmt.Println(string(result))
  14349. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  14350. utils.ErrorLog("解析失败:%v", err)
  14351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14352. return
  14353. }
  14354. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  14355. AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  14356. res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  14357. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  14358. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  14359. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  14360. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  14361. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  14362. res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  14363. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  14364. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  14365. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  14366. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  14367. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  14368. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  14369. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  14370. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  14371. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  14372. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  14373. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  14374. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  14375. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  14376. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  14377. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  14378. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  14379. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  14380. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  14381. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  14382. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  14383. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  14384. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  14385. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  14386. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  14387. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  14388. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  14389. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  14390. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  14391. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  14392. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  14393. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  14394. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  14395. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  14396. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  14397. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  14398. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  14399. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  14400. res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  14401. res.ErrMsg = resSeven10265Two.ErrMsg
  14402. res.Cainfo = resSeven10265Two.Cainfo
  14403. res.WarnMsg = resSeven10265Two.WarnMsg
  14404. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  14405. res.Infcode = infocode
  14406. }
  14407. }
  14408. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14409. psn_info, _ := service.GetPsnByPatientId(id)
  14410. var verify_number string
  14411. if psn_info.IdCardType == 4 {
  14412. verify_number = psn_info.VerifyNumber
  14413. } else if psn_info.IdCardType == 1 {
  14414. bas := strings.Split(psn_info.CardInfo, "|")
  14415. cardNumber := bas[2]
  14416. verify_number = cardNumber
  14417. } else {
  14418. psn_info.IdCardType = 2
  14419. verify_number = psn_info.Certno
  14420. }
  14421. var api string
  14422. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  14423. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  14424. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14425. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  14426. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  14427. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  14428. "&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
  14429. resp, requestErr := http.Get(api)
  14430. if requestErr != nil {
  14431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14432. return
  14433. }
  14434. body, ioErr := ioutil.ReadAll(resp.Body)
  14435. if ioErr != nil {
  14436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14438. return
  14439. }
  14440. var respJSON map[string]interface{}
  14441. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14444. return
  14445. }
  14446. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14447. result, _ := json.Marshal(respJSON)
  14448. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  14449. utils.ErrorLog("解析失败:%v", err)
  14450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14451. return
  14452. }
  14453. res.InfRefmsgid = resSeven10265.InfRefmsgid
  14454. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  14455. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  14456. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  14457. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  14458. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  14459. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  14460. res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  14461. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  14462. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  14463. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  14464. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  14465. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  14466. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  14467. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  14468. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  14469. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  14470. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  14471. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  14472. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  14473. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  14474. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  14475. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  14476. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  14477. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  14478. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  14479. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  14480. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  14481. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  14482. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  14483. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  14484. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  14485. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  14486. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  14487. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  14488. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  14489. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  14490. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  14491. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  14492. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  14493. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  14494. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  14495. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  14496. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  14497. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  14498. res.Output.Setldetail = resSeven10265.Output.Setldetail
  14499. res.ErrMsg = resSeven10265.ErrMsg
  14500. res.Cainfo = resSeven10265.Cainfo
  14501. res.WarnMsg = resSeven10265.WarnMsg
  14502. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  14503. res.Infcode = infocode
  14504. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14505. acct_used_flag := "1"
  14506. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  14507. var result string
  14508. var request_log string
  14509. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  14510. 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)
  14511. } else {
  14512. 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)
  14513. }
  14514. var dat map[string]interface{}
  14515. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14516. fmt.Println(dat)
  14517. } else {
  14518. fmt.Println(err)
  14519. }
  14520. saveLog(result, request_log, "2206", "预结算")
  14521. userJSONBytes, _ := json.Marshal(dat)
  14522. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14523. utils.ErrorLog("解析失败:%v", err)
  14524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14525. return
  14526. }
  14527. } else if miConfig.MdtrtareaAdmvs == "360399" {
  14528. var result string
  14529. var request_log string
  14530. if his.IdCardType == 2 {
  14531. 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, "")
  14532. } else if his.IdCardType == 1 {
  14533. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14534. bas := strings.Split(psn_info.CardInfo, "|")
  14535. basNumber := bas[2]
  14536. card_sn := bas[3]
  14537. 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)
  14538. } else {
  14539. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14540. 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, "")
  14541. }
  14542. var dat map[string]interface{}
  14543. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14544. fmt.Println(dat)
  14545. } else {
  14546. fmt.Println(err)
  14547. }
  14548. saveLog(result, request_log, "2206", "预结算")
  14549. userJSONBytes, _ := json.Marshal(dat)
  14550. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14551. utils.ErrorLog("解析失败:%v", err)
  14552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14553. return
  14554. }
  14555. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14556. var result string
  14557. var request_log string
  14558. if his.IdCardType == 2 {
  14559. 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")
  14560. } else if his.IdCardType == 1 {
  14561. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14562. bas := strings.Split(psn_info.CardInfo, "|")
  14563. basNumber := bas[2]
  14564. card_sn := bas[3]
  14565. 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")
  14566. } else {
  14567. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14568. 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")
  14569. }
  14570. var dat map[string]interface{}
  14571. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14572. fmt.Println(dat)
  14573. } else {
  14574. fmt.Println(err)
  14575. }
  14576. saveLog(result, request_log, "2206", "预结算")
  14577. userJSONBytes, _ := json.Marshal(dat)
  14578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14579. utils.ErrorLog("解析失败:%v", err)
  14580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14581. return
  14582. }
  14583. } else {
  14584. var result string
  14585. var request_log string
  14586. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  14587. allTotal = fmt.Sprintf("%2f", total_two)
  14588. if his.IdCardType == 4 {
  14589. 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)
  14590. } else {
  14591. 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)
  14592. }
  14593. var dat map[string]interface{}
  14594. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14595. fmt.Println(dat)
  14596. } else {
  14597. fmt.Println(err)
  14598. }
  14599. saveLog(result, request_log, "2206", "预结算")
  14600. //userJSONBytes, _ := json.Marshal(dat)
  14601. //
  14602. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14603. // utils.ErrorLog("解析失败:%v", err)
  14604. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14605. // return
  14606. //}
  14607. userJSONBytes, _ := json.Marshal(dat)
  14608. if miConfig.Code == "H15049901371" {
  14609. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  14610. utils.ErrorLog("解析失败:%v", err)
  14611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14612. return
  14613. }
  14614. res.InfRefmsgid = resSeven10265.InfRefmsgid
  14615. res.Output = resSeven10265.Output
  14616. res.ErrMsg = resSeven10265.ErrMsg
  14617. res.Cainfo = resSeven10265.Cainfo
  14618. res.WarnMsg = resSeven10265.WarnMsg
  14619. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  14620. res.Infcode = infocode
  14621. } else {
  14622. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14623. utils.ErrorLog("解析失败:%v", err)
  14624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14625. return
  14626. }
  14627. }
  14628. }
  14629. if res.Infcode != 0 {
  14630. errlog := &models.HisOrderError{
  14631. UserOrgId: adminUser.CurrentOrgId,
  14632. Ctime: time.Now().Unix(),
  14633. Mtime: time.Now().Unix(),
  14634. Number: chrg_bchno,
  14635. ErrMsg: res.ErrMsg,
  14636. Status: 1,
  14637. PatientId: id,
  14638. RecordTime: recordDateTime,
  14639. Stage: 20,
  14640. }
  14641. service.CreateErrMsgLog(errlog)
  14642. c.ServeSuccessJSON(map[string]interface{}{
  14643. "failed_code": -10,
  14644. "msg": res.ErrMsg,
  14645. })
  14646. return
  14647. } else {
  14648. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  14649. order.OrderStatus = 1
  14650. order.IsPre = 1
  14651. order.Status = 1
  14652. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  14653. order.SetlId = res.Output.Setlinfo.SetlID
  14654. order.PsnNo = res.Output.Setlinfo.PsnNo
  14655. order.PsnName = res.Output.Setlinfo.PsnName
  14656. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  14657. order.Certno = res.Output.Setlinfo.Certno
  14658. order.Gend = res.Output.Setlinfo.Gend
  14659. order.Naty = res.Output.Setlinfo.Naty
  14660. order.Age = res.Output.Setlinfo.Age
  14661. order.Insutype = res.Output.Setlinfo.Insutype
  14662. order.PsnType = res.Output.Setlinfo.PsnType
  14663. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  14664. order.SetlTime = res.Output.Setlinfo.SetlTime
  14665. order.AcctUsedFlag = acct_used_flag
  14666. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  14667. if res.Output.Setlinfo.MedType == "140101" {
  14668. order.MedType = "14"
  14669. } else {
  14670. order.MedType = res.Output.Setlinfo.MedType
  14671. }
  14672. if reg_type == 1112 {
  14673. order.MedType = "1112"
  14674. }
  14675. if reg_type == 1111 {
  14676. order.MedType = "1111"
  14677. }
  14678. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  14679. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  14680. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  14681. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  14682. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  14683. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  14684. order.HifpPay = res.Output.Setlinfo.HifpPay
  14685. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  14686. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  14687. order.HifesPay = res.Output.Setlinfo.HifesPay
  14688. order.HifobPay = res.Output.Setlinfo.HifobPay
  14689. order.MafPay = res.Output.Setlinfo.MafPay
  14690. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  14691. order.OthPay = res.Output.Setlinfo.OthPay
  14692. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  14693. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  14694. order.AcctPay = res.Output.Setlinfo.AcctPay
  14695. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  14696. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  14697. order.Balc = res.Output.Setlinfo.Balc
  14698. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  14699. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  14700. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  14701. order.ClrWay = res.Output.Setlinfo.ClrWay
  14702. order.Creator = order.Creator
  14703. order.Modify = roles.AdminUserId
  14704. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  14705. detailStr := string(setlDetail)
  14706. order.SetlDetail = detailStr
  14707. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  14708. err = service.UpDateOrder(order)
  14709. if err == nil {
  14710. c.ServeSuccessJSON(map[string]interface{}{
  14711. "msg": "预结算成功",
  14712. })
  14713. } else {
  14714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  14715. return
  14716. }
  14717. }
  14718. } else {
  14719. adminUser := c.GetAdminUserInfo()
  14720. errlog := &models.HisOrderError{
  14721. UserOrgId: adminUser.CurrentOrgId,
  14722. Ctime: time.Now().Unix(),
  14723. Mtime: time.Now().Unix(),
  14724. ErrMsg: res.ErrMsg,
  14725. Status: 1,
  14726. PatientId: id,
  14727. RecordTime: recordDateTime,
  14728. Stage: 4,
  14729. }
  14730. service.CreateErrMsgLog(errlog)
  14731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  14732. return
  14733. }
  14734. } else {
  14735. adminUser := c.GetAdminUserInfo()
  14736. errlog := &models.HisOrderError{
  14737. UserOrgId: adminUser.CurrentOrgId,
  14738. Ctime: time.Now().Unix(),
  14739. Mtime: time.Now().Unix(),
  14740. ErrMsg: res.ErrMsg,
  14741. Status: 1,
  14742. PatientId: id,
  14743. RecordTime: recordDateTime,
  14744. Stage: 4,
  14745. }
  14746. service.CreateErrMsgLog(errlog)
  14747. c.ServeSuccessJSON(map[string]interface{}{
  14748. "failed_code": -10,
  14749. "msg": res.ErrMsg,
  14750. })
  14751. return
  14752. }
  14753. }
  14754. }
  14755. }
  14756. // 退款
  14757. func (c *HisApiController) Refund() {
  14758. order_id, _ := c.GetInt64("order_id")
  14759. admin_user_id, _ := c.GetInt64("admin_user_id")
  14760. adminUser := c.GetAdminUserInfo()
  14761. var order models.HisOrder
  14762. order, _ = service.GetHisOrderByID(order_id)
  14763. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14764. if order.ID == 0 {
  14765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14766. return
  14767. }
  14768. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14769. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14770. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14771. if config.IsOpen == 1 { //对接了医保,走医保流程
  14772. var res ResultSixteen
  14773. var resSixteen10265 ResultSixteen10265
  14774. var resSixteen10265Two ResultSixteen10265Two
  14775. var src_resquest string
  14776. var result string
  14777. if miConfig.MdtrtareaAdmvs == "421300" {
  14778. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  14779. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14780. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14781. resp3, requestErr3 := http.Get(api3)
  14782. if requestErr3 != nil {
  14783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14784. return
  14785. }
  14786. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  14787. if ioErr3 != nil {
  14788. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  14789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14790. return
  14791. }
  14792. var respJSON3 map[string]interface{}
  14793. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  14794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14796. return
  14797. }
  14798. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14799. userJSONBytes3, _ := json.Marshal(respJSON3)
  14800. fmt.Println("log")
  14801. fmt.Println(string(userJSONBytes3))
  14802. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  14803. utils.ErrorLog("解析失败:%v", err)
  14804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14805. return
  14806. }
  14807. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14808. var api3 string
  14809. if miConfig.MdtrtareaAdmvs == "320921" {
  14810. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  14811. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14812. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14813. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14814. } else {
  14815. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14816. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  14817. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14818. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14819. }
  14820. resp3, requestErr3 := http.Get(api3)
  14821. if requestErr3 != nil {
  14822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14823. return
  14824. }
  14825. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  14826. if ioErr3 != nil {
  14827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  14828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14829. return
  14830. }
  14831. var respJSON3 map[string]interface{}
  14832. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  14833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14835. return
  14836. }
  14837. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14838. userJSONBytes3, _ := json.Marshal(respJSON3)
  14839. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  14840. utils.ErrorLog("解析失败:%v", err)
  14841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14842. return
  14843. }
  14844. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  14845. res.Output = resSixteen10265.Output
  14846. res.ErrMsg = resSixteen10265.ErrMsg
  14847. res.Cainfo = resSixteen10265.Cainfo
  14848. res.WarnMsg = resSixteen10265.WarnMsg
  14849. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  14850. res.Infcode = infocode
  14851. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14852. var api3 string
  14853. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  14854. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14855. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14856. resp3, requestErr3 := http.Get(api3)
  14857. if requestErr3 != nil {
  14858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14859. return
  14860. }
  14861. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  14862. if ioErr3 != nil {
  14863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  14864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14865. return
  14866. }
  14867. var respJSON3 map[string]interface{}
  14868. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  14869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14871. return
  14872. }
  14873. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14874. userJSONBytes3, _ := json.Marshal(respJSON3)
  14875. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  14876. utils.ErrorLog("解析失败:%v", err)
  14877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14878. return
  14879. }
  14880. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  14881. res.Output = resSixteen10265.Output
  14882. res.ErrMsg = resSixteen10265.ErrMsg
  14883. res.Cainfo = resSixteen10265.Cainfo
  14884. res.WarnMsg = resSixteen10265.WarnMsg
  14885. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  14886. res.Infcode = infocode
  14887. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14888. 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)
  14889. var dat map[string]interface{}
  14890. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14891. fmt.Println(dat)
  14892. } else {
  14893. fmt.Println(err)
  14894. }
  14895. saveLog(result, src_resquest, "2208", "退费")
  14896. userJSONBytes, _ := json.Marshal(dat)
  14897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14898. utils.ErrorLog("解析失败:%v", err)
  14899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14900. return
  14901. }
  14902. } else if miConfig.MdtrtareaAdmvs == "360399" {
  14903. 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, "")
  14904. var dat map[string]interface{}
  14905. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14906. fmt.Println(dat)
  14907. } else {
  14908. fmt.Println(err)
  14909. }
  14910. saveLog(result, src_resquest, "2208", "退费")
  14911. userJSONBytes, _ := json.Marshal(dat)
  14912. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14913. utils.ErrorLog("解析失败:%v", err)
  14914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14915. return
  14916. }
  14917. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14918. 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, "")
  14919. var dat map[string]interface{}
  14920. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14921. fmt.Println(dat)
  14922. } else {
  14923. fmt.Println(err)
  14924. }
  14925. saveLog(result, src_resquest, "2208", "退费")
  14926. userJSONBytes, _ := json.Marshal(dat)
  14927. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14928. utils.ErrorLog("解析失败:%v", err)
  14929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14930. return
  14931. }
  14932. } else {
  14933. if miConfig.Code == "H15049901371" {
  14934. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  14935. var dat map[string]interface{}
  14936. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14937. fmt.Println(dat)
  14938. } else {
  14939. fmt.Println(err)
  14940. }
  14941. saveLog(result, src_resquest, "2208", "退费")
  14942. userJSONBytes, _ := json.Marshal(dat)
  14943. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  14944. utils.ErrorLog("解析失败:%v", err)
  14945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14946. return
  14947. }
  14948. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  14949. res.Output = resSixteen10265.Output
  14950. res.ErrMsg = resSixteen10265.ErrMsg
  14951. res.Cainfo = resSixteen10265.Cainfo
  14952. res.WarnMsg = resSixteen10265.WarnMsg
  14953. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  14954. res.Infcode = infocode
  14955. } else {
  14956. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  14957. var dat map[string]interface{}
  14958. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14959. fmt.Println(dat)
  14960. } else {
  14961. fmt.Println(err)
  14962. }
  14963. saveLog(result, src_resquest, "2208", "退费")
  14964. userJSONBytes, _ := json.Marshal(dat)
  14965. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14966. utils.ErrorLog("解析失败:%v", err)
  14967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14968. return
  14969. }
  14970. }
  14971. }
  14972. if res.Infcode == 0 {
  14973. var res2 ResultSix
  14974. var resSix10265 ResultSix10265
  14975. if miConfig.MdtrtareaAdmvs == "421300" {
  14976. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  14977. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  14978. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14979. resp3, requestErr3 := http.Get(api3)
  14980. if requestErr3 != nil {
  14981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14982. return
  14983. }
  14984. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  14985. if ioErr3 != nil {
  14986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  14987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14988. return
  14989. }
  14990. var respJSON3 map[string]interface{}
  14991. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  14992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14994. return
  14995. }
  14996. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14997. userJSONBytes3, _ := json.Marshal(respJSON3)
  14998. fmt.Println("log")
  14999. fmt.Println(string(userJSONBytes3))
  15000. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  15001. utils.ErrorLog("解析失败:%v", err)
  15002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15003. return
  15004. }
  15005. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15006. var api3 string
  15007. if miConfig.MdtrtareaAdmvs == "320921" {
  15008. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  15009. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15010. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15011. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15012. } else {
  15013. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15014. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  15015. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15016. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15017. }
  15018. resp3, requestErr3 := http.Get(api3)
  15019. if requestErr3 != nil {
  15020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15021. return
  15022. }
  15023. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  15024. if ioErr3 != nil {
  15025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  15026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15027. return
  15028. }
  15029. var respJSON3 map[string]interface{}
  15030. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  15031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15033. return
  15034. }
  15035. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15036. userJSONBytes3, _ := json.Marshal(respJSON3)
  15037. fmt.Println("log")
  15038. fmt.Println(string(userJSONBytes3))
  15039. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  15040. utils.ErrorLog("解析失败:%v", err)
  15041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15042. return
  15043. }
  15044. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15045. res2.Output = resSix10265.Output
  15046. res2.ErrMsg = resSix10265.ErrMsg
  15047. res2.Cainfo = resSix10265.Cainfo
  15048. res2.WarnMsg = resSix10265.WarnMsg
  15049. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15050. res2.Infcode = infocode
  15051. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15052. var api3 string
  15053. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  15054. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15055. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15056. resp3, requestErr3 := http.Get(api3)
  15057. if requestErr3 != nil {
  15058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15059. return
  15060. }
  15061. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  15062. if ioErr3 != nil {
  15063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  15064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15065. return
  15066. }
  15067. var respJSON3 map[string]interface{}
  15068. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  15069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15071. return
  15072. }
  15073. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15074. userJSONBytes3, _ := json.Marshal(respJSON3)
  15075. fmt.Println("log")
  15076. fmt.Println(string(userJSONBytes3))
  15077. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  15078. utils.ErrorLog("解析失败:%v", err)
  15079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15080. return
  15081. }
  15082. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15083. res2.Output = resSix10265.Output
  15084. res2.ErrMsg = resSix10265.ErrMsg
  15085. res2.Cainfo = resSix10265.Cainfo
  15086. res2.WarnMsg = resSix10265.WarnMsg
  15087. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15088. res2.Infcode = infocode
  15089. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15090. 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)
  15091. var dat map[string]interface{}
  15092. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  15093. fmt.Println(dat)
  15094. } else {
  15095. fmt.Println(err)
  15096. }
  15097. saveLog(result2, src_request, "2205", "撤销明细")
  15098. userJSONBytes, _ := json.Marshal(dat)
  15099. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15100. utils.ErrorLog("解析失败:%v", err)
  15101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15102. return
  15103. }
  15104. } else if miConfig.MdtrtareaAdmvs == "360399" {
  15105. 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, "")
  15106. var dat map[string]interface{}
  15107. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  15108. fmt.Println(dat)
  15109. } else {
  15110. fmt.Println(err)
  15111. }
  15112. saveLog(result2, src_request, "2205", "撤销明细")
  15113. userJSONBytes, _ := json.Marshal(dat)
  15114. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15115. utils.ErrorLog("解析失败:%v", err)
  15116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15117. return
  15118. }
  15119. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15120. 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, "")
  15121. var dat map[string]interface{}
  15122. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  15123. fmt.Println(dat)
  15124. } else {
  15125. fmt.Println(err)
  15126. }
  15127. saveLog(result2, src_request, "2205", "撤销明细")
  15128. userJSONBytes, _ := json.Marshal(dat)
  15129. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15130. utils.ErrorLog("解析失败:%v", err)
  15131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15132. return
  15133. }
  15134. } else {
  15135. if miConfig.Code == "H15049901371" {
  15136. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  15137. var dat map[string]interface{}
  15138. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  15139. fmt.Println(dat)
  15140. } else {
  15141. fmt.Println(err)
  15142. }
  15143. saveLog(result2, src_request, "2205", "撤销明细")
  15144. userJSONBytes, _ := json.Marshal(dat)
  15145. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  15146. utils.ErrorLog("解析失败:%v", err)
  15147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15148. return
  15149. }
  15150. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15151. res2.Output = resSix10265.Output
  15152. res2.ErrMsg = resSix10265.ErrMsg
  15153. res2.Cainfo = resSix10265.Cainfo
  15154. res2.WarnMsg = resSix10265.WarnMsg
  15155. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15156. res2.Infcode = infocode
  15157. } else {
  15158. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  15159. var dat map[string]interface{}
  15160. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  15161. fmt.Println(dat)
  15162. } else {
  15163. fmt.Println(err)
  15164. }
  15165. saveLog(result2, src_request, "2205", "撤销明细")
  15166. userJSONBytes, _ := json.Marshal(dat)
  15167. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15168. utils.ErrorLog("解析失败:%v", err)
  15169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15170. return
  15171. }
  15172. }
  15173. }
  15174. if res2.Infcode == 0 {
  15175. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  15176. if err == nil {
  15177. //当押金不为零时产生退费记录
  15178. if order.Decimal != 0 {
  15179. tmp := strconv.FormatInt(order.ID, 10)
  15180. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  15181. if err != nil {
  15182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15183. return
  15184. }
  15185. }
  15186. c.ServeSuccessJSON(map[string]interface{}{
  15187. "msg": "退费成功",
  15188. })
  15189. } else {
  15190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15191. return
  15192. }
  15193. } else {
  15194. c.ServeSuccessJSON(map[string]interface{}{
  15195. "code": -10,
  15196. "msg": res2.ErrMsg,
  15197. })
  15198. }
  15199. } else {
  15200. c.ServeSuccessJSON(map[string]interface{}{
  15201. "code": -10,
  15202. "msg": res.ErrMsg,
  15203. })
  15204. }
  15205. }
  15206. }
  15207. func (c *HisApiController) RefundNumber() {
  15208. record_time := c.GetString("record_time")
  15209. //patient_id, _ := c.GetInt64("patient_id")
  15210. admin_user_id, _ := c.GetInt64("admin_user_id")
  15211. his_patient_id, _ := c.GetInt64("id")
  15212. timeLayout := "2006-01-02"
  15213. loc, _ := time.LoadLocation("Local")
  15214. adminUser := c.GetAdminUserInfo()
  15215. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  15216. fmt.Println(err)
  15217. if err != nil {
  15218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  15219. return
  15220. }
  15221. recordDateTime := theTime.Unix()
  15222. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  15223. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  15224. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  15225. //order, _ := service.GetHisOrderByID(order_id)
  15226. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15227. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15228. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15229. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  15230. if count > 0 {
  15231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  15232. return
  15233. }
  15234. if config.IsOpen == 1 { //对接了医保,走医保流程
  15235. var res2 ResultSix
  15236. var resSix10265 ResultSix10265
  15237. if miConfig.MdtrtareaAdmvs == "421300" {
  15238. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  15239. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15240. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  15241. resp3, requestErr3 := http.Get(api3)
  15242. if requestErr3 != nil {
  15243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15244. return
  15245. }
  15246. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  15247. if ioErr3 != nil {
  15248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  15249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15250. return
  15251. }
  15252. var respJSON3 map[string]interface{}
  15253. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  15254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15256. return
  15257. }
  15258. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15259. userJSONBytes3, _ := json.Marshal(respJSON3)
  15260. fmt.Println("log")
  15261. fmt.Println(string(userJSONBytes3))
  15262. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  15263. utils.ErrorLog("解析失败:%v", err)
  15264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15265. return
  15266. }
  15267. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15268. var api3 string
  15269. if miConfig.MdtrtareaAdmvs == "320921" {
  15270. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  15271. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15272. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15273. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15274. } else {
  15275. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15276. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  15277. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15278. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15279. }
  15280. resp3, requestErr3 := http.Get(api3)
  15281. if requestErr3 != nil {
  15282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15283. return
  15284. }
  15285. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  15286. if ioErr3 != nil {
  15287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  15288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15289. return
  15290. }
  15291. var respJSON3 map[string]interface{}
  15292. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  15293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15295. return
  15296. }
  15297. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15298. userJSONBytes3, _ := json.Marshal(respJSON3)
  15299. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  15300. utils.ErrorLog("解析失败:%v", err)
  15301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15302. return
  15303. }
  15304. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15305. res2.Output = resSix10265.Output
  15306. res2.ErrMsg = resSix10265.ErrMsg
  15307. res2.Cainfo = resSix10265.Cainfo
  15308. res2.WarnMsg = resSix10265.WarnMsg
  15309. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15310. res2.Infcode = infocode
  15311. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15312. var api3 string
  15313. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  15314. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15315. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15316. resp3, requestErr3 := http.Get(api3)
  15317. if requestErr3 != nil {
  15318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15319. return
  15320. }
  15321. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  15322. if ioErr3 != nil {
  15323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  15324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15325. return
  15326. }
  15327. var respJSON3 map[string]interface{}
  15328. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  15329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15331. return
  15332. }
  15333. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15334. userJSONBytes3, _ := json.Marshal(respJSON3)
  15335. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  15336. utils.ErrorLog("解析失败:%v", err)
  15337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15338. return
  15339. }
  15340. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15341. res2.Output = resSix10265.Output
  15342. res2.ErrMsg = resSix10265.ErrMsg
  15343. res2.Cainfo = resSix10265.Cainfo
  15344. res2.WarnMsg = resSix10265.WarnMsg
  15345. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15346. res2.Infcode = infocode
  15347. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15348. 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)
  15349. var dat map[string]interface{}
  15350. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15351. fmt.Println(dat)
  15352. } else {
  15353. fmt.Println(err)
  15354. }
  15355. saveLog(result, request, "2202", "退号")
  15356. userJSONBytes, _ := json.Marshal(dat)
  15357. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15358. utils.ErrorLog("解析失败:%v", err)
  15359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15360. return
  15361. }
  15362. } else if miConfig.MdtrtareaAdmvs == "360399" {
  15363. 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, "")
  15364. var dat map[string]interface{}
  15365. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15366. fmt.Println(dat)
  15367. } else {
  15368. fmt.Println(err)
  15369. }
  15370. saveLog(result, request, "2202", "退号")
  15371. userJSONBytes, _ := json.Marshal(dat)
  15372. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15373. utils.ErrorLog("解析失败:%v", err)
  15374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15375. return
  15376. }
  15377. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15378. 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, "")
  15379. var dat map[string]interface{}
  15380. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15381. fmt.Println(dat)
  15382. } else {
  15383. fmt.Println(err)
  15384. }
  15385. saveLog(result, request, "2202", "退号")
  15386. userJSONBytes, _ := json.Marshal(dat)
  15387. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15388. utils.ErrorLog("解析失败:%v", err)
  15389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15390. return
  15391. }
  15392. } else {
  15393. var api3 string
  15394. if miConfig.Code == "H15049901371" {
  15395. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  15396. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15397. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  15398. } else {
  15399. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  15400. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15401. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  15402. }
  15403. resp3, requestErr3 := http.Get(api3)
  15404. if requestErr3 != nil {
  15405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15406. return
  15407. }
  15408. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  15409. if ioErr3 != nil {
  15410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  15411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15412. return
  15413. }
  15414. var respJSON3 map[string]interface{}
  15415. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  15416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15418. return
  15419. }
  15420. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15421. userJSONBytes3, _ := json.Marshal(respJSON3)
  15422. if miConfig.Code == "H15049901371" {
  15423. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  15424. utils.ErrorLog("解析失败:%v", err)
  15425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15426. return
  15427. }
  15428. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15429. res2.Output = resSix10265.Output
  15430. res2.ErrMsg = resSix10265.ErrMsg
  15431. res2.Cainfo = resSix10265.Cainfo
  15432. res2.WarnMsg = resSix10265.WarnMsg
  15433. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15434. res2.Infcode = infocode
  15435. } else {
  15436. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  15437. utils.ErrorLog("解析失败:%v", err)
  15438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15439. return
  15440. }
  15441. }
  15442. }
  15443. if res2.Infcode == 0 {
  15444. if err == nil {
  15445. c.ServeSuccessJSON(map[string]interface{}{
  15446. "msg": "退号成功",
  15447. })
  15448. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  15449. } else {
  15450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15451. return
  15452. }
  15453. } else {
  15454. c.ServeSuccessJSON(map[string]interface{}{
  15455. "code": -10,
  15456. "msg": res2.ErrMsg,
  15457. })
  15458. }
  15459. } else {
  15460. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  15461. //if err == nil {
  15462. // c.ServeSuccessJSON(map[string]interface{}{
  15463. // "msg": "退费成功",
  15464. // })
  15465. //} else {
  15466. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15467. // return
  15468. //}
  15469. }
  15470. }
  15471. func (c *HisApiController) RefundDetail() {
  15472. order_id, _ := c.GetInt64("order_id")
  15473. admin_user_id, _ := c.GetInt64("admin_user_id")
  15474. //his_patient_id, _ := c.GetInt64("his_patient_id")
  15475. number := c.GetString("number")
  15476. record_time := c.GetString("record_time")
  15477. patient_id, _ := c.GetInt64("patient_id")
  15478. //med_type, _ := c.GetInt64("med_type")
  15479. timeLayout := "2006-01-02"
  15480. loc, _ := time.LoadLocation("Local")
  15481. adminUser := c.GetAdminUserInfo()
  15482. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15483. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  15484. fmt.Println(err)
  15485. if err != nil {
  15486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  15487. return
  15488. }
  15489. recordDateTime := theTime.Unix()
  15490. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  15491. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  15492. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15493. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15494. var order models.HisOrder
  15495. order, _ = service.GetHisOrderByID(order_id)
  15496. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  15497. if config.IsOpen == 1 { //对接了医保,走医保流程
  15498. var res2 ResultSix
  15499. if miConfig.MdtrtareaAdmvs == "421300" {
  15500. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  15501. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15502. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  15503. resp3, requestErr3 := http.Get(api3)
  15504. if requestErr3 != nil {
  15505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15506. return
  15507. }
  15508. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  15509. if ioErr3 != nil {
  15510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  15511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15512. return
  15513. }
  15514. var respJSON3 map[string]interface{}
  15515. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  15516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15518. return
  15519. }
  15520. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15521. userJSONBytes3, _ := json.Marshal(respJSON3)
  15522. fmt.Println("log")
  15523. fmt.Println(string(userJSONBytes3))
  15524. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  15525. utils.ErrorLog("解析失败:%v", err)
  15526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15527. return
  15528. }
  15529. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15530. if err == nil {
  15531. c.ServeSuccessJSON(map[string]interface{}{
  15532. "msg": "撤销明细成功",
  15533. })
  15534. return
  15535. } else {
  15536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15537. return
  15538. }
  15539. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15540. var resSix10265 ResultSix10265
  15541. var api3 string
  15542. if miConfig.MdtrtareaAdmvs == "320921" {
  15543. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  15544. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15545. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15546. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15547. } else {
  15548. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  15549. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  15550. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15551. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15552. }
  15553. resp3, requestErr3 := http.Get(api3)
  15554. if requestErr3 != nil {
  15555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15556. return
  15557. }
  15558. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  15559. if ioErr3 != nil {
  15560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  15561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15562. return
  15563. }
  15564. var respJSON3 map[string]interface{}
  15565. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  15566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15568. return
  15569. }
  15570. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15571. userJSONBytes3, _ := json.Marshal(respJSON3)
  15572. fmt.Println("log")
  15573. fmt.Println(string(userJSONBytes3))
  15574. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  15575. utils.ErrorLog("解析失败:%v", err)
  15576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15577. return
  15578. }
  15579. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15580. res2.Output = resSix10265.Output
  15581. res2.ErrMsg = resSix10265.ErrMsg
  15582. res2.Cainfo = resSix10265.Cainfo
  15583. res2.WarnMsg = resSix10265.WarnMsg
  15584. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15585. res2.Infcode = infocode
  15586. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15587. if err == nil {
  15588. c.ServeSuccessJSON(map[string]interface{}{
  15589. "msg": "撤销明细成功",
  15590. })
  15591. return
  15592. } else {
  15593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15594. return
  15595. }
  15596. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15597. var resSix10265 ResultSix10265
  15598. var api3 string
  15599. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  15600. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15601. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15602. resp3, requestErr3 := http.Get(api3)
  15603. if requestErr3 != nil {
  15604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15605. return
  15606. }
  15607. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  15608. if ioErr3 != nil {
  15609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  15610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15611. return
  15612. }
  15613. var respJSON3 map[string]interface{}
  15614. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  15615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15617. return
  15618. }
  15619. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15620. userJSONBytes3, _ := json.Marshal(respJSON3)
  15621. fmt.Println("log")
  15622. fmt.Println(string(userJSONBytes3))
  15623. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  15624. utils.ErrorLog("解析失败:%v", err)
  15625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15626. return
  15627. }
  15628. res2.InfRefmsgid = resSix10265.InfRefmsgid
  15629. res2.Output = resSix10265.Output
  15630. res2.ErrMsg = resSix10265.ErrMsg
  15631. res2.Cainfo = resSix10265.Cainfo
  15632. res2.WarnMsg = resSix10265.WarnMsg
  15633. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  15634. res2.Infcode = infocode
  15635. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15636. if err == nil {
  15637. c.ServeSuccessJSON(map[string]interface{}{
  15638. "msg": "撤销明细成功",
  15639. })
  15640. return
  15641. } else {
  15642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15643. return
  15644. }
  15645. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15646. 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)
  15647. var dat map[string]interface{}
  15648. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  15649. fmt.Println(dat)
  15650. } else {
  15651. fmt.Println(err)
  15652. }
  15653. saveLog(result2, src_request, "2205", "撤销明细")
  15654. userJSONBytes, _ := json.Marshal(dat)
  15655. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15656. utils.ErrorLog("解析失败:%v", err)
  15657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15658. return
  15659. }
  15660. if res2.Infcode == 0 {
  15661. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15662. if err == nil {
  15663. c.ServeSuccessJSON(map[string]interface{}{
  15664. "msg": "撤销明细成功",
  15665. })
  15666. return
  15667. } else {
  15668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15669. return
  15670. }
  15671. } else {
  15672. c.ServeSuccessJSON(map[string]interface{}{
  15673. "code": -10,
  15674. "msg": res2.ErrMsg,
  15675. })
  15676. }
  15677. } else if miConfig.MdtrtareaAdmvs == "360399" {
  15678. 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, "")
  15679. var dat map[string]interface{}
  15680. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  15681. fmt.Println(dat)
  15682. } else {
  15683. fmt.Println(err)
  15684. }
  15685. saveLog(result2, src_request, "2205", "撤销明细")
  15686. userJSONBytes, _ := json.Marshal(dat)
  15687. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15688. utils.ErrorLog("解析失败:%v", err)
  15689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15690. return
  15691. }
  15692. if res2.Infcode == 0 {
  15693. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15694. if err == nil {
  15695. c.ServeSuccessJSON(map[string]interface{}{
  15696. "msg": "撤销明细成功",
  15697. })
  15698. return
  15699. } else {
  15700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15701. return
  15702. }
  15703. } else {
  15704. c.ServeSuccessJSON(map[string]interface{}{
  15705. "code": -10,
  15706. "msg": res2.ErrMsg,
  15707. })
  15708. }
  15709. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15710. 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, "")
  15711. var dat map[string]interface{}
  15712. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  15713. fmt.Println(dat)
  15714. } else {
  15715. fmt.Println(err)
  15716. }
  15717. saveLog(result2, src_request, "2205", "撤销明细")
  15718. userJSONBytes, _ := json.Marshal(dat)
  15719. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15720. utils.ErrorLog("解析失败:%v", err)
  15721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15722. return
  15723. }
  15724. if res2.Infcode == 0 {
  15725. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15726. if err == nil {
  15727. c.ServeSuccessJSON(map[string]interface{}{
  15728. "msg": "撤销明细成功",
  15729. })
  15730. return
  15731. } else {
  15732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15733. return
  15734. }
  15735. } else {
  15736. c.ServeSuccessJSON(map[string]interface{}{
  15737. "code": -10,
  15738. "msg": res2.ErrMsg,
  15739. })
  15740. }
  15741. } else {
  15742. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  15743. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  15744. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  15745. resp2, requestErr2 := http.Get(api2)
  15746. if requestErr2 != nil {
  15747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15748. return
  15749. }
  15750. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  15751. if ioErr2 != nil {
  15752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  15753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15754. return
  15755. }
  15756. var respJSON2 map[string]interface{}
  15757. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  15758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15760. return
  15761. }
  15762. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15763. if err == nil {
  15764. c.ServeSuccessJSON(map[string]interface{}{
  15765. "msg": "撤销明细成功",
  15766. })
  15767. return
  15768. } else {
  15769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15770. return
  15771. }
  15772. }
  15773. } else {
  15774. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  15775. if err == nil {
  15776. c.ServeSuccessJSON(map[string]interface{}{
  15777. "msg": "退费成功",
  15778. })
  15779. } else {
  15780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15781. return
  15782. }
  15783. }
  15784. }
  15785. // 对账
  15786. func (c *HisApiController) GetCheckAccount() {
  15787. start_time := c.GetString("start_time")
  15788. end_time := c.GetString("end_time")
  15789. insutype := c.GetString("insutype")
  15790. clr_type := c.GetString("clr_type")
  15791. clr_org := c.GetString("clr_optins")
  15792. admin_user_id, _ := c.GetInt64("admin_user_id")
  15793. adminUser := c.GetAdminUserInfo()
  15794. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15795. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15796. if len(clr_org) == 0 {
  15797. clr_org = miConfig.MdtrtareaAdmvs
  15798. }
  15799. timeLayout := "2006-01-02"
  15800. loc, _ := time.LoadLocation("Local")
  15801. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  15802. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  15803. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  15804. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  15805. fixmedins_setl_cnt := int64(len(orders))
  15806. var medfee_sumamt float64
  15807. var acct_pay float64
  15808. var fund_pay_sumamt float64
  15809. for _, item := range orders {
  15810. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  15811. acct_pay = acct_pay + item.AcctPay
  15812. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  15813. }
  15814. var user_name string
  15815. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15816. if role.ID == 0 {
  15817. user_name = "xxx"
  15818. } else {
  15819. user_name = role.UserName
  15820. }
  15821. var res ResultEight
  15822. var res10188 ResultEightFor10188
  15823. if config.IsOpen == 1 {
  15824. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15825. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  15826. "insutype=" + insutype +
  15827. "&clr_type=" + clr_type +
  15828. "&setl_optins=" + clr_org +
  15829. "&stmt_begndate=" + start_time +
  15830. "&stm_enddate=" + end_time +
  15831. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  15832. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  15833. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  15834. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  15835. "&fixmedins_code=" + miConfig.Code +
  15836. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  15837. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  15838. "&secret_key=" + miConfig.SecretKey +
  15839. "&org_name=" + miConfig.OrgName +
  15840. "&doctor=" + user_name +
  15841. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  15842. fmt.Println(api)
  15843. resp, requestErr := http.Get(api)
  15844. if requestErr != nil {
  15845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15846. return
  15847. }
  15848. body, ioErr := ioutil.ReadAll(resp.Body)
  15849. fmt.Println(body)
  15850. if ioErr != nil {
  15851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15853. return
  15854. }
  15855. var respJSON map[string]interface{}
  15856. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15859. return
  15860. }
  15861. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15862. userJSONBytes, _ := json.Marshal(respJSON)
  15863. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15864. utils.ErrorLog("解析失败:%v", err)
  15865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15866. return
  15867. }
  15868. res.InfRefmsgid = res10188.InfRefmsgid
  15869. res.Output = res10188.Output
  15870. res.ErrMsg = res10188.ErrMsg
  15871. res.Cainfo = res10188.Cainfo
  15872. res.WarnMsg = res10188.WarnMsg
  15873. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  15874. res.Infcode = infocode
  15875. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15876. if clr_type == "11" {
  15877. fixmedins_setl_cnt = 0
  15878. }
  15879. //if clr_type == "21" {
  15880. // clr_type = "22"
  15881. //}
  15882. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  15883. "insutype=" + insutype +
  15884. "&clr_type=" + clr_type +
  15885. "&setl_optins=" + clr_org +
  15886. "&stmt_begndate=" + start_time +
  15887. "&stm_enddate=" + end_time +
  15888. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  15889. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  15890. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  15891. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  15892. "&fixmedins_code=" + miConfig.Code +
  15893. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  15894. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  15895. "&secret_key=" + miConfig.SecretKey +
  15896. "&org_name=" + miConfig.OrgName +
  15897. "&doctor=" + user_name
  15898. resp, requestErr := http.Get(api)
  15899. if requestErr != nil {
  15900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15901. return
  15902. }
  15903. body, ioErr := ioutil.ReadAll(resp.Body)
  15904. if ioErr != nil {
  15905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15907. return
  15908. }
  15909. var respJSON map[string]interface{}
  15910. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15913. return
  15914. }
  15915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15916. result, _ := json.Marshal(respJSON)
  15917. fmt.Println("log")
  15918. fmt.Println(string(result))
  15919. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  15920. utils.ErrorLog("解析失败:%v", err)
  15921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15922. return
  15923. }
  15924. res.InfRefmsgid = res10188.InfRefmsgid
  15925. res.Output = res10188.Output
  15926. res.ErrMsg = res10188.ErrMsg
  15927. res.Cainfo = res10188.Cainfo
  15928. res.WarnMsg = res10188.WarnMsg
  15929. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  15930. res.Infcode = infocode
  15931. } else if miConfig.MdtrtareaAdmvs == "350500" {
  15932. var baseParams models.BaseParams
  15933. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15934. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15935. baseParams.SecretKey = miConfig.SecretKey
  15936. baseParams.OrgName = miConfig.OrgName
  15937. baseParams.FixmedinsCode = miConfig.Code
  15938. baseParams.EncKey = miConfig.EncKey
  15939. baseParams.AppSecret = miConfig.AppSecret
  15940. baseParams.SignKey = miConfig.SignKey
  15941. baseParams.AppID = miConfig.Code
  15942. baseParams.Doctor = role.UserName
  15943. baseParams.RequestUrl = miConfig.Url
  15944. businessParams := models.BusinessParams{
  15945. Insutype: insutype,
  15946. ClrType: clr_type,
  15947. SetlOptins: clr_org,
  15948. StmtBegndate: start_time,
  15949. StmtEnddate: end_time,
  15950. MedfeeSumamt: medfee_sumamt,
  15951. FundPaySumamt: fund_pay_sumamt,
  15952. AcctPay: acct_pay,
  15953. FixmedinsSetlCnt: fixmedins_setl_cnt,
  15954. }
  15955. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  15956. fmt.Println(requestLog)
  15957. fmt.Println(result)
  15958. fmt.Println(err_msg)
  15959. var dat map[string]interface{}
  15960. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15961. fmt.Println(dat)
  15962. } else {
  15963. fmt.Println(err)
  15964. }
  15965. userJSONBytes, _ := json.Marshal(dat)
  15966. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15967. utils.ErrorLog("解析失败:%v", err)
  15968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15969. return
  15970. }
  15971. } else if miConfig.MdtrtareaAdmvs == "430800" {
  15972. var baseParams models.BaseParams
  15973. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15974. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15975. baseParams.SecretKey = miConfig.SecretKey
  15976. baseParams.OrgName = miConfig.OrgName
  15977. baseParams.FixmedinsCode = miConfig.Code
  15978. baseParams.EncKey = miConfig.EncKey
  15979. baseParams.AppSecret = miConfig.AppSecret
  15980. baseParams.SignKey = miConfig.SignKey
  15981. baseParams.AppID = miConfig.Code
  15982. baseParams.Doctor = role.UserName
  15983. baseParams.RequestUrl = miConfig.Url
  15984. baseParams.AccessKey = miConfig.AccessKey
  15985. businessParams := models.BusinessParams{
  15986. Insutype: insutype,
  15987. ClrType: clr_type,
  15988. SetlOptins: "430822",
  15989. StmtBegndate: start_time,
  15990. StmtEnddate: end_time,
  15991. MedfeeSumamt: medfee_sumamt,
  15992. FundPaySumamt: fund_pay_sumamt,
  15993. AcctPay: acct_pay,
  15994. FixmedinsSetlCnt: fixmedins_setl_cnt,
  15995. }
  15996. 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)
  15997. fmt.Println(requestLog)
  15998. fmt.Println(result)
  15999. var dat map[string]interface{}
  16000. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16001. fmt.Println(dat)
  16002. } else {
  16003. fmt.Println(err)
  16004. }
  16005. userJSONBytes, _ := json.Marshal(dat)
  16006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16007. utils.ErrorLog("解析失败:%v", err)
  16008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16009. return
  16010. }
  16011. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16012. var baseParams models.BaseParams
  16013. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  16014. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  16015. baseParams.SecretKey = miConfig.SecretKey
  16016. baseParams.OrgName = miConfig.OrgName
  16017. baseParams.FixmedinsCode = miConfig.Code
  16018. baseParams.EncKey = miConfig.EncKey
  16019. baseParams.AppSecret = miConfig.AppSecret
  16020. baseParams.SignKey = miConfig.SignKey
  16021. baseParams.AppID = miConfig.Code
  16022. baseParams.Doctor = role.UserName
  16023. baseParams.RequestUrl = miConfig.Url
  16024. businessParams := models.BusinessParams{
  16025. Insutype: insutype,
  16026. ClrType: clr_type,
  16027. SetlOptins: clr_org,
  16028. StmtBegndate: start_time,
  16029. StmtEnddate: end_time,
  16030. MedfeeSumamt: medfee_sumamt,
  16031. FundPaySumamt: fund_pay_sumamt,
  16032. AcctPay: acct_pay,
  16033. FixmedinsSetlCnt: fixmedins_setl_cnt,
  16034. }
  16035. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  16036. fmt.Println(requestLog)
  16037. fmt.Println(result)
  16038. fmt.Println(err_msg)
  16039. var dat map[string]interface{}
  16040. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16041. fmt.Println(dat)
  16042. } else {
  16043. fmt.Println(err)
  16044. }
  16045. userJSONBytes, _ := json.Marshal(dat)
  16046. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16047. utils.ErrorLog("解析失败:%v", err)
  16048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16049. return
  16050. }
  16051. } else {
  16052. if len(clr_type) == 0 {
  16053. clr_type = "11"
  16054. }
  16055. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  16056. "insutype=" + insutype +
  16057. "&clr_type=" + clr_type +
  16058. "&setl_optins=" + clr_org +
  16059. "&stmt_begndate=" + start_time +
  16060. "&stm_enddate=" + end_time +
  16061. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  16062. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  16063. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  16064. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  16065. "&fixmedins_code=" + miConfig.Code +
  16066. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  16067. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  16068. "&secret_key=" + miConfig.SecretKey +
  16069. "&org_name=" + miConfig.OrgName +
  16070. "&doctor=" + user_name
  16071. fmt.Println(api)
  16072. resp, requestErr := http.Get(api)
  16073. if requestErr != nil {
  16074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16075. return
  16076. }
  16077. body, ioErr := ioutil.ReadAll(resp.Body)
  16078. fmt.Println(body)
  16079. if ioErr != nil {
  16080. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16082. return
  16083. }
  16084. var respJSON map[string]interface{}
  16085. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16088. return
  16089. }
  16090. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16091. userJSONBytes, _ := json.Marshal(respJSON)
  16092. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16093. utils.ErrorLog("解析失败:%v", err)
  16094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16095. return
  16096. }
  16097. }
  16098. if res.Infcode == 0 {
  16099. if res.Output.Stmtinfo.StmtRslt == "0" {
  16100. micc := &models.MedicalInsuranceCostCompare{
  16101. StartTime: startime.Unix(),
  16102. EndTime: endtime.Unix(),
  16103. Insutype: insutype,
  16104. CheckType: 1,
  16105. Num: fixmedins_setl_cnt,
  16106. Mtime: time.Now().Unix(),
  16107. Status: 1,
  16108. UserOrgId: adminUser.CurrentOrgId,
  16109. CostTotal: medfee_sumamt,
  16110. FuncTotal: fund_pay_sumamt,
  16111. PsnPay: acct_pay,
  16112. Creator: admin_user_id,
  16113. Ctime: time.Now().Unix(),
  16114. ClrType: clr_type,
  16115. }
  16116. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  16117. if err == nil {
  16118. c.ServeSuccessJSON(map[string]interface{}{
  16119. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  16120. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  16121. })
  16122. } else {
  16123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16124. }
  16125. } else {
  16126. c.ServeSuccessJSON(map[string]interface{}{
  16127. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  16128. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  16129. })
  16130. }
  16131. } else {
  16132. c.ServeSuccessJSON(map[string]interface{}{
  16133. "code": -10,
  16134. "msg": res.ErrMsg,
  16135. })
  16136. }
  16137. }
  16138. }
  16139. func (c *HisApiController) Check310() {
  16140. adminUser := c.GetAdminUserInfo()
  16141. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16142. var user_name string
  16143. user_name = "高慧裕"
  16144. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  16145. "insutype=" + "310" +
  16146. "&clr_type=" + "" +
  16147. "&setl_optins=" + "441202" +
  16148. "&stmt_begndate=" + "2022-03-01" +
  16149. "&stm_enddate=" + "2022-03-31" +
  16150. "&medfee_sumamt=" + "194930.12" +
  16151. "&fund_pay_sumamt=" + "188741.46" +
  16152. "&acct_pay=" + "0" +
  16153. "&fixmedins_setl_cnt=" + "452" +
  16154. "&fixmedins_code=" + miConfig.Code +
  16155. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  16156. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  16157. "&secret_key=" + miConfig.SecretKey +
  16158. "&org_name=" + miConfig.OrgName +
  16159. "&doctor=" + user_name
  16160. fmt.Println(api)
  16161. resp, requestErr := http.Get(api)
  16162. if requestErr != nil {
  16163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16164. return
  16165. }
  16166. body, ioErr := ioutil.ReadAll(resp.Body)
  16167. fmt.Println(body)
  16168. if ioErr != nil {
  16169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16171. return
  16172. }
  16173. var respJSON map[string]interface{}
  16174. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16177. return
  16178. }
  16179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16180. userJSONBytes, _ := json.Marshal(respJSON)
  16181. var res ResultEight
  16182. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16183. utils.ErrorLog("解析失败:%v", err)
  16184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16185. return
  16186. }
  16187. }
  16188. func (c *HisApiController) Check390() {
  16189. adminUser := c.GetAdminUserInfo()
  16190. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16191. var user_name string
  16192. user_name = "高慧裕"
  16193. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  16194. "insutype=" + "390" +
  16195. "&clr_type=" + "" +
  16196. "&setl_optins=" + "441202" +
  16197. "&stmt_begndate=" + "2022-03-01" +
  16198. "&stm_enddate=" + "2022-03-31" +
  16199. "&medfee_sumamt=" + "1068448.89" +
  16200. "&fund_pay_sumamt=" + "1014677.62" +
  16201. "&acct_pay=" + "0" +
  16202. "&fixmedins_setl_cnt=" + "1950" +
  16203. "&fixmedins_code=" + miConfig.Code +
  16204. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  16205. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  16206. "&secret_key=" + miConfig.SecretKey +
  16207. "&org_name=" + miConfig.OrgName +
  16208. "&doctor=" + user_name
  16209. fmt.Println(api)
  16210. resp, requestErr := http.Get(api)
  16211. if requestErr != nil {
  16212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16213. return
  16214. }
  16215. body, ioErr := ioutil.ReadAll(resp.Body)
  16216. fmt.Println(body)
  16217. if ioErr != nil {
  16218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16220. return
  16221. }
  16222. var respJSON map[string]interface{}
  16223. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16226. return
  16227. }
  16228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16229. userJSONBytes, _ := json.Marshal(respJSON)
  16230. var res ResultEight
  16231. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16232. utils.ErrorLog("解析失败:%v", err)
  16233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16234. return
  16235. }
  16236. }
  16237. // 对账明细
  16238. func (c *HisApiController) GetCheckDetailAccount() {
  16239. start_time := c.GetString("start_time")
  16240. end_time := c.GetString("end_time")
  16241. admin_user_id, _ := c.GetInt64("admin_user_id")
  16242. adminUser := c.GetAdminUserInfo()
  16243. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16244. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16245. timeLayout := "2006-01-02"
  16246. loc, _ := time.LoadLocation("Local")
  16247. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  16248. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  16249. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  16250. rand.Seed(time.Now().UnixNano())
  16251. num := rand.Intn(30000)
  16252. Mkdir(miConfig.OrgName)
  16253. file := strconv.FormatInt(int64(num), 10)
  16254. file_name := file + ".txt"
  16255. zip_name := file + ".zip"
  16256. zip_path := miConfig.OrgName + "/" + zip_name
  16257. file_path := miConfig.OrgName + "/" + file_name
  16258. decimal.DivisionPrecision = 2
  16259. var medfee_sumamt float64
  16260. var psn_cash_pay float64
  16261. var fund_pay_sumamt float64
  16262. fixmedins_setl_cnt := int64(len(orders))
  16263. for _, item := range orders {
  16264. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  16265. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  16266. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  16267. }
  16268. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  16269. defer f.Close()
  16270. if err != nil {
  16271. fmt.Println(err.Error())
  16272. } else {
  16273. for _, item := range orders {
  16274. var refd_setl_flag string
  16275. if item.OrderStatus == 2 {
  16276. refd_setl_flag = "0"
  16277. var str string
  16278. str = item.SetlId + " " +
  16279. item.MdtrtId + " " +
  16280. item.PsnNo + " " +
  16281. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  16282. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  16283. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  16284. _, err = f.Write([]byte(str))
  16285. }
  16286. if item.OrderStatus == 3 {
  16287. var str string
  16288. str = item.SetlId + " " +
  16289. item.MdtrtId + " " +
  16290. item.PsnNo + " " +
  16291. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  16292. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  16293. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  16294. _, err = f.Write([]byte(str))
  16295. var str2 string
  16296. str2 = item.SetlId + " " +
  16297. item.MdtrtId + " " +
  16298. item.PsnNo + " " +
  16299. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  16300. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  16301. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  16302. _, err = f.Write([]byte(str2))
  16303. }
  16304. }
  16305. }
  16306. Zip(file_path, zip_path)
  16307. fmt.Println(ReadFile(zip_path))
  16308. fmt.Println(string(ReadFile(zip_path)))
  16309. if config.IsOpen == 1 {
  16310. var user_name string
  16311. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16312. if role.ID == 0 {
  16313. user_name = "管理员"
  16314. } else {
  16315. user_name = role.UserName
  16316. }
  16317. baseParams := models.BaseParams{
  16318. SecretKey: miConfig.SecretKey,
  16319. FixmedinsCode: miConfig.Code,
  16320. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  16321. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  16322. OrgName: miConfig.OrgName,
  16323. Doctor: user_name,
  16324. }
  16325. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  16326. var dat map[string]interface{}
  16327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16328. fmt.Println(dat)
  16329. } else {
  16330. fmt.Println(err)
  16331. }
  16332. userJSONBytes, _ := json.Marshal(dat)
  16333. var res ResultNine
  16334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16335. utils.ErrorLog("解析失败:%v", err)
  16336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16337. return
  16338. }
  16339. if res.Infcode == 0 {
  16340. fileNo := res.Output.FileQuryNo
  16341. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  16342. "file_qury_no=" + fileNo +
  16343. "&setl_optins=" + "定点医保中心" +
  16344. "&stmt_begndate=" + start_time +
  16345. "&stm_enddate=" + end_time +
  16346. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  16347. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  16348. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  16349. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  16350. "&fixmedins_code=" + miConfig.Code +
  16351. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  16352. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  16353. "&secret_key=" + miConfig.SecretKey +
  16354. "&org_name=" + miConfig.OrgName +
  16355. "&doctor=" + user_name
  16356. resp, requestErr := http.Get(api)
  16357. if requestErr != nil {
  16358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16359. return
  16360. }
  16361. body, ioErr := ioutil.ReadAll(resp.Body)
  16362. if ioErr != nil {
  16363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16365. return
  16366. }
  16367. var respJSON map[string]interface{}
  16368. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16371. return
  16372. }
  16373. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16374. userJSONBytes, _ := json.Marshal(respJSON)
  16375. var res ResultTen
  16376. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16377. utils.ErrorLog("解析失败:%v", err)
  16378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16379. return
  16380. }
  16381. if res.Infcode == 0 {
  16382. service.Gdyb9102(baseParams, zip_name, fileNo)
  16383. micc := &models.MedicalInsuranceCostCompare{
  16384. StartTime: startime.Unix(),
  16385. EndTime: endtime.Unix(),
  16386. Insutype: "0",
  16387. CheckType: 2,
  16388. Num: fixmedins_setl_cnt,
  16389. Mtime: time.Now().Unix(),
  16390. Status: 1,
  16391. UserOrgId: adminUser.CurrentOrgId,
  16392. CostTotal: medfee_sumamt,
  16393. FuncTotal: fund_pay_sumamt,
  16394. PsnPay: psn_cash_pay,
  16395. Creator: admin_user_id,
  16396. Ctime: time.Now().Unix(),
  16397. }
  16398. service.CreateMedicalInsuranceCostCompareRecord(micc)
  16399. c.ServeSuccessJSON(map[string]interface{}{
  16400. "msg": "明细对账成功",
  16401. })
  16402. }
  16403. } else {
  16404. }
  16405. }
  16406. }
  16407. type CustomOrderInfo struct {
  16408. Name string
  16409. Spec string
  16410. Unit string
  16411. Count float64
  16412. Price float64
  16413. Total float64
  16414. }
  16415. func (c *HisApiController) GetBatchSettleAccounts() {
  16416. admin_user_id, _ := c.GetInt64("admin_user_id")
  16417. order_ids := c.GetString("order_ids")
  16418. order_ids_arr := strings.Split(order_ids, ",")
  16419. data3 := []map[string]interface{}{}
  16420. for _, item := range order_ids_arr {
  16421. id, _ := strconv.ParseInt(item, 10, 64)
  16422. order_id := id
  16423. adminUser := c.GetAdminUserInfo()
  16424. order, _ := service.GetHisOrderByID(order_id)
  16425. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  16426. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  16427. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  16428. orderInfos = append(orderInfos, orderInfos_two...)
  16429. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  16430. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  16431. var diagnosis_ids []string
  16432. if his.ID > 0 {
  16433. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  16434. } else {
  16435. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  16436. }
  16437. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  16438. var dia_config []*models.HisXtDiagnoseConfig
  16439. var name string
  16440. for _, item := range diagnosis_ids {
  16441. id, _ := strconv.ParseInt(item, 10, 64)
  16442. diagnosisConfig, _ := service.FindDiagnoseById(id)
  16443. dia_config = append(dia_config, &diagnosisConfig)
  16444. if len(name) == 0 {
  16445. name = diagnosisConfig.ClassName
  16446. } else {
  16447. name = name + "," + diagnosisConfig.ClassName
  16448. }
  16449. }
  16450. var bedCostTotal float64 = 0 //床位总费
  16451. var bedCostSelfTotal float64 = 0 //床位自费
  16452. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  16453. var bedSelfTotal float64 = 0 //床位部分项目自费
  16454. var bedInscpTotal float64 = 0 //床位部分项目自费
  16455. var operationCostTotal float64 = 0 //手术费
  16456. var operationCostSelfTotal float64 = 0 //手术费
  16457. var operationCostPartSelfTotal float64 = 0 //手术费
  16458. var operationSelfTotal float64 = 0 //床位部分项目自费
  16459. var operationInscpTotal float64 = 0 //床位部分项目自费
  16460. var otherCostTotal float64 = 0 //其他费用
  16461. var otherCostSelfTotal float64 = 0 //其他费用
  16462. var otherCostPartSelfTotal float64 = 0 //其他费用
  16463. var otherSelfTotal float64 = 0 //床位部分项目自费
  16464. var otherInscpTotal float64 = 0 //床位部分项目自费
  16465. var materialCostTotal float64 = 0 //材料费
  16466. var materialCostSelfTotal float64 = 0 //材料费
  16467. var materialCostPartSelfTotal float64 = 0 //材料费
  16468. var materialSelfTotal float64 = 0 //床位部分项目自费
  16469. var materialInscpTotal float64 = 0 //床位部分项目自费
  16470. var westernMedicineCostTotal float64 = 0 //西药费
  16471. var westernMedicineCostSelfTotal float64 = 0 //西药费
  16472. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  16473. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  16474. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  16475. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  16476. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  16477. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  16478. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  16479. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  16480. var checkCostTotal float64 = 0 //检查费
  16481. var checkCostSelfTotal float64 = 0 //检查费
  16482. var checkCostPartSelfTotal float64 = 0 //检查费
  16483. var checkSelfTotal float64 = 0 //床位部分项目自费
  16484. var checkInscpTotal float64 = 0 //床位部分项目自费
  16485. var laboratoryCostTotal float64 = 0 //化验费
  16486. var laboratoryCostSelfTotal float64 = 0 //化验费
  16487. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  16488. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  16489. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  16490. var treatCostTotal float64 = 0 //治疗费用
  16491. var treatCostSelfTotal float64 = 0 //治疗费用
  16492. var treatCostPartSelfTotal float64 = 0 //治疗费用
  16493. var treatSelfTotal float64 = 0 //床位部分项目自费
  16494. var treatInscpTotal float64 = 0 //床位部分项目自费
  16495. decimal.DivisionPrecision = 2
  16496. for _, item := range orderInfos {
  16497. if item.MedChrgitmType == "01" { //床位费
  16498. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16499. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16500. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16501. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16502. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16503. }
  16504. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  16505. if item.MedChrgitmType == "03" { //检查费
  16506. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16507. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16508. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16509. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16510. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16511. }
  16512. } else {
  16513. if item.MedChrgitmType == "03" { //检查费
  16514. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16515. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16516. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16517. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16518. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16519. }
  16520. }
  16521. if item.MedChrgitmType == "04" { //化验费
  16522. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16523. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16524. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16525. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16526. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16527. }
  16528. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  16529. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16530. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16531. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16532. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16533. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16534. }
  16535. if item.MedChrgitmType == "06" { //手术费
  16536. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16537. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16538. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16539. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16540. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16541. }
  16542. if item.MedChrgitmType == "08" { //材料费
  16543. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16544. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16545. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16546. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16547. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16548. }
  16549. if item.MedChrgitmType == "09" { //西药费
  16550. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16551. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16552. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16553. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16554. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16555. }
  16556. if item.MedChrgitmType == "11" { //中成费
  16557. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16558. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16559. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16560. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16561. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16562. }
  16563. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  16564. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16565. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16566. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16567. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16568. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16569. }
  16570. }
  16571. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16572. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16573. var user_name string
  16574. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16575. if role.ID == 0 {
  16576. user_name = "管理员"
  16577. } else {
  16578. user_name = role.UserName
  16579. }
  16580. baseParams := models.BaseParams{
  16581. SecretKey: miConfig.SecretKey,
  16582. FixmedinsCode: miConfig.Code,
  16583. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  16584. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  16585. OrgName: miConfig.OrgName,
  16586. Doctor: user_name,
  16587. RequestUrl: miConfig.Url,
  16588. AccessKey: miConfig.AccessKey,
  16589. }
  16590. businessParams := models.BusinessParams{
  16591. PsnNo: order.PsnNo,
  16592. MdtrtId: order.MdtrtId,
  16593. SetlId: order.SetlId,
  16594. }
  16595. var res ResultEleven
  16596. var resEleven10265 ResultEleven10265
  16597. if config.IsOpen == 1 {
  16598. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  16599. result := service.Gdyb5203(baseParams, businessParams)
  16600. //service.Gdyb5204(baseParams, businessParams)
  16601. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  16602. var dat map[string]interface{}
  16603. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16604. fmt.Println(dat)
  16605. } else {
  16606. fmt.Println(err)
  16607. }
  16608. userJSONBytes, _ := json.Marshal(dat)
  16609. if miConfig.Code == "H15049901371" {
  16610. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  16611. utils.ErrorLog("解析失败:%v", err)
  16612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16613. return
  16614. }
  16615. res.InfRefmsgid = resEleven10265.InfRefmsgid
  16616. res.Output = resEleven10265.Output
  16617. res.ErrMsg = resEleven10265.ErrMsg
  16618. res.Cainfo = resEleven10265.Cainfo
  16619. res.WarnMsg = resEleven10265.WarnMsg
  16620. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  16621. res.Infcode = infocode
  16622. } else {
  16623. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16624. utils.ErrorLog("解析失败:%v", err)
  16625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16626. return
  16627. }
  16628. }
  16629. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16630. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  16631. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  16632. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  16633. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  16634. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16635. var doctor_name string
  16636. if roles.ID == 0 {
  16637. doctor_name = "管理员"
  16638. } else {
  16639. doctor_name = roles.UserName
  16640. }
  16641. yiliao_leibie := ""
  16642. switch order.MedType {
  16643. case "11":
  16644. yiliao_leibie = "普通门诊"
  16645. break
  16646. case "12":
  16647. yiliao_leibie = "门诊挂号"
  16648. break
  16649. case "13":
  16650. yiliao_leibie = "急诊"
  16651. break
  16652. case "14":
  16653. yiliao_leibie = "门诊特殊病"
  16654. break
  16655. case "15":
  16656. yiliao_leibie = "门诊统筹"
  16657. break
  16658. case "16":
  16659. yiliao_leibie = "门诊慢性病"
  16660. break
  16661. case "21":
  16662. yiliao_leibie = "普通住院"
  16663. break
  16664. }
  16665. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  16666. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  16667. if res.Infcode == 0 {
  16668. data2 := map[string]interface{}{
  16669. "diagnosis": name,
  16670. "order_infos": orderInfos,
  16671. "number": order.MdtrtId,
  16672. "date": order.SettleAccountsDate,
  16673. "charge_admin": charge_admin,
  16674. "printor_admin": printor_admin,
  16675. "info": res.Output.Setlinfo,
  16676. "order": order,
  16677. "bedCostTotal": bedCostTotal,
  16678. "bedCostSelfTotal": bedCostSelfTotal,
  16679. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  16680. "bedSelfTotal": bedSelfTotal,
  16681. "bedInscpTotal": bedInscpTotal,
  16682. "operationCostTotal": operationCostTotal,
  16683. "operationCostSelfTotal": operationCostSelfTotal,
  16684. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  16685. "operationSelfTotal": operationSelfTotal,
  16686. "operationInscpTotal": operationInscpTotal,
  16687. "otherCostTotal": otherCostTotal,
  16688. "otherCostSelfTotal": otherCostSelfTotal,
  16689. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  16690. "otherSelfTotal": otherSelfTotal,
  16691. "otherInscpTotal": otherInscpTotal,
  16692. "materialCostTotal": materialCostTotal,
  16693. "materialCostSelfTotal": materialCostSelfTotal,
  16694. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  16695. "materialSelfTotal": materialSelfTotal,
  16696. "materialInscpTotal": materialInscpTotal,
  16697. "westernMedicineCostTotal": westernMedicineCostTotal,
  16698. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  16699. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  16700. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  16701. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  16702. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  16703. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  16704. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  16705. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  16706. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  16707. "checkCostTotal": checkCostTotal,
  16708. "checkCostSelfTotal": checkCostSelfTotal,
  16709. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  16710. "checkSelfTotal": checkSelfTotal,
  16711. "checkInscpTotal": checkInscpTotal,
  16712. "laboratoryCostTotal": laboratoryCostTotal,
  16713. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  16714. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  16715. "laboratorySelfTotal": laboratorySelfTotal,
  16716. "laboratoryInscpTotal": laboratoryInscpTotal,
  16717. "treatCostTotal": treatCostTotal,
  16718. "treatCostSelfTotal": treatCostSelfTotal,
  16719. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  16720. "treatSelfTotal": treatSelfTotal,
  16721. "treatInscpTotal": treatInscpTotal,
  16722. "doctor_info": doctor_info,
  16723. "doctor_code": adminRole_two.DoctorCode,
  16724. "doctor_name": doctor_name,
  16725. "health_card_no": order.PsnNo,
  16726. "department": departments.Name,
  16727. "yiliao_leibie": yiliao_leibie,
  16728. "after_money": order.AccountPrice,
  16729. "patient": patient,
  16730. "org_name": miConfig.OrgName,
  16731. "org_code": miConfig.Code,
  16732. "order_number": order.Number,
  16733. "his_hospital": his_hospital,
  16734. "his": his,
  16735. "dia_config": dia_config,
  16736. "psn_cash_pay": order.PsnCashPay,
  16737. //"check_order_info": cus_slice,
  16738. }
  16739. data3 = append(data3, data2)
  16740. }
  16741. }
  16742. }
  16743. c.ServeSuccessJSON(map[string]interface{}{
  16744. "infos": data3,
  16745. })
  16746. }
  16747. func (c *HisApiController) GetSettleAccounts() {
  16748. //id, _ := c.GetInt64("id")
  16749. //record_time := c.GetString("record_time")
  16750. order_id, _ := c.GetInt64("order_id")
  16751. admin_user_id, _ := c.GetInt64("admin_user_id")
  16752. //timeLayout := "2006-01-02"
  16753. //loc, _ := time.LoadLocation("Local")
  16754. //
  16755. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  16756. //if err != nil {
  16757. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  16758. // return
  16759. //}
  16760. //recordDateTime := theTime.Unix()
  16761. adminUser := c.GetAdminUserInfo()
  16762. order, _ := service.GetHisOrderByID(order_id)
  16763. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  16764. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  16765. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  16766. orderInfos = append(orderInfos, orderInfos_two...)
  16767. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  16768. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  16769. var diagnosis_ids []string
  16770. if his.ID > 0 {
  16771. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  16772. } else {
  16773. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  16774. }
  16775. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  16776. var dia_config []*models.HisXtDiagnoseConfig
  16777. var name string
  16778. for _, item := range diagnosis_ids {
  16779. id, _ := strconv.ParseInt(item, 10, 64)
  16780. diagnosisConfig, _ := service.FindDiagnoseById(id)
  16781. dia_config = append(dia_config, &diagnosisConfig)
  16782. if len(name) == 0 {
  16783. name = diagnosisConfig.ClassName
  16784. } else {
  16785. name = name + "," + diagnosisConfig.ClassName
  16786. }
  16787. }
  16788. var bedCostTotal float64 = 0 //床位总费
  16789. var bedCostSelfTotal float64 = 0 //床位自费
  16790. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  16791. var bedSelfTotal float64 = 0 //床位部分项目自费
  16792. var bedInscpTotal float64 = 0 //床位部分项目自费
  16793. var operationCostTotal float64 = 0 //手术费
  16794. var operationCostSelfTotal float64 = 0 //手术费
  16795. var operationCostPartSelfTotal float64 = 0 //手术费
  16796. var operationSelfTotal float64 = 0 //床位部分项目自费
  16797. var operationInscpTotal float64 = 0 //床位部分项目自费
  16798. var otherCostTotal float64 = 0 //其他费用
  16799. var otherCostSelfTotal float64 = 0 //其他费用
  16800. var otherCostPartSelfTotal float64 = 0 //其他费用
  16801. var otherSelfTotal float64 = 0 //床位部分项目自费
  16802. var otherInscpTotal float64 = 0 //床位部分项目自费
  16803. var materialCostTotal float64 = 0 //材料费
  16804. var materialCostSelfTotal float64 = 0 //材料费
  16805. var materialCostPartSelfTotal float64 = 0 //材料费
  16806. var materialSelfTotal float64 = 0 //床位部分项目自费
  16807. var materialInscpTotal float64 = 0 //床位部分项目自费
  16808. var westernMedicineCostTotal float64 = 0 //西药费
  16809. var westernMedicineCostSelfTotal float64 = 0 //西药费
  16810. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  16811. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  16812. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  16813. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  16814. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  16815. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  16816. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  16817. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  16818. var checkCostTotal float64 = 0 //检查费
  16819. var checkCostSelfTotal float64 = 0 //检查费
  16820. var checkCostPartSelfTotal float64 = 0 //检查费
  16821. var checkSelfTotal float64 = 0 //床位部分项目自费
  16822. var checkInscpTotal float64 = 0 //床位部分项目自费
  16823. var laboratoryCostTotal float64 = 0 //化验费
  16824. var laboratoryCostSelfTotal float64 = 0 //化验费
  16825. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  16826. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  16827. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  16828. var treatCostTotal float64 = 0 //治疗费用
  16829. var treatCostSelfTotal float64 = 0 //治疗费用
  16830. var treatCostPartSelfTotal float64 = 0 //治疗费用
  16831. var treatSelfTotal float64 = 0 //床位部分项目自费
  16832. var treatInscpTotal float64 = 0 //床位部分项目自费
  16833. decimal.DivisionPrecision = 2
  16834. for _, item := range orderInfos {
  16835. if item.MedChrgitmType == "01" { //床位费
  16836. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16837. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16838. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16839. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16840. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16841. }
  16842. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  16843. if item.MedChrgitmType == "03" { //检查费
  16844. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16845. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16846. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16847. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16848. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16849. }
  16850. } else {
  16851. if item.MedChrgitmType == "03" { //检查费
  16852. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16853. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16854. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16855. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16856. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16857. }
  16858. }
  16859. if item.MedChrgitmType == "04" { //化验费
  16860. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16861. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16862. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16863. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16864. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16865. }
  16866. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  16867. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16868. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16869. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16870. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16871. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16872. }
  16873. if item.MedChrgitmType == "06" { //手术费
  16874. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16875. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16876. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16877. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16878. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16879. }
  16880. if item.MedChrgitmType == "08" { //材料费
  16881. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16882. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16883. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16884. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16885. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16886. }
  16887. if item.MedChrgitmType == "09" { //西药费
  16888. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16889. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16890. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16891. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16892. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16893. }
  16894. if item.MedChrgitmType == "11" { //中成费
  16895. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16896. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16897. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16898. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16899. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16900. }
  16901. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  16902. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  16903. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  16904. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  16905. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  16906. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  16907. }
  16908. }
  16909. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16910. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16911. var user_name string
  16912. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16913. if role.ID == 0 {
  16914. user_name = "管理员"
  16915. } else {
  16916. user_name = role.UserName
  16917. }
  16918. baseParams := models.BaseParams{
  16919. SecretKey: miConfig.SecretKey,
  16920. FixmedinsCode: miConfig.Code,
  16921. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  16922. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  16923. OrgName: miConfig.OrgName,
  16924. Doctor: user_name,
  16925. RequestUrl: miConfig.Url,
  16926. AccessKey: miConfig.AccessKey,
  16927. }
  16928. businessParams := models.BusinessParams{
  16929. PsnNo: order.PsnNo,
  16930. MdtrtId: order.MdtrtId,
  16931. SetlId: order.SetlId,
  16932. }
  16933. var res ResultEleven
  16934. var resEleven10265 ResultEleven10265
  16935. if config.IsOpen == 1 {
  16936. if miConfig.MdtrtareaAdmvs == "421300" {
  16937. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  16938. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  16939. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  16940. resp, requestErr := http.Get(api)
  16941. if requestErr != nil {
  16942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16943. return
  16944. }
  16945. body, ioErr := ioutil.ReadAll(resp.Body)
  16946. if ioErr != nil {
  16947. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16949. return
  16950. }
  16951. var respJSON map[string]interface{}
  16952. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16953. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16955. return
  16956. }
  16957. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16958. result, _ := json.Marshal(respJSON)
  16959. fmt.Println("log")
  16960. fmt.Println(string(result))
  16961. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16962. utils.ErrorLog("解析失败:%v", err)
  16963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16964. return
  16965. }
  16966. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16967. var api string
  16968. if miConfig.MdtrtareaAdmvs == "320921" {
  16969. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  16970. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  16971. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  16972. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  16973. } else {
  16974. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  16975. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  16976. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  16977. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  16978. }
  16979. resp, requestErr := http.Get(api)
  16980. if requestErr != nil {
  16981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16982. return
  16983. }
  16984. body, ioErr := ioutil.ReadAll(resp.Body)
  16985. if ioErr != nil {
  16986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16988. return
  16989. }
  16990. var respJSON map[string]interface{}
  16991. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16994. return
  16995. }
  16996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16997. result, _ := json.Marshal(respJSON)
  16998. fmt.Println("log")
  16999. fmt.Println(string(result))
  17000. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  17001. utils.ErrorLog("解析失败:%v", err)
  17002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17003. return
  17004. }
  17005. res.InfRefmsgid = resEleven10265.InfRefmsgid
  17006. res.Output = resEleven10265.Output
  17007. res.ErrMsg = resEleven10265.ErrMsg
  17008. res.Cainfo = resEleven10265.Cainfo
  17009. res.WarnMsg = resEleven10265.WarnMsg
  17010. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  17011. res.Infcode = infocode
  17012. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17013. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  17014. saveLog(result, requestLog, "5203", "结算单")
  17015. var dat map[string]interface{}
  17016. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17017. fmt.Println(dat)
  17018. } else {
  17019. fmt.Println(err)
  17020. }
  17021. userJSONBytes, _ := json.Marshal(dat)
  17022. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17023. utils.ErrorLog("解析失败:%v", err)
  17024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17025. return
  17026. }
  17027. } else if miConfig.MdtrtareaAdmvs == "360399" {
  17028. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  17029. fmt.Println(result3)
  17030. fmt.Println(requestLog3)
  17031. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  17032. fmt.Println(result2)
  17033. fmt.Println(requestLog2)
  17034. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  17035. saveLog(result, requestLog, "5203", "结算单")
  17036. var dat map[string]interface{}
  17037. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17038. fmt.Println(dat)
  17039. } else {
  17040. fmt.Println(err)
  17041. }
  17042. userJSONBytes, _ := json.Marshal(dat)
  17043. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17044. utils.ErrorLog("解析失败:%v", err)
  17045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17046. return
  17047. }
  17048. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17049. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  17050. saveLog(result, requestLog, "5203", "结算单")
  17051. var dat map[string]interface{}
  17052. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17053. fmt.Println(dat)
  17054. } else {
  17055. fmt.Println(err)
  17056. }
  17057. userJSONBytes, _ := json.Marshal(dat)
  17058. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17059. utils.ErrorLog("解析失败:%v", err)
  17060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17061. return
  17062. }
  17063. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17064. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  17065. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  17066. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  17067. resp, requestErr := http.Get(api)
  17068. if requestErr != nil {
  17069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17070. return
  17071. }
  17072. body, ioErr := ioutil.ReadAll(resp.Body)
  17073. if ioErr != nil {
  17074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17076. return
  17077. }
  17078. var respJSON map[string]interface{}
  17079. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17082. return
  17083. }
  17084. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17085. result, _ := json.Marshal(respJSON)
  17086. fmt.Println("log")
  17087. fmt.Println(string(result))
  17088. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  17089. utils.ErrorLog("解析失败:%v", err)
  17090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17091. return
  17092. }
  17093. res.InfRefmsgid = resEleven10265.InfRefmsgid
  17094. res.Output = resEleven10265.Output
  17095. res.ErrMsg = resEleven10265.ErrMsg
  17096. res.Cainfo = resEleven10265.Cainfo
  17097. res.WarnMsg = resEleven10265.WarnMsg
  17098. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  17099. res.Infcode = infocode
  17100. } else {
  17101. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  17102. result := service.Gdyb5203(baseParams, businessParams)
  17103. //service.Gdyb5204(baseParams, businessParams)
  17104. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  17105. var dat map[string]interface{}
  17106. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17107. fmt.Println(dat)
  17108. } else {
  17109. fmt.Println(err)
  17110. }
  17111. userJSONBytes, _ := json.Marshal(dat)
  17112. if miConfig.Code == "H15049901371" {
  17113. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  17114. utils.ErrorLog("解析失败:%v", err)
  17115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17116. return
  17117. }
  17118. res.InfRefmsgid = resEleven10265.InfRefmsgid
  17119. res.Output = resEleven10265.Output
  17120. res.ErrMsg = resEleven10265.ErrMsg
  17121. res.Cainfo = resEleven10265.Cainfo
  17122. res.WarnMsg = resEleven10265.WarnMsg
  17123. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  17124. res.Infcode = infocode
  17125. } else {
  17126. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17127. utils.ErrorLog("解析失败:%v", err)
  17128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17129. return
  17130. }
  17131. }
  17132. }
  17133. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17134. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  17135. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  17136. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  17137. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  17138. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17139. var doctor_name string
  17140. if roles.ID == 0 {
  17141. doctor_name = "管理员"
  17142. } else {
  17143. doctor_name = roles.UserName
  17144. }
  17145. yiliao_leibie := ""
  17146. switch order.MedType {
  17147. case "11":
  17148. yiliao_leibie = "普通门诊"
  17149. break
  17150. case "12":
  17151. yiliao_leibie = "门诊挂号"
  17152. break
  17153. case "13":
  17154. yiliao_leibie = "急诊"
  17155. break
  17156. case "14":
  17157. yiliao_leibie = "门诊特殊病"
  17158. break
  17159. case "15":
  17160. yiliao_leibie = "门诊统筹"
  17161. break
  17162. case "16":
  17163. yiliao_leibie = "门诊慢性病"
  17164. break
  17165. case "21":
  17166. yiliao_leibie = "普通住院"
  17167. break
  17168. }
  17169. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  17170. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  17171. if res.Infcode == 0 {
  17172. c.ServeSuccessJSON(map[string]interface{}{
  17173. "diagnosis": name,
  17174. "order_infos": orderInfos,
  17175. "number": order.MdtrtId,
  17176. "date": order.SettleAccountsDate,
  17177. "charge_admin": charge_admin,
  17178. "printor_admin": printor_admin,
  17179. "info": res.Output.Setlinfo,
  17180. "order": order,
  17181. "bedCostTotal": bedCostTotal,
  17182. "bedCostSelfTotal": bedCostSelfTotal,
  17183. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  17184. "bedSelfTotal": bedSelfTotal,
  17185. "bedInscpTotal": bedInscpTotal,
  17186. "operationCostTotal": operationCostTotal,
  17187. "operationCostSelfTotal": operationCostSelfTotal,
  17188. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  17189. "operationSelfTotal": operationSelfTotal,
  17190. "operationInscpTotal": operationInscpTotal,
  17191. "otherCostTotal": otherCostTotal,
  17192. "otherCostSelfTotal": otherCostSelfTotal,
  17193. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  17194. "otherSelfTotal": otherSelfTotal,
  17195. "otherInscpTotal": otherInscpTotal,
  17196. "materialCostTotal": materialCostTotal,
  17197. "materialCostSelfTotal": materialCostSelfTotal,
  17198. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  17199. "materialSelfTotal": materialSelfTotal,
  17200. "materialInscpTotal": materialInscpTotal,
  17201. "westernMedicineCostTotal": westernMedicineCostTotal,
  17202. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  17203. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  17204. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  17205. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  17206. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  17207. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  17208. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  17209. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  17210. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  17211. "checkCostTotal": checkCostTotal,
  17212. "checkCostSelfTotal": checkCostSelfTotal,
  17213. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  17214. "checkSelfTotal": checkSelfTotal,
  17215. "checkInscpTotal": checkInscpTotal,
  17216. "laboratoryCostTotal": laboratoryCostTotal,
  17217. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  17218. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  17219. "laboratorySelfTotal": laboratorySelfTotal,
  17220. "laboratoryInscpTotal": laboratoryInscpTotal,
  17221. "treatCostTotal": treatCostTotal,
  17222. "treatCostSelfTotal": treatCostSelfTotal,
  17223. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  17224. "treatSelfTotal": treatSelfTotal,
  17225. "treatInscpTotal": treatInscpTotal,
  17226. "doctor_info": doctor_info,
  17227. "doctor_code": adminRole_two.DoctorCode,
  17228. "doctor_name": doctor_name,
  17229. "health_card_no": order.PsnNo,
  17230. "department": departments.Name,
  17231. "yiliao_leibie": yiliao_leibie,
  17232. "after_money": order.AccountPrice,
  17233. "patient": patient,
  17234. "org_name": miConfig.OrgName,
  17235. "org_code": miConfig.Code,
  17236. "order_number": order.Number,
  17237. "his_hospital": his_hospital,
  17238. "his": his,
  17239. "dia_config": dia_config,
  17240. "psn_cash_pay": order.PsnCashPay,
  17241. //"check_order_info": cus_slice,
  17242. })
  17243. }
  17244. }
  17245. }
  17246. func (c *HisApiController) CheckTreatment() {
  17247. patient_id, _ := c.GetInt64("patient_id")
  17248. id_card_no := c.GetString("id_card_no")
  17249. insutype := c.GetString("insutype")
  17250. med_type := c.GetString("med_type")
  17251. admin_user_id, _ := c.GetInt64("admin_user_id")
  17252. adminUser := c.GetAdminUserInfo()
  17253. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  17254. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17255. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17256. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17257. if miConfig.MdtrtareaAdmvs == "421300" {
  17258. var res ResultTwo
  17259. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  17260. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17261. "&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)
  17262. resp, requestErr := http.Get(api)
  17263. if requestErr != nil {
  17264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17265. return
  17266. }
  17267. body, ioErr := ioutil.ReadAll(resp.Body)
  17268. if ioErr != nil {
  17269. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17271. return
  17272. }
  17273. var respJSON map[string]interface{}
  17274. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17275. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17277. return
  17278. }
  17279. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17280. result, _ := json.Marshal(respJSON)
  17281. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17282. utils.ErrorLog("解析失败:%v", err)
  17283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17284. return
  17285. }
  17286. if res.Infcode == 0 {
  17287. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  17288. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17289. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  17290. resp, requestErr := http.Get(api)
  17291. if requestErr != nil {
  17292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17293. return
  17294. }
  17295. body, ioErr := ioutil.ReadAll(resp.Body)
  17296. if ioErr != nil {
  17297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17299. return
  17300. }
  17301. var respJSON map[string]interface{}
  17302. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17305. return
  17306. }
  17307. var res Result2001
  17308. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17309. result2, _ := json.Marshal(respJSON)
  17310. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17311. utils.ErrorLog("解析失败:%v", err)
  17312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17313. return
  17314. }
  17315. if res.Infcode == 0 {
  17316. c.ServeSuccessJSON(map[string]interface{}{
  17317. "msg": res.Output.Trtinfo,
  17318. })
  17319. }
  17320. } else {
  17321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17322. return
  17323. }
  17324. } else {
  17325. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  17326. var dat map[string]interface{}
  17327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17328. fmt.Println(dat)
  17329. } else {
  17330. fmt.Println(err)
  17331. }
  17332. userJSONBytes, _ := json.Marshal(dat)
  17333. var res ResultTwo
  17334. var res10265 ResultTwo10265
  17335. if miConfig.Code == "H15049901371" {
  17336. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  17337. utils.ErrorLog("解析失败:%v", err)
  17338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17339. return
  17340. }
  17341. res.ErrMsg = res10265.ErrMsg
  17342. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17343. res.Infcode = infocode
  17344. res.Output = res10265.Output
  17345. res.InfRefmsgid = res10265.InfRefmsgid
  17346. } else {
  17347. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17348. utils.ErrorLog("解析失败:%v", err)
  17349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17350. return
  17351. }
  17352. }
  17353. var user_name string
  17354. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  17355. if role.ID == 0 {
  17356. user_name = "xxx"
  17357. } else {
  17358. user_name = role.UserName
  17359. }
  17360. baseParams := models.BaseParams{
  17361. SecretKey: miConfig.SecretKey,
  17362. FixmedinsCode: miConfig.Code,
  17363. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  17364. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  17365. OrgName: miConfig.OrgName,
  17366. Doctor: user_name,
  17367. }
  17368. if config.IsOpen == 1 {
  17369. if miConfig.Code == "H15049901371" {
  17370. if med_type == "14" {
  17371. if insutype == "390" {
  17372. med_type = "9933"
  17373. } else if insutype == "310" {
  17374. med_type = "990502"
  17375. }
  17376. } else if med_type == "11" {
  17377. med_type = "11"
  17378. }
  17379. }
  17380. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  17381. var dat map[string]interface{}
  17382. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17383. fmt.Println(dat)
  17384. } else {
  17385. fmt.Println(err)
  17386. }
  17387. var res Result2001
  17388. var res10265 Result2001Org10265
  17389. if miConfig.Code == "H15049901371" {
  17390. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17391. utils.ErrorLog("解析失败:%v", err)
  17392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17393. return
  17394. }
  17395. res.ErrMsg = res10265.ErrMsg
  17396. res.Output = res10265.Output
  17397. res.InfRefmsgid = res10265.InfRefmsgid
  17398. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17399. res.Infcode = infocode
  17400. } else {
  17401. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17402. utils.ErrorLog("解析失败:%v", err)
  17403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17404. return
  17405. }
  17406. }
  17407. if res.Infcode == 0 {
  17408. c.ServeSuccessJSON(map[string]interface{}{
  17409. "msg": res.Output.Trtinfo,
  17410. })
  17411. }
  17412. }
  17413. }
  17414. }
  17415. //func (c *HisApiController) PutRecord() {
  17416. // id, _ := c.GetInt64("id")
  17417. // record_time := c.GetString("record_time")
  17418. // timeLayout := "2006-01-02"
  17419. // loc, _ := time.LoadLocation("Local")
  17420. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17421. // if err != nil {
  17422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17423. // return
  17424. // }
  17425. // recordDateTime := theTime.Unix()
  17426. //
  17427. // adminInfo := c.GetAdminUserInfo()
  17428. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  17429. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17430. //
  17431. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  17432. //
  17433. // fmt.Println(miConfig.SecretKey)
  17434. //
  17435. // if patient == nil {
  17436. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  17437. // return
  17438. // }
  17439. // if len(patient.IdCardNo) == 0 {
  17440. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  17441. // return
  17442. // }
  17443. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  17444. // if config.IsOpen == 1 {
  17445. // 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
  17446. // resp, requestErr := http.Get(api)
  17447. // if requestErr != nil {
  17448. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17449. // return
  17450. // }
  17451. // defer resp.Body.Close()
  17452. // body, ioErr := ioutil.ReadAll(resp.Body)
  17453. // if ioErr != nil {
  17454. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17455. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17456. // return
  17457. // }
  17458. // var respJSON map[string]interface{}
  17459. //
  17460. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17461. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17462. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17463. // return
  17464. // }
  17465. //
  17466. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17467. // userJSONBytes, _ := json.Marshal(userJSON)
  17468. // var res ResultTwo
  17469. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17470. // utils.ErrorLog("解析失败:%v", err)
  17471. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17472. // return
  17473. // }
  17474. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17475. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17476. // infoStr := string(Iinfos)
  17477. // idetinfoStr := string(Idetinfos)
  17478. //
  17479. // if res.Infcode == 0 {
  17480. // his := models.VMHisPatient{
  17481. // Status: 1,
  17482. // Ctime: time.Now().Unix(),
  17483. // Mtime: time.Now().Unix(),
  17484. // PsnNo: res.Output.Baseinfo.PsnNo,
  17485. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  17486. // Certno: res.Output.Baseinfo.Certno,
  17487. // PsnName: res.Output.Baseinfo.PsnName,
  17488. // Gend: res.Output.Baseinfo.Gend,
  17489. // Naty: res.Output.Baseinfo.Naty,
  17490. // Brdy: res.Output.Baseinfo.Brdy,
  17491. // Age: res.Output.Baseinfo.Age,
  17492. // Iinfo: infoStr,
  17493. // Idetinfo: idetinfoStr,
  17494. // PatientId: patient.ID,
  17495. // RecordDate: theTime.Unix(),
  17496. // UserOrgId: adminInfo.CurrentOrgId,
  17497. // AdminUserId: adminInfo.AdminUser.Id,
  17498. // IsReturn: 1,
  17499. // }
  17500. //
  17501. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  17502. // //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")
  17503. // //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")
  17504. //
  17505. // //var dat map[string]interface{}
  17506. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17507. // // fmt.Println(dat)
  17508. // //} else {
  17509. // // fmt.Println(err)
  17510. // //}
  17511. //
  17512. // var dat2 map[string]interface{}
  17513. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  17514. // fmt.Println(dat2)
  17515. // } else {
  17516. // fmt.Println(err)
  17517. // }
  17518. //
  17519. // } else {
  17520. // adminUser := c.GetAdminUserInfo()
  17521. // errlog := &models.HisOrderError{
  17522. // UserOrgId: adminUser.CurrentOrgId,
  17523. // Ctime: time.Now().Unix(),
  17524. // Mtime: time.Now().Unix(),
  17525. // ErrMsg: res.ErrMsg,
  17526. // Status: 1,
  17527. // PatientId: id,
  17528. // RecordTime: recordDateTime,
  17529. // Stage: 1,
  17530. // }
  17531. // service.CreateErrMsgLog(errlog)
  17532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  17533. // return
  17534. // }
  17535. // }
  17536. //
  17537. //}
  17538. //func (c *HisApiController) GetUploadDiag() {
  17539. // id, _ := c.GetInt64("id")
  17540. // record_time := c.GetString("record_time")
  17541. //
  17542. // diagnosis_id, _ := c.GetInt64("diagnosis")
  17543. // sick_type, _ := c.GetInt64("sick_type")
  17544. // reg_type, _ := c.GetInt64("reg_type")
  17545. //
  17546. // timeLayout := "2006-01-02"
  17547. // loc, _ := time.LoadLocation("Local")
  17548. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17549. // if err != nil {
  17550. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17551. // return
  17552. // }
  17553. //
  17554. // var patientPrescription models.HisPrescriptionInfo
  17555. // recordDateTime := theTime.Unix()
  17556. // adminInfo := c.GetAdminUserInfo()
  17557. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17558. //
  17559. // if patientPrescription.ID == 0 {
  17560. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17561. // }
  17562. //
  17563. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  17564. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  17565. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17566. // sickConfig, _ := service.FindSickById(sick_type)
  17567. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  17568. //
  17569. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  17570. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  17571. // "&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 +
  17572. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  17573. // resp2, requestErr2 := http.Get(api2)
  17574. // if requestErr2 != nil {
  17575. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17576. // return
  17577. // }
  17578. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  17579. // if ioErr2 != nil {
  17580. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  17581. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17582. // return
  17583. // }
  17584. // var respJSON2 map[string]interface{}
  17585. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  17586. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17588. // return
  17589. // }
  17590. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17591. // userJSONBytes2, _ := json.Marshal(respJSON2)
  17592. //
  17593. // var res2 ResultSix
  17594. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  17595. // utils.ErrorLog("解析失败:%v", err)
  17596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17597. // return
  17598. // }
  17599. // if res2.Infcode != 0 {
  17600. // adminUser := c.GetAdminUserInfo()
  17601. // errlog := &models.HisOrderError{
  17602. // UserOrgId: adminUser.CurrentOrgId,
  17603. // Ctime: time.Now().Unix(),
  17604. // Mtime: time.Now().Unix(),
  17605. // ErrMsg: res2.ErrMsg,
  17606. // Status: 1,
  17607. // PatientId: id,
  17608. // RecordTime: recordDateTime,
  17609. // Stage: 3,
  17610. // }
  17611. // service.CreateErrMsgLog(errlog)
  17612. //
  17613. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  17614. // return
  17615. // }
  17616. //
  17617. // c.ServeSuccessJSON(map[string]interface{}{
  17618. // "msg": "上传成功",
  17619. // })
  17620. //
  17621. //}
  17622. type QueryResult struct {
  17623. ID int64
  17624. Name string
  17625. Code string
  17626. List_type_code string
  17627. }
  17628. func (c *HisApiController) GetCheckCode() {
  17629. ids_str := c.GetString("ids")
  17630. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  17631. ids_arr := strings.Split(ids_str, ",")
  17632. var queryResult []QueryResult
  17633. ids := make([]int64, 0)
  17634. for _, item := range ids_arr {
  17635. id, _ := strconv.ParseInt(item, 10, 64)
  17636. ids = append(ids, id)
  17637. }
  17638. if record_type == 1 {
  17639. drugs, _ := service.GetBatchDrugList(ids)
  17640. for _, item := range drugs {
  17641. result := QueryResult{
  17642. ID: item.ID,
  17643. Name: item.DrugName,
  17644. Code: item.MedicalInsuranceNumber,
  17645. List_type_code: "101",
  17646. }
  17647. queryResult = append(queryResult, result)
  17648. }
  17649. } else if record_type == 2 {
  17650. goods, _ := service.GetBatchGoodInformationList(ids)
  17651. for _, item := range goods {
  17652. result := QueryResult{
  17653. ID: item.ID,
  17654. Name: item.GoodName,
  17655. Code: item.MedicalInsuranceNumber,
  17656. List_type_code: "301",
  17657. }
  17658. queryResult = append(queryResult, result)
  17659. }
  17660. } else if record_type == 3 {
  17661. projects, _ := service.GetBathchMyPorjecgList(ids)
  17662. for _, item := range projects {
  17663. result := QueryResult{
  17664. ID: item.ID,
  17665. Name: item.ProjectName,
  17666. Code: item.MedicalCode,
  17667. List_type_code: "201",
  17668. }
  17669. queryResult = append(queryResult, result)
  17670. }
  17671. }
  17672. admin_user_id, _ := c.GetInt64("admin_user_id")
  17673. adminUser := c.GetAdminUserInfo()
  17674. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17675. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17676. var user_name string
  17677. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17678. if role.ID == 0 {
  17679. user_name = "xxx"
  17680. } else {
  17681. user_name = role.UserName
  17682. }
  17683. baseParams := &models.BaseParams{
  17684. SecretKey: miConfig.SecretKey,
  17685. FixmedinsCode: miConfig.Code,
  17686. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  17687. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  17688. OrgName: miConfig.OrgName,
  17689. Doctor: user_name,
  17690. }
  17691. if config.IsOpen == 1 {
  17692. for _, item := range queryResult {
  17693. var result string
  17694. if record_type == 1 {
  17695. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  17696. } else if record_type == 2 {
  17697. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  17698. } else if record_type == 3 {
  17699. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  17700. }
  17701. var dat map[string]interface{}
  17702. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17703. fmt.Println(dat)
  17704. } else {
  17705. fmt.Println(err)
  17706. }
  17707. userJSONBytes, _ := json.Marshal(dat)
  17708. var res ResultSix
  17709. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17710. utils.ErrorLog("解析失败:%v", err)
  17711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17712. return
  17713. }
  17714. if res.Infcode == 0 {
  17715. if record_type == 1 {
  17716. service.UpdateBaseDrugById(item.ID)
  17717. } else if record_type == 2 {
  17718. service.UpdateGoodInformaitonByDetail(item.ID)
  17719. } else if record_type == 3 {
  17720. service.UpdateProjectById(item.ID)
  17721. }
  17722. c.ServeSuccessJSON(map[string]interface{}{
  17723. "failed_code": 0,
  17724. "msg": "目录对照成功",
  17725. })
  17726. } else {
  17727. c.ServeSuccessJSON(map[string]interface{}{
  17728. "failed_code": -10,
  17729. "msg": res.ErrMsg,
  17730. })
  17731. }
  17732. }
  17733. }
  17734. }
  17735. func (c *HisApiController) UnCheckCode() {
  17736. ids_str := c.GetString("ids")
  17737. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  17738. admin_user_id, _ := c.GetInt64("admin_user_id")
  17739. ids_arr := strings.Split(ids_str, ",")
  17740. var queryResult []QueryResult
  17741. ids := make([]int64, 0)
  17742. for _, item := range ids_arr {
  17743. id, _ := strconv.ParseInt(item, 10, 64)
  17744. ids = append(ids, id)
  17745. }
  17746. if record_type == 1 {
  17747. drugs, _ := service.GetBatchDrugList(ids)
  17748. for _, item := range drugs {
  17749. result := QueryResult{
  17750. ID: item.ID,
  17751. Name: item.DrugName,
  17752. Code: item.MedicalInsuranceNumber,
  17753. List_type_code: "101",
  17754. }
  17755. queryResult = append(queryResult, result)
  17756. }
  17757. } else if record_type == 2 {
  17758. goods, _ := service.GetBatchGoodInformationList(ids)
  17759. for _, item := range goods {
  17760. result := QueryResult{
  17761. ID: item.ID,
  17762. Name: item.GoodName,
  17763. Code: item.MedicalInsuranceNumber,
  17764. List_type_code: "301",
  17765. }
  17766. queryResult = append(queryResult, result)
  17767. }
  17768. } else if record_type == 3 {
  17769. projects, _ := service.GetBathchMyPorjecgList(ids)
  17770. for _, item := range projects {
  17771. result := QueryResult{
  17772. ID: item.ID,
  17773. Name: item.ProjectName,
  17774. Code: item.MedicalCode,
  17775. List_type_code: "201",
  17776. }
  17777. queryResult = append(queryResult, result)
  17778. }
  17779. }
  17780. adminUser := c.GetAdminUserInfo()
  17781. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17782. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17783. var user_name string
  17784. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17785. if role.ID == 0 {
  17786. user_name = "xxx"
  17787. } else {
  17788. user_name = role.UserName
  17789. }
  17790. baseParams := &models.BaseParams{
  17791. SecretKey: miConfig.SecretKey,
  17792. FixmedinsCode: miConfig.Code,
  17793. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  17794. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  17795. OrgName: miConfig.OrgName,
  17796. Doctor: user_name,
  17797. }
  17798. if config.IsOpen == 1 {
  17799. for _, item := range queryResult {
  17800. var result string
  17801. if record_type == 1 {
  17802. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  17803. } else if record_type == 2 {
  17804. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  17805. } else if record_type == 3 {
  17806. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  17807. }
  17808. var dat2 map[string]interface{}
  17809. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  17810. fmt.Println(dat2)
  17811. } else {
  17812. fmt.Println(err)
  17813. }
  17814. userJSONBytes, _ := json.Marshal(dat2)
  17815. var res ResultSix
  17816. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17817. utils.ErrorLog("解析失败:%v", err)
  17818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17819. return
  17820. }
  17821. if res.Infcode == 0 {
  17822. if record_type == 1 {
  17823. service.UpdateDrugByIdDetail(item.ID)
  17824. } else if record_type == 2 {
  17825. service.UpdateGoodInfoById(item.ID)
  17826. } else if record_type == 3 {
  17827. service.UpdateMyProjectById(item.ID)
  17828. }
  17829. c.ServeSuccessJSON(map[string]interface{}{
  17830. "failed_code": 0,
  17831. "msg": "撤销目录对照成功",
  17832. })
  17833. } else {
  17834. c.ServeSuccessJSON(map[string]interface{}{
  17835. "failed_code": -10,
  17836. "msg": res.ErrMsg,
  17837. })
  17838. }
  17839. }
  17840. }
  17841. }
  17842. func (c *HisApiController) GetPatientInfo() {
  17843. id_card_no := c.GetString("id_card_no")
  17844. admin_user_id, _ := c.GetInt64("admin_user_id")
  17845. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  17846. if patient.ID == 0 {
  17847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  17848. return
  17849. }
  17850. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  17851. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17852. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  17853. var res ResultTwo
  17854. var res10265 ResultTwo10265
  17855. if config.IsOpen == 1 {
  17856. if miConfig.MdtrtareaAdmvs == "150499" {
  17857. //请求内网数据
  17858. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  17859. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  17860. "&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
  17861. resp, requestErr := http.Get(api)
  17862. if requestErr != nil {
  17863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17864. return
  17865. }
  17866. body, ioErr := ioutil.ReadAll(resp.Body)
  17867. if ioErr != nil {
  17868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17870. return
  17871. }
  17872. var respJSON map[string]interface{}
  17873. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17876. return
  17877. }
  17878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17879. result_byte, _ := json.Marshal(respJSON)
  17880. result := string(result_byte)
  17881. var dat map[string]interface{}
  17882. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17883. fmt.Println(dat)
  17884. } else {
  17885. fmt.Println(err)
  17886. }
  17887. userJSONBytes, _ := json.Marshal(dat)
  17888. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  17889. utils.ErrorLog("解析失败:%v", err)
  17890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17891. return
  17892. }
  17893. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17894. res.Infcode = Infcode
  17895. res.ErrMsg = res10265.ErrMsg
  17896. res.Output = res10265.Output
  17897. res.InfRefmsgid = res10265.InfRefmsgid
  17898. res.RespondTime = res10265.RespondTime
  17899. res.WarnInfo = res10265.WarnInfo
  17900. } else {
  17901. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  17902. var dat map[string]interface{}
  17903. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17904. fmt.Println(dat)
  17905. } else {
  17906. fmt.Println(err)
  17907. }
  17908. userJSONBytes, _ := json.Marshal(dat)
  17909. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17910. utils.ErrorLog("解析失败:%v", err)
  17911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17912. return
  17913. }
  17914. }
  17915. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17916. // utils.ErrorLog("解析失败:%v", err)
  17917. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17918. // return
  17919. //}
  17920. for index, item := range res.Output.Iinfo {
  17921. if item.PsnInsuStas == "2" {
  17922. fmt.Println("--------")
  17923. res.Output.Iinfo[index].Insutype = "300"
  17924. res.Output.Iinfo[index].PsnInsuStas = "1"
  17925. }
  17926. }
  17927. fmt.Println(res.Output.Iinfo)
  17928. if res.Infcode != 0 {
  17929. c.ServeSuccessJSON(map[string]interface{}{
  17930. "failed_code": -10,
  17931. "msg": res.ErrMsg,
  17932. })
  17933. } else {
  17934. c.ServeSuccessJSON(map[string]interface{}{
  17935. "failed_code": 0,
  17936. "info": res,
  17937. })
  17938. }
  17939. }
  17940. }
  17941. func (c *HisApiController) PsnPutOnRecord() {
  17942. record_type, _ := c.GetInt64("type")
  17943. patient_id, _ := c.GetInt64("patient_id")
  17944. admin_user_id, _ := c.GetInt64("admin_user_id")
  17945. start_time := c.GetString("start_time")
  17946. end_time := c.GetString("end_time")
  17947. adminUser := c.GetAdminUserInfo()
  17948. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17949. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17950. var patients []*models.Patients
  17951. if record_type == 1 { //全部备案
  17952. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  17953. patients = append(patients, patient...)
  17954. } else { //单个备案
  17955. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  17956. patients = append(patients, patient)
  17957. }
  17958. var user_name string
  17959. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17960. if role.ID == 0 {
  17961. user_name = "xxx"
  17962. } else {
  17963. user_name = role.UserName
  17964. }
  17965. if config.IsOpen == 1 {
  17966. for _, item := range patients {
  17967. 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
  17968. resp, requestErr := http.Get(api)
  17969. if requestErr != nil {
  17970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17971. return
  17972. }
  17973. defer resp.Body.Close()
  17974. body, ioErr := ioutil.ReadAll(resp.Body)
  17975. if ioErr != nil {
  17976. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17978. return
  17979. }
  17980. var respJSON map[string]interface{}
  17981. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17984. return
  17985. }
  17986. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17987. userJSONBytes, _ := json.Marshal(userJSON)
  17988. var res ResultTwo
  17989. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17990. utils.ErrorLog("解析失败:%v", err)
  17991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17992. return
  17993. }
  17994. if res.Infcode == 0 {
  17995. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  17996. var dat map[string]interface{}
  17997. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17998. fmt.Println(dat)
  17999. } else {
  18000. fmt.Println(err)
  18001. }
  18002. userJSONBytes, _ := json.Marshal(dat)
  18003. var res2 ResultThirteen
  18004. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18005. utils.ErrorLog("解析失败:%v", err)
  18006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18007. return
  18008. }
  18009. if res2.Infcode == 0 {
  18010. psnResult := &models.GdybPsnRecord{
  18011. UserOrgId: adminUser.CurrentOrgId,
  18012. PatientId: item.ID,
  18013. PsnNo: res.Output.Baseinfo.PsnNo,
  18014. Ctime: time.Now().Unix(),
  18015. Mtime: time.Now().Unix(),
  18016. Status: 1,
  18017. IsCancel: 1,
  18018. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  18019. }
  18020. service.CreatePsnRecord(psnResult)
  18021. } else {
  18022. c.ServeSuccessJSON(map[string]interface{}{
  18023. "failed_code": -10,
  18024. "msg": res2.ErrMsg,
  18025. })
  18026. return
  18027. }
  18028. }
  18029. }
  18030. }
  18031. }
  18032. func (c *HisApiController) PsnUnPutOnRecord() {
  18033. id, _ := c.GetInt64("id")
  18034. //record_type, _ := c.GetInt64("type")
  18035. admin_user_id, _ := c.GetInt64("admin_user_id")
  18036. adminUser := c.GetAdminUserInfo()
  18037. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18038. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  18039. var user_name string
  18040. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18041. if role.ID == 0 {
  18042. user_name = "xxx"
  18043. } else {
  18044. user_name = role.UserName
  18045. }
  18046. psn_record, _ := service.GetPsnRecordById(id)
  18047. if psn_record.ID == 0 {
  18048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  18049. return
  18050. }
  18051. if config.IsOpen == 1 {
  18052. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  18053. var dat map[string]interface{}
  18054. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18055. fmt.Println(dat)
  18056. } else {
  18057. fmt.Println(err)
  18058. }
  18059. userJSONBytes, _ := json.Marshal(dat)
  18060. var res ResultFourteen
  18061. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18062. utils.ErrorLog("解析失败:%v", err)
  18063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18064. return
  18065. }
  18066. if res.Infcode == 0 {
  18067. psn_record.IsCancel = 2
  18068. service.CreatePsnRecord(&psn_record)
  18069. } else {
  18070. c.ServeSuccessJSON(map[string]interface{}{
  18071. "failed_code": -10,
  18072. "msg": res.ErrMsg,
  18073. })
  18074. return
  18075. }
  18076. }
  18077. }
  18078. func (c *HisApiController) PsnPutNCDSOnRecord() {
  18079. patient_id, _ := c.GetInt64("patient_id")
  18080. insutype_two := c.GetString("insutype")
  18081. psn_no := c.GetString("psn_no")
  18082. doctor_id, _ := c.GetInt64("doctor_id")
  18083. sick_id, _ := c.GetInt64("sick_id")
  18084. department_id, _ := c.GetInt64("department_id")
  18085. start_time := c.GetString("start_time")
  18086. end_time := c.GetString("end_time")
  18087. check_time := c.GetString("check_time")
  18088. hospital_code := c.GetString("hospital_code")
  18089. hospital_name := c.GetString("hospital_name")
  18090. adminUser := c.GetAdminUserInfo()
  18091. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  18092. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18093. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  18094. sick, _ := service.FindSickById(sick_id)
  18095. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  18096. if len(hospital_code) == 0 {
  18097. hospital_code = miConfig.Code
  18098. }
  18099. if len(hospital_name) == 0 {
  18100. hospital_name = miConfig.OrgName
  18101. }
  18102. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  18103. var res ResultTwo
  18104. var res10265 ResultTwo10265
  18105. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18106. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  18107. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  18108. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  18109. "&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
  18110. resp, requestErr := http.Get(api)
  18111. if requestErr != nil {
  18112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18113. return
  18114. }
  18115. body, ioErr := ioutil.ReadAll(resp.Body)
  18116. if ioErr != nil {
  18117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18119. return
  18120. }
  18121. var respJSON map[string]interface{}
  18122. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18125. return
  18126. }
  18127. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18128. result, _ := json.Marshal(respJSON)
  18129. fmt.Println("log")
  18130. fmt.Println(string(result))
  18131. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  18132. utils.ErrorLog("解析失败:%v", err)
  18133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18134. return
  18135. }
  18136. res.ErrMsg = res10265.ErrMsg
  18137. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  18138. res.Infcode = infocode
  18139. res.Output = res10265.Output
  18140. res.InfRefmsgid = res10265.InfRefmsgid
  18141. } else {
  18142. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  18143. if miConfig.Code == "H15049901371" {
  18144. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  18145. utils.ErrorLog("解析失败:%v", err)
  18146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18147. return
  18148. }
  18149. res.ErrMsg = res10265.ErrMsg
  18150. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  18151. res.Infcode = infocode
  18152. res.Output = res10265.Output
  18153. res.InfRefmsgid = res10265.InfRefmsgid
  18154. } else {
  18155. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18156. utils.ErrorLog("解析失败:%v", err)
  18157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18158. return
  18159. }
  18160. }
  18161. }
  18162. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18163. infoStr := string(Iinfos)
  18164. var rf []*ResultFive
  18165. json.Unmarshal([]byte(infoStr), &rf)
  18166. var insuplc_admdvs string
  18167. var insutype string
  18168. var is390 int = 0
  18169. var is310 int = 0
  18170. var insutypes []*ResultFive
  18171. for _, item := range rf {
  18172. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18173. insutypes = append(insutypes, item)
  18174. }
  18175. }
  18176. if len(insutypes) == 1 {
  18177. insutype = insutypes[0].Insutype
  18178. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18179. } else {
  18180. for _, i := range insutypes {
  18181. if i.Insutype == "390" {
  18182. is390 = 1
  18183. }
  18184. if i.Insutype == "310" {
  18185. is310 = 1
  18186. }
  18187. }
  18188. }
  18189. if is390 == 1 {
  18190. insutype = "390"
  18191. }
  18192. if is310 == 1 {
  18193. insutype = "310"
  18194. }
  18195. if len(insutypes) == 2 {
  18196. insutype = insutype_two
  18197. }
  18198. if len(insutypes) == 0 {
  18199. insutype = "310"
  18200. }
  18201. insutype = insutype_two
  18202. fmt.Println(insutype)
  18203. for _, item := range rf {
  18204. fmt.Println(item.Insutype)
  18205. fmt.Println(insutype)
  18206. if item.Insutype == insutype {
  18207. fmt.Println(item.Insutype)
  18208. fmt.Println(insutype)
  18209. insuplc_admdvs = item.InsuplcAdmdvs
  18210. }
  18211. }
  18212. fmt.Println(insuplc_admdvs)
  18213. var res2 ResultThirteen
  18214. var res10265_2 ResultThirteen10265
  18215. if config.IsOpen == 1 {
  18216. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18217. } else {
  18218. if miConfig.MdtrtareaAdmvs == "150499" {
  18219. //
  18220. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  18221. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  18222. // "&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
  18223. //resp, requestErr := http.Get(api)
  18224. //if requestErr != nil {
  18225. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18226. // return
  18227. //}
  18228. //
  18229. //body, ioErr := ioutil.ReadAll(resp.Body)
  18230. //if ioErr != nil {
  18231. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18233. // return
  18234. //}
  18235. //var respJSON map[string]interface{}
  18236. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18237. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18239. // return
  18240. //}
  18241. //
  18242. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18243. //result, _ := json.Marshal(respJSON)
  18244. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18245. // utils.ErrorLog("解析失败:%v", err)
  18246. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18247. // return
  18248. //}
  18249. //infocode = resThree.Infcode
  18250. //result, _ := json.Marshal(respJSON)
  18251. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18252. // utils.ErrorLog("解析失败:%v", err)
  18253. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18254. // return
  18255. //}
  18256. //
  18257. //resThree.ErrMsg = resThree10265.ErrMsg
  18258. //
  18259. //resThree.Output = resThree10265.Output
  18260. //
  18261. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18262. //
  18263. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18264. //
  18265. } else {
  18266. 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)
  18267. var dat map[string]interface{}
  18268. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18269. fmt.Println(dat)
  18270. } else {
  18271. fmt.Println(err)
  18272. }
  18273. userJSONBytes, _ := json.Marshal(dat)
  18274. if miConfig.Code == "H15049901371" {
  18275. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  18276. utils.ErrorLog("解析失败:%v", err)
  18277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18278. return
  18279. }
  18280. res2.ErrMsg = res10265_2.ErrMsg
  18281. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  18282. res2.Infcode = infocode
  18283. res2.Output = res10265_2.Output
  18284. res2.InfRefmsgid = res10265_2.InfRefmsgid
  18285. } else {
  18286. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18287. utils.ErrorLog("解析失败:%v", err)
  18288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18289. return
  18290. }
  18291. }
  18292. }
  18293. }
  18294. if res2.Infcode == 0 {
  18295. psnResult := &models.GdybPsnNcdsRecord{
  18296. UserOrgId: adminUser.CurrentOrgId,
  18297. PatientId: patient.ID,
  18298. PsnNo: psn_no,
  18299. DoctorId: doctor.AdminUserId,
  18300. DepartmentId: department_id,
  18301. SickType: sick_id,
  18302. Insutype: insutype,
  18303. Ctime: time.Now().Unix(),
  18304. Mtime: time.Now().Unix(),
  18305. Status: 1,
  18306. IsCancel: 1,
  18307. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  18308. }
  18309. service.CreatePsnNCDSRecord(psnResult)
  18310. c.ServeSuccessJSON(map[string]interface{}{
  18311. "failed_code": 0,
  18312. "msg": "备案成功",
  18313. "result": psnResult,
  18314. })
  18315. } else {
  18316. c.ServeSuccessJSON(map[string]interface{}{
  18317. "failed_code": -10,
  18318. "msg": res2.ErrMsg,
  18319. })
  18320. return
  18321. }
  18322. }
  18323. }
  18324. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  18325. id, _ := c.GetInt64("id")
  18326. admin_user_id, _ := c.GetInt64("admin_user_id")
  18327. adminUser := c.GetAdminUserInfo()
  18328. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18329. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  18330. //config, _ := service.Ge(adminUser.CurrentOrgId)
  18331. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  18332. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18333. //var user_name string
  18334. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18335. //if role.ID == 0 {
  18336. // user_name = "xxx"
  18337. //} else {
  18338. // user_name = role.UserName
  18339. //}
  18340. psn_record, _ := service.GetPsnNCDSRecordById(id)
  18341. if psn_record.ID == 0 {
  18342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  18343. return
  18344. }
  18345. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  18346. var res ResultTwo
  18347. var res10265 ResultTwo10265
  18348. if miConfig.Code == "H15049901371" {
  18349. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  18350. utils.ErrorLog("解析失败:%v", err)
  18351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18352. return
  18353. }
  18354. res.ErrMsg = res10265.ErrMsg
  18355. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  18356. res.Infcode = infocode
  18357. res.Output = res10265.Output
  18358. res.InfRefmsgid = res10265.InfRefmsgid
  18359. } else {
  18360. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18361. utils.ErrorLog("解析失败:%v", err)
  18362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18363. return
  18364. }
  18365. }
  18366. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18367. infoStr := string(Iinfos)
  18368. var rf []*ResultFive
  18369. json.Unmarshal([]byte(infoStr), &rf)
  18370. var insuplc_admdvs string
  18371. var insutype string
  18372. var is390 int = 0
  18373. var is310 int = 0
  18374. var insutypes []*ResultFive
  18375. for _, item := range rf {
  18376. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18377. insutypes = append(insutypes, item)
  18378. }
  18379. }
  18380. if len(insutypes) == 1 {
  18381. insutype = insutypes[0].Insutype
  18382. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18383. } else {
  18384. for _, i := range insutypes {
  18385. if i.Insutype == "390" {
  18386. is390 = 1
  18387. }
  18388. if i.Insutype == "310" {
  18389. is310 = 1
  18390. }
  18391. }
  18392. }
  18393. if is390 == 1 {
  18394. insutype = "390"
  18395. }
  18396. if is310 == 1 {
  18397. insutype = "310"
  18398. }
  18399. if len(insutypes) == 0 {
  18400. insutype = "310"
  18401. }
  18402. insutype = psn_record.Insutype
  18403. for _, item := range rf {
  18404. if item.Insutype == insutype {
  18405. insuplc_admdvs = item.InsuplcAdmdvs
  18406. }
  18407. }
  18408. if config.IsOpen == 1 {
  18409. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  18410. var dat map[string]interface{}
  18411. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18412. fmt.Println(dat)
  18413. } else {
  18414. fmt.Println(err)
  18415. }
  18416. userJSONBytes, _ := json.Marshal(dat)
  18417. var res ResultFourteen
  18418. var res10265 ResultFourteen10265
  18419. if miConfig.Code == "H15049901371" {
  18420. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  18421. utils.ErrorLog("解析失败:%v", err)
  18422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18423. return
  18424. }
  18425. res.ErrMsg = res10265.ErrMsg
  18426. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  18427. res.Infcode = infocode
  18428. res.Output = res10265.Output
  18429. res.InfRefmsgid = res10265.InfRefmsgid
  18430. } else {
  18431. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18432. utils.ErrorLog("解析失败:%v", err)
  18433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18434. return
  18435. }
  18436. }
  18437. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18438. // utils.ErrorLog("解析失败:%v", err)
  18439. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18440. // return
  18441. //}
  18442. if res.Infcode == 0 {
  18443. psn_record.IsCancel = 2
  18444. service.CreatePsnNCDSRecord(&psn_record)
  18445. c.ServeSuccessJSON(map[string]interface{}{
  18446. "failed_code": 0,
  18447. "msg": "撤销备案成功",
  18448. })
  18449. } else {
  18450. c.ServeSuccessJSON(map[string]interface{}{
  18451. "failed_code": -10,
  18452. "msg": res.ErrMsg,
  18453. })
  18454. return
  18455. }
  18456. }
  18457. }
  18458. func (c *HisApiController) TestTest() {
  18459. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  18460. fmt.Println(patient.Iinfo)
  18461. }
  18462. type CustomData struct {
  18463. MsgId string
  18464. PsnNo string
  18465. Info string
  18466. }
  18467. func (c *HisApiController) ReversalData() {
  18468. var customData []*CustomData
  18469. custom := &CustomData{
  18470. MsgId: "H44022900158202103301714472004",
  18471. PsnNo: "44020000001101329945",
  18472. Info: "2207",
  18473. }
  18474. customData = append(customData, custom)
  18475. custom1 := &CustomData{
  18476. MsgId: "H4402290015820210330172057803",
  18477. PsnNo: "44020000001101161813",
  18478. Info: "2207",
  18479. }
  18480. customData = append(customData, custom1)
  18481. custom2 := &CustomData{
  18482. MsgId: "H44022900158202103301705198813",
  18483. PsnNo: "44190000133097375417",
  18484. Info: "2207",
  18485. }
  18486. customData = append(customData, custom2)
  18487. custom3 := &CustomData{
  18488. MsgId: "H44022900158202103301715524756",
  18489. PsnNo: "44020000001100187221",
  18490. Info: "2207",
  18491. }
  18492. customData = append(customData, custom3)
  18493. custom4 := &CustomData{
  18494. MsgId: "H44022900158202103301730376224",
  18495. PsnNo: "44020000001101959155",
  18496. Info: "2207",
  18497. }
  18498. customData = append(customData, custom4)
  18499. custom5 := &CustomData{
  18500. MsgId: "H44022900158202103301748008725",
  18501. PsnNo: "44020000001104246641",
  18502. Info: "2207",
  18503. }
  18504. customData = append(customData, custom5)
  18505. custom6 := &CustomData{
  18506. MsgId: "H44022900158202103301718096755",
  18507. PsnNo: "44020000001102211860",
  18508. Info: "2207",
  18509. }
  18510. customData = append(customData, custom6)
  18511. custom7 := &CustomData{
  18512. MsgId: "H44022900158202103301736551640",
  18513. PsnNo: "44020000001102687718",
  18514. Info: "2207",
  18515. }
  18516. customData = append(customData, custom7)
  18517. custom8 := &CustomData{
  18518. MsgId: "H44022900158202103301743097676",
  18519. PsnNo: "44020000001102127785",
  18520. Info: "2207",
  18521. }
  18522. customData = append(customData, custom8)
  18523. custom9 := &CustomData{
  18524. MsgId: "H44022900158202103301712304203",
  18525. PsnNo: "44020000001101518097",
  18526. Info: "2207",
  18527. }
  18528. customData = append(customData, custom9)
  18529. custom10 := &CustomData{
  18530. MsgId: "H44022900158202103301738448785",
  18531. PsnNo: "44020000001100500813",
  18532. Info: "2207",
  18533. }
  18534. customData = append(customData, custom10)
  18535. custom11 := &CustomData{
  18536. MsgId: "H44022900158202103301732455843",
  18537. PsnNo: "44020000001102690557",
  18538. Info: "2207",
  18539. }
  18540. customData = append(customData, custom11)
  18541. custom12 := &CustomData{
  18542. MsgId: "H44022900158202103301745421708",
  18543. PsnNo: "44020000001102211928",
  18544. Info: "2207",
  18545. }
  18546. customData = append(customData, custom12)
  18547. custom1212 := &CustomData{
  18548. MsgId: "H440229001582021033017351627",
  18549. PsnNo: "44020000001102481733",
  18550. Info: "2207",
  18551. }
  18552. customData = append(customData, custom1212)
  18553. custom13 := &CustomData{
  18554. MsgId: "H44022900158202103301740327951",
  18555. PsnNo: "44020000001103174866",
  18556. Info: "2207",
  18557. }
  18558. customData = append(customData, custom13)
  18559. custom14 := &CustomData{
  18560. MsgId: "H4402290015820210330174922668",
  18561. PsnNo: "44020000001102927272",
  18562. Info: "2207",
  18563. }
  18564. customData = append(customData, custom14)
  18565. custom15 := &CustomData{
  18566. MsgId: "H44022900158202103301752362273",
  18567. PsnNo: "44020000001102942890",
  18568. Info: "2207",
  18569. }
  18570. customData = append(customData, custom15)
  18571. custom16 := &CustomData{
  18572. MsgId: "H44022900158202103301751082917",
  18573. PsnNo: "44020000001101662162",
  18574. Info: "2207",
  18575. }
  18576. customData = append(customData, custom16)
  18577. custom17 := &CustomData{
  18578. MsgId: "H44022900158202103301754147728",
  18579. PsnNo: "44020000000229014511",
  18580. Info: "2207",
  18581. }
  18582. customData = append(customData, custom17)
  18583. adminUser := c.GetAdminUserInfo()
  18584. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18585. for _, item := range customData {
  18586. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  18587. fmt.Println(result)
  18588. }
  18589. }
  18590. func (c *HisApiController) GetAllopatry() {
  18591. year := c.GetString("year")
  18592. month := c.GetString("month")
  18593. admin_user_id, _ := c.GetInt64("admin_user_id")
  18594. adminUser := c.GetAdminUserInfo()
  18595. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18596. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18597. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  18598. var dat map[string]interface{}
  18599. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18600. fmt.Println(dat)
  18601. } else {
  18602. fmt.Println(err)
  18603. }
  18604. userJSONBytes, _ := json.Marshal(dat)
  18605. var res models.Result9001
  18606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18607. utils.ErrorLog("解析失败:%v", err)
  18608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18609. return
  18610. }
  18611. fmt.Println(res.Output.Signinoutb)
  18612. fmt.Println(res.Output.Signinoutb.SignNo)
  18613. fmt.Println(string(userJSONBytes))
  18614. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  18615. var dat3 map[string]interface{}
  18616. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  18617. fmt.Println(dat3)
  18618. } else {
  18619. fmt.Println(err)
  18620. }
  18621. userJSONBytes3, _ := json.Marshal(dat3)
  18622. var res3 models.Result3260
  18623. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  18624. utils.ErrorLog("解析失败:%v", err)
  18625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18626. return
  18627. }
  18628. var curpage int
  18629. var pagesize int = 100
  18630. var start int = 1
  18631. //var stop int
  18632. //pagecount := 10
  18633. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  18634. for curpage = 1; curpage <= pagecount; curpage++ {
  18635. if curpage == 1 {
  18636. start = 0
  18637. } else {
  18638. start = (curpage-1)*pagesize + 1
  18639. }
  18640. fmt.Println(start)
  18641. //stop = curpage * pagesize
  18642. //if stop > int(res3.Output.Totalrow) {
  18643. // stop =int(res3.Output.Totalrow)
  18644. //}
  18645. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  18646. var dat2 map[string]interface{}
  18647. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  18648. fmt.Println(dat)
  18649. } else {
  18650. fmt.Println(err)
  18651. }
  18652. userJSONBytes2, _ := json.Marshal(dat2)
  18653. var res2 models.Result3260
  18654. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18655. utils.ErrorLog("解析失败:%v", err)
  18656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18657. return
  18658. }
  18659. if res2.Infcode == 0 {
  18660. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  18661. var dat2 map[string]interface{}
  18662. if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  18663. fmt.Println(dat)
  18664. } else {
  18665. fmt.Println(err)
  18666. }
  18667. c.ServeSuccessJSON(map[string]interface{}{
  18668. "list": res2.Output.Data,
  18669. })
  18670. continue
  18671. }
  18672. }
  18673. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  18674. //var dat2 map[string]interface{}
  18675. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  18676. // fmt.Println(dat)
  18677. //} else {
  18678. // fmt.Println(err)
  18679. //}
  18680. //userJSONBytes2, _ := json.Marshal(dat2)
  18681. //var res2 models.Result3260
  18682. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18683. // utils.ErrorLog("解析失败:%v", err)
  18684. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18685. // return
  18686. //}
  18687. //if res2.Infcode == 0 {
  18688. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  18689. // var dat2 map[string]interface{}
  18690. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  18691. // fmt.Println(dat)
  18692. // } else {
  18693. // fmt.Println(err)
  18694. // }
  18695. // c.ServeSuccessJSON(map[string]interface{}{
  18696. // "list": res2.Output.Data,
  18697. // })
  18698. //}
  18699. }
  18700. func (c *HisApiController) ComfirmAllopatry() {
  18701. year := c.GetString("year")
  18702. month := c.GetString("month")
  18703. admin_user_id, _ := c.GetInt64("admin_user_id")
  18704. adminUser := c.GetAdminUserInfo()
  18705. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18706. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18707. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  18708. var dat map[string]interface{}
  18709. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18710. fmt.Println(dat)
  18711. } else {
  18712. fmt.Println(err)
  18713. }
  18714. userJSONBytes, _ := json.Marshal(dat)
  18715. var res models.Result9001
  18716. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18717. utils.ErrorLog("解析失败:%v", err)
  18718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18719. return
  18720. }
  18721. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  18722. var dat2 map[string]interface{}
  18723. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  18724. fmt.Println(dat)
  18725. } else {
  18726. fmt.Println(err)
  18727. }
  18728. userJSONBytes2, _ := json.Marshal(dat2)
  18729. var res2 models.Result3260
  18730. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18731. utils.ErrorLog("解析失败:%v", err)
  18732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18733. return
  18734. }
  18735. //if res2.Infcode == 0 {
  18736. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  18737. // var dat map[string]interface{}
  18738. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18739. // fmt.Println(dat)
  18740. // } else {
  18741. // fmt.Println(err)
  18742. // }
  18743. // userJSONBytes, _ := json.Marshal(dat)
  18744. // var res3 models.Result3261
  18745. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  18746. // utils.ErrorLog("解析失败:%v", err)
  18747. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18748. // return
  18749. // }
  18750. //
  18751. // if res3.Infcode == 0 {
  18752. // record := &models.HisYidiClearRecord{
  18753. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18754. // Ctime: time.Now().Unix(),
  18755. // Mtime: time.Now().Unix(),
  18756. // Status: 1,
  18757. // MsgId: msgId,
  18758. // }
  18759. // service.SaveClearRecord(record)
  18760. // c.ServeSuccessJSON(map[string]interface{}{
  18761. // "msg": "提取成功",
  18762. // })
  18763. // }
  18764. //}
  18765. }
  18766. func (c *HisApiController) RefundAllopatry() {
  18767. year := c.GetString("year")
  18768. month := c.GetString("month")
  18769. //id, _ := c.GetInt64("id")
  18770. admin_user_id, _ := c.GetInt64("admin_user_id")
  18771. adminUser := c.GetAdminUserInfo()
  18772. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18773. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18774. //record, _ := service.GetClearRecordById(id)
  18775. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  18776. var dat map[string]interface{}
  18777. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  18778. fmt.Println(dat)
  18779. } else {
  18780. fmt.Println(err)
  18781. }
  18782. userJSONBytes, _ := json.Marshal(dat)
  18783. var res models.Result9001
  18784. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18785. utils.ErrorLog("解析失败:%v", err)
  18786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18787. return
  18788. }
  18789. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  18790. var dat2 map[string]interface{}
  18791. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  18792. fmt.Println(dat)
  18793. } else {
  18794. fmt.Println(err)
  18795. }
  18796. userJSONBytes2, _ := json.Marshal(dat2)
  18797. var empty ResultFourteen
  18798. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  18799. utils.ErrorLog("解析失败:%v", err)
  18800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18801. return
  18802. }
  18803. if empty.Infcode == 0 {
  18804. c.ServeSuccessJSON(map[string]interface{}{
  18805. "msg": "撤销成功",
  18806. })
  18807. return
  18808. }
  18809. }
  18810. func (c *HisApiController) ReversalOtherData() {
  18811. var customData []*CustomData
  18812. custom := &CustomData{
  18813. MsgId: "H44022900158202103301714472004",
  18814. PsnNo: "44020000001101329945",
  18815. Info: "2208",
  18816. }
  18817. customData = append(customData, custom)
  18818. custom1 := &CustomData{
  18819. MsgId: "H4402290015820210330172057803",
  18820. PsnNo: "44020000001101161813",
  18821. Info: "2208",
  18822. }
  18823. customData = append(customData, custom1)
  18824. custom2 := &CustomData{
  18825. MsgId: "H44022900158202103301705198813",
  18826. PsnNo: "44190000133097375417",
  18827. Info: "2208",
  18828. }
  18829. customData = append(customData, custom2)
  18830. custom3 := &CustomData{
  18831. MsgId: "H44022900158202103301715524756",
  18832. PsnNo: "44020000001100187221",
  18833. Info: "2208",
  18834. }
  18835. customData = append(customData, custom3)
  18836. custom4 := &CustomData{
  18837. MsgId: "H44022900158202103301730376224",
  18838. PsnNo: "44020000001101959155",
  18839. Info: "2208",
  18840. }
  18841. customData = append(customData, custom4)
  18842. custom5 := &CustomData{
  18843. MsgId: "H44022900158202103301748008725",
  18844. PsnNo: "44020000001104246641",
  18845. Info: "2208",
  18846. }
  18847. customData = append(customData, custom5)
  18848. custom6 := &CustomData{
  18849. MsgId: "H44022900158202103301718096755",
  18850. PsnNo: "44020000001102211860",
  18851. Info: "2208",
  18852. }
  18853. customData = append(customData, custom6)
  18854. custom7 := &CustomData{
  18855. MsgId: "H44022900158202103301736551640",
  18856. PsnNo: "44020000001102687718",
  18857. Info: "2208",
  18858. }
  18859. customData = append(customData, custom7)
  18860. custom8 := &CustomData{
  18861. MsgId: "H44022900158202103301743097676",
  18862. PsnNo: "44020000001102127785",
  18863. Info: "2208",
  18864. }
  18865. customData = append(customData, custom8)
  18866. custom9 := &CustomData{
  18867. MsgId: "H44022900158202103301712304203",
  18868. PsnNo: "44020000001101518097",
  18869. Info: "2208",
  18870. }
  18871. customData = append(customData, custom9)
  18872. custom10 := &CustomData{
  18873. MsgId: "H44022900158202103301738448785",
  18874. PsnNo: "44020000001100500813",
  18875. Info: "2208",
  18876. }
  18877. customData = append(customData, custom10)
  18878. custom11 := &CustomData{
  18879. MsgId: "H44022900158202103301732455843",
  18880. PsnNo: "44020000001102690557",
  18881. Info: "2208",
  18882. }
  18883. customData = append(customData, custom11)
  18884. custom12 := &CustomData{
  18885. MsgId: "H44022900158202103301745421708",
  18886. PsnNo: "44020000001102211928",
  18887. Info: "2208",
  18888. }
  18889. customData = append(customData, custom12)
  18890. custom1212 := &CustomData{
  18891. MsgId: "H440229001582021033017351627",
  18892. PsnNo: "44020000001102481733",
  18893. Info: "2208",
  18894. }
  18895. customData = append(customData, custom1212)
  18896. custom13 := &CustomData{
  18897. MsgId: "H44022900158202103301740327951",
  18898. PsnNo: "44020000001103174866",
  18899. Info: "2208",
  18900. }
  18901. customData = append(customData, custom13)
  18902. custom14 := &CustomData{
  18903. MsgId: "H4402290015820210330174922668",
  18904. PsnNo: "44020000001102927272",
  18905. Info: "2208",
  18906. }
  18907. customData = append(customData, custom14)
  18908. custom15 := &CustomData{
  18909. MsgId: "H44022900158202103301752362273",
  18910. PsnNo: "44020000001102942890",
  18911. Info: "2208",
  18912. }
  18913. customData = append(customData, custom15)
  18914. custom16 := &CustomData{
  18915. MsgId: "H44022900158202103301751082917",
  18916. PsnNo: "44020000001101662162",
  18917. Info: "2208",
  18918. }
  18919. customData = append(customData, custom16)
  18920. custom17 := &CustomData{
  18921. MsgId: "H44022900158202103301754147728",
  18922. PsnNo: "44020000000229014511",
  18923. Info: "2208",
  18924. }
  18925. customData = append(customData, custom17)
  18926. adminUser := c.GetAdminUserInfo()
  18927. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18928. for _, item := range customData {
  18929. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  18930. fmt.Println(result)
  18931. }
  18932. }
  18933. func PathExists(path string) (bool, error) {
  18934. _, err := os.Stat(path)
  18935. if err == nil {
  18936. return true, nil
  18937. }
  18938. if os.IsNotExist(err) {
  18939. return false, nil
  18940. }
  18941. return false, err
  18942. }
  18943. // 创建文件夹
  18944. func Mkdir(dir string) {
  18945. // 创建文件夹
  18946. exist, err := PathExists(dir)
  18947. if err != nil {
  18948. fmt.Println(err.Error())
  18949. } else {
  18950. if exist {
  18951. fmt.Println(dir + "文件夹已存在!")
  18952. } else {
  18953. // 文件夹名称,权限
  18954. err := os.Mkdir(dir, os.ModePerm)
  18955. if err != nil {
  18956. fmt.Println(dir+"文件夹创建失败:", err.Error())
  18957. } else {
  18958. fmt.Println(dir + "文件夹创建成功!")
  18959. }
  18960. }
  18961. }
  18962. }
  18963. // 压缩文件
  18964. func Zip(srcFile string, destZip string) error {
  18965. zipfile, err := os.Create(destZip)
  18966. if err != nil {
  18967. return err
  18968. }
  18969. defer zipfile.Close()
  18970. archive := zip.NewWriter(zipfile)
  18971. defer archive.Close()
  18972. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  18973. if err != nil {
  18974. return err
  18975. }
  18976. header, err := zip.FileInfoHeader(info)
  18977. if err != nil {
  18978. return err
  18979. }
  18980. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  18981. // header.Name = path
  18982. if info.IsDir() {
  18983. header.Name += "/"
  18984. } else {
  18985. header.Method = zip.Deflate
  18986. }
  18987. writer, err := archive.CreateHeader(header)
  18988. if err != nil {
  18989. return err
  18990. }
  18991. if !info.IsDir() {
  18992. file, err := os.Open(path)
  18993. if err != nil {
  18994. return err
  18995. }
  18996. defer file.Close()
  18997. _, err = io.Copy(writer, file)
  18998. }
  18999. return err
  19000. })
  19001. return err
  19002. }
  19003. func ReadFile(filePath string) []byte {
  19004. f, err := os.Open(filePath)
  19005. if err != nil {
  19006. fmt.Println("read file fail", err)
  19007. return nil
  19008. }
  19009. defer f.Close()
  19010. fd, err := ioutil.ReadAll(f)
  19011. if err != nil {
  19012. fmt.Println("read to fd fail", err)
  19013. return nil
  19014. }
  19015. return fd
  19016. }
  19017. func saveLog(result string, request string, infno string, desc string) {
  19018. org_id, _ := beego.AppConfig.Int64("org_id")
  19019. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  19020. dir := miConfig.OrgName + "日志"
  19021. utils.Mkdir(dir)
  19022. month := time.Unix(1557042972, 0).Format("1")
  19023. year := time.Now().Format("2006")
  19024. month = time.Now().Format("01")
  19025. day := time.Now().Format("02")
  19026. hour := time.Now().Format("15")
  19027. min := time.Now().Format("04")
  19028. sec := time.Now().Format("05")
  19029. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  19030. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  19031. file_name := file + ".txt"
  19032. file_path := miConfig.OrgName + "日志" + "/" + file_name
  19033. exist, _ := utils.PathExists(file_path)
  19034. if exist { //存在
  19035. fmt.Println("存在")
  19036. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  19037. if err != nil {
  19038. fmt.Println("read fail")
  19039. }
  19040. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  19041. n, _ := f.Seek(0, 2)
  19042. _, err = f.WriteAt([]byte(content), n)
  19043. } else { //不存在
  19044. fmt.Println("文件不存在,创建文件")
  19045. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  19046. defer f.Close()
  19047. if err != nil {
  19048. } else {
  19049. _, err = f.Write([]byte("记录日志"))
  19050. }
  19051. }
  19052. }
  19053. type Charset string
  19054. const (
  19055. UTF8 = Charset("UTF-8")
  19056. GB18030 = Charset("GB18030")
  19057. )
  19058. func ConvertToString(src string, srcCode string, tagCode string) string {
  19059. srcCoder := mahonia.NewDecoder(srcCode)
  19060. srcResult := srcCoder.ConvertString(src)
  19061. tagCoder := mahonia.NewDecoder(tagCode)
  19062. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  19063. result := string(cdata)
  19064. return result
  19065. }
  19066. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  19067. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  19068. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  19069. var token string
  19070. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19071. var api string
  19072. if miConfig.MdtrtareaAdmvs == "320921" {
  19073. 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 +
  19074. "&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
  19075. fmt.Println(api)
  19076. } else {
  19077. 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 +
  19078. "&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
  19079. }
  19080. resp, requestErr := http.Get(api)
  19081. if requestErr != nil {
  19082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19083. return ""
  19084. }
  19085. body, ioErr := ioutil.ReadAll(resp.Body)
  19086. if ioErr != nil {
  19087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19089. return ""
  19090. }
  19091. var respJSON map[string]interface{}
  19092. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19095. return ""
  19096. }
  19097. var status string
  19098. status = respJSON["data"].(map[string]interface{})["status"].(string)
  19099. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  19100. var res ResultTwo //1101结果
  19101. var res10265 ResultTwo10265 //1101结果
  19102. if status == "0" { //读卡成功
  19103. var card_info string //卡信息
  19104. var busi_card_info string
  19105. token = respJSON["data"].(map[string]interface{})["token"].(string)
  19106. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  19107. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  19108. fmt.Println(card_info)
  19109. fmt.Println(busi_card_info)
  19110. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  19111. result, _ := json.Marshal(respJSON)
  19112. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  19113. utils.ErrorLog("解析失败:%v", err)
  19114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19115. return ""
  19116. }
  19117. res.ErrMsg = res10265.ErrMsg
  19118. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  19119. res.Infcode = infocode
  19120. res.Output = res10265.Output
  19121. res.InfRefmsgid = res10265.InfRefmsgid
  19122. if res.Infcode == 0 {
  19123. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  19124. if err == gorm.ErrRecordNotFound {
  19125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  19126. return ""
  19127. } else if err != nil {
  19128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  19129. return ""
  19130. } else {
  19131. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  19132. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  19133. infoStr := string(Iinfos)
  19134. idetinfoStr := string(Idetinfos)
  19135. psn := &models.HisPsn{
  19136. PsnNo: res.Output.Baseinfo.PsnNo,
  19137. Age: res.Output.Baseinfo.Age,
  19138. PatientId: patient.ID,
  19139. Certno: res.Output.Baseinfo.Certno,
  19140. Brdy: res.Output.Baseinfo.Brdy,
  19141. Gend: res.Output.Baseinfo.Gend,
  19142. Naty: res.Output.Baseinfo.Naty,
  19143. PsnCertType: res.Output.Baseinfo.PsnCertType,
  19144. PsnName: res.Output.Baseinfo.PsnName,
  19145. Idetinfo: idetinfoStr,
  19146. Insuinfo: infoStr,
  19147. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19148. CardInfo: card_info,
  19149. VerifyNumber: token,
  19150. }
  19151. service.CreateHisPsn(psn)
  19152. return token
  19153. }
  19154. }
  19155. } else {
  19156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  19157. return ""
  19158. }
  19159. } else { //读卡失败
  19160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  19161. return ""
  19162. }
  19163. return token
  19164. }
  19165. func DeleteExtraSpaceTwo(s string) string {
  19166. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  19167. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  19168. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  19169. reg, _ := regexp.Compile(regstr) //编译正则表达式
  19170. s2 := make([]byte, len(s1)) //定义字符数组切片
  19171. copy(s2, s1) //将字符串复制到切片
  19172. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  19173. for len(spc_index) > 0 { //找到适配项
  19174. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  19175. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  19176. }
  19177. return string(s2)
  19178. }
  19179. func Remove0000(s string) string {
  19180. str := make([]rune, 0, len(s))
  19181. for _, v := range []rune(s) {
  19182. if v == 0 {
  19183. continue
  19184. }
  19185. str = append(str, v)
  19186. }
  19187. return string(str)
  19188. }
  19189. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  19190. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  19191. readCard := DllDef.MustFindProc("EcQuery")
  19192. pCardInfo := make([]byte, 8192)
  19193. pBusiCardInfo := make([]byte, 8192)
  19194. data := make(map[string]interface{})
  19195. //pData := make(map[string]interface{})
  19196. inputData := make(map[string]interface{})
  19197. inputData["orgId"] = code
  19198. inputData["businessType"] = "01101"
  19199. inputData["operatorId"] = operator_id
  19200. inputData["operatorName"] = operator_name
  19201. inputData["officeId"] = "001"
  19202. inputData["officeName"] = "血透室"
  19203. //
  19204. data["data"] = inputData
  19205. data["transType"] = "ec.query"
  19206. data["orgId"] = code
  19207. bytesData, _ := json.Marshal(data)
  19208. pCardInfo = bytesData
  19209. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  19210. fmt.Println(ret2)
  19211. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  19212. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  19213. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  19214. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  19215. if ret2 != 0 {
  19216. return "", ""
  19217. }
  19218. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  19219. }
  19220. func DeleteExtraSpace(s string) string {
  19221. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  19222. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  19223. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  19224. reg, _ := regexp.Compile(regstr) //编译正则表达式
  19225. s2 := make([]byte, len(s1)) //定义字符数组切片
  19226. copy(s2, s1) //将字符串复制到切片
  19227. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  19228. for len(spc_index) > 0 { //找到适配项
  19229. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  19230. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  19231. }
  19232. return string(s2)
  19233. }
  19234. // 对账
  19235. func (c *HisApiController) Post3202() {
  19236. start_time := c.GetString("start_time")
  19237. end_time := c.GetString("end_time")
  19238. //insutype := c.GetString("insutype")
  19239. clr_type := c.GetString("clr_type")
  19240. clr_org := c.GetString("clr_optins")
  19241. admin_user_id, _ := c.GetInt64("admin_user_id")
  19242. adminUser := c.GetAdminUserInfo()
  19243. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  19244. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  19245. if len(clr_org) == 0 {
  19246. clr_org = miConfig.MdtrtareaAdmvs
  19247. }
  19248. timeLayout := "2006-01-02"
  19249. loc, _ := time.LoadLocation("Local")
  19250. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  19251. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  19252. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  19253. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  19254. //fixmedins_setl_cnt := int64(len(orders))
  19255. var medfee_sumamt float64
  19256. var acct_pay float64
  19257. var fund_pay_sumamt float64
  19258. for _, item := range orders {
  19259. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  19260. acct_pay = acct_pay + item.AcctPay
  19261. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  19262. }
  19263. //var medfee_sumamt_two float64
  19264. //var acct_pay_two float64
  19265. //var fund_pay_sumamt_two float64
  19266. //for _, item := range orders_two {
  19267. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  19268. // acct_pay_two = acct_pay_two + item.AcctPay
  19269. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  19270. //}
  19271. //var user_name string
  19272. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  19273. //if role.ID == 0 {
  19274. // user_name = "xxx"
  19275. //} else {
  19276. // user_name = role.UserName
  19277. //}
  19278. var res ResultSix
  19279. if config.IsOpen == 1 {
  19280. var bps []*models.BusinessParamsTwo
  19281. var bp models.BusinessParamsTwo
  19282. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  19283. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  19284. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  19285. bp.MedfeeSumamt = medfee_sumamt_str
  19286. bp.AcctPay = acct_pay_str
  19287. bp.FundPaySumamt = fund_pay_sumamt_str
  19288. bp.Insutype = "390"
  19289. bp.StmtBegndate = start_time
  19290. bp.ClrType = clr_type
  19291. bp.SetlOptins = clr_org
  19292. bp.StmtEnddate = end_time
  19293. bps = append(bps, &bp)
  19294. data := make(map[string]interface{})
  19295. data["bps"] = bps
  19296. data["org_name"] = miConfig.OrgName
  19297. data["doctor"] = role.UserName
  19298. data["fixmedins_code"] = miConfig.Code
  19299. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  19300. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19301. if miConfig.MdtrtareaAdmvs == "421300" {
  19302. client := &http.Client{}
  19303. bytesData, _ := json.Marshal(data)
  19304. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  19305. resp, _ := client.Do(req)
  19306. defer resp.Body.Close()
  19307. body, ioErr := ioutil.ReadAll(resp.Body)
  19308. if ioErr != nil {
  19309. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19311. return
  19312. }
  19313. var respJSON map[string]interface{}
  19314. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19315. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19317. return
  19318. }
  19319. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19320. userJSONBytes, _ := json.Marshal(respJSON)
  19321. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19322. utils.ErrorLog("解析失败:%v", err)
  19323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19324. return
  19325. }
  19326. }
  19327. if res.Infcode == 0 {
  19328. c.ServeSuccessJSON(map[string]interface{}{
  19329. "msg": "发起成功",
  19330. })
  19331. } else {
  19332. c.ServeSuccessJSON(map[string]interface{}{
  19333. "code": -10,
  19334. "msg": res.ErrMsg,
  19335. })
  19336. }
  19337. }
  19338. }
  19339. func (c *HisApiController) Post3501() {
  19340. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19341. data := make(map[string]interface{})
  19342. var struct3501s []models.Struct3501
  19343. var struct3501 models.Struct3501
  19344. struct3501.OrgName = miConfig.OrgName
  19345. struct3501.AccessKey = miConfig.AccessKey
  19346. struct3501.RequestUrl = miConfig.Url
  19347. struct3501.SecretKey = miConfig.SecretKey
  19348. struct3501.ManuDate = "2022-08-17"
  19349. struct3501.FixmedinsBchno = ""
  19350. struct3501.ManuLotnum = ""
  19351. struct3501.RxFlag = "0"
  19352. struct3501.ExpyEnd = "2022-08-17"
  19353. struct3501.Invdate = "2022-08-17"
  19354. struct3501.InvCnt = "20.25"
  19355. struct3501.Memo = ""
  19356. struct3501.MedListCodg = "XB01ABD056B002020200517"
  19357. struct3501.FixmedinsHilistId = miConfig.Code
  19358. struct3501.FixmedinsHilistName = miConfig.OrgName
  19359. struct3501s = append(struct3501s, struct3501)
  19360. data["struct_3501s"] = struct3501s
  19361. client := &http.Client{}
  19362. bytesData, _ := json.Marshal(data)
  19363. var req *http.Request
  19364. if miConfig.MdtrtareaAdmvs == "320921" {
  19365. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19366. } else {
  19367. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19368. }
  19369. resp, _ := client.Do(req)
  19370. defer resp.Body.Close()
  19371. body, ioErr := ioutil.ReadAll(resp.Body)
  19372. if ioErr != nil {
  19373. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19375. return
  19376. }
  19377. var respJSON map[string]interface{}
  19378. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19381. return
  19382. }
  19383. var res ResultSix
  19384. var resSix10265 ResultSix10265 //1101结果
  19385. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19386. result, _ := json.Marshal(respJSON)
  19387. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  19388. utils.ErrorLog("解析失败:%v", err)
  19389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19390. return
  19391. }
  19392. res.InfRefmsgid = resSix10265.InfRefmsgid
  19393. res.Output = resSix10265.Output
  19394. res.ErrMsg = resSix10265.ErrMsg
  19395. res.Cainfo = resSix10265.Cainfo
  19396. res.WarnMsg = resSix10265.WarnMsg
  19397. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  19398. res.Infcode = infocode
  19399. if infocode == 0 {
  19400. c.ServeSuccessJSON(map[string]interface{}{
  19401. "msg": "上传成功",
  19402. })
  19403. return
  19404. } else {
  19405. c.ServeSuccessJSON(map[string]interface{}{
  19406. "failed_code": -10,
  19407. "msg": res.ErrMsg,
  19408. })
  19409. return
  19410. }
  19411. }
  19412. func (c *HisApiController) Post3502() {
  19413. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19414. data := make(map[string]interface{})
  19415. var struct3502s []models.Struct3502
  19416. var struct3502 models.Struct3502
  19417. struct3502.OrgName = miConfig.OrgName
  19418. struct3502.AccessKey = miConfig.AccessKey
  19419. struct3502.RequestUrl = miConfig.Url
  19420. struct3502.SecretKey = miConfig.SecretKey
  19421. struct3502.ManuDate = "2022-08-15"
  19422. struct3502.FixmedinsBchno = ""
  19423. struct3502.ManuLotnum = ""
  19424. struct3502.RxFlag = "0"
  19425. struct3502.ExpyEnd = "2022-08-15"
  19426. struct3502.Invdate = "2022-08-15"
  19427. struct3502.InvCnt = "20.25"
  19428. struct3502.Memo = ""
  19429. struct3502.MedListCodg = "XB01ABD056B002020200517"
  19430. struct3502.FixmedinsHilistId = miConfig.Code
  19431. struct3502.FixmedinsHilistName = miConfig.OrgName
  19432. struct3502s = append(struct3502s, struct3502)
  19433. data["struct_3502s"] = struct3502s
  19434. client := &http.Client{}
  19435. bytesData, _ := json.Marshal(data)
  19436. var req *http.Request
  19437. if miConfig.MdtrtareaAdmvs == "320921" {
  19438. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19439. } else {
  19440. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19441. }
  19442. resp, _ := client.Do(req)
  19443. defer resp.Body.Close()
  19444. body, ioErr := ioutil.ReadAll(resp.Body)
  19445. if ioErr != nil {
  19446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19448. return
  19449. }
  19450. var respJSON map[string]interface{}
  19451. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19454. return
  19455. }
  19456. var res ResultSix
  19457. var resSix10265 ResultSix10265 //1101结果
  19458. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19459. result, _ := json.Marshal(respJSON)
  19460. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  19461. utils.ErrorLog("解析失败:%v", err)
  19462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19463. return
  19464. }
  19465. res.InfRefmsgid = resSix10265.InfRefmsgid
  19466. res.Output = resSix10265.Output
  19467. res.ErrMsg = resSix10265.ErrMsg
  19468. res.Cainfo = resSix10265.Cainfo
  19469. res.WarnMsg = resSix10265.WarnMsg
  19470. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  19471. res.Infcode = infocode
  19472. if infocode == 0 {
  19473. c.ServeSuccessJSON(map[string]interface{}{
  19474. "msg": "上传成功",
  19475. })
  19476. return
  19477. } else {
  19478. c.ServeSuccessJSON(map[string]interface{}{
  19479. "failed_code": -10,
  19480. "msg": res.ErrMsg,
  19481. })
  19482. return
  19483. }
  19484. }
  19485. func (c *HisApiController) Post3503() {
  19486. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19487. data := make(map[string]interface{})
  19488. var struct3501s []models.Struct3501
  19489. var struct3501 models.Struct3501
  19490. struct3501.OrgName = miConfig.OrgName
  19491. struct3501.AccessKey = miConfig.AccessKey
  19492. struct3501.RequestUrl = miConfig.Url
  19493. struct3501.SecretKey = miConfig.SecretKey
  19494. struct3501.ManuDate = "2022-08-15"
  19495. struct3501.FixmedinsBchno = ""
  19496. struct3501.ManuLotnum = ""
  19497. struct3501.RxFlag = "0"
  19498. struct3501.ExpyEnd = "2022-08-15"
  19499. struct3501.Invdate = "2022-08-15"
  19500. struct3501.InvCnt = "20.25"
  19501. struct3501.Memo = ""
  19502. struct3501.MedListCodg = "XB01ABD056B002020200517"
  19503. struct3501.FixmedinsHilistId = miConfig.Code
  19504. struct3501.FixmedinsHilistName = miConfig.OrgName
  19505. struct3501s = append(struct3501s, struct3501)
  19506. data["struct_3501s"] = struct3501s
  19507. client := &http.Client{}
  19508. bytesData, _ := json.Marshal(data)
  19509. var req *http.Request
  19510. if miConfig.MdtrtareaAdmvs == "320921" {
  19511. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19512. } else {
  19513. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19514. }
  19515. resp, _ := client.Do(req)
  19516. defer resp.Body.Close()
  19517. body, ioErr := ioutil.ReadAll(resp.Body)
  19518. if ioErr != nil {
  19519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19521. return
  19522. }
  19523. var respJSON map[string]interface{}
  19524. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19527. return
  19528. }
  19529. var res ResultSix
  19530. var resSix10265 ResultSix10265 //1101结果
  19531. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19532. result, _ := json.Marshal(respJSON)
  19533. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  19534. utils.ErrorLog("解析失败:%v", err)
  19535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19536. return
  19537. }
  19538. res.InfRefmsgid = resSix10265.InfRefmsgid
  19539. res.Output = resSix10265.Output
  19540. res.ErrMsg = resSix10265.ErrMsg
  19541. res.Cainfo = resSix10265.Cainfo
  19542. res.WarnMsg = resSix10265.WarnMsg
  19543. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  19544. res.Infcode = infocode
  19545. if infocode == 0 {
  19546. c.ServeSuccessJSON(map[string]interface{}{
  19547. "msg": "上传成功",
  19548. })
  19549. return
  19550. } else {
  19551. c.ServeSuccessJSON(map[string]interface{}{
  19552. "failed_code": -10,
  19553. "msg": res.ErrMsg,
  19554. })
  19555. return
  19556. }
  19557. }
  19558. func (c *HisApiController) Post3504() {
  19559. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19560. data := make(map[string]interface{})
  19561. var struct3501s []models.Struct3501
  19562. var struct3501 models.Struct3501
  19563. struct3501.OrgName = miConfig.OrgName
  19564. struct3501.AccessKey = miConfig.AccessKey
  19565. struct3501.RequestUrl = miConfig.Url
  19566. struct3501.SecretKey = miConfig.SecretKey
  19567. struct3501.ManuDate = "2022-08-15"
  19568. struct3501.FixmedinsBchno = ""
  19569. struct3501.ManuLotnum = ""
  19570. struct3501.RxFlag = "0"
  19571. struct3501.ExpyEnd = "2022-08-15"
  19572. struct3501.Invdate = "2022-08-15"
  19573. struct3501.InvCnt = "20.25"
  19574. struct3501.Memo = ""
  19575. struct3501.MedListCodg = "XB01ABD056B002020200517"
  19576. struct3501.FixmedinsHilistId = miConfig.Code
  19577. struct3501.FixmedinsHilistName = miConfig.OrgName
  19578. struct3501s = append(struct3501s, struct3501)
  19579. data["struct_3501s"] = struct3501s
  19580. client := &http.Client{}
  19581. bytesData, _ := json.Marshal(data)
  19582. var req *http.Request
  19583. if miConfig.MdtrtareaAdmvs == "320921" {
  19584. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19585. } else {
  19586. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19587. }
  19588. resp, _ := client.Do(req)
  19589. defer resp.Body.Close()
  19590. body, ioErr := ioutil.ReadAll(resp.Body)
  19591. if ioErr != nil {
  19592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19594. return
  19595. }
  19596. var respJSON map[string]interface{}
  19597. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19600. return
  19601. }
  19602. var res ResultSix
  19603. var resSix10265 ResultSix10265 //1101结果
  19604. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19605. result, _ := json.Marshal(respJSON)
  19606. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  19607. utils.ErrorLog("解析失败:%v", err)
  19608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19609. return
  19610. }
  19611. res.InfRefmsgid = resSix10265.InfRefmsgid
  19612. res.Output = resSix10265.Output
  19613. res.ErrMsg = resSix10265.ErrMsg
  19614. res.Cainfo = resSix10265.Cainfo
  19615. res.WarnMsg = resSix10265.WarnMsg
  19616. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  19617. res.Infcode = infocode
  19618. if infocode == 0 {
  19619. c.ServeSuccessJSON(map[string]interface{}{
  19620. "msg": "上传成功",
  19621. })
  19622. return
  19623. } else {
  19624. c.ServeSuccessJSON(map[string]interface{}{
  19625. "failed_code": -10,
  19626. "msg": res.ErrMsg,
  19627. })
  19628. return
  19629. }
  19630. }
  19631. func (c *HisApiController) Post3505() {
  19632. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19633. data := make(map[string]interface{})
  19634. var struct3501s []models.Struct3501
  19635. var struct3501 models.Struct3501
  19636. struct3501.OrgName = miConfig.OrgName
  19637. struct3501.AccessKey = miConfig.AccessKey
  19638. struct3501.RequestUrl = miConfig.Url
  19639. struct3501.SecretKey = miConfig.SecretKey
  19640. struct3501.ManuDate = "2022-08-15"
  19641. struct3501.FixmedinsBchno = ""
  19642. struct3501.ManuLotnum = ""
  19643. struct3501.RxFlag = "0"
  19644. struct3501.ExpyEnd = "2022-08-15"
  19645. struct3501.Invdate = "2022-08-15"
  19646. struct3501.InvCnt = "20.25"
  19647. struct3501.Memo = ""
  19648. struct3501.MedListCodg = "XB01ABD056B002020200517"
  19649. struct3501.FixmedinsHilistId = miConfig.Code
  19650. struct3501.FixmedinsHilistName = miConfig.OrgName
  19651. struct3501s = append(struct3501s, struct3501)
  19652. data["struct_3501s"] = struct3501s
  19653. client := &http.Client{}
  19654. bytesData, _ := json.Marshal(data)
  19655. var req *http.Request
  19656. if miConfig.MdtrtareaAdmvs == "320921" {
  19657. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19658. } else {
  19659. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19660. }
  19661. resp, _ := client.Do(req)
  19662. defer resp.Body.Close()
  19663. body, ioErr := ioutil.ReadAll(resp.Body)
  19664. if ioErr != nil {
  19665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19667. return
  19668. }
  19669. var respJSON map[string]interface{}
  19670. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19673. return
  19674. }
  19675. var res ResultSix
  19676. var resSix10265 ResultSix10265 //1101结果
  19677. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19678. result, _ := json.Marshal(respJSON)
  19679. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  19680. utils.ErrorLog("解析失败:%v", err)
  19681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19682. return
  19683. }
  19684. res.InfRefmsgid = resSix10265.InfRefmsgid
  19685. res.Output = resSix10265.Output
  19686. res.ErrMsg = resSix10265.ErrMsg
  19687. res.Cainfo = resSix10265.Cainfo
  19688. res.WarnMsg = resSix10265.WarnMsg
  19689. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  19690. res.Infcode = infocode
  19691. if infocode == 0 {
  19692. c.ServeSuccessJSON(map[string]interface{}{
  19693. "msg": "上传成功",
  19694. })
  19695. return
  19696. } else {
  19697. c.ServeSuccessJSON(map[string]interface{}{
  19698. "failed_code": -10,
  19699. "msg": res.ErrMsg,
  19700. })
  19701. return
  19702. }
  19703. }
  19704. func (c *HisApiController) Post3506() {
  19705. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19706. data := make(map[string]interface{})
  19707. var struct3501s []models.Struct3501
  19708. var struct3501 models.Struct3501
  19709. struct3501.OrgName = miConfig.OrgName
  19710. struct3501.AccessKey = miConfig.AccessKey
  19711. struct3501.RequestUrl = miConfig.Url
  19712. struct3501.SecretKey = miConfig.SecretKey
  19713. struct3501.ManuDate = "2022-08-15"
  19714. struct3501.FixmedinsBchno = ""
  19715. struct3501.ManuLotnum = ""
  19716. struct3501.RxFlag = "0"
  19717. struct3501.ExpyEnd = "2022-08-15"
  19718. struct3501.Invdate = "2022-08-15"
  19719. struct3501.InvCnt = "20.25"
  19720. struct3501.Memo = ""
  19721. struct3501.MedListCodg = "XB01ABD056B002020200517"
  19722. struct3501.FixmedinsHilistId = miConfig.Code
  19723. struct3501.FixmedinsHilistName = miConfig.OrgName
  19724. struct3501s = append(struct3501s, struct3501)
  19725. data["struct_3501s"] = struct3501s
  19726. client := &http.Client{}
  19727. bytesData, _ := json.Marshal(data)
  19728. var req *http.Request
  19729. if miConfig.MdtrtareaAdmvs == "320921" {
  19730. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19731. } else {
  19732. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19733. }
  19734. resp, _ := client.Do(req)
  19735. defer resp.Body.Close()
  19736. body, ioErr := ioutil.ReadAll(resp.Body)
  19737. if ioErr != nil {
  19738. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19740. return
  19741. }
  19742. var respJSON map[string]interface{}
  19743. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19746. return
  19747. }
  19748. var res ResultSix
  19749. var resSix10265 ResultSix10265 //1101结果
  19750. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19751. result, _ := json.Marshal(respJSON)
  19752. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  19753. utils.ErrorLog("解析失败:%v", err)
  19754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19755. return
  19756. }
  19757. res.InfRefmsgid = resSix10265.InfRefmsgid
  19758. res.Output = resSix10265.Output
  19759. res.ErrMsg = resSix10265.ErrMsg
  19760. res.Cainfo = resSix10265.Cainfo
  19761. res.WarnMsg = resSix10265.WarnMsg
  19762. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  19763. res.Infcode = infocode
  19764. if infocode == 0 {
  19765. c.ServeSuccessJSON(map[string]interface{}{
  19766. "msg": "上传成功",
  19767. })
  19768. return
  19769. } else {
  19770. c.ServeSuccessJSON(map[string]interface{}{
  19771. "failed_code": -10,
  19772. "msg": res.ErrMsg,
  19773. })
  19774. return
  19775. }
  19776. }
  19777. func (c *HisApiController) Post3507() {
  19778. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19779. data := make(map[string]interface{})
  19780. var struct3501s []models.Struct3501
  19781. var struct3501 models.Struct3501
  19782. struct3501.OrgName = miConfig.OrgName
  19783. struct3501.AccessKey = miConfig.AccessKey
  19784. struct3501.RequestUrl = miConfig.Url
  19785. struct3501.SecretKey = miConfig.SecretKey
  19786. struct3501.ManuDate = "2022-08-15"
  19787. struct3501.FixmedinsBchno = ""
  19788. struct3501.ManuLotnum = ""
  19789. struct3501.RxFlag = "0"
  19790. struct3501.ExpyEnd = "2022-08-15"
  19791. struct3501.Invdate = "2022-08-15"
  19792. struct3501.InvCnt = "20.25"
  19793. struct3501.Memo = ""
  19794. struct3501.MedListCodg = "XB01ABD056B002020200517"
  19795. struct3501.FixmedinsHilistId = miConfig.Code
  19796. struct3501.FixmedinsHilistName = miConfig.OrgName
  19797. struct3501s = append(struct3501s, struct3501)
  19798. data["struct_3501s"] = struct3501s
  19799. client := &http.Client{}
  19800. bytesData, _ := json.Marshal(data)
  19801. var req *http.Request
  19802. if miConfig.MdtrtareaAdmvs == "320921" {
  19803. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19804. } else {
  19805. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  19806. }
  19807. resp, _ := client.Do(req)
  19808. defer resp.Body.Close()
  19809. body, ioErr := ioutil.ReadAll(resp.Body)
  19810. if ioErr != nil {
  19811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19813. return
  19814. }
  19815. var respJSON map[string]interface{}
  19816. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19819. return
  19820. }
  19821. var res ResultSix
  19822. var resSix10265 ResultSix10265 //1101结果
  19823. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19824. result, _ := json.Marshal(respJSON)
  19825. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  19826. utils.ErrorLog("解析失败:%v", err)
  19827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19828. return
  19829. }
  19830. res.InfRefmsgid = resSix10265.InfRefmsgid
  19831. res.Output = resSix10265.Output
  19832. res.ErrMsg = resSix10265.ErrMsg
  19833. res.Cainfo = resSix10265.Cainfo
  19834. res.WarnMsg = resSix10265.WarnMsg
  19835. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  19836. res.Infcode = infocode
  19837. if infocode == 0 {
  19838. c.ServeSuccessJSON(map[string]interface{}{
  19839. "msg": "上传成功",
  19840. })
  19841. return
  19842. } else {
  19843. c.ServeSuccessJSON(map[string]interface{}{
  19844. "failed_code": -10,
  19845. "msg": res.ErrMsg,
  19846. })
  19847. return
  19848. }
  19849. }
  19850. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  19851. // WebSocket服务器地址
  19852. serverURL := "ws://127.0.0.1:8899"
  19853. // 解析WebSocket服务器地址
  19854. u, err := url.Parse(serverURL)
  19855. if err != nil {
  19856. }
  19857. // 建立WebSocket连接
  19858. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  19859. if err != nil {
  19860. }
  19861. defer conn.Close()
  19862. input2 := make(map[string]interface{})
  19863. input := make(map[string]interface{})
  19864. inputData := make(map[string]interface{})
  19865. inputData["orgId"] = code
  19866. inputData["businessType"] = "01101"
  19867. inputData["operatorId"] = operator_id
  19868. inputData["operatorName"] = operator_name
  19869. inputData["officeId"] = "001"
  19870. inputData["officeName"] = "血透室"
  19871. inputData["deviceType"] = ""
  19872. input["data"] = inputData
  19873. input["orgId"] = code
  19874. input["transType"] = "ec.query"
  19875. //if md == ""
  19876. if md[:4] == "4403" {
  19877. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  19878. } else if md[:4] == "4401" {
  19879. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  19880. } else {
  19881. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  19882. }
  19883. input2["indata"] = input
  19884. bytesData, _ := json.Marshal(input2)
  19885. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  19886. if err != nil {
  19887. fmt.Println(err)
  19888. }
  19889. // 接收消息
  19890. _, receivedMessage, err := conn.ReadMessage()
  19891. if err != nil {
  19892. fmt.Println(err)
  19893. }
  19894. return "", string(receivedMessage)
  19895. }
  19896. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  19897. // WebSocket服务器地址
  19898. serverURL := "ws://127.0.0.1:8899"
  19899. // 解析WebSocket服务器地址
  19900. u, err := url.Parse(serverURL)
  19901. if err != nil {
  19902. }
  19903. // 建立WebSocket连接
  19904. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  19905. if err != nil {
  19906. }
  19907. defer conn.Close()
  19908. input2 := make(map[string]interface{})
  19909. input := make(map[string]interface{})
  19910. inputData := make(map[string]interface{})
  19911. inputData["orgId"] = code
  19912. inputData["businessType"] = "01301"
  19913. inputData["operatorId"] = operator_id
  19914. inputData["operatorName"] = operator_name
  19915. inputData["officeId"] = "001"
  19916. inputData["officeName"] = "血透室"
  19917. inputData["deviceType"] = ""
  19918. input["data"] = inputData
  19919. input["orgId"] = code
  19920. input["transType"] = "ec.query"
  19921. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  19922. input2["indata"] = input
  19923. bytesData, _ := json.Marshal(input2)
  19924. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  19925. if err != nil {
  19926. fmt.Println(err)
  19927. }
  19928. // 接收消息
  19929. _, receivedMessage, err := conn.ReadMessage()
  19930. if err != nil {
  19931. fmt.Println(err)
  19932. }
  19933. return "", string(receivedMessage)
  19934. }