his_api_controller.go 590KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  79. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  80. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  81. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  82. //beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  83. //beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  84. //beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  85. //beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  86. //beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  87. //beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  88. //beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  89. //
  90. }
  91. func (c *HisApiController) Get2505() {
  92. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  93. 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")
  94. }
  95. //func (c *HisApiController) Get4201A(){
  96. // order_id, _ := c.GetInt64("order_id")
  97. // admin_user_id, _ := c.GetInt64("admin_user_id")
  98. // order, _ := service.GetHisOrderByIDTwo(order_id)
  99. // his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  100. // order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  101. // order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  102. // order_info = append(order_info, order_info_two...)
  103. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  104. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  105. //
  106. // department,_ := service.GetDepartMentDetail(his.Departments)
  107. //
  108. //
  109. //
  110. //
  111. // if order.ID == 0 {
  112. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  113. // return
  114. // }
  115. // var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  116. // for _,items := range order_info{
  117. // var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  118. // fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  119. // fsiOPFLD.MedType = "14"
  120. // fsiOPFLD.BkkpSn = items.OrderNumber
  121. // fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime,0).Format("2006-01-02 15:04:05")
  122. // fsiOPFLD.FixmedinsCode = miConfig.Code
  123. // fsiOPFLD.FixmedinsName = miConfig.OrgName
  124. // fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  125. // fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  126. // fsiOPFLD.MedChrgitmType = "09"
  127. // fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.AdviceName
  128. // fsiOPFLD.BilgDeptCodg = department.Number
  129. // fsiOPFLD.BilgDeptName = department.Name
  130. //
  131. //
  132. //
  133. //
  134. //
  135. //
  136. // }
  137. //
  138. //
  139. //
  140. //
  141. //
  142. //
  143. //}
  144. //func (c *HisApiController) Get4202(){
  145. // order_id, _ := c.GetInt64("order_id")
  146. // admin_user_id, _ := c.GetInt64("admin_user_id")
  147. // order, _ := service.GetHisOrderByIDTwo(order_id)
  148. // his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  149. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  150. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  151. //
  152. // if order.ID == 0 {
  153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  154. // return
  155. // }
  156. //
  157. // var struct4202 models.Struct4202
  158. // struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  159. // struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  160. // struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  161. // struct4202.OwnPayPatnMdtrtD.PsnCertType ="01"
  162. // struct4202.OwnPayPatnMdtrtD.Certno =his.IdCardNo
  163. // struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  164. // struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  165. // struct4202.OwnPayPatnMdtrtD.MedType = "14"
  166. // struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  167. // struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f",order.MedfeeSumamt)
  168. //
  169. //
  170. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  171. // var config []*models.HisXtDiagnoseConfig
  172. // for _, item := range diagnosis_ids {
  173. // id, _ := strconv.ParseInt(item, 10, 64)
  174. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  175. // config = append(config, &diagnosisConfig)
  176. // }
  177. // var tempDiaginfos []models.OwnPayPatnDiagListD
  178. // for index, item := range config {
  179. // if index == 0 {
  180. // var tempDiaginfo models.OwnPayPatnDiagListD
  181. // tempDiaginfo.InoutDiagType = "1"
  182. // tempDiaginfo.DiagCode = item.CountryCode
  183. // tempDiaginfo.DiagName = item.CountryContentName
  184. // tempDiaginfo.DiagType = "1"
  185. // tempDiaginfo.DiagSrtNo = "1"
  186. // tempDiaginfo.MaindiagFlag = "1"
  187. // tempDiaginfo.ValiFlag = "1"
  188. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  189. // } else {
  190. //
  191. // var tempDiaginfo models.OwnPayPatnDiagListD
  192. // tempDiaginfo.DiagCode = item.CountryCode
  193. // tempDiaginfo.DiagName = item.CountryContentName
  194. // tempDiaginfo.DiagType = "2"
  195. // tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1),10)
  196. // tempDiaginfo.MaindiagFlag = "0"
  197. // tempDiaginfo.ValiFlag = "1"
  198. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  199. // }
  200. // }
  201. // struct4202.ODiagListD = tempDiaginfos
  202. // service.Gdyb4202(miConfig.OrgName,curRoles.UserName,miConfig.Code,miConfig.InsuplcAdmdvs,miConfig.MdtrtareaAdmvs,miConfig.SecretKey,struct4202)
  203. //
  204. //
  205. //
  206. //
  207. //}
  208. //func (c *HisApiController) Get4203(){
  209. //
  210. //
  211. //}
  212. //func (c *HisApiController) Get4205(){
  213. //
  214. //
  215. //}
  216. //func (c *HisApiController) Get4207(){
  217. //
  218. //
  219. //}
  220. //func (c *HisApiController) Get4208(){
  221. //
  222. //
  223. //}
  224. //func (c *HisApiController) Get4209(){
  225. //
  226. //
  227. //}
  228. type Result3101 struct {
  229. Infcode string `json:"infcode"`
  230. InfRefmsgid string `json:"inf_refmsgid"`
  231. RefmsgTime string `json:"refmsg_time"`
  232. RespondTime string `json:"respond_time"`
  233. Enctype string `json:"enctype"`
  234. Signtype string `json:"signtype"`
  235. ErrMsg string `json:"err_msg"`
  236. Output struct {
  237. Result []struct {
  238. JudgeResultDetailDtos []struct {
  239. VolaItemType string `json:"vola_item_type"`
  240. MdtrtID string `json:"mdtrt_id"`
  241. JrdID string `json:"jrd_id"`
  242. PatnID string `json:"patn_id"`
  243. RxID string `json:"rx_id"`
  244. VolaAmt interface{} `json:"vola_amt"`
  245. } `json:"judge_result_detail_dtos"`
  246. RuleID string `json:"rule_id"`
  247. VolaEvid string `json:"vola_evid"`
  248. MdtrtID string `json:"mdtrt_id"`
  249. RuleName string `json:"rule_name"`
  250. VolaAmtStas string `json:"vola_amt_stas"`
  251. JrID string `json:"jr_id"`
  252. PatnID string `json:"patn_id"`
  253. SevDeg string `json:"sev_deg"`
  254. VolaAmt float64 `json:"vola_amt"`
  255. VolaBhvrType string `json:"vola_bhvr_type"`
  256. VolaCont string `json:"vola_cont"`
  257. } `json:"result"`
  258. } `json:"output"`
  259. }
  260. func (c *HisApiController) ReadEleToken() {
  261. admin_user_id, _ := c.GetInt64("admin_user_id")
  262. his_patient_id, _ := c.GetInt64("his_patient_id")
  263. adminUser := c.GetAdminUserInfo()
  264. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  265. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  266. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  267. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  268. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  269. if len(tokens) > 0 {
  270. c.ServeSuccessJSON(map[string]interface{}{
  271. "msg": "读取成功",
  272. })
  273. } else {
  274. c.ServeSuccessJSON(map[string]interface{}{
  275. "failed_code": -10,
  276. "msg": "读取失败",
  277. })
  278. }
  279. } else if miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "440305" || miConfig.MdtrtareaAdmvs == "441202" {
  280. if initFlag == 0 {
  281. c.TestGetBasBaseInit()
  282. }
  283. token := c.GetEleBaseInfo()
  284. token = Remove0000(token)
  285. if len(token) > 0 {
  286. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  287. saveLog(result2, requestLog2, "1101", "获取人员信息")
  288. var res ResultTwo
  289. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  290. utils.ErrorLog("解析失败:%v", err)
  291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  292. return
  293. }
  294. if res.Infcode == 0 {
  295. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  296. if err == gorm.ErrRecordNotFound {
  297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  298. return
  299. } else if err != nil {
  300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  301. return
  302. } else {
  303. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  304. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  305. infoStr := string(Iinfos)
  306. idetinfoStr := string(Idetinfos)
  307. psn := &models.HisPsn{
  308. PsnNo: res.Output.Baseinfo.PsnNo,
  309. Age: res.Output.Baseinfo.Age,
  310. PatientId: patient.ID,
  311. Certno: res.Output.Baseinfo.Certno,
  312. Brdy: res.Output.Baseinfo.Brdy,
  313. Gend: res.Output.Baseinfo.Gend,
  314. Naty: res.Output.Baseinfo.Naty,
  315. PsnCertType: res.Output.Baseinfo.PsnCertType,
  316. PsnName: res.Output.Baseinfo.PsnName,
  317. Idetinfo: idetinfoStr,
  318. Insuinfo: infoStr,
  319. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  320. CardInfo: "",
  321. VerifyNumber: token,
  322. }
  323. service.CreateHisPsn(psn)
  324. c.ServeSuccessJSON(map[string]interface{}{
  325. "msg": "读取成功",
  326. })
  327. }
  328. } else {
  329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  330. return
  331. }
  332. } else {
  333. c.ServeSuccessJSON(map[string]interface{}{
  334. "failed_code": -10,
  335. "msg": "读取失败",
  336. })
  337. }
  338. } else if miConfig.MdtrtareaAdmvs == "350500" {
  339. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  340. if len(errMsg) == 0 {
  341. type ELeData struct {
  342. Data struct {
  343. IdNo string `json:"idNo"`
  344. IdType string `json:"idType"`
  345. UserName string `json:"userName"`
  346. EcToken string `json:"ecToken"`
  347. InsuOrg string `json:"insuOrg"`
  348. Gender string `json:"gender"`
  349. Birthday string `json:"birthday"`
  350. Nationality string `json:"nationality"`
  351. Email string `json:"email"`
  352. Extra string `json:"extra"`
  353. } `json:"data"`
  354. Code int `json:"code"`
  355. Message string `json:"message"`
  356. }
  357. var ele ELeData
  358. err := json.Unmarshal([]byte(outPutInfo), &ele)
  359. if err != nil {
  360. utils.ErrorLog("解析失败:%v", err)
  361. }
  362. token := ele.Data.EcToken
  363. if len(token) > 0 {
  364. psn := &models.HisPsn{
  365. PsnNo: his.PsnNo,
  366. Age: 0,
  367. PatientId: his.PatientId,
  368. Certno: his.Certno,
  369. Brdy: his.Brdy,
  370. Gend: his.Gend,
  371. Naty: his.Naty,
  372. PsnCertType: his.PsnCertType,
  373. PsnName: his.PsnName,
  374. Idetinfo: his.Idetinfo,
  375. Insuinfo: his.Iinfo,
  376. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  377. CardInfo: outPutInfo,
  378. VerifyNumber: token,
  379. }
  380. service.CreateHisPsn(psn)
  381. }
  382. if len(token) > 0 {
  383. c.ServeSuccessJSON(map[string]interface{}{
  384. "msg": "读取成功",
  385. })
  386. } else {
  387. c.ServeSuccessJSON(map[string]interface{}{
  388. "failed_code": -10,
  389. "msg": "读取失败",
  390. })
  391. }
  392. }
  393. } else if miConfig.MdtrtareaAdmvs == "360399" {
  394. if initFlag == 0 {
  395. c.TestGetJiangXiBasBaseInit()
  396. }
  397. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  398. type ELeData struct {
  399. Data struct {
  400. IdNo string `json:"idNo"`
  401. IdType string `json:"idType"`
  402. UserName string `json:"userName"`
  403. EcToken string `json:"ecToken"`
  404. InsuOrg string `json:"insuOrg"`
  405. Gender string `json:"gender"`
  406. Birthday string `json:"birthday"`
  407. Nationality string `json:"nationality"`
  408. Email string `json:"email"`
  409. Extra string `json:"extra"`
  410. } `json:"data"`
  411. Code int `json:"code"`
  412. Message string `json:"message"`
  413. }
  414. var ele ELeData
  415. err := json.Unmarshal([]byte(json_result), &ele)
  416. if err != nil {
  417. utils.ErrorLog("解析失败:%v", err)
  418. }
  419. token := ele.Data.EcToken
  420. token = Remove0000(token)
  421. fmt.Println(ele.Data.UserName)
  422. 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)
  423. saveLog(result2, requestLog2, "1101", "获取人员信息")
  424. var res ResultTwo
  425. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  426. utils.ErrorLog("解析失败:%v", err)
  427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  428. return
  429. }
  430. if res.Infcode == 0 {
  431. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  432. if err == gorm.ErrRecordNotFound {
  433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  434. return
  435. } else if err != nil {
  436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  437. return
  438. } else {
  439. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  440. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  441. infoStr := string(Iinfos)
  442. idetinfoStr := string(Idetinfos)
  443. psn := &models.HisPsn{
  444. PsnNo: res.Output.Baseinfo.PsnNo,
  445. Age: res.Output.Baseinfo.Age,
  446. PatientId: patient.ID,
  447. Certno: res.Output.Baseinfo.Certno,
  448. Brdy: res.Output.Baseinfo.Brdy,
  449. Gend: res.Output.Baseinfo.Gend,
  450. Naty: res.Output.Baseinfo.Naty,
  451. PsnCertType: res.Output.Baseinfo.PsnCertType,
  452. PsnName: res.Output.Baseinfo.PsnName,
  453. Idetinfo: idetinfoStr,
  454. Insuinfo: infoStr,
  455. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  456. CardInfo: "",
  457. VerifyNumber: token,
  458. }
  459. service.CreateHisPsn(psn)
  460. c.ServeSuccessJSON(map[string]interface{}{
  461. "patient": patient,
  462. "number": token,
  463. })
  464. }
  465. } else {
  466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  467. return
  468. }
  469. } else if miConfig.MdtrtareaAdmvs == "430800" {
  470. if initFlag == 0 {
  471. c.TestGetJiangXiBasBaseInit()
  472. }
  473. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  474. type ELeData struct {
  475. Data struct {
  476. IdNo string `json:"idNo"`
  477. IdType string `json:"idType"`
  478. UserName string `json:"userName"`
  479. EcToken string `json:"ecToken"`
  480. InsuOrg string `json:"insuOrg"`
  481. Gender string `json:"gender"`
  482. Birthday string `json:"birthday"`
  483. Nationality string `json:"nationality"`
  484. Email string `json:"email"`
  485. Extra string `json:"extra"`
  486. } `json:"data"`
  487. Code int `json:"code"`
  488. Message string `json:"message"`
  489. }
  490. var ele ELeData
  491. err := json.Unmarshal([]byte(json_result), &ele)
  492. if err != nil {
  493. utils.ErrorLog("解析失败:%v", err)
  494. }
  495. token := ele.Data.EcToken
  496. token = Remove0000(token)
  497. fmt.Println(ele.Data.UserName)
  498. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  499. saveLog(result2, requestLog2, "1101", "获取人员信息")
  500. var res ResultTwo
  501. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  502. utils.ErrorLog("解析失败:%v", err)
  503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  504. return
  505. }
  506. if res.Infcode == 0 {
  507. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  508. if err == gorm.ErrRecordNotFound {
  509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  510. return
  511. } else if err != nil {
  512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  513. return
  514. } else {
  515. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  516. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  517. infoStr := string(Iinfos)
  518. idetinfoStr := string(Idetinfos)
  519. psn := &models.HisPsn{
  520. PsnNo: res.Output.Baseinfo.PsnNo,
  521. Age: res.Output.Baseinfo.Age,
  522. PatientId: patient.ID,
  523. Certno: res.Output.Baseinfo.Certno,
  524. Brdy: res.Output.Baseinfo.Brdy,
  525. Gend: res.Output.Baseinfo.Gend,
  526. Naty: res.Output.Baseinfo.Naty,
  527. PsnCertType: res.Output.Baseinfo.PsnCertType,
  528. PsnName: res.Output.Baseinfo.PsnName,
  529. Idetinfo: idetinfoStr,
  530. Insuinfo: infoStr,
  531. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  532. CardInfo: "",
  533. VerifyNumber: token,
  534. }
  535. service.CreateHisPsn(psn)
  536. c.ServeSuccessJSON(map[string]interface{}{
  537. "patient": patient,
  538. "number": token,
  539. })
  540. }
  541. } else {
  542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  543. return
  544. }
  545. }
  546. }
  547. func (c *HisApiController) Get9001() {
  548. adminUser := c.GetAdminUserInfo()
  549. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  550. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  551. if miConfig.MdtrtareaAdmvs == "350500" {
  552. service.GetFjAuthorizationInfo(miConfig.Code)
  553. } else if miConfig.MdtrtareaAdmvs == "131023" {
  554. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  555. var dat map[string]interface{}
  556. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  557. fmt.Println(dat)
  558. } else {
  559. fmt.Println(err)
  560. }
  561. userJSONBytes, _ := json.Marshal(dat)
  562. var res models.Result9001
  563. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  564. utils.ErrorLog("解析失败:%v", err)
  565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  566. return
  567. }
  568. } else {
  569. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  570. var dat map[string]interface{}
  571. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  572. fmt.Println(dat)
  573. } else {
  574. fmt.Println(err)
  575. }
  576. userJSONBytes, _ := json.Marshal(dat)
  577. var res models.Result9001
  578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  579. utils.ErrorLog("解析失败:%v", err)
  580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  581. return
  582. }
  583. }
  584. }
  585. 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) {
  586. var res Result3101
  587. adminUser := c.GetAdminUserInfo()
  588. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  589. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  590. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  591. //record_time := c.GetString("record_time")
  592. //trig_scen := c.GetString("trig_scen")
  593. timeLayout := "2006-01-02"
  594. loc, _ := time.LoadLocation("Local")
  595. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  596. if err != nil {
  597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  598. return res
  599. }
  600. recordDateTime := theTime.Unix()
  601. var patientPrescription models.HisPrescriptionInfo
  602. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  603. //if patientPrescription.ID == 0 {
  604. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  605. //}
  606. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  607. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  608. //
  609. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  610. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  611. var pp models.PublicParams
  612. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  613. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  614. pp.FixmedinsName = miConfig.OrgName
  615. pp.FixmedinsCode = miConfig.Code
  616. pp.RequestUrl = miConfig.Url
  617. pp.Cainfo = miConfig.Cainfo
  618. pp.SecretKey = miConfig.SecretKey
  619. pp.AccessKey = miConfig.AccessKey
  620. pp.OpterName = roles.UserName
  621. var config []*models.HisXtDiagnoseConfig
  622. for _, item := range diagnosis_ids {
  623. id, _ := strconv.ParseInt(item, 10, 64)
  624. diagnosisConfig, _ := service.FindDiagnoseById(id)
  625. config = append(config, &diagnosisConfig)
  626. }
  627. var pd models.PatientDtos
  628. pd.PatnID = his.PsnNo
  629. pd.PatnName = his.Name
  630. pd.Gend = his.Gend
  631. pd.Brdy = his.Brdy
  632. pd.Poolarea = miConfig.MdtrtareaAdmvs
  633. pd.CurrMdtrtID = his.Number
  634. var fed models.FsiEncounterDtos
  635. fed.MdtrtID = his.Number
  636. fed.MedinsID = miConfig.Code
  637. fed.MedinsName = miConfig.OrgName
  638. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  639. fed.MedMdtrtType = "1"
  640. fed.MedinsType = "1"
  641. fed.MedinsLv = "11"
  642. tm := time.Unix(his.RecordDate, 0)
  643. s_tm := tm.Format("2006-01-02 15:04:05")
  644. fed.AdmDate = s_tm
  645. fed.DscgDate = s_tm
  646. fed.DscgMainDiseCodg = config[0].CountryCode
  647. fed.DscgMainDiseName = config[0].CountryContentName
  648. //诊断信息
  649. var fdds []*models.FsiDiagnoseDtos
  650. for index, item := range config {
  651. if index == 0 {
  652. var fdd models.FsiDiagnoseDtos
  653. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  654. fdd.InoutDiseType = "1"
  655. fdd.MaindiseFlag = "1"
  656. fdd.DiseDate = s_tm
  657. fdd.DiasSrtNo = "1"
  658. fdd.DiseName = item.CountryContentName
  659. fdd.DiseCodg = item.CountryCode
  660. fdds = append(fdds, &fdd)
  661. } else {
  662. var fdd models.FsiDiagnoseDtos
  663. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  664. fdd.InoutDiseType = "1"
  665. fdd.MaindiseFlag = "1"
  666. fdd.DiseDate = s_tm
  667. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  668. fdd.DiseName = item.CountryContentName
  669. fdd.DiseCodg = item.CountryCode
  670. fdds = append(fdds, &fdd)
  671. }
  672. }
  673. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  674. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  675. fed.AdmDeptName = department.Name
  676. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  677. fed.DscgDeptName = department.Name
  678. fed.MedMdtrtType = "1"
  679. fed.MedType = "11"
  680. //if his.Insutype == "390" {
  681. // fed.MedType = "1402"
  682. //} else {
  683. // fed.MedType = "9933"
  684. //}
  685. var orders []*models.FsiOrderDtos
  686. if trig_scen == "2" {
  687. //处方医嘱信息
  688. for _, item := range prescriptions {
  689. for _, subItem := range item.HisDoctorAdviceInfo {
  690. var order models.FsiOrderDtos
  691. order.RxID = strconv.FormatInt(item.ID, 10)
  692. order.Rxno = strconv.FormatInt(item.ID, 10)
  693. order.LongDrordFlag = "0"
  694. order.HilistType = "1"
  695. order.ChrgType = "1"
  696. order.DrordBhvr = "-"
  697. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  698. order.HosplistName = subItem.BaseDrugLib.DrugName
  699. order.HilistLv = "1"
  700. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  701. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  702. order.HosplistName = subItem.BaseDrugLib.DrugName
  703. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  704. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  705. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  706. order.OwnpayAmt = ""
  707. order.SelfpayAmt = ""
  708. order.Spec = ""
  709. order.SpecUnt = ""
  710. order.DrordBegnDate = s_tm
  711. order.DrordStopDate = ""
  712. order.DrordDrCodg = "1"
  713. order.DrordDeptName = department.Name
  714. order.DrordDrCodg = "1"
  715. order.DrordDrName = doctor_info.UserName
  716. order.DrordDrProfttl = ""
  717. order.CurrDrordFlag = "1"
  718. orders = append(orders, &order)
  719. }
  720. for _, subItem := range item.HisPrescriptionProject {
  721. if subItem.Type == 2 {
  722. var order models.FsiOrderDtos
  723. order.RxID = strconv.FormatInt(item.ID, 10)
  724. order.Rxno = strconv.FormatInt(item.ID, 10)
  725. order.LongDrordFlag = "0"
  726. order.HilistType = "1"
  727. order.ChrgType = "1"
  728. order.DrordBhvr = "-"
  729. order.HilistCode = subItem.HisProject.MedicalCode
  730. order.HosplistName = subItem.HisProject.ProjectName
  731. order.HilistLv = "1"
  732. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  733. order.HosplistCode = subItem.HisProject.MedicalCode
  734. order.HosplistName = subItem.HisProject.ProjectName
  735. order.Cnt = subItem.Count
  736. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  737. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  738. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  739. order.OwnpayAmt = ""
  740. order.SelfpayAmt = ""
  741. order.Spec = ""
  742. order.SpecUnt = ""
  743. order.DrordBegnDate = s_tm
  744. order.DrordStopDate = ""
  745. order.DrordDrCodg = "1"
  746. order.DrordDeptName = department.Name
  747. order.DrordDrCodg = "1"
  748. order.DrordDrName = doctor_info.UserName
  749. order.DrordDrProfttl = ""
  750. order.CurrDrordFlag = "1"
  751. orders = append(orders, &order)
  752. }
  753. if subItem.Type == 3 {
  754. var order models.FsiOrderDtos
  755. order.RxID = strconv.FormatInt(item.ID, 10)
  756. order.Rxno = strconv.FormatInt(item.ID, 10)
  757. order.LongDrordFlag = "0"
  758. order.HilistType = "1"
  759. order.ChrgType = "1"
  760. order.DrordBhvr = "-"
  761. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  762. order.HosplistName = subItem.GoodInfo.GoodName
  763. order.HilistLv = "1"
  764. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  765. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  766. order.HosplistName = subItem.GoodInfo.GoodName
  767. order.Cnt = subItem.Count
  768. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  769. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  770. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  771. order.OwnpayAmt = ""
  772. order.SelfpayAmt = ""
  773. order.Spec = ""
  774. order.SpecUnt = ""
  775. order.DrordBegnDate = s_tm
  776. order.DrordStopDate = ""
  777. order.DrordDrCodg = "1"
  778. order.DrordDeptName = department.Name
  779. order.DrordDrCodg = "1"
  780. order.DrordDrName = doctor_info.UserName
  781. order.DrordDrProfttl = ""
  782. order.CurrDrordFlag = "1"
  783. orders = append(orders, &order)
  784. }
  785. }
  786. }
  787. //处方医嘱信息
  788. }
  789. fed.MatnStas = "0"
  790. fed.MedfeeSumamt = "0"
  791. fed.OwnpayAmt = "0"
  792. fed.SelfpayAmt = "0"
  793. fed.AcctPayamt = "0"
  794. fed.MaAmt = "0"
  795. fed.HifpPayamt = "0"
  796. fed.SetlTotlnum = "1"
  797. fed.Insutype = his.Insutype
  798. fed.ReimFlag = "0"
  799. fed.OutSetlFlag = "0"
  800. var fopd []*models.FsiOperationDtosData
  801. data := make(map[string]interface{})
  802. data["fed"] = fed
  803. data["fdd"] = fdds
  804. data["fod"] = orders
  805. data["pd"] = pd
  806. data["pp"] = pp
  807. data["fopd"] = fopd
  808. data["trig_scen"] = trig_scen
  809. fmt.Println(data)
  810. fmt.Println(fed)
  811. fmt.Println(fdds)
  812. fmt.Println(orders)
  813. fmt.Println(pd)
  814. fmt.Println(pp)
  815. fmt.Println(fopd)
  816. client := &http.Client{}
  817. bytesData, _ := json.Marshal(data)
  818. var req *http.Request
  819. if miConfig.MdtrtareaAdmvs == "320921" {
  820. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  821. } else {
  822. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  823. }
  824. resp, _ := client.Do(req)
  825. defer resp.Body.Close()
  826. body, ioErr := ioutil.ReadAll(resp.Body)
  827. if ioErr != nil {
  828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  830. return res
  831. }
  832. var respJSON map[string]interface{}
  833. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  836. return res
  837. }
  838. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  839. fmt.Println(respJSON)
  840. result, _ := json.Marshal(respJSON)
  841. fmt.Println(result)
  842. if err := json.Unmarshal([]byte(result), &res); err != nil {
  843. utils.ErrorLog("解析失败:%v", err)
  844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  845. return res
  846. }
  847. return res
  848. }
  849. 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) {
  850. adminUser := c.GetAdminUserInfo()
  851. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  852. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  853. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  854. //record_time := c.GetString("record_time")
  855. //trig_scen := c.GetString("trig_scen")
  856. timeLayout := "2006-01-02"
  857. loc, _ := time.LoadLocation("Local")
  858. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  859. if err != nil {
  860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  861. return res
  862. }
  863. recordDateTime := theTime.Unix()
  864. var patientPrescription models.HisPrescriptionInfo
  865. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  866. if patientPrescription.ID == 0 {
  867. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  868. }
  869. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  870. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  871. //
  872. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  873. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  874. var pp models.PublicParams
  875. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  876. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  877. pp.FixmedinsName = miConfig.OrgName
  878. pp.FixmedinsCode = miConfig.Code
  879. pp.RequestUrl = miConfig.Url
  880. pp.Cainfo = miConfig.Cainfo
  881. pp.SecretKey = miConfig.SecretKey
  882. pp.AccessKey = miConfig.AccessKey
  883. pp.OpterName = roles.UserName
  884. var config []*models.HisXtDiagnoseConfig
  885. for _, item := range diagnosis_ids {
  886. id, _ := strconv.ParseInt(item, 10, 64)
  887. diagnosisConfig, _ := service.FindDiagnoseById(id)
  888. config = append(config, &diagnosisConfig)
  889. }
  890. var pd models.PatientDtos
  891. pd.PatnID = his.PsnNo
  892. pd.PatnName = his.Name
  893. pd.Gend = his.Gend
  894. pd.Brdy = his.Brdy
  895. pd.Poolarea = his.InsuplcAdmdvs
  896. pd.CurrMdtrtID = his.Number
  897. var fed models.FsiEncounterDtos
  898. fed.MdtrtID = his.Number
  899. fed.MedinsID = miConfig.Code
  900. fed.MedinsName = miConfig.OrgName
  901. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  902. fed.MedMdtrtType = "1"
  903. fed.MedinsType = "1"
  904. fed.MedinsLv = "11"
  905. tm := time.Unix(his.RecordDate, 0)
  906. s_tm := tm.Format("2006-01-02 15:04:05")
  907. fed.AdmDate = s_tm
  908. fed.DscgDate = s_tm
  909. fed.DscgMainDiseCodg = config[0].CountryCode
  910. fed.DscgMainDiseName = config[0].CountryContentName
  911. //诊断信息
  912. var fdds []*models.FsiDiagnoseDtos
  913. for index, item := range config {
  914. if index == 0 {
  915. var fdd models.FsiDiagnoseDtos
  916. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  917. fdd.InoutDiseType = "1"
  918. fdd.MaindiseFlag = "1"
  919. fdd.DiseDate = s_tm
  920. fdd.DiasSrtNo = "1"
  921. fdd.DiseName = item.CountryContentName
  922. fdd.DiseCodg = item.CountryCode
  923. fdds = append(fdds, &fdd)
  924. } else {
  925. var fdd models.FsiDiagnoseDtos
  926. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  927. fdd.InoutDiseType = "1"
  928. fdd.MaindiseFlag = "1"
  929. fdd.DiseDate = s_tm
  930. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  931. fdd.DiseName = item.CountryContentName
  932. fdd.DiseCodg = item.CountryCode
  933. fdds = append(fdds, &fdd)
  934. }
  935. }
  936. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  937. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  938. fed.AdmDeptName = department.Name
  939. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  940. fed.DscgDeptName = department.Name
  941. fed.MedMdtrtType = "1"
  942. fed.MedType = "11"
  943. //if his.Insutype == "390" {
  944. // fed.MedType = "1402"
  945. //} else {
  946. // fed.MedType = "9933"
  947. //}
  948. var orders []*models.FsiOrderDtos
  949. if trig_scen == "2" {
  950. //处方医嘱信息
  951. for _, item := range prescriptions {
  952. for _, subItem := range item.HisDoctorAdviceInfo {
  953. var order models.FsiOrderDtos
  954. order.RxID = strconv.FormatInt(item.ID, 10)
  955. order.Rxno = strconv.FormatInt(item.ID, 10)
  956. order.LongDrordFlag = "0"
  957. order.HilistType = "1"
  958. order.ChrgType = "1"
  959. order.DrordBhvr = "-"
  960. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  961. order.HosplistName = subItem.BaseDrugLib.DrugName
  962. order.HilistLv = "1"
  963. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  964. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  965. order.HosplistName = subItem.BaseDrugLib.DrugName
  966. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  967. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  968. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  969. order.OwnpayAmt = ""
  970. order.SelfpayAmt = ""
  971. order.Spec = ""
  972. order.SpecUnt = ""
  973. order.DrordBegnDate = s_tm
  974. order.DrordStopDate = ""
  975. order.DrordDrCodg = "1"
  976. order.DrordDeptName = department.Name
  977. order.DrordDrCodg = "1"
  978. order.DrordDrName = doctor_info.UserName
  979. order.DrordDrProfttl = ""
  980. order.CurrDrordFlag = "1"
  981. orders = append(orders, &order)
  982. }
  983. for _, subItem := range item.HisPrescriptionProject {
  984. if subItem.Type == 2 {
  985. var order models.FsiOrderDtos
  986. order.RxID = strconv.FormatInt(item.ID, 10)
  987. order.Rxno = strconv.FormatInt(item.ID, 10)
  988. order.LongDrordFlag = "0"
  989. order.HilistType = "1"
  990. order.ChrgType = "1"
  991. order.DrordBhvr = "-"
  992. order.HilistCode = subItem.HisProject.MedicalCode
  993. order.HosplistName = subItem.HisProject.ProjectName
  994. order.HilistLv = "1"
  995. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  996. order.HosplistCode = subItem.HisProject.MedicalCode
  997. order.HosplistName = subItem.HisProject.ProjectName
  998. order.Cnt = subItem.Count
  999. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1000. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1001. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1002. order.OwnpayAmt = ""
  1003. order.SelfpayAmt = ""
  1004. order.Spec = ""
  1005. order.SpecUnt = ""
  1006. order.DrordBegnDate = s_tm
  1007. order.DrordStopDate = ""
  1008. order.DrordDrCodg = "1"
  1009. order.DrordDeptName = department.Name
  1010. order.DrordDrCodg = "1"
  1011. order.DrordDrName = doctor_info.UserName
  1012. order.DrordDrProfttl = ""
  1013. order.CurrDrordFlag = "1"
  1014. orders = append(orders, &order)
  1015. }
  1016. if subItem.Type == 3 {
  1017. var order models.FsiOrderDtos
  1018. order.RxID = strconv.FormatInt(item.ID, 10)
  1019. order.Rxno = strconv.FormatInt(item.ID, 10)
  1020. order.LongDrordFlag = "0"
  1021. order.HilistType = "1"
  1022. order.ChrgType = "1"
  1023. order.DrordBhvr = "-"
  1024. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1025. order.HosplistName = subItem.GoodInfo.GoodName
  1026. order.HilistLv = "1"
  1027. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1028. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1029. order.HosplistName = subItem.GoodInfo.GoodName
  1030. order.Cnt = subItem.Count
  1031. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1032. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1033. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1034. order.OwnpayAmt = ""
  1035. order.SelfpayAmt = ""
  1036. order.Spec = ""
  1037. order.SpecUnt = ""
  1038. order.DrordBegnDate = s_tm
  1039. order.DrordStopDate = ""
  1040. order.DrordDrCodg = "1"
  1041. order.DrordDeptName = department.Name
  1042. order.DrordDrCodg = "1"
  1043. order.DrordDrName = doctor_info.UserName
  1044. order.DrordDrProfttl = ""
  1045. order.CurrDrordFlag = "1"
  1046. orders = append(orders, &order)
  1047. }
  1048. }
  1049. }
  1050. //处方医嘱信息
  1051. }
  1052. fed.MatnStas = "0"
  1053. fed.MedfeeSumamt = "0"
  1054. fed.OwnpayAmt = "0"
  1055. fed.SelfpayAmt = "0"
  1056. fed.AcctPayamt = "0"
  1057. fed.MaAmt = "0"
  1058. fed.HifpPayamt = "0"
  1059. fed.SetlTotlnum = "1"
  1060. fed.Insutype = his.Insutype
  1061. fed.ReimFlag = "0"
  1062. fed.OutSetlFlag = "0"
  1063. var fopd []*models.FsiOperationDtosData
  1064. data := make(map[string]interface{})
  1065. data["fed"] = fed
  1066. data["fdd"] = fdds
  1067. data["fod"] = orders
  1068. data["pd"] = pd
  1069. data["pp"] = pp
  1070. data["fopd"] = fopd
  1071. data["trig_scen"] = trig_scen
  1072. fmt.Println(data)
  1073. fmt.Println(fed)
  1074. fmt.Println(fdds)
  1075. fmt.Println(orders)
  1076. fmt.Println(pd)
  1077. fmt.Println(pp)
  1078. fmt.Println(fopd)
  1079. client := &http.Client{}
  1080. bytesData, _ := json.Marshal(data)
  1081. var req *http.Request
  1082. if miConfig.MdtrtareaAdmvs == "320921" {
  1083. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1084. } else {
  1085. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  1086. }
  1087. resp, _ := client.Do(req)
  1088. defer resp.Body.Close()
  1089. body, ioErr := ioutil.ReadAll(resp.Body)
  1090. if ioErr != nil {
  1091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1093. return res
  1094. }
  1095. var respJSON map[string]interface{}
  1096. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1099. return res
  1100. }
  1101. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1102. result, _ := json.Marshal(respJSON)
  1103. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1104. utils.ErrorLog("解析失败:%v", err)
  1105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1106. return res
  1107. }
  1108. return res
  1109. }
  1110. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  1111. ////patient_id, _ := c.GetInt64("patient_id")
  1112. //order_id, _ := c.GetInt64("order_id")
  1113. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  1114. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  1115. //trig_scen := c.GetString("trig_scen")
  1116. adminUser := c.GetAdminUserInfo()
  1117. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1118. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1119. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1120. record_time := c.GetString("record_time")
  1121. order, _ := service.GetHisOrderByID(order_id)
  1122. timeLayout := "2006-01-02"
  1123. loc, _ := time.LoadLocation("Local")
  1124. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1125. if err != nil {
  1126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1127. return
  1128. }
  1129. recordDateTime := theTime.Unix()
  1130. var patientPrescription models.HisPrescriptionInfo
  1131. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1132. if patientPrescription.ID == 0 {
  1133. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1134. }
  1135. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1136. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1137. //
  1138. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1139. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1140. var pp models.PublicParams
  1141. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1142. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1143. pp.FixmedinsName = miConfig.OrgName
  1144. pp.FixmedinsCode = miConfig.Code
  1145. pp.RequestUrl = miConfig.Url
  1146. pp.Cainfo = miConfig.Cainfo
  1147. pp.SecretKey = miConfig.SecretKey
  1148. pp.AccessKey = miConfig.AccessKey
  1149. pp.OpterName = roles.UserName
  1150. var config []*models.HisXtDiagnoseConfig
  1151. for _, item := range diagnosis_ids {
  1152. id, _ := strconv.ParseInt(item, 10, 64)
  1153. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1154. config = append(config, &diagnosisConfig)
  1155. }
  1156. var pd models.PatientDtos
  1157. pd.PatnID = his.PsnNo
  1158. pd.PatnName = his.Name
  1159. pd.Gend = his.Gend
  1160. pd.Brdy = his.Brdy
  1161. pd.Poolarea = his.InsuplcAdmdvs
  1162. pd.CurrMdtrtID = his.Number
  1163. var fed models.FsiEncounterDtos
  1164. fed.MdtrtID = his.Number
  1165. fed.MedinsID = miConfig.Code
  1166. fed.MedinsName = miConfig.OrgName
  1167. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1168. fed.MedMdtrtType = "1"
  1169. fed.MedinsType = "1"
  1170. fed.MedinsLv = "11"
  1171. tm := time.Unix(his.RecordDate, 0)
  1172. s_tm := tm.Format("2006-01-02 15:04:05")
  1173. fed.AdmDate = s_tm
  1174. fed.DscgDate = s_tm
  1175. fed.DscgMainDiseCodg = config[0].CountryCode
  1176. fed.DscgMainDiseName = config[0].CountryContentName
  1177. //诊断信息
  1178. var fdds []*models.FsiDiagnoseDtos
  1179. for index, item := range config {
  1180. if index == 0 {
  1181. var fdd models.FsiDiagnoseDtos
  1182. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1183. fdd.InoutDiseType = "1"
  1184. fdd.MaindiseFlag = "1"
  1185. fdd.DiseDate = s_tm
  1186. fdd.DiasSrtNo = "1"
  1187. fdd.DiseName = item.CountryContentName
  1188. fdd.DiseCodg = item.CountryCode
  1189. fdds = append(fdds, &fdd)
  1190. } else {
  1191. var fdd models.FsiDiagnoseDtos
  1192. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1193. fdd.InoutDiseType = "1"
  1194. fdd.MaindiseFlag = "1"
  1195. fdd.DiseDate = s_tm
  1196. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1197. fdd.DiseName = item.CountryContentName
  1198. fdd.DiseCodg = item.CountryCode
  1199. fdds = append(fdds, &fdd)
  1200. }
  1201. }
  1202. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1203. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1204. fed.AdmDeptName = department.Name
  1205. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1206. fed.DscgDeptName = department.Name
  1207. fed.MedType = order.MedType
  1208. //处方医嘱信息
  1209. var orders []*models.FsiOrderDtos
  1210. //for _, item := range prescriptions {
  1211. // for _, subItem := range item.HisDoctorAdviceInfo {
  1212. // var order models.FsiOrderDtos
  1213. // order.RxID = strconv.FormatInt(item.ID, 10)
  1214. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1215. // order.LongDrordFlag = "0"
  1216. // order.HilistType = "1"
  1217. // order.ChrgType = "1"
  1218. // order.DrordBhvr = "-"
  1219. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1220. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1221. // order.HilistLv = "1"
  1222. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1223. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1224. // order.HosplistName = subItem.BaseDrugLib.DrugName
  1225. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  1226. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1227. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  1228. // order.OwnpayAmt = ""
  1229. // order.SelfpayAmt = ""
  1230. // order.Spec = ""
  1231. // order.SpecUnt = ""
  1232. // order.DrordBegnDate = s_tm
  1233. // order.DrordStopDate = ""
  1234. // order.DrordDrCodg = "1"
  1235. // order.DrordDeptName = department.Name
  1236. // order.DrordDrCodg = "1"
  1237. // order.DrordDrName = doctor_info.UserName
  1238. // order.DrordDrProfttl = ""
  1239. // order.CurrDrordFlag = "1"
  1240. // orders = append(orders, &order)
  1241. // }
  1242. // for _, subItem := range item.HisPrescriptionProject {
  1243. // if subItem.Type == 2 {
  1244. // var order models.FsiOrderDtos
  1245. // order.RxID = strconv.FormatInt(item.ID, 10)
  1246. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1247. // order.LongDrordFlag = "0"
  1248. // order.HilistType = "1"
  1249. // order.ChrgType = "1"
  1250. // order.DrordBhvr = "-"
  1251. // order.HilistCode = subItem.HisProject.MedicalCode
  1252. // order.HosplistName = subItem.HisProject.ProjectName
  1253. // order.HilistLv = "1"
  1254. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1255. // order.HosplistCode = subItem.HisProject.MedicalCode
  1256. // order.HosplistName = subItem.HisProject.ProjectName
  1257. // order.Cnt = subItem.Count
  1258. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1259. //
  1260. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1261. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1262. // order.OwnpayAmt = ""
  1263. // order.SelfpayAmt = ""
  1264. // order.Spec = ""
  1265. // order.SpecUnt = ""
  1266. // order.DrordBegnDate = s_tm
  1267. // order.DrordStopDate = ""
  1268. // order.DrordDrCodg = "1"
  1269. // order.DrordDeptName = department.Name
  1270. // order.DrordDrCodg = "1"
  1271. // order.DrordDrName = doctor_info.UserName
  1272. // order.DrordDrProfttl = ""
  1273. // order.CurrDrordFlag = "1"
  1274. // orders = append(orders, &order)
  1275. //
  1276. // }
  1277. // if subItem.Type == 3 {
  1278. //
  1279. // var order models.FsiOrderDtos
  1280. // order.RxID = strconv.FormatInt(item.ID, 10)
  1281. // order.Rxno = strconv.FormatInt(item.ID, 10)
  1282. // order.LongDrordFlag = "0"
  1283. // order.HilistType = "1"
  1284. // order.ChrgType = "1"
  1285. // order.DrordBhvr = "-"
  1286. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1287. // order.HosplistName = subItem.GoodInfo.GoodName
  1288. // order.HilistLv = "1"
  1289. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1290. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1291. // order.HosplistName = subItem.GoodInfo.GoodName
  1292. // order.Cnt = subItem.Count
  1293. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1294. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  1295. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  1296. // order.OwnpayAmt = ""
  1297. // order.SelfpayAmt = ""
  1298. // order.Spec = ""
  1299. // order.SpecUnt = ""
  1300. // order.DrordBegnDate = s_tm
  1301. // order.DrordStopDate = ""
  1302. // order.DrordDrCodg = "1"
  1303. // order.DrordDeptName = department.Name
  1304. // order.DrordDrCodg = "1"
  1305. // order.DrordDrName = doctor_info.UserName
  1306. // order.DrordDrProfttl = ""
  1307. // order.CurrDrordFlag = "1"
  1308. // orders = append(orders, &order)
  1309. //
  1310. // }
  1311. // }
  1312. //}
  1313. for _, item := range prescriptions {
  1314. for _, subItem := range item.HisDoctorAdviceInfo {
  1315. var order models.FsiOrderDtos
  1316. order.RxID = strconv.FormatInt(item.ID, 10)
  1317. order.Rxno = strconv.FormatInt(item.ID, 10)
  1318. order.LongDrordFlag = "0"
  1319. order.HilistType = "1"
  1320. order.ChrgType = "1"
  1321. order.DrordBhvr = "-"
  1322. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1323. order.HosplistName = subItem.BaseDrugLib.DrugName
  1324. order.HilistLv = "1"
  1325. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1326. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1327. order.HosplistName = subItem.BaseDrugLib.DrugName
  1328. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1329. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1330. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1331. order.OwnpayAmt = ""
  1332. order.SelfpayAmt = ""
  1333. order.Spec = ""
  1334. order.SpecUnt = ""
  1335. order.DrordBegnDate = s_tm
  1336. order.DrordStopDate = ""
  1337. order.DrordDrCodg = "1"
  1338. order.DrordDeptName = department.Name
  1339. order.DrordDrCodg = "1"
  1340. order.DrordDrName = doctor_info.UserName
  1341. order.DrordDrProfttl = ""
  1342. order.CurrDrordFlag = "1"
  1343. orders = append(orders, &order)
  1344. }
  1345. for _, subItem := range item.HisPrescriptionProject {
  1346. if subItem.Type == 2 {
  1347. var order models.FsiOrderDtos
  1348. order.RxID = strconv.FormatInt(item.ID, 10)
  1349. order.Rxno = strconv.FormatInt(item.ID, 10)
  1350. order.LongDrordFlag = "0"
  1351. order.HilistType = "1"
  1352. order.ChrgType = "1"
  1353. order.DrordBhvr = "-"
  1354. order.HilistCode = subItem.HisProject.MedicalCode
  1355. order.HosplistName = subItem.HisProject.ProjectName
  1356. order.HilistLv = "1"
  1357. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1358. order.HosplistCode = subItem.HisProject.MedicalCode
  1359. order.HosplistName = subItem.HisProject.ProjectName
  1360. order.Cnt = subItem.Count
  1361. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1362. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1363. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1364. order.OwnpayAmt = ""
  1365. order.SelfpayAmt = ""
  1366. order.Spec = ""
  1367. order.SpecUnt = ""
  1368. order.DrordBegnDate = s_tm
  1369. order.DrordStopDate = ""
  1370. order.DrordDrCodg = "1"
  1371. order.DrordDeptName = department.Name
  1372. order.DrordDrCodg = "1"
  1373. order.DrordDrName = doctor_info.UserName
  1374. order.DrordDrProfttl = ""
  1375. order.CurrDrordFlag = "1"
  1376. orders = append(orders, &order)
  1377. }
  1378. if subItem.Type == 3 {
  1379. var order models.FsiOrderDtos
  1380. order.RxID = strconv.FormatInt(item.ID, 10)
  1381. order.Rxno = strconv.FormatInt(item.ID, 10)
  1382. order.LongDrordFlag = "0"
  1383. order.HilistType = "1"
  1384. order.ChrgType = "1"
  1385. order.DrordBhvr = "-"
  1386. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1387. order.HosplistName = subItem.GoodInfo.GoodName
  1388. order.HilistLv = "1"
  1389. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1390. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  1391. order.HosplistName = subItem.GoodInfo.GoodName
  1392. order.Cnt = subItem.Count
  1393. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1394. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1395. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1396. order.OwnpayAmt = ""
  1397. order.SelfpayAmt = ""
  1398. order.Spec = ""
  1399. order.SpecUnt = ""
  1400. order.DrordBegnDate = s_tm
  1401. order.DrordStopDate = ""
  1402. order.DrordDrCodg = "1"
  1403. order.DrordDeptName = department.Name
  1404. order.DrordDrCodg = "1"
  1405. order.DrordDrName = doctor_info.UserName
  1406. order.DrordDrProfttl = ""
  1407. order.CurrDrordFlag = "1"
  1408. orders = append(orders, &order)
  1409. }
  1410. }
  1411. }
  1412. //处方医嘱信息
  1413. fed.MatnStas = "0"
  1414. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1415. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  1416. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  1417. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  1418. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  1419. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  1420. fed.SetlTotlnum = "1"
  1421. fed.Insutype = his.Insutype
  1422. fed.ReimFlag = "0"
  1423. fed.OutSetlFlag = "0"
  1424. var fopd []*models.FsiOperationDtosData
  1425. data := make(map[string]interface{})
  1426. data["fed"] = fed
  1427. data["fdd"] = fdds
  1428. data["fod"] = orders
  1429. data["pd"] = pd
  1430. data["pp"] = pp
  1431. data["fopd"] = fopd
  1432. data["trig_scen"] = trig_scen
  1433. client := &http.Client{}
  1434. bytesData, _ := json.Marshal(data)
  1435. var req *http.Request
  1436. if miConfig.MdtrtareaAdmvs == "320921" {
  1437. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1438. } else {
  1439. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  1440. }
  1441. resp, _ := client.Do(req)
  1442. defer resp.Body.Close()
  1443. body, ioErr := ioutil.ReadAll(resp.Body)
  1444. if ioErr != nil {
  1445. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1447. return res
  1448. }
  1449. var respJSON map[string]interface{}
  1450. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1451. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1453. return res
  1454. }
  1455. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1456. result, _ := json.Marshal(respJSON)
  1457. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1458. utils.ErrorLog("解析失败:%v", err)
  1459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1460. return res
  1461. }
  1462. return res
  1463. //手术操作集合
  1464. //手术操作集合
  1465. }
  1466. func (c *HisApiController) Check() {
  1467. psn_no := c.GetString("psn_no")
  1468. in := c.GetString("in")
  1469. mt := c.GetString("mt")
  1470. baseParams := models.BaseParams{
  1471. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  1472. FixmedinsCode: "H15049901371",
  1473. InsuplcAdmdvs: "150499",
  1474. MdtrtareaAdmvs: "150499",
  1475. OrgName: "赤峰费森血液透析中心",
  1476. Doctor: "1111",
  1477. }
  1478. service.Gdyb2001(baseParams, psn_no, in, mt)
  1479. }
  1480. func (c *HisApiController) GetPsnNcdsInfo() {
  1481. admin_user_id, _ := c.GetInt64("admin_user_id")
  1482. patient_id, _ := c.GetInt64("patient_id")
  1483. id, _ := c.GetInt64("id")
  1484. adminUser := c.GetAdminUserInfo()
  1485. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1486. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1487. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  1488. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1489. psn_record, _ := service.GetPsnNCDSRecordById(id)
  1490. //
  1491. //if psn_record.ID == 0 {
  1492. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  1493. // return
  1494. //}
  1495. var res Result5301
  1496. var res10265 Result5301For10265
  1497. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1498. psn_info, _ := service.GetPsnByPatientId(patient_id)
  1499. var api string
  1500. if miConfig.MdtrtareaAdmvs == "320921" {
  1501. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  1502. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1503. } else {
  1504. 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 +
  1505. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  1506. }
  1507. resp, requestErr := http.Get(api)
  1508. if requestErr != nil {
  1509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1510. return
  1511. }
  1512. body, ioErr := ioutil.ReadAll(resp.Body)
  1513. if ioErr != nil {
  1514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1516. return
  1517. }
  1518. var respJSON map[string]interface{}
  1519. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1522. return
  1523. }
  1524. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1525. result, _ := json.Marshal(respJSON)
  1526. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1527. utils.ErrorLog("解析失败:%v", err)
  1528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1529. return
  1530. }
  1531. res.ErrMsg = res10265.ErrMsg
  1532. res.Output = res10265.Output
  1533. res.InfRefmsgid = res10265.InfRefmsgid
  1534. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1535. res.Infcode = infocode
  1536. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1537. p, _ := service.GetHisPatientById(patient_id)
  1538. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1539. var dat map[string]interface{}
  1540. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1541. fmt.Println(dat)
  1542. } else {
  1543. fmt.Println(err)
  1544. }
  1545. userJSONBytes, _ := json.Marshal(dat)
  1546. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1547. utils.ErrorLog("解析失败:%v", err)
  1548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1549. return
  1550. }
  1551. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1552. p, _ := service.GetHisPatientById(patient_id)
  1553. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  1554. var dat map[string]interface{}
  1555. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1556. fmt.Println(dat)
  1557. } else {
  1558. fmt.Println(err)
  1559. }
  1560. userJSONBytes, _ := json.Marshal(dat)
  1561. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1562. utils.ErrorLog("解析失败:%v", err)
  1563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1564. return
  1565. }
  1566. } else {
  1567. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1568. var dat map[string]interface{}
  1569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1570. fmt.Println(dat)
  1571. } else {
  1572. fmt.Println(err)
  1573. }
  1574. userJSONBytes, _ := json.Marshal(dat)
  1575. if miConfig.Code == "H15049901371" {
  1576. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  1577. utils.ErrorLog("解析失败:%v", err)
  1578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1579. return
  1580. }
  1581. res.InfRefmsgid = res10265.InfRefmsgid
  1582. res.Output = res10265.Output
  1583. res.ErrMsg = res10265.ErrMsg
  1584. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1585. res.Infcode = infocode
  1586. } else {
  1587. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1588. utils.ErrorLog("解析失败:%v", err)
  1589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1590. return
  1591. }
  1592. }
  1593. }
  1594. if res.Infcode == 0 {
  1595. c.ServeSuccessJSON(map[string]interface{}{
  1596. "result": res.Output.Result,
  1597. })
  1598. }
  1599. }
  1600. func (c *HisApiController) CheckInsutype() {
  1601. his_patient_id, _ := c.GetInt64("his_patient_id")
  1602. admin_user_id, _ := c.GetInt64("admin_user_id")
  1603. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1604. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1605. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1606. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1607. var dat map[string]interface{}
  1608. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1609. fmt.Println(dat)
  1610. } else {
  1611. fmt.Println(err)
  1612. }
  1613. userJSONBytes, _ := json.Marshal(dat)
  1614. var res Result90100
  1615. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1616. utils.ErrorLog("解析失败:%v", err)
  1617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1618. return
  1619. }
  1620. if res.Infcode != 0 {
  1621. c.ServeSuccessJSON(map[string]interface{}{
  1622. "failed_code": -10,
  1623. "msg": res.ErrMsg,
  1624. })
  1625. return
  1626. } else {
  1627. fmt.Println(res)
  1628. }
  1629. }
  1630. func (c *HisApiController) CheckCardPWD() {
  1631. card_pwd := c.GetString("card_pwd")
  1632. his_patient_id, _ := c.GetInt64("his_patient_id")
  1633. admin_user_id, _ := c.GetInt64("admin_user_id")
  1634. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1635. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1636. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1637. psn, _ := service.GetPsnByPatientId(his.PatientId)
  1638. bas := strings.Split(psn.CardInfo, "|")
  1639. basNumber := bas[2]
  1640. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  1641. var dat map[string]interface{}
  1642. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1643. fmt.Println(dat)
  1644. } else {
  1645. fmt.Println(err)
  1646. }
  1647. userJSONBytes, _ := json.Marshal(dat)
  1648. var res Result90991
  1649. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1650. utils.ErrorLog("解析失败:%v", err)
  1651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1652. return
  1653. }
  1654. if res.Infcode != 0 {
  1655. c.ServeSuccessJSON(map[string]interface{}{
  1656. "failed_code": -10,
  1657. "msg": res.ErrMsg,
  1658. })
  1659. return
  1660. } else {
  1661. if res.Output.Result.SscnoCheckStat == "0" {
  1662. var msg string
  1663. switch res.Output.Result.CardStat {
  1664. case "00":
  1665. msg = "未激活"
  1666. break
  1667. case "10":
  1668. msg = "激活"
  1669. break
  1670. case "20":
  1671. msg = "窗口挂失"
  1672. break
  1673. case "21":
  1674. msg = "电话挂失"
  1675. break
  1676. case "22":
  1677. msg = "单位网上申报挂失"
  1678. break
  1679. case "23":
  1680. msg = "保健办挂失"
  1681. break
  1682. case "24":
  1683. msg = "个人网上挂失"
  1684. break
  1685. case "25":
  1686. msg = "网上服务大厅挂失"
  1687. break
  1688. case "30":
  1689. msg = "注销"
  1690. break
  1691. case "40":
  1692. msg = "回收"
  1693. break
  1694. case "99":
  1695. msg = "制卡中(无效卡)"
  1696. break
  1697. }
  1698. c.ServeSuccessJSON(map[string]interface{}{
  1699. "failed_code": -10,
  1700. "msg": msg,
  1701. })
  1702. return
  1703. } else {
  1704. c.ServeSuccessJSON(map[string]interface{}{
  1705. "msg": "校验成功",
  1706. })
  1707. return
  1708. }
  1709. }
  1710. }
  1711. func (c *HisApiController) CheckCardPWDTwo() {
  1712. //card_pwd := c.GetString("card_pwd")
  1713. //his_patient_id, _ := c.GetInt64("his_patient_id")
  1714. admin_user_id, _ := c.GetInt64("admin_user_id")
  1715. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1716. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1717. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  1718. var dat map[string]interface{}
  1719. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1720. fmt.Println(dat)
  1721. } else {
  1722. fmt.Println(err)
  1723. }
  1724. userJSONBytes, _ := json.Marshal(dat)
  1725. var res Result90991
  1726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1727. utils.ErrorLog("解析失败:%v", err)
  1728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1729. return
  1730. }
  1731. if res.Infcode != 0 {
  1732. c.ServeSuccessJSON(map[string]interface{}{
  1733. "failed_code": -10,
  1734. "msg": res.ErrMsg,
  1735. })
  1736. return
  1737. } else {
  1738. if res.Output.Result.SscnoCheckStat == "0" {
  1739. var msg string
  1740. switch res.Output.Result.CardStat {
  1741. case "00":
  1742. msg = "未激活"
  1743. break
  1744. case "10":
  1745. msg = "激活"
  1746. break
  1747. case "20":
  1748. msg = "窗口挂失"
  1749. break
  1750. case "21":
  1751. msg = "电话挂失"
  1752. break
  1753. case "22":
  1754. msg = "单位网上申报挂失"
  1755. break
  1756. case "23":
  1757. msg = "保健办挂失"
  1758. break
  1759. case "24":
  1760. msg = "个人网上挂失"
  1761. break
  1762. case "25":
  1763. msg = "网上服务大厅挂失"
  1764. break
  1765. case "30":
  1766. msg = "注销"
  1767. break
  1768. case "40":
  1769. msg = "回收"
  1770. break
  1771. case "99":
  1772. msg = "制卡中(无效卡)"
  1773. break
  1774. }
  1775. c.ServeSuccessJSON(map[string]interface{}{
  1776. "failed_code": -10,
  1777. "msg": msg,
  1778. })
  1779. return
  1780. } else {
  1781. c.ServeSuccessJSON(map[string]interface{}{
  1782. "msg": "校验成功",
  1783. })
  1784. return
  1785. }
  1786. }
  1787. }
  1788. type ELeCertData struct {
  1789. Data struct {
  1790. Extra string `json:"extra"`
  1791. IDNo string `json:"idNo"`
  1792. IDType string `json:"idType"`
  1793. EcToken string `json:"ecToken"`
  1794. InsuOrg string `json:"insuOrg"`
  1795. UserName string `json:"userName"`
  1796. EcIndexNo string `json:"ecIndexNo"`
  1797. Gender string `json:"gender"`
  1798. Birthday string `json:"birthday"`
  1799. Nationality string `json:"nationality"`
  1800. Email string `json:"email"`
  1801. } `json:"OutData"`
  1802. }
  1803. func (c *HisApiController) ReadCard() {
  1804. id_card_type, _ := c.GetInt64("id_card_type")
  1805. admin_user_id, _ := c.GetInt64("admin_user_id")
  1806. certificates, _ := c.GetInt64("certificates")
  1807. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1808. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1809. switch id_card_type {
  1810. case 1:
  1811. if miConfig.MdtrtareaAdmvs == "421300" {
  1812. var res ResultTwo
  1813. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1814. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1815. "&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)
  1816. resp, requestErr := http.Get(api)
  1817. if requestErr != nil {
  1818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1819. return
  1820. }
  1821. body, ioErr := ioutil.ReadAll(resp.Body)
  1822. if ioErr != nil {
  1823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1825. return
  1826. }
  1827. var respJSON map[string]interface{}
  1828. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1831. return
  1832. }
  1833. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1834. result, _ := json.Marshal(respJSON)
  1835. fmt.Println("log")
  1836. fmt.Println(string(result))
  1837. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1838. utils.ErrorLog("解析失败:%v", err)
  1839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1840. return
  1841. }
  1842. if res.Infcode == 0 {
  1843. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1844. if err == gorm.ErrRecordNotFound {
  1845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1846. return
  1847. } else if err != nil {
  1848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1849. return
  1850. } else {
  1851. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1852. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1853. infoStr := string(Iinfos)
  1854. idetinfoStr := string(Idetinfos)
  1855. psn := &models.HisPsn{
  1856. PsnNo: res.Output.Baseinfo.PsnNo,
  1857. Age: res.Output.Baseinfo.Age,
  1858. PatientId: patient.ID,
  1859. Certno: res.Output.Baseinfo.Certno,
  1860. Brdy: res.Output.Baseinfo.Brdy,
  1861. Gend: res.Output.Baseinfo.Gend,
  1862. Naty: res.Output.Baseinfo.Naty,
  1863. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1864. PsnName: res.Output.Baseinfo.PsnName,
  1865. Idetinfo: idetinfoStr,
  1866. Insuinfo: infoStr,
  1867. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1868. }
  1869. service.CreateHisPsn(psn)
  1870. c.ServeSuccessJSON(map[string]interface{}{
  1871. "patient": patient,
  1872. "number": res.Output.Baseinfo.Certno,
  1873. })
  1874. }
  1875. } else {
  1876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1877. return
  1878. }
  1879. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1880. var api string
  1881. if miConfig.MdtrtareaAdmvs == "320921" {
  1882. 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 +
  1883. "&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
  1884. fmt.Println(api)
  1885. } else {
  1886. 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 +
  1887. "&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)
  1888. }
  1889. resp, requestErr := http.Get(api)
  1890. if requestErr != nil {
  1891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1892. return
  1893. }
  1894. body, ioErr := ioutil.ReadAll(resp.Body)
  1895. if ioErr != nil {
  1896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1898. return
  1899. }
  1900. var respJSON map[string]interface{}
  1901. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1904. return
  1905. }
  1906. var status string
  1907. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1908. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1909. //console.log()
  1910. fmt.Println("type===")
  1911. fmt.Println(card_type)
  1912. var token string
  1913. var res ResultTwo //1101结果
  1914. var res10265 ResultTwo10265 //1101结果
  1915. var card_info string //卡信息
  1916. var busi_card_info string
  1917. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1918. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1919. if status == "0" { //读卡成功
  1920. if card_type == "1" {
  1921. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1922. result, _ := json.Marshal(respJSON)
  1923. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1924. utils.ErrorLog("解析失败:%v", err)
  1925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1926. return
  1927. }
  1928. res.ErrMsg = res10265.ErrMsg
  1929. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1930. res.Infcode = infocode
  1931. res.Output = res10265.Output
  1932. res.InfRefmsgid = res10265.InfRefmsgid
  1933. } else {
  1934. //var card_info string //卡信息
  1935. //var busi_card_info string
  1936. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1937. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1938. //fmt.Println(card_info)
  1939. //fmt.Println(busi_card_info)
  1940. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1941. result, _ := json.Marshal(respJSON)
  1942. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1943. utils.ErrorLog("解析失败:%v", err)
  1944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1945. return
  1946. }
  1947. res.ErrMsg = res10265.ErrMsg
  1948. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1949. res.Infcode = infocode
  1950. res.Output = res10265.Output
  1951. res.InfRefmsgid = res10265.InfRefmsgid
  1952. }
  1953. if res.Infcode == 0 {
  1954. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1955. if err == gorm.ErrRecordNotFound {
  1956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1957. return
  1958. } else if err != nil {
  1959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1960. return
  1961. } else {
  1962. if card_type == "1" {
  1963. bas := strings.Split(card_info, "|")
  1964. basNumber := bas[2]
  1965. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1966. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1967. infoStr := string(Iinfos)
  1968. idetinfoStr := string(Idetinfos)
  1969. psn := &models.HisPsn{
  1970. PsnNo: res.Output.Baseinfo.PsnNo,
  1971. Age: res.Output.Baseinfo.Age,
  1972. PatientId: patient.ID,
  1973. Certno: res.Output.Baseinfo.Certno,
  1974. Brdy: res.Output.Baseinfo.Brdy,
  1975. Gend: res.Output.Baseinfo.Gend,
  1976. Naty: res.Output.Baseinfo.Naty,
  1977. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1978. PsnName: res.Output.Baseinfo.PsnName,
  1979. Idetinfo: idetinfoStr,
  1980. Insuinfo: infoStr,
  1981. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1982. CardInfo: card_info,
  1983. VerifyNumber: busi_card_info,
  1984. }
  1985. service.CreateHisPsn(psn)
  1986. var rf []*ResultFive
  1987. json.Unmarshal([]byte(infoStr), &rf)
  1988. var insutypes []*ResultFive
  1989. var insutype string
  1990. var is390 int = 0
  1991. var is310 int = 0
  1992. for _, item := range rf {
  1993. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1994. insutypes = append(insutypes, item)
  1995. }
  1996. }
  1997. if len(insutypes) == 1 {
  1998. insutype = insutypes[0].Insutype
  1999. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2000. } else {
  2001. for _, i := range insutypes {
  2002. if i.Insutype == "390" {
  2003. is390 = 1
  2004. }
  2005. if i.Insutype == "310" {
  2006. is310 = 1
  2007. }
  2008. }
  2009. }
  2010. if is390 == 1 {
  2011. insutype = "390"
  2012. }
  2013. if is310 == 1 {
  2014. insutype = "310"
  2015. }
  2016. if len(insutypes) == 0 {
  2017. insutype = "310"
  2018. }
  2019. c.ServeSuccessJSON(map[string]interface{}{
  2020. "patient": patient,
  2021. "number": basNumber,
  2022. "insutype": insutype,
  2023. })
  2024. } else {
  2025. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2026. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2027. infoStr := string(Iinfos)
  2028. idetinfoStr := string(Idetinfos)
  2029. psn := &models.HisPsn{
  2030. PsnNo: res.Output.Baseinfo.PsnNo,
  2031. Age: res.Output.Baseinfo.Age,
  2032. PatientId: patient.ID,
  2033. Certno: res.Output.Baseinfo.Certno,
  2034. Brdy: res.Output.Baseinfo.Brdy,
  2035. Gend: res.Output.Baseinfo.Gend,
  2036. Naty: res.Output.Baseinfo.Naty,
  2037. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2038. PsnName: res.Output.Baseinfo.PsnName,
  2039. Idetinfo: idetinfoStr,
  2040. Insuinfo: infoStr,
  2041. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2042. CardInfo: card_info,
  2043. VerifyNumber: token,
  2044. }
  2045. service.CreateHisPsn(psn)
  2046. c.ServeSuccessJSON(map[string]interface{}{
  2047. "patient": patient,
  2048. "number": token,
  2049. })
  2050. }
  2051. }
  2052. } else {
  2053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2054. return
  2055. }
  2056. } else { //读卡失败
  2057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2058. return
  2059. }
  2060. } else if miConfig.MdtrtareaAdmvs == "350500" {
  2061. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  2062. cardnum = DeleteExtraSpaceTwo(cardnum)
  2063. cardCode = DeleteExtraSpaceTwo(cardCode)
  2064. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  2065. name = DeleteExtraSpaceTwo(name)
  2066. errmsg = DeleteExtraSpaceTwo(errmsg)
  2067. cardnum = Remove0000(cardnum)
  2068. cardCode = Remove0000(cardCode)
  2069. id_card_no = Remove0000(id_card_no)
  2070. name = Remove0000(name)
  2071. errmsg = Remove0000(errmsg)
  2072. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  2073. result, requestLog, errMsgLog := service.FJyb1101(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)
  2074. saveLog(result, requestLog, "1101", "获取人员信息")
  2075. fmt.Println(errMsgLog)
  2076. if len(errMsgLog) > 0 {
  2077. } else {
  2078. var dat map[string]interface{}
  2079. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2080. fmt.Println(dat)
  2081. } else {
  2082. fmt.Println(err)
  2083. }
  2084. userJSONBytes, _ := json.Marshal(dat)
  2085. var res ResultTwo
  2086. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2087. utils.ErrorLog("解析失败:%v", err)
  2088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2089. return
  2090. }
  2091. res.ErrMsg = errMsgLog
  2092. if res.Infcode == 0 {
  2093. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  2094. if err == gorm.ErrRecordNotFound {
  2095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2096. return
  2097. } else if err != nil {
  2098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2099. return
  2100. } else {
  2101. fmt.Println(res)
  2102. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2103. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2104. infoStr := string(Iinfos)
  2105. idetinfoStr := string(Idetinfos)
  2106. psn := &models.HisPsn{
  2107. PsnNo: res.Output.Baseinfo.PsnNo,
  2108. Age: res.Output.Baseinfo.Age,
  2109. PatientId: patient.ID,
  2110. Certno: res.Output.Baseinfo.Certno,
  2111. Brdy: res.Output.Baseinfo.Brdy,
  2112. Gend: res.Output.Baseinfo.Gend,
  2113. Naty: res.Output.Baseinfo.Naty,
  2114. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2115. PsnName: res.Output.Baseinfo.PsnName,
  2116. Idetinfo: idetinfoStr,
  2117. Insuinfo: infoStr,
  2118. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2119. CardInfo: basStr,
  2120. VerifyNumber: "",
  2121. }
  2122. service.CreateHisPsn(psn)
  2123. var rf []*ResultFive
  2124. json.Unmarshal([]byte(infoStr), &rf)
  2125. var insutypes []*ResultFive
  2126. var insutype string
  2127. var is390 int = 0
  2128. var is310 int = 0
  2129. for _, item := range rf {
  2130. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2131. insutypes = append(insutypes, item)
  2132. }
  2133. }
  2134. if len(insutypes) == 1 {
  2135. insutype = insutypes[0].Insutype
  2136. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2137. } else {
  2138. for _, i := range insutypes {
  2139. if i.Insutype == "390" {
  2140. is390 = 1
  2141. }
  2142. if i.Insutype == "310" {
  2143. is310 = 1
  2144. }
  2145. }
  2146. }
  2147. if is390 == 1 {
  2148. insutype = "390"
  2149. }
  2150. if is310 == 1 {
  2151. insutype = "310"
  2152. }
  2153. if len(insutypes) == 0 {
  2154. insutype = "310"
  2155. }
  2156. c.ServeSuccessJSON(map[string]interface{}{
  2157. "patient": patient,
  2158. "number": cardnum,
  2159. "insutype": insutype,
  2160. })
  2161. }
  2162. } else {
  2163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2164. return
  2165. }
  2166. }
  2167. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2168. fmt.Println(initFlag)
  2169. fmt.Println("initFlag")
  2170. if initFlag == 0 {
  2171. c.TestGetJiangXiBasBaseInit()
  2172. }
  2173. basStr := c.GetBasBaseInfo()
  2174. if len(basStr) == 0 {
  2175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2176. return
  2177. }
  2178. fmt.Println(basStr)
  2179. bas := strings.Split(basStr, "|")
  2180. basNumber := bas[1]
  2181. fmt.Println(basNumber)
  2182. card_sn := bas[3]
  2183. fmt.Println(card_sn)
  2184. 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, "")
  2185. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2186. var dat map[string]interface{}
  2187. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2188. fmt.Println(dat)
  2189. } else {
  2190. fmt.Println(err)
  2191. }
  2192. userJSONBytes, _ := json.Marshal(dat)
  2193. var res ResultTwo
  2194. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2195. utils.ErrorLog("解析失败:%v", err)
  2196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2197. return
  2198. }
  2199. if res.Infcode == 0 {
  2200. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2201. if err == gorm.ErrRecordNotFound {
  2202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2203. return
  2204. } else if err != nil {
  2205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2206. return
  2207. } else {
  2208. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2209. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2210. infoStr := string(Iinfos)
  2211. idetinfoStr := string(Idetinfos)
  2212. psn := &models.HisPsn{
  2213. PsnNo: res.Output.Baseinfo.PsnNo,
  2214. Age: res.Output.Baseinfo.Age,
  2215. PatientId: patient.ID,
  2216. Certno: res.Output.Baseinfo.Certno,
  2217. Brdy: res.Output.Baseinfo.Brdy,
  2218. Gend: res.Output.Baseinfo.Gend,
  2219. Naty: res.Output.Baseinfo.Naty,
  2220. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2221. PsnName: res.Output.Baseinfo.PsnName,
  2222. Idetinfo: idetinfoStr,
  2223. Insuinfo: infoStr,
  2224. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2225. CardInfo: basStr,
  2226. VerifyNumber: "",
  2227. }
  2228. service.CreateHisPsn(psn)
  2229. var rf []*ResultFive
  2230. json.Unmarshal([]byte(infoStr), &rf)
  2231. var insutypes []*ResultFive
  2232. var insutype string
  2233. var is390 int = 0
  2234. var is310 int = 0
  2235. for _, item := range rf {
  2236. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2237. insutypes = append(insutypes, item)
  2238. }
  2239. }
  2240. if len(insutypes) == 1 {
  2241. insutype = insutypes[0].Insutype
  2242. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2243. } else {
  2244. for _, i := range insutypes {
  2245. if i.Insutype == "390" {
  2246. is390 = 1
  2247. }
  2248. if i.Insutype == "310" {
  2249. is310 = 1
  2250. }
  2251. }
  2252. }
  2253. if is390 == 1 {
  2254. insutype = "390"
  2255. }
  2256. if is310 == 1 {
  2257. insutype = "310"
  2258. }
  2259. if len(insutypes) == 0 {
  2260. insutype = "310"
  2261. }
  2262. c.ServeSuccessJSON(map[string]interface{}{
  2263. "patient": patient,
  2264. "number": basNumber,
  2265. "insutype": insutype,
  2266. })
  2267. }
  2268. } else {
  2269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2270. return
  2271. }
  2272. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2273. fmt.Println(initFlag)
  2274. fmt.Println("initFlag")
  2275. if initFlag == 0 {
  2276. c.TestGetHnBasBaseInit()
  2277. }
  2278. basStr := c.GetBasBaseInfo()
  2279. if len(basStr) == 0 {
  2280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2281. return
  2282. }
  2283. fmt.Println(basStr)
  2284. bas := strings.Split(basStr, "|")
  2285. basNumber := bas[1]
  2286. fmt.Println(basNumber)
  2287. card_sn := bas[3]
  2288. card_no := bas[2]
  2289. fmt.Println(card_sn)
  2290. name := bas[4]
  2291. name = ConvertToString(name, "gbk", "utf-8")
  2292. 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)
  2293. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2294. var dat map[string]interface{}
  2295. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2296. fmt.Println(dat)
  2297. } else {
  2298. fmt.Println(err)
  2299. }
  2300. userJSONBytes, _ := json.Marshal(dat)
  2301. var res ResultTwo
  2302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2303. utils.ErrorLog("解析失败:%v", err)
  2304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2305. return
  2306. }
  2307. if res.Infcode == 0 {
  2308. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2309. if err == gorm.ErrRecordNotFound {
  2310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2311. return
  2312. } else if err != nil {
  2313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2314. return
  2315. } else {
  2316. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2317. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2318. infoStr := string(Iinfos)
  2319. idetinfoStr := string(Idetinfos)
  2320. psn := &models.HisPsn{
  2321. PsnNo: res.Output.Baseinfo.PsnNo,
  2322. Age: res.Output.Baseinfo.Age,
  2323. PatientId: patient.ID,
  2324. Certno: res.Output.Baseinfo.Certno,
  2325. Brdy: res.Output.Baseinfo.Brdy,
  2326. Gend: res.Output.Baseinfo.Gend,
  2327. Naty: res.Output.Baseinfo.Naty,
  2328. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2329. PsnName: res.Output.Baseinfo.PsnName,
  2330. Idetinfo: idetinfoStr,
  2331. Insuinfo: infoStr,
  2332. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2333. CardInfo: basStr,
  2334. VerifyNumber: "",
  2335. }
  2336. service.CreateHisPsn(psn)
  2337. var rf []*ResultFive
  2338. json.Unmarshal([]byte(infoStr), &rf)
  2339. var insutypes []*ResultFive
  2340. var insutype string
  2341. var is390 int = 0
  2342. var is310 int = 0
  2343. for _, item := range rf {
  2344. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2345. insutypes = append(insutypes, item)
  2346. }
  2347. }
  2348. if len(insutypes) == 1 {
  2349. insutype = insutypes[0].Insutype
  2350. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2351. } else {
  2352. for _, i := range insutypes {
  2353. if i.Insutype == "390" {
  2354. is390 = 1
  2355. }
  2356. if i.Insutype == "310" {
  2357. is310 = 1
  2358. }
  2359. }
  2360. }
  2361. if is390 == 1 {
  2362. insutype = "390"
  2363. }
  2364. if is310 == 1 {
  2365. insutype = "310"
  2366. }
  2367. if len(insutypes) == 0 {
  2368. insutype = "310"
  2369. }
  2370. c.ServeSuccessJSON(map[string]interface{}{
  2371. "patient": patient,
  2372. "number": basNumber,
  2373. "insutype": insutype,
  2374. })
  2375. }
  2376. } else {
  2377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2378. return
  2379. }
  2380. } else {
  2381. if initFlag == 0 {
  2382. c.TestGetBasBaseInit()
  2383. }
  2384. basStr := c.GetBasBaseInfo()
  2385. if len(basStr) == 0 {
  2386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2387. return
  2388. }
  2389. fmt.Println(basStr)
  2390. bas := strings.Split(basStr, "|")
  2391. basNumber := bas[1]
  2392. fmt.Println(basNumber)
  2393. card_sn := bas[3]
  2394. fmt.Println(card_sn)
  2395. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2396. var dat map[string]interface{}
  2397. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2398. fmt.Println(dat)
  2399. } else {
  2400. fmt.Println(err)
  2401. }
  2402. userJSONBytes, _ := json.Marshal(dat)
  2403. var res ResultTwo
  2404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2405. utils.ErrorLog("解析失败:%v", err)
  2406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2407. return
  2408. }
  2409. if res.Infcode == 0 {
  2410. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  2411. if err == gorm.ErrRecordNotFound {
  2412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2413. return
  2414. } else if err != nil {
  2415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2416. return
  2417. } else {
  2418. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2419. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2420. infoStr := string(Iinfos)
  2421. idetinfoStr := string(Idetinfos)
  2422. psn := &models.HisPsn{
  2423. PsnNo: res.Output.Baseinfo.PsnNo,
  2424. Age: res.Output.Baseinfo.Age,
  2425. PatientId: patient.ID,
  2426. Certno: res.Output.Baseinfo.Certno,
  2427. Brdy: res.Output.Baseinfo.Brdy,
  2428. Gend: res.Output.Baseinfo.Gend,
  2429. Naty: res.Output.Baseinfo.Naty,
  2430. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2431. PsnName: res.Output.Baseinfo.PsnName,
  2432. Idetinfo: idetinfoStr,
  2433. Insuinfo: infoStr,
  2434. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2435. CardInfo: basStr,
  2436. VerifyNumber: "",
  2437. }
  2438. service.CreateHisPsn(psn)
  2439. c.ServeSuccessJSON(map[string]interface{}{
  2440. "patient": patient,
  2441. "number": basNumber,
  2442. })
  2443. }
  2444. } else {
  2445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2446. return
  2447. }
  2448. break
  2449. }
  2450. case 2:
  2451. if miConfig.MdtrtareaAdmvs == "430800" {
  2452. if initFlag == 0 {
  2453. c.TestGetHnBasBaseInit()
  2454. }
  2455. SFZStr := c.GetSFZBaseInfo()
  2456. if len(SFZStr) == 0 {
  2457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2458. return
  2459. }
  2460. fmt.Println(SFZStr)
  2461. id_card_str := strings.Split(SFZStr, "^")
  2462. card_no := id_card_str[0]
  2463. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  2464. //name := id_card_str[1]
  2465. //name = ConvertToString(name, "gbk", "utf-8")
  2466. 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)
  2467. var dat map[string]interface{}
  2468. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2469. fmt.Println(dat)
  2470. } else {
  2471. fmt.Println(err)
  2472. }
  2473. userJSONBytes, _ := json.Marshal(dat)
  2474. var res ResultTwo
  2475. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2476. utils.ErrorLog("解析失败:%v", err)
  2477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2478. return
  2479. }
  2480. if res.Infcode == 0 {
  2481. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  2482. if err == gorm.ErrRecordNotFound {
  2483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2484. return
  2485. } else if err != nil {
  2486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2487. return
  2488. } else {
  2489. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2490. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2491. infoStr := string(Iinfos)
  2492. idetinfoStr := string(Idetinfos)
  2493. psn := &models.HisPsn{
  2494. PsnNo: res.Output.Baseinfo.PsnNo,
  2495. Age: res.Output.Baseinfo.Age,
  2496. PatientId: patient.ID,
  2497. Certno: res.Output.Baseinfo.Certno,
  2498. Brdy: res.Output.Baseinfo.Brdy,
  2499. Gend: res.Output.Baseinfo.Gend,
  2500. Naty: res.Output.Baseinfo.Naty,
  2501. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2502. PsnName: res.Output.Baseinfo.PsnName,
  2503. Idetinfo: idetinfoStr,
  2504. Insuinfo: infoStr,
  2505. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2506. CardInfo: SFZStr,
  2507. VerifyNumber: "",
  2508. }
  2509. service.CreateHisPsn(psn)
  2510. var rf []*ResultFive
  2511. json.Unmarshal([]byte(infoStr), &rf)
  2512. var insutypes []*ResultFive
  2513. var insutype string
  2514. var is390 int = 0
  2515. var is310 int = 0
  2516. for _, item := range rf {
  2517. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2518. insutypes = append(insutypes, item)
  2519. }
  2520. }
  2521. if len(insutypes) == 1 {
  2522. insutype = insutypes[0].Insutype
  2523. } else {
  2524. for _, i := range insutypes {
  2525. if i.Insutype == "390" {
  2526. is390 = 1
  2527. }
  2528. if i.Insutype == "310" {
  2529. is310 = 1
  2530. }
  2531. }
  2532. }
  2533. if is390 == 1 {
  2534. insutype = "390"
  2535. }
  2536. if is310 == 1 {
  2537. insutype = "310"
  2538. }
  2539. if len(insutypes) == 0 {
  2540. insutype = "310"
  2541. }
  2542. c.ServeSuccessJSON(map[string]interface{}{
  2543. "patient": patient,
  2544. "number": card_no,
  2545. "insutype": insutype,
  2546. })
  2547. }
  2548. } else {
  2549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2550. return
  2551. }
  2552. } else {
  2553. SFZStr := c.GetSFZBaseInfo()
  2554. id_card_str := strings.Split(SFZStr, "^")
  2555. id_card_number := id_card_str[0]
  2556. card_sn := ""
  2557. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  2558. var dat map[string]interface{}
  2559. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2560. fmt.Println(dat)
  2561. } else {
  2562. fmt.Println(err)
  2563. }
  2564. userJSONBytes, _ := json.Marshal(dat)
  2565. var res ResultTwo
  2566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2567. utils.ErrorLog("解析失败:%v", err)
  2568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2569. return
  2570. }
  2571. if res.Infcode == 0 {
  2572. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  2573. if err == gorm.ErrRecordNotFound {
  2574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2575. return
  2576. } else if err != nil {
  2577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2578. return
  2579. } else {
  2580. c.ServeSuccessJSON(map[string]interface{}{
  2581. "patient": patient,
  2582. "number": id_card_number,
  2583. })
  2584. }
  2585. } else {
  2586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2587. return
  2588. }
  2589. }
  2590. break
  2591. case 3:
  2592. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2593. var api string
  2594. if miConfig.MdtrtareaAdmvs == "320921" {
  2595. 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 +
  2596. "&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
  2597. fmt.Println(api)
  2598. } else {
  2599. 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 +
  2600. "&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)
  2601. }
  2602. resp, requestErr := http.Get(api)
  2603. if requestErr != nil {
  2604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2605. return
  2606. }
  2607. body, ioErr := ioutil.ReadAll(resp.Body)
  2608. if ioErr != nil {
  2609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2611. return
  2612. }
  2613. var respJSON map[string]interface{}
  2614. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2617. return
  2618. }
  2619. var status string
  2620. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2621. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2622. var token string
  2623. var res ResultTwo //1101结果
  2624. var res10265 ResultTwo10265 //1101结果
  2625. var card_info string //卡信息
  2626. var busi_card_info string
  2627. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2628. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2629. if status == "0" { //读卡成功
  2630. if card_type == "1" {
  2631. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2632. result, _ := json.Marshal(respJSON)
  2633. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2634. utils.ErrorLog("解析失败:%v", err)
  2635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2636. return
  2637. }
  2638. res.ErrMsg = res10265.ErrMsg
  2639. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2640. res.Infcode = infocode
  2641. res.Output = res10265.Output
  2642. res.InfRefmsgid = res10265.InfRefmsgid
  2643. } else {
  2644. //var card_info string //卡信息
  2645. //var busi_card_info string
  2646. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2647. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2648. //fmt.Println(card_info)
  2649. //fmt.Println(busi_card_info)
  2650. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2651. result, _ := json.Marshal(respJSON)
  2652. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2653. utils.ErrorLog("解析失败:%v", err)
  2654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2655. return
  2656. }
  2657. res.ErrMsg = res10265.ErrMsg
  2658. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2659. res.Infcode = infocode
  2660. res.Output = res10265.Output
  2661. res.InfRefmsgid = res10265.InfRefmsgid
  2662. }
  2663. if res.Infcode == 0 {
  2664. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2665. if err == gorm.ErrRecordNotFound {
  2666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2667. return
  2668. } else if err != nil {
  2669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2670. return
  2671. } else {
  2672. if card_type == "1" {
  2673. bas := strings.Split(card_info, "|")
  2674. basNumber := bas[2]
  2675. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2676. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2677. infoStr := string(Iinfos)
  2678. idetinfoStr := string(Idetinfos)
  2679. psn := &models.HisPsn{
  2680. PsnNo: res.Output.Baseinfo.PsnNo,
  2681. Age: res.Output.Baseinfo.Age,
  2682. PatientId: patient.ID,
  2683. Certno: res.Output.Baseinfo.Certno,
  2684. Brdy: res.Output.Baseinfo.Brdy,
  2685. Gend: res.Output.Baseinfo.Gend,
  2686. Naty: res.Output.Baseinfo.Naty,
  2687. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2688. PsnName: res.Output.Baseinfo.PsnName,
  2689. Idetinfo: idetinfoStr,
  2690. Insuinfo: infoStr,
  2691. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2692. CardInfo: card_info,
  2693. VerifyNumber: busi_card_info,
  2694. }
  2695. service.CreateHisPsn(psn)
  2696. c.ServeSuccessJSON(map[string]interface{}{
  2697. "patient": patient,
  2698. "number": basNumber,
  2699. })
  2700. } else {
  2701. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2702. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2703. infoStr := string(Iinfos)
  2704. idetinfoStr := string(Idetinfos)
  2705. psn := &models.HisPsn{
  2706. PsnNo: res.Output.Baseinfo.PsnNo,
  2707. Age: res.Output.Baseinfo.Age,
  2708. PatientId: patient.ID,
  2709. Certno: res.Output.Baseinfo.Certno,
  2710. Brdy: res.Output.Baseinfo.Brdy,
  2711. Gend: res.Output.Baseinfo.Gend,
  2712. Naty: res.Output.Baseinfo.Naty,
  2713. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2714. PsnName: res.Output.Baseinfo.PsnName,
  2715. Idetinfo: idetinfoStr,
  2716. Insuinfo: infoStr,
  2717. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2718. CardInfo: card_info,
  2719. VerifyNumber: token,
  2720. }
  2721. service.CreateHisPsn(psn)
  2722. var rf []*ResultFive
  2723. json.Unmarshal([]byte(infoStr), &rf)
  2724. var insutypes []*ResultFive
  2725. var insutype string
  2726. var is390 int = 0
  2727. var is310 int = 0
  2728. for _, item := range rf {
  2729. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2730. insutypes = append(insutypes, item)
  2731. }
  2732. }
  2733. if len(insutypes) == 1 {
  2734. insutype = insutypes[0].Insutype
  2735. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2736. } else {
  2737. for _, i := range insutypes {
  2738. if i.Insutype == "390" {
  2739. is390 = 1
  2740. }
  2741. if i.Insutype == "310" {
  2742. is310 = 1
  2743. }
  2744. }
  2745. }
  2746. if is390 == 1 {
  2747. insutype = "390"
  2748. }
  2749. if is310 == 1 {
  2750. insutype = "310"
  2751. }
  2752. if len(insutypes) == 0 {
  2753. insutype = "310"
  2754. }
  2755. c.ServeSuccessJSON(map[string]interface{}{
  2756. "patient": patient,
  2757. "number": token,
  2758. "insutype": insutype,
  2759. })
  2760. }
  2761. }
  2762. } else {
  2763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2764. return
  2765. }
  2766. } else { //读卡失败
  2767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2768. return
  2769. }
  2770. }
  2771. break
  2772. case 4:
  2773. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2774. var api string
  2775. if miConfig.MdtrtareaAdmvs == "320921" {
  2776. 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 +
  2777. "&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
  2778. fmt.Println(api)
  2779. } else {
  2780. 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 +
  2781. "&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)
  2782. }
  2783. resp, requestErr := http.Get(api)
  2784. if requestErr != nil {
  2785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2786. return
  2787. }
  2788. body, ioErr := ioutil.ReadAll(resp.Body)
  2789. if ioErr != nil {
  2790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2792. return
  2793. }
  2794. var respJSON map[string]interface{}
  2795. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2798. return
  2799. }
  2800. var status string
  2801. status = respJSON["data"].(map[string]interface{})["status"].(string)
  2802. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  2803. var token string
  2804. var res ResultTwo //1101结果
  2805. var res10265 ResultTwo10265 //1101结果
  2806. if status == "0" { //读卡成功
  2807. var card_info string //卡信息
  2808. var busi_card_info string
  2809. token = respJSON["data"].(map[string]interface{})["token"].(string)
  2810. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  2811. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  2812. fmt.Println(card_info)
  2813. fmt.Println(busi_card_info)
  2814. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  2815. result, _ := json.Marshal(respJSON)
  2816. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2817. utils.ErrorLog("解析失败:%v", err)
  2818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2819. return
  2820. }
  2821. res.ErrMsg = res10265.ErrMsg
  2822. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2823. res.Infcode = infocode
  2824. res.Output = res10265.Output
  2825. res.InfRefmsgid = res10265.InfRefmsgid
  2826. if res.Infcode == 0 {
  2827. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2828. if err == gorm.ErrRecordNotFound {
  2829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2830. return
  2831. } else if err != nil {
  2832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2833. return
  2834. } else {
  2835. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2836. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2837. infoStr := string(Iinfos)
  2838. idetinfoStr := string(Idetinfos)
  2839. psn := &models.HisPsn{
  2840. PsnNo: res.Output.Baseinfo.PsnNo,
  2841. Age: res.Output.Baseinfo.Age,
  2842. PatientId: patient.ID,
  2843. Certno: res.Output.Baseinfo.Certno,
  2844. Brdy: res.Output.Baseinfo.Brdy,
  2845. Gend: res.Output.Baseinfo.Gend,
  2846. Naty: res.Output.Baseinfo.Naty,
  2847. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2848. PsnName: res.Output.Baseinfo.PsnName,
  2849. Idetinfo: idetinfoStr,
  2850. Insuinfo: infoStr,
  2851. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2852. CardInfo: card_info,
  2853. VerifyNumber: token,
  2854. }
  2855. var rf []*ResultFive
  2856. json.Unmarshal([]byte(infoStr), &rf)
  2857. var insutypes []*ResultFive
  2858. var insutype string
  2859. var is390 int = 0
  2860. var is310 int = 0
  2861. for _, item := range rf {
  2862. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2863. insutypes = append(insutypes, item)
  2864. }
  2865. }
  2866. if len(insutypes) == 1 {
  2867. insutype = insutypes[0].Insutype
  2868. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2869. } else {
  2870. for _, i := range insutypes {
  2871. if i.Insutype == "390" {
  2872. is390 = 1
  2873. }
  2874. if i.Insutype == "310" {
  2875. is310 = 1
  2876. }
  2877. }
  2878. }
  2879. if is390 == 1 {
  2880. insutype = "390"
  2881. }
  2882. if is310 == 1 {
  2883. insutype = "310"
  2884. }
  2885. if len(insutypes) == 0 {
  2886. insutype = "310"
  2887. }
  2888. service.CreateHisPsn(psn)
  2889. c.ServeSuccessJSON(map[string]interface{}{
  2890. "patient": patient,
  2891. "number": token,
  2892. "insutype": insutype,
  2893. })
  2894. }
  2895. } else {
  2896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2897. return
  2898. }
  2899. } else { //读卡失败
  2900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2901. return
  2902. }
  2903. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  2904. if initFlag == 0 {
  2905. c.TestGetBasBaseInit()
  2906. }
  2907. token := c.GetEleBaseInfo()
  2908. token = Remove0000(token)
  2909. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  2910. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2911. //
  2912. var res ResultTwo
  2913. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2914. utils.ErrorLog("解析失败:%v", err)
  2915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2916. return
  2917. }
  2918. if res.Infcode == 0 {
  2919. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2920. if err == gorm.ErrRecordNotFound {
  2921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2922. return
  2923. } else if err != nil {
  2924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2925. return
  2926. } else {
  2927. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2928. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2929. infoStr := string(Iinfos)
  2930. idetinfoStr := string(Idetinfos)
  2931. psn := &models.HisPsn{
  2932. PsnNo: res.Output.Baseinfo.PsnNo,
  2933. Age: res.Output.Baseinfo.Age,
  2934. PatientId: patient.ID,
  2935. Certno: res.Output.Baseinfo.Certno,
  2936. Brdy: res.Output.Baseinfo.Brdy,
  2937. Gend: res.Output.Baseinfo.Gend,
  2938. Naty: res.Output.Baseinfo.Naty,
  2939. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2940. PsnName: res.Output.Baseinfo.PsnName,
  2941. Idetinfo: idetinfoStr,
  2942. Insuinfo: infoStr,
  2943. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2944. CardInfo: "",
  2945. VerifyNumber: token,
  2946. }
  2947. service.CreateHisPsn(psn)
  2948. c.ServeSuccessJSON(map[string]interface{}{
  2949. "patient": patient,
  2950. "number": token,
  2951. })
  2952. }
  2953. } else {
  2954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2955. return
  2956. }
  2957. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2958. if initFlag == 0 {
  2959. c.TestGetBasBaseInit()
  2960. }
  2961. token := c.GetEleBaseInfo()
  2962. token = Remove0000(token)
  2963. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", "", "")
  2964. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2965. //
  2966. var res ResultTwo
  2967. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2968. utils.ErrorLog("解析失败:%v", err)
  2969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2970. return
  2971. }
  2972. if res.Infcode == 0 {
  2973. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2974. if err == gorm.ErrRecordNotFound {
  2975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2976. return
  2977. } else if err != nil {
  2978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2979. return
  2980. } else {
  2981. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2982. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2983. infoStr := string(Iinfos)
  2984. idetinfoStr := string(Idetinfos)
  2985. psn := &models.HisPsn{
  2986. PsnNo: res.Output.Baseinfo.PsnNo,
  2987. Age: res.Output.Baseinfo.Age,
  2988. PatientId: patient.ID,
  2989. Certno: res.Output.Baseinfo.Certno,
  2990. Brdy: res.Output.Baseinfo.Brdy,
  2991. Gend: res.Output.Baseinfo.Gend,
  2992. Naty: res.Output.Baseinfo.Naty,
  2993. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2994. PsnName: res.Output.Baseinfo.PsnName,
  2995. Idetinfo: idetinfoStr,
  2996. Insuinfo: infoStr,
  2997. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2998. CardInfo: "",
  2999. VerifyNumber: token,
  3000. }
  3001. service.CreateHisPsn(psn)
  3002. c.ServeSuccessJSON(map[string]interface{}{
  3003. "patient": patient,
  3004. "number": token,
  3005. })
  3006. }
  3007. } else {
  3008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3009. return
  3010. }
  3011. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3012. //if initFlag == 0 {
  3013. c.TestGetJiangXiBasBaseInit()
  3014. //}
  3015. //if initEleFlag == 0 {
  3016. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3017. //}
  3018. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3019. type ELeData struct {
  3020. Data struct {
  3021. IdNo string `json:"idNo"`
  3022. IdType string `json:"idType"`
  3023. UserName string `json:"userName"`
  3024. EcToken string `json:"ecToken"`
  3025. InsuOrg string `json:"insuOrg"`
  3026. Gender string `json:"gender"`
  3027. Birthday string `json:"birthday"`
  3028. Nationality string `json:"nationality"`
  3029. Email string `json:"email"`
  3030. Extra string `json:"extra"`
  3031. } `json:"data"`
  3032. Code int `json:"code"`
  3033. Message string `json:"message"`
  3034. }
  3035. var ele ELeData
  3036. err := json.Unmarshal([]byte(json_result), &ele)
  3037. if err != nil {
  3038. utils.ErrorLog("解析失败:%v", err)
  3039. }
  3040. token := ele.Data.EcToken
  3041. token = Remove0000(token)
  3042. 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)
  3043. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3044. var res ResultTwo
  3045. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3046. utils.ErrorLog("解析失败:%v", err)
  3047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3048. return
  3049. }
  3050. if res.Infcode == 0 {
  3051. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3052. if err == gorm.ErrRecordNotFound {
  3053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3054. return
  3055. } else if err != nil {
  3056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3057. return
  3058. } else {
  3059. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3060. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3061. infoStr := string(Iinfos)
  3062. idetinfoStr := string(Idetinfos)
  3063. psn := &models.HisPsn{
  3064. PsnNo: res.Output.Baseinfo.PsnNo,
  3065. Age: res.Output.Baseinfo.Age,
  3066. PatientId: patient.ID,
  3067. Certno: res.Output.Baseinfo.Certno,
  3068. Brdy: res.Output.Baseinfo.Brdy,
  3069. Gend: res.Output.Baseinfo.Gend,
  3070. Naty: res.Output.Baseinfo.Naty,
  3071. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3072. PsnName: res.Output.Baseinfo.PsnName,
  3073. Idetinfo: idetinfoStr,
  3074. Insuinfo: infoStr,
  3075. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3076. CardInfo: "",
  3077. VerifyNumber: token,
  3078. }
  3079. service.CreateHisPsn(psn)
  3080. var rf []*ResultFive
  3081. json.Unmarshal([]byte(infoStr), &rf)
  3082. var insutypes []*ResultFive
  3083. var insutype string
  3084. var is390 int = 0
  3085. var is310 int = 0
  3086. for _, item := range rf {
  3087. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3088. insutypes = append(insutypes, item)
  3089. }
  3090. }
  3091. if len(insutypes) == 1 {
  3092. insutype = insutypes[0].Insutype
  3093. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3094. } else {
  3095. for _, i := range insutypes {
  3096. if i.Insutype == "390" {
  3097. is390 = 1
  3098. }
  3099. if i.Insutype == "310" {
  3100. is310 = 1
  3101. }
  3102. }
  3103. }
  3104. if is390 == 1 {
  3105. insutype = "390"
  3106. }
  3107. if is310 == 1 {
  3108. insutype = "310"
  3109. }
  3110. if len(insutypes) == 0 {
  3111. insutype = "310"
  3112. }
  3113. c.ServeSuccessJSON(map[string]interface{}{
  3114. "patient": patient,
  3115. "number": token,
  3116. "insutype": insutype,
  3117. })
  3118. }
  3119. } else {
  3120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3121. return
  3122. }
  3123. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3124. //if initFlag == 0 {
  3125. c.TestGetJiangXiBasBaseInit()
  3126. //}
  3127. //if initEleFlag == 0 {
  3128. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  3129. //}
  3130. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  3131. type ELeData struct {
  3132. Data struct {
  3133. IdNo string `json:"idNo"`
  3134. IdType string `json:"idType"`
  3135. UserName string `json:"userName"`
  3136. EcToken string `json:"ecToken"`
  3137. InsuOrg string `json:"insuOrg"`
  3138. Gender string `json:"gender"`
  3139. Birthday string `json:"birthday"`
  3140. Nationality string `json:"nationality"`
  3141. Email string `json:"email"`
  3142. Extra string `json:"extra"`
  3143. } `json:"data"`
  3144. Code int `json:"code"`
  3145. Message string `json:"message"`
  3146. }
  3147. var ele ELeData
  3148. err := json.Unmarshal([]byte(json_result), &ele)
  3149. if err != nil {
  3150. utils.ErrorLog("解析失败:%v", err)
  3151. }
  3152. token := ele.Data.EcToken
  3153. token = Remove0000(token)
  3154. 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)
  3155. saveLog(result2, requestLog2, "1101", "获取人员信息")
  3156. var res ResultTwo
  3157. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  3158. utils.ErrorLog("解析失败:%v", err)
  3159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3160. return
  3161. }
  3162. if res.Infcode == 0 {
  3163. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3164. if err == gorm.ErrRecordNotFound {
  3165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3166. return
  3167. } else if err != nil {
  3168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3169. return
  3170. } else {
  3171. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3172. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3173. infoStr := string(Iinfos)
  3174. idetinfoStr := string(Idetinfos)
  3175. psn := &models.HisPsn{
  3176. PsnNo: res.Output.Baseinfo.PsnNo,
  3177. Age: res.Output.Baseinfo.Age,
  3178. PatientId: patient.ID,
  3179. Certno: res.Output.Baseinfo.Certno,
  3180. Brdy: res.Output.Baseinfo.Brdy,
  3181. Gend: res.Output.Baseinfo.Gend,
  3182. Naty: res.Output.Baseinfo.Naty,
  3183. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3184. PsnName: res.Output.Baseinfo.PsnName,
  3185. Idetinfo: idetinfoStr,
  3186. Insuinfo: infoStr,
  3187. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3188. CardInfo: "",
  3189. VerifyNumber: token,
  3190. }
  3191. service.CreateHisPsn(psn)
  3192. var rf []*ResultFive
  3193. json.Unmarshal([]byte(infoStr), &rf)
  3194. var insutypes []*ResultFive
  3195. var insutype string
  3196. var is390 int = 0
  3197. var is310 int = 0
  3198. for _, item := range rf {
  3199. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3200. insutypes = append(insutypes, item)
  3201. }
  3202. }
  3203. if len(insutypes) == 1 {
  3204. insutype = insutypes[0].Insutype
  3205. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3206. } else {
  3207. for _, i := range insutypes {
  3208. if i.Insutype == "390" {
  3209. is390 = 1
  3210. }
  3211. if i.Insutype == "310" {
  3212. is310 = 1
  3213. }
  3214. }
  3215. }
  3216. if is390 == 1 {
  3217. insutype = "390"
  3218. }
  3219. if is310 == 1 {
  3220. insutype = "310"
  3221. }
  3222. if len(insutypes) == 0 {
  3223. insutype = "310"
  3224. }
  3225. c.ServeSuccessJSON(map[string]interface{}{
  3226. "patient": patient,
  3227. "number": token,
  3228. "insutype": insutype,
  3229. })
  3230. }
  3231. } else {
  3232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3233. return
  3234. }
  3235. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3236. type ELeData struct {
  3237. Code string `json:"code"`
  3238. Data struct {
  3239. Aac002 string `json:"aac002"`
  3240. Aaz500 string `json:"aaz500"`
  3241. ActCardNo string `json:"actCardNo"`
  3242. Bab520 string `json:"bab520"`
  3243. Bkz543 string `json:"bkz543"`
  3244. BusinessType string `json:"businessType"`
  3245. CertfCodg string `json:"certfCodg"`
  3246. EcIndexNo string `json:"ecIndexNo"`
  3247. EcToken string `json:"ecToken"`
  3248. ID0000 string `json:"id0000"`
  3249. IDNo string `json:"idNo"`
  3250. IDType string `json:"idType"`
  3251. Idcode string `json:"idcode"`
  3252. IdentityToken string `json:"identity_token"`
  3253. InsuOrg string `json:"insuOrg"`
  3254. OfficeID string `json:"officeId"`
  3255. OfficeName string `json:"officeName"`
  3256. OperatorID string `json:"operatorId"`
  3257. OperatorName string `json:"operatorName"`
  3258. OrgID string `json:"orgId"`
  3259. UserName string `json:"userName"`
  3260. } `json:"data"`
  3261. Infno interface{} `json:"infno"`
  3262. Message string `json:"message"`
  3263. OrgID string `json:"orgId"`
  3264. TransType string `json:"transType"`
  3265. }
  3266. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  3267. outPutInfo = Remove0000(outPutInfo)
  3268. if len(outPutInfo) > 0 {
  3269. var ele ELeData
  3270. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3271. if err != nil {
  3272. utils.ErrorLog("解析失败:%v", err)
  3273. }
  3274. token := ele.Data.EcToken
  3275. fmt.Println(inputInfo)
  3276. fmt.Println(outPutInfo)
  3277. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IDNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, "", 1, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token, ele.Data.UserName)
  3278. saveLog(result, requestLog, "1101", "获取人员信息")
  3279. var dat map[string]interface{}
  3280. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3281. fmt.Println(dat)
  3282. } else {
  3283. fmt.Println(err)
  3284. }
  3285. userJSONBytes, _ := json.Marshal(dat)
  3286. var res ResultTwo
  3287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3288. utils.ErrorLog("解析失败:%v", err)
  3289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3290. return
  3291. }
  3292. res.ErrMsg = errMsgLog
  3293. if res.Infcode == 0 {
  3294. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  3295. if err == gorm.ErrRecordNotFound {
  3296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3297. return
  3298. } else if err != nil {
  3299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3300. return
  3301. } else {
  3302. fmt.Println(res)
  3303. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3304. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3305. infoStr := string(Iinfos)
  3306. idetinfoStr := string(Idetinfos)
  3307. psn := &models.HisPsn{
  3308. PsnNo: res.Output.Baseinfo.PsnNo,
  3309. Age: res.Output.Baseinfo.Age,
  3310. PatientId: patient.ID,
  3311. Certno: res.Output.Baseinfo.Certno,
  3312. Brdy: res.Output.Baseinfo.Brdy,
  3313. Gend: res.Output.Baseinfo.Gend,
  3314. Naty: res.Output.Baseinfo.Naty,
  3315. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3316. PsnName: res.Output.Baseinfo.PsnName,
  3317. Idetinfo: idetinfoStr,
  3318. Insuinfo: infoStr,
  3319. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3320. CardInfo: outPutInfo,
  3321. VerifyNumber: token,
  3322. }
  3323. service.CreateHisPsn(psn)
  3324. var rf []*ResultFive
  3325. json.Unmarshal([]byte(infoStr), &rf)
  3326. var insutypes []*ResultFive
  3327. var insutype string
  3328. var is390 int = 0
  3329. var is310 int = 0
  3330. for _, item := range rf {
  3331. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3332. insutypes = append(insutypes, item)
  3333. }
  3334. }
  3335. if len(insutypes) == 1 {
  3336. insutype = insutypes[0].Insutype
  3337. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3338. } else {
  3339. for _, i := range insutypes {
  3340. if i.Insutype == "390" {
  3341. is390 = 1
  3342. }
  3343. if i.Insutype == "310" {
  3344. is310 = 1
  3345. }
  3346. }
  3347. }
  3348. if is390 == 1 {
  3349. insutype = "390"
  3350. }
  3351. if is310 == 1 {
  3352. insutype = "310"
  3353. }
  3354. if len(insutypes) == 0 {
  3355. insutype = "310"
  3356. }
  3357. c.ServeSuccessJSON(map[string]interface{}{
  3358. "patient": patient,
  3359. "number": token,
  3360. "insutype": insutype,
  3361. })
  3362. }
  3363. } else {
  3364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3365. return
  3366. }
  3367. }
  3368. }
  3369. break
  3370. }
  3371. }
  3372. var initFlag int64 = 0
  3373. var initEleFlag int64 = 0
  3374. func (c *HisApiController) TestGetBasBaseInit() {
  3375. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3376. Iinit := DllDef.MustFindProc("Init")
  3377. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3378. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  3379. if ret != 0 {
  3380. fmt.Println("SSCard的报错原因:", err)
  3381. fmt.Println("SSCard的运算结果为:", ret)
  3382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3383. return
  3384. }
  3385. result := int(ret)
  3386. fmt.Println("SSCard的运算结果为1:", result)
  3387. initFlag = 1
  3388. return
  3389. }
  3390. func (c *HisApiController) HandleJiangXiReadCard() {
  3391. fmt.Println("~~~~~~")
  3392. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3393. admin_user_id, _ := c.GetInt64("admin_user_id")
  3394. id_card_type, _ := c.GetInt64("id_card_type")
  3395. //certificates, _ := c.GetInt64("certificates")
  3396. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3397. if initFlag == 0 {
  3398. c.TestGetJiangXiBasBaseInit()
  3399. }
  3400. basStr := c.GetBasBaseInfo()
  3401. if len(basStr) == 0 {
  3402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3403. return
  3404. }
  3405. fmt.Println(basStr)
  3406. bas := strings.Split(basStr, "|")
  3407. basNumber := bas[1]
  3408. fmt.Println(basNumber)
  3409. card_sn := bas[3]
  3410. fmt.Println(card_sn)
  3411. 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, "")
  3412. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3413. var dat map[string]interface{}
  3414. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3415. fmt.Println(dat)
  3416. } else {
  3417. fmt.Println(err)
  3418. }
  3419. userJSONBytes, _ := json.Marshal(dat)
  3420. var res ResultTwo
  3421. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3422. utils.ErrorLog("解析失败:%v", err)
  3423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3424. return
  3425. }
  3426. if res.Infcode == 0 {
  3427. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3428. if err == gorm.ErrRecordNotFound {
  3429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3430. return
  3431. } else if err != nil {
  3432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3433. return
  3434. } else {
  3435. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3436. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3437. infoStr := string(Iinfos)
  3438. idetinfoStr := string(Idetinfos)
  3439. psn := &models.HisPsn{
  3440. PsnNo: res.Output.Baseinfo.PsnNo,
  3441. Age: res.Output.Baseinfo.Age,
  3442. PatientId: patient.ID,
  3443. Certno: res.Output.Baseinfo.Certno,
  3444. Brdy: res.Output.Baseinfo.Brdy,
  3445. Gend: res.Output.Baseinfo.Gend,
  3446. Naty: res.Output.Baseinfo.Naty,
  3447. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3448. PsnName: res.Output.Baseinfo.PsnName,
  3449. Idetinfo: idetinfoStr,
  3450. Insuinfo: infoStr,
  3451. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3452. CardInfo: basStr,
  3453. VerifyNumber: "",
  3454. }
  3455. service.CreateHisPsn(psn)
  3456. c.ServeSuccessJSON(map[string]interface{}{
  3457. "patient": patient,
  3458. "number": basNumber,
  3459. })
  3460. }
  3461. } else {
  3462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3463. return
  3464. }
  3465. }
  3466. func (c *HisApiController) TestGetHnBasBaseInit() {
  3467. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3468. Iinit := DllDef.MustFindProc("Init")
  3469. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3470. //http://10.77.211.236/CSB/hsa-fsi-1303
  3471. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  3472. if ret != 0 {
  3473. fmt.Println("SSCard的报错原因:", err)
  3474. fmt.Println("SSCard的运算结果为:", ret)
  3475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3476. return
  3477. }
  3478. result := int(ret)
  3479. fmt.Println("SSCard的运算结果为1:", result)
  3480. initFlag = 1
  3481. return
  3482. }
  3483. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  3484. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3485. Iinit := DllDef.MustFindProc("Init")
  3486. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3487. //http://10.77.211.236/CSB/hsa-fsi-1303
  3488. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  3489. if ret != 0 {
  3490. fmt.Println("SSCard的报错原因:", err)
  3491. fmt.Println("SSCard的运算结果为:", ret)
  3492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3493. return
  3494. }
  3495. result := int(ret)
  3496. fmt.Println("SSCard的运算结果为1:", result)
  3497. initFlag = 1
  3498. return
  3499. }
  3500. func (c *HisApiController) GetSFZBaseInfo() string {
  3501. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3502. readCard := DllDef.MustFindProc("ReadSFZ")
  3503. if readCard == nil {
  3504. fmt.Println("readcard is nil")
  3505. readCard = DllDef.MustFindProc("ReadSFZ")
  3506. }
  3507. str := make([]byte, 8096)
  3508. str1 := make([]byte, 8096)
  3509. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  3510. fmt.Println(r)
  3511. return Remove0000(string(str))
  3512. }
  3513. func (c *HisApiController) GetEleBaseInfo() string {
  3514. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3515. readCard := DllDef.MustFindProc("GetQRBase")
  3516. fmt.Println(readCard)
  3517. if readCard == nil {
  3518. fmt.Println("readcard is nil")
  3519. readCard = DllDef.MustFindProc("GetQRBase")
  3520. }
  3521. str := make([]byte, 1024)
  3522. str1 := make([]byte, 1024)
  3523. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3524. fmt.Println(ret2)
  3525. fmt.Println(string(str1))
  3526. fmt.Println(string(str))
  3527. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3528. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3529. if ret2 != 0 {
  3530. return ""
  3531. }
  3532. return string(str)
  3533. }
  3534. func GetJxEleBaseInfo(org_id int64) string {
  3535. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3536. readCard := DllDef.MustFindProc("NationEcTrans")
  3537. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3538. if readCard == nil {
  3539. fmt.Println("readcard is nil")
  3540. readCard = DllDef.MustFindProc("NationEcTrans")
  3541. }
  3542. str1 := make([]byte, 1024)
  3543. data := make(map[string]interface{})
  3544. inputData := make(map[string]interface{})
  3545. inputData["orgId"] = miConfig.Code
  3546. inputData["businessType"] = "01101"
  3547. inputData["operatorId"] = "test001"
  3548. inputData["operatorName"] = "cn"
  3549. inputData["officeId"] = "32760"
  3550. inputData["officeName"] = "waike"
  3551. inputData["deviceType"] = ""
  3552. data["data"] = inputData
  3553. data["transType"] = "ec.query"
  3554. data["extra "] = ""
  3555. data["orgId"] = miConfig.Code
  3556. bytesData, _ := json.Marshal(data)
  3557. //bytesData, _ := json.Marshal(data)
  3558. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3559. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3560. fmt.Println(ret2)
  3561. fmt.Println(string(str1))
  3562. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3563. if ret2 != 0 {
  3564. return ""
  3565. }
  3566. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3567. }
  3568. func GetJxEleBaseInitInfo(org_id int64) string {
  3569. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3570. readCard := DllDef.MustFindProc("NationEcTrans")
  3571. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  3572. if readCard == nil {
  3573. fmt.Println("readcard is nil")
  3574. readCard = DllDef.MustFindProc("NationEcTrans")
  3575. }
  3576. str1 := make([]byte, 2048)
  3577. data := make(map[string]interface{})
  3578. inputData := make(map[string]interface{})
  3579. inputData["orgId"] = miConfig.Code
  3580. inputData["businessType"] = "01101"
  3581. inputData["operatorId"] = "1"
  3582. inputData["operatorName"] = "huangchuang"
  3583. inputData["officeId"] = "101"
  3584. inputData["officeName"] = "xuetou"
  3585. inputData["deviceType"] = ""
  3586. data["data"] = inputData
  3587. data["transType"] = "ec.query"
  3588. data["orgId"] = miConfig.Code
  3589. bytesData, _ := json.Marshal(data)
  3590. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  3591. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  3592. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  3593. fmt.Println(ret2)
  3594. fmt.Println(string(str1))
  3595. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3596. if ret2 != 0 {
  3597. return ""
  3598. }
  3599. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  3600. initEleFlag = 1
  3601. }
  3602. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  3603. }
  3604. func (c *HisApiController) GetBasBaseInfo() string {
  3605. DllDef := syscall.MustLoadDLL("SSCard.dll")
  3606. readCard := DllDef.MustFindProc("ReadCardBas")
  3607. if readCard == nil {
  3608. fmt.Println("readcard is nil")
  3609. readCard = DllDef.MustFindProc("ReadCardBas")
  3610. }
  3611. str := make([]byte, 1024)
  3612. str1 := make([]byte, 1024)
  3613. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  3614. fmt.Println(string(str1))
  3615. fmt.Println(string(str))
  3616. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3617. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3618. if ret2 != 0 {
  3619. return ""
  3620. }
  3621. return string(str)
  3622. }
  3623. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  3624. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  3625. readCard := DllDef.MustFindProc("read_cardinfo")
  3626. if readCard == nil {
  3627. fmt.Println("readcard is nil")
  3628. readCard = DllDef.MustFindProc("read_cardinfo")
  3629. }
  3630. str := make([]byte, 1024) //卡号
  3631. str1 := make([]byte, 1024) //卡识别码
  3632. str2 := make([]byte, 1024) //身份证号
  3633. str3 := make([]byte, 1024) //姓名
  3634. str4 := make([]byte, 1024) //错误信息
  3635. 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])))
  3636. fmt.Println(string(str1))
  3637. fmt.Println(string(str))
  3638. fmt.Println(string(str2))
  3639. fmt.Println(string(str3))
  3640. fmt.Println(string(str4))
  3641. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  3642. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  3643. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  3644. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3645. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  3646. if ret2 != 0 {
  3647. return "", "", "", "", ""
  3648. }
  3649. return string(str), string(str1), string(str2), string(str3), string(str4)
  3650. }
  3651. type CustomFundPay struct {
  3652. FundPayType string `json:"fund_pay_type"`
  3653. FundPayamt float64 `json:"fund_payamt"`
  3654. }
  3655. func (c *HisApiController) GetSettleList() {
  3656. order_id, _ := c.GetInt64("order_id")
  3657. admin_user_id, _ := c.GetInt64("admin_user_id")
  3658. order, _ := service.GetHisOrderByIDTwo(order_id)
  3659. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  3660. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3661. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  3662. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3663. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  3664. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3665. if order.ID == 0 {
  3666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3667. return
  3668. }
  3669. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  3670. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  3671. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  3672. fmt.Println(count)
  3673. var zero string
  3674. number := count + 1
  3675. if number >= 1000 {
  3676. zero = "0000" + strconv.FormatInt(number, 10)
  3677. } else if number >= 10000 {
  3678. zero = "000" + strconv.FormatInt(number, 10)
  3679. } else if number >= 100000 {
  3680. zero = "00" + strconv.FormatInt(number, 10)
  3681. } else if number >= 1000000 {
  3682. zero = "0" + strconv.FormatInt(number, 10)
  3683. } else {
  3684. zero = strconv.FormatInt(number, 10)
  3685. }
  3686. fmt.Println(zero)
  3687. struct4101 := service.Struct4101{
  3688. PsnNo: order.PsnNo,
  3689. MdtrtId: order.MdtrtId,
  3690. SetlId: order.SetlId,
  3691. PsnName: order.PsnName,
  3692. Gend: order.Gend,
  3693. Brdy: his.Brdy,
  3694. Age: his.Age,
  3695. Naty: order.Naty,
  3696. PatnCertType: "01",
  3697. Certno: order.Certno,
  3698. Prfs: "90",
  3699. ConerName: roles[0].UserName,
  3700. PatnRlts: "99",
  3701. ConerAddr: miConfig.OrgName,
  3702. ConerTel: admin.Mobile,
  3703. HiType: order.Insutype,
  3704. Insuplc: miConfig.InsuplcAdmdvs,
  3705. MaindiagFlag: "1",
  3706. BillCode: order.SetlId,
  3707. BillNo: order.SetlId,
  3708. BizSn: order.Number,
  3709. PsnSelfPay: order.PsnPartAmt,
  3710. PsnOwnPay: order.PsnPartAmt,
  3711. AcctPay: order.AcctPay,
  3712. PsnCashpay: order.PsnCashPay,
  3713. HiPaymtd: "1",
  3714. Hsorg: miConfig.InsuplcAdmdvs,
  3715. HsorgOpter: miConfig.InsuplcAdmdvs,
  3716. MedinsFillPsn: curRoles.UserName,
  3717. MedinsFillDept: depart.Name,
  3718. IptMedType: "2",
  3719. }
  3720. struct4101.SetlBegnDate = order.SetlTime
  3721. struct4101.SetlEndDate = order.SetlTime
  3722. time_arr := strings.Split(order.SetlTime, " ")
  3723. struct4101.AdmTime = time_arr[0]
  3724. struct4101.AdmEndTime = time_arr[0]
  3725. var rf []CustomFundPay
  3726. json.Unmarshal([]byte(order.SetlDetail), &rf)
  3727. var tempFunPays []service.CustomStruct
  3728. for _, item := range rf {
  3729. var tempFunPay service.CustomStruct
  3730. tempFunPay.FundPayamt = item.FundPayamt
  3731. tempFunPay.FundPayType = item.FundPayType
  3732. tempFunPays = append(tempFunPays, tempFunPay)
  3733. }
  3734. struct4101.CustomStruct = tempFunPays
  3735. var tempDiaginfos []service.DiaginfoStructTwo
  3736. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  3737. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  3738. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3739. var config []*models.HisXtDiagnoseConfig
  3740. for _, item := range diagnosis_ids {
  3741. id, _ := strconv.ParseInt(item, 10, 64)
  3742. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3743. config = append(config, &diagnosisConfig)
  3744. }
  3745. for index, item := range config {
  3746. if index == 0 {
  3747. var tempDiaginfo service.DiaginfoStructTwo
  3748. tempDiaginfo.DiagCode = item.CountryCode
  3749. tempDiaginfo.DiagName = item.CountryContentName
  3750. tempDiaginfo.DiagType = "1"
  3751. tempDiaginfo.MaindiagFlag = "1"
  3752. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3753. } else {
  3754. var tempDiaginfo service.DiaginfoStructTwo
  3755. tempDiaginfo.DiagCode = item.CountryCode
  3756. tempDiaginfo.DiagName = item.CountryContentName
  3757. tempDiaginfo.DiagType = "2"
  3758. tempDiaginfo.MaindiagFlag = "0"
  3759. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3760. }
  3761. }
  3762. struct4101.Diseinfo = tempDiaginfos
  3763. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3764. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3765. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3766. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  3767. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  3768. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3769. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3770. var iteminfo service.IteminfoStruct
  3771. var bedCostTotal float64 = 0 //床位总费
  3772. var bedCostSelfTotal float64 = 0 //床位自费
  3773. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3774. var operationCostTotal float64 = 0 //手术费
  3775. var operationCostSelfTotal float64 = 0 //手术费
  3776. var operationCostPartSelfTotal float64 = 0 //手术费
  3777. var otherCostTotal float64 = 0 //其他费用
  3778. var otherCostSelfTotal float64 = 0 //其他费用
  3779. var otherCostPartSelfTotal float64 = 0 //其他费用
  3780. var materialCostTotal float64 = 0 //材料费
  3781. var materialCostSelfTotal float64 = 0 //材料费
  3782. var materialCostPartSelfTotal float64 = 0 //材料费
  3783. var westernMedicineCostTotal float64 = 0 //西药费
  3784. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3785. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3786. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3787. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3788. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3789. var checkCostTotal float64 = 0 //检查费
  3790. var checkCostSelfTotal float64 = 0 //检查费
  3791. var checkCostPartSelfTotal float64 = 0 //检查费
  3792. var laboratoryCostTotal float64 = 0 //化验费
  3793. var laboratoryCostSelfTotal float64 = 0 //化验费
  3794. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3795. var treatCostTotal float64 = 0 //治疗费用
  3796. var treatCostSelfTotal float64 = 0 //治疗费用
  3797. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3798. decimal.DivisionPrecision = 2
  3799. var bed_fulamt_ownpay_amt float64 = 0
  3800. var operation_fulamt_ownpay_amt float64 = 0
  3801. var other_fulamt_ownpay_amt float64 = 0
  3802. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3803. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3804. var check_fulamt_ownpay_amt float64 = 0
  3805. var material_fulamt_ownpay_amt float64 = 0
  3806. var laboratory_fulamt_ownpay_amt float64 = 0
  3807. var treat_fulamt_ownpay_amt float64 = 0
  3808. var bed_claa_sunmfee float64 = 0
  3809. var bed_clab_amt float64 = 0
  3810. var bed_other_amt float64 = 0
  3811. var operation_claa_sunmfee float64 = 0
  3812. var operation_clab_amt float64 = 0
  3813. var operation_other_amt float64 = 0
  3814. var other_claa_sunmfee float64 = 0
  3815. var other_clab_amt float64 = 0
  3816. var other_other_amt float64 = 0
  3817. var westernMedicine_claa_sunmfee float64 = 0
  3818. var westernMedicine_clab_amt float64 = 0
  3819. var westernMedicine_other_amt float64 = 0
  3820. var chineseTraditional_claa_sunmfee float64 = 0
  3821. var chineseTraditional_clab_amt float64 = 0
  3822. var chineseTraditional_other_amt float64 = 0
  3823. var check_claa_sunmfee float64 = 0
  3824. var check_clab_amt float64 = 0
  3825. var check_other_amt float64 = 0
  3826. var material_claa_sunmfee float64 = 0
  3827. var material_clab_amt float64 = 0
  3828. var material_other_amt float64 = 0
  3829. var laboratory_claa_sunmfee float64 = 0
  3830. var laboratory_clab_amt float64 = 0
  3831. var laboratory_other_amt float64 = 0
  3832. var treat_claa_sunmfee float64 = 0
  3833. var treat_clab_amt float64 = 0
  3834. var treat_other_amt float64 = 0
  3835. for _, item := range order.HisOrderInfo {
  3836. if item.MedChrgitmType == "01" { //床位费
  3837. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3838. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3839. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3840. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3841. if item.ChrgitmLv == "1" {
  3842. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3843. }
  3844. if item.ChrgitmLv == "2" {
  3845. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3846. }
  3847. if item.ChrgitmLv == "3" {
  3848. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3849. }
  3850. }
  3851. if item.MedChrgitmType == "03" { //检查费
  3852. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3853. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3854. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3855. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3856. if item.ChrgitmLv == "1" {
  3857. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3858. }
  3859. if item.ChrgitmLv == "2" {
  3860. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3861. }
  3862. if item.ChrgitmLv == "3" {
  3863. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3864. }
  3865. }
  3866. if item.MedChrgitmType == "04" { //化验费
  3867. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3868. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3869. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3870. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3871. if item.ChrgitmLv == "1" {
  3872. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3873. }
  3874. if item.ChrgitmLv == "2" {
  3875. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3876. }
  3877. if item.ChrgitmLv == "3" {
  3878. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3879. }
  3880. }
  3881. if item.MedChrgitmType == "05" { //治疗费
  3882. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3883. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3884. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3885. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3886. if item.ChrgitmLv == "1" {
  3887. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3888. }
  3889. if item.ChrgitmLv == "2" {
  3890. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3891. }
  3892. if item.ChrgitmLv == "3" {
  3893. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3894. }
  3895. }
  3896. if item.MedChrgitmType == "06" { //手术费
  3897. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3898. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3899. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3900. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3901. if item.ChrgitmLv == "1" {
  3902. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3903. }
  3904. if item.ChrgitmLv == "2" {
  3905. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3906. }
  3907. if item.ChrgitmLv == "3" {
  3908. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3909. }
  3910. }
  3911. if item.MedChrgitmType == "08" { //材料费
  3912. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3913. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3914. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3915. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3916. if item.ChrgitmLv == "1" {
  3917. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3918. }
  3919. if item.ChrgitmLv == "2" {
  3920. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3921. }
  3922. if item.ChrgitmLv == "3" {
  3923. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3924. }
  3925. }
  3926. if item.MedChrgitmType == "09" { //西药费
  3927. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3928. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3929. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3930. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3931. if item.ChrgitmLv == "1" {
  3932. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3933. }
  3934. if item.ChrgitmLv == "2" {
  3935. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3936. }
  3937. if item.ChrgitmLv == "3" {
  3938. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3939. }
  3940. }
  3941. if item.MedChrgitmType == "11" { //中成费
  3942. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3943. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3944. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3945. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3946. if item.ChrgitmLv == "1" {
  3947. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3948. }
  3949. if item.ChrgitmLv == "2" {
  3950. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3951. }
  3952. if item.ChrgitmLv == "3" {
  3953. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3954. }
  3955. }
  3956. if item.MedChrgitmType == "14" { //其他费
  3957. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3958. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3959. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3960. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3961. if item.ChrgitmLv == "1" {
  3962. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3963. }
  3964. if item.ChrgitmLv == "2" {
  3965. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3966. }
  3967. if item.ChrgitmLv == "3" {
  3968. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3969. }
  3970. }
  3971. }
  3972. var iteminfoStructs []service.IteminfoStruct
  3973. if bedCostTotal != 0 {
  3974. iteminfo.MedChrgitm = "01"
  3975. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3976. iteminfo.Amt = bedCostTotal
  3977. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3978. iteminfo.ClabAmt = bed_clab_amt
  3979. iteminfo.OthAmt = bed_other_amt
  3980. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3981. }
  3982. if checkCostTotal != 0 {
  3983. iteminfo.MedChrgitm = "03"
  3984. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3985. iteminfo.Amt = checkCostTotal
  3986. iteminfo.ClaaSumfee = check_claa_sunmfee
  3987. iteminfo.ClabAmt = check_clab_amt
  3988. iteminfo.OthAmt = check_other_amt
  3989. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3990. }
  3991. if laboratoryCostTotal != 0 {
  3992. iteminfo.MedChrgitm = "04"
  3993. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3994. iteminfo.Amt = laboratoryCostTotal
  3995. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3996. iteminfo.ClabAmt = laboratory_clab_amt
  3997. iteminfo.OthAmt = laboratory_other_amt
  3998. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3999. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4000. }
  4001. if treatCostTotal != 0 {
  4002. iteminfo.MedChrgitm = "05"
  4003. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4004. iteminfo.Amt = treatCostTotal
  4005. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4006. iteminfo.ClabAmt = treat_clab_amt
  4007. iteminfo.OthAmt = treat_other_amt
  4008. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4009. //(struct4101.IteminfoStruct, iteminfo)
  4010. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4011. }
  4012. if operationCostTotal != 0 {
  4013. iteminfo.MedChrgitm = "06"
  4014. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4015. iteminfo.Amt = operationCostTotal
  4016. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4017. iteminfo.ClabAmt = operation_clab_amt
  4018. iteminfo.OthAmt = operation_other_amt
  4019. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4020. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4021. }
  4022. if materialCostTotal != 0 {
  4023. iteminfo.MedChrgitm = "08"
  4024. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4025. iteminfo.Amt = materialCostTotal
  4026. iteminfo.ClaaSumfee = material_claa_sunmfee
  4027. iteminfo.ClabAmt = material_clab_amt
  4028. iteminfo.OthAmt = material_other_amt
  4029. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4030. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4031. }
  4032. if westernMedicineCostTotal != 0 {
  4033. iteminfo.MedChrgitm = "09"
  4034. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4035. iteminfo.Amt = westernMedicineCostTotal
  4036. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4037. iteminfo.ClabAmt = westernMedicine_clab_amt
  4038. iteminfo.OthAmt = westernMedicine_other_amt
  4039. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4040. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4041. }
  4042. if chineseTraditionalMedicineCostTotal != 0 {
  4043. iteminfo.MedChrgitm = "11"
  4044. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4045. iteminfo.Amt = westernMedicineCostTotal
  4046. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4047. iteminfo.ClabAmt = westernMedicine_clab_amt
  4048. iteminfo.OthAmt = westernMedicine_other_amt
  4049. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4050. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4051. }
  4052. if otherCostTotal != 0 {
  4053. iteminfo.MedChrgitm = "14"
  4054. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4055. iteminfo.Amt = otherCostTotal
  4056. iteminfo.ClaaSumfee = other_claa_sunmfee
  4057. iteminfo.ClabAmt = other_clab_amt
  4058. iteminfo.OthAmt = other_other_amt
  4059. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4060. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4061. }
  4062. struct4101.IteminfoStruct = iteminfoStructs
  4063. struct4101.Ntly = "中国"
  4064. struct4101.AdmCaty = "A03.06"
  4065. var res ResultSeventeen
  4066. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4067. struct4101.BillCode = order.Number
  4068. struct4101.BillNo = order.SetlId
  4069. var resOther ResultSeventeenOther
  4070. var pp models.PublicParams
  4071. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4072. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4073. pp.FixmedinsName = miConfig.OrgName
  4074. pp.FixmedinsCode = miConfig.Code
  4075. pp.RequestUrl = miConfig.Url
  4076. pp.Cainfo = miConfig.Cainfo
  4077. pp.SecretKey = miConfig.SecretKey
  4078. pp.AccessKey = miConfig.AccessKey
  4079. pp.OpterName = curRoles.UserName
  4080. client := &http.Client{}
  4081. var req *http.Request
  4082. data := make(map[string]interface{})
  4083. data["struct4101"] = struct4101
  4084. data["pp"] = pp
  4085. bytesData, _ := json.Marshal(data)
  4086. if miConfig.MdtrtareaAdmvs == "320921" {
  4087. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4088. } else {
  4089. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  4090. }
  4091. resp, _ := client.Do(req)
  4092. defer resp.Body.Close()
  4093. body, ioErr := ioutil.ReadAll(resp.Body)
  4094. if ioErr != nil {
  4095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4097. return
  4098. }
  4099. var respJSON map[string]interface{}
  4100. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4103. return
  4104. }
  4105. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4106. userJSONBytes, _ := json.Marshal(respJSON)
  4107. fmt.Println("log")
  4108. fmt.Println(string(userJSONBytes))
  4109. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4110. utils.ErrorLog("解析失败:%v", err)
  4111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4112. return
  4113. }
  4114. res.InfRefmsgid = resOther.InfRefmsgid
  4115. res.Output = resOther.Output
  4116. res.ErrMsg = resOther.ErrMsg
  4117. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4118. res.Infcode = infocode
  4119. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4120. var pp models.PublicParams
  4121. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4122. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4123. pp.FixmedinsName = miConfig.OrgName
  4124. pp.FixmedinsCode = miConfig.Code
  4125. pp.RequestUrl = miConfig.Url
  4126. pp.Cainfo = miConfig.Cainfo
  4127. pp.SecretKey = miConfig.SecretKey
  4128. pp.AccessKey = miConfig.AccessKey
  4129. pp.OpterName = curRoles.UserName
  4130. result, _ := service.Jxyb4101(struct4101, pp)
  4131. var dat map[string]interface{}
  4132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4133. fmt.Println(dat)
  4134. } else {
  4135. fmt.Println(err)
  4136. }
  4137. userJSONBytes, _ := json.Marshal(dat)
  4138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4139. utils.ErrorLog("解析失败:%v", err)
  4140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4141. return
  4142. }
  4143. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4144. var pp models.PublicParams
  4145. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4146. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4147. pp.FixmedinsName = miConfig.OrgName
  4148. pp.FixmedinsCode = miConfig.Code
  4149. pp.RequestUrl = miConfig.Url
  4150. pp.Cainfo = miConfig.Cainfo
  4151. pp.SecretKey = miConfig.SecretKey
  4152. pp.AccessKey = miConfig.AccessKey
  4153. pp.OpterName = curRoles.UserName
  4154. result, _ := service.Hnyb4101(struct4101, pp)
  4155. var dat map[string]interface{}
  4156. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4157. fmt.Println(dat)
  4158. } else {
  4159. fmt.Println(err)
  4160. }
  4161. userJSONBytes, _ := json.Marshal(dat)
  4162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4163. utils.ErrorLog("解析失败:%v", err)
  4164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4165. return
  4166. }
  4167. } else {
  4168. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  4169. var dat map[string]interface{}
  4170. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4171. fmt.Println(dat)
  4172. } else {
  4173. fmt.Println(err)
  4174. }
  4175. userJSONBytes, _ := json.Marshal(dat)
  4176. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4177. utils.ErrorLog("解析失败:%v", err)
  4178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4179. return
  4180. }
  4181. }
  4182. if res.Infcode != 0 {
  4183. c.ServeSuccessJSON(map[string]interface{}{
  4184. "failed_code": -10,
  4185. "msg": res.ErrMsg,
  4186. })
  4187. return
  4188. } else {
  4189. order.FaPiaoNumber = zero
  4190. order.FaPiaoCode = last_order.FaPiaoCode
  4191. service.UpdateOrder(order)
  4192. hisFundSettleListResult := &models.HisFundSettleListResult{
  4193. Number: res.Output.SetlListId,
  4194. Status: 1,
  4195. Ctime: time.Now().Unix(),
  4196. Mtime: time.Now().Unix(),
  4197. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4198. IsUpload: 1,
  4199. OrderId: order_id,
  4200. }
  4201. service.CreateUploadRecord(hisFundSettleListResult)
  4202. c.ServeSuccessJSON(map[string]interface{}{
  4203. "msg": "上传成功",
  4204. "result": hisFundSettleListResult,
  4205. })
  4206. return
  4207. }
  4208. }
  4209. func (c *HisApiController) GetSettleListHospital() {
  4210. order_id, _ := c.GetInt64("order_id")
  4211. admin_user_id, _ := c.GetInt64("admin_user_id")
  4212. order, _ := service.GetHisOrderByIDTwo(order_id)
  4213. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4214. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4215. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4216. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4217. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4218. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4219. if order.ID == 0 {
  4220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4221. return
  4222. }
  4223. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  4224. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  4225. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  4226. fmt.Println(count)
  4227. var zero string
  4228. number := count + 1
  4229. if number >= 1000 {
  4230. zero = "0000" + strconv.FormatInt(number, 10)
  4231. } else if number >= 10000 {
  4232. zero = "000" + strconv.FormatInt(number, 10)
  4233. } else if number >= 100000 {
  4234. zero = "00" + strconv.FormatInt(number, 10)
  4235. } else if number >= 1000000 {
  4236. zero = "0" + strconv.FormatInt(number, 10)
  4237. } else {
  4238. zero = strconv.FormatInt(number, 10)
  4239. }
  4240. fmt.Println(zero)
  4241. struct4101 := service.Struct4101{
  4242. PsnNo: order.PsnNo,
  4243. MdtrtId: order.MdtrtId,
  4244. SetlId: order.SetlId,
  4245. PsnName: order.PsnName,
  4246. Gend: order.Gend,
  4247. Brdy: his.Brdy,
  4248. Age: int64(order.Age),
  4249. Naty: order.Naty,
  4250. PatnCertType: "01",
  4251. Certno: order.Certno,
  4252. Prfs: "90",
  4253. ConerName: roles[0].UserName,
  4254. PatnRlts: "99",
  4255. ConerAddr: miConfig.OrgName,
  4256. ConerTel: admin.Mobile,
  4257. HiType: order.Insutype,
  4258. Insuplc: miConfig.InsuplcAdmdvs,
  4259. MaindiagFlag: "1",
  4260. BillCode: order.SetlId,
  4261. BillNo: order.SetlId,
  4262. BizSn: order.Number,
  4263. PsnSelfPay: order.PsnPartAmt,
  4264. PsnOwnPay: order.PsnPartAmt,
  4265. AcctPay: order.AcctPay,
  4266. PsnCashpay: order.PsnCashPay,
  4267. HiPaymtd: "1",
  4268. Hsorg: miConfig.InsuplcAdmdvs,
  4269. HsorgOpter: miConfig.InsuplcAdmdvs,
  4270. MedinsFillPsn: curRoles.UserName,
  4271. MedinsFillDept: depart.Name,
  4272. IptMedType: "2",
  4273. AdmTime: his.InHosptialTime,
  4274. AdmEndTime: his.OutHosptialTime,
  4275. }
  4276. struct4101.SetlBegnDate = order.SetlTime
  4277. struct4101.SetlEndDate = order.SetlTime
  4278. var rf []CustomFundPay
  4279. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4280. var tempFunPays []service.CustomStruct
  4281. for _, item := range rf {
  4282. var tempFunPay service.CustomStruct
  4283. tempFunPay.FundPayamt = item.FundPayamt
  4284. tempFunPay.FundPayType = item.FundPayType
  4285. tempFunPays = append(tempFunPays, tempFunPay)
  4286. }
  4287. struct4101.CustomStruct = tempFunPays
  4288. var tempDiaginfos []service.DiaginfoStructTwo
  4289. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4290. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4291. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4292. var config []*models.HisXtDiagnoseConfig
  4293. for _, item := range diagnosis_ids {
  4294. id, _ := strconv.ParseInt(item, 10, 64)
  4295. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4296. config = append(config, &diagnosisConfig)
  4297. }
  4298. for index, item := range config {
  4299. if index == 0 {
  4300. var tempDiaginfo service.DiaginfoStructTwo
  4301. tempDiaginfo.DiagCode = item.CountryCode
  4302. tempDiaginfo.DiagName = item.CountryContentName
  4303. tempDiaginfo.DiagType = "1"
  4304. tempDiaginfo.MaindiagFlag = "1"
  4305. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4306. } else {
  4307. var tempDiaginfo service.DiaginfoStructTwo
  4308. tempDiaginfo.DiagCode = item.CountryCode
  4309. tempDiaginfo.DiagName = item.CountryContentName
  4310. tempDiaginfo.DiagType = "2"
  4311. tempDiaginfo.MaindiagFlag = "0"
  4312. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4313. }
  4314. }
  4315. struct4101.Diseinfo = tempDiaginfos
  4316. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4317. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4318. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4319. tempOpspdiseinfo2.OprnOprtCode = ""
  4320. tempOpspdiseinfo2.OprnOprtName = ""
  4321. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4322. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4323. var iteminfo service.IteminfoStruct
  4324. var bedCostTotal float64 = 0 //床位总费
  4325. var bedCostSelfTotal float64 = 0 //床位自费
  4326. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4327. var operationCostTotal float64 = 0 //手术费
  4328. var operationCostSelfTotal float64 = 0 //手术费
  4329. var operationCostPartSelfTotal float64 = 0 //手术费
  4330. var otherCostTotal float64 = 0 //其他费用
  4331. var otherCostSelfTotal float64 = 0 //其他费用
  4332. var otherCostPartSelfTotal float64 = 0 //其他费用
  4333. var materialCostTotal float64 = 0 //材料费
  4334. var materialCostSelfTotal float64 = 0 //材料费
  4335. var materialCostPartSelfTotal float64 = 0 //材料费
  4336. var westernMedicineCostTotal float64 = 0 //西药费
  4337. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4338. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4339. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4340. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4341. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4342. var checkCostTotal float64 = 0 //检查费
  4343. var checkCostSelfTotal float64 = 0 //检查费
  4344. var checkCostPartSelfTotal float64 = 0 //检查费
  4345. var laboratoryCostTotal float64 = 0 //化验费
  4346. var laboratoryCostSelfTotal float64 = 0 //化验费
  4347. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4348. var treatCostTotal float64 = 0 //治疗费用
  4349. var treatCostSelfTotal float64 = 0 //治疗费用
  4350. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4351. decimal.DivisionPrecision = 2
  4352. var bed_fulamt_ownpay_amt float64 = 0
  4353. var operation_fulamt_ownpay_amt float64 = 0
  4354. var other_fulamt_ownpay_amt float64 = 0
  4355. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4356. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4357. var check_fulamt_ownpay_amt float64 = 0
  4358. var material_fulamt_ownpay_amt float64 = 0
  4359. var laboratory_fulamt_ownpay_amt float64 = 0
  4360. var treat_fulamt_ownpay_amt float64 = 0
  4361. var bed_claa_sunmfee float64 = 0
  4362. var bed_clab_amt float64 = 0
  4363. var bed_other_amt float64 = 0
  4364. var operation_claa_sunmfee float64 = 0
  4365. var operation_clab_amt float64 = 0
  4366. var operation_other_amt float64 = 0
  4367. var other_claa_sunmfee float64 = 0
  4368. var other_clab_amt float64 = 0
  4369. var other_other_amt float64 = 0
  4370. var westernMedicine_claa_sunmfee float64 = 0
  4371. var westernMedicine_clab_amt float64 = 0
  4372. var westernMedicine_other_amt float64 = 0
  4373. var chineseTraditional_claa_sunmfee float64 = 0
  4374. var chineseTraditional_clab_amt float64 = 0
  4375. var chineseTraditional_other_amt float64 = 0
  4376. var check_claa_sunmfee float64 = 0
  4377. var check_clab_amt float64 = 0
  4378. var check_other_amt float64 = 0
  4379. var material_claa_sunmfee float64 = 0
  4380. var material_clab_amt float64 = 0
  4381. var material_other_amt float64 = 0
  4382. var laboratory_claa_sunmfee float64 = 0
  4383. var laboratory_clab_amt float64 = 0
  4384. var laboratory_other_amt float64 = 0
  4385. var treat_claa_sunmfee float64 = 0
  4386. var treat_clab_amt float64 = 0
  4387. var treat_other_amt float64 = 0
  4388. for _, item := range order.HisOrderInfo {
  4389. if item.MedChrgitmType == "01" { //床位费
  4390. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4391. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4392. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4393. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4394. if item.ChrgitmLv == "1" {
  4395. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4396. }
  4397. if item.ChrgitmLv == "2" {
  4398. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4399. }
  4400. if item.ChrgitmLv == "3" {
  4401. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4402. }
  4403. }
  4404. if item.MedChrgitmType == "03" { //检查费
  4405. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4406. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4407. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4408. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4409. if item.ChrgitmLv == "1" {
  4410. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4411. }
  4412. if item.ChrgitmLv == "2" {
  4413. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4414. }
  4415. if item.ChrgitmLv == "3" {
  4416. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4417. }
  4418. }
  4419. if item.MedChrgitmType == "04" { //化验费
  4420. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4421. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4422. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4423. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4424. if item.ChrgitmLv == "1" {
  4425. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4426. }
  4427. if item.ChrgitmLv == "2" {
  4428. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4429. }
  4430. if item.ChrgitmLv == "3" {
  4431. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4432. }
  4433. }
  4434. if item.MedChrgitmType == "05" { //治疗费
  4435. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4436. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4437. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4438. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4439. if item.ChrgitmLv == "1" {
  4440. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4441. }
  4442. if item.ChrgitmLv == "2" {
  4443. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4444. }
  4445. if item.ChrgitmLv == "3" {
  4446. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4447. }
  4448. }
  4449. if item.MedChrgitmType == "06" { //手术费
  4450. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4451. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4452. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4453. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4454. if item.ChrgitmLv == "1" {
  4455. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4456. }
  4457. if item.ChrgitmLv == "2" {
  4458. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4459. }
  4460. if item.ChrgitmLv == "3" {
  4461. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4462. }
  4463. }
  4464. if item.MedChrgitmType == "08" { //材料费
  4465. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4466. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4467. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4468. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4469. if item.ChrgitmLv == "1" {
  4470. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4471. }
  4472. if item.ChrgitmLv == "2" {
  4473. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4474. }
  4475. if item.ChrgitmLv == "3" {
  4476. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4477. }
  4478. }
  4479. if item.MedChrgitmType == "09" { //西药费
  4480. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4481. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4482. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4483. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4484. if item.ChrgitmLv == "1" {
  4485. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4486. }
  4487. if item.ChrgitmLv == "2" {
  4488. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4489. }
  4490. if item.ChrgitmLv == "3" {
  4491. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4492. }
  4493. }
  4494. if item.MedChrgitmType == "11" { //中成费
  4495. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4496. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4497. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4498. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4499. if item.ChrgitmLv == "1" {
  4500. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4501. }
  4502. if item.ChrgitmLv == "2" {
  4503. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4504. }
  4505. if item.ChrgitmLv == "3" {
  4506. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4507. }
  4508. }
  4509. if item.MedChrgitmType == "14" { //其他费
  4510. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4511. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4512. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4513. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4514. if item.ChrgitmLv == "1" {
  4515. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4516. }
  4517. if item.ChrgitmLv == "2" {
  4518. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4519. }
  4520. if item.ChrgitmLv == "3" {
  4521. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4522. }
  4523. }
  4524. }
  4525. var iteminfoStructs []service.IteminfoStruct
  4526. if bedCostTotal != 0 {
  4527. iteminfo.MedChrgitm = "01"
  4528. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4529. iteminfo.Amt = bedCostTotal
  4530. iteminfo.ClaaSumfee = bed_claa_sunmfee
  4531. iteminfo.ClabAmt = bed_clab_amt
  4532. iteminfo.OthAmt = bed_other_amt
  4533. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4534. }
  4535. if checkCostTotal != 0 {
  4536. iteminfo.MedChrgitm = "03"
  4537. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  4538. iteminfo.Amt = checkCostTotal
  4539. iteminfo.ClaaSumfee = check_claa_sunmfee
  4540. iteminfo.ClabAmt = check_clab_amt
  4541. iteminfo.OthAmt = check_other_amt
  4542. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4543. }
  4544. if laboratoryCostTotal != 0 {
  4545. iteminfo.MedChrgitm = "04"
  4546. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  4547. iteminfo.Amt = laboratoryCostTotal
  4548. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  4549. iteminfo.ClabAmt = laboratory_clab_amt
  4550. iteminfo.OthAmt = laboratory_other_amt
  4551. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4552. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4553. }
  4554. if treatCostTotal != 0 {
  4555. iteminfo.MedChrgitm = "05"
  4556. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  4557. iteminfo.Amt = treatCostTotal
  4558. iteminfo.ClaaSumfee = treat_claa_sunmfee
  4559. iteminfo.ClabAmt = treat_clab_amt
  4560. iteminfo.OthAmt = treat_other_amt
  4561. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4562. //(struct4101.IteminfoStruct, iteminfo)
  4563. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4564. }
  4565. if operationCostTotal != 0 {
  4566. iteminfo.MedChrgitm = "06"
  4567. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  4568. iteminfo.Amt = operationCostTotal
  4569. iteminfo.ClaaSumfee = operation_claa_sunmfee
  4570. iteminfo.ClabAmt = operation_clab_amt
  4571. iteminfo.OthAmt = operation_other_amt
  4572. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4573. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4574. }
  4575. if materialCostTotal != 0 {
  4576. iteminfo.MedChrgitm = "08"
  4577. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  4578. iteminfo.Amt = materialCostTotal
  4579. iteminfo.ClaaSumfee = material_claa_sunmfee
  4580. iteminfo.ClabAmt = material_clab_amt
  4581. iteminfo.OthAmt = material_other_amt
  4582. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4583. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4584. }
  4585. if westernMedicineCostTotal != 0 {
  4586. iteminfo.MedChrgitm = "09"
  4587. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4588. iteminfo.Amt = westernMedicineCostTotal
  4589. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4590. iteminfo.ClabAmt = westernMedicine_clab_amt
  4591. iteminfo.OthAmt = westernMedicine_other_amt
  4592. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4593. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4594. }
  4595. if chineseTraditionalMedicineCostTotal != 0 {
  4596. iteminfo.MedChrgitm = "11"
  4597. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  4598. iteminfo.Amt = westernMedicineCostTotal
  4599. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  4600. iteminfo.ClabAmt = westernMedicine_clab_amt
  4601. iteminfo.OthAmt = westernMedicine_other_amt
  4602. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4603. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4604. }
  4605. if otherCostTotal != 0 {
  4606. iteminfo.MedChrgitm = "14"
  4607. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  4608. iteminfo.Amt = otherCostTotal
  4609. iteminfo.ClaaSumfee = other_claa_sunmfee
  4610. iteminfo.ClabAmt = other_clab_amt
  4611. iteminfo.OthAmt = other_other_amt
  4612. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  4613. iteminfoStructs = append(iteminfoStructs, iteminfo)
  4614. }
  4615. struct4101.IteminfoStruct = iteminfoStructs
  4616. struct4101.Ntly = "中国"
  4617. struct4101.AdmCaty = "A03.06"
  4618. var resOther ResultSeventeenOther
  4619. var res ResultSeventeen
  4620. if miConfig.MdtrtareaAdmvs == "150499" {
  4621. var pp models.PublicParams
  4622. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4623. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4624. pp.FixmedinsName = miConfig.OrgName
  4625. pp.FixmedinsCode = miConfig.Code
  4626. pp.RequestUrl = miConfig.Url
  4627. pp.Cainfo = miConfig.Cainfo
  4628. pp.SecretKey = miConfig.SecretKey
  4629. pp.AccessKey = miConfig.AccessKey
  4630. pp.OpterName = curRoles.UserName
  4631. client := &http.Client{}
  4632. var req *http.Request
  4633. data := make(map[string]interface{})
  4634. data["struct4101"] = struct4101
  4635. data["pp"] = pp
  4636. bytesData, _ := json.Marshal(data)
  4637. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  4638. resp, _ := client.Do(req)
  4639. defer resp.Body.Close()
  4640. body, ioErr := ioutil.ReadAll(resp.Body)
  4641. if ioErr != nil {
  4642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4644. return
  4645. }
  4646. var respJSON map[string]interface{}
  4647. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4650. return
  4651. }
  4652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4653. userJSONBytes, _ := json.Marshal(respJSON)
  4654. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  4655. utils.ErrorLog("解析失败:%v", err)
  4656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4657. return
  4658. }
  4659. res.InfRefmsgid = resOther.InfRefmsgid
  4660. res.Output = resOther.Output
  4661. res.ErrMsg = resOther.ErrMsg
  4662. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  4663. res.Infcode = infocode
  4664. } else {
  4665. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  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 err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4674. utils.ErrorLog("解析失败:%v", err)
  4675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4676. return
  4677. }
  4678. }
  4679. if res.Infcode != 0 {
  4680. c.ServeSuccessJSON(map[string]interface{}{
  4681. "failed_code": -10,
  4682. "msg": res.ErrMsg,
  4683. })
  4684. return
  4685. } else {
  4686. if miConfig.MdtrtareaAdmvs != "150499" {
  4687. order.FaPiaoNumber = zero
  4688. order.FaPiaoCode = last_order.FaPiaoCode
  4689. service.UpdateOrder(order)
  4690. }
  4691. hisFundSettleListResult := &models.HisFundSettleListResult{
  4692. Number: res.Output.SetlListId,
  4693. Status: 1,
  4694. Ctime: time.Now().Unix(),
  4695. Mtime: time.Now().Unix(),
  4696. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4697. IsUpload: 1,
  4698. OrderId: order_id,
  4699. }
  4700. service.CreateUploadRecord(hisFundSettleListResult)
  4701. c.ServeSuccessJSON(map[string]interface{}{
  4702. "msg": "上传成功",
  4703. "result": hisFundSettleListResult,
  4704. })
  4705. return
  4706. }
  4707. }
  4708. func (c *HisApiController) GetBatchSettleList() {
  4709. orders, _ := service.GetAllHisOrder(10106)
  4710. for _, item := range orders {
  4711. order_id := item.ID
  4712. order, _ := service.GetHisOrderByIDTwo(order_id)
  4713. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  4714. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4715. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  4716. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  4717. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  4718. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4719. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4720. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4721. if order.ID == 0 {
  4722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4723. return
  4724. }
  4725. if his.BalanceAccountsType == 2 {
  4726. continue
  4727. }
  4728. struct4101 := service.Struct4101{
  4729. PsnNo: order.PsnNo,
  4730. MdtrtId: order.MdtrtId,
  4731. SetlId: order.SetlId,
  4732. PsnName: order.PsnName,
  4733. Gend: order.Gend,
  4734. Brdy: his.Brdy,
  4735. Age: his.Age,
  4736. Naty: order.Naty,
  4737. PatnCertType: "01",
  4738. Certno: order.Certno,
  4739. Prfs: "90",
  4740. ConerName: roles[0].UserName,
  4741. PatnRlts: "99",
  4742. ConerAddr: miConfig.OrgName,
  4743. ConerTel: admin.Mobile,
  4744. HiType: order.Insutype,
  4745. Insuplc: his.InsuplcAdmdvs,
  4746. MaindiagFlag: "1",
  4747. BillCode: order.SetlId,
  4748. BillNo: order.SetlId,
  4749. BizSn: order.Number,
  4750. PsnSelfPay: order.PsnPartAmt,
  4751. PsnOwnPay: order.PsnPartAmt,
  4752. AcctPay: order.AcctPay,
  4753. PsnCashpay: order.PsnCashPay,
  4754. HiPaymtd: "1",
  4755. Hsorg: his.InsuplcAdmdvs,
  4756. HsorgOpter: his.InsuplcAdmdvs,
  4757. MedinsFillPsn: curRoles.UserName,
  4758. MedinsFillDept: depart.Name,
  4759. IptMedType: "2",
  4760. }
  4761. struct4101.SetlBegnDate = order.SetlTime
  4762. struct4101.SetlEndDate = order.SetlTime
  4763. //if order.SettleType == 1 {
  4764. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  4765. // dateStr := t.Format("2006-01-02")
  4766. // struct4101.SetlBegnDate = dateStr
  4767. // struct4101.SetlEndDate = dateStr
  4768. //} else {
  4769. // t := time.Unix(int64(order.SettleStartTime), 0)
  4770. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  4771. // dateStartStr := t.Format("2006-01-02")
  4772. // dateEndStr := t2.Format("2006-01-02")
  4773. // struct4101.SetlBegnDate = dateStartStr
  4774. // struct4101.SetlEndDate = dateEndStr
  4775. //}
  4776. var rf []CustomFundPay
  4777. json.Unmarshal([]byte(order.SetlDetail), &rf)
  4778. var tempFunPays []service.CustomStruct
  4779. var tempFunPay610100 service.CustomStruct
  4780. for _, item := range rf {
  4781. if item.FundPayType == "610100" {
  4782. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  4783. tempFunPay610100.FundPayType = item.FundPayType
  4784. } else {
  4785. var tempFunPay service.CustomStruct
  4786. tempFunPay.FundPayamt = item.FundPayamt
  4787. tempFunPay.FundPayType = item.FundPayType
  4788. tempFunPays = append(tempFunPays, tempFunPay)
  4789. }
  4790. }
  4791. tempFunPays = append(tempFunPays, tempFunPay610100)
  4792. struct4101.CustomStruct = tempFunPays
  4793. var tempDiaginfos []service.DiaginfoStructTwo
  4794. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  4795. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  4796. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4797. var config []*models.HisXtDiagnoseConfig
  4798. for _, item := range diagnosis_ids {
  4799. id, _ := strconv.ParseInt(item, 10, 64)
  4800. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4801. config = append(config, &diagnosisConfig)
  4802. }
  4803. for index, item := range config {
  4804. if index == 0 {
  4805. var tempDiaginfo service.DiaginfoStructTwo
  4806. tempDiaginfo.DiagCode = item.CountryCode
  4807. tempDiaginfo.DiagName = item.CountryContentName
  4808. tempDiaginfo.DiagType = "1"
  4809. tempDiaginfo.MaindiagFlag = "1"
  4810. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4811. } else {
  4812. var tempDiaginfo service.DiaginfoStructTwo
  4813. tempDiaginfo.DiagCode = item.CountryCode
  4814. tempDiaginfo.DiagName = item.CountryContentName
  4815. tempDiaginfo.DiagType = "2"
  4816. tempDiaginfo.MaindiagFlag = "0"
  4817. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4818. }
  4819. }
  4820. struct4101.Diseinfo = tempDiaginfos
  4821. sickConfigTwo, _ := service.FindSickById(his.SickType)
  4822. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  4823. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  4824. tempOpspdiseinfo2.OprnOprtCode = ""
  4825. tempOpspdiseinfo2.OprnOprtName = ""
  4826. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  4827. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  4828. var iteminfo service.IteminfoStruct
  4829. var bedCostTotal float64 = 0 //床位总费
  4830. var bedCostSelfTotal float64 = 0 //床位自费
  4831. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4832. var examineCostTotal float64 = 0 //诊查总费
  4833. var examineCostSelfTotal float64 = 0 //诊查自费
  4834. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  4835. var nursingCostTotal float64 = 0 //护理总费
  4836. var nursingCostSelfTotal float64 = 0 //护理自费
  4837. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  4838. var chineseMedicineCostTotal float64 = 0 //中成药
  4839. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  4840. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  4841. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  4842. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  4843. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  4844. var registerCostTotal float64 = 0 //一般诊疗费
  4845. var registerCostSelfTotal float64 = 0 //一般诊疗费
  4846. var registerPartSelfTotal float64 = 0 //一般诊疗费
  4847. var operationCostTotal float64 = 0 //手术费
  4848. var operationCostSelfTotal float64 = 0 //手术费
  4849. var operationCostPartSelfTotal float64 = 0 //手术费
  4850. var otherCostTotal float64 = 0 //其他费用
  4851. var otherCostSelfTotal float64 = 0 //其他费用
  4852. var otherCostPartSelfTotal float64 = 0 //其他费用
  4853. var materialCostTotal float64 = 0 //材料费
  4854. var materialCostSelfTotal float64 = 0 //材料费
  4855. var materialCostPartSelfTotal float64 = 0 //材料费
  4856. var westernMedicineCostTotal float64 = 0 //西药费
  4857. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4858. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4859. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4860. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4861. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4862. var checkCostTotal float64 = 0 //检查费
  4863. var checkCostSelfTotal float64 = 0 //检查费
  4864. var checkCostPartSelfTotal float64 = 0 //检查费
  4865. var laboratoryCostTotal float64 = 0 //化验费
  4866. var laboratoryCostSelfTotal float64 = 0 //化验费
  4867. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4868. var treatCostTotal float64 = 0 //治疗费用
  4869. var treatCostSelfTotal float64 = 0 //治疗费用
  4870. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4871. decimal.DivisionPrecision = 2
  4872. var bed_fulamt_ownpay_amt float64 = 0
  4873. var examine_fulamt_ownpay_amt float64 = 0
  4874. var nursing_fulamt_ownpay_amt float64 = 0
  4875. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  4876. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  4877. var register_fulamt_ownpay_amt float64 = 0
  4878. var operation_fulamt_ownpay_amt float64 = 0
  4879. var other_fulamt_ownpay_amt float64 = 0
  4880. var westernMedicine_fulamt_ownpay_amt float64 = 0
  4881. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  4882. var check_fulamt_ownpay_amt float64 = 0
  4883. var material_fulamt_ownpay_amt float64 = 0
  4884. var laboratory_fulamt_ownpay_amt float64 = 0
  4885. var treat_fulamt_ownpay_amt float64 = 0
  4886. var bed_claa_sunmfee float64 = 0
  4887. var bed_clab_amt float64 = 0
  4888. var bed_other_amt float64 = 0
  4889. var examine_claa_sunmfee float64 = 0
  4890. var examine_clab_amt float64 = 0
  4891. var examine_other_amt float64 = 0
  4892. var nursing_claa_sunmfee float64 = 0
  4893. var nursing_clab_amt float64 = 0
  4894. var nursing_other_amt float64 = 0
  4895. var chinese_medicine_claa_sunmfee float64 = 0
  4896. var chinese_medicine_clab_amt float64 = 0
  4897. var chinese_medicine_other_amt float64 = 0
  4898. var commonly_treatment_claa_sunmfee float64 = 0
  4899. var commonly_treatment_clab_amt float64 = 0
  4900. var commonly_treatment_other_amt float64 = 0
  4901. var operation_claa_sunmfee float64 = 0
  4902. var operation_clab_amt float64 = 0
  4903. var operation_other_amt float64 = 0
  4904. var other_claa_sunmfee float64 = 0
  4905. var other_clab_amt float64 = 0
  4906. var other_other_amt float64 = 0
  4907. var westernMedicine_claa_sunmfee float64 = 0
  4908. var westernMedicine_clab_amt float64 = 0
  4909. var westernMedicine_other_amt float64 = 0
  4910. var chineseTraditional_claa_sunmfee float64 = 0
  4911. var chineseTraditional_clab_amt float64 = 0
  4912. var chineseTraditional_other_amt float64 = 0
  4913. var check_claa_sunmfee float64 = 0
  4914. var check_clab_amt float64 = 0
  4915. var check_other_amt float64 = 0
  4916. var material_claa_sunmfee float64 = 0
  4917. var material_clab_amt float64 = 0
  4918. var material_other_amt float64 = 0
  4919. var laboratory_claa_sunmfee float64 = 0
  4920. var laboratory_clab_amt float64 = 0
  4921. var laboratory_other_amt float64 = 0
  4922. var treat_claa_sunmfee float64 = 0
  4923. var treat_clab_amt float64 = 0
  4924. var treat_other_amt float64 = 0
  4925. var register_claa_sunmfee float64 = 0
  4926. var register_clab_amt float64 = 0
  4927. var register_other_amt float64 = 0
  4928. for _, item := range order.HisOrderInfo {
  4929. if item.MedChrgitmType == "01" { //床位费
  4930. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4931. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4932. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4933. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4934. if item.ChrgitmLv == "1" {
  4935. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4936. }
  4937. if item.ChrgitmLv == "2" {
  4938. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4939. }
  4940. if item.ChrgitmLv == "3" {
  4941. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4942. }
  4943. }
  4944. if item.MedChrgitmType == "02" { //诊查
  4945. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4946. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4947. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4948. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4949. if item.ChrgitmLv == "1" {
  4950. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4951. }
  4952. if item.ChrgitmLv == "2" {
  4953. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4954. }
  4955. if item.ChrgitmLv == "3" {
  4956. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4957. }
  4958. }
  4959. if item.MedChrgitmType == "03" { //检查费
  4960. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4961. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4962. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4963. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4964. if item.ChrgitmLv == "1" {
  4965. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4966. }
  4967. if item.ChrgitmLv == "2" {
  4968. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4969. }
  4970. if item.ChrgitmLv == "3" {
  4971. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4972. }
  4973. }
  4974. if item.MedChrgitmType == "04" { //化验费
  4975. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4976. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4977. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4978. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4979. if item.ChrgitmLv == "1" {
  4980. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4981. }
  4982. if item.ChrgitmLv == "2" {
  4983. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4984. }
  4985. if item.ChrgitmLv == "3" {
  4986. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4987. }
  4988. }
  4989. if item.MedChrgitmType == "05" { //治疗费
  4990. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4991. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4992. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4993. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  4994. if item.ChrgitmLv == "1" {
  4995. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4996. }
  4997. if item.ChrgitmLv == "2" {
  4998. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4999. }
  5000. if item.ChrgitmLv == "3" {
  5001. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5002. }
  5003. }
  5004. if item.MedChrgitmType == "06" { //手术费
  5005. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5006. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5007. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5008. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5009. if item.ChrgitmLv == "1" {
  5010. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5011. }
  5012. if item.ChrgitmLv == "2" {
  5013. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5014. }
  5015. if item.ChrgitmLv == "3" {
  5016. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5017. }
  5018. }
  5019. if item.MedChrgitmType == "07" { //手术费
  5020. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5021. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5022. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5023. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5024. if item.ChrgitmLv == "1" {
  5025. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5026. }
  5027. if item.ChrgitmLv == "2" {
  5028. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5029. }
  5030. if item.ChrgitmLv == "3" {
  5031. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5032. }
  5033. }
  5034. if item.MedChrgitmType == "08" { //材料费
  5035. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5036. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5037. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5038. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5039. if item.ChrgitmLv == "1" {
  5040. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5041. }
  5042. if item.ChrgitmLv == "2" {
  5043. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5044. }
  5045. if item.ChrgitmLv == "3" {
  5046. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5047. }
  5048. }
  5049. if item.MedChrgitmType == "09" { //西药费
  5050. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5051. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5052. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5053. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5054. if item.ChrgitmLv == "1" {
  5055. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5056. }
  5057. if item.ChrgitmLv == "2" {
  5058. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5059. }
  5060. if item.ChrgitmLv == "3" {
  5061. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5062. }
  5063. }
  5064. if item.MedChrgitmType == "10" { //中药饮片
  5065. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5066. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5067. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5068. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5069. if item.ChrgitmLv == "1" {
  5070. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5071. }
  5072. if item.ChrgitmLv == "2" {
  5073. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5074. }
  5075. if item.ChrgitmLv == "3" {
  5076. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5077. }
  5078. }
  5079. if item.MedChrgitmType == "11" { //中成费
  5080. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5081. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5082. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5083. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5084. if item.ChrgitmLv == "1" {
  5085. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5086. }
  5087. if item.ChrgitmLv == "2" {
  5088. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5089. }
  5090. if item.ChrgitmLv == "3" {
  5091. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5092. }
  5093. }
  5094. if item.MedChrgitmType == "12" { //中成费
  5095. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5096. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5097. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5098. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5099. if item.ChrgitmLv == "1" {
  5100. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5101. }
  5102. if item.ChrgitmLv == "2" {
  5103. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5104. }
  5105. if item.ChrgitmLv == "3" {
  5106. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5107. }
  5108. }
  5109. if item.MedChrgitmType == "13" { //中成费
  5110. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5111. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5112. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5113. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5114. if item.ChrgitmLv == "1" {
  5115. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5116. }
  5117. if item.ChrgitmLv == "2" {
  5118. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5119. }
  5120. if item.ChrgitmLv == "3" {
  5121. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5122. }
  5123. }
  5124. if item.MedChrgitmType == "14" { //其他费
  5125. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5126. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5127. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5128. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5129. if item.ChrgitmLv == "1" {
  5130. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5131. }
  5132. if item.ChrgitmLv == "2" {
  5133. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5134. }
  5135. if item.ChrgitmLv == "3" {
  5136. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5137. }
  5138. }
  5139. }
  5140. var iteminfoStructs []service.IteminfoStruct
  5141. if bedCostTotal != 0 {
  5142. iteminfo.MedChrgitm = "01"
  5143. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5144. iteminfo.Amt = bedCostTotal
  5145. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5146. iteminfo.ClabAmt = bed_clab_amt
  5147. iteminfo.OthAmt = bed_other_amt
  5148. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5149. }
  5150. if examineCostTotal != 0 {
  5151. iteminfo.MedChrgitm = "02"
  5152. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  5153. iteminfo.Amt = examineCostTotal
  5154. iteminfo.ClaaSumfee = examine_claa_sunmfee
  5155. iteminfo.ClabAmt = examine_clab_amt
  5156. iteminfo.OthAmt = examine_other_amt
  5157. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5158. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5159. }
  5160. if checkCostTotal != 0 {
  5161. iteminfo.MedChrgitm = "03"
  5162. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5163. iteminfo.Amt = checkCostTotal
  5164. iteminfo.ClaaSumfee = check_claa_sunmfee
  5165. iteminfo.ClabAmt = check_clab_amt
  5166. iteminfo.OthAmt = check_other_amt
  5167. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5168. }
  5169. if laboratoryCostTotal != 0 {
  5170. iteminfo.MedChrgitm = "04"
  5171. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5172. iteminfo.Amt = laboratoryCostTotal
  5173. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5174. iteminfo.ClabAmt = laboratory_clab_amt
  5175. iteminfo.OthAmt = laboratory_other_amt
  5176. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5177. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5178. }
  5179. if treatCostTotal != 0 {
  5180. iteminfo.MedChrgitm = "05"
  5181. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5182. iteminfo.Amt = treatCostTotal
  5183. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5184. iteminfo.ClabAmt = treat_clab_amt
  5185. iteminfo.OthAmt = treat_other_amt
  5186. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5187. //(struct4101.IteminfoStruct, iteminfo)
  5188. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5189. }
  5190. if operationCostTotal != 0 {
  5191. iteminfo.MedChrgitm = "06"
  5192. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5193. iteminfo.Amt = operationCostTotal
  5194. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5195. iteminfo.ClabAmt = operation_clab_amt
  5196. iteminfo.OthAmt = operation_other_amt
  5197. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5198. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5199. }
  5200. if nursingCostTotal != 0 {
  5201. iteminfo.MedChrgitm = "07"
  5202. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  5203. iteminfo.Amt = nursingCostTotal
  5204. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  5205. iteminfo.ClabAmt = nursing_clab_amt
  5206. iteminfo.OthAmt = nursing_other_amt
  5207. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5208. }
  5209. if materialCostTotal != 0 {
  5210. iteminfo.MedChrgitm = "08"
  5211. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5212. iteminfo.Amt = materialCostTotal
  5213. iteminfo.ClaaSumfee = material_claa_sunmfee
  5214. iteminfo.ClabAmt = material_clab_amt
  5215. iteminfo.OthAmt = material_other_amt
  5216. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5217. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5218. }
  5219. if westernMedicineCostTotal != 0 {
  5220. iteminfo.MedChrgitm = "09"
  5221. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5222. iteminfo.Amt = westernMedicineCostTotal
  5223. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5224. iteminfo.ClabAmt = westernMedicine_clab_amt
  5225. iteminfo.OthAmt = westernMedicine_other_amt
  5226. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5227. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5228. }
  5229. if chineseMedicineCostTotal != 0 {
  5230. iteminfo.MedChrgitm = "10"
  5231. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  5232. iteminfo.Amt = chineseMedicineCostTotal
  5233. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  5234. iteminfo.ClabAmt = chinese_medicine_clab_amt
  5235. iteminfo.OthAmt = chinese_medicine_other_amt
  5236. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5237. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5238. }
  5239. if chineseTraditionalMedicineCostTotal != 0 {
  5240. iteminfo.MedChrgitm = "11"
  5241. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5242. iteminfo.Amt = westernMedicineCostTotal
  5243. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5244. iteminfo.ClabAmt = westernMedicine_clab_amt
  5245. iteminfo.OthAmt = westernMedicine_other_amt
  5246. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5247. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5248. }
  5249. if commonlyTreatmentCostTotal != 0 {
  5250. iteminfo.MedChrgitm = "12"
  5251. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  5252. iteminfo.Amt = commonlyTreatmentCostTotal
  5253. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  5254. iteminfo.ClabAmt = commonly_treatment_clab_amt
  5255. iteminfo.OthAmt = commonly_treatment_other_amt
  5256. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5257. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5258. }
  5259. if registerCostTotal != 0 {
  5260. iteminfo.MedChrgitm = "13"
  5261. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  5262. iteminfo.Amt = registerCostTotal
  5263. iteminfo.ClaaSumfee = register_claa_sunmfee
  5264. iteminfo.ClabAmt = register_clab_amt
  5265. iteminfo.OthAmt = register_other_amt
  5266. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5267. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5268. }
  5269. if otherCostTotal != 0 {
  5270. iteminfo.MedChrgitm = "14"
  5271. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5272. iteminfo.Amt = otherCostTotal
  5273. iteminfo.ClaaSumfee = other_claa_sunmfee
  5274. iteminfo.ClabAmt = other_clab_amt
  5275. iteminfo.OthAmt = other_other_amt
  5276. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5277. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5278. }
  5279. struct4101.IteminfoStruct = iteminfoStructs
  5280. time_arr := strings.Split(order.SetlTime, " ")
  5281. struct4101.AdmTime = time_arr[0]
  5282. struct4101.AdmEndTime = time_arr[0]
  5283. struct4101.DoctorName = doctor.UserName
  5284. struct4101.DoctorCode = doctor.DoctorNumber
  5285. struct4101.Ntly = "中国"
  5286. struct4101.AdmCaty = "A03.06"
  5287. var res ResultSeventeen
  5288. if miConfig.MdtrtareaAdmvs == "421300" {
  5289. data := make(map[string]interface{})
  5290. data["struct4101"] = struct4101
  5291. data["secret_key"] = miConfig.SecretKey
  5292. data["org_name"] = miConfig.OrgName
  5293. data["opera"] = curRoles.UserName
  5294. data["code"] = miConfig.Code
  5295. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5296. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5297. client := &http.Client{}
  5298. bytesData, _ := json.Marshal(data)
  5299. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  5300. resp, _ := client.Do(req)
  5301. defer resp.Body.Close()
  5302. body, ioErr := ioutil.ReadAll(resp.Body)
  5303. if ioErr != nil {
  5304. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5306. return
  5307. }
  5308. var respJSON map[string]interface{}
  5309. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5310. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5312. return
  5313. }
  5314. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5315. userJSONBytes, _ := json.Marshal(respJSON)
  5316. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5317. utils.ErrorLog("解析失败:%v", err)
  5318. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5319. adminUser := c.GetAdminUserInfo()
  5320. errlog := &models.HisOrderError{
  5321. UserOrgId: adminUser.CurrentOrgId,
  5322. Ctime: time.Now().Unix(),
  5323. Mtime: time.Now().Unix(),
  5324. ErrMsg: res.ErrMsg + "解析失败",
  5325. Status: 1,
  5326. PatientId: order_id,
  5327. Stage: 10088,
  5328. }
  5329. service.CreateErrMsgLog(errlog)
  5330. continue
  5331. }
  5332. } else {
  5333. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  5334. fmt.Println(result)
  5335. var dat map[string]interface{}
  5336. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5337. fmt.Println(dat)
  5338. } else {
  5339. fmt.Println(err)
  5340. }
  5341. userJSONBytes, _ := json.Marshal(dat)
  5342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5343. utils.ErrorLog("解析失败:%v", err)
  5344. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5345. adminUser := c.GetAdminUserInfo()
  5346. errlog := &models.HisOrderError{
  5347. UserOrgId: adminUser.CurrentOrgId,
  5348. Ctime: time.Now().Unix(),
  5349. Mtime: time.Now().Unix(),
  5350. ErrMsg: res.ErrMsg + "解析失败",
  5351. Status: 1,
  5352. PatientId: order_id,
  5353. Stage: 10106,
  5354. }
  5355. service.CreateErrMsgLog(errlog)
  5356. continue
  5357. }
  5358. }
  5359. if res.Infcode != 0 {
  5360. adminUser := c.GetAdminUserInfo()
  5361. errlog := &models.HisOrderError{
  5362. UserOrgId: adminUser.CurrentOrgId,
  5363. Ctime: time.Now().Unix(),
  5364. Mtime: time.Now().Unix(),
  5365. ErrMsg: res.ErrMsg,
  5366. Status: 1,
  5367. PatientId: order_id,
  5368. Stage: 10106,
  5369. }
  5370. service.CreateErrMsgLog(errlog)
  5371. continue
  5372. } else {
  5373. hisFundSettleListResult := &models.HisFundSettleListResult{
  5374. Number: res.Output.SetlListId,
  5375. Status: 1,
  5376. Ctime: time.Now().Unix(),
  5377. Mtime: time.Now().Unix(),
  5378. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5379. IsUpload: 1,
  5380. OrderId: order_id,
  5381. }
  5382. service.CreateUploadRecord(hisFundSettleListResult)
  5383. continue
  5384. }
  5385. }
  5386. }
  5387. func (c *HisApiController) GetOrgInfo() {
  5388. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  5389. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  5390. }
  5391. func (c *HisApiController) GetHisPatientInfo() {
  5392. medical_insurance_card := c.GetString("medical_insurance_card")
  5393. id_card_type, _ := c.GetInt64("id_card_type")
  5394. id_card := c.GetString("id_card")
  5395. adminInfo := c.GetAdminUserInfo()
  5396. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  5397. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5398. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  5399. IdCardNo := ""
  5400. if id_card_type == 1 {
  5401. IdCardNo = medical_insurance_card
  5402. } else if id_card_type == 2 {
  5403. IdCardNo = id_card
  5404. }
  5405. if config.IsOpen == 1 {
  5406. 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
  5407. resp, requestErr := http.Get(api)
  5408. if requestErr != nil {
  5409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5410. return
  5411. }
  5412. defer resp.Body.Close()
  5413. body, ioErr := ioutil.ReadAll(resp.Body)
  5414. if ioErr != nil {
  5415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5417. return
  5418. }
  5419. var respJSON map[string]interface{}
  5420. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5423. return
  5424. }
  5425. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5426. userJSONBytes, _ := json.Marshal(userJSON)
  5427. var res ResultTwo
  5428. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5429. utils.ErrorLog("解析失败:%v", err)
  5430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5431. return
  5432. }
  5433. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5434. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5435. infoStr := string(Iinfos)
  5436. idetinfoStr := string(Idetinfos)
  5437. if res.Infcode == 0 {
  5438. his := models.VMHisPatient{
  5439. Status: 1,
  5440. Ctime: time.Now().Unix(),
  5441. Mtime: time.Now().Unix(),
  5442. PsnNo: res.Output.Baseinfo.PsnNo,
  5443. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5444. Certno: res.Output.Baseinfo.Certno,
  5445. PsnName: res.Output.Baseinfo.PsnName,
  5446. Gend: res.Output.Baseinfo.Gend,
  5447. Naty: res.Output.Baseinfo.Naty,
  5448. Brdy: res.Output.Baseinfo.Brdy,
  5449. Age: res.Output.Baseinfo.Age,
  5450. Iinfo: infoStr,
  5451. Idetinfo: idetinfoStr,
  5452. UserOrgId: adminInfo.CurrentOrgId,
  5453. IsReturn: 1,
  5454. IdCardType: id_card_type,
  5455. }
  5456. c.ServeSuccessJSON(map[string]interface{}{
  5457. "info": his,
  5458. })
  5459. } else {
  5460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5461. return
  5462. }
  5463. }
  5464. }
  5465. //func GetBasBaseInfo() (jsonStr string, err error) {
  5466. //
  5467. // handle := syscall.NewLazyDLL("SSCard.dll")
  5468. // add := handle.NewProc("ReadCardBas")
  5469. // str := make([]byte, 1024)
  5470. // str1 := make([]byte, 1024)
  5471. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5472. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  5473. //
  5474. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  5475. //
  5476. // fmt.Println("> Add(4,5)的结果为:", ret)
  5477. // handle.Release()
  5478. //
  5479. // return "", nil
  5480. //
  5481. //}
  5482. //func GetQRBaseInfo() (jsonStr string, err error) {
  5483. // handle := syscall.LoadDLL("SSCard.dll")
  5484. // ReadCardBas := handle.FindProc("GetQRBase")
  5485. //
  5486. // str := make([]byte, 256)
  5487. // str1 := make([]byte, 256)
  5488. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  5489. //
  5490. // fmt.Println(string(str))
  5491. // fmt.Println(r)
  5492. // return string(str), nil
  5493. //}
  5494. //func CardInit() int {
  5495. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  5496. // add := DllTestDef.MustFindProc("Init")
  5497. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5498. // if err != nil {
  5499. // fmt.Println("SSCard的运算结果为:", ret)
  5500. // }
  5501. // result := int(ret)
  5502. // return result
  5503. //}
  5504. //func CardInit() int {
  5505. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  5506. // if err != nil {
  5507. // fmt.Println("SSCard的运算结果为:", ret)
  5508. // }
  5509. // fmt.Println(err)
  5510. // result := int(ret)
  5511. // return result
  5512. //}
  5513. func IntPtr(n int) uintptr {
  5514. return uintptr(n)
  5515. }
  5516. func StrPtr(s string) uintptr {
  5517. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  5518. }
  5519. type Result2001 struct {
  5520. Cainfo interface{} `json:"cainfo"`
  5521. ErrMsg string `json:"err_msg"`
  5522. InfRefmsgid string `json:"inf_refmsgid"`
  5523. Infcode int64 `json:"infcode"`
  5524. Output struct {
  5525. Trtinfo struct {
  5526. PsnNo string `json:"psn_no"`
  5527. TrtChkType string `json:"trt_chk_type"`
  5528. FundPayType string `json:"fund_pay_type"`
  5529. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5530. Begndate string `json:"begndate"`
  5531. Enddate string `json:"enddate"`
  5532. TrtChkRslt string `json:"trt_chk_rslt"`
  5533. } `json:"trtinfo"`
  5534. } `json:"output"`
  5535. RefmsgTime string `json:"refmsg_time"`
  5536. RespondTime string `json:"respond_time"`
  5537. Signtype interface{} `json:"signtype"`
  5538. WarnMsg interface{} `json:"warn_msg"`
  5539. }
  5540. type Result2001Org10265 struct {
  5541. Cainfo interface{} `json:"cainfo"`
  5542. ErrMsg string `json:"err_msg"`
  5543. InfRefmsgid string `json:"inf_refmsgid"`
  5544. Infcode string `json:"infcode"`
  5545. Output struct {
  5546. Trtinfo struct {
  5547. PsnNo string `json:"psn_no"`
  5548. TrtChkType string `json:"trt_chk_type"`
  5549. FundPayType string `json:"fund_pay_type"`
  5550. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  5551. Begndate string `json:"begndate"`
  5552. Enddate string `json:"enddate"`
  5553. TrtChkRslt string `json:"trt_chk_rslt"`
  5554. } `json:"trtinfo"`
  5555. } `json:"output"`
  5556. RefmsgTime string `json:"refmsg_time"`
  5557. RespondTime string `json:"respond_time"`
  5558. Signtype interface{} `json:"signtype"`
  5559. WarnMsg interface{} `json:"warn_msg"`
  5560. }
  5561. type ResultTwo struct {
  5562. ErrMsg string `json:"err_msg"`
  5563. InfRefmsgid string `json:"inf_refmsgid"`
  5564. Infcode int64 `json:"infcode"`
  5565. Output struct {
  5566. Baseinfo struct {
  5567. Age float64 `json:"age"`
  5568. Brdy string `json:"brdy"`
  5569. Certno string `json:"certno"`
  5570. Gend string `json:"gend"`
  5571. Naty string `json:"naty"`
  5572. PsnCertType string `json:"psn_cert_type"`
  5573. PsnName string `json:"psn_name"`
  5574. PsnNo string `json:"psn_no"`
  5575. } `json:"baseinfo"`
  5576. Idetinfo []interface{} `json:"idetinfo"`
  5577. Iinfo []struct {
  5578. Balc float64 `json:"balc"`
  5579. CvlservFlag string `json:"cvlserv_flag"`
  5580. EmpName string `json:"emp_name"`
  5581. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5582. Insutype string `json:"insutype"`
  5583. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5584. PausInsuDate string `json:"paus_insu_date"`
  5585. PsnInsuDate string `json:"psn_insu_date"`
  5586. PsnInsuStas string `json:"psn_insu_stas"`
  5587. PsnType string `json:"psn_type"`
  5588. } `json:"insuinfo"`
  5589. } `json:"output"`
  5590. RefmsgTime string `json:"refmsg_time"`
  5591. RespondTime string `json:"respond_time"`
  5592. Signtype interface{} `json:"signtype"`
  5593. WarnInfo interface{} `json:"warn_info"`
  5594. }
  5595. type ResultTwo10265 struct {
  5596. ErrMsg string `json:"err_msg"`
  5597. InfRefmsgid string `json:"inf_refmsgid"`
  5598. Infcode string `json:"infcode"`
  5599. Output struct {
  5600. Baseinfo struct {
  5601. Age float64 `json:"age"`
  5602. Brdy string `json:"brdy"`
  5603. Certno string `json:"certno"`
  5604. Gend string `json:"gend"`
  5605. Naty string `json:"naty"`
  5606. PsnCertType string `json:"psn_cert_type"`
  5607. PsnName string `json:"psn_name"`
  5608. PsnNo string `json:"psn_no"`
  5609. } `json:"baseinfo"`
  5610. Idetinfo []interface{} `json:"idetinfo"`
  5611. Iinfo []struct {
  5612. Balc float64 `json:"balc"`
  5613. CvlservFlag string `json:"cvlserv_flag"`
  5614. EmpName string `json:"emp_name"`
  5615. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5616. Insutype string `json:"insutype"`
  5617. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5618. PausInsuDate string `json:"paus_insu_date"`
  5619. PsnInsuDate string `json:"psn_insu_date"`
  5620. PsnInsuStas string `json:"psn_insu_stas"`
  5621. PsnType string `json:"psn_type"`
  5622. } `json:"insuinfo"`
  5623. } `json:"output"`
  5624. RefmsgTime string `json:"refmsg_time"`
  5625. RespondTime string `json:"respond_time"`
  5626. Signtype interface{} `json:"signtype"`
  5627. WarnInfo interface{} `json:"warn_info"`
  5628. }
  5629. type ResultThree struct {
  5630. Cainfo interface{} `json:"cainfo"`
  5631. ErrMsg string `json:"err_msg"`
  5632. InfRefmsgid string `json:"inf_refmsgid"`
  5633. Infcode int64 `json:"infcode"`
  5634. Output struct {
  5635. Data struct {
  5636. IptOtpNo string `json:"ipt_otp_no"`
  5637. MdtrtID string `json:"mdtrt_id"`
  5638. PsnNo string `json:"psn_no"`
  5639. } `json:"data"`
  5640. } `json:"output"`
  5641. RefmsgTime string `json:"refmsg_time"`
  5642. RespondTime string `json:"respond_time"`
  5643. Signtype interface{} `json:"signtype"`
  5644. WarnMsg interface{} `json:"warn_msg"`
  5645. }
  5646. type ResultThree10265 struct {
  5647. Cainfo interface{} `json:"cainfo"`
  5648. ErrMsg string `json:"err_msg"`
  5649. InfRefmsgid string `json:"inf_refmsgid"`
  5650. Infcode string `json:"infcode"`
  5651. Output struct {
  5652. Data struct {
  5653. IptOtpNo string `json:"ipt_otp_no"`
  5654. MdtrtID string `json:"mdtrt_id"`
  5655. PsnNo string `json:"psn_no"`
  5656. } `json:"data"`
  5657. } `json:"output"`
  5658. RefmsgTime string `json:"refmsg_time"`
  5659. RespondTime string `json:"respond_time"`
  5660. Signtype interface{} `json:"signtype"`
  5661. WarnMsg interface{} `json:"warn_msg"`
  5662. }
  5663. type ResultFour struct {
  5664. Cainfo string `json:"cainfo"`
  5665. ErrMsg string `json:"err_msg"`
  5666. InfRefmsgid string `json:"inf_refmsgid"`
  5667. Infcode int64 `json:"infcode"`
  5668. Output struct {
  5669. Result []struct {
  5670. BasMednFlag string `json:"bas_medn_flag"`
  5671. ChldMedcFlag string `json:"chld_medc_flag"`
  5672. ChrgitmLv string `json:"chrgitm_lv"`
  5673. Cnt float64 `json:"cnt"`
  5674. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5675. DrtReimFlag string `json:"drt_reim_flag"`
  5676. FeedetlSn string `json:"feedetl_sn"`
  5677. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5678. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5679. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5680. ListSpItemFlag string `json:"list_sp_item_flag"`
  5681. LmtUsedFlag string `json:"lmt_used_flag"`
  5682. MedChrgitmType string `json:"med_chrgitm_type"`
  5683. Memo string `json:"memo"`
  5684. OverlmtAmt float64 `json:"overlmt_amt"`
  5685. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5686. Pric float64 `json:"pric"`
  5687. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5688. SelfpayProp float64 `json:"selfpay_prop"`
  5689. } `json:"result"`
  5690. } `json:"output"`
  5691. RefmsgTime string `json:"refmsg_time"`
  5692. RespondTime string `json:"respond_time"`
  5693. Signtype string `json:"signtype"`
  5694. WarnMsg string `json:"warn_msg"`
  5695. }
  5696. type ResultFour10265 struct {
  5697. Cainfo string `json:"cainfo"`
  5698. ErrMsg string `json:"err_msg"`
  5699. InfRefmsgid string `json:"inf_refmsgid"`
  5700. Infcode string `json:"infcode"`
  5701. Output struct {
  5702. Result []struct {
  5703. BasMednFlag string `json:"bas_medn_flag"`
  5704. ChldMedcFlag string `json:"chld_medc_flag"`
  5705. ChrgitmLv string `json:"chrgitm_lv"`
  5706. Cnt float64 `json:"cnt"`
  5707. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  5708. DrtReimFlag string `json:"drt_reim_flag"`
  5709. FeedetlSn string `json:"feedetl_sn"`
  5710. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5711. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  5712. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5713. ListSpItemFlag string `json:"list_sp_item_flag"`
  5714. LmtUsedFlag string `json:"lmt_used_flag"`
  5715. MedChrgitmType string `json:"med_chrgitm_type"`
  5716. Memo string `json:"memo"`
  5717. OverlmtAmt float64 `json:"overlmt_amt"`
  5718. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5719. Pric float64 `json:"pric"`
  5720. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  5721. SelfpayProp float64 `json:"selfpay_prop"`
  5722. } `json:"result"`
  5723. } `json:"output"`
  5724. RefmsgTime string `json:"refmsg_time"`
  5725. RespondTime string `json:"respond_time"`
  5726. Signtype string `json:"signtype"`
  5727. WarnMsg string `json:"warn_msg"`
  5728. }
  5729. type ResultFive struct {
  5730. Balc float64 `json:"balc"`
  5731. CvlservFlag string `json:"cvlserv_flag"`
  5732. EmpName string `json:"emp_name"`
  5733. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  5734. Insutype string `json:"insutype"`
  5735. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  5736. PausInsuDate string `json:"paus_insu_date"`
  5737. PsnInsuDate string `json:"psn_insu_date"`
  5738. PsnInsuStas string `json:"psn_insu_stas"`
  5739. PsnType string `json:"psn_type"`
  5740. }
  5741. type ResultSix struct {
  5742. Cainfo interface{} `json:"cainfo"`
  5743. ErrMsg string `json:"err_msg"`
  5744. InfRefmsgid string `json:"inf_refmsgid"`
  5745. Infcode int64 `json:"infcode"`
  5746. Output struct {
  5747. } `json:"output"`
  5748. RefmsgTime string `json:"refmsg_time"`
  5749. RespondTime string `json:"respond_time"`
  5750. Signtype interface{} `json:"signtype"`
  5751. WarnMsg interface{} `json:"warn_msg"`
  5752. }
  5753. type ResultSix10265 struct {
  5754. Cainfo interface{} `json:"cainfo"`
  5755. ErrMsg string `json:"err_msg"`
  5756. InfRefmsgid string `json:"inf_refmsgid"`
  5757. Infcode string `json:"infcode"`
  5758. Output struct {
  5759. } `json:"output"`
  5760. RefmsgTime string `json:"refmsg_time"`
  5761. RespondTime string `json:"respond_time"`
  5762. Signtype interface{} `json:"signtype"`
  5763. WarnMsg interface{} `json:"warn_msg"`
  5764. }
  5765. type ResultSeven struct {
  5766. Cainfo string `json:"cainfo"`
  5767. ErrMsg string `json:"err_msg"`
  5768. InfRefmsgid string `json:"inf_refmsgid"`
  5769. Infcode int64 `json:"infcode"`
  5770. Output struct {
  5771. Setldetail []interface{} `json:"setldetail"`
  5772. Setlinfo struct {
  5773. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5774. AcctPay float64 `json:"acct_pay"`
  5775. ActPayDedc float64 `json:"act_pay_dedc"`
  5776. Age float64 `json:"age"`
  5777. Balc float64 `json:"balc"`
  5778. Brdy string `json:"brdy"`
  5779. Certno string `json:"certno"`
  5780. ClrOptins string `json:"clr_optins"`
  5781. ClrType string `json:"clr_type"`
  5782. ClrWay string `json:"clr_way"`
  5783. CvlservFlag string `json:"cvlserv_flag"`
  5784. CvlservPay float64 `json:"cvlserv_pay"`
  5785. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5786. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5787. Gend string `json:"gend"`
  5788. HifesPay float64 `json:"hifes_pay"`
  5789. HifmiPay float64 `json:"hifmi_pay"`
  5790. HifpPay float64 `json:"hifp_pay"`
  5791. HospPartAmt float64 `json:"hosp_part_amt"`
  5792. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5793. Insutype string `json:"insutype"`
  5794. MafPay float64 `json:"maf_pay"`
  5795. MdtrtCertType string `json:"mdtrt_cert_type"`
  5796. HifobPay float64 `json:"hifob_pay"`
  5797. MdtrtID string `json:"mdtrt_id"`
  5798. MedType string `json:"med_type"`
  5799. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5800. MedinsSetlID string `json:"medins_setl_id"`
  5801. Naty string `json:"naty"`
  5802. OthPay float64 `json:"oth_pay"`
  5803. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5804. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5805. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5806. PsnCashPay float64 `json:"psn_cash_pay"`
  5807. PsnCertType string `json:"psn_cert_type"`
  5808. PsnName string `json:"psn_name"`
  5809. PsnNo string `json:"psn_no"`
  5810. PsnPartAmt float64 `json:"psn_part_amt"`
  5811. PsnType string `json:"psn_type"`
  5812. SetlID string `json:"setl_id"`
  5813. SetlTime string `json:"setl_time"`
  5814. } `json:"setlinfo"`
  5815. } `json:"output"`
  5816. RefmsgTime string `json:"refmsg_time"`
  5817. RespondTime string `json:"respond_time"`
  5818. Signtype interface{} `json:"signtype"`
  5819. WarnMsg interface{} `json:"warn_msg"`
  5820. }
  5821. type ResultSeven10265 struct {
  5822. Cainfo string `json:"cainfo"`
  5823. ErrMsg string `json:"err_msg"`
  5824. InfRefmsgid string `json:"inf_refmsgid"`
  5825. Infcode string `json:"infcode"`
  5826. Output struct {
  5827. Setldetail []interface{} `json:"setldetail"`
  5828. Setlinfo struct {
  5829. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  5830. AcctPay float64 `json:"acct_pay"`
  5831. ActPayDedc float64 `json:"act_pay_dedc"`
  5832. Age float64 `json:"age"`
  5833. Balc float64 `json:"balc"`
  5834. Brdy string `json:"brdy"`
  5835. Certno string `json:"certno"`
  5836. ClrOptins string `json:"clr_optins"`
  5837. ClrType string `json:"clr_type"`
  5838. ClrWay string `json:"clr_way"`
  5839. CvlservFlag string `json:"cvlserv_flag"`
  5840. CvlservPay float64 `json:"cvlserv_pay"`
  5841. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5842. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5843. Gend string `json:"gend"`
  5844. HifesPay float64 `json:"hifes_pay"`
  5845. HifmiPay float64 `json:"hifmi_pay"`
  5846. HifpPay float64 `json:"hifp_pay"`
  5847. HospPartAmt float64 `json:"hosp_part_amt"`
  5848. InscpScpAmt float64 `json:"inscp_scp_amt"`
  5849. Insutype string `json:"insutype"`
  5850. MafPay float64 `json:"maf_pay"`
  5851. MdtrtCertType string `json:"mdtrt_cert_type"`
  5852. HifobPay float64 `json:"hifob_pay"`
  5853. MdtrtID string `json:"mdtrt_id"`
  5854. MedType string `json:"med_type"`
  5855. MedfeeSumamt float64 `json:"medfee_sumamt"`
  5856. MedinsSetlID string `json:"medins_setl_id"`
  5857. Naty string `json:"naty"`
  5858. OthPay float64 `json:"oth_pay"`
  5859. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5860. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5861. PreselfpayAmt float64 `json:"preselfpay_amt"`
  5862. PsnCashPay float64 `json:"psn_cash_pay"`
  5863. PsnCertType string `json:"psn_cert_type"`
  5864. PsnName string `json:"psn_name"`
  5865. PsnNo string `json:"psn_no"`
  5866. PsnPartAmt float64 `json:"psn_part_amt"`
  5867. PsnType string `json:"psn_type"`
  5868. SetlID string `json:"setl_id"`
  5869. SetlTime string `json:"setl_time"`
  5870. } `json:"setlinfo"`
  5871. } `json:"output"`
  5872. RefmsgTime string `json:"refmsg_time"`
  5873. RespondTime string `json:"respond_time"`
  5874. Signtype interface{} `json:"signtype"`
  5875. WarnMsg interface{} `json:"warn_msg"`
  5876. }
  5877. type ResultEight struct {
  5878. Cainfo string `json:"cainfo"`
  5879. ErrMsg string `json:"err_msg"`
  5880. InfRefmsgid string `json:"inf_refmsgid"`
  5881. Infcode int64 `json:"infcode"`
  5882. Output struct {
  5883. Stmtinfo struct {
  5884. SetlOptins string `json:"setl_optins"`
  5885. StmtRslt string `json:"stmt_rslt"`
  5886. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5887. } `json:"stmtinfo"`
  5888. } `json:"output"`
  5889. RefmsgTime string `json:"refmsg_time"`
  5890. RespondTime string `json:"respond_time"`
  5891. Signtype interface{} `json:"signtype"`
  5892. WarnMsg interface{} `json:"warn_msg"`
  5893. }
  5894. type ResultEightFor10188 struct {
  5895. Cainfo string `json:"cainfo"`
  5896. ErrMsg string `json:"err_msg"`
  5897. InfRefmsgid string `json:"inf_refmsgid"`
  5898. Infcode string `json:"infcode"`
  5899. Output struct {
  5900. Stmtinfo struct {
  5901. SetlOptins string `json:"setl_optins"`
  5902. StmtRslt string `json:"stmt_rslt"`
  5903. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  5904. } `json:"stmtinfo"`
  5905. } `json:"output"`
  5906. RefmsgTime string `json:"refmsg_time"`
  5907. RespondTime string `json:"respond_time"`
  5908. Signtype interface{} `json:"signtype"`
  5909. WarnMsg interface{} `json:"warn_msg"`
  5910. }
  5911. type ResultNine struct {
  5912. Cainfo string `json:"cainfo"`
  5913. ErrMsg string `json:"err_msg"`
  5914. InfRefmsgid string `json:"inf_refmsgid"`
  5915. Infcode int64 `json:"infcode"`
  5916. Output struct {
  5917. FileQuryNo string `json:"file_qury_no"`
  5918. } `json:"output"`
  5919. RefmsgTime string `json:"refmsg_time"`
  5920. RespondTime string `json:"respond_time"`
  5921. Signtype interface{} `json:"signtype"`
  5922. WarnMsg interface{} `json:"warn_msg"`
  5923. }
  5924. type ResultTen struct {
  5925. Cainfo string `json:"cainfo"`
  5926. ErrMsg string `json:"err_msg"`
  5927. InfRefmsgid string `json:"inf_refmsgid"`
  5928. Infcode int64 `json:"infcode"`
  5929. Output struct {
  5930. DldEndtime string `json:"dld_endtime"`
  5931. FileQuryNo string `json:"file_qury_no"`
  5932. Filename string `json:"filename"`
  5933. } `json:"output"`
  5934. RefmsgTime string `json:"refmsg_time"`
  5935. RespondTime string `json:"respond_time"`
  5936. Signtype interface{} `json:"signtype"`
  5937. WarnMsg interface{} `json:"warn_msg"`
  5938. }
  5939. //type Autogenerated struct {
  5940. // Output struct {
  5941. // Setlinfo struct {
  5942. // SetlTime string `json:"setl_time"`
  5943. // CvlservPay float64 `json:"cvlserv_pay"`
  5944. // Year string `json:"year"`
  5945. // MedType string `json:"med_type"`
  5946. // PsnPay float64 `json:"psn_pay"`
  5947. // OpterID string `json:"opter_id"`
  5948. // Begndate string `json:"begndate"`
  5949. // FlxempeFlag string `json:"flxempe_flag"`
  5950. // HifmiPay float64 `json:"hifmi_pay"`
  5951. // PsnNo string `json:"psn_no"`
  5952. // ActPayDedc float64 `json:"act_pay_dedc"`
  5953. // MedinsSetlID interface{} `json:"medins_setl_id"`
  5954. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  5955. // ClrWay string `json:"clr_way"`
  5956. // OthPay float64 `json:"oth_pay"`
  5957. // Gend string `json:"gend"`
  5958. // MdtrtID string `json:"mdtrt_id"`
  5959. // AcctPay float64 `json:"acct_pay"`
  5960. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  5961. // Insutype string `json:"insutype"`
  5962. // Invono interface{} `json:"invono"`
  5963. // Enddate string `json:"enddate"`
  5964. // CashPayamt float64 `json:"cash_payamt"`
  5965. // PsnType string `json:"psn_type"`
  5966. // FixmedinsName string `json:"fixmedins_name"`
  5967. // HifpPay float64 `json:"hifp_pay"`
  5968. // NewFlag interface{} `json:"new_flag"`
  5969. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  5970. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  5971. // PayLoc string `json:"pay_loc"`
  5972. // ClrType string `json:"clr_type"`
  5973. // RefdSetlFlag string `json:"refd_setl_flag"`
  5974. // CvlservFlag string `json:"cvlserv_flag"`
  5975. // EmpName string `json:"emp_name"`
  5976. // Brdy string `json:"brdy"`
  5977. // Naty string `json:"naty"`
  5978. // Certno string `json:"certno"`
  5979. // DiseCode string `json:"dise_code"`
  5980. // FixmedinsCode string `json:"fixmedins_code"`
  5981. // DedcHospLv string `json:"dedc_hosp_lv"`
  5982. // OpterName string `json:"opter_name"`
  5983. // Balc float64 `json:"balc"`
  5984. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  5985. // PsnCertType string `json:"psn_cert_type"`
  5986. // HifobPay float64 `json:"hifob_pay"`
  5987. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  5988. // HifesPay float64 `json:"hifes_pay"`
  5989. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  5990. // OptTime string `json:"opt_time"`
  5991. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  5992. // SetlID string `json:"setl_id"`
  5993. // MafPay float64 `json:"maf_pay"`
  5994. // PsnName string `json:"psn_name"`
  5995. // InsuOptins interface{} `json:"insu_optins"`
  5996. // PrefFundPay interface{} `json:"pref_fund_pay"`
  5997. // ClrOptins string `json:"clr_optins"`
  5998. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  5999. // DiseName string `json:"dise_name"`
  6000. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6001. // Age float64 `json:"age"`
  6002. // DtrtCertType string `json:"dtrt_cert_type"`
  6003. // HospLv string `json:"hosp_lv"`
  6004. // } `json:"setlinfo"`
  6005. // Setldetail []struct {
  6006. // FundPayType string `json:"fund_pay_type"`
  6007. // FundPayamt float64 `json:"fund_payamt"`
  6008. // SetlProcInfo interface{} `json:"setl_proc_info"`
  6009. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  6010. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  6011. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  6012. // PrefFundPay interface{} `json:"pref_fund_pay"`
  6013. // } `json:"setldetail"`
  6014. // } `json:"output"`
  6015. // Infcode int `json:"infcode"`
  6016. // WarnMsg interface{} `json:"warn_msg"`
  6017. // Cainfo interface{} `json:"cainfo"`
  6018. // ErrMsg interface{} `json:"err_msg"`
  6019. // RefmsgTime string `json:"refmsg_time"`
  6020. // Signtype interface{} `json:"signtype"`
  6021. // RespondTime string `json:"respond_time"`
  6022. // InfRefmsgid string `json:"inf_refmsgid"`
  6023. //}
  6024. type ResultEleven struct {
  6025. Cainfo string `json:"cainfo"`
  6026. ErrMsg string `json:"err_msg"`
  6027. InfRefmsgid string `json:"inf_refmsgid"`
  6028. Infcode int64 `json:"infcode"`
  6029. Output struct {
  6030. Setlinfo struct {
  6031. SetlTime string `json:"setl_time"`
  6032. CvlservPay float64 `json:"cvlserv_pay"`
  6033. Year string `json:"year"`
  6034. MedType string `json:"med_type"`
  6035. PsnPay float64 `json:"psn_pay"`
  6036. OpterID string `json:"opter_id"`
  6037. Begndate string `json:"begndate"`
  6038. FlxempeFlag string `json:"flxempe_flag"`
  6039. HifmiPay float64 `json:"hifmi_pay"`
  6040. PsnNo string `json:"psn_no"`
  6041. ActPayDedc float64 `json:"act_pay_dedc"`
  6042. MedinsSetlID interface{} `json:"medins_setl_id"`
  6043. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6044. ClrWay string `json:"clr_way"`
  6045. OthPay float64 `json:"oth_pay"`
  6046. Gend string `json:"gend"`
  6047. MdtrtID string `json:"mdtrt_id"`
  6048. AcctPay float64 `json:"acct_pay"`
  6049. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6050. Insutype string `json:"insutype"`
  6051. Invono interface{} `json:"invono"`
  6052. Enddate string `json:"enddate"`
  6053. CashPayamt float64 `json:"cash_payamt"`
  6054. PsnType string `json:"psn_type"`
  6055. FixmedinsName string `json:"fixmedins_name"`
  6056. HifpPay float64 `json:"hifp_pay"`
  6057. NewFlag interface{} `json:"new_flag"`
  6058. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6059. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6060. PayLoc string `json:"pay_loc"`
  6061. ClrType string `json:"clr_type"`
  6062. RefdSetlFlag string `json:"refd_setl_flag"`
  6063. CvlservFlag string `json:"cvlserv_flag"`
  6064. EmpName string `json:"emp_name"`
  6065. Brdy string `json:"brdy"`
  6066. Naty string `json:"naty"`
  6067. Certno string `json:"certno"`
  6068. DiseCode string `json:"dise_code"`
  6069. FixmedinsCode string `json:"fixmedins_code"`
  6070. DedcHospLv string `json:"dedc_hosp_lv"`
  6071. OpterName string `json:"opter_name"`
  6072. Balc float64 `json:"balc"`
  6073. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6074. PsnCertType string `json:"psn_cert_type"`
  6075. HifobPay float64 `json:"hifob_pay"`
  6076. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6077. HifesPay float64 `json:"hifes_pay"`
  6078. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6079. OptTime string `json:"opt_time"`
  6080. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6081. SetlID string `json:"setl_id"`
  6082. MafPay float64 `json:"maf_pay"`
  6083. PsnName string `json:"psn_name"`
  6084. InsuOptins interface{} `json:"insu_optins"`
  6085. PrefFundPay interface{} `json:"pref_fund_pay"`
  6086. ClrOptins string `json:"clr_optins"`
  6087. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6088. DiseName string `json:"dise_name"`
  6089. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6090. Age float64 `json:"age"`
  6091. DtrtCertType string `json:"dtrt_cert_type"`
  6092. HospLv string `json:"hosp_lv"`
  6093. PsnCashPay float64
  6094. } `json:"setlinfo"`
  6095. } `json:"output"`
  6096. RefmsgTime string `json:"refmsg_time"`
  6097. RespondTime string `json:"respond_time"`
  6098. Signtype interface{} `json:"signtype"`
  6099. WarnMsg interface{} `json:"warn_msg"`
  6100. }
  6101. type ResultEleven10265 struct {
  6102. Cainfo string `json:"cainfo"`
  6103. ErrMsg string `json:"err_msg"`
  6104. InfRefmsgid string `json:"inf_refmsgid"`
  6105. Infcode string `json:"infcode"`
  6106. Output struct {
  6107. Setlinfo struct {
  6108. SetlTime string `json:"setl_time"`
  6109. CvlservPay float64 `json:"cvlserv_pay"`
  6110. Year string `json:"year"`
  6111. MedType string `json:"med_type"`
  6112. PsnPay float64 `json:"psn_pay"`
  6113. OpterID string `json:"opter_id"`
  6114. Begndate string `json:"begndate"`
  6115. FlxempeFlag string `json:"flxempe_flag"`
  6116. HifmiPay float64 `json:"hifmi_pay"`
  6117. PsnNo string `json:"psn_no"`
  6118. ActPayDedc float64 `json:"act_pay_dedc"`
  6119. MedinsSetlID interface{} `json:"medins_setl_id"`
  6120. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  6121. ClrWay string `json:"clr_way"`
  6122. OthPay float64 `json:"oth_pay"`
  6123. Gend string `json:"gend"`
  6124. MdtrtID string `json:"mdtrt_id"`
  6125. AcctPay float64 `json:"acct_pay"`
  6126. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6127. Insutype string `json:"insutype"`
  6128. Invono interface{} `json:"invono"`
  6129. Enddate string `json:"enddate"`
  6130. CashPayamt float64 `json:"cash_payamt"`
  6131. PsnType string `json:"psn_type"`
  6132. FixmedinsName string `json:"fixmedins_name"`
  6133. HifpPay float64 `json:"hifp_pay"`
  6134. NewFlag interface{} `json:"new_flag"`
  6135. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6136. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6137. PayLoc string `json:"pay_loc"`
  6138. ClrType string `json:"clr_type"`
  6139. RefdSetlFlag string `json:"refd_setl_flag"`
  6140. CvlservFlag string `json:"cvlserv_flag"`
  6141. EmpName string `json:"emp_name"`
  6142. Brdy string `json:"brdy"`
  6143. Naty string `json:"naty"`
  6144. Certno string `json:"certno"`
  6145. DiseCode string `json:"dise_code"`
  6146. FixmedinsCode string `json:"fixmedins_code"`
  6147. DedcHospLv string `json:"dedc_hosp_lv"`
  6148. OpterName string `json:"opter_name"`
  6149. Balc float64 `json:"balc"`
  6150. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  6151. PsnCertType string `json:"psn_cert_type"`
  6152. HifobPay float64 `json:"hifob_pay"`
  6153. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6154. HifesPay float64 `json:"hifes_pay"`
  6155. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6156. OptTime string `json:"opt_time"`
  6157. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6158. SetlID string `json:"setl_id"`
  6159. MafPay float64 `json:"maf_pay"`
  6160. PsnName string `json:"psn_name"`
  6161. InsuOptins interface{} `json:"insu_optins"`
  6162. PrefFundPay interface{} `json:"pref_fund_pay"`
  6163. ClrOptins string `json:"clr_optins"`
  6164. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  6165. DiseName string `json:"dise_name"`
  6166. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  6167. Age float64 `json:"age"`
  6168. DtrtCertType string `json:"dtrt_cert_type"`
  6169. HospLv string `json:"hosp_lv"`
  6170. PsnCashPay float64
  6171. } `json:"setlinfo"`
  6172. } `json:"output"`
  6173. RefmsgTime string `json:"refmsg_time"`
  6174. RespondTime string `json:"respond_time"`
  6175. Signtype interface{} `json:"signtype"`
  6176. WarnMsg interface{} `json:"warn_msg"`
  6177. }
  6178. type ResultTwelve struct {
  6179. Cainfo string `json:"cainfo"`
  6180. ErrMsg string `json:"err_msg"`
  6181. InfRefmsgid string `json:"inf_refmsgid"`
  6182. Infcode int64 `json:"infcode"`
  6183. Output struct {
  6184. MdtrtId string `json:"mdtrt_id"`
  6185. ChrgBchno string `json:"chrg_bchno"`
  6186. PsnNo string `json:"psn_no"`
  6187. } `json:"output"`
  6188. RefmsgTime string `json:"refmsg_time"`
  6189. RespondTime string `json:"respond_time"`
  6190. Signtype interface{} `json:"signtype"`
  6191. WarnMsg interface{} `json:"warn_msg"`
  6192. }
  6193. type ResultThirteen struct {
  6194. ErrMsg string `json:"err_msg"`
  6195. InfRefmsgid string `json:"inf_refmsgid"`
  6196. Infcode int64 `json:"infcode"`
  6197. Output struct {
  6198. Result struct {
  6199. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6200. } `json:"result"`
  6201. } `json:"output"`
  6202. RefmsgTime string `json:"refmsg_time"`
  6203. RespondTime string `json:"respond_time"`
  6204. Signtype interface{} `json:"signtype"`
  6205. WarnInfo interface{} `json:"warn_info"`
  6206. }
  6207. type ResultThirteen10265 struct {
  6208. ErrMsg string `json:"err_msg"`
  6209. InfRefmsgid string `json:"inf_refmsgid"`
  6210. Infcode string `json:"infcode"`
  6211. Output struct {
  6212. Result struct {
  6213. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  6214. } `json:"result"`
  6215. } `json:"output"`
  6216. RefmsgTime string `json:"refmsg_time"`
  6217. RespondTime string `json:"respond_time"`
  6218. Signtype interface{} `json:"signtype"`
  6219. WarnInfo interface{} `json:"warn_info"`
  6220. }
  6221. type ResultFourteen struct {
  6222. ErrMsg string `json:"err_msg"`
  6223. InfRefmsgid string `json:"inf_refmsgid"`
  6224. Infcode int64 `json:"infcode"`
  6225. Output struct {
  6226. } `json:"output"`
  6227. RefmsgTime string `json:"refmsg_time"`
  6228. RespondTime string `json:"respond_time"`
  6229. Signtype interface{} `json:"signtype"`
  6230. WarnInfo interface{} `json:"warn_info"`
  6231. }
  6232. type ResultFourteen10265 struct {
  6233. ErrMsg string `json:"err_msg"`
  6234. InfRefmsgid string `json:"inf_refmsgid"`
  6235. Infcode string `json:"infcode"`
  6236. Output struct {
  6237. } `json:"output"`
  6238. RefmsgTime string `json:"refmsg_time"`
  6239. RespondTime string `json:"respond_time"`
  6240. Signtype interface{} `json:"signtype"`
  6241. WarnInfo interface{} `json:"warn_info"`
  6242. }
  6243. type ResultSixteen struct {
  6244. Cainfo string `json:"cainfo"`
  6245. ErrMsg string `json:"err_msg"`
  6246. InfRefmsgid string `json:"inf_refmsgid"`
  6247. Infcode int64 `json:"infcode"`
  6248. Output struct {
  6249. Setldetail []interface{} `json:"setldetail"`
  6250. Setlinfo struct {
  6251. MdtrtID string `json:"mdtrt_id"`
  6252. SetlID string `json:"setl_id"`
  6253. ClrOptins string `json:"clr_optins"`
  6254. SetlTime string `json:"setl_time"`
  6255. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6256. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6257. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6258. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6259. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6260. ActPayDedc float64 `json:"act_pay_dedc"`
  6261. HifpPay float64 `json:"hifp_pay"`
  6262. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6263. Lfpay float64 `json:"selfpay"`
  6264. CvlservPay float64 `json:"cvlserv_pay"`
  6265. HifesPay float64 `json:"hifes_pay"`
  6266. HifmiPay float64 `json:"hifmi_pay"`
  6267. HifobPay float64 `json:"hifob_pay"`
  6268. MafPay float64 `json:"maf_pay"`
  6269. OthPay float64 `json:"oth_pay"`
  6270. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6271. PsnPartAmt float64 `json:"psn_part_amt"`
  6272. AcctPay float64 `json:"acct_pay"`
  6273. Balc float64 `json:"balc"`
  6274. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6275. HospPartAmt float64 `json:"hosp_part_amt"`
  6276. MedinsSetlID string `json:"medins_setl_id"`
  6277. PdnCashPay string `json:"pdn_cash_pay"`
  6278. } `json:"setlinfo"`
  6279. } `json:"output"`
  6280. RefmsgTime string `json:"refmsg_time"`
  6281. RespondTime string `json:"respond_time"`
  6282. Signtype interface{} `json:"signtype"`
  6283. WarnMsg interface{} `json:"warn_msg"`
  6284. }
  6285. type ResultSixteen10265 struct {
  6286. Cainfo string `json:"cainfo"`
  6287. ErrMsg string `json:"err_msg"`
  6288. InfRefmsgid string `json:"inf_refmsgid"`
  6289. Infcode string `json:"infcode"`
  6290. Output struct {
  6291. Setldetail []interface{} `json:"setldetail"`
  6292. Setlinfo struct {
  6293. MdtrtID string `json:"mdtrt_id"`
  6294. SetlID string `json:"setl_id"`
  6295. ClrOptins string `json:"clr_optins"`
  6296. SetlTime string `json:"setl_time"`
  6297. MedfeeSumamt float64 `json:"medfee_sumamt"`
  6298. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6299. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  6300. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6301. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6302. ActPayDedc float64 `json:"act_pay_dedc"`
  6303. HifpPay float64 `json:"hifp_pay"`
  6304. PoolPropSe float64 `json:"pool_prop_selfpay"`
  6305. Lfpay float64 `json:"selfpay"`
  6306. CvlservPay float64 `json:"cvlserv_pay"`
  6307. HifesPay float64 `json:"hifes_pay"`
  6308. HifmiPay float64 `json:"hifmi_pay"`
  6309. HifobPay float64 `json:"hifob_pay"`
  6310. MafPay float64 `json:"maf_pay"`
  6311. OthPay float64 `json:"oth_pay"`
  6312. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  6313. PsnPartAmt float64 `json:"psn_part_amt"`
  6314. AcctPay float64 `json:"acct_pay"`
  6315. Balc float64 `json:"balc"`
  6316. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  6317. HospPartAmt float64 `json:"hosp_part_amt"`
  6318. MedinsSetlID string `json:"medins_setl_id"`
  6319. PdnCashPay string `json:"pdn_cash_pay"`
  6320. } `json:"setlinfo"`
  6321. } `json:"output"`
  6322. RefmsgTime string `json:"refmsg_time"`
  6323. RespondTime string `json:"respond_time"`
  6324. Signtype interface{} `json:"signtype"`
  6325. WarnMsg interface{} `json:"warn_msg"`
  6326. }
  6327. type ResultSeventeen struct {
  6328. ErrMsg string `json:"err_msg"`
  6329. InfRefmsgid string `json:"inf_refmsgid"`
  6330. Infcode int64 `json:"infcode"`
  6331. Output struct {
  6332. SetlListId string `json:"setl_list_id"`
  6333. } `json:"output"`
  6334. RefmsgTime string `json:"refmsg_time"`
  6335. RespondTime string `json:"respond_time"`
  6336. Signtype string `json:"signtype"`
  6337. WarnInfo string `json:"warn_info"`
  6338. }
  6339. type ResultSeventeenOther struct {
  6340. ErrMsg string `json:"err_msg"`
  6341. InfRefmsgid string `json:"inf_refmsgid"`
  6342. Infcode string `json:"infcode"`
  6343. Output struct {
  6344. SetlListId string `json:"setl_list_id"`
  6345. } `json:"output"`
  6346. RefmsgTime string `json:"refmsg_time"`
  6347. RespondTime string `json:"respond_time"`
  6348. Signtype string `json:"signtype"`
  6349. WarnInfo string `json:"warn_info"`
  6350. }
  6351. type Result90991 struct {
  6352. ErrMsg string `json:"err_msg"`
  6353. InfRefmsgid string `json:"inf_refmsgid"`
  6354. Infcode int64 `json:"infcode"`
  6355. Output struct {
  6356. Result struct {
  6357. PsnNo string `json:"psn_no"`
  6358. CardStat string `json:"card_stat"`
  6359. Certno string `json:"certno"`
  6360. PsnName string `json:"psn_name"`
  6361. CheckStat string `json:"check_stat"`
  6362. SscnoCheckStat string `json:"sscno_check_stat"`
  6363. } `json:"result"`
  6364. } `json:"output"`
  6365. RefmsgTime string `json:"refmsg_time"`
  6366. RespondTime string `json:"respond_time"`
  6367. Signtype interface{} `json:"signtype"`
  6368. WarnInfo interface{} `json:"warn_info"`
  6369. }
  6370. type Result90100 struct {
  6371. ErrMsg string `json:"err_msg"`
  6372. InfRefmsgid string `json:"inf_refmsgid"`
  6373. Infcode int64 `json:"infcode"`
  6374. Output struct {
  6375. PoolareaNo string `json:"poolarea_no"`
  6376. PoolareaNoName string `json:"poolarea_no_name"`
  6377. Insutype string `json:"insutype"`
  6378. InsutypeName string `json:"insutype_name"`
  6379. ClctType string `json:"clct_type"`
  6380. ClctTypeName string `json:"clct_type_name"`
  6381. ClctFlag string `json:"clct_flag"`
  6382. ClctFlagName string `json:"clct_flag_name"`
  6383. AccrymBegn string `json:"accrym_begn"`
  6384. AccrymEnd string `json:"accrym_end"`
  6385. ClctTime string `json:"clct_time"`
  6386. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  6387. } `json:"output"`
  6388. RefmsgTime string `json:"refmsg_time"`
  6389. RespondTime string `json:"respond_time"`
  6390. Signtype interface{} `json:"signtype"`
  6391. WarnInfo interface{} `json:"warn_info"`
  6392. }
  6393. type Custom struct {
  6394. DetItemFeeSumamt string
  6395. Cut string
  6396. FeedetlSn string
  6397. Price string
  6398. MedListCodg string
  6399. Type int64
  6400. AdviceId int64
  6401. ProjectId int64
  6402. ItemId int64
  6403. }
  6404. type Result5301 struct {
  6405. ErrMsg string `json:"err_msg"`
  6406. InfRefmsgid string `json:"inf_refmsgid"`
  6407. Infcode int64 `json:"infcode"`
  6408. Output struct {
  6409. Result []struct {
  6410. OpspDiseCode string `json:"opsp_dise_code"`
  6411. OpspDiseName string `json:"opsp_dise_name"`
  6412. Begndate string `json:"begndate"`
  6413. Enddate string `json:"enddate"`
  6414. } `json:"feedetail"`
  6415. } `json:"output"`
  6416. RefmsgTime string `json:"refmsg_time"`
  6417. RespondTime string `json:"respond_time"`
  6418. Signtype interface{} `json:"signtype"`
  6419. WarnInfo interface{} `json:"warn_info"`
  6420. }
  6421. type Result5301For10265 struct {
  6422. ErrMsg string `json:"err_msg"`
  6423. InfRefmsgid string `json:"inf_refmsgid"`
  6424. Infcode string `json:"infcode"`
  6425. Output struct {
  6426. Result []struct {
  6427. OpspDiseCode string `json:"opsp_dise_code"`
  6428. OpspDiseName string `json:"opsp_dise_name"`
  6429. Begndate string `json:"begndate"`
  6430. Enddate string `json:"enddate"`
  6431. } `json:"feedetail"`
  6432. } `json:"output"`
  6433. RefmsgTime string `json:"refmsg_time"`
  6434. RespondTime string `json:"respond_time"`
  6435. Signtype interface{} `json:"signtype"`
  6436. WarnInfo interface{} `json:"warn_info"`
  6437. }
  6438. //获取个人信息----挂号-----上传就诊信息
  6439. func (c *HisApiController) GetRegisterInfo() {
  6440. id, _ := c.GetInt64("id")
  6441. record_time := c.GetString("record_time")
  6442. settlementValue, _ := c.GetInt64("settlement_value")
  6443. medical_insurance_card := c.GetString("medical_insurance_card")
  6444. name := c.GetString("name")
  6445. id_card_type, _ := c.GetInt64("id_card_type")
  6446. certificates, _ := c.GetInt64("certificates")
  6447. medical_care, _ := c.GetInt64("medical_care")
  6448. birthday := c.GetString("birthday")
  6449. id_card := c.GetString("id_card")
  6450. register_type, _ := c.GetInt64("register")
  6451. doctor, _ := c.GetInt64("doctor")
  6452. department, _ := c.GetInt64("department")
  6453. gender, _ := c.GetInt64("sex")
  6454. registration_fee, _ := c.GetFloat("registration_fee")
  6455. medical_expenses, _ := c.GetFloat("medical_expenses")
  6456. social_type, _ := c.GetInt64("social_type")
  6457. med_type := c.GetString("social_type")
  6458. admin_user_id, _ := c.GetInt64("admin_user_id")
  6459. insuplc_admdvs := c.GetString("insuplc_admdvs")
  6460. timeLayout := "2006-01-02"
  6461. loc, _ := time.LoadLocation("Local")
  6462. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  6463. birthUnix := birthdays.Unix()
  6464. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6465. if err != nil {
  6466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6467. return
  6468. }
  6469. recordDateTime := theTime.Unix()
  6470. adminInfo := c.GetAdminUserInfo()
  6471. var patient service.Patients
  6472. if id == 0 {
  6473. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  6474. } else {
  6475. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  6476. }
  6477. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6478. if patientPrescription.ID == 0 {
  6479. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6480. }
  6481. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6482. if patient.ID == 0 {
  6483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6484. return
  6485. }
  6486. if len(patient.IdCardNo) == 0 {
  6487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6488. return
  6489. }
  6490. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6491. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  6492. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  6493. //就诊结算未完成,不能进行二次挂号
  6494. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  6495. if len(his) >= 1 {
  6496. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  6497. if len(his) >= 1 && order.ID == 0 {
  6498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  6499. return
  6500. }
  6501. }
  6502. //var register_log string
  6503. if config.IsOpen == 1 {
  6504. var res ResultTwo
  6505. var res10265 ResultTwo10265
  6506. var PsnNo string
  6507. var PsnCertType string
  6508. var Certno string
  6509. var PsnName string
  6510. var Gend string
  6511. var Naty string
  6512. var Brdy string
  6513. var Age float64
  6514. var infoStr string
  6515. var idetinfoStr string
  6516. var infocode int64
  6517. var verify_number string
  6518. fmt.Println(verify_number)
  6519. if miConfig.MdtrtareaAdmvs == "421300" {
  6520. psn_info, _ := service.GetPsnByPatientId(id)
  6521. PsnNo = psn_info.PsnNo
  6522. PsnCertType = psn_info.PsnCertType
  6523. Certno = psn_info.Certno
  6524. PsnName = psn_info.PsnName
  6525. Gend = psn_info.Gend
  6526. Naty = psn_info.Naty
  6527. Brdy = psn_info.Brdy
  6528. Age = psn_info.Age
  6529. infoStr = psn_info.Insuinfo
  6530. idetinfoStr = psn_info.Idetinfo
  6531. infocode = 0
  6532. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6533. psn_info, _ := service.GetPsnByPatientId(id)
  6534. PsnNo = psn_info.PsnNo
  6535. PsnCertType = psn_info.PsnCertType
  6536. Certno = psn_info.Certno
  6537. PsnName = psn_info.PsnName
  6538. Gend = psn_info.Gend
  6539. Naty = psn_info.Naty
  6540. Brdy = psn_info.Brdy
  6541. Age = psn_info.Age
  6542. infoStr = psn_info.Insuinfo
  6543. idetinfoStr = psn_info.Idetinfo
  6544. infocode = 0
  6545. verify_number = psn_info.VerifyNumber
  6546. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6547. if id_card_type == 1 {
  6548. psn_info, _ := service.GetPsnByPatientId(id)
  6549. PsnNo = psn_info.PsnNo
  6550. PsnCertType = psn_info.PsnCertType
  6551. Certno = psn_info.Certno
  6552. PsnName = psn_info.PsnName
  6553. Gend = psn_info.Gend
  6554. Naty = psn_info.Naty
  6555. Brdy = psn_info.Brdy
  6556. Age = psn_info.Age
  6557. infoStr = psn_info.Insuinfo
  6558. idetinfoStr = psn_info.Idetinfo
  6559. infocode = 0
  6560. verify_number = psn_info.VerifyNumber
  6561. } else if id_card_type == 2 {
  6562. 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)
  6563. fmt.Println(errMsgLog)
  6564. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6565. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6566. utils.ErrorLog("解析失败:%v", err)
  6567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6568. return
  6569. }
  6570. PsnNo = res.Output.Baseinfo.PsnNo
  6571. PsnCertType = res.Output.Baseinfo.PsnCertType
  6572. Certno = res.Output.Baseinfo.Certno
  6573. PsnName = res.Output.Baseinfo.PsnName
  6574. Gend = res.Output.Baseinfo.Gend
  6575. Naty = res.Output.Baseinfo.Naty
  6576. Brdy = res.Output.Baseinfo.Brdy
  6577. Age = res.Output.Baseinfo.Age
  6578. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6579. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6580. infoStr = string(Iinfos)
  6581. idetinfoStr = string(Idetinfos)
  6582. infocode = res.Infcode
  6583. }
  6584. } else if miConfig.MdtrtareaAdmvs == "360399" {
  6585. if id_card_type == 1 {
  6586. psn_info, _ := service.GetPsnByPatientId(id)
  6587. PsnNo = psn_info.PsnNo
  6588. PsnCertType = psn_info.PsnCertType
  6589. Certno = psn_info.Certno
  6590. PsnName = psn_info.PsnName
  6591. Gend = psn_info.Gend
  6592. Naty = psn_info.Naty
  6593. Brdy = psn_info.Brdy
  6594. Age = psn_info.Age
  6595. infoStr = psn_info.Insuinfo
  6596. idetinfoStr = psn_info.Idetinfo
  6597. infocode = 0
  6598. verify_number = psn_info.VerifyNumber
  6599. } else if id_card_type == 2 {
  6600. 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, "")
  6601. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6602. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6603. utils.ErrorLog("解析失败:%v", err)
  6604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6605. return
  6606. }
  6607. PsnNo = res.Output.Baseinfo.PsnNo
  6608. PsnCertType = res.Output.Baseinfo.PsnCertType
  6609. Certno = res.Output.Baseinfo.Certno
  6610. PsnName = res.Output.Baseinfo.PsnName
  6611. Gend = res.Output.Baseinfo.Gend
  6612. Naty = res.Output.Baseinfo.Naty
  6613. Brdy = res.Output.Baseinfo.Brdy
  6614. Age = res.Output.Baseinfo.Age
  6615. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6616. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6617. infoStr = string(Iinfos)
  6618. idetinfoStr = string(Idetinfos)
  6619. infocode = res.Infcode
  6620. }
  6621. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6622. if id_card_type == 1 {
  6623. psn_info, _ := service.GetPsnByPatientId(id)
  6624. PsnNo = psn_info.PsnNo
  6625. PsnCertType = psn_info.PsnCertType
  6626. Certno = psn_info.Certno
  6627. PsnName = psn_info.PsnName
  6628. Gend = psn_info.Gend
  6629. Naty = psn_info.Naty
  6630. Brdy = psn_info.Brdy
  6631. Age = psn_info.Age
  6632. infoStr = psn_info.Insuinfo
  6633. idetinfoStr = psn_info.Idetinfo
  6634. infocode = 0
  6635. verify_number = psn_info.VerifyNumber
  6636. } else if id_card_type == 2 {
  6637. 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)
  6638. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6639. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6640. utils.ErrorLog("解析失败:%v", err)
  6641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6642. return
  6643. }
  6644. PsnNo = res.Output.Baseinfo.PsnNo
  6645. PsnCertType = res.Output.Baseinfo.PsnCertType
  6646. Certno = res.Output.Baseinfo.Certno
  6647. PsnName = res.Output.Baseinfo.PsnName
  6648. Gend = res.Output.Baseinfo.Gend
  6649. Naty = res.Output.Baseinfo.Naty
  6650. Brdy = res.Output.Baseinfo.Brdy
  6651. Age = res.Output.Baseinfo.Age
  6652. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6653. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6654. infoStr = string(Iinfos)
  6655. idetinfoStr = string(Idetinfos)
  6656. infocode = res.Infcode
  6657. }
  6658. } else if miConfig.MdtrtareaAdmvs == "131023" {
  6659. var result string
  6660. var requestLog string
  6661. 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), "")
  6662. if id_card_type == 4 {
  6663. psn_info, _ := service.GetPsnByPatientId(id)
  6664. PsnNo = psn_info.PsnNo
  6665. PsnCertType = psn_info.PsnCertType
  6666. Certno = psn_info.Certno
  6667. PsnName = psn_info.PsnName
  6668. Gend = psn_info.Gend
  6669. Naty = psn_info.Naty
  6670. Brdy = psn_info.Brdy
  6671. Age = psn_info.Age
  6672. infoStr = psn_info.Insuinfo
  6673. idetinfoStr = psn_info.Idetinfo
  6674. infocode = 0
  6675. verify_number = psn_info.VerifyNumber
  6676. } else {
  6677. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6678. if miConfig.Code == "H15049901371" {
  6679. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6680. utils.ErrorLog("解析失败:%v", err)
  6681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6682. return
  6683. }
  6684. res.ErrMsg = res10265.ErrMsg
  6685. res.Output = res10265.Output
  6686. res.InfRefmsgid = res10265.InfRefmsgid
  6687. } else {
  6688. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6689. utils.ErrorLog("解析失败:%v", err)
  6690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6691. return
  6692. }
  6693. }
  6694. PsnNo = res.Output.Baseinfo.PsnNo
  6695. PsnCertType = res.Output.Baseinfo.PsnCertType
  6696. Certno = res.Output.Baseinfo.Certno
  6697. PsnName = res.Output.Baseinfo.PsnName
  6698. Gend = res.Output.Baseinfo.Gend
  6699. Naty = res.Output.Baseinfo.Naty
  6700. Brdy = res.Output.Baseinfo.Brdy
  6701. Age = res.Output.Baseinfo.Age
  6702. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6703. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6704. infoStr = string(Iinfos)
  6705. idetinfoStr = string(Idetinfos)
  6706. if miConfig.Code == "H15049901371" {
  6707. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6708. } else {
  6709. infocode = res.Infcode
  6710. }
  6711. }
  6712. } else {
  6713. var result string
  6714. var requestLog string
  6715. if miConfig.UserOrgId == 10138 {
  6716. if id_card_type != 4 {
  6717. //psn_info, _ := service.GetPsnByPatientId(id)
  6718. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  6719. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  6720. }
  6721. } else {
  6722. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  6723. }
  6724. if id_card_type == 4 {
  6725. psn_info, _ := service.GetPsnByPatientId(id)
  6726. PsnNo = psn_info.PsnNo
  6727. PsnCertType = psn_info.PsnCertType
  6728. Certno = psn_info.Certno
  6729. PsnName = psn_info.PsnName
  6730. Gend = psn_info.Gend
  6731. Naty = psn_info.Naty
  6732. Brdy = psn_info.Brdy
  6733. Age = psn_info.Age
  6734. infoStr = psn_info.Insuinfo
  6735. idetinfoStr = psn_info.Idetinfo
  6736. infocode = 0
  6737. verify_number = psn_info.VerifyNumber
  6738. } else {
  6739. saveLog(result, requestLog, "1101", "人员基本信息获取")
  6740. if miConfig.Code == "H15049901371" {
  6741. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6742. utils.ErrorLog("解析失败:%v", err)
  6743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6744. return
  6745. }
  6746. res.ErrMsg = res10265.ErrMsg
  6747. res.Output = res10265.Output
  6748. res.InfRefmsgid = res10265.InfRefmsgid
  6749. } else {
  6750. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6751. utils.ErrorLog("解析失败:%v", err)
  6752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6753. return
  6754. }
  6755. }
  6756. PsnNo = res.Output.Baseinfo.PsnNo
  6757. PsnCertType = res.Output.Baseinfo.PsnCertType
  6758. Certno = res.Output.Baseinfo.Certno
  6759. PsnName = res.Output.Baseinfo.PsnName
  6760. Gend = res.Output.Baseinfo.Gend
  6761. Naty = res.Output.Baseinfo.Naty
  6762. Brdy = res.Output.Baseinfo.Brdy
  6763. Age = res.Output.Baseinfo.Age
  6764. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6765. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6766. infoStr = string(Iinfos)
  6767. idetinfoStr = string(Idetinfos)
  6768. if miConfig.Code == "H15049901371" {
  6769. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  6770. } else {
  6771. infocode = res.Infcode
  6772. }
  6773. }
  6774. }
  6775. if infocode == 0 {
  6776. his := models.VMHisPatient{
  6777. Name: name,
  6778. Gender: gender,
  6779. Birthday: birthUnix,
  6780. MedicalTreatmentType: medical_care,
  6781. IdType: certificates,
  6782. IdCardNo: id_card,
  6783. BalanceAccountsType: settlementValue,
  6784. SocialType: social_type,
  6785. MedicalInsuranceNumber: medical_insurance_card,
  6786. RegisterType: register_type,
  6787. RegisterCost: registration_fee,
  6788. TreatmentCost: medical_expenses,
  6789. Status: 1,
  6790. Ctime: time.Now().Unix(),
  6791. Mtime: time.Now().Unix(),
  6792. PsnNo: PsnNo,
  6793. PsnCertType: PsnCertType,
  6794. Certno: Certno,
  6795. PsnName: PsnName,
  6796. Gend: Gend,
  6797. Naty: Naty,
  6798. Brdy: Brdy,
  6799. Age: Age,
  6800. Iinfo: infoStr,
  6801. Idetinfo: idetinfoStr,
  6802. PatientId: patient.ID,
  6803. RecordDate: theTime.Unix(),
  6804. UserOrgId: adminInfo.CurrentOrgId,
  6805. AdminUserId: admin_user_id,
  6806. IsReturn: 1,
  6807. IdCardType: id_card_type,
  6808. Doctor: doctor,
  6809. Departments: department,
  6810. }
  6811. timestamp := time.Now().Unix()
  6812. tempTime := time.Unix(timestamp, 0)
  6813. timeFormat := tempTime.Format("20060102150405")
  6814. chrgBchno := rand.Intn(100000) + 10000
  6815. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6816. his.Number = ipt_otp_no
  6817. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  6818. department, _ := service.GetDepartMentDetail(department)
  6819. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  6820. IdCardNo := ""
  6821. if id_card_type == 1 {
  6822. // IdCardNo = medical_insurance_card
  6823. IdCardNo = patient.IdCardNo
  6824. } else {
  6825. IdCardNo = patient.IdCardNo
  6826. }
  6827. var rf []*ResultFive
  6828. json.Unmarshal([]byte(his.Iinfo), &rf)
  6829. var insutypes []*ResultFive
  6830. var insutype string
  6831. var insuplc_admdvs_temp string
  6832. var is390 int = 0
  6833. var is310 int = 0
  6834. for _, item := range rf {
  6835. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6836. insutypes = append(insutypes, item)
  6837. }
  6838. }
  6839. if len(insutypes) == 1 {
  6840. insutype = insutypes[0].Insutype
  6841. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6842. } else {
  6843. for _, i := range insutypes {
  6844. if i.Insutype == "390" {
  6845. is390 = 1
  6846. }
  6847. if i.Insutype == "310" {
  6848. is310 = 1
  6849. }
  6850. }
  6851. }
  6852. if is390 == 1 {
  6853. insutype = "390"
  6854. }
  6855. if is310 == 1 {
  6856. insutype = "310"
  6857. }
  6858. if len(insutypes) == 0 {
  6859. insutype = "310"
  6860. }
  6861. if len(insutypes) == 2 {
  6862. insutype = med_type
  6863. }
  6864. if len(med_type) > 0 {
  6865. insutype = med_type
  6866. }
  6867. var infocode int64
  6868. var resThree ResultThree
  6869. var resThree10265 ResultThree10265
  6870. if len(insuplc_admdvs) == 0 {
  6871. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  6872. } else {
  6873. insuplc_admdvs_temp = insuplc_admdvs
  6874. }
  6875. if miConfig.MdtrtareaAdmvs == "421300" {
  6876. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  6877. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  6878. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6879. "&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
  6880. resp, requestErr := http.Get(api)
  6881. if requestErr != nil {
  6882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6883. return
  6884. }
  6885. body, ioErr := ioutil.ReadAll(resp.Body)
  6886. if ioErr != nil {
  6887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6889. return
  6890. }
  6891. var respJSON map[string]interface{}
  6892. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6895. return
  6896. }
  6897. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6898. result, _ := json.Marshal(respJSON)
  6899. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  6900. utils.ErrorLog("解析失败:%v", err)
  6901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6902. return
  6903. }
  6904. infocode = resThree.Infcode
  6905. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6906. psn_info, _ := service.GetPsnByPatientId(id)
  6907. his.PsnNo = psn_info.PsnNo
  6908. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6909. var cert_no string
  6910. if id_card_type == 3 {
  6911. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  6912. cert_no = IdCardNo
  6913. } else if id_card_type == 4 {
  6914. cert_no = IdCardNo
  6915. psn_info.VerifyNumber = psn_info.VerifyNumber
  6916. } else {
  6917. bas := strings.Split(psn_info.CardInfo, "|")
  6918. cert_no = bas[2]
  6919. }
  6920. var hisPrescription []*models.HisPrescription
  6921. for _, item := range rf {
  6922. if item.Insutype == insutype {
  6923. //insuplc_admdvs = item.InsuplcAdmdvs
  6924. his.InsuplcAdmdvs = insuplc_admdvs
  6925. }
  6926. }
  6927. his.Insutype = insutype
  6928. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  6929. fmt.Println(res3101)
  6930. fmt.Println(res3101.Infcode)
  6931. if res3101.Infcode == "0" {
  6932. fmt.Println("33333333")
  6933. if len(res3101.Output.Result) > 0 {
  6934. fmt.Println("222222")
  6935. for _, item := range res3101.Output.Result {
  6936. if len(res3101.ErrMsg) == 0 {
  6937. res3101.ErrMsg = item.VolaCont
  6938. } else {
  6939. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  6940. }
  6941. }
  6942. c.ServeSuccessJSON(map[string]interface{}{
  6943. "failed_code": -10,
  6944. "msg": res3101.ErrMsg,
  6945. })
  6946. return
  6947. } else {
  6948. fmt.Println("11111")
  6949. var api string
  6950. if miConfig.MdtrtareaAdmvs == "320921" {
  6951. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6952. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6953. "&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
  6954. } else {
  6955. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  6956. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  6957. "&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
  6958. }
  6959. resp, requestErr := http.Get(api)
  6960. if requestErr != nil {
  6961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6962. return
  6963. }
  6964. body, ioErr := ioutil.ReadAll(resp.Body)
  6965. if ioErr != nil {
  6966. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6968. return
  6969. }
  6970. var respJSON map[string]interface{}
  6971. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6974. return
  6975. }
  6976. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6977. result, _ := json.Marshal(respJSON)
  6978. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  6979. utils.ErrorLog("解析失败:%v", err)
  6980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6981. return
  6982. }
  6983. resThree.ErrMsg = resThree10265.ErrMsg
  6984. resThree.Output = resThree10265.Output
  6985. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  6986. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  6987. }
  6988. } else if res3101.Infcode != "0" {
  6989. c.ServeSuccessJSON(map[string]interface{}{
  6990. "failed_code": -10,
  6991. "msg": res3101.ErrMsg,
  6992. })
  6993. return
  6994. }
  6995. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6996. psn_info, _ := service.GetPsnByPatientId(id)
  6997. var cert_no string
  6998. if id_card_type == 1 {
  6999. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  7000. } else if id_card_type == 4 {
  7001. cert_no = psn_info.VerifyNumber
  7002. } else {
  7003. cert_no = psn_info.VerifyNumber
  7004. }
  7005. 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)
  7006. saveLog(result, requestLog, "2201", "挂号")
  7007. if miConfig.Code == "H15049901371" {
  7008. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7009. utils.ErrorLog("解析失败:%v", err)
  7010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7011. return
  7012. }
  7013. resThree.ErrMsg = resThree10265.ErrMsg
  7014. resThree.Output = resThree10265.Output
  7015. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7016. } else {
  7017. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7018. utils.ErrorLog("解析失败:%v", err)
  7019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7020. return
  7021. }
  7022. }
  7023. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7024. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  7025. psn_info, _ := service.GetPsnByPatientId(id)
  7026. var result string
  7027. var requestLog string
  7028. if id_card_type == 1 {
  7029. bas := strings.Split(psn_info.CardInfo, "|")
  7030. basNumber := bas[2]
  7031. card_sn := bas[3]
  7032. 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)
  7033. saveLog(result, requestLog, "2201A", "挂号")
  7034. } else if id_card_type == 2 {
  7035. 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, "", "")
  7036. saveLog(result, requestLog, "2201A", "挂号")
  7037. } else {
  7038. 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, "", "")
  7039. saveLog(result, requestLog, "2201A", "挂号")
  7040. }
  7041. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7042. utils.ErrorLog("解析失败:%v", err)
  7043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7044. return
  7045. }
  7046. infocode = resThree.Infcode
  7047. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  7048. psn_info, _ := service.GetPsnByPatientId(id)
  7049. var result string
  7050. var requestLog string
  7051. if id_card_type == 1 {
  7052. bas := strings.Split(psn_info.CardInfo, "|")
  7053. basNumber := bas[2]
  7054. card_sn := bas[3]
  7055. 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)
  7056. saveLog(result, requestLog, "2201A", "挂号")
  7057. } else if id_card_type == 2 {
  7058. 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, "", "")
  7059. saveLog(result, requestLog, "2201A", "挂号")
  7060. } else {
  7061. 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, "", "")
  7062. saveLog(result, requestLog, "2201A", "挂号")
  7063. }
  7064. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7065. utils.ErrorLog("解析失败:%v", err)
  7066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7067. return
  7068. }
  7069. infocode = resThree.Infcode
  7070. } else if miConfig.MdtrtareaAdmvs == "131023" {
  7071. psn_info, _ := service.GetPsnByPatientId(id)
  7072. 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)
  7073. saveLog(result, requestLog, "2201A", "挂号")
  7074. if miConfig.Code == "H15049901371" {
  7075. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7076. utils.ErrorLog("解析失败:%v", err)
  7077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7078. return
  7079. }
  7080. resThree.ErrMsg = resThree10265.ErrMsg
  7081. resThree.Output = resThree10265.Output
  7082. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7083. } else {
  7084. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7085. utils.ErrorLog("解析失败:%v", err)
  7086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7087. return
  7088. }
  7089. }
  7090. if miConfig.Code == "H15049901371" {
  7091. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7092. } else {
  7093. infocode = resThree.Infcode
  7094. }
  7095. } else {
  7096. psn_info, _ := service.GetPsnByPatientId(id)
  7097. result, requestLog := service.Gdyb2201A(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)
  7098. saveLog(result, requestLog, "2201A", "挂号")
  7099. if miConfig.Code == "H15049901371" {
  7100. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  7101. utils.ErrorLog("解析失败:%v", err)
  7102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7103. return
  7104. }
  7105. resThree.ErrMsg = resThree10265.ErrMsg
  7106. resThree.Output = resThree10265.Output
  7107. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  7108. } else {
  7109. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  7110. utils.ErrorLog("解析失败:%v", err)
  7111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7112. return
  7113. }
  7114. }
  7115. if miConfig.Code == "H15049901371" {
  7116. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  7117. } else {
  7118. infocode = resThree.Infcode
  7119. }
  7120. }
  7121. if infocode != 0 {
  7122. adminUser := c.GetAdminUserInfo()
  7123. errlog := &models.HisOrderError{
  7124. UserOrgId: adminUser.CurrentOrgId,
  7125. Ctime: time.Now().Unix(),
  7126. Mtime: time.Now().Unix(),
  7127. ErrMsg: resThree.ErrMsg,
  7128. Status: 1,
  7129. PatientId: id,
  7130. RecordTime: recordDateTime,
  7131. Stage: 2,
  7132. }
  7133. service.CreateErrMsgLog(errlog)
  7134. c.ServeSuccessJSON(map[string]interface{}{
  7135. "failed_code": -10,
  7136. "msg": resThree.ErrMsg,
  7137. })
  7138. return
  7139. }
  7140. his.Number = resThree.Output.Data.MdtrtID
  7141. his.PsnNo = resThree.Output.Data.PsnNo
  7142. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  7143. his.IdCardNo = patient.IdCardNo
  7144. his.PhoneNumber = patient.Phone
  7145. his.UserOrgId = adminInfo.CurrentOrgId
  7146. his.Insutype = insutype
  7147. his.Ctime = time.Now().Unix()
  7148. his.Mtime = time.Now().Unix()
  7149. his.InsuplcAdmdvs = insuplc_admdvs_temp
  7150. his.Status = 1
  7151. service.UpdateHisPatientStatus(&his)
  7152. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  7153. c.ServeSuccessJSON(map[string]interface{}{
  7154. "his_info": his,
  7155. })
  7156. } else {
  7157. adminUser := c.GetAdminUserInfo()
  7158. errlog := &models.HisOrderError{
  7159. UserOrgId: adminUser.CurrentOrgId,
  7160. Ctime: time.Now().Unix(),
  7161. Mtime: time.Now().Unix(),
  7162. ErrMsg: res.ErrMsg,
  7163. Status: 1,
  7164. PatientId: id,
  7165. RecordTime: recordDateTime,
  7166. Stage: 1,
  7167. }
  7168. service.CreateErrMsgLog(errlog)
  7169. c.ServeSuccessJSON(map[string]interface{}{
  7170. "failed_code": -10,
  7171. "msg": res.ErrMsg,
  7172. })
  7173. return
  7174. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7175. }
  7176. }
  7177. }
  7178. //上传明细----预结算----确认订单
  7179. func (c *HisApiController) GetUploadInfo() {
  7180. id, _ := c.GetInt64("id")
  7181. record_time := c.GetString("record_time")
  7182. his_patient_id, _ := c.GetInt64("his_patient_id")
  7183. order_id, _ := c.GetInt64("order_id")
  7184. pay_way, _ := c.GetInt64("pay_way")
  7185. pay_price, _ := c.GetFloat("pay_price")
  7186. pay_card_no := c.GetString("pay_card_no")
  7187. discount_price, _ := c.GetFloat("discount_price")
  7188. preferential_price, _ := c.GetFloat("preferential_price")
  7189. reality_price, _ := c.GetFloat("reality_price")
  7190. found_price, _ := c.GetFloat("found_price")
  7191. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7192. private_price, _ := c.GetFloat("private_price")
  7193. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7194. admin_user_id, _ := c.GetInt64("admin_user_id")
  7195. fapiao_code := c.GetString("fapiao_code")
  7196. fapiao_number := c.GetString("fapiao_number")
  7197. diagnosis_id := c.GetString("diagnosis")
  7198. sick_type, _ := c.GetInt64("sick_type")
  7199. reg_type, _ := c.GetInt64("p_type")
  7200. begin_time := c.GetString("begin_time")
  7201. id_str := c.GetString("ids")
  7202. ids_arr := strings.Split(id_str, ",")
  7203. timeLayout := "2006-01-02"
  7204. loc, _ := time.LoadLocation("Local")
  7205. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7206. if err != nil {
  7207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7208. return
  7209. }
  7210. recordDateTime := theTime.Unix()
  7211. adminUser := c.GetAdminUserInfo()
  7212. var tempOrder models.HisOrder
  7213. tempOrder, _ = service.GetHisOrderByID(order_id)
  7214. var prescriptions []*models.HisPrescription
  7215. var start_time int64
  7216. var end_time int64
  7217. //押金模块
  7218. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  7219. tmp_decimal := c.GetString("tmp_decimal")
  7220. var decimal float64 //本次使用的押金
  7221. var errmsg error
  7222. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  7223. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  7224. return
  7225. }
  7226. if len(tmp_decimal) > 0 {
  7227. if tmp_decimal[0] == 45 {
  7228. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  7229. return
  7230. }
  7231. }
  7232. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  7233. fmt.Println(errs)
  7234. decimal = tt
  7235. //if adminUser.CurrentOrgId == 10106{
  7236. // if len(fapiao_code) == 0{
  7237. // fapiao_code = "144072080589"
  7238. // }
  7239. // if len(fapiao_number) == 0{
  7240. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  7241. // if order.ID == 0{
  7242. // fapiao_number = "00001520"
  7243. // }else{
  7244. // //fapiao_code = "00001520"
  7245. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  7246. // var zero string
  7247. // if fpNumber >= 1000{
  7248. // zero = "0000" + strconv.Itoa(fpNumber)
  7249. // }else if fpNumber >= 10000{
  7250. // zero = "000" + strconv.Itoa(fpNumber)
  7251. // } else if fpNumber >= 100000{
  7252. // zero = "00" + strconv.Itoa(fpNumber)
  7253. // } else if fpNumber >= 1000000{
  7254. // zero = "0" + strconv.Itoa(fpNumber)
  7255. // }else {
  7256. // zero = strconv.Itoa(fpNumber)
  7257. // }
  7258. // fapiao_number = zero
  7259. // }
  7260. // }
  7261. //}
  7262. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7263. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7264. var patientPrescription models.HisPrescriptionInfo
  7265. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7266. if patientPrescription.ID == 0 {
  7267. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7268. }
  7269. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7270. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7271. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7272. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7273. var config []*models.HisXtDiagnoseConfig
  7274. for _, item := range diagnosis_ids {
  7275. id, _ := strconv.ParseInt(item, 10, 64)
  7276. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7277. config = append(config, &diagnosisConfig)
  7278. }
  7279. sickConfig, _ := service.FindSickById(sick_type)
  7280. //if tempOrder.ID == 0 {
  7281. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  7282. //}
  7283. if tempOrder.ID == 0 {
  7284. var result string
  7285. var requestLog string
  7286. var res2 ResultSix
  7287. var ressix10265 ResultSix10265
  7288. if miConfig.MdtrtareaAdmvs == "421300" {
  7289. data := make(map[string]interface{})
  7290. client := &http.Client{}
  7291. data["psn_no"] = his.PsnNo
  7292. data["mdtrt_id"] = his.Number
  7293. data["opter"] = roles.UserName
  7294. data["org_name"] = miConfig.OrgName
  7295. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7296. data["doctor_id"] = doctor_info.DoctorNumber
  7297. data["doctor_name"] = doctor_info.UserName
  7298. data["department"] = department.Name
  7299. data["fixmedins_code"] = miConfig.Code
  7300. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7301. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7302. data["secret_key"] = miConfig.SecretKey
  7303. data["sick_code"] = sickConfig.CountryCode
  7304. data["sick_name"] = sickConfig.ClassName
  7305. data["dept"] = strconv.FormatInt(department.ID, 10)
  7306. data["config"] = config
  7307. data["begin_time"] = begin_time
  7308. bytesData, _ := json.Marshal(data)
  7309. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7310. resp, _ := client.Do(req)
  7311. defer resp.Body.Close()
  7312. body, ioErr := ioutil.ReadAll(resp.Body)
  7313. if ioErr != nil {
  7314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7316. return
  7317. }
  7318. var respJSON map[string]interface{}
  7319. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7322. return
  7323. }
  7324. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7325. userJSONBytes, _ := json.Marshal(respJSON)
  7326. fmt.Println("log")
  7327. fmt.Println(string(userJSONBytes))
  7328. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7329. utils.ErrorLog("解析失败:%v", err)
  7330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7331. return
  7332. }
  7333. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7334. data := make(map[string]interface{})
  7335. client := &http.Client{}
  7336. data["psn_no"] = his.PsnNo
  7337. data["mdtrt_id"] = his.Number
  7338. data["doctor"] = roles.UserName
  7339. data["department"] = department.Name
  7340. data["org_name"] = miConfig.OrgName
  7341. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7342. data["doctor_id"] = doctor_info.DoctorNumber
  7343. data["new_doctor_name"] = doctor_info.UserName
  7344. data["fixmedins_code"] = miConfig.Code
  7345. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7346. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7347. data["secret_key"] = miConfig.SecretKey
  7348. data["sick_code"] = sickConfig.CountryCode
  7349. data["sick_name"] = sickConfig.ClassName
  7350. data["url"] = miConfig.Url
  7351. data["ak"] = miConfig.AccessKey
  7352. data["begin_time"] = begin_time
  7353. data["cainfo"] = miConfig.Cainfo
  7354. data["dept"] = strconv.FormatInt(department.ID, 10)
  7355. data["config"] = config
  7356. bytesData, _ := json.Marshal(data)
  7357. var req *http.Request
  7358. if miConfig.MdtrtareaAdmvs == "320921" {
  7359. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7360. //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 +
  7361. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7362. } else {
  7363. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7364. }
  7365. resp, _ := client.Do(req)
  7366. defer resp.Body.Close()
  7367. body, ioErr := ioutil.ReadAll(resp.Body)
  7368. if ioErr != nil {
  7369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7371. return
  7372. }
  7373. var respJSON map[string]interface{}
  7374. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7377. return
  7378. }
  7379. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7380. userJSONBytes, _ := json.Marshal(respJSON)
  7381. fmt.Println("log")
  7382. fmt.Println(string(userJSONBytes))
  7383. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  7384. utils.ErrorLog("解析失败:%v", err)
  7385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7386. return
  7387. }
  7388. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7389. res2.Output = ressix10265.Output
  7390. res2.ErrMsg = ressix10265.ErrMsg
  7391. res2.Cainfo = ressix10265.Cainfo
  7392. res2.WarnMsg = ressix10265.WarnMsg
  7393. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7394. res2.Infcode = infocode
  7395. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7396. 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)
  7397. saveLog(result, requestLog, "2203", "上传就诊信息")
  7398. var respJSON2 map[string]interface{}
  7399. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7402. return
  7403. }
  7404. userJSONBytes2, _ := json.Marshal(respJSON2)
  7405. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7406. utils.ErrorLog("解析失败:%v", err)
  7407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7408. return
  7409. }
  7410. } else {
  7411. if miConfig.MdtrtareaAdmvs == "440781" { //
  7412. 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)
  7413. } else {
  7414. if miConfig.Code == "H15049901371" {
  7415. //赤峰地区国家医保医疗类别
  7416. //职工透析:医疗类别选特殊情况门诊990502
  7417. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7418. var med_type string
  7419. if his.Insutype == "390" {
  7420. if reg_type == 14 {
  7421. med_type = "9933"
  7422. } else if reg_type == 11 {
  7423. med_type = "11"
  7424. }
  7425. } else if his.Insutype == "310" {
  7426. if reg_type == 14 {
  7427. med_type = "990502"
  7428. } else if reg_type == 11 {
  7429. med_type = "11"
  7430. }
  7431. }
  7432. 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)
  7433. } else {
  7434. 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)
  7435. }
  7436. }
  7437. saveLog(result, requestLog, "2203", "上传就诊信息")
  7438. var respJSON2 map[string]interface{}
  7439. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7440. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7442. return
  7443. }
  7444. userJSONBytes2, _ := json.Marshal(respJSON2)
  7445. if miConfig.Code == "H15049901371" {
  7446. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  7447. utils.ErrorLog("解析失败:%v", err)
  7448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7449. return
  7450. }
  7451. res2.InfRefmsgid = ressix10265.InfRefmsgid
  7452. res2.Output = ressix10265.Output
  7453. res2.ErrMsg = ressix10265.ErrMsg
  7454. res2.Cainfo = ressix10265.Cainfo
  7455. res2.WarnMsg = ressix10265.WarnMsg
  7456. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  7457. res2.Infcode = infocode
  7458. } else {
  7459. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7460. utils.ErrorLog("解析失败:%v", err)
  7461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7462. return
  7463. }
  7464. }
  7465. }
  7466. if res2.Infcode != 0 {
  7467. adminUser := c.GetAdminUserInfo()
  7468. errlog := &models.HisOrderError{
  7469. UserOrgId: adminUser.CurrentOrgId,
  7470. Ctime: time.Now().Unix(),
  7471. Mtime: time.Now().Unix(),
  7472. ErrMsg: res2.ErrMsg,
  7473. Status: 1,
  7474. PatientId: id,
  7475. RecordTime: recordDateTime,
  7476. Stage: 3,
  7477. }
  7478. service.CreateErrMsgLog(errlog)
  7479. c.ServeSuccessJSON(map[string]interface{}{
  7480. "failed_code": -10,
  7481. "msg": res2.ErrMsg,
  7482. })
  7483. return
  7484. } else {
  7485. his.Diagnosis = diagnosis_id
  7486. his.SickType = sickConfig.ID
  7487. //var p_type int64
  7488. //if reg_type == 1111 || reg_type == 1112 {
  7489. // p_type = 11
  7490. //
  7491. //}
  7492. his.PType = fmt.Sprintf("%d", reg_type)
  7493. service.UpdateHisPatientThree(&his)
  7494. data := make(map[string]interface{})
  7495. if settle_accounts_type == 1 { //日结
  7496. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7497. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7498. } else {
  7499. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7500. }
  7501. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  7502. data["pre"] = prescriptions
  7503. } else { //月结
  7504. start_time_str := c.GetString("start_time")
  7505. end_time_str := c.GetString("end_time")
  7506. timeLayout := "2006-01-02"
  7507. loc, _ := time.LoadLocation("Local")
  7508. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7509. if err != nil {
  7510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7511. return
  7512. }
  7513. recordStartTime := theStartTime.Unix()
  7514. start_time = recordStartTime
  7515. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7516. if err != nil {
  7517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7518. return
  7519. }
  7520. recordEndTime := theEndTime.Unix()
  7521. end_time = recordEndTime
  7522. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7523. data["pre"] = prescriptions
  7524. }
  7525. timestamp := time.Now().Unix()
  7526. tempTime := time.Unix(timestamp, 0)
  7527. timeFormat := tempTime.Format("20060102150405")
  7528. chrgBchno := rand.Intn(100000) + 10000
  7529. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7530. strconv.FormatInt(his.PatientId, 10)
  7531. client := &http.Client{}
  7532. data["psn_no"] = his.PsnNo
  7533. data["mdtrt_id"] = his.Number
  7534. data["chrg_bchno"] = chrg_bchno
  7535. data["org_name"] = miConfig.OrgName
  7536. data["doctor"] = doctor_info.UserName
  7537. data["doctor_id"] = doctor_info.DoctorNumber
  7538. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7539. data["fixmedins_code"] = miConfig.Code
  7540. data["opter"] = roles.UserName
  7541. data["dept_code"] = department.Number
  7542. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7543. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7544. data["secret_key"] = miConfig.SecretKey
  7545. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7546. data["url"] = miConfig.Url
  7547. data["ak"] = miConfig.AccessKey
  7548. data["new_doctor_name"] = patientPrescription.Doctor
  7549. data["diag_code"] = sickConfig.CountryCode
  7550. data["cainfo"] = miConfig.Cainfo
  7551. data["opter"] = roles.UserName
  7552. var ids []int64
  7553. for _, item := range prescriptions {
  7554. ids = append(ids, item.ID)
  7555. }
  7556. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7557. if config.IsOpen == 1 { //对接了医保,走医保流程
  7558. var res ResultFour
  7559. var resFour10265 ResultFour10265
  7560. if miConfig.MdtrtareaAdmvs == "421300" {
  7561. bytesData, _ := json.Marshal(data)
  7562. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7563. resp, _ := client.Do(req)
  7564. defer resp.Body.Close()
  7565. body, ioErr := ioutil.ReadAll(resp.Body)
  7566. if ioErr != nil {
  7567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7569. return
  7570. }
  7571. var respJSON map[string]interface{}
  7572. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7575. return
  7576. }
  7577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7578. userJSONBytes, _ := json.Marshal(respJSON)
  7579. fmt.Println("log")
  7580. fmt.Println(string(userJSONBytes))
  7581. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7582. utils.ErrorLog("解析失败:%v", err)
  7583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7584. return
  7585. }
  7586. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7587. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  7588. if result3101.Infcode == "0" {
  7589. if len(result3101.Output.Result) > 0 {
  7590. var errMsgs []string
  7591. for _, item := range result3101.Output.Result {
  7592. errMsgs = append(errMsgs, item.VolaCont)
  7593. }
  7594. c.ServeSuccessJSON(map[string]interface{}{
  7595. "failed_code": -10,
  7596. "msg": errMsgs,
  7597. })
  7598. return
  7599. }
  7600. }
  7601. if miConfig.MdtrtareaAdmvs == "320921" {
  7602. data["doctor_id"] = "D320923012139"
  7603. } else {
  7604. data["doctor_id"] = "D371621008686"
  7605. }
  7606. bytesData, _ := json.Marshal(data)
  7607. var req *http.Request
  7608. if miConfig.MdtrtareaAdmvs == "320921" {
  7609. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7610. } else {
  7611. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7612. }
  7613. resp, _ := client.Do(req)
  7614. defer resp.Body.Close()
  7615. body, ioErr := ioutil.ReadAll(resp.Body)
  7616. if ioErr != nil {
  7617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7619. return
  7620. }
  7621. var respJSON map[string]interface{}
  7622. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7625. return
  7626. }
  7627. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7628. userJSONBytes, _ := json.Marshal(respJSON)
  7629. fmt.Println("log")
  7630. fmt.Println(string(userJSONBytes))
  7631. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7632. utils.ErrorLog("解析失败:%v", err)
  7633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7634. return
  7635. }
  7636. res.InfRefmsgid = resFour10265.InfRefmsgid
  7637. res.Output = resFour10265.Output
  7638. res.ErrMsg = resFour10265.ErrMsg
  7639. res.Cainfo = resFour10265.Cainfo
  7640. res.WarnMsg = resFour10265.WarnMsg
  7641. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7642. res.Infcode = infocode
  7643. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7644. 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)
  7645. var dat map[string]interface{}
  7646. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7647. fmt.Println(dat)
  7648. } else {
  7649. fmt.Println(err)
  7650. }
  7651. saveLog(result, request_log, "2204", "上传费用明细")
  7652. userJSONBytes, _ := json.Marshal(dat)
  7653. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7654. utils.ErrorLog("解析失败:%v", err)
  7655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7656. return
  7657. }
  7658. res.InfRefmsgid = resFour10265.InfRefmsgid
  7659. res.Output = resFour10265.Output
  7660. res.ErrMsg = resFour10265.ErrMsg
  7661. res.Cainfo = resFour10265.Cainfo
  7662. res.WarnMsg = resFour10265.WarnMsg
  7663. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7664. res.Infcode = infocode
  7665. } else {
  7666. if miConfig.Code == "H15049901371" {
  7667. 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)
  7668. var dat map[string]interface{}
  7669. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7670. fmt.Println(dat)
  7671. } else {
  7672. fmt.Println(err)
  7673. }
  7674. saveLog(result, request_log, "2204", "上传费用明细")
  7675. userJSONBytes, _ := json.Marshal(dat)
  7676. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7677. utils.ErrorLog("解析失败:%v", err)
  7678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7679. return
  7680. }
  7681. res.InfRefmsgid = resFour10265.InfRefmsgid
  7682. res.Output = resFour10265.Output
  7683. res.ErrMsg = resFour10265.ErrMsg
  7684. res.Cainfo = resFour10265.Cainfo
  7685. res.WarnMsg = resFour10265.WarnMsg
  7686. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7687. res.Infcode = infocode
  7688. } else {
  7689. 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)
  7690. var dat map[string]interface{}
  7691. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7692. fmt.Println(dat)
  7693. } else {
  7694. fmt.Println(err)
  7695. }
  7696. saveLog(result, request_log, "2204", "上传费用明细")
  7697. userJSONBytes, _ := json.Marshal(dat)
  7698. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7699. utils.ErrorLog("解析失败:%v", err)
  7700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7701. return
  7702. }
  7703. }
  7704. }
  7705. if res.Infcode == 0 {
  7706. order := &models.HisOrder{
  7707. UserOrgId: adminUser.CurrentOrgId,
  7708. HisPatientId: his.ID,
  7709. PatientId: his.PatientId,
  7710. SettleAccountsDate: recordDateTime,
  7711. MdtrtId: his.Number,
  7712. PsnNo: his.PsnNo,
  7713. MedType: strconv.FormatInt(reg_type, 10),
  7714. Ctime: time.Now().Unix(),
  7715. Mtime: time.Now().Unix(),
  7716. Status: 1,
  7717. Number: chrg_bchno,
  7718. Infcode: res.Infcode,
  7719. WarnMsg: res.WarnMsg,
  7720. Cainfo: res.Cainfo,
  7721. ErrMsg: res.ErrMsg,
  7722. RespondTime: res.RefmsgTime,
  7723. InfRefmsgid: res.InfRefmsgid,
  7724. OrderStatus: 1,
  7725. PayWay: pay_way,
  7726. PayPrice: pay_price,
  7727. PayCardNo: pay_card_no,
  7728. DiscountPrice: discount_price,
  7729. PreferentialPrice: preferential_price,
  7730. RealityPrice: reality_price,
  7731. FoundPrice: found_price,
  7732. MedicalInsurancePrice: medical_insurance_price,
  7733. PrivatePrice: private_price,
  7734. IsMedicineInsurance: 1,
  7735. SettleType: settle_accounts_type,
  7736. SettleStartTime: start_time,
  7737. SettleEndTime: end_time,
  7738. Creator: roles.AdminUserId,
  7739. Modify: roles.AdminUserId,
  7740. FaPiaoNumber: fapiao_number,
  7741. FaPiaoCode: fapiao_code,
  7742. PType: 2,
  7743. Diagnosis: diagnosis_id,
  7744. }
  7745. err = service.CreateOrder(order)
  7746. if err != nil {
  7747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7748. return
  7749. }
  7750. for _, item := range res.Output.Result {
  7751. temp := strings.Split(item.FeedetlSn, "-")
  7752. var advice_id int64 = 0
  7753. var project_id int64 = 0
  7754. var types int64 = 0
  7755. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7756. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7757. if temp[1] == "1" {
  7758. advice_id = id
  7759. project_id = 0
  7760. } else if temp[1] == "2" {
  7761. advice_id = 0
  7762. project_id = id
  7763. }
  7764. if item.MedChrgitmType == "9" {
  7765. item.MedChrgitmType = "09"
  7766. }
  7767. info := &models.HisOrderInfo{
  7768. OrderNumber: order.Number,
  7769. FeedetlSn: item.FeedetlSn,
  7770. UploadDate: time.Now().Unix(),
  7771. AdviceId: advice_id,
  7772. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7773. Cnt: item.Cnt,
  7774. Pric: float64(item.Pric),
  7775. PatientId: his.PatientId,
  7776. PricUplmtAmt: item.PricUplmtAmt,
  7777. SelfpayProp: item.SelfpayProp,
  7778. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7779. OverlmtAmt: item.OverlmtAmt,
  7780. PreselfpayAmt: item.PreselfpayAmt,
  7781. BasMednFlag: item.BasMednFlag,
  7782. MedChrgitmType: item.MedChrgitmType,
  7783. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7784. Status: 1,
  7785. Memo: item.Memo,
  7786. Mtime: time.Now().Unix(),
  7787. InscpScpAmt: item.InscpScpAmt,
  7788. DrtReimFlag: item.DrtReimFlag,
  7789. Ctime: time.Now().Unix(),
  7790. ListSpItemFlag: item.ListSpItemFlag,
  7791. ChldMedcFlag: item.ChldMedcFlag,
  7792. LmtUsedFlag: item.LmtUsedFlag,
  7793. ChrgitmLv: item.ChrgitmLv,
  7794. UserOrgId: adminUser.CurrentOrgId,
  7795. HisPatientId: his.ID,
  7796. OrderId: order.ID,
  7797. ProjectId: project_id,
  7798. Type: types,
  7799. }
  7800. service.CreateOrderInfo(info)
  7801. }
  7802. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7803. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7804. var total float64
  7805. for _, item := range prescriptions {
  7806. if item.Type == 1 { //药品
  7807. for _, subItem := range item.HisDoctorAdviceInfo {
  7808. total = total + (subItem.Price * subItem.PrescribingNumber)
  7809. }
  7810. }
  7811. if item.Type == 2 { //项目
  7812. for _, subItem := range item.HisPrescriptionProject {
  7813. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7814. total = total + (subItem.Price * cnt)
  7815. }
  7816. }
  7817. }
  7818. for _, item := range prescriptions {
  7819. for _, subItem := range item.HisAdditionalCharge {
  7820. total = total + (subItem.Price * float64(subItem.Count))
  7821. }
  7822. }
  7823. var allTotal string
  7824. if adminUser.CurrentOrgId == 9919 {
  7825. allTotal = fmt.Sprintf("%.4f", total)
  7826. } else {
  7827. allTotal = fmt.Sprintf("%.4f", total)
  7828. }
  7829. if res.Infcode == 0 {
  7830. var rf []*ResultFive
  7831. json.Unmarshal([]byte(his.Iinfo), &rf)
  7832. chrg_bchno := chrg_bchno
  7833. cert_no := his.Certno
  7834. var insutypes []string
  7835. var insutype string
  7836. var is390 int = 0
  7837. var is310 int = 0
  7838. for _, item := range rf {
  7839. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7840. insutypes = append(insutypes, item.Insutype)
  7841. }
  7842. }
  7843. if len(insutypes) == 1 {
  7844. insutype = insutypes[0]
  7845. } else {
  7846. for _, i := range insutypes {
  7847. if i == "390" {
  7848. is390 = 1
  7849. }
  7850. if i == "310" {
  7851. is310 = 1
  7852. }
  7853. }
  7854. }
  7855. if is390 == 1 {
  7856. insutype = "390"
  7857. }
  7858. if is310 == 1 {
  7859. insutype = "310"
  7860. }
  7861. if len(insutypes) == 0 {
  7862. insutype = "310"
  7863. }
  7864. if len(insutypes) == 2 {
  7865. insutype = strconv.FormatInt(his.SocialType, 10)
  7866. }
  7867. insutype = strconv.FormatInt(his.SocialType, 10)
  7868. //insutype = "390"
  7869. if his.IdCardType == 1 {
  7870. // cert_no = his.MedicalInsuranceNumber
  7871. cert_no = his.Certno
  7872. } else {
  7873. cert_no = his.Certno
  7874. }
  7875. var res ResultSeven
  7876. var resSeven10265 ResultSeven10265
  7877. var src_resquest string
  7878. var result2 string
  7879. var acct_used_flag string
  7880. fmt.Println("pay_way")
  7881. fmt.Println(pay_way)
  7882. fmt.Println("pay_way")
  7883. if pay_way == 4 {
  7884. acct_used_flag = "1"
  7885. } else {
  7886. acct_used_flag = "0"
  7887. }
  7888. if miConfig.MdtrtareaAdmvs == "421300" {
  7889. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7890. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7891. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7892. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7893. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7894. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7895. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  7896. resp, requestErr := http.Get(api)
  7897. if requestErr != nil {
  7898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7899. return
  7900. }
  7901. body, ioErr := ioutil.ReadAll(resp.Body)
  7902. if ioErr != nil {
  7903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7905. return
  7906. }
  7907. var respJSON map[string]interface{}
  7908. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7911. return
  7912. }
  7913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7914. result, _ := json.Marshal(respJSON)
  7915. if miConfig.Code == "H15049901371" {
  7916. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7917. utils.ErrorLog("解析失败:%v", err)
  7918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7919. return
  7920. }
  7921. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7922. res.Output = resSeven10265.Output
  7923. res.ErrMsg = resSeven10265.ErrMsg
  7924. res.Cainfo = resSeven10265.Cainfo
  7925. res.WarnMsg = resSeven10265.WarnMsg
  7926. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7927. res.Infcode = infocode
  7928. } else {
  7929. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7930. utils.ErrorLog("解析失败:%v", err)
  7931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7932. return
  7933. }
  7934. }
  7935. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7936. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  7937. if result3101.Infcode == "0" {
  7938. if len(result3101.Output.Result) > 0 {
  7939. var errMsgs []string
  7940. for _, item := range result3101.Output.Result {
  7941. errMsgs = append(errMsgs, item.VolaCont)
  7942. }
  7943. c.ServeSuccessJSON(map[string]interface{}{
  7944. "failed_code": -10,
  7945. "msg": errMsgs,
  7946. })
  7947. return
  7948. } else {
  7949. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7950. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7951. bas := strings.Split(psn_info.CardInfo, "|")
  7952. if his.IdCardType == 1 {
  7953. cert_no = bas[2]
  7954. } else if his.IdCardType == 3 {
  7955. cert_no = his.Certno
  7956. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  7957. } else if his.IdCardType == 4 {
  7958. cert_no = his.Certno
  7959. psn_info.VerifyNumber = psn_info.VerifyNumber
  7960. }
  7961. var api string
  7962. if miConfig.MdtrtareaAdmvs == "320921" {
  7963. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7964. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7965. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7966. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7967. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7968. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7969. "&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
  7970. } else {
  7971. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7972. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7973. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7974. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7975. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7976. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7977. "&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
  7978. }
  7979. resp, requestErr := http.Get(api)
  7980. if requestErr != nil {
  7981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7982. return
  7983. }
  7984. body, ioErr := ioutil.ReadAll(resp.Body)
  7985. if ioErr != nil {
  7986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7988. return
  7989. }
  7990. var respJSON map[string]interface{}
  7991. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7994. return
  7995. }
  7996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7997. result, _ := json.Marshal(respJSON)
  7998. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7999. utils.ErrorLog("解析失败:%v", err)
  8000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8001. return
  8002. }
  8003. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8004. res.Output = resSeven10265.Output
  8005. res.ErrMsg = resSeven10265.ErrMsg
  8006. res.Cainfo = resSeven10265.Cainfo
  8007. res.WarnMsg = resSeven10265.WarnMsg
  8008. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8009. res.Infcode = infocode
  8010. }
  8011. }
  8012. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8013. var cert_no string
  8014. if his.IdCardType == 4 {
  8015. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8016. cert_no = psn_info.VerifyNumber
  8017. 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)
  8018. } else if his.IdCardType == 1 {
  8019. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8020. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8021. 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)
  8022. }
  8023. //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)
  8024. var dat map[string]interface{}
  8025. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8026. fmt.Println(dat)
  8027. } else {
  8028. fmt.Println(err)
  8029. }
  8030. saveLog(result2, src_resquest, "2207", "结算")
  8031. userJSONBytes, _ := json.Marshal(dat)
  8032. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8033. utils.ErrorLog("解析失败:%v", err)
  8034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8035. return
  8036. }
  8037. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8038. res.Output = resSeven10265.Output
  8039. res.ErrMsg = resSeven10265.ErrMsg
  8040. res.Cainfo = resSeven10265.Cainfo
  8041. res.WarnMsg = resSeven10265.WarnMsg
  8042. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8043. res.Infcode = infocode
  8044. } else {
  8045. if miConfig.Code == "H15049901371" {
  8046. //赤峰地区国家医保医疗类别
  8047. //职工透析:医疗类别选特殊情况门诊990502
  8048. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8049. var med_type string
  8050. if his.Insutype == "390" {
  8051. if reg_type == 14 {
  8052. med_type = "9933"
  8053. } else if reg_type == 11 {
  8054. med_type = "11"
  8055. }
  8056. } else if his.Insutype == "310" {
  8057. if reg_type == 14 {
  8058. med_type = "990502"
  8059. } else if reg_type == 11 {
  8060. med_type = "11"
  8061. }
  8062. }
  8063. 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, "")
  8064. } else {
  8065. if his.IdCardType == 4 {
  8066. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8067. var token string
  8068. token = psn_info.VerifyNumber
  8069. 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)
  8070. } else {
  8071. 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, "")
  8072. }
  8073. }
  8074. //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)
  8075. var dat map[string]interface{}
  8076. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8077. fmt.Println(dat)
  8078. } else {
  8079. fmt.Println(err)
  8080. }
  8081. saveLog(result2, src_resquest, "2207", "结算")
  8082. userJSONBytes, _ := json.Marshal(dat)
  8083. if miConfig.Code == "H15049901371" {
  8084. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8085. utils.ErrorLog("解析失败:%v", err)
  8086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8087. return
  8088. }
  8089. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8090. res.Output = resSeven10265.Output
  8091. res.ErrMsg = resSeven10265.ErrMsg
  8092. res.Cainfo = resSeven10265.Cainfo
  8093. res.WarnMsg = resSeven10265.WarnMsg
  8094. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8095. res.Infcode = infocode
  8096. } else {
  8097. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8098. utils.ErrorLog("解析失败:%v", err)
  8099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8100. return
  8101. }
  8102. }
  8103. }
  8104. if res.Infcode != 0 {
  8105. errlog := &models.HisOrderError{
  8106. UserOrgId: adminUser.CurrentOrgId,
  8107. Ctime: time.Now().Unix(),
  8108. Mtime: time.Now().Unix(),
  8109. Number: chrg_bchno,
  8110. ErrMsg: res.ErrMsg,
  8111. Status: 1,
  8112. PatientId: id,
  8113. RecordTime: recordDateTime,
  8114. Stage: 6,
  8115. }
  8116. service.CreateErrMsgLog(errlog)
  8117. c.ServeSuccessJSON(map[string]interface{}{
  8118. "failed_code": -10,
  8119. "msg": res.ErrMsg,
  8120. })
  8121. return
  8122. } else {
  8123. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8124. order.OrderStatus = 2
  8125. order.Status = 1
  8126. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8127. order.SetlId = res.Output.Setlinfo.SetlID
  8128. order.PsnNo = res.Output.Setlinfo.PsnNo
  8129. order.PsnName = res.Output.Setlinfo.PsnName
  8130. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8131. order.Certno = res.Output.Setlinfo.Certno
  8132. order.Gend = res.Output.Setlinfo.Gend
  8133. order.Naty = res.Output.Setlinfo.Naty
  8134. order.Age = res.Output.Setlinfo.Age
  8135. order.Insutype = res.Output.Setlinfo.Insutype
  8136. order.PsnType = res.Output.Setlinfo.PsnType
  8137. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8138. order.SetlTime = res.Output.Setlinfo.SetlTime
  8139. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8140. if res.Output.Setlinfo.MedType == "140101" {
  8141. order.MedType = "14"
  8142. } else {
  8143. order.MedType = res.Output.Setlinfo.MedType
  8144. }
  8145. if reg_type == 1112 {
  8146. order.MedType = "1112"
  8147. }
  8148. if reg_type == 1111 {
  8149. order.MedType = "1111"
  8150. }
  8151. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8152. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8153. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8154. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8155. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8156. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8157. order.HifpPay = res.Output.Setlinfo.HifpPay
  8158. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8159. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8160. order.HifesPay = res.Output.Setlinfo.HifesPay
  8161. order.HifobPay = res.Output.Setlinfo.HifobPay
  8162. order.MafPay = res.Output.Setlinfo.MafPay
  8163. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8164. order.OthPay = res.Output.Setlinfo.OthPay
  8165. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8166. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8167. order.AcctPay = res.Output.Setlinfo.AcctPay
  8168. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8169. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8170. order.Balc = res.Output.Setlinfo.Balc
  8171. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8172. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8173. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8174. order.ClrType = res.Output.Setlinfo.ClrType
  8175. order.ClrWay = res.Output.Setlinfo.ClrWay
  8176. order.Creator = order.Creator
  8177. order.Modify = roles.AdminUserId
  8178. order.RequestLog = src_resquest
  8179. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8180. detailStr := string(setlDetail)
  8181. order.SetlDetail = detailStr
  8182. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8183. err = service.UpDateOrder(order)
  8184. if err == nil {
  8185. //判断是否使用了押金
  8186. if dec_way == "true" {
  8187. tmpstring := strconv.FormatInt(order.ID, 10)
  8188. order.Decimal = decimal
  8189. service.UpDateOrder(order)
  8190. //扣押金
  8191. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8192. if errmsg != nil {
  8193. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8194. return
  8195. }
  8196. }
  8197. c.ServeSuccessJSON(map[string]interface{}{
  8198. "msg": "结算成功",
  8199. })
  8200. } else {
  8201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8202. return
  8203. }
  8204. }
  8205. } else {
  8206. adminUser := c.GetAdminUserInfo()
  8207. errlog := &models.HisOrderError{
  8208. UserOrgId: adminUser.CurrentOrgId,
  8209. Ctime: time.Now().Unix(),
  8210. Mtime: time.Now().Unix(),
  8211. ErrMsg: res.ErrMsg,
  8212. Status: 1,
  8213. PatientId: id,
  8214. RecordTime: recordDateTime,
  8215. Stage: 4,
  8216. }
  8217. service.CreateErrMsgLog(errlog)
  8218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8219. return
  8220. }
  8221. } else {
  8222. adminUser := c.GetAdminUserInfo()
  8223. errlog := &models.HisOrderError{
  8224. UserOrgId: adminUser.CurrentOrgId,
  8225. Ctime: time.Now().Unix(),
  8226. Mtime: time.Now().Unix(),
  8227. ErrMsg: res.ErrMsg,
  8228. Status: 1,
  8229. PatientId: id,
  8230. RecordTime: recordDateTime,
  8231. Stage: 4,
  8232. }
  8233. service.CreateErrMsgLog(errlog)
  8234. c.ServeSuccessJSON(map[string]interface{}{
  8235. "failed_code": -10,
  8236. "msg": res.ErrMsg,
  8237. })
  8238. return
  8239. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  8240. //return
  8241. }
  8242. }
  8243. }
  8244. } else if tempOrder.ID > 0 {
  8245. if tempOrder.IsPre == 1 {
  8246. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  8247. var rf []*ResultFive
  8248. json.Unmarshal([]byte(his.Iinfo), &rf)
  8249. chrg_bchno := tempOrder.Number
  8250. cert_no := his.Certno
  8251. var insutypes []string
  8252. var insutype string
  8253. var is390 int = 0
  8254. var is310 int = 0
  8255. for _, item := range rf {
  8256. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8257. insutypes = append(insutypes, item.Insutype)
  8258. }
  8259. }
  8260. if len(insutypes) == 1 {
  8261. insutype = insutypes[0]
  8262. } else {
  8263. for _, i := range insutypes {
  8264. if i == "390" {
  8265. is390 = 1
  8266. }
  8267. if i == "310" {
  8268. is310 = 1
  8269. }
  8270. }
  8271. }
  8272. if is390 == 1 {
  8273. insutype = "390"
  8274. }
  8275. if is310 == 1 {
  8276. insutype = "310"
  8277. }
  8278. if len(insutypes) == 0 {
  8279. insutype = "310"
  8280. }
  8281. if len(insutypes) == 2 {
  8282. insutype = strconv.FormatInt(his.SocialType, 64)
  8283. }
  8284. //insutype = "390"
  8285. if his.IdCardType == 1 {
  8286. // cert_no = his.MedicalInsuranceNumber
  8287. cert_no = his.Certno
  8288. } else {
  8289. cert_no = his.Certno
  8290. }
  8291. var res ResultSeven
  8292. var resSeven10265 ResultSeven10265
  8293. var src_resquest string
  8294. var result2 string
  8295. var acct_used_flag string
  8296. fmt.Println("pay_way")
  8297. fmt.Println(pay_way)
  8298. fmt.Println("pay_way")
  8299. if pay_way == 4 {
  8300. acct_used_flag = "1"
  8301. } else {
  8302. acct_used_flag = "0"
  8303. }
  8304. if miConfig.MdtrtareaAdmvs == "421300" {
  8305. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8306. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8307. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8308. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8309. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8310. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8311. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  8312. resp, requestErr := http.Get(api)
  8313. if requestErr != nil {
  8314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8315. return
  8316. }
  8317. body, ioErr := ioutil.ReadAll(resp.Body)
  8318. if ioErr != nil {
  8319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8321. return
  8322. }
  8323. var respJSON map[string]interface{}
  8324. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8327. return
  8328. }
  8329. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8330. result, _ := json.Marshal(respJSON)
  8331. fmt.Println("log")
  8332. fmt.Println(string(result))
  8333. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8334. utils.ErrorLog("解析失败:%v", err)
  8335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8336. return
  8337. }
  8338. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8339. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  8340. if result3101.Infcode == "0" {
  8341. if len(result3101.Output.Result) > 0 {
  8342. var errMsgs []string
  8343. for _, item := range result3101.Output.Result {
  8344. errMsgs = append(errMsgs, item.VolaCont)
  8345. }
  8346. c.ServeSuccessJSON(map[string]interface{}{
  8347. "failed_code": -10,
  8348. "msg": errMsgs,
  8349. })
  8350. return
  8351. } else {
  8352. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8353. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8354. bas := strings.Split(psn_info.CardInfo, "|")
  8355. if his.IdCardType == 1 {
  8356. cert_no = bas[2]
  8357. } else if his.IdCardType == 3 {
  8358. cert_no = his.Certno
  8359. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  8360. } else if his.IdCardType == 4 {
  8361. cert_no = his.Certno
  8362. psn_info.VerifyNumber = psn_info.VerifyNumber
  8363. }
  8364. //江苏地区国家医保医疗类别
  8365. //职工透析:医疗类别选特殊情况门诊9933
  8366. //居民血透门慢: 医疗类别选门诊慢病1402
  8367. //var med_type string
  8368. //if his.Insutype == "310" {
  8369. // if reg_type == 14 {
  8370. // med_type = "9933"
  8371. // } else if reg_type == 11 {
  8372. // med_type = "11"
  8373. //
  8374. // }
  8375. //} else if his.Insutype == "390" {
  8376. // if reg_type == 14 {
  8377. // med_type = "1402"
  8378. // } else if reg_type == 11 {
  8379. // med_type = "11"
  8380. // }
  8381. //}
  8382. var api string
  8383. if miConfig.MdtrtareaAdmvs == "320921" {
  8384. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8385. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8386. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8387. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8388. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8389. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8390. "&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
  8391. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8392. } else {
  8393. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8394. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  8395. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  8396. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8397. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8398. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  8399. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  8400. "&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
  8401. }
  8402. resp, requestErr := http.Get(api)
  8403. if requestErr != nil {
  8404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8405. return
  8406. }
  8407. body, ioErr := ioutil.ReadAll(resp.Body)
  8408. if ioErr != nil {
  8409. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8411. return
  8412. }
  8413. var respJSON map[string]interface{}
  8414. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8417. return
  8418. }
  8419. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8420. result, _ := json.Marshal(respJSON)
  8421. fmt.Println("log")
  8422. fmt.Println(string(result))
  8423. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  8424. utils.ErrorLog("解析失败:%v", err)
  8425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8426. return
  8427. }
  8428. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8429. res.Output = resSeven10265.Output
  8430. res.ErrMsg = resSeven10265.ErrMsg
  8431. res.Cainfo = resSeven10265.Cainfo
  8432. res.WarnMsg = resSeven10265.WarnMsg
  8433. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8434. res.Infcode = infocode
  8435. }
  8436. }
  8437. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8438. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8439. var cert_no string
  8440. if his.IdCardType == 1 {
  8441. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8442. } else {
  8443. cert_no = psn_info.VerifyNumber
  8444. }
  8445. 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)
  8446. var dat map[string]interface{}
  8447. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8448. fmt.Println(dat)
  8449. } else {
  8450. fmt.Println(err)
  8451. }
  8452. saveLog(result2, src_resquest, "2207", "结算")
  8453. userJSONBytes, _ := json.Marshal(dat)
  8454. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8455. utils.ErrorLog("解析失败:%v", err)
  8456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8457. return
  8458. }
  8459. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8460. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8461. var cert_no string
  8462. if his.IdCardType == 1 {
  8463. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8464. } else if his.IdCardType == 2 {
  8465. cert_no = his.IdCardNo
  8466. } else {
  8467. cert_no = psn_info.VerifyNumber
  8468. }
  8469. 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, "")
  8470. var dat map[string]interface{}
  8471. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8472. fmt.Println(dat)
  8473. } else {
  8474. fmt.Println(err)
  8475. }
  8476. saveLog(result2, src_resquest, "2207", "结算")
  8477. userJSONBytes, _ := json.Marshal(dat)
  8478. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8479. utils.ErrorLog("解析失败:%v", err)
  8480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8481. return
  8482. }
  8483. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8484. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8485. var cert_no string
  8486. if his.IdCardType == 1 {
  8487. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8488. } else if his.IdCardType == 2 {
  8489. cert_no = his.IdCardNo
  8490. } else {
  8491. cert_no = psn_info.VerifyNumber
  8492. }
  8493. 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, "")
  8494. var dat map[string]interface{}
  8495. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8496. fmt.Println(dat)
  8497. } else {
  8498. fmt.Println(err)
  8499. }
  8500. saveLog(result2, src_resquest, "2207", "结算")
  8501. userJSONBytes, _ := json.Marshal(dat)
  8502. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8503. utils.ErrorLog("解析失败:%v", err)
  8504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8505. return
  8506. }
  8507. } else {
  8508. var src_resquest string
  8509. if miConfig.Code == "H15049901371" {
  8510. //赤峰地区国家医保医疗类别
  8511. //职工透析:医疗类别选特殊情况门诊990502
  8512. //居民定额血透门慢: 医疗类别选门诊慢病140104
  8513. var med_type string
  8514. if his.Insutype == "390" {
  8515. if reg_type == 14 {
  8516. med_type = "9933"
  8517. } else if reg_type == 11 {
  8518. med_type = "11"
  8519. }
  8520. } else if his.Insutype == "310" {
  8521. if reg_type == 14 {
  8522. med_type = "990502"
  8523. } else if reg_type == 11 {
  8524. med_type = "11"
  8525. }
  8526. }
  8527. 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, "")
  8528. } else {
  8529. if his.IdCardType == 4 {
  8530. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  8531. token := psn_info.VerifyNumber
  8532. 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)
  8533. } else {
  8534. 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, "")
  8535. }
  8536. }
  8537. var dat map[string]interface{}
  8538. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8539. fmt.Println(dat)
  8540. } else {
  8541. fmt.Println(err)
  8542. }
  8543. saveLog(result2, src_resquest, "2207", "结算")
  8544. userJSONBytes, _ := json.Marshal(dat)
  8545. if miConfig.Code == "H15049901371" {
  8546. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  8547. utils.ErrorLog("解析失败:%v", err)
  8548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8549. return
  8550. }
  8551. res.InfRefmsgid = resSeven10265.InfRefmsgid
  8552. res.Output = resSeven10265.Output
  8553. res.ErrMsg = resSeven10265.ErrMsg
  8554. res.Cainfo = resSeven10265.Cainfo
  8555. res.WarnMsg = resSeven10265.WarnMsg
  8556. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  8557. res.Infcode = infocode
  8558. } else {
  8559. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8560. utils.ErrorLog("解析失败:%v", err)
  8561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8562. return
  8563. }
  8564. }
  8565. }
  8566. if res.Infcode != 0 {
  8567. errlog := &models.HisOrderError{
  8568. UserOrgId: adminUser.CurrentOrgId,
  8569. Ctime: time.Now().Unix(),
  8570. Mtime: time.Now().Unix(),
  8571. Number: chrg_bchno,
  8572. ErrMsg: res.ErrMsg,
  8573. Status: 1,
  8574. PatientId: id,
  8575. RecordTime: recordDateTime,
  8576. Stage: 6,
  8577. }
  8578. service.CreateErrMsgLog(errlog)
  8579. c.ServeSuccessJSON(map[string]interface{}{
  8580. "failed_code": -10,
  8581. "msg": res.ErrMsg,
  8582. })
  8583. return
  8584. } else {
  8585. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8586. order.OrderStatus = 2
  8587. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8588. order.SetlId = res.Output.Setlinfo.SetlID
  8589. order.PsnNo = res.Output.Setlinfo.PsnNo
  8590. order.PsnName = res.Output.Setlinfo.PsnName
  8591. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8592. order.Certno = res.Output.Setlinfo.Certno
  8593. order.Gend = res.Output.Setlinfo.Gend
  8594. order.Naty = res.Output.Setlinfo.Naty
  8595. order.Age = res.Output.Setlinfo.Age
  8596. order.Insutype = res.Output.Setlinfo.Insutype
  8597. order.PsnType = res.Output.Setlinfo.PsnType
  8598. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8599. order.SetlTime = res.Output.Setlinfo.SetlTime
  8600. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8601. //order.MedType = res.Output.Setlinfo.MedType
  8602. if reg_type == 1112 {
  8603. order.MedType = "1112"
  8604. }
  8605. if reg_type == 1111 {
  8606. order.MedType = "1111"
  8607. }
  8608. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8609. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8610. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8611. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8612. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8613. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8614. order.HifpPay = res.Output.Setlinfo.HifpPay
  8615. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8616. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8617. order.HifesPay = res.Output.Setlinfo.HifesPay
  8618. order.HifobPay = res.Output.Setlinfo.HifobPay
  8619. order.MafPay = res.Output.Setlinfo.MafPay
  8620. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  8621. order.OthPay = res.Output.Setlinfo.OthPay
  8622. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8623. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8624. order.AcctPay = res.Output.Setlinfo.AcctPay
  8625. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8626. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8627. order.Balc = res.Output.Setlinfo.Balc
  8628. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8629. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8630. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8631. order.ClrWay = res.Output.Setlinfo.ClrWay
  8632. order.Creator = order.Creator
  8633. order.Modify = roles.AdminUserId
  8634. order.RequestLog = src_resquest
  8635. order.Diagnosis = diagnosis_id
  8636. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8637. detailStr := string(setlDetail)
  8638. order.SetlDetail = detailStr
  8639. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8640. err = service.UpDateOrder(order)
  8641. if err == nil {
  8642. //判断是否使用了押金
  8643. if dec_way == "true" {
  8644. tmpstring := strconv.FormatInt(order.ID, 10)
  8645. //扣押金
  8646. order.Decimal = decimal
  8647. service.UpDateOrder(order)
  8648. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  8649. if errmsg != nil {
  8650. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  8651. return
  8652. }
  8653. }
  8654. c.ServeSuccessJSON(map[string]interface{}{
  8655. "msg": "结算成功",
  8656. })
  8657. } else {
  8658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8659. return
  8660. }
  8661. }
  8662. }
  8663. }
  8664. }
  8665. //func (c *HisApiController) GetPreUploadInfo() {
  8666. // id, _ := c.GetInt64("id")
  8667. // record_time := c.GetString("record_time")
  8668. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  8669. // admin_user_id, _ := c.GetInt64("admin_user_id")
  8670. //
  8671. // timeLayout := "2006-01-02"
  8672. // loc, _ := time.LoadLocation("Local")
  8673. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8674. // if err != nil {
  8675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8676. // return
  8677. // }
  8678. // recordDateTime := theTime.Unix()
  8679. // adminUser := c.GetAdminUserInfo()
  8680. //
  8681. // var prescriptions []*models.HisPrescription
  8682. //
  8683. // var start_time int64
  8684. // var end_time int64
  8685. //
  8686. // data := make(map[string]interface{})
  8687. // if settle_accounts_type == 1 { //日结
  8688. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  8689. // data["pre"] = prescriptions
  8690. //
  8691. // } else { //月结
  8692. // start_time_str := c.GetString("start_time")
  8693. // end_time_str := c.GetString("end_time")
  8694. // timeLayout := "2006-01-02"
  8695. // loc, _ := time.LoadLocation("Local")
  8696. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  8697. // if err != nil {
  8698. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8699. // return
  8700. // }
  8701. // recordStartTime := theStartTime.Unix()
  8702. // start_time = recordStartTime
  8703. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  8704. // if err != nil {
  8705. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8706. // return
  8707. // }
  8708. // recordEndTime := theEndTime.Unix()
  8709. // end_time = recordEndTime
  8710. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  8711. // data["pre"] = prescriptions
  8712. //
  8713. // }
  8714. //
  8715. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8716. //
  8717. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8718. // timestamp := time.Now().Unix()
  8719. // tempTime := time.Unix(timestamp, 0)
  8720. // timeFormat := tempTime.Format("20060102150405")
  8721. // chrgBchno := rand.Intn(100000) + 10000
  8722. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8723. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8724. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  8725. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8726. // strconv.FormatInt(his.PatientId, 10)
  8727. // client := &http.Client{}
  8728. // data["psn_no"] = his.PsnNo
  8729. // data["mdtrt_id"] = his.Number
  8730. // data["chrg_bchno"] = chrg_bchno
  8731. // data["org_name"] = miConfig.OrgName
  8732. // data["doctor"] = roles.UserName
  8733. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  8734. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  8735. // data["fixmedins_code"] = miConfig.Code
  8736. // data["dept_code"] = department.Number
  8737. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  8738. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  8739. // data["secret_key"] = miConfig.SecretKey
  8740. // var ids []int64
  8741. //
  8742. // for _, item := range prescriptions {
  8743. // ids = append(ids, item.ID)
  8744. // }
  8745. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8746. // if config.IsOpen == 1 { //对接了医保,走医保流程
  8747. // bytesData, _ := json.Marshal(data)
  8748. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  8749. // resp, _ := client.Do(req)
  8750. // defer resp.Body.Close()
  8751. // body, ioErr := ioutil.ReadAll(resp.Body)
  8752. // if ioErr != nil {
  8753. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8754. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8755. // return
  8756. // }
  8757. // var respJSON map[string]interface{}
  8758. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8759. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8761. // return
  8762. // }
  8763. //
  8764. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8765. // userJSONBytes, _ := json.Marshal(respJSON)
  8766. // var res ResultFour
  8767. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8768. // utils.ErrorLog("解析失败:%v", err)
  8769. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8770. // return
  8771. // }
  8772. //
  8773. // if res.Infcode == 0 {
  8774. // order := &models.HisOrder{
  8775. // UserOrgId: adminUser.CurrentOrgId,
  8776. // HisPatientId: his.ID,
  8777. // PatientId: his.PatientId,
  8778. // SettleAccountsDate: recordDateTime,
  8779. // Ctime: time.Now().Unix(),
  8780. // Mtime: time.Now().Unix(),
  8781. // Status: 1,
  8782. // Number: chrg_bchno,
  8783. // Infcode: res.Infcode,
  8784. // WarnMsg: res.WarnMsg,
  8785. // Cainfo: res.Cainfo,
  8786. // ErrMsg: res.ErrMsg,
  8787. // RespondTime: res.RefmsgTime,
  8788. // InfRefmsgid: res.InfRefmsgid,
  8789. // OrderStatus: 1,
  8790. // IsMedicineInsurance: 1,
  8791. // SettleType: settle_accounts_type,
  8792. // SettleStartTime: start_time,
  8793. // SettleEndTime: end_time,
  8794. // Creator: roles.ID,
  8795. // Modify: roles.ID,
  8796. // PType: 2,
  8797. // }
  8798. // err = service.CreateOrder(order)
  8799. // if err != nil {
  8800. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  8801. // return
  8802. // }
  8803. //
  8804. // for _, item := range res.Output.Result {
  8805. // temp := strings.Split(item.FeedetlSn, "-")
  8806. // var advice_id int64 = 0
  8807. // var project_id int64 = 0
  8808. // var types int64 = 0
  8809. //
  8810. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  8811. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  8812. //
  8813. // if temp[1] == "1" {
  8814. // advice_id = id
  8815. // project_id = 0
  8816. // } else if temp[1] == "2" {
  8817. // advice_id = 0
  8818. // project_id = id
  8819. // }
  8820. //
  8821. // info := &models.HisOrderInfo{
  8822. // OrderNumber: order.Number,
  8823. // FeedetlSn: item.FeedetlSn,
  8824. // UploadDate: time.Now().Unix(),
  8825. // AdviceId: advice_id,
  8826. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  8827. // Cnt: item.Cnt,
  8828. // Pric: float64(item.Pric),
  8829. // PatientId: his.PatientId,
  8830. // PricUplmtAmt: item.PricUplmtAmt,
  8831. // SelfpayProp: item.SelfpayProp,
  8832. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  8833. // OverlmtAmt: item.OverlmtAmt,
  8834. // PreselfpayAmt: item.PreselfpayAmt,
  8835. // BasMednFlag: item.BasMednFlag,
  8836. // MedChrgitmType: item.MedChrgitmType,
  8837. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  8838. // Status: 1,
  8839. // Memo: item.Memo,
  8840. // Mtime: time.Now().Unix(),
  8841. // InscpScpAmt: item.InscpScpAmt,
  8842. // DrtReimFlag: item.DrtReimFlag,
  8843. // Ctime: time.Now().Unix(),
  8844. // ListSpItemFlag: item.ListSpItemFlag,
  8845. // ChldMedcFlag: item.ChldMedcFlag,
  8846. // LmtUsedFlag: item.LmtUsedFlag,
  8847. // ChrgitmLv: item.ChrgitmLv,
  8848. // UserOrgId: adminUser.CurrentOrgId,
  8849. // HisPatientId: his.ID,
  8850. // OrderId: order.ID,
  8851. // ProjectId: project_id,
  8852. // Type: types,
  8853. // }
  8854. // service.CreateOrderInfo(info)
  8855. //
  8856. // }
  8857. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  8858. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  8859. //
  8860. // var total float64
  8861. // for _, item := range prescriptions {
  8862. // if item.Type == 1 { //药品
  8863. // for _, subItem := range item.HisDoctorAdviceInfo {
  8864. // total = total + (subItem.Price * subItem.PrescribingNumber)
  8865. // }
  8866. // }
  8867. // if item.Type == 2 { //项目
  8868. // for _, subItem := range item.HisPrescriptionProject {
  8869. // total = total + (subItem.Price * float64(subItem.Count))
  8870. // }
  8871. // }
  8872. // }
  8873. //
  8874. // for _, item := range prescriptions {
  8875. // for _, subItem := range item.HisAdditionalCharge {
  8876. // total = total + (subItem.Price * float64(subItem.Count))
  8877. // }
  8878. // }
  8879. //
  8880. // allTotal := fmt.Sprintf("%.2f", total)
  8881. // if res.Infcode == 0 {
  8882. // var rf []*ResultFive
  8883. // json.Unmarshal([]byte(his.Iinfo), &rf)
  8884. // psn_no := his.PsnNo
  8885. // mdtrt_id := his.Number
  8886. // chrg_bchno := chrg_bchno
  8887. // cert_no := his.Certno
  8888. // insutype := rf[0].Insutype
  8889. //
  8890. // if his.IdCardType == 1 {
  8891. // cert_no = his.MedicalInsuranceNumber
  8892. //
  8893. // } else {
  8894. //
  8895. // cert_no = his.Certno
  8896. //
  8897. // }
  8898. //
  8899. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  8900. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  8901. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  8902. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  8903. // resp, requestErr := http.Get(api)
  8904. // if requestErr != nil {
  8905. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8906. // return
  8907. // }
  8908. // defer resp.Body.Close()
  8909. // body, ioErr := ioutil.ReadAll(resp.Body)
  8910. // if ioErr != nil {
  8911. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8913. // return
  8914. // }
  8915. // var respJSON map[string]interface{}
  8916. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8917. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8919. // return
  8920. // }
  8921. // fmt.Println(respJSON)
  8922. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8923. // userJSONBytes, _ := json.Marshal(respJSON)
  8924. // var res ResultSeven
  8925. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8926. // utils.ErrorLog("解析失败:%v", err)
  8927. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8928. // return
  8929. // }
  8930. // if res.Infcode != 0 {
  8931. // errlog := &models.HisOrderError{
  8932. // UserOrgId: adminUser.CurrentOrgId,
  8933. // Ctime: time.Now().Unix(),
  8934. // Mtime: time.Now().Unix(),
  8935. // Number: chrg_bchno,
  8936. // ErrMsg: res.ErrMsg,
  8937. // Status: 1,
  8938. // PatientId: id,
  8939. // RecordTime: recordDateTime,
  8940. // Stage: 7,
  8941. // }
  8942. // service.CreateErrMsgLog(errlog)
  8943. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  8944. // return
  8945. // } else {
  8946. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  8947. // order.OrderStatus = 1
  8948. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  8949. // order.SetlId = res.Output.Setlinfo.SetlID
  8950. // order.PsnNo = res.Output.Setlinfo.PsnNo
  8951. // order.PsnName = res.Output.Setlinfo.PsnName
  8952. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  8953. // order.Certno = res.Output.Setlinfo.Certno
  8954. // order.Gend = res.Output.Setlinfo.Gend
  8955. // order.Naty = res.Output.Setlinfo.Naty
  8956. // order.Age = res.Output.Setlinfo.Age
  8957. // order.Insutype = res.Output.Setlinfo.Insutype
  8958. // order.PsnType = res.Output.Setlinfo.PsnType
  8959. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  8960. // order.SetlTime = res.Output.Setlinfo.SetlTime
  8961. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  8962. // order.MedType = res.Output.Setlinfo.MedType
  8963. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  8964. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  8965. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  8966. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  8967. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  8968. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  8969. // order.HifpPay = res.Output.Setlinfo.HifpPay
  8970. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  8971. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  8972. // order.HifesPay = res.Output.Setlinfo.HifesPay
  8973. // order.HifobPay = res.Output.Setlinfo.HifobPay
  8974. // order.MafPay = res.Output.Setlinfo.MafPay
  8975. // order.OthPay = res.Output.Setlinfo.OthPay
  8976. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  8977. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  8978. // order.AcctPay = res.Output.Setlinfo.AcctPay
  8979. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  8980. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  8981. // order.Balc = res.Output.Setlinfo.Balc
  8982. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  8983. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  8984. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  8985. // order.ClrWay = res.Output.Setlinfo.ClrWay
  8986. // order.Creator = order.Creator
  8987. // order.Modify = roles.ID
  8988. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  8989. // detailStr := string(setlDetail)
  8990. // order.SetlDetail = detailStr
  8991. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  8992. // err = service.UpDateOrder(order)
  8993. // if err == nil {
  8994. // c.ServeSuccessJSON(map[string]interface{}{
  8995. // "msg": "预结算成功",
  8996. // })
  8997. // } else {
  8998. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  8999. // return
  9000. // }
  9001. // }
  9002. // } else {
  9003. // adminUser := c.GetAdminUserInfo()
  9004. // errlog := &models.HisOrderError{
  9005. // UserOrgId: adminUser.CurrentOrgId,
  9006. // Ctime: time.Now().Unix(),
  9007. // Mtime: time.Now().Unix(),
  9008. // ErrMsg: res.ErrMsg,
  9009. // Status: 1,
  9010. // PatientId: id,
  9011. // RecordTime: recordDateTime,
  9012. // Stage: 4,
  9013. // }
  9014. // service.CreateErrMsgLog(errlog)
  9015. //
  9016. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  9017. // return
  9018. // }
  9019. // } else {
  9020. // adminUser := c.GetAdminUserInfo()
  9021. // errlog := &models.HisOrderError{
  9022. // UserOrgId: adminUser.CurrentOrgId,
  9023. // Ctime: time.Now().Unix(),
  9024. // Mtime: time.Now().Unix(),
  9025. // ErrMsg: res.ErrMsg,
  9026. // Status: 1,
  9027. // PatientId: id,
  9028. // RecordTime: recordDateTime,
  9029. // Stage: 4,
  9030. // }
  9031. // service.CreateErrMsgLog(errlog)
  9032. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  9033. // return
  9034. // }
  9035. //
  9036. // } else {
  9037. // var total float64
  9038. // for _, item := range prescriptions {
  9039. // if item.Type == 1 { //药品
  9040. // for _, subItem := range item.HisDoctorAdviceInfo {
  9041. // total = total + (subItem.Price * subItem.PrescribingNumber)
  9042. // }
  9043. // }
  9044. // if item.Type == 2 { //项目
  9045. // for _, subItem := range item.HisPrescriptionProject {
  9046. // total = total + (subItem.Price * float64(subItem.Count))
  9047. // }
  9048. // }
  9049. //
  9050. // for _, subItem := range item.HisAdditionalCharge {
  9051. // total = total + (subItem.Price * float64(subItem.Count))
  9052. // }
  9053. // }
  9054. //
  9055. // allTotal := fmt.Sprintf("%.2f", total)
  9056. // totals, _ := strconv.ParseFloat(allTotal, 64)
  9057. // order := &models.HisOrder{
  9058. // UserOrgId: adminUser.CurrentOrgId,
  9059. // HisPatientId: his.ID,
  9060. // PatientId: id,
  9061. // SettleAccountsDate: recordDateTime,
  9062. // Ctime: time.Now().Unix(),
  9063. // Mtime: time.Now().Unix(),
  9064. // Status: 1,
  9065. // OrderStatus: 2,
  9066. // Number: chrg_bchno,
  9067. // MedfeeSumamt: totals,
  9068. // }
  9069. // err = service.CreateOrder(order)
  9070. // if err != nil {
  9071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9072. // return
  9073. // }
  9074. //
  9075. // var customs []*Custom
  9076. // for _, item := range prescriptions {
  9077. //
  9078. // if item.Type == 1 { //药品
  9079. // for _, subItem := range item.HisDoctorAdviceInfo {
  9080. // cus := &Custom{
  9081. // AdviceId: subItem.ID,
  9082. // ProjectId: 0,
  9083. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  9084. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  9085. // FeedetlSn: subItem.FeedetlSn,
  9086. // Price: fmt.Sprintf("%.2f", subItem.Price),
  9087. // MedListCodg: subItem.MedListCodg,
  9088. // Type: 1,
  9089. // }
  9090. // customs = append(customs, cus)
  9091. // }
  9092. // }
  9093. //
  9094. // if item.Type == 2 { //项目
  9095. // for _, subItem := range item.HisPrescriptionProject {
  9096. //
  9097. // cus := &Custom{
  9098. // AdviceId: 0,
  9099. // ProjectId: subItem.ID,
  9100. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  9101. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  9102. // FeedetlSn: subItem.FeedetlSn,
  9103. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  9104. // MedListCodg: subItem.MedListCodg,
  9105. // Type: 2,
  9106. // }
  9107. //
  9108. // customs = append(customs, cus)
  9109. // }
  9110. // }
  9111. //
  9112. // for _, item := range item.HisAdditionalCharge {
  9113. // cus := &Custom{
  9114. // ItemId: item.ID,
  9115. // AdviceId: 0,
  9116. // ProjectId: 0,
  9117. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  9118. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  9119. // FeedetlSn: item.FeedetlSn,
  9120. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  9121. // MedListCodg: item.XtHisAddtionConfig.Code,
  9122. // Type: 3,
  9123. // }
  9124. //
  9125. // customs = append(customs, cus)
  9126. // }
  9127. //
  9128. // }
  9129. //
  9130. // for _, item := range customs {
  9131. // var advice_id int64 = 0
  9132. // var project_id int64 = 0
  9133. // var item_id int64 = 0
  9134. //
  9135. // var types int64 = 0
  9136. //
  9137. // if item.Type == 1 {
  9138. // advice_id = item.AdviceId
  9139. // project_id = 0
  9140. // item_id = 0
  9141. // } else if item.Type == 2 {
  9142. // advice_id = 0
  9143. // item_id = 0
  9144. //
  9145. // project_id = item.ProjectId
  9146. // } else if item.Type == 3 {
  9147. // advice_id = 0
  9148. // item_id = item.ItemId
  9149. // project_id = 0
  9150. // }
  9151. //
  9152. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  9153. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  9154. // pric, _ := strconv.ParseFloat(item.Price, 32)
  9155. //
  9156. // info := &models.HisOrderInfo{
  9157. // OrderNumber: order.Number,
  9158. // UploadDate: time.Now().Unix(),
  9159. // AdviceId: advice_id,
  9160. // DetItemFeeSumamt: detItemFeeSumamt,
  9161. // Cnt: cut,
  9162. // Pric: pric,
  9163. // PatientId: id,
  9164. // Status: 1,
  9165. // Mtime: time.Now().Unix(),
  9166. // Ctime: time.Now().Unix(),
  9167. // UserOrgId: adminUser.CurrentOrgId,
  9168. // HisPatientId: his.ID,
  9169. // OrderId: order.ID,
  9170. // ProjectId: project_id,
  9171. // Type: types,
  9172. // ItemId: item_id,
  9173. // }
  9174. // service.CreateOrderInfo(info)
  9175. // }
  9176. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9177. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9178. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  9179. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  9180. // if err == nil {
  9181. // c.ServeSuccessJSON(map[string]interface{}{
  9182. // "msg": "结算成功",
  9183. // })
  9184. // } else {
  9185. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  9186. // return
  9187. // }
  9188. // }
  9189. //}
  9190. //上传明细-预结算-
  9191. func (c *HisApiController) GetPreUploadInfo() {
  9192. id, _ := c.GetInt64("id")
  9193. record_time := c.GetString("record_time")
  9194. his_patient_id, _ := c.GetInt64("his_patient_id")
  9195. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9196. admin_user_id, _ := c.GetInt64("admin_user_id")
  9197. diagnosis_id := c.GetString("diagnosis")
  9198. sick_type, _ := c.GetInt64("sick_type")
  9199. reg_type, _ := c.GetInt64("p_type")
  9200. begin_time := c.GetString("begin_time")
  9201. id_str := c.GetString("ids")
  9202. ids_arr := strings.Split(id_str, ",")
  9203. timeLayout := "2006-01-02"
  9204. loc, _ := time.LoadLocation("Local")
  9205. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9206. if err != nil {
  9207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9208. return
  9209. }
  9210. recordDateTime := theTime.Unix()
  9211. adminUser := c.GetAdminUserInfo()
  9212. diagnosis_ids := strings.Split(diagnosis_id, ",")
  9213. var config []*models.HisXtDiagnoseConfig
  9214. for _, item := range diagnosis_ids {
  9215. id, _ := strconv.ParseInt(item, 10, 64)
  9216. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9217. config = append(config, &diagnosisConfig)
  9218. }
  9219. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9220. sickConfig, _ := service.FindSickById(sick_type)
  9221. var prescriptions []*models.HisPrescription
  9222. var start_time int64
  9223. var end_time int64
  9224. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9225. fmt.Println(his_patient_id)
  9226. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9227. timestamp := time.Now().Unix()
  9228. tempTime := time.Unix(timestamp, 0)
  9229. timeFormat := tempTime.Format("20060102150405")
  9230. chrgBchno := rand.Intn(100000) + 10000
  9231. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9232. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9233. var patientPrescription models.HisPrescriptionInfo
  9234. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9235. if patientPrescription.ID == 0 {
  9236. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9237. }
  9238. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9239. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9240. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9241. strconv.FormatInt(his.PatientId, 10)
  9242. var res2 ResultSix
  9243. var resSix10265 ResultSix10265
  9244. //var time_stamp string
  9245. if miConfig.MdtrtareaAdmvs == "421300" {
  9246. data := make(map[string]interface{})
  9247. client := &http.Client{}
  9248. data["psn_no"] = his.PsnNo
  9249. data["mdtrt_id"] = his.Number
  9250. data["department"] = department.Name
  9251. data["org_name"] = miConfig.OrgName
  9252. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9253. data["doctor_id"] = doctor_info.DoctorNumber
  9254. data["doctor_name"] = roles.UserName
  9255. data["fixmedins_code"] = miConfig.Code
  9256. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  9257. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9258. data["secret_key"] = miConfig.SecretKey
  9259. data["sick_code"] = sickConfig.CountryCode
  9260. data["sick_name"] = sickConfig.ClassName
  9261. data["begin_time"] = begin_time
  9262. data["dept"] = strconv.FormatInt(department.ID, 10)
  9263. data["config"] = config
  9264. data["opter"] = roles.UserName
  9265. fmt.Println(data)
  9266. bytesData, _ := json.Marshal(data)
  9267. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  9268. resp, _ := client.Do(req)
  9269. defer resp.Body.Close()
  9270. body, ioErr := ioutil.ReadAll(resp.Body)
  9271. if ioErr != nil {
  9272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9274. return
  9275. }
  9276. var respJSON map[string]interface{}
  9277. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9280. return
  9281. }
  9282. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9283. userJSONBytes, _ := json.Marshal(respJSON)
  9284. fmt.Println("log")
  9285. fmt.Println(string(userJSONBytes))
  9286. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9287. utils.ErrorLog("解析失败:%v", err)
  9288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9289. return
  9290. }
  9291. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9292. data := make(map[string]interface{})
  9293. client := &http.Client{}
  9294. data["psn_no"] = his.PsnNo
  9295. data["mdtrt_id"] = his.Number
  9296. data["doctor"] = roles.UserName
  9297. data["department"] = department.Name
  9298. data["org_name"] = miConfig.OrgName
  9299. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9300. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  9301. data["fixmedins_code"] = miConfig.Code
  9302. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9303. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9304. data["secret_key"] = miConfig.SecretKey
  9305. data["sick_code"] = sickConfig.CountryCode
  9306. data["sick_name"] = sickConfig.ClassName
  9307. data["begin_time"] = begin_time
  9308. data["dept"] = strconv.FormatInt(department.ID, 10)
  9309. data["config"] = config
  9310. data["url"] = miConfig.Url
  9311. data["ak"] = miConfig.AccessKey
  9312. data["cainfo"] = miConfig.Cainfo
  9313. bytesData, _ := json.Marshal(data)
  9314. var req *http.Request
  9315. if miConfig.MdtrtareaAdmvs == "320921" {
  9316. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9317. } else {
  9318. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9319. }
  9320. resp, _ := client.Do(req)
  9321. defer resp.Body.Close()
  9322. body, ioErr := ioutil.ReadAll(resp.Body)
  9323. if ioErr != nil {
  9324. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9326. return
  9327. }
  9328. var respJSON map[string]interface{}
  9329. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9330. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9332. return
  9333. }
  9334. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  9335. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  9336. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  9337. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9338. userJSONBytes, _ := json.Marshal(respJSON)
  9339. fmt.Println("log")
  9340. fmt.Println(string(userJSONBytes))
  9341. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  9342. utils.ErrorLog("解析失败:%v", err)
  9343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9344. return
  9345. }
  9346. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9347. res2.Output = resSix10265.Output
  9348. res2.ErrMsg = resSix10265.ErrMsg
  9349. res2.Cainfo = resSix10265.Cainfo
  9350. res2.WarnMsg = resSix10265.WarnMsg
  9351. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9352. res2.Infcode = infocode
  9353. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9354. 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)
  9355. saveLog(result, requestLog, "2203", "上传就诊信息")
  9356. var respJSON2 map[string]interface{}
  9357. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9360. return
  9361. }
  9362. userJSONBytes2, _ := json.Marshal(respJSON2)
  9363. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9364. utils.ErrorLog("解析失败:%v", err)
  9365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9366. return
  9367. }
  9368. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9369. var result string
  9370. var requestLog string
  9371. 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, "")
  9372. saveLog(result, requestLog, "2203", "上传就诊信息")
  9373. var respJSON2 map[string]interface{}
  9374. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9377. return
  9378. }
  9379. userJSONBytes2, _ := json.Marshal(respJSON2)
  9380. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9381. utils.ErrorLog("解析失败:%v", err)
  9382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9383. return
  9384. }
  9385. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9386. var result string
  9387. var requestLog string
  9388. 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, "")
  9389. saveLog(result, requestLog, "2203", "上传就诊信息")
  9390. var respJSON2 map[string]interface{}
  9391. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9394. return
  9395. }
  9396. userJSONBytes2, _ := json.Marshal(respJSON2)
  9397. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9398. utils.ErrorLog("解析失败:%v", err)
  9399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9400. return
  9401. }
  9402. } else {
  9403. var result string
  9404. var requestLog string
  9405. if miConfig.MdtrtareaAdmvs == "440781" { //
  9406. 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)
  9407. } else {
  9408. if miConfig.Code == "H15049901371" {
  9409. //赤峰地区国家医保医疗类别
  9410. //职工透析:医疗类别选特殊情况门诊990502
  9411. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9412. var med_type string
  9413. if his.Insutype == "390" {
  9414. if reg_type == 14 {
  9415. med_type = "9933"
  9416. } else if reg_type == 11 {
  9417. med_type = "11"
  9418. }
  9419. } else if his.Insutype == "310" {
  9420. if reg_type == 14 {
  9421. med_type = "990502"
  9422. } else if reg_type == 11 {
  9423. med_type = "11"
  9424. }
  9425. }
  9426. 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)
  9427. } else {
  9428. 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)
  9429. }
  9430. saveLog(result, requestLog, "2203", "上传就诊信息")
  9431. var respJSON2 map[string]interface{}
  9432. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9435. return
  9436. }
  9437. userJSONBytes2, _ := json.Marshal(respJSON2)
  9438. if miConfig.Code == "H15049901371" {
  9439. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  9440. utils.ErrorLog("解析失败:%v", err)
  9441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9442. return
  9443. }
  9444. res2.InfRefmsgid = resSix10265.InfRefmsgid
  9445. res2.Output = resSix10265.Output
  9446. res2.ErrMsg = resSix10265.ErrMsg
  9447. res2.Cainfo = resSix10265.Cainfo
  9448. res2.WarnMsg = resSix10265.WarnMsg
  9449. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  9450. res2.Infcode = infocode
  9451. } else {
  9452. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9453. utils.ErrorLog("解析失败:%v", err)
  9454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9455. return
  9456. }
  9457. }
  9458. }
  9459. }
  9460. if res2.Infcode != 0 {
  9461. adminUser := c.GetAdminUserInfo()
  9462. errlog := &models.HisOrderError{
  9463. UserOrgId: adminUser.CurrentOrgId,
  9464. Ctime: time.Now().Unix(),
  9465. Mtime: time.Now().Unix(),
  9466. ErrMsg: res2.ErrMsg,
  9467. Status: 1,
  9468. PatientId: id,
  9469. RecordTime: recordDateTime,
  9470. Stage: 3,
  9471. }
  9472. service.CreateErrMsgLog(errlog)
  9473. c.ServeSuccessJSON(map[string]interface{}{
  9474. "failed_code": -10,
  9475. "msg": res2.ErrMsg,
  9476. })
  9477. return
  9478. } else {
  9479. his.Diagnosis = diagnosis_id
  9480. his.SickType = sickConfig.ID
  9481. his.PType = fmt.Sprintf("%d", reg_type)
  9482. service.UpdateHisPatientThree(&his)
  9483. data := make(map[string]interface{})
  9484. if settle_accounts_type == 1 { //日结
  9485. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9486. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9487. } else {
  9488. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9489. }
  9490. data["pre"] = prescriptions
  9491. } else { //月结
  9492. start_time_str := c.GetString("start_time")
  9493. end_time_str := c.GetString("end_time")
  9494. timeLayout := "2006-01-02"
  9495. loc, _ := time.LoadLocation("Local")
  9496. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9497. if err != nil {
  9498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9499. return
  9500. }
  9501. recordStartTime := theStartTime.Unix()
  9502. start_time = recordStartTime
  9503. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9504. if err != nil {
  9505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9506. return
  9507. }
  9508. recordEndTime := theEndTime.Unix()
  9509. end_time = recordEndTime
  9510. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9511. data["pre"] = prescriptions
  9512. }
  9513. client := &http.Client{}
  9514. data["psn_no"] = his.PsnNo
  9515. data["mdtrt_id"] = his.Number
  9516. data["chrg_bchno"] = chrg_bchno
  9517. data["org_name"] = miConfig.OrgName
  9518. data["doctor"] = doctor_info.UserName
  9519. data["doctor_id"] = doctor_info.DoctorNumber
  9520. data["dept"] = department.Name
  9521. data["fixmedins_code"] = miConfig.Code
  9522. data["opter"] = roles.UserName
  9523. data["dept_code"] = department.Number
  9524. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9525. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9526. data["secret_key"] = miConfig.SecretKey
  9527. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9528. data["url"] = miConfig.Url
  9529. data["ak"] = miConfig.AccessKey
  9530. data["new_doctor_name"] = patientPrescription.Doctor
  9531. data["diag_code"] = sickConfig.CountryCode
  9532. data["cainfo"] = miConfig.Cainfo
  9533. data["opter"] = roles.UserName
  9534. var ids []int64
  9535. for _, item := range prescriptions {
  9536. ids = append(ids, item.ID)
  9537. }
  9538. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9539. if config.IsOpen == 1 { //对接了医保,走医保流程
  9540. var res ResultFour
  9541. var resFour10265 ResultFour10265
  9542. if miConfig.MdtrtareaAdmvs == "421300" {
  9543. bytesData, _ := json.Marshal(data)
  9544. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9545. resp, _ := client.Do(req)
  9546. defer resp.Body.Close()
  9547. body, ioErr := ioutil.ReadAll(resp.Body)
  9548. if ioErr != nil {
  9549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9551. return
  9552. }
  9553. var respJSON map[string]interface{}
  9554. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9557. return
  9558. }
  9559. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9560. userJSONBytes, _ := json.Marshal(respJSON)
  9561. fmt.Println("log")
  9562. fmt.Println(string(userJSONBytes))
  9563. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9564. utils.ErrorLog("解析失败:%v", err)
  9565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9566. return
  9567. }
  9568. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9569. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9570. if result3101.Infcode == "0" {
  9571. if len(result3101.Output.Result) > 0 {
  9572. var errMsgs []string
  9573. for _, item := range result3101.Output.Result {
  9574. errMsgs = append(errMsgs, item.VolaCont)
  9575. }
  9576. c.ServeSuccessJSON(map[string]interface{}{
  9577. "failed_code": -10,
  9578. "msg": errMsgs,
  9579. })
  9580. return
  9581. } else {
  9582. if miConfig.MdtrtareaAdmvs == "320921" {
  9583. data["doctor_id"] = "D320923012139"
  9584. } else {
  9585. data["doctor_id"] = "D371621008686"
  9586. }
  9587. bytesData, _ := json.Marshal(data)
  9588. var req *http.Request
  9589. if miConfig.MdtrtareaAdmvs == "320921" {
  9590. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9591. } else {
  9592. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9593. }
  9594. resp, _ := client.Do(req)
  9595. defer resp.Body.Close()
  9596. body, ioErr := ioutil.ReadAll(resp.Body)
  9597. if ioErr != nil {
  9598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9600. return
  9601. }
  9602. var respJSON map[string]interface{}
  9603. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9606. return
  9607. }
  9608. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9609. userJSONBytes, _ := json.Marshal(respJSON)
  9610. fmt.Println("log")
  9611. fmt.Println(string(userJSONBytes))
  9612. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9613. utils.ErrorLog("解析失败:%v", err)
  9614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9615. return
  9616. }
  9617. res.InfRefmsgid = resFour10265.InfRefmsgid
  9618. res.Output = resFour10265.Output
  9619. res.ErrMsg = resFour10265.ErrMsg
  9620. res.Cainfo = resFour10265.Cainfo
  9621. res.WarnMsg = resFour10265.WarnMsg
  9622. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9623. res.Infcode = infocode
  9624. }
  9625. }
  9626. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9627. 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)
  9628. var dat map[string]interface{}
  9629. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9630. fmt.Println(dat)
  9631. } else {
  9632. fmt.Println(err)
  9633. }
  9634. saveLog(result, request_log, "2204", "上传费用明细")
  9635. userJSONBytes, _ := json.Marshal(dat)
  9636. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9637. utils.ErrorLog("解析失败:%v", err)
  9638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9639. return
  9640. }
  9641. } else if miConfig.MdtrtareaAdmvs == "360399" {
  9642. 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, "", "")
  9643. var dat map[string]interface{}
  9644. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9645. fmt.Println(dat)
  9646. } else {
  9647. fmt.Println(err)
  9648. }
  9649. saveLog(result, request_log, "2204", "上传费用明细")
  9650. userJSONBytes, _ := json.Marshal(dat)
  9651. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9652. utils.ErrorLog("解析失败:%v", err)
  9653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9654. return
  9655. }
  9656. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9657. 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, "", "")
  9658. var dat map[string]interface{}
  9659. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9660. fmt.Println(dat)
  9661. } else {
  9662. fmt.Println(err)
  9663. }
  9664. saveLog(result, request_log, "2204", "上传费用明细")
  9665. userJSONBytes, _ := json.Marshal(dat)
  9666. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9667. utils.ErrorLog("解析失败:%v", err)
  9668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9669. return
  9670. }
  9671. } else {
  9672. if miConfig.Code == "H15049901371" {
  9673. 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)
  9674. var dat map[string]interface{}
  9675. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9676. fmt.Println(dat)
  9677. } else {
  9678. fmt.Println(err)
  9679. }
  9680. saveLog(result, request_log, "2204", "上传费用明细")
  9681. userJSONBytes, _ := json.Marshal(dat)
  9682. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9683. utils.ErrorLog("解析失败:%v", err)
  9684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9685. return
  9686. }
  9687. res.InfRefmsgid = resFour10265.InfRefmsgid
  9688. res.Output = resFour10265.Output
  9689. res.ErrMsg = resFour10265.ErrMsg
  9690. res.Cainfo = resFour10265.Cainfo
  9691. res.WarnMsg = resFour10265.WarnMsg
  9692. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9693. res.Infcode = infocode
  9694. } else {
  9695. 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), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  9696. var dat map[string]interface{}
  9697. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9698. fmt.Println(dat)
  9699. } else {
  9700. fmt.Println(err)
  9701. }
  9702. saveLog(result, request_log, "2204", "上传费用明细")
  9703. userJSONBytes, _ := json.Marshal(dat)
  9704. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9705. utils.ErrorLog("解析失败:%v", err)
  9706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9707. return
  9708. }
  9709. }
  9710. }
  9711. if res.Infcode == 0 {
  9712. order := &models.HisOrder{
  9713. UserOrgId: adminUser.CurrentOrgId,
  9714. HisPatientId: his.ID,
  9715. PatientId: his.PatientId,
  9716. SettleAccountsDate: recordDateTime,
  9717. Ctime: time.Now().Unix(),
  9718. Mtime: time.Now().Unix(),
  9719. MdtrtId: his.Number,
  9720. PsnNo: his.PsnNo,
  9721. MedType: strconv.FormatInt(reg_type, 10),
  9722. Status: 1,
  9723. Number: chrg_bchno,
  9724. Infcode: res.Infcode,
  9725. WarnMsg: res.WarnMsg,
  9726. Cainfo: res.Cainfo,
  9727. ErrMsg: res.ErrMsg,
  9728. RespondTime: res.RefmsgTime,
  9729. InfRefmsgid: res.InfRefmsgid,
  9730. OrderStatus: 1,
  9731. IsMedicineInsurance: 1,
  9732. SettleType: settle_accounts_type,
  9733. SettleStartTime: start_time,
  9734. SettleEndTime: end_time,
  9735. Creator: roles.AdminUserId,
  9736. Modify: roles.AdminUserId,
  9737. PType: 2,
  9738. Diagnosis: diagnosis_id,
  9739. }
  9740. err = service.CreateOrder(order)
  9741. if err != nil {
  9742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9743. return
  9744. }
  9745. for _, item := range res.Output.Result {
  9746. temp := strings.Split(item.FeedetlSn, "-")
  9747. var advice_id int64 = 0
  9748. var project_id int64 = 0
  9749. var types int64 = 0
  9750. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9751. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9752. if temp[1] == "1" {
  9753. advice_id = id
  9754. project_id = 0
  9755. } else if temp[1] == "2" {
  9756. advice_id = 0
  9757. project_id = id
  9758. }
  9759. info := &models.HisOrderInfo{
  9760. OrderNumber: order.Number,
  9761. FeedetlSn: item.FeedetlSn,
  9762. UploadDate: time.Now().Unix(),
  9763. AdviceId: advice_id,
  9764. DetItemFeeSumamt: item.DetItemFeeSumamt,
  9765. Cnt: item.Cnt,
  9766. Pric: float64(item.Pric),
  9767. PatientId: his.PatientId,
  9768. PricUplmtAmt: item.PricUplmtAmt,
  9769. SelfpayProp: item.SelfpayProp,
  9770. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9771. OverlmtAmt: item.OverlmtAmt,
  9772. PreselfpayAmt: item.PreselfpayAmt,
  9773. BasMednFlag: item.BasMednFlag,
  9774. MedChrgitmType: item.MedChrgitmType,
  9775. HiNegoDrugFlag: item.HiNegoDrugFlag,
  9776. Status: 1,
  9777. Memo: item.Memo,
  9778. Mtime: time.Now().Unix(),
  9779. InscpScpAmt: item.InscpScpAmt,
  9780. DrtReimFlag: item.DrtReimFlag,
  9781. Ctime: time.Now().Unix(),
  9782. ListSpItemFlag: item.ListSpItemFlag,
  9783. ChldMedcFlag: item.ChldMedcFlag,
  9784. LmtUsedFlag: item.LmtUsedFlag,
  9785. ChrgitmLv: item.ChrgitmLv,
  9786. UserOrgId: adminUser.CurrentOrgId,
  9787. HisPatientId: his.ID,
  9788. OrderId: order.ID,
  9789. ProjectId: project_id,
  9790. Type: types,
  9791. }
  9792. service.CreateOrderInfo(info)
  9793. }
  9794. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9795. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  9796. var total float64
  9797. for _, item := range prescriptions {
  9798. if item.Type == 1 { //药品
  9799. for _, subItem := range item.HisDoctorAdviceInfo {
  9800. total = total + (subItem.Price * subItem.PrescribingNumber)
  9801. }
  9802. }
  9803. if item.Type == 2 { //项目
  9804. for _, subItem := range item.HisPrescriptionProject {
  9805. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9806. total = total + (subItem.Price * cnt)
  9807. }
  9808. }
  9809. }
  9810. for _, item := range prescriptions {
  9811. for _, subItem := range item.HisAdditionalCharge {
  9812. total = total + (subItem.Price * float64(subItem.Count))
  9813. }
  9814. }
  9815. allTotal := fmt.Sprintf("%.4f", total)
  9816. if res.Infcode == 0 {
  9817. var rf []*ResultFive
  9818. json.Unmarshal([]byte(his.Iinfo), &rf)
  9819. chrg_bchno := chrg_bchno
  9820. cert_no := his.Certno
  9821. var insutypes []string
  9822. var insutype string
  9823. var is390 int = 0
  9824. var is310 int = 0
  9825. for _, item := range rf {
  9826. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9827. insutypes = append(insutypes, item.Insutype)
  9828. }
  9829. }
  9830. if len(insutypes) == 1 {
  9831. insutype = insutypes[0]
  9832. } else {
  9833. for _, i := range insutypes {
  9834. if i == "390" {
  9835. is390 = 1
  9836. }
  9837. if i == "310" {
  9838. is310 = 1
  9839. }
  9840. }
  9841. }
  9842. if is390 == 1 {
  9843. insutype = "390"
  9844. }
  9845. if is310 == 1 {
  9846. insutype = "310"
  9847. }
  9848. if len(insutypes) == 0 {
  9849. insutype = "310"
  9850. }
  9851. if len(insutypes) == 2 {
  9852. insutype = strconv.FormatInt(his.SocialType, 64)
  9853. }
  9854. //insutype = "390"
  9855. if his.IdCardType == 1 {
  9856. cert_no = his.MedicalInsuranceNumber
  9857. } else {
  9858. cert_no = his.Certno
  9859. }
  9860. var res ResultSeven
  9861. var resSeven10265 ResultSeven10265
  9862. if miConfig.MdtrtareaAdmvs == "421300" {
  9863. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9864. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9865. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9866. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9867. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9868. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9869. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  9870. resp, requestErr := http.Get(api)
  9871. if requestErr != nil {
  9872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9873. return
  9874. }
  9875. body, ioErr := ioutil.ReadAll(resp.Body)
  9876. if ioErr != nil {
  9877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9879. return
  9880. }
  9881. var respJSON map[string]interface{}
  9882. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9885. return
  9886. }
  9887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9888. result, _ := json.Marshal(respJSON)
  9889. fmt.Println("log")
  9890. fmt.Println(string(result))
  9891. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9892. utils.ErrorLog("解析失败:%v", err)
  9893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9894. return
  9895. }
  9896. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9897. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  9898. if result3101.Infcode == "0" {
  9899. if len(result3101.Output.Result) > 0 {
  9900. var errMsgs []string
  9901. for _, item := range result3101.Output.Result {
  9902. errMsgs = append(errMsgs, item.VolaCont)
  9903. }
  9904. c.ServeSuccessJSON(map[string]interface{}{
  9905. "failed_code": -10,
  9906. "msg": errMsgs,
  9907. })
  9908. return
  9909. } else {
  9910. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9911. if his.IdCardType != 4 {
  9912. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9913. bas := strings.Split(psn_info.CardInfo, "|")
  9914. if his.IdCardType == 1 {
  9915. cert_no = bas[2]
  9916. } else {
  9917. cert_no = bas[1]
  9918. }
  9919. } else {
  9920. cert_no = his.Certno
  9921. }
  9922. //江苏地区国家医保医疗类别
  9923. //职工透析:医疗类别选特殊情况门诊9933
  9924. //居民血透门慢: 医疗类别选门诊慢病1402
  9925. //var med_type string
  9926. //if his.Insutype == "310" {
  9927. // if reg_type == 14 {
  9928. // med_type = "9933"
  9929. // } else if reg_type == 11 {
  9930. // med_type = "11"
  9931. //
  9932. // }
  9933. //} else if his.Insutype == "390" {
  9934. // if reg_type == 14 {
  9935. // med_type = "1402"
  9936. // } else if reg_type == 11 {
  9937. // med_type = "11"
  9938. // }
  9939. //}
  9940. var api string
  9941. if miConfig.MdtrtareaAdmvs == "320921" {
  9942. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9943. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9944. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9945. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9946. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9947. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9948. "&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
  9949. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9950. } else {
  9951. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9952. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9953. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9954. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9955. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9956. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9957. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9958. "&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
  9959. }
  9960. resp, requestErr := http.Get(api)
  9961. if requestErr != nil {
  9962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9963. return
  9964. }
  9965. body, ioErr := ioutil.ReadAll(resp.Body)
  9966. if ioErr != nil {
  9967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9969. return
  9970. }
  9971. var respJSON map[string]interface{}
  9972. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9975. return
  9976. }
  9977. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9978. result, _ := json.Marshal(respJSON)
  9979. fmt.Println("log")
  9980. fmt.Println(string(result))
  9981. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9982. utils.ErrorLog("解析失败:%v", err)
  9983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9984. return
  9985. }
  9986. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9987. res.Output = resSeven10265.Output
  9988. res.ErrMsg = resSeven10265.ErrMsg
  9989. res.Cainfo = resSeven10265.Cainfo
  9990. res.WarnMsg = resSeven10265.WarnMsg
  9991. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9992. res.Infcode = infocode
  9993. }
  9994. }
  9995. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9996. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId, recordDateTime)
  9997. var result string
  9998. var request_log string
  9999. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  10000. 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)
  10001. } else {
  10002. 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)
  10003. }
  10004. var dat map[string]interface{}
  10005. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10006. fmt.Println(dat)
  10007. } else {
  10008. fmt.Println(err)
  10009. }
  10010. saveLog(result, request_log, "2206", "预结算")
  10011. userJSONBytes, _ := json.Marshal(dat)
  10012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10013. utils.ErrorLog("解析失败:%v", err)
  10014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10015. return
  10016. }
  10017. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10018. var result string
  10019. var request_log string
  10020. if his.IdCardType == 2 {
  10021. 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, "")
  10022. } else if his.IdCardType == 1 {
  10023. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10024. bas := strings.Split(psn_info.CardInfo, "|")
  10025. basNumber := bas[2]
  10026. card_sn := bas[3]
  10027. 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)
  10028. } else {
  10029. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10030. 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, "")
  10031. }
  10032. var dat map[string]interface{}
  10033. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10034. fmt.Println(dat)
  10035. } else {
  10036. fmt.Println(err)
  10037. }
  10038. saveLog(result, request_log, "2206", "预结算")
  10039. userJSONBytes, _ := json.Marshal(dat)
  10040. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10041. utils.ErrorLog("解析失败:%v", err)
  10042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10043. return
  10044. }
  10045. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10046. var result string
  10047. var request_log string
  10048. if his.IdCardType == 2 {
  10049. 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, "")
  10050. } else if his.IdCardType == 1 {
  10051. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10052. bas := strings.Split(psn_info.CardInfo, "|")
  10053. basNumber := bas[2]
  10054. card_sn := bas[3]
  10055. 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)
  10056. } else {
  10057. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10058. 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, "")
  10059. }
  10060. var dat map[string]interface{}
  10061. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10062. fmt.Println(dat)
  10063. } else {
  10064. fmt.Println(err)
  10065. }
  10066. saveLog(result, request_log, "2206", "预结算")
  10067. userJSONBytes, _ := json.Marshal(dat)
  10068. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10069. utils.ErrorLog("解析失败:%v", err)
  10070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10071. return
  10072. }
  10073. } else {
  10074. var result string
  10075. var request_log string
  10076. if miConfig.Code == "H15049901371" {
  10077. //赤峰地区国家医保医疗类别
  10078. //职工透析:医疗类别选特殊情况门诊990502
  10079. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10080. var med_type string
  10081. if his.Insutype == "390" {
  10082. if reg_type == 14 {
  10083. med_type = "9933"
  10084. } else if reg_type == 11 {
  10085. med_type = "11"
  10086. }
  10087. } else if his.Insutype == "310" {
  10088. if reg_type == 14 {
  10089. med_type = "990502"
  10090. } else if reg_type == 11 {
  10091. med_type = "11"
  10092. }
  10093. }
  10094. 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, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  10095. } else {
  10096. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10097. if his.IdCardType == 4 {
  10098. 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)
  10099. } else {
  10100. 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)
  10101. }
  10102. }
  10103. var dat map[string]interface{}
  10104. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10105. fmt.Println(dat)
  10106. } else {
  10107. fmt.Println(err)
  10108. }
  10109. saveLog(result, request_log, "2206", "预结算")
  10110. //userJSONBytes, _ := json.Marshal(dat)
  10111. //
  10112. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10113. // utils.ErrorLog("解析失败:%v", err)
  10114. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10115. // return
  10116. //}
  10117. userJSONBytes, _ := json.Marshal(dat)
  10118. if miConfig.Code == "H15049901371" {
  10119. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10120. utils.ErrorLog("解析失败:%v", err)
  10121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10122. return
  10123. }
  10124. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10125. res.Output = resSeven10265.Output
  10126. res.ErrMsg = resSeven10265.ErrMsg
  10127. res.Cainfo = resSeven10265.Cainfo
  10128. res.WarnMsg = resSeven10265.WarnMsg
  10129. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10130. res.Infcode = infocode
  10131. } else {
  10132. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10133. utils.ErrorLog("解析失败:%v", err)
  10134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10135. return
  10136. }
  10137. }
  10138. }
  10139. if res.Infcode != 0 {
  10140. errlog := &models.HisOrderError{
  10141. UserOrgId: adminUser.CurrentOrgId,
  10142. Ctime: time.Now().Unix(),
  10143. Mtime: time.Now().Unix(),
  10144. Number: chrg_bchno,
  10145. ErrMsg: res.ErrMsg,
  10146. Status: 1,
  10147. PatientId: id,
  10148. RecordTime: recordDateTime,
  10149. Stage: 20,
  10150. }
  10151. service.CreateErrMsgLog(errlog)
  10152. c.ServeSuccessJSON(map[string]interface{}{
  10153. "failed_code": -10,
  10154. "msg": res.ErrMsg,
  10155. })
  10156. return
  10157. } else {
  10158. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10159. order.OrderStatus = 1
  10160. order.IsPre = 1
  10161. order.Status = 1
  10162. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10163. order.SetlId = res.Output.Setlinfo.SetlID
  10164. order.PsnNo = res.Output.Setlinfo.PsnNo
  10165. order.PsnName = res.Output.Setlinfo.PsnName
  10166. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10167. order.Certno = res.Output.Setlinfo.Certno
  10168. order.Gend = res.Output.Setlinfo.Gend
  10169. order.Naty = res.Output.Setlinfo.Naty
  10170. order.Age = res.Output.Setlinfo.Age
  10171. order.Insutype = res.Output.Setlinfo.Insutype
  10172. order.PsnType = res.Output.Setlinfo.PsnType
  10173. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10174. order.SetlTime = res.Output.Setlinfo.SetlTime
  10175. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10176. if res.Output.Setlinfo.MedType == "140101" {
  10177. order.MedType = "14"
  10178. } else {
  10179. order.MedType = res.Output.Setlinfo.MedType
  10180. }
  10181. if reg_type == 1112 {
  10182. order.MedType = "1112"
  10183. }
  10184. if reg_type == 1111 {
  10185. order.MedType = "1111"
  10186. }
  10187. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10188. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10189. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10190. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10191. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10192. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10193. order.HifpPay = res.Output.Setlinfo.HifpPay
  10194. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10195. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10196. order.HifesPay = res.Output.Setlinfo.HifesPay
  10197. order.HifobPay = res.Output.Setlinfo.HifobPay
  10198. order.MafPay = res.Output.Setlinfo.MafPay
  10199. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10200. order.OthPay = res.Output.Setlinfo.OthPay
  10201. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10202. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10203. order.AcctPay = res.Output.Setlinfo.AcctPay
  10204. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10205. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10206. order.Balc = res.Output.Setlinfo.Balc
  10207. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10208. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10209. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10210. order.ClrWay = res.Output.Setlinfo.ClrWay
  10211. order.Creator = order.Creator
  10212. order.Modify = roles.AdminUserId
  10213. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10214. detailStr := string(setlDetail)
  10215. order.SetlDetail = detailStr
  10216. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10217. err = service.UpDateOrder(order)
  10218. if err == nil {
  10219. c.ServeSuccessJSON(map[string]interface{}{
  10220. "msg": "预结算成功",
  10221. })
  10222. } else {
  10223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10224. return
  10225. }
  10226. }
  10227. } else {
  10228. adminUser := c.GetAdminUserInfo()
  10229. errlog := &models.HisOrderError{
  10230. UserOrgId: adminUser.CurrentOrgId,
  10231. Ctime: time.Now().Unix(),
  10232. Mtime: time.Now().Unix(),
  10233. ErrMsg: res.ErrMsg,
  10234. Status: 1,
  10235. PatientId: id,
  10236. RecordTime: recordDateTime,
  10237. Stage: 4,
  10238. }
  10239. service.CreateErrMsgLog(errlog)
  10240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10241. return
  10242. }
  10243. } else {
  10244. adminUser := c.GetAdminUserInfo()
  10245. errlog := &models.HisOrderError{
  10246. UserOrgId: adminUser.CurrentOrgId,
  10247. Ctime: time.Now().Unix(),
  10248. Mtime: time.Now().Unix(),
  10249. ErrMsg: res.ErrMsg,
  10250. Status: 1,
  10251. PatientId: id,
  10252. RecordTime: recordDateTime,
  10253. Stage: 4,
  10254. }
  10255. service.CreateErrMsgLog(errlog)
  10256. c.ServeSuccessJSON(map[string]interface{}{
  10257. "failed_code": -10,
  10258. "msg": res.ErrMsg,
  10259. })
  10260. return
  10261. }
  10262. }
  10263. }
  10264. }
  10265. //退款
  10266. func (c *HisApiController) Refund() {
  10267. order_id, _ := c.GetInt64("order_id")
  10268. admin_user_id, _ := c.GetInt64("admin_user_id")
  10269. adminUser := c.GetAdminUserInfo()
  10270. var order models.HisOrder
  10271. order, _ = service.GetHisOrderByID(order_id)
  10272. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10273. if order.ID == 0 {
  10274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10275. return
  10276. }
  10277. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10278. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10279. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10280. if config.IsOpen == 1 { //对接了医保,走医保流程
  10281. var res ResultSixteen
  10282. var resSixteen10265 ResultSixteen10265
  10283. var src_resquest string
  10284. var result string
  10285. if miConfig.MdtrtareaAdmvs == "421300" {
  10286. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  10287. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10288. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10289. resp3, requestErr3 := http.Get(api3)
  10290. if requestErr3 != nil {
  10291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10292. return
  10293. }
  10294. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10295. if ioErr3 != nil {
  10296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10298. return
  10299. }
  10300. var respJSON3 map[string]interface{}
  10301. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10304. return
  10305. }
  10306. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10307. userJSONBytes3, _ := json.Marshal(respJSON3)
  10308. fmt.Println("log")
  10309. fmt.Println(string(userJSONBytes3))
  10310. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  10311. utils.ErrorLog("解析失败:%v", err)
  10312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10313. return
  10314. }
  10315. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10316. var api3 string
  10317. if miConfig.MdtrtareaAdmvs == "320921" {
  10318. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10319. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10320. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10321. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10322. } else {
  10323. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10324. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  10325. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10326. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10327. }
  10328. resp3, requestErr3 := http.Get(api3)
  10329. if requestErr3 != nil {
  10330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10331. return
  10332. }
  10333. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10334. if ioErr3 != nil {
  10335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10337. return
  10338. }
  10339. var respJSON3 map[string]interface{}
  10340. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10343. return
  10344. }
  10345. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10346. userJSONBytes3, _ := json.Marshal(respJSON3)
  10347. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  10348. utils.ErrorLog("解析失败:%v", err)
  10349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10350. return
  10351. }
  10352. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10353. res.Output = resSixteen10265.Output
  10354. res.ErrMsg = resSixteen10265.ErrMsg
  10355. res.Cainfo = resSixteen10265.Cainfo
  10356. res.WarnMsg = resSixteen10265.WarnMsg
  10357. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10358. res.Infcode = infocode
  10359. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10360. 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)
  10361. var dat map[string]interface{}
  10362. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10363. fmt.Println(dat)
  10364. } else {
  10365. fmt.Println(err)
  10366. }
  10367. saveLog(result, src_resquest, "2208", "退费")
  10368. userJSONBytes, _ := json.Marshal(dat)
  10369. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10370. utils.ErrorLog("解析失败:%v", err)
  10371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10372. return
  10373. }
  10374. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10375. 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, "")
  10376. var dat map[string]interface{}
  10377. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10378. fmt.Println(dat)
  10379. } else {
  10380. fmt.Println(err)
  10381. }
  10382. saveLog(result, src_resquest, "2208", "退费")
  10383. userJSONBytes, _ := json.Marshal(dat)
  10384. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10385. utils.ErrorLog("解析失败:%v", err)
  10386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10387. return
  10388. }
  10389. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10390. 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, "")
  10391. var dat map[string]interface{}
  10392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10393. fmt.Println(dat)
  10394. } else {
  10395. fmt.Println(err)
  10396. }
  10397. saveLog(result, src_resquest, "2208", "退费")
  10398. userJSONBytes, _ := json.Marshal(dat)
  10399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10400. utils.ErrorLog("解析失败:%v", err)
  10401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10402. return
  10403. }
  10404. } else {
  10405. if miConfig.Code == "H15049901371" {
  10406. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10407. var dat map[string]interface{}
  10408. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10409. fmt.Println(dat)
  10410. } else {
  10411. fmt.Println(err)
  10412. }
  10413. saveLog(result, src_resquest, "2208", "退费")
  10414. userJSONBytes, _ := json.Marshal(dat)
  10415. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  10416. utils.ErrorLog("解析失败:%v", err)
  10417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10418. return
  10419. }
  10420. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  10421. res.Output = resSixteen10265.Output
  10422. res.ErrMsg = resSixteen10265.ErrMsg
  10423. res.Cainfo = resSixteen10265.Cainfo
  10424. res.WarnMsg = resSixteen10265.WarnMsg
  10425. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  10426. res.Infcode = infocode
  10427. } else {
  10428. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  10429. var dat map[string]interface{}
  10430. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10431. fmt.Println(dat)
  10432. } else {
  10433. fmt.Println(err)
  10434. }
  10435. saveLog(result, src_resquest, "2208", "退费")
  10436. userJSONBytes, _ := json.Marshal(dat)
  10437. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10438. utils.ErrorLog("解析失败:%v", err)
  10439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10440. return
  10441. }
  10442. }
  10443. }
  10444. if res.Infcode == 0 {
  10445. var res2 ResultSix
  10446. var resSix10265 ResultSix10265
  10447. if miConfig.MdtrtareaAdmvs == "421300" {
  10448. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10449. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10450. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10451. resp3, requestErr3 := http.Get(api3)
  10452. if requestErr3 != nil {
  10453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10454. return
  10455. }
  10456. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10457. if ioErr3 != nil {
  10458. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10460. return
  10461. }
  10462. var respJSON3 map[string]interface{}
  10463. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10466. return
  10467. }
  10468. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10469. userJSONBytes3, _ := json.Marshal(respJSON3)
  10470. fmt.Println("log")
  10471. fmt.Println(string(userJSONBytes3))
  10472. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10473. utils.ErrorLog("解析失败:%v", err)
  10474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10475. return
  10476. }
  10477. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10478. var api3 string
  10479. if miConfig.MdtrtareaAdmvs == "320921" {
  10480. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10481. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10482. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10483. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10484. } else {
  10485. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10486. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10487. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10488. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10489. }
  10490. resp3, requestErr3 := http.Get(api3)
  10491. if requestErr3 != nil {
  10492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10493. return
  10494. }
  10495. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10496. if ioErr3 != nil {
  10497. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10499. return
  10500. }
  10501. var respJSON3 map[string]interface{}
  10502. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10505. return
  10506. }
  10507. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10508. userJSONBytes3, _ := json.Marshal(respJSON3)
  10509. fmt.Println("log")
  10510. fmt.Println(string(userJSONBytes3))
  10511. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10512. utils.ErrorLog("解析失败:%v", err)
  10513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10514. return
  10515. }
  10516. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10517. res2.Output = resSix10265.Output
  10518. res2.ErrMsg = resSix10265.ErrMsg
  10519. res2.Cainfo = resSix10265.Cainfo
  10520. res2.WarnMsg = resSix10265.WarnMsg
  10521. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10522. res2.Infcode = infocode
  10523. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10524. result2, src_request, _ := service.FJyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  10525. var dat map[string]interface{}
  10526. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10527. fmt.Println(dat)
  10528. } else {
  10529. fmt.Println(err)
  10530. }
  10531. saveLog(result2, src_request, "2205", "撤销明细")
  10532. userJSONBytes, _ := json.Marshal(dat)
  10533. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10534. utils.ErrorLog("解析失败:%v", err)
  10535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10536. return
  10537. }
  10538. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10539. 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, "")
  10540. var dat map[string]interface{}
  10541. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10542. fmt.Println(dat)
  10543. } else {
  10544. fmt.Println(err)
  10545. }
  10546. saveLog(result2, src_request, "2205", "撤销明细")
  10547. userJSONBytes, _ := json.Marshal(dat)
  10548. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10549. utils.ErrorLog("解析失败:%v", err)
  10550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10551. return
  10552. }
  10553. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10554. 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, "")
  10555. var dat map[string]interface{}
  10556. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10557. fmt.Println(dat)
  10558. } else {
  10559. fmt.Println(err)
  10560. }
  10561. saveLog(result2, src_request, "2205", "撤销明细")
  10562. userJSONBytes, _ := json.Marshal(dat)
  10563. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10564. utils.ErrorLog("解析失败:%v", err)
  10565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10566. return
  10567. }
  10568. } else {
  10569. if miConfig.Code == "H15049901371" {
  10570. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10571. var dat map[string]interface{}
  10572. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10573. fmt.Println(dat)
  10574. } else {
  10575. fmt.Println(err)
  10576. }
  10577. saveLog(result2, src_request, "2205", "撤销明细")
  10578. userJSONBytes, _ := json.Marshal(dat)
  10579. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  10580. utils.ErrorLog("解析失败:%v", err)
  10581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10582. return
  10583. }
  10584. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10585. res2.Output = resSix10265.Output
  10586. res2.ErrMsg = resSix10265.ErrMsg
  10587. res2.Cainfo = resSix10265.Cainfo
  10588. res2.WarnMsg = resSix10265.WarnMsg
  10589. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10590. res2.Infcode = infocode
  10591. } else {
  10592. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  10593. var dat map[string]interface{}
  10594. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10595. fmt.Println(dat)
  10596. } else {
  10597. fmt.Println(err)
  10598. }
  10599. saveLog(result2, src_request, "2205", "撤销明细")
  10600. userJSONBytes, _ := json.Marshal(dat)
  10601. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10602. utils.ErrorLog("解析失败:%v", err)
  10603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10604. return
  10605. }
  10606. }
  10607. }
  10608. if res2.Infcode == 0 {
  10609. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  10610. if err == nil {
  10611. //当押金不为零时产生退费记录
  10612. if order.Decimal != 0 {
  10613. tmp := strconv.FormatInt(order.ID, 10)
  10614. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  10615. if err != nil {
  10616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10617. return
  10618. }
  10619. }
  10620. c.ServeSuccessJSON(map[string]interface{}{
  10621. "msg": "退费成功",
  10622. })
  10623. } else {
  10624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10625. return
  10626. }
  10627. } else {
  10628. c.ServeSuccessJSON(map[string]interface{}{
  10629. "code": -10,
  10630. "msg": res2.ErrMsg,
  10631. })
  10632. }
  10633. } else {
  10634. c.ServeSuccessJSON(map[string]interface{}{
  10635. "code": -10,
  10636. "msg": res.ErrMsg,
  10637. })
  10638. }
  10639. }
  10640. }
  10641. func (c *HisApiController) RefundNumber() {
  10642. record_time := c.GetString("record_time")
  10643. //patient_id, _ := c.GetInt64("patient_id")
  10644. admin_user_id, _ := c.GetInt64("admin_user_id")
  10645. his_patient_id, _ := c.GetInt64("id")
  10646. timeLayout := "2006-01-02"
  10647. loc, _ := time.LoadLocation("Local")
  10648. adminUser := c.GetAdminUserInfo()
  10649. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10650. fmt.Println(err)
  10651. if err != nil {
  10652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10653. return
  10654. }
  10655. recordDateTime := theTime.Unix()
  10656. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10657. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  10658. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10659. //order, _ := service.GetHisOrderByID(order_id)
  10660. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10661. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10662. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10663. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  10664. if count > 0 {
  10665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  10666. return
  10667. }
  10668. if config.IsOpen == 1 { //对接了医保,走医保流程
  10669. var res2 ResultSix
  10670. var resSix10265 ResultSix10265
  10671. if miConfig.MdtrtareaAdmvs == "421300" {
  10672. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  10673. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10674. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10675. resp3, requestErr3 := http.Get(api3)
  10676. if requestErr3 != nil {
  10677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10678. return
  10679. }
  10680. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10681. if ioErr3 != nil {
  10682. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10684. return
  10685. }
  10686. var respJSON3 map[string]interface{}
  10687. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10690. return
  10691. }
  10692. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10693. userJSONBytes3, _ := json.Marshal(respJSON3)
  10694. fmt.Println("log")
  10695. fmt.Println(string(userJSONBytes3))
  10696. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10697. utils.ErrorLog("解析失败:%v", err)
  10698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10699. return
  10700. }
  10701. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10702. var api3 string
  10703. if miConfig.MdtrtareaAdmvs == "320921" {
  10704. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10705. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10706. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10707. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10708. } else {
  10709. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10710. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  10711. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10712. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10713. }
  10714. resp3, requestErr3 := http.Get(api3)
  10715. if requestErr3 != nil {
  10716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10717. return
  10718. }
  10719. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10720. if ioErr3 != nil {
  10721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10723. return
  10724. }
  10725. var respJSON3 map[string]interface{}
  10726. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10729. return
  10730. }
  10731. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10732. userJSONBytes3, _ := json.Marshal(respJSON3)
  10733. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10734. utils.ErrorLog("解析失败:%v", err)
  10735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10736. return
  10737. }
  10738. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10739. res2.Output = resSix10265.Output
  10740. res2.ErrMsg = resSix10265.ErrMsg
  10741. res2.Cainfo = resSix10265.Cainfo
  10742. res2.WarnMsg = resSix10265.WarnMsg
  10743. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10744. res2.Infcode = infocode
  10745. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10746. 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)
  10747. var dat map[string]interface{}
  10748. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10749. fmt.Println(dat)
  10750. } else {
  10751. fmt.Println(err)
  10752. }
  10753. saveLog(result, request, "2202", "退号")
  10754. userJSONBytes, _ := json.Marshal(dat)
  10755. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10756. utils.ErrorLog("解析失败:%v", err)
  10757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10758. return
  10759. }
  10760. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10761. 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, "")
  10762. var dat map[string]interface{}
  10763. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10764. fmt.Println(dat)
  10765. } else {
  10766. fmt.Println(err)
  10767. }
  10768. saveLog(result, request, "2202", "退号")
  10769. userJSONBytes, _ := json.Marshal(dat)
  10770. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10771. utils.ErrorLog("解析失败:%v", err)
  10772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10773. return
  10774. }
  10775. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10776. 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, "")
  10777. var dat map[string]interface{}
  10778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10779. fmt.Println(dat)
  10780. } else {
  10781. fmt.Println(err)
  10782. }
  10783. saveLog(result, request, "2202", "退号")
  10784. userJSONBytes, _ := json.Marshal(dat)
  10785. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10786. utils.ErrorLog("解析失败:%v", err)
  10787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10788. return
  10789. }
  10790. } else {
  10791. var api3 string
  10792. if miConfig.Code == "H15049901371" {
  10793. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10794. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10795. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10796. } else {
  10797. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  10798. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10799. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10800. }
  10801. resp3, requestErr3 := http.Get(api3)
  10802. if requestErr3 != nil {
  10803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10804. return
  10805. }
  10806. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10807. if ioErr3 != nil {
  10808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10810. return
  10811. }
  10812. var respJSON3 map[string]interface{}
  10813. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10816. return
  10817. }
  10818. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10819. userJSONBytes3, _ := json.Marshal(respJSON3)
  10820. if miConfig.Code == "H15049901371" {
  10821. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10822. utils.ErrorLog("解析失败:%v", err)
  10823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10824. return
  10825. }
  10826. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10827. res2.Output = resSix10265.Output
  10828. res2.ErrMsg = resSix10265.ErrMsg
  10829. res2.Cainfo = resSix10265.Cainfo
  10830. res2.WarnMsg = resSix10265.WarnMsg
  10831. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10832. res2.Infcode = infocode
  10833. } else {
  10834. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10835. utils.ErrorLog("解析失败:%v", err)
  10836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10837. return
  10838. }
  10839. }
  10840. }
  10841. if res2.Infcode == 0 {
  10842. if err == nil {
  10843. c.ServeSuccessJSON(map[string]interface{}{
  10844. "msg": "退号成功",
  10845. })
  10846. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  10847. } else {
  10848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10849. return
  10850. }
  10851. } else {
  10852. c.ServeSuccessJSON(map[string]interface{}{
  10853. "code": -10,
  10854. "msg": res2.ErrMsg,
  10855. })
  10856. }
  10857. } else {
  10858. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  10859. //if err == nil {
  10860. // c.ServeSuccessJSON(map[string]interface{}{
  10861. // "msg": "退费成功",
  10862. // })
  10863. //} else {
  10864. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10865. // return
  10866. //}
  10867. }
  10868. }
  10869. func (c *HisApiController) RefundDetail() {
  10870. order_id, _ := c.GetInt64("order_id")
  10871. admin_user_id, _ := c.GetInt64("admin_user_id")
  10872. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10873. number := c.GetString("number")
  10874. record_time := c.GetString("record_time")
  10875. patient_id, _ := c.GetInt64("patient_id")
  10876. //med_type, _ := c.GetInt64("med_type")
  10877. timeLayout := "2006-01-02"
  10878. loc, _ := time.LoadLocation("Local")
  10879. adminUser := c.GetAdminUserInfo()
  10880. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10881. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10882. fmt.Println(err)
  10883. if err != nil {
  10884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10885. return
  10886. }
  10887. recordDateTime := theTime.Unix()
  10888. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  10889. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  10890. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10891. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10892. var order models.HisOrder
  10893. order, _ = service.GetHisOrderByID(order_id)
  10894. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10895. if config.IsOpen == 1 { //对接了医保,走医保流程
  10896. var res2 ResultSix
  10897. if miConfig.MdtrtareaAdmvs == "421300" {
  10898. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  10899. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10900. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  10901. resp3, requestErr3 := http.Get(api3)
  10902. if requestErr3 != nil {
  10903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10904. return
  10905. }
  10906. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10907. if ioErr3 != nil {
  10908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10910. return
  10911. }
  10912. var respJSON3 map[string]interface{}
  10913. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10916. return
  10917. }
  10918. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10919. userJSONBytes3, _ := json.Marshal(respJSON3)
  10920. fmt.Println("log")
  10921. fmt.Println(string(userJSONBytes3))
  10922. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  10923. utils.ErrorLog("解析失败:%v", err)
  10924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10925. return
  10926. }
  10927. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10928. if err == nil {
  10929. c.ServeSuccessJSON(map[string]interface{}{
  10930. "msg": "撤销明细成功",
  10931. })
  10932. return
  10933. } else {
  10934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10935. return
  10936. }
  10937. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10938. var resSix10265 ResultSix10265
  10939. var api3 string
  10940. if miConfig.MdtrtareaAdmvs == "320921" {
  10941. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10942. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10943. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10944. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10945. } else {
  10946. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10947. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  10948. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  10949. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  10950. }
  10951. resp3, requestErr3 := http.Get(api3)
  10952. if requestErr3 != nil {
  10953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10954. return
  10955. }
  10956. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  10957. if ioErr3 != nil {
  10958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  10959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10960. return
  10961. }
  10962. var respJSON3 map[string]interface{}
  10963. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  10964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10966. return
  10967. }
  10968. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10969. userJSONBytes3, _ := json.Marshal(respJSON3)
  10970. fmt.Println("log")
  10971. fmt.Println(string(userJSONBytes3))
  10972. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  10973. utils.ErrorLog("解析失败:%v", err)
  10974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10975. return
  10976. }
  10977. res2.InfRefmsgid = resSix10265.InfRefmsgid
  10978. res2.Output = resSix10265.Output
  10979. res2.ErrMsg = resSix10265.ErrMsg
  10980. res2.Cainfo = resSix10265.Cainfo
  10981. res2.WarnMsg = resSix10265.WarnMsg
  10982. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  10983. res2.Infcode = infocode
  10984. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  10985. if err == nil {
  10986. c.ServeSuccessJSON(map[string]interface{}{
  10987. "msg": "撤销明细成功",
  10988. })
  10989. return
  10990. } else {
  10991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10992. return
  10993. }
  10994. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10995. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  10996. var dat map[string]interface{}
  10997. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10998. fmt.Println(dat)
  10999. } else {
  11000. fmt.Println(err)
  11001. }
  11002. saveLog(result2, src_request, "2205", "撤销明细")
  11003. userJSONBytes, _ := json.Marshal(dat)
  11004. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11005. utils.ErrorLog("解析失败:%v", err)
  11006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11007. return
  11008. }
  11009. if res2.Infcode == 0 {
  11010. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11011. if err == nil {
  11012. c.ServeSuccessJSON(map[string]interface{}{
  11013. "msg": "撤销明细成功",
  11014. })
  11015. return
  11016. } else {
  11017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11018. return
  11019. }
  11020. } else {
  11021. c.ServeSuccessJSON(map[string]interface{}{
  11022. "code": -10,
  11023. "msg": res2.ErrMsg,
  11024. })
  11025. }
  11026. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11027. 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, "")
  11028. var dat map[string]interface{}
  11029. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11030. fmt.Println(dat)
  11031. } else {
  11032. fmt.Println(err)
  11033. }
  11034. saveLog(result2, src_request, "2205", "撤销明细")
  11035. userJSONBytes, _ := json.Marshal(dat)
  11036. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11037. utils.ErrorLog("解析失败:%v", err)
  11038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11039. return
  11040. }
  11041. if res2.Infcode == 0 {
  11042. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11043. if err == nil {
  11044. c.ServeSuccessJSON(map[string]interface{}{
  11045. "msg": "撤销明细成功",
  11046. })
  11047. return
  11048. } else {
  11049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11050. return
  11051. }
  11052. } else {
  11053. c.ServeSuccessJSON(map[string]interface{}{
  11054. "code": -10,
  11055. "msg": res2.ErrMsg,
  11056. })
  11057. }
  11058. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11059. 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, "")
  11060. var dat map[string]interface{}
  11061. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  11062. fmt.Println(dat)
  11063. } else {
  11064. fmt.Println(err)
  11065. }
  11066. saveLog(result2, src_request, "2205", "撤销明细")
  11067. userJSONBytes, _ := json.Marshal(dat)
  11068. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11069. utils.ErrorLog("解析失败:%v", err)
  11070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11071. return
  11072. }
  11073. if res2.Infcode == 0 {
  11074. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11075. if err == nil {
  11076. c.ServeSuccessJSON(map[string]interface{}{
  11077. "msg": "撤销明细成功",
  11078. })
  11079. return
  11080. } else {
  11081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11082. return
  11083. }
  11084. } else {
  11085. c.ServeSuccessJSON(map[string]interface{}{
  11086. "code": -10,
  11087. "msg": res2.ErrMsg,
  11088. })
  11089. }
  11090. } else {
  11091. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  11092. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  11093. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11094. resp2, requestErr2 := http.Get(api2)
  11095. if requestErr2 != nil {
  11096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11097. return
  11098. }
  11099. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  11100. if ioErr2 != nil {
  11101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  11102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11103. return
  11104. }
  11105. var respJSON2 map[string]interface{}
  11106. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  11107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11109. return
  11110. }
  11111. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11112. if err == nil {
  11113. c.ServeSuccessJSON(map[string]interface{}{
  11114. "msg": "撤销明细成功",
  11115. })
  11116. return
  11117. } else {
  11118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11119. return
  11120. }
  11121. }
  11122. } else {
  11123. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  11124. if err == nil {
  11125. c.ServeSuccessJSON(map[string]interface{}{
  11126. "msg": "退费成功",
  11127. })
  11128. } else {
  11129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11130. return
  11131. }
  11132. }
  11133. }
  11134. //对账
  11135. func (c *HisApiController) GetCheckAccount() {
  11136. start_time := c.GetString("start_time")
  11137. end_time := c.GetString("end_time")
  11138. insutype := c.GetString("insutype")
  11139. clr_type := c.GetString("clr_type")
  11140. clr_org := c.GetString("clr_optins")
  11141. admin_user_id, _ := c.GetInt64("admin_user_id")
  11142. adminUser := c.GetAdminUserInfo()
  11143. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11144. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11145. if len(clr_org) == 0 {
  11146. clr_org = miConfig.MdtrtareaAdmvs
  11147. }
  11148. timeLayout := "2006-01-02"
  11149. loc, _ := time.LoadLocation("Local")
  11150. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11151. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11152. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  11153. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  11154. fixmedins_setl_cnt := int64(len(orders))
  11155. var medfee_sumamt float64
  11156. var acct_pay float64
  11157. var fund_pay_sumamt float64
  11158. for _, item := range orders {
  11159. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11160. acct_pay = acct_pay + item.AcctPay
  11161. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11162. }
  11163. var user_name string
  11164. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11165. if role.ID == 0 {
  11166. user_name = "xxx"
  11167. } else {
  11168. user_name = role.UserName
  11169. }
  11170. var res ResultEight
  11171. var res10188 ResultEightFor10188
  11172. if config.IsOpen == 1 {
  11173. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11174. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  11175. "insutype=" + insutype +
  11176. "&clr_type=" + clr_type +
  11177. "&setl_optins=" + clr_org +
  11178. "&stmt_begndate=" + start_time +
  11179. "&stm_enddate=" + end_time +
  11180. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11181. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11182. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11183. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11184. "&fixmedins_code=" + miConfig.Code +
  11185. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11186. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11187. "&secret_key=" + miConfig.SecretKey +
  11188. "&org_name=" + miConfig.OrgName +
  11189. "&doctor=" + user_name +
  11190. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11191. fmt.Println(api)
  11192. resp, requestErr := http.Get(api)
  11193. if requestErr != nil {
  11194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11195. return
  11196. }
  11197. body, ioErr := ioutil.ReadAll(resp.Body)
  11198. fmt.Println(body)
  11199. if ioErr != nil {
  11200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11202. return
  11203. }
  11204. var respJSON map[string]interface{}
  11205. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11208. return
  11209. }
  11210. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11211. userJSONBytes, _ := json.Marshal(respJSON)
  11212. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11213. utils.ErrorLog("解析失败:%v", err)
  11214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11215. return
  11216. }
  11217. res.InfRefmsgid = res10188.InfRefmsgid
  11218. res.Output = res10188.Output
  11219. res.ErrMsg = res10188.ErrMsg
  11220. res.Cainfo = res10188.Cainfo
  11221. res.WarnMsg = res10188.WarnMsg
  11222. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11223. res.Infcode = infocode
  11224. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11225. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  11226. "insutype=" + insutype +
  11227. "&clr_type=" + "21" +
  11228. "&setl_optins=" + clr_org +
  11229. "&stmt_begndate=" + start_time +
  11230. "&stm_enddate=" + end_time +
  11231. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11232. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11233. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11234. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  11235. "&fixmedins_code=" + miConfig.Code +
  11236. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11237. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11238. "&secret_key=" + miConfig.SecretKey +
  11239. "&org_name=" + miConfig.OrgName +
  11240. "&doctor=" + user_name
  11241. resp, requestErr := http.Get(api)
  11242. if requestErr != nil {
  11243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11244. return
  11245. }
  11246. body, ioErr := ioutil.ReadAll(resp.Body)
  11247. if ioErr != nil {
  11248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11250. return
  11251. }
  11252. var respJSON map[string]interface{}
  11253. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11256. return
  11257. }
  11258. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11259. result, _ := json.Marshal(respJSON)
  11260. fmt.Println("log")
  11261. fmt.Println(string(result))
  11262. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  11263. utils.ErrorLog("解析失败:%v", err)
  11264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11265. return
  11266. }
  11267. res.InfRefmsgid = res10188.InfRefmsgid
  11268. res.Output = res10188.Output
  11269. res.ErrMsg = res10188.ErrMsg
  11270. res.Cainfo = res10188.Cainfo
  11271. res.WarnMsg = res10188.WarnMsg
  11272. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  11273. res.Infcode = infocode
  11274. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11275. var baseParams models.BaseParams
  11276. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11277. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11278. baseParams.SecretKey = miConfig.SecretKey
  11279. baseParams.OrgName = miConfig.OrgName
  11280. baseParams.FixmedinsCode = miConfig.Code
  11281. baseParams.EncKey = miConfig.EncKey
  11282. baseParams.AppSecret = miConfig.AppSecret
  11283. baseParams.SignKey = miConfig.SignKey
  11284. baseParams.AppID = miConfig.Code
  11285. baseParams.Doctor = role.UserName
  11286. baseParams.RequestUrl = miConfig.Url
  11287. businessParams := models.BusinessParams{
  11288. Insutype: insutype,
  11289. ClrType: clr_type,
  11290. SetlOptins: clr_org,
  11291. StmtBegndate: start_time,
  11292. StmtEnddate: end_time,
  11293. MedfeeSumamt: medfee_sumamt,
  11294. FundPaySumamt: fund_pay_sumamt,
  11295. AcctPay: acct_pay,
  11296. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11297. }
  11298. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11299. fmt.Println(requestLog)
  11300. fmt.Println(result)
  11301. fmt.Println(err_msg)
  11302. var dat map[string]interface{}
  11303. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11304. fmt.Println(dat)
  11305. } else {
  11306. fmt.Println(err)
  11307. }
  11308. userJSONBytes, _ := json.Marshal(dat)
  11309. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11310. utils.ErrorLog("解析失败:%v", err)
  11311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11312. return
  11313. }
  11314. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11315. var baseParams models.BaseParams
  11316. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11317. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11318. baseParams.SecretKey = miConfig.SecretKey
  11319. baseParams.OrgName = miConfig.OrgName
  11320. baseParams.FixmedinsCode = miConfig.Code
  11321. baseParams.EncKey = miConfig.EncKey
  11322. baseParams.AppSecret = miConfig.AppSecret
  11323. baseParams.SignKey = miConfig.SignKey
  11324. baseParams.AppID = miConfig.Code
  11325. baseParams.Doctor = role.UserName
  11326. baseParams.RequestUrl = miConfig.Url
  11327. baseParams.AccessKey = miConfig.AccessKey
  11328. businessParams := models.BusinessParams{
  11329. Insutype: insutype,
  11330. ClrType: clr_type,
  11331. SetlOptins: "430822",
  11332. StmtBegndate: start_time,
  11333. StmtEnddate: end_time,
  11334. MedfeeSumamt: medfee_sumamt,
  11335. FundPaySumamt: fund_pay_sumamt,
  11336. AcctPay: acct_pay,
  11337. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11338. }
  11339. 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)
  11340. fmt.Println(requestLog)
  11341. fmt.Println(result)
  11342. var dat map[string]interface{}
  11343. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11344. fmt.Println(dat)
  11345. } else {
  11346. fmt.Println(err)
  11347. }
  11348. userJSONBytes, _ := json.Marshal(dat)
  11349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11350. utils.ErrorLog("解析失败:%v", err)
  11351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11352. return
  11353. }
  11354. } else if miConfig.MdtrtareaAdmvs == "" {
  11355. var baseParams models.BaseParams
  11356. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11357. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11358. baseParams.SecretKey = miConfig.SecretKey
  11359. baseParams.OrgName = miConfig.OrgName
  11360. baseParams.FixmedinsCode = miConfig.Code
  11361. baseParams.EncKey = miConfig.EncKey
  11362. baseParams.AppSecret = miConfig.AppSecret
  11363. baseParams.SignKey = miConfig.SignKey
  11364. baseParams.AppID = miConfig.Code
  11365. baseParams.Doctor = role.UserName
  11366. baseParams.RequestUrl = miConfig.Url
  11367. businessParams := models.BusinessParams{
  11368. Insutype: insutype,
  11369. ClrType: clr_type,
  11370. SetlOptins: clr_org,
  11371. StmtBegndate: start_time,
  11372. StmtEnddate: end_time,
  11373. MedfeeSumamt: medfee_sumamt,
  11374. FundPaySumamt: fund_pay_sumamt,
  11375. AcctPay: acct_pay,
  11376. FixmedinsSetlCnt: fixmedins_setl_cnt,
  11377. }
  11378. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  11379. fmt.Println(requestLog)
  11380. fmt.Println(result)
  11381. fmt.Println(err_msg)
  11382. var dat map[string]interface{}
  11383. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11384. fmt.Println(dat)
  11385. } else {
  11386. fmt.Println(err)
  11387. }
  11388. userJSONBytes, _ := json.Marshal(dat)
  11389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11390. utils.ErrorLog("解析失败:%v", err)
  11391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11392. return
  11393. }
  11394. } else {
  11395. if len(clr_type) == 0 {
  11396. clr_type = "11"
  11397. }
  11398. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11399. "insutype=" + insutype +
  11400. "&clr_type=" + clr_type +
  11401. "&setl_optins=" + clr_org +
  11402. "&stmt_begndate=" + start_time +
  11403. "&stm_enddate=" + end_time +
  11404. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11405. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11406. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  11407. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11408. "&fixmedins_code=" + miConfig.Code +
  11409. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11410. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11411. "&secret_key=" + miConfig.SecretKey +
  11412. "&org_name=" + miConfig.OrgName +
  11413. "&doctor=" + user_name
  11414. fmt.Println(api)
  11415. resp, requestErr := http.Get(api)
  11416. if requestErr != nil {
  11417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11418. return
  11419. }
  11420. body, ioErr := ioutil.ReadAll(resp.Body)
  11421. fmt.Println(body)
  11422. if ioErr != nil {
  11423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11425. return
  11426. }
  11427. var respJSON map[string]interface{}
  11428. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11431. return
  11432. }
  11433. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11434. userJSONBytes, _ := json.Marshal(respJSON)
  11435. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11436. utils.ErrorLog("解析失败:%v", err)
  11437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11438. return
  11439. }
  11440. }
  11441. if res.Infcode == 0 {
  11442. if res.Output.Stmtinfo.StmtRslt == "0" {
  11443. micc := &models.MedicalInsuranceCostCompare{
  11444. StartTime: startime.Unix(),
  11445. EndTime: endtime.Unix(),
  11446. Insutype: insutype,
  11447. CheckType: 1,
  11448. Num: fixmedins_setl_cnt,
  11449. Mtime: time.Now().Unix(),
  11450. Status: 1,
  11451. UserOrgId: adminUser.CurrentOrgId,
  11452. CostTotal: medfee_sumamt,
  11453. FuncTotal: fund_pay_sumamt,
  11454. PsnPay: acct_pay,
  11455. Creator: admin_user_id,
  11456. Ctime: time.Now().Unix(),
  11457. ClrType: clr_type,
  11458. }
  11459. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  11460. if err == nil {
  11461. c.ServeSuccessJSON(map[string]interface{}{
  11462. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11463. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11464. })
  11465. } else {
  11466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11467. }
  11468. } else {
  11469. c.ServeSuccessJSON(map[string]interface{}{
  11470. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  11471. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  11472. })
  11473. }
  11474. } else {
  11475. c.ServeSuccessJSON(map[string]interface{}{
  11476. "code": -10,
  11477. "msg": res.ErrMsg,
  11478. })
  11479. }
  11480. }
  11481. }
  11482. func (c *HisApiController) Check310() {
  11483. adminUser := c.GetAdminUserInfo()
  11484. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11485. var user_name string
  11486. user_name = "高慧裕"
  11487. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11488. "insutype=" + "310" +
  11489. "&clr_type=" + "" +
  11490. "&setl_optins=" + "441202" +
  11491. "&stmt_begndate=" + "2022-03-01" +
  11492. "&stm_enddate=" + "2022-03-31" +
  11493. "&medfee_sumamt=" + "194930.12" +
  11494. "&fund_pay_sumamt=" + "188741.46" +
  11495. "&acct_pay=" + "0" +
  11496. "&fixmedins_setl_cnt=" + "452" +
  11497. "&fixmedins_code=" + miConfig.Code +
  11498. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11499. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11500. "&secret_key=" + miConfig.SecretKey +
  11501. "&org_name=" + miConfig.OrgName +
  11502. "&doctor=" + user_name
  11503. fmt.Println(api)
  11504. resp, requestErr := http.Get(api)
  11505. if requestErr != nil {
  11506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11507. return
  11508. }
  11509. body, ioErr := ioutil.ReadAll(resp.Body)
  11510. fmt.Println(body)
  11511. if ioErr != nil {
  11512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11514. return
  11515. }
  11516. var respJSON map[string]interface{}
  11517. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11520. return
  11521. }
  11522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11523. userJSONBytes, _ := json.Marshal(respJSON)
  11524. var res ResultEight
  11525. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11526. utils.ErrorLog("解析失败:%v", err)
  11527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11528. return
  11529. }
  11530. }
  11531. func (c *HisApiController) Check390() {
  11532. adminUser := c.GetAdminUserInfo()
  11533. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11534. var user_name string
  11535. user_name = "高慧裕"
  11536. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  11537. "insutype=" + "390" +
  11538. "&clr_type=" + "" +
  11539. "&setl_optins=" + "441202" +
  11540. "&stmt_begndate=" + "2022-03-01" +
  11541. "&stm_enddate=" + "2022-03-31" +
  11542. "&medfee_sumamt=" + "1068448.89" +
  11543. "&fund_pay_sumamt=" + "1014677.62" +
  11544. "&acct_pay=" + "0" +
  11545. "&fixmedins_setl_cnt=" + "1950" +
  11546. "&fixmedins_code=" + miConfig.Code +
  11547. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11548. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11549. "&secret_key=" + miConfig.SecretKey +
  11550. "&org_name=" + miConfig.OrgName +
  11551. "&doctor=" + user_name
  11552. fmt.Println(api)
  11553. resp, requestErr := http.Get(api)
  11554. if requestErr != nil {
  11555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11556. return
  11557. }
  11558. body, ioErr := ioutil.ReadAll(resp.Body)
  11559. fmt.Println(body)
  11560. if ioErr != nil {
  11561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11563. return
  11564. }
  11565. var respJSON map[string]interface{}
  11566. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11569. return
  11570. }
  11571. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11572. userJSONBytes, _ := json.Marshal(respJSON)
  11573. var res ResultEight
  11574. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11575. utils.ErrorLog("解析失败:%v", err)
  11576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11577. return
  11578. }
  11579. }
  11580. //对账明细
  11581. func (c *HisApiController) GetCheckDetailAccount() {
  11582. start_time := c.GetString("start_time")
  11583. end_time := c.GetString("end_time")
  11584. admin_user_id, _ := c.GetInt64("admin_user_id")
  11585. adminUser := c.GetAdminUserInfo()
  11586. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11587. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11588. timeLayout := "2006-01-02"
  11589. loc, _ := time.LoadLocation("Local")
  11590. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  11591. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  11592. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  11593. rand.Seed(time.Now().UnixNano())
  11594. num := rand.Intn(30000)
  11595. Mkdir(miConfig.OrgName)
  11596. file := strconv.FormatInt(int64(num), 10)
  11597. file_name := file + ".txt"
  11598. zip_name := file + ".zip"
  11599. zip_path := miConfig.OrgName + "/" + zip_name
  11600. file_path := miConfig.OrgName + "/" + file_name
  11601. decimal.DivisionPrecision = 2
  11602. var medfee_sumamt float64
  11603. var psn_cash_pay float64
  11604. var fund_pay_sumamt float64
  11605. fixmedins_setl_cnt := int64(len(orders))
  11606. for _, item := range orders {
  11607. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  11608. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  11609. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  11610. }
  11611. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  11612. defer f.Close()
  11613. if err != nil {
  11614. fmt.Println(err.Error())
  11615. } else {
  11616. for _, item := range orders {
  11617. var refd_setl_flag string
  11618. if item.OrderStatus == 2 {
  11619. refd_setl_flag = "0"
  11620. var str string
  11621. str = item.SetlId + " " +
  11622. item.MdtrtId + " " +
  11623. item.PsnNo + " " +
  11624. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11625. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11626. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  11627. _, err = f.Write([]byte(str))
  11628. }
  11629. if item.OrderStatus == 3 {
  11630. var str string
  11631. str = item.SetlId + " " +
  11632. item.MdtrtId + " " +
  11633. item.PsnNo + " " +
  11634. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  11635. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  11636. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  11637. _, err = f.Write([]byte(str))
  11638. var str2 string
  11639. str2 = item.SetlId + " " +
  11640. item.MdtrtId + " " +
  11641. item.PsnNo + " " +
  11642. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  11643. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  11644. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  11645. _, err = f.Write([]byte(str2))
  11646. }
  11647. }
  11648. }
  11649. Zip(file_path, zip_path)
  11650. fmt.Println(ReadFile(zip_path))
  11651. fmt.Println(string(ReadFile(zip_path)))
  11652. if config.IsOpen == 1 {
  11653. var user_name string
  11654. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11655. if role.ID == 0 {
  11656. user_name = "管理员"
  11657. } else {
  11658. user_name = role.UserName
  11659. }
  11660. baseParams := models.BaseParams{
  11661. SecretKey: miConfig.SecretKey,
  11662. FixmedinsCode: miConfig.Code,
  11663. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11664. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11665. OrgName: miConfig.OrgName,
  11666. Doctor: user_name,
  11667. }
  11668. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  11669. var dat map[string]interface{}
  11670. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11671. fmt.Println(dat)
  11672. } else {
  11673. fmt.Println(err)
  11674. }
  11675. userJSONBytes, _ := json.Marshal(dat)
  11676. var res ResultNine
  11677. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11678. utils.ErrorLog("解析失败:%v", err)
  11679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11680. return
  11681. }
  11682. if res.Infcode == 0 {
  11683. fileNo := res.Output.FileQuryNo
  11684. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  11685. "file_qury_no=" + fileNo +
  11686. "&setl_optins=" + "定点医保中心" +
  11687. "&stmt_begndate=" + start_time +
  11688. "&stm_enddate=" + end_time +
  11689. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  11690. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  11691. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  11692. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  11693. "&fixmedins_code=" + miConfig.Code +
  11694. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  11695. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11696. "&secret_key=" + miConfig.SecretKey +
  11697. "&org_name=" + miConfig.OrgName +
  11698. "&doctor=" + user_name
  11699. resp, requestErr := http.Get(api)
  11700. if requestErr != nil {
  11701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11702. return
  11703. }
  11704. body, ioErr := ioutil.ReadAll(resp.Body)
  11705. if ioErr != nil {
  11706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11708. return
  11709. }
  11710. var respJSON map[string]interface{}
  11711. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11714. return
  11715. }
  11716. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11717. userJSONBytes, _ := json.Marshal(respJSON)
  11718. var res ResultTen
  11719. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11720. utils.ErrorLog("解析失败:%v", err)
  11721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11722. return
  11723. }
  11724. if res.Infcode == 0 {
  11725. service.Gdyb9102(baseParams, zip_name, fileNo)
  11726. micc := &models.MedicalInsuranceCostCompare{
  11727. StartTime: startime.Unix(),
  11728. EndTime: endtime.Unix(),
  11729. Insutype: "0",
  11730. CheckType: 2,
  11731. Num: fixmedins_setl_cnt,
  11732. Mtime: time.Now().Unix(),
  11733. Status: 1,
  11734. UserOrgId: adminUser.CurrentOrgId,
  11735. CostTotal: medfee_sumamt,
  11736. FuncTotal: fund_pay_sumamt,
  11737. PsnPay: psn_cash_pay,
  11738. Creator: admin_user_id,
  11739. Ctime: time.Now().Unix(),
  11740. }
  11741. service.CreateMedicalInsuranceCostCompareRecord(micc)
  11742. c.ServeSuccessJSON(map[string]interface{}{
  11743. "msg": "明细对账成功",
  11744. })
  11745. }
  11746. } else {
  11747. }
  11748. }
  11749. }
  11750. type CustomOrderInfo struct {
  11751. Name string
  11752. Spec string
  11753. Unit string
  11754. Count float64
  11755. Price float64
  11756. Total float64
  11757. }
  11758. func (c *HisApiController) GetSettleAccounts() {
  11759. //id, _ := c.GetInt64("id")
  11760. //record_time := c.GetString("record_time")
  11761. order_id, _ := c.GetInt64("order_id")
  11762. admin_user_id, _ := c.GetInt64("admin_user_id")
  11763. //timeLayout := "2006-01-02"
  11764. //loc, _ := time.LoadLocation("Local")
  11765. //
  11766. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11767. //if err != nil {
  11768. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11769. // return
  11770. //}
  11771. //recordDateTime := theTime.Unix()
  11772. adminUser := c.GetAdminUserInfo()
  11773. order, _ := service.GetHisOrderByID(order_id)
  11774. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11775. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  11776. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  11777. orderInfos = append(orderInfos, orderInfos_two...)
  11778. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  11779. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  11780. var diagnosis_ids []string
  11781. if his.ID > 0 {
  11782. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  11783. } else {
  11784. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  11785. }
  11786. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  11787. var dia_config []*models.HisXtDiagnoseConfig
  11788. var name string
  11789. for _, item := range diagnosis_ids {
  11790. id, _ := strconv.ParseInt(item, 10, 64)
  11791. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11792. dia_config = append(dia_config, &diagnosisConfig)
  11793. if len(name) == 0 {
  11794. name = diagnosisConfig.ClassName
  11795. } else {
  11796. name = name + "," + diagnosisConfig.ClassName
  11797. }
  11798. }
  11799. var bedCostTotal float64 = 0 //床位总费
  11800. var bedCostSelfTotal float64 = 0 //床位自费
  11801. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11802. var operationCostTotal float64 = 0 //手术费
  11803. var operationCostSelfTotal float64 = 0 //手术费
  11804. var operationCostPartSelfTotal float64 = 0 //手术费
  11805. var otherCostTotal float64 = 0 //其他费用
  11806. var otherCostSelfTotal float64 = 0 //其他费用
  11807. var otherCostPartSelfTotal float64 = 0 //其他费用
  11808. var materialCostTotal float64 = 0 //材料费
  11809. var materialCostSelfTotal float64 = 0 //材料费
  11810. var materialCostPartSelfTotal float64 = 0 //材料费
  11811. var westernMedicineCostTotal float64 = 0 //西药费
  11812. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11813. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11814. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11815. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11816. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11817. var checkCostTotal float64 = 0 //检查费
  11818. var checkCostSelfTotal float64 = 0 //检查费
  11819. var checkCostPartSelfTotal float64 = 0 //检查费
  11820. var laboratoryCostTotal float64 = 0 //化验费
  11821. var laboratoryCostSelfTotal float64 = 0 //化验费
  11822. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11823. var treatCostTotal float64 = 0 //治疗费用
  11824. var treatCostSelfTotal float64 = 0 //治疗费用
  11825. var treatCostPartSelfTotal float64 = 0 //治疗费用
  11826. decimal.DivisionPrecision = 2
  11827. for _, item := range orderInfos {
  11828. if item.MedChrgitmType == "01" { //床位费
  11829. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11830. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11831. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11832. }
  11833. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  11834. if item.MedChrgitmType == "03" { //检查费
  11835. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11836. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11837. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11838. }
  11839. } else {
  11840. if item.MedChrgitmType == "03" { //检查费
  11841. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11842. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11843. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11844. }
  11845. }
  11846. if item.MedChrgitmType == "04" { //化验费
  11847. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11848. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11849. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11850. }
  11851. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  11852. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11853. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11854. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11855. }
  11856. if item.MedChrgitmType == "06" { //手术费
  11857. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11858. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11859. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11860. }
  11861. if item.MedChrgitmType == "08" { //材料费
  11862. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11863. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11864. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11865. }
  11866. if item.MedChrgitmType == "09" { //西药费
  11867. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11868. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11869. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11870. }
  11871. if item.MedChrgitmType == "11" { //中成费
  11872. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11873. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11874. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11875. }
  11876. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  11877. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11878. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11879. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11880. }
  11881. }
  11882. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11883. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11884. var user_name string
  11885. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11886. if role.ID == 0 {
  11887. user_name = "管理员"
  11888. } else {
  11889. user_name = role.UserName
  11890. }
  11891. baseParams := models.BaseParams{
  11892. SecretKey: miConfig.SecretKey,
  11893. FixmedinsCode: miConfig.Code,
  11894. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  11895. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  11896. OrgName: miConfig.OrgName,
  11897. Doctor: user_name,
  11898. RequestUrl: miConfig.Url,
  11899. AccessKey: miConfig.AccessKey,
  11900. }
  11901. businessParams := models.BusinessParams{
  11902. PsnNo: order.PsnNo,
  11903. MdtrtId: order.MdtrtId,
  11904. SetlId: order.SetlId,
  11905. }
  11906. var res ResultEleven
  11907. var resEleven10265 ResultEleven10265
  11908. if config.IsOpen == 1 {
  11909. if miConfig.MdtrtareaAdmvs == "421300" {
  11910. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11911. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11912. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  11913. resp, requestErr := http.Get(api)
  11914. if requestErr != nil {
  11915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11916. return
  11917. }
  11918. body, ioErr := ioutil.ReadAll(resp.Body)
  11919. if ioErr != nil {
  11920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11922. return
  11923. }
  11924. var respJSON map[string]interface{}
  11925. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11928. return
  11929. }
  11930. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11931. result, _ := json.Marshal(respJSON)
  11932. fmt.Println("log")
  11933. fmt.Println(string(result))
  11934. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11935. utils.ErrorLog("解析失败:%v", err)
  11936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11937. return
  11938. }
  11939. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11940. var api string
  11941. if miConfig.MdtrtareaAdmvs == "320921" {
  11942. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11943. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11944. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11945. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11946. } else {
  11947. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11948. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  11949. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  11950. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  11951. }
  11952. resp, requestErr := http.Get(api)
  11953. if requestErr != nil {
  11954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11955. return
  11956. }
  11957. body, ioErr := ioutil.ReadAll(resp.Body)
  11958. if ioErr != nil {
  11959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11961. return
  11962. }
  11963. var respJSON map[string]interface{}
  11964. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11967. return
  11968. }
  11969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11970. result, _ := json.Marshal(respJSON)
  11971. fmt.Println("log")
  11972. fmt.Println(string(result))
  11973. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  11974. utils.ErrorLog("解析失败:%v", err)
  11975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11976. return
  11977. }
  11978. res.InfRefmsgid = resEleven10265.InfRefmsgid
  11979. res.Output = resEleven10265.Output
  11980. res.ErrMsg = resEleven10265.ErrMsg
  11981. res.Cainfo = resEleven10265.Cainfo
  11982. res.WarnMsg = resEleven10265.WarnMsg
  11983. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  11984. res.Infcode = infocode
  11985. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11986. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  11987. saveLog(result, requestLog, "5203", "结算单")
  11988. var dat map[string]interface{}
  11989. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11990. fmt.Println(dat)
  11991. } else {
  11992. fmt.Println(err)
  11993. }
  11994. userJSONBytes, _ := json.Marshal(dat)
  11995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11996. utils.ErrorLog("解析失败:%v", err)
  11997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11998. return
  11999. }
  12000. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12001. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  12002. saveLog(result, requestLog, "5203", "结算单")
  12003. var dat map[string]interface{}
  12004. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12005. fmt.Println(dat)
  12006. } else {
  12007. fmt.Println(err)
  12008. }
  12009. userJSONBytes, _ := json.Marshal(dat)
  12010. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12011. utils.ErrorLog("解析失败:%v", err)
  12012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12013. return
  12014. }
  12015. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12016. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  12017. saveLog(result, requestLog, "5203", "结算单")
  12018. var dat map[string]interface{}
  12019. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12020. fmt.Println(dat)
  12021. } else {
  12022. fmt.Println(err)
  12023. }
  12024. userJSONBytes, _ := json.Marshal(dat)
  12025. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12026. utils.ErrorLog("解析失败:%v", err)
  12027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12028. return
  12029. }
  12030. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12031. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  12032. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  12033. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12034. resp, requestErr := http.Get(api)
  12035. if requestErr != nil {
  12036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12037. return
  12038. }
  12039. body, ioErr := ioutil.ReadAll(resp.Body)
  12040. if ioErr != nil {
  12041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12043. return
  12044. }
  12045. var respJSON map[string]interface{}
  12046. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12049. return
  12050. }
  12051. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12052. result, _ := json.Marshal(respJSON)
  12053. fmt.Println("log")
  12054. fmt.Println(string(result))
  12055. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  12056. utils.ErrorLog("解析失败:%v", err)
  12057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12058. return
  12059. }
  12060. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12061. res.Output = resEleven10265.Output
  12062. res.ErrMsg = resEleven10265.ErrMsg
  12063. res.Cainfo = resEleven10265.Cainfo
  12064. res.WarnMsg = resEleven10265.WarnMsg
  12065. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12066. res.Infcode = infocode
  12067. } else {
  12068. result := service.Gdyb5203(baseParams, businessParams)
  12069. //service.Gdyb5204(baseParams, businessParams)
  12070. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  12071. var dat map[string]interface{}
  12072. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12073. fmt.Println(dat)
  12074. } else {
  12075. fmt.Println(err)
  12076. }
  12077. userJSONBytes, _ := json.Marshal(dat)
  12078. if miConfig.Code == "H15049901371" {
  12079. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  12080. utils.ErrorLog("解析失败:%v", err)
  12081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12082. return
  12083. }
  12084. res.InfRefmsgid = resEleven10265.InfRefmsgid
  12085. res.Output = resEleven10265.Output
  12086. res.ErrMsg = resEleven10265.ErrMsg
  12087. res.Cainfo = resEleven10265.Cainfo
  12088. res.WarnMsg = resEleven10265.WarnMsg
  12089. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  12090. res.Infcode = infocode
  12091. } else {
  12092. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12093. utils.ErrorLog("解析失败:%v", err)
  12094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12095. return
  12096. }
  12097. }
  12098. }
  12099. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12100. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  12101. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  12102. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12103. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  12104. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12105. var doctor_name string
  12106. if roles.ID == 0 {
  12107. doctor_name = "管理员"
  12108. } else {
  12109. doctor_name = roles.UserName
  12110. }
  12111. yiliao_leibie := ""
  12112. switch order.MedType {
  12113. case "11":
  12114. yiliao_leibie = "普通门诊"
  12115. break
  12116. case "12":
  12117. yiliao_leibie = "门诊挂号"
  12118. break
  12119. case "13":
  12120. yiliao_leibie = "急诊"
  12121. break
  12122. case "14":
  12123. yiliao_leibie = "门诊特殊病"
  12124. break
  12125. case "15":
  12126. yiliao_leibie = "门诊统筹"
  12127. break
  12128. case "16":
  12129. yiliao_leibie = "门诊慢性病"
  12130. break
  12131. case "21":
  12132. yiliao_leibie = "普通住院"
  12133. break
  12134. }
  12135. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12136. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  12137. if res.Infcode == 0 {
  12138. c.ServeSuccessJSON(map[string]interface{}{
  12139. "diagnosis": name,
  12140. "order_infos": orderInfos,
  12141. "number": order.MdtrtId,
  12142. "date": order.SettleAccountsDate,
  12143. "charge_admin": charge_admin,
  12144. "printor_admin": printor_admin,
  12145. "info": res.Output.Setlinfo,
  12146. "order": order,
  12147. "bedCostTotal": bedCostTotal,
  12148. "bedCostSelfTotal": bedCostSelfTotal,
  12149. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  12150. "operationCostTotal": operationCostTotal,
  12151. "operationCostSelfTotal": operationCostSelfTotal,
  12152. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  12153. "otherCostTotal": otherCostTotal,
  12154. "otherCostSelfTotal": otherCostSelfTotal,
  12155. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  12156. "materialCostTotal": materialCostTotal,
  12157. "materialCostSelfTotal": materialCostSelfTotal,
  12158. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  12159. "westernMedicineCostTotal": westernMedicineCostTotal,
  12160. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  12161. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  12162. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  12163. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  12164. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  12165. "checkCostTotal": checkCostTotal,
  12166. "checkCostSelfTotal": checkCostSelfTotal,
  12167. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  12168. "laboratoryCostTotal": laboratoryCostTotal,
  12169. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  12170. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  12171. "treatCostTotal": treatCostTotal,
  12172. "treatCostSelfTotal": treatCostSelfTotal,
  12173. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  12174. "doctor_info": doctor_info,
  12175. "doctor_code": adminRole_two.DoctorCode,
  12176. "doctor_name": doctor_name,
  12177. "health_card_no": order.PsnNo,
  12178. "department": departments.Name,
  12179. "yiliao_leibie": yiliao_leibie,
  12180. "after_money": order.AccountPrice,
  12181. "patient": patient,
  12182. "org_name": miConfig.OrgName,
  12183. "org_code": miConfig.Code,
  12184. "order_number": order.Number,
  12185. "his_hospital": his_hospital,
  12186. "his": his,
  12187. "dia_config": dia_config,
  12188. //"check_order_info": cus_slice,
  12189. })
  12190. }
  12191. }
  12192. }
  12193. func (c *HisApiController) CheckTreatment() {
  12194. patient_id, _ := c.GetInt64("patient_id")
  12195. id_card_no := c.GetString("id_card_no")
  12196. insutype := c.GetString("insutype")
  12197. med_type := c.GetString("med_type")
  12198. admin_user_id, _ := c.GetInt64("admin_user_id")
  12199. adminUser := c.GetAdminUserInfo()
  12200. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12201. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12202. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12203. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12204. if miConfig.MdtrtareaAdmvs == "421300" {
  12205. var res ResultTwo
  12206. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  12207. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12208. "&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)
  12209. resp, requestErr := http.Get(api)
  12210. if requestErr != nil {
  12211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12212. return
  12213. }
  12214. body, ioErr := ioutil.ReadAll(resp.Body)
  12215. if ioErr != nil {
  12216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12218. return
  12219. }
  12220. var respJSON map[string]interface{}
  12221. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12224. return
  12225. }
  12226. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12227. result, _ := json.Marshal(respJSON)
  12228. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12229. utils.ErrorLog("解析失败:%v", err)
  12230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12231. return
  12232. }
  12233. if res.Infcode == 0 {
  12234. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  12235. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12236. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  12237. resp, requestErr := http.Get(api)
  12238. if requestErr != nil {
  12239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12240. return
  12241. }
  12242. body, ioErr := ioutil.ReadAll(resp.Body)
  12243. if ioErr != nil {
  12244. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12246. return
  12247. }
  12248. var respJSON map[string]interface{}
  12249. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12252. return
  12253. }
  12254. var res Result2001
  12255. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12256. result2, _ := json.Marshal(respJSON)
  12257. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  12258. utils.ErrorLog("解析失败:%v", err)
  12259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12260. return
  12261. }
  12262. if res.Infcode == 0 {
  12263. c.ServeSuccessJSON(map[string]interface{}{
  12264. "msg": res.Output.Trtinfo,
  12265. })
  12266. }
  12267. } else {
  12268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12269. return
  12270. }
  12271. } else {
  12272. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12273. var dat map[string]interface{}
  12274. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12275. fmt.Println(dat)
  12276. } else {
  12277. fmt.Println(err)
  12278. }
  12279. userJSONBytes, _ := json.Marshal(dat)
  12280. var res ResultTwo
  12281. var res10265 ResultTwo10265
  12282. if miConfig.Code == "H15049901371" {
  12283. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12284. utils.ErrorLog("解析失败:%v", err)
  12285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12286. return
  12287. }
  12288. res.ErrMsg = res10265.ErrMsg
  12289. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12290. res.Infcode = infocode
  12291. res.Output = res10265.Output
  12292. res.InfRefmsgid = res10265.InfRefmsgid
  12293. } else {
  12294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12295. utils.ErrorLog("解析失败:%v", err)
  12296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12297. return
  12298. }
  12299. }
  12300. var user_name string
  12301. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  12302. if role.ID == 0 {
  12303. user_name = "xxx"
  12304. } else {
  12305. user_name = role.UserName
  12306. }
  12307. baseParams := models.BaseParams{
  12308. SecretKey: miConfig.SecretKey,
  12309. FixmedinsCode: miConfig.Code,
  12310. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12311. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12312. OrgName: miConfig.OrgName,
  12313. Doctor: user_name,
  12314. }
  12315. if config.IsOpen == 1 {
  12316. if miConfig.Code == "H15049901371" {
  12317. if med_type == "14" {
  12318. if insutype == "390" {
  12319. med_type = "9933"
  12320. } else if insutype == "310" {
  12321. med_type = "990502"
  12322. }
  12323. } else if med_type == "11" {
  12324. med_type = "11"
  12325. }
  12326. }
  12327. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  12328. var dat map[string]interface{}
  12329. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12330. fmt.Println(dat)
  12331. } else {
  12332. fmt.Println(err)
  12333. }
  12334. var res Result2001
  12335. var res10265 Result2001Org10265
  12336. if miConfig.Code == "H15049901371" {
  12337. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12338. utils.ErrorLog("解析失败:%v", err)
  12339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12340. return
  12341. }
  12342. res.ErrMsg = res10265.ErrMsg
  12343. res.Output = res10265.Output
  12344. res.InfRefmsgid = res10265.InfRefmsgid
  12345. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12346. res.Infcode = infocode
  12347. } else {
  12348. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12349. utils.ErrorLog("解析失败:%v", err)
  12350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12351. return
  12352. }
  12353. }
  12354. if res.Infcode == 0 {
  12355. c.ServeSuccessJSON(map[string]interface{}{
  12356. "msg": res.Output.Trtinfo,
  12357. })
  12358. }
  12359. }
  12360. }
  12361. }
  12362. //func (c *HisApiController) PutRecord() {
  12363. // id, _ := c.GetInt64("id")
  12364. // record_time := c.GetString("record_time")
  12365. // timeLayout := "2006-01-02"
  12366. // loc, _ := time.LoadLocation("Local")
  12367. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12368. // if err != nil {
  12369. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12370. // return
  12371. // }
  12372. // recordDateTime := theTime.Unix()
  12373. //
  12374. // adminInfo := c.GetAdminUserInfo()
  12375. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  12376. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12377. //
  12378. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12379. //
  12380. // fmt.Println(miConfig.SecretKey)
  12381. //
  12382. // if patient == nil {
  12383. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12384. // return
  12385. // }
  12386. // if len(patient.IdCardNo) == 0 {
  12387. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  12388. // return
  12389. // }
  12390. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  12391. // if config.IsOpen == 1 {
  12392. // 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
  12393. // resp, requestErr := http.Get(api)
  12394. // if requestErr != nil {
  12395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12396. // return
  12397. // }
  12398. // defer resp.Body.Close()
  12399. // body, ioErr := ioutil.ReadAll(resp.Body)
  12400. // if ioErr != nil {
  12401. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12402. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12403. // return
  12404. // }
  12405. // var respJSON map[string]interface{}
  12406. //
  12407. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12408. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12409. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12410. // return
  12411. // }
  12412. //
  12413. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12414. // userJSONBytes, _ := json.Marshal(userJSON)
  12415. // var res ResultTwo
  12416. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12417. // utils.ErrorLog("解析失败:%v", err)
  12418. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12419. // return
  12420. // }
  12421. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12422. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12423. // infoStr := string(Iinfos)
  12424. // idetinfoStr := string(Idetinfos)
  12425. //
  12426. // if res.Infcode == 0 {
  12427. // his := models.VMHisPatient{
  12428. // Status: 1,
  12429. // Ctime: time.Now().Unix(),
  12430. // Mtime: time.Now().Unix(),
  12431. // PsnNo: res.Output.Baseinfo.PsnNo,
  12432. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  12433. // Certno: res.Output.Baseinfo.Certno,
  12434. // PsnName: res.Output.Baseinfo.PsnName,
  12435. // Gend: res.Output.Baseinfo.Gend,
  12436. // Naty: res.Output.Baseinfo.Naty,
  12437. // Brdy: res.Output.Baseinfo.Brdy,
  12438. // Age: res.Output.Baseinfo.Age,
  12439. // Iinfo: infoStr,
  12440. // Idetinfo: idetinfoStr,
  12441. // PatientId: patient.ID,
  12442. // RecordDate: theTime.Unix(),
  12443. // UserOrgId: adminInfo.CurrentOrgId,
  12444. // AdminUserId: adminInfo.AdminUser.Id,
  12445. // IsReturn: 1,
  12446. // }
  12447. //
  12448. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  12449. // //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")
  12450. // //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")
  12451. //
  12452. // //var dat map[string]interface{}
  12453. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12454. // // fmt.Println(dat)
  12455. // //} else {
  12456. // // fmt.Println(err)
  12457. // //}
  12458. //
  12459. // var dat2 map[string]interface{}
  12460. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  12461. // fmt.Println(dat2)
  12462. // } else {
  12463. // fmt.Println(err)
  12464. // }
  12465. //
  12466. // } else {
  12467. // adminUser := c.GetAdminUserInfo()
  12468. // errlog := &models.HisOrderError{
  12469. // UserOrgId: adminUser.CurrentOrgId,
  12470. // Ctime: time.Now().Unix(),
  12471. // Mtime: time.Now().Unix(),
  12472. // ErrMsg: res.ErrMsg,
  12473. // Status: 1,
  12474. // PatientId: id,
  12475. // RecordTime: recordDateTime,
  12476. // Stage: 1,
  12477. // }
  12478. // service.CreateErrMsgLog(errlog)
  12479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  12480. // return
  12481. // }
  12482. // }
  12483. //
  12484. //}
  12485. //func (c *HisApiController) GetUploadDiag() {
  12486. // id, _ := c.GetInt64("id")
  12487. // record_time := c.GetString("record_time")
  12488. //
  12489. // diagnosis_id, _ := c.GetInt64("diagnosis")
  12490. // sick_type, _ := c.GetInt64("sick_type")
  12491. // reg_type, _ := c.GetInt64("reg_type")
  12492. //
  12493. // timeLayout := "2006-01-02"
  12494. // loc, _ := time.LoadLocation("Local")
  12495. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12496. // if err != nil {
  12497. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12498. // return
  12499. // }
  12500. //
  12501. // var patientPrescription models.HisPrescriptionInfo
  12502. // recordDateTime := theTime.Unix()
  12503. // adminInfo := c.GetAdminUserInfo()
  12504. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12505. //
  12506. // if patientPrescription.ID == 0 {
  12507. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12508. // }
  12509. //
  12510. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  12511. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  12512. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  12513. // sickConfig, _ := service.FindSickById(sick_type)
  12514. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12515. //
  12516. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  12517. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  12518. // "&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 +
  12519. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  12520. // resp2, requestErr2 := http.Get(api2)
  12521. // if requestErr2 != nil {
  12522. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12523. // return
  12524. // }
  12525. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  12526. // if ioErr2 != nil {
  12527. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  12528. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12529. // return
  12530. // }
  12531. // var respJSON2 map[string]interface{}
  12532. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12533. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12534. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12535. // return
  12536. // }
  12537. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12538. // userJSONBytes2, _ := json.Marshal(respJSON2)
  12539. //
  12540. // var res2 ResultSix
  12541. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  12542. // utils.ErrorLog("解析失败:%v", err)
  12543. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12544. // return
  12545. // }
  12546. // if res2.Infcode != 0 {
  12547. // adminUser := c.GetAdminUserInfo()
  12548. // errlog := &models.HisOrderError{
  12549. // UserOrgId: adminUser.CurrentOrgId,
  12550. // Ctime: time.Now().Unix(),
  12551. // Mtime: time.Now().Unix(),
  12552. // ErrMsg: res2.ErrMsg,
  12553. // Status: 1,
  12554. // PatientId: id,
  12555. // RecordTime: recordDateTime,
  12556. // Stage: 3,
  12557. // }
  12558. // service.CreateErrMsgLog(errlog)
  12559. //
  12560. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  12561. // return
  12562. // }
  12563. //
  12564. // c.ServeSuccessJSON(map[string]interface{}{
  12565. // "msg": "上传成功",
  12566. // })
  12567. //
  12568. //}
  12569. type QueryResult struct {
  12570. ID int64
  12571. Name string
  12572. Code string
  12573. List_type_code string
  12574. }
  12575. func (c *HisApiController) GetCheckCode() {
  12576. ids_str := c.GetString("ids")
  12577. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12578. ids_arr := strings.Split(ids_str, ",")
  12579. var queryResult []QueryResult
  12580. ids := make([]int64, 0)
  12581. for _, item := range ids_arr {
  12582. id, _ := strconv.ParseInt(item, 10, 64)
  12583. ids = append(ids, id)
  12584. }
  12585. if record_type == 1 {
  12586. drugs, _ := service.GetBatchDrugList(ids)
  12587. for _, item := range drugs {
  12588. result := QueryResult{
  12589. ID: item.ID,
  12590. Name: item.DrugName,
  12591. Code: item.MedicalInsuranceNumber,
  12592. List_type_code: "101",
  12593. }
  12594. queryResult = append(queryResult, result)
  12595. }
  12596. } else if record_type == 2 {
  12597. goods, _ := service.GetBatchGoodInformationList(ids)
  12598. for _, item := range goods {
  12599. result := QueryResult{
  12600. ID: item.ID,
  12601. Name: item.GoodName,
  12602. Code: item.MedicalInsuranceNumber,
  12603. List_type_code: "301",
  12604. }
  12605. queryResult = append(queryResult, result)
  12606. }
  12607. } else if record_type == 3 {
  12608. projects, _ := service.GetBathchMyPorjecgList(ids)
  12609. for _, item := range projects {
  12610. result := QueryResult{
  12611. ID: item.ID,
  12612. Name: item.ProjectName,
  12613. Code: item.MedicalCode,
  12614. List_type_code: "201",
  12615. }
  12616. queryResult = append(queryResult, result)
  12617. }
  12618. }
  12619. admin_user_id, _ := c.GetInt64("admin_user_id")
  12620. adminUser := c.GetAdminUserInfo()
  12621. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12622. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12623. var user_name string
  12624. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12625. if role.ID == 0 {
  12626. user_name = "xxx"
  12627. } else {
  12628. user_name = role.UserName
  12629. }
  12630. baseParams := &models.BaseParams{
  12631. SecretKey: miConfig.SecretKey,
  12632. FixmedinsCode: miConfig.Code,
  12633. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12634. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12635. OrgName: miConfig.OrgName,
  12636. Doctor: user_name,
  12637. }
  12638. if config.IsOpen == 1 {
  12639. for _, item := range queryResult {
  12640. var result string
  12641. if record_type == 1 {
  12642. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12643. } else if record_type == 2 {
  12644. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12645. } else if record_type == 3 {
  12646. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  12647. }
  12648. var dat map[string]interface{}
  12649. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12650. fmt.Println(dat)
  12651. } else {
  12652. fmt.Println(err)
  12653. }
  12654. userJSONBytes, _ := json.Marshal(dat)
  12655. var res ResultSix
  12656. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12657. utils.ErrorLog("解析失败:%v", err)
  12658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12659. return
  12660. }
  12661. if res.Infcode == 0 {
  12662. if record_type == 1 {
  12663. service.UpdateBaseDrugById(item.ID)
  12664. } else if record_type == 2 {
  12665. service.UpdateGoodInformaitonByDetail(item.ID)
  12666. } else if record_type == 3 {
  12667. service.UpdateProjectById(item.ID)
  12668. }
  12669. c.ServeSuccessJSON(map[string]interface{}{
  12670. "failed_code": 0,
  12671. "msg": "目录对照成功",
  12672. })
  12673. } else {
  12674. c.ServeSuccessJSON(map[string]interface{}{
  12675. "failed_code": -10,
  12676. "msg": res.ErrMsg,
  12677. })
  12678. }
  12679. }
  12680. }
  12681. }
  12682. func (c *HisApiController) UnCheckCode() {
  12683. ids_str := c.GetString("ids")
  12684. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  12685. admin_user_id, _ := c.GetInt64("admin_user_id")
  12686. ids_arr := strings.Split(ids_str, ",")
  12687. var queryResult []QueryResult
  12688. ids := make([]int64, 0)
  12689. for _, item := range ids_arr {
  12690. id, _ := strconv.ParseInt(item, 10, 64)
  12691. ids = append(ids, id)
  12692. }
  12693. if record_type == 1 {
  12694. drugs, _ := service.GetBatchDrugList(ids)
  12695. for _, item := range drugs {
  12696. result := QueryResult{
  12697. ID: item.ID,
  12698. Name: item.DrugName,
  12699. Code: item.MedicalInsuranceNumber,
  12700. List_type_code: "101",
  12701. }
  12702. queryResult = append(queryResult, result)
  12703. }
  12704. } else if record_type == 2 {
  12705. goods, _ := service.GetBatchGoodInformationList(ids)
  12706. for _, item := range goods {
  12707. result := QueryResult{
  12708. ID: item.ID,
  12709. Name: item.GoodName,
  12710. Code: item.MedicalInsuranceNumber,
  12711. List_type_code: "301",
  12712. }
  12713. queryResult = append(queryResult, result)
  12714. }
  12715. } else if record_type == 3 {
  12716. projects, _ := service.GetBathchMyPorjecgList(ids)
  12717. for _, item := range projects {
  12718. result := QueryResult{
  12719. ID: item.ID,
  12720. Name: item.ProjectName,
  12721. Code: item.MedicalCode,
  12722. List_type_code: "201",
  12723. }
  12724. queryResult = append(queryResult, result)
  12725. }
  12726. }
  12727. adminUser := c.GetAdminUserInfo()
  12728. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12729. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12730. var user_name string
  12731. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12732. if role.ID == 0 {
  12733. user_name = "xxx"
  12734. } else {
  12735. user_name = role.UserName
  12736. }
  12737. baseParams := &models.BaseParams{
  12738. SecretKey: miConfig.SecretKey,
  12739. FixmedinsCode: miConfig.Code,
  12740. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  12741. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  12742. OrgName: miConfig.OrgName,
  12743. Doctor: user_name,
  12744. }
  12745. if config.IsOpen == 1 {
  12746. for _, item := range queryResult {
  12747. var result string
  12748. if record_type == 1 {
  12749. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12750. } else if record_type == 2 {
  12751. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12752. } else if record_type == 3 {
  12753. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  12754. }
  12755. var dat2 map[string]interface{}
  12756. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  12757. fmt.Println(dat2)
  12758. } else {
  12759. fmt.Println(err)
  12760. }
  12761. userJSONBytes, _ := json.Marshal(dat2)
  12762. var res ResultSix
  12763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12764. utils.ErrorLog("解析失败:%v", err)
  12765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12766. return
  12767. }
  12768. if res.Infcode == 0 {
  12769. if record_type == 1 {
  12770. service.UpdateDrugByIdDetail(item.ID)
  12771. } else if record_type == 2 {
  12772. service.UpdateGoodInfoById(item.ID)
  12773. } else if record_type == 3 {
  12774. service.UpdateMyProjectById(item.ID)
  12775. }
  12776. c.ServeSuccessJSON(map[string]interface{}{
  12777. "failed_code": 0,
  12778. "msg": "撤销目录对照成功",
  12779. })
  12780. } else {
  12781. c.ServeSuccessJSON(map[string]interface{}{
  12782. "failed_code": -10,
  12783. "msg": res.ErrMsg,
  12784. })
  12785. }
  12786. }
  12787. }
  12788. }
  12789. func (c *HisApiController) GetPatientInfo() {
  12790. id_card_no := c.GetString("id_card_no")
  12791. admin_user_id, _ := c.GetInt64("admin_user_id")
  12792. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  12793. if patient.ID == 0 {
  12794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  12795. return
  12796. }
  12797. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12798. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12799. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  12800. if config.IsOpen == 1 {
  12801. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  12802. var dat map[string]interface{}
  12803. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12804. fmt.Println(dat)
  12805. } else {
  12806. fmt.Println(err)
  12807. }
  12808. userJSONBytes, _ := json.Marshal(dat)
  12809. var res ResultTwo
  12810. var res10265 ResultTwo10265
  12811. if miConfig.Code == "H15049901371" {
  12812. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  12813. utils.ErrorLog("解析失败:%v", err)
  12814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12815. return
  12816. }
  12817. res.ErrMsg = res10265.ErrMsg
  12818. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12819. res.Infcode = infocode
  12820. res.Output = res10265.Output
  12821. res.InfRefmsgid = res10265.InfRefmsgid
  12822. } else {
  12823. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12824. utils.ErrorLog("解析失败:%v", err)
  12825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12826. return
  12827. }
  12828. }
  12829. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12830. // utils.ErrorLog("解析失败:%v", err)
  12831. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12832. // return
  12833. //}
  12834. if res.Infcode != 0 {
  12835. c.ServeSuccessJSON(map[string]interface{}{
  12836. "failed_code": -10,
  12837. "msg": res.ErrMsg,
  12838. })
  12839. } else {
  12840. c.ServeSuccessJSON(map[string]interface{}{
  12841. "failed_code": 0,
  12842. "info": res,
  12843. })
  12844. }
  12845. }
  12846. }
  12847. func (c *HisApiController) PsnPutOnRecord() {
  12848. record_type, _ := c.GetInt64("type")
  12849. patient_id, _ := c.GetInt64("patient_id")
  12850. admin_user_id, _ := c.GetInt64("admin_user_id")
  12851. start_time := c.GetString("start_time")
  12852. end_time := c.GetString("end_time")
  12853. adminUser := c.GetAdminUserInfo()
  12854. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12855. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12856. var patients []*models.Patients
  12857. if record_type == 1 { //全部备案
  12858. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  12859. patients = append(patients, patient...)
  12860. } else { //单个备案
  12861. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12862. patients = append(patients, patient)
  12863. }
  12864. var user_name string
  12865. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12866. if role.ID == 0 {
  12867. user_name = "xxx"
  12868. } else {
  12869. user_name = role.UserName
  12870. }
  12871. if config.IsOpen == 1 {
  12872. for _, item := range patients {
  12873. 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
  12874. resp, requestErr := http.Get(api)
  12875. if requestErr != nil {
  12876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12877. return
  12878. }
  12879. defer resp.Body.Close()
  12880. body, ioErr := ioutil.ReadAll(resp.Body)
  12881. if ioErr != nil {
  12882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12884. return
  12885. }
  12886. var respJSON map[string]interface{}
  12887. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12890. return
  12891. }
  12892. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12893. userJSONBytes, _ := json.Marshal(userJSON)
  12894. var res ResultTwo
  12895. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12896. utils.ErrorLog("解析失败:%v", err)
  12897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12898. return
  12899. }
  12900. if res.Infcode == 0 {
  12901. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  12902. var dat map[string]interface{}
  12903. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12904. fmt.Println(dat)
  12905. } else {
  12906. fmt.Println(err)
  12907. }
  12908. userJSONBytes, _ := json.Marshal(dat)
  12909. var res2 ResultThirteen
  12910. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12911. utils.ErrorLog("解析失败:%v", err)
  12912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12913. return
  12914. }
  12915. if res2.Infcode == 0 {
  12916. psnResult := &models.GdybPsnRecord{
  12917. UserOrgId: adminUser.CurrentOrgId,
  12918. PatientId: item.ID,
  12919. PsnNo: res.Output.Baseinfo.PsnNo,
  12920. Ctime: time.Now().Unix(),
  12921. Mtime: time.Now().Unix(),
  12922. Status: 1,
  12923. IsCancel: 1,
  12924. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  12925. }
  12926. service.CreatePsnRecord(psnResult)
  12927. } else {
  12928. c.ServeSuccessJSON(map[string]interface{}{
  12929. "failed_code": -10,
  12930. "msg": res2.ErrMsg,
  12931. })
  12932. return
  12933. }
  12934. }
  12935. }
  12936. }
  12937. }
  12938. func (c *HisApiController) PsnUnPutOnRecord() {
  12939. id, _ := c.GetInt64("id")
  12940. //record_type, _ := c.GetInt64("type")
  12941. admin_user_id, _ := c.GetInt64("admin_user_id")
  12942. adminUser := c.GetAdminUserInfo()
  12943. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12944. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12945. var user_name string
  12946. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12947. if role.ID == 0 {
  12948. user_name = "xxx"
  12949. } else {
  12950. user_name = role.UserName
  12951. }
  12952. psn_record, _ := service.GetPsnRecordById(id)
  12953. if psn_record.ID == 0 {
  12954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12955. return
  12956. }
  12957. if config.IsOpen == 1 {
  12958. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  12959. var dat map[string]interface{}
  12960. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12961. fmt.Println(dat)
  12962. } else {
  12963. fmt.Println(err)
  12964. }
  12965. userJSONBytes, _ := json.Marshal(dat)
  12966. var res ResultFourteen
  12967. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12968. utils.ErrorLog("解析失败:%v", err)
  12969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12970. return
  12971. }
  12972. if res.Infcode == 0 {
  12973. psn_record.IsCancel = 2
  12974. service.CreatePsnRecord(&psn_record)
  12975. } else {
  12976. c.ServeSuccessJSON(map[string]interface{}{
  12977. "failed_code": -10,
  12978. "msg": res.ErrMsg,
  12979. })
  12980. return
  12981. }
  12982. }
  12983. }
  12984. func (c *HisApiController) PsnPutNCDSOnRecord() {
  12985. patient_id, _ := c.GetInt64("patient_id")
  12986. insutype_two := c.GetString("insutype")
  12987. psn_no := c.GetString("psn_no")
  12988. doctor_id, _ := c.GetInt64("doctor_id")
  12989. sick_id, _ := c.GetInt64("sick_id")
  12990. department_id, _ := c.GetInt64("department_id")
  12991. start_time := c.GetString("start_time")
  12992. end_time := c.GetString("end_time")
  12993. check_time := c.GetString("check_time")
  12994. adminUser := c.GetAdminUserInfo()
  12995. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  12996. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12997. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12998. sick, _ := service.FindSickById(sick_id)
  12999. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13000. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  13001. var res ResultTwo
  13002. var res10265 ResultTwo10265
  13003. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13004. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  13005. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  13006. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13007. "&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
  13008. resp, requestErr := http.Get(api)
  13009. if requestErr != nil {
  13010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13011. return
  13012. }
  13013. body, ioErr := ioutil.ReadAll(resp.Body)
  13014. if ioErr != nil {
  13015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13017. return
  13018. }
  13019. var respJSON map[string]interface{}
  13020. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13023. return
  13024. }
  13025. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13026. result, _ := json.Marshal(respJSON)
  13027. fmt.Println("log")
  13028. fmt.Println(string(result))
  13029. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13030. utils.ErrorLog("解析失败:%v", err)
  13031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13032. return
  13033. }
  13034. res.ErrMsg = res10265.ErrMsg
  13035. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13036. res.Infcode = infocode
  13037. res.Output = res10265.Output
  13038. res.InfRefmsgid = res10265.InfRefmsgid
  13039. } else {
  13040. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13041. if miConfig.Code == "H15049901371" {
  13042. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13043. utils.ErrorLog("解析失败:%v", err)
  13044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13045. return
  13046. }
  13047. res.ErrMsg = res10265.ErrMsg
  13048. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13049. res.Infcode = infocode
  13050. res.Output = res10265.Output
  13051. res.InfRefmsgid = res10265.InfRefmsgid
  13052. } else {
  13053. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13054. utils.ErrorLog("解析失败:%v", err)
  13055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13056. return
  13057. }
  13058. }
  13059. }
  13060. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13061. infoStr := string(Iinfos)
  13062. var rf []*ResultFive
  13063. json.Unmarshal([]byte(infoStr), &rf)
  13064. var insuplc_admdvs string
  13065. var insutype string
  13066. var is390 int = 0
  13067. var is310 int = 0
  13068. var insutypes []*ResultFive
  13069. for _, item := range rf {
  13070. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13071. insutypes = append(insutypes, item)
  13072. }
  13073. }
  13074. if len(insutypes) == 1 {
  13075. insutype = insutypes[0].Insutype
  13076. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13077. } else {
  13078. for _, i := range insutypes {
  13079. if i.Insutype == "390" {
  13080. is390 = 1
  13081. }
  13082. if i.Insutype == "310" {
  13083. is310 = 1
  13084. }
  13085. }
  13086. }
  13087. if is390 == 1 {
  13088. insutype = "390"
  13089. }
  13090. if is310 == 1 {
  13091. insutype = "310"
  13092. }
  13093. if len(insutypes) == 2 {
  13094. insutype = insutype_two
  13095. }
  13096. if len(insutypes) == 0 {
  13097. insutype = "310"
  13098. }
  13099. insutype = insutype_two
  13100. fmt.Println(insutype)
  13101. for _, item := range rf {
  13102. fmt.Println(item.Insutype)
  13103. fmt.Println(insutype)
  13104. if item.Insutype == insutype {
  13105. fmt.Println(item.Insutype)
  13106. fmt.Println(insutype)
  13107. insuplc_admdvs = item.InsuplcAdmdvs
  13108. }
  13109. }
  13110. fmt.Println(insuplc_admdvs)
  13111. var res2 ResultThirteen
  13112. var res10265_2 ResultThirteen10265
  13113. if config.IsOpen == 1 {
  13114. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13115. } else {
  13116. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time)
  13117. var dat map[string]interface{}
  13118. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13119. fmt.Println(dat)
  13120. } else {
  13121. fmt.Println(err)
  13122. }
  13123. userJSONBytes, _ := json.Marshal(dat)
  13124. if miConfig.Code == "H15049901371" {
  13125. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  13126. utils.ErrorLog("解析失败:%v", err)
  13127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13128. return
  13129. }
  13130. res2.ErrMsg = res10265_2.ErrMsg
  13131. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  13132. res2.Infcode = infocode
  13133. res2.Output = res10265_2.Output
  13134. res2.InfRefmsgid = res10265_2.InfRefmsgid
  13135. } else {
  13136. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13137. utils.ErrorLog("解析失败:%v", err)
  13138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13139. return
  13140. }
  13141. }
  13142. }
  13143. if res2.Infcode == 0 {
  13144. psnResult := &models.GdybPsnNcdsRecord{
  13145. UserOrgId: adminUser.CurrentOrgId,
  13146. PatientId: patient.ID,
  13147. PsnNo: psn_no,
  13148. DoctorId: doctor.AdminUserId,
  13149. DepartmentId: department_id,
  13150. SickType: sick_id,
  13151. Insutype: insutype,
  13152. Ctime: time.Now().Unix(),
  13153. Mtime: time.Now().Unix(),
  13154. Status: 1,
  13155. IsCancel: 1,
  13156. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  13157. }
  13158. service.CreatePsnNCDSRecord(psnResult)
  13159. c.ServeSuccessJSON(map[string]interface{}{
  13160. "failed_code": 0,
  13161. "msg": "备案成功",
  13162. "result": psnResult,
  13163. })
  13164. } else {
  13165. c.ServeSuccessJSON(map[string]interface{}{
  13166. "failed_code": -10,
  13167. "msg": res2.ErrMsg,
  13168. })
  13169. return
  13170. }
  13171. }
  13172. }
  13173. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  13174. id, _ := c.GetInt64("id")
  13175. admin_user_id, _ := c.GetInt64("admin_user_id")
  13176. adminUser := c.GetAdminUserInfo()
  13177. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13178. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13179. //config, _ := service.Ge(adminUser.CurrentOrgId)
  13180. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  13181. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13182. //var user_name string
  13183. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13184. //if role.ID == 0 {
  13185. // user_name = "xxx"
  13186. //} else {
  13187. // user_name = role.UserName
  13188. //}
  13189. psn_record, _ := service.GetPsnNCDSRecordById(id)
  13190. if psn_record.ID == 0 {
  13191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13192. return
  13193. }
  13194. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  13195. var res ResultTwo
  13196. var res10265 ResultTwo10265
  13197. if miConfig.Code == "H15049901371" {
  13198. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13199. utils.ErrorLog("解析失败:%v", err)
  13200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13201. return
  13202. }
  13203. res.ErrMsg = res10265.ErrMsg
  13204. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13205. res.Infcode = infocode
  13206. res.Output = res10265.Output
  13207. res.InfRefmsgid = res10265.InfRefmsgid
  13208. } else {
  13209. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13210. utils.ErrorLog("解析失败:%v", err)
  13211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13212. return
  13213. }
  13214. }
  13215. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13216. infoStr := string(Iinfos)
  13217. var rf []*ResultFive
  13218. json.Unmarshal([]byte(infoStr), &rf)
  13219. var insuplc_admdvs string
  13220. var insutype string
  13221. var is390 int = 0
  13222. var is310 int = 0
  13223. var insutypes []*ResultFive
  13224. for _, item := range rf {
  13225. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13226. insutypes = append(insutypes, item)
  13227. }
  13228. }
  13229. if len(insutypes) == 1 {
  13230. insutype = insutypes[0].Insutype
  13231. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13232. } else {
  13233. for _, i := range insutypes {
  13234. if i.Insutype == "390" {
  13235. is390 = 1
  13236. }
  13237. if i.Insutype == "310" {
  13238. is310 = 1
  13239. }
  13240. }
  13241. }
  13242. if is390 == 1 {
  13243. insutype = "390"
  13244. }
  13245. if is310 == 1 {
  13246. insutype = "310"
  13247. }
  13248. if len(insutypes) == 0 {
  13249. insutype = "310"
  13250. }
  13251. insutype = psn_record.Insutype
  13252. for _, item := range rf {
  13253. if item.Insutype == insutype {
  13254. insuplc_admdvs = item.InsuplcAdmdvs
  13255. }
  13256. }
  13257. if config.IsOpen == 1 {
  13258. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  13259. var dat map[string]interface{}
  13260. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13261. fmt.Println(dat)
  13262. } else {
  13263. fmt.Println(err)
  13264. }
  13265. userJSONBytes, _ := json.Marshal(dat)
  13266. var res ResultFourteen
  13267. var res10265 ResultFourteen10265
  13268. if miConfig.Code == "H15049901371" {
  13269. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13270. utils.ErrorLog("解析失败:%v", err)
  13271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13272. return
  13273. }
  13274. res.ErrMsg = res10265.ErrMsg
  13275. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13276. res.Infcode = infocode
  13277. res.Output = res10265.Output
  13278. res.InfRefmsgid = res10265.InfRefmsgid
  13279. } else {
  13280. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13281. utils.ErrorLog("解析失败:%v", err)
  13282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13283. return
  13284. }
  13285. }
  13286. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13287. // utils.ErrorLog("解析失败:%v", err)
  13288. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13289. // return
  13290. //}
  13291. if res.Infcode == 0 {
  13292. psn_record.IsCancel = 2
  13293. service.CreatePsnNCDSRecord(&psn_record)
  13294. c.ServeSuccessJSON(map[string]interface{}{
  13295. "failed_code": 0,
  13296. "msg": "撤销备案成功",
  13297. })
  13298. } else {
  13299. c.ServeSuccessJSON(map[string]interface{}{
  13300. "failed_code": -10,
  13301. "msg": res.ErrMsg,
  13302. })
  13303. return
  13304. }
  13305. }
  13306. }
  13307. func (c *HisApiController) TestTest() {
  13308. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  13309. fmt.Println(patient.Iinfo)
  13310. }
  13311. type CustomData struct {
  13312. MsgId string
  13313. PsnNo string
  13314. Info string
  13315. }
  13316. func (c *HisApiController) ReversalData() {
  13317. var customData []*CustomData
  13318. custom := &CustomData{
  13319. MsgId: "H44022900158202103301714472004",
  13320. PsnNo: "44020000001101329945",
  13321. Info: "2207",
  13322. }
  13323. customData = append(customData, custom)
  13324. custom1 := &CustomData{
  13325. MsgId: "H4402290015820210330172057803",
  13326. PsnNo: "44020000001101161813",
  13327. Info: "2207",
  13328. }
  13329. customData = append(customData, custom1)
  13330. custom2 := &CustomData{
  13331. MsgId: "H44022900158202103301705198813",
  13332. PsnNo: "44190000133097375417",
  13333. Info: "2207",
  13334. }
  13335. customData = append(customData, custom2)
  13336. custom3 := &CustomData{
  13337. MsgId: "H44022900158202103301715524756",
  13338. PsnNo: "44020000001100187221",
  13339. Info: "2207",
  13340. }
  13341. customData = append(customData, custom3)
  13342. custom4 := &CustomData{
  13343. MsgId: "H44022900158202103301730376224",
  13344. PsnNo: "44020000001101959155",
  13345. Info: "2207",
  13346. }
  13347. customData = append(customData, custom4)
  13348. custom5 := &CustomData{
  13349. MsgId: "H44022900158202103301748008725",
  13350. PsnNo: "44020000001104246641",
  13351. Info: "2207",
  13352. }
  13353. customData = append(customData, custom5)
  13354. custom6 := &CustomData{
  13355. MsgId: "H44022900158202103301718096755",
  13356. PsnNo: "44020000001102211860",
  13357. Info: "2207",
  13358. }
  13359. customData = append(customData, custom6)
  13360. custom7 := &CustomData{
  13361. MsgId: "H44022900158202103301736551640",
  13362. PsnNo: "44020000001102687718",
  13363. Info: "2207",
  13364. }
  13365. customData = append(customData, custom7)
  13366. custom8 := &CustomData{
  13367. MsgId: "H44022900158202103301743097676",
  13368. PsnNo: "44020000001102127785",
  13369. Info: "2207",
  13370. }
  13371. customData = append(customData, custom8)
  13372. custom9 := &CustomData{
  13373. MsgId: "H44022900158202103301712304203",
  13374. PsnNo: "44020000001101518097",
  13375. Info: "2207",
  13376. }
  13377. customData = append(customData, custom9)
  13378. custom10 := &CustomData{
  13379. MsgId: "H44022900158202103301738448785",
  13380. PsnNo: "44020000001100500813",
  13381. Info: "2207",
  13382. }
  13383. customData = append(customData, custom10)
  13384. custom11 := &CustomData{
  13385. MsgId: "H44022900158202103301732455843",
  13386. PsnNo: "44020000001102690557",
  13387. Info: "2207",
  13388. }
  13389. customData = append(customData, custom11)
  13390. custom12 := &CustomData{
  13391. MsgId: "H44022900158202103301745421708",
  13392. PsnNo: "44020000001102211928",
  13393. Info: "2207",
  13394. }
  13395. customData = append(customData, custom12)
  13396. custom1212 := &CustomData{
  13397. MsgId: "H440229001582021033017351627",
  13398. PsnNo: "44020000001102481733",
  13399. Info: "2207",
  13400. }
  13401. customData = append(customData, custom1212)
  13402. custom13 := &CustomData{
  13403. MsgId: "H44022900158202103301740327951",
  13404. PsnNo: "44020000001103174866",
  13405. Info: "2207",
  13406. }
  13407. customData = append(customData, custom13)
  13408. custom14 := &CustomData{
  13409. MsgId: "H4402290015820210330174922668",
  13410. PsnNo: "44020000001102927272",
  13411. Info: "2207",
  13412. }
  13413. customData = append(customData, custom14)
  13414. custom15 := &CustomData{
  13415. MsgId: "H44022900158202103301752362273",
  13416. PsnNo: "44020000001102942890",
  13417. Info: "2207",
  13418. }
  13419. customData = append(customData, custom15)
  13420. custom16 := &CustomData{
  13421. MsgId: "H44022900158202103301751082917",
  13422. PsnNo: "44020000001101662162",
  13423. Info: "2207",
  13424. }
  13425. customData = append(customData, custom16)
  13426. custom17 := &CustomData{
  13427. MsgId: "H44022900158202103301754147728",
  13428. PsnNo: "44020000000229014511",
  13429. Info: "2207",
  13430. }
  13431. customData = append(customData, custom17)
  13432. adminUser := c.GetAdminUserInfo()
  13433. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13434. for _, item := range customData {
  13435. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13436. fmt.Println(result)
  13437. }
  13438. }
  13439. //func (c *HisApiController) GetAllopatry() {
  13440. // year := c.GetString("year")
  13441. // month := c.GetString("month")
  13442. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13443. // adminUser := c.GetAdminUserInfo()
  13444. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13445. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13446. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13447. //
  13448. // var dat map[string]interface{}
  13449. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13450. // fmt.Println(dat)
  13451. // } else {
  13452. // fmt.Println(err)
  13453. // }
  13454. // userJSONBytes, _ := json.Marshal(dat)
  13455. // var res models.Result9001
  13456. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13457. // utils.ErrorLog("解析失败:%v", err)
  13458. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13459. // return
  13460. // }
  13461. //
  13462. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13463. // var dat2 map[string]interface{}
  13464. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13465. // fmt.Println(dat)
  13466. // } else {
  13467. // fmt.Println(err)
  13468. // }
  13469. // userJSONBytes2, _ := json.Marshal(dat2)
  13470. // var res2 models.Result3260
  13471. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13472. // utils.ErrorLog("解析失败:%v", err)
  13473. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13474. // return
  13475. // }
  13476. // if res2.Infcode == 0 {
  13477. // c.ServeSuccessJSON(map[string]interface{}{
  13478. // "list": res2.Output.Data,
  13479. // })
  13480. // return
  13481. // } else {
  13482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13483. // return
  13484. // }
  13485. //
  13486. //}
  13487. //func (c *HisApiController) ComfirmAllopatry() {
  13488. // year := c.GetString("year")
  13489. // month := c.GetString("month")
  13490. // admin_user_id, _ := c.GetInt64("admin_user_id")
  13491. // adminUser := c.GetAdminUserInfo()
  13492. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13493. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13494. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  13495. // var dat map[string]interface{}
  13496. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13497. // fmt.Println(dat)
  13498. // } else {
  13499. // fmt.Println(err)
  13500. // }
  13501. // userJSONBytes, _ := json.Marshal(dat)
  13502. // var res models.Result9001
  13503. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13504. // utils.ErrorLog("解析失败:%v", err)
  13505. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13506. // return
  13507. // }
  13508. //
  13509. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  13510. // var dat2 map[string]interface{}
  13511. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  13512. // fmt.Println(dat)
  13513. // } else {
  13514. // fmt.Println(err)
  13515. // }
  13516. // userJSONBytes2, _ := json.Marshal(dat2)
  13517. // var res2 models.Result3260
  13518. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  13519. // utils.ErrorLog("解析失败:%v", err)
  13520. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13521. // return
  13522. // }
  13523. //
  13524. // if res2.Infcode == 0 {
  13525. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  13526. // var dat map[string]interface{}
  13527. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13528. // fmt.Println(dat)
  13529. // } else {
  13530. // fmt.Println(err)
  13531. // }
  13532. // userJSONBytes, _ := json.Marshal(dat)
  13533. // var res3 models.Result3261
  13534. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  13535. // utils.ErrorLog("解析失败:%v", err)
  13536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13537. // return
  13538. // }
  13539. //
  13540. // if res3.Infcode == 0 {
  13541. // record := &models.HisYidiClearRecord{
  13542. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13543. // Ctime: time.Now().Unix(),
  13544. // Mtime: time.Now().Unix(),
  13545. // Status: 1,
  13546. // MsgId: msgId,
  13547. // }
  13548. // service.SaveClearRecord(record)
  13549. // c.ServeSuccessJSON(map[string]interface{}{
  13550. // "msg": "提取成功",
  13551. // })
  13552. // }
  13553. // }
  13554. //}
  13555. func (c *HisApiController) RefundAllopatry() {
  13556. year := c.GetString("year")
  13557. month := c.GetString("month")
  13558. id, _ := c.GetInt64("id")
  13559. admin_user_id, _ := c.GetInt64("admin_user_id")
  13560. adminUser := c.GetAdminUserInfo()
  13561. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13562. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13563. record, _ := service.GetClearRecordById(id)
  13564. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  13565. var dat map[string]interface{}
  13566. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13567. fmt.Println(dat)
  13568. } else {
  13569. fmt.Println(err)
  13570. }
  13571. userJSONBytes, _ := json.Marshal(dat)
  13572. var empty ResultFourteen
  13573. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  13574. utils.ErrorLog("解析失败:%v", err)
  13575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13576. return
  13577. }
  13578. if empty.Infcode == 0 {
  13579. c.ServeSuccessJSON(map[string]interface{}{
  13580. "msg": "撤销成功",
  13581. })
  13582. return
  13583. }
  13584. }
  13585. func (c *HisApiController) ReversalOtherData() {
  13586. var customData []*CustomData
  13587. custom := &CustomData{
  13588. MsgId: "H44022900158202103301714472004",
  13589. PsnNo: "44020000001101329945",
  13590. Info: "2208",
  13591. }
  13592. customData = append(customData, custom)
  13593. custom1 := &CustomData{
  13594. MsgId: "H4402290015820210330172057803",
  13595. PsnNo: "44020000001101161813",
  13596. Info: "2208",
  13597. }
  13598. customData = append(customData, custom1)
  13599. custom2 := &CustomData{
  13600. MsgId: "H44022900158202103301705198813",
  13601. PsnNo: "44190000133097375417",
  13602. Info: "2208",
  13603. }
  13604. customData = append(customData, custom2)
  13605. custom3 := &CustomData{
  13606. MsgId: "H44022900158202103301715524756",
  13607. PsnNo: "44020000001100187221",
  13608. Info: "2208",
  13609. }
  13610. customData = append(customData, custom3)
  13611. custom4 := &CustomData{
  13612. MsgId: "H44022900158202103301730376224",
  13613. PsnNo: "44020000001101959155",
  13614. Info: "2208",
  13615. }
  13616. customData = append(customData, custom4)
  13617. custom5 := &CustomData{
  13618. MsgId: "H44022900158202103301748008725",
  13619. PsnNo: "44020000001104246641",
  13620. Info: "2208",
  13621. }
  13622. customData = append(customData, custom5)
  13623. custom6 := &CustomData{
  13624. MsgId: "H44022900158202103301718096755",
  13625. PsnNo: "44020000001102211860",
  13626. Info: "2208",
  13627. }
  13628. customData = append(customData, custom6)
  13629. custom7 := &CustomData{
  13630. MsgId: "H44022900158202103301736551640",
  13631. PsnNo: "44020000001102687718",
  13632. Info: "2208",
  13633. }
  13634. customData = append(customData, custom7)
  13635. custom8 := &CustomData{
  13636. MsgId: "H44022900158202103301743097676",
  13637. PsnNo: "44020000001102127785",
  13638. Info: "2208",
  13639. }
  13640. customData = append(customData, custom8)
  13641. custom9 := &CustomData{
  13642. MsgId: "H44022900158202103301712304203",
  13643. PsnNo: "44020000001101518097",
  13644. Info: "2208",
  13645. }
  13646. customData = append(customData, custom9)
  13647. custom10 := &CustomData{
  13648. MsgId: "H44022900158202103301738448785",
  13649. PsnNo: "44020000001100500813",
  13650. Info: "2208",
  13651. }
  13652. customData = append(customData, custom10)
  13653. custom11 := &CustomData{
  13654. MsgId: "H44022900158202103301732455843",
  13655. PsnNo: "44020000001102690557",
  13656. Info: "2208",
  13657. }
  13658. customData = append(customData, custom11)
  13659. custom12 := &CustomData{
  13660. MsgId: "H44022900158202103301745421708",
  13661. PsnNo: "44020000001102211928",
  13662. Info: "2208",
  13663. }
  13664. customData = append(customData, custom12)
  13665. custom1212 := &CustomData{
  13666. MsgId: "H440229001582021033017351627",
  13667. PsnNo: "44020000001102481733",
  13668. Info: "2208",
  13669. }
  13670. customData = append(customData, custom1212)
  13671. custom13 := &CustomData{
  13672. MsgId: "H44022900158202103301740327951",
  13673. PsnNo: "44020000001103174866",
  13674. Info: "2208",
  13675. }
  13676. customData = append(customData, custom13)
  13677. custom14 := &CustomData{
  13678. MsgId: "H4402290015820210330174922668",
  13679. PsnNo: "44020000001102927272",
  13680. Info: "2208",
  13681. }
  13682. customData = append(customData, custom14)
  13683. custom15 := &CustomData{
  13684. MsgId: "H44022900158202103301752362273",
  13685. PsnNo: "44020000001102942890",
  13686. Info: "2208",
  13687. }
  13688. customData = append(customData, custom15)
  13689. custom16 := &CustomData{
  13690. MsgId: "H44022900158202103301751082917",
  13691. PsnNo: "44020000001101662162",
  13692. Info: "2208",
  13693. }
  13694. customData = append(customData, custom16)
  13695. custom17 := &CustomData{
  13696. MsgId: "H44022900158202103301754147728",
  13697. PsnNo: "44020000000229014511",
  13698. Info: "2208",
  13699. }
  13700. customData = append(customData, custom17)
  13701. adminUser := c.GetAdminUserInfo()
  13702. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13703. for _, item := range customData {
  13704. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13705. fmt.Println(result)
  13706. }
  13707. }
  13708. func PathExists(path string) (bool, error) {
  13709. _, err := os.Stat(path)
  13710. if err == nil {
  13711. return true, nil
  13712. }
  13713. if os.IsNotExist(err) {
  13714. return false, nil
  13715. }
  13716. return false, err
  13717. }
  13718. //创建文件夹
  13719. func Mkdir(dir string) {
  13720. // 创建文件夹
  13721. exist, err := PathExists(dir)
  13722. if err != nil {
  13723. fmt.Println(err.Error())
  13724. } else {
  13725. if exist {
  13726. fmt.Println(dir + "文件夹已存在!")
  13727. } else {
  13728. // 文件夹名称,权限
  13729. err := os.Mkdir(dir, os.ModePerm)
  13730. if err != nil {
  13731. fmt.Println(dir+"文件夹创建失败:", err.Error())
  13732. } else {
  13733. fmt.Println(dir + "文件夹创建成功!")
  13734. }
  13735. }
  13736. }
  13737. }
  13738. //压缩文件
  13739. func Zip(srcFile string, destZip string) error {
  13740. zipfile, err := os.Create(destZip)
  13741. if err != nil {
  13742. return err
  13743. }
  13744. defer zipfile.Close()
  13745. archive := zip.NewWriter(zipfile)
  13746. defer archive.Close()
  13747. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  13748. if err != nil {
  13749. return err
  13750. }
  13751. header, err := zip.FileInfoHeader(info)
  13752. if err != nil {
  13753. return err
  13754. }
  13755. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  13756. // header.Name = path
  13757. if info.IsDir() {
  13758. header.Name += "/"
  13759. } else {
  13760. header.Method = zip.Deflate
  13761. }
  13762. writer, err := archive.CreateHeader(header)
  13763. if err != nil {
  13764. return err
  13765. }
  13766. if !info.IsDir() {
  13767. file, err := os.Open(path)
  13768. if err != nil {
  13769. return err
  13770. }
  13771. defer file.Close()
  13772. _, err = io.Copy(writer, file)
  13773. }
  13774. return err
  13775. })
  13776. return err
  13777. }
  13778. func ReadFile(filePath string) []byte {
  13779. f, err := os.Open(filePath)
  13780. if err != nil {
  13781. fmt.Println("read file fail", err)
  13782. return nil
  13783. }
  13784. defer f.Close()
  13785. fd, err := ioutil.ReadAll(f)
  13786. if err != nil {
  13787. fmt.Println("read to fd fail", err)
  13788. return nil
  13789. }
  13790. return fd
  13791. }
  13792. func saveLog(result string, request string, infno string, desc string) {
  13793. org_id, _ := beego.AppConfig.Int64("org_id")
  13794. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13795. dir := miConfig.OrgName + "日志"
  13796. utils.Mkdir(dir)
  13797. month := time.Unix(1557042972, 0).Format("1")
  13798. year := time.Now().Format("2006")
  13799. month = time.Now().Format("01")
  13800. day := time.Now().Format("02")
  13801. hour := time.Now().Format("15")
  13802. min := time.Now().Format("04")
  13803. sec := time.Now().Format("05")
  13804. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  13805. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  13806. file_name := file + ".txt"
  13807. file_path := miConfig.OrgName + "日志" + "/" + file_name
  13808. exist, _ := utils.PathExists(file_path)
  13809. if exist { //存在
  13810. fmt.Println("存在")
  13811. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  13812. if err != nil {
  13813. fmt.Println("read fail")
  13814. }
  13815. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  13816. n, _ := f.Seek(0, 2)
  13817. _, err = f.WriteAt([]byte(content), n)
  13818. } else { //不存在
  13819. fmt.Println("文件不存在,创建文件")
  13820. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  13821. defer f.Close()
  13822. if err != nil {
  13823. } else {
  13824. _, err = f.Write([]byte("记录日志"))
  13825. }
  13826. }
  13827. }
  13828. type Charset string
  13829. const (
  13830. UTF8 = Charset("UTF-8")
  13831. GB18030 = Charset("GB18030")
  13832. )
  13833. func ConvertToString(src string, srcCode string, tagCode string) string {
  13834. srcCoder := mahonia.NewDecoder(srcCode)
  13835. srcResult := srcCoder.ConvertString(src)
  13836. tagCoder := mahonia.NewDecoder(tagCode)
  13837. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  13838. result := string(cdata)
  13839. return result
  13840. }
  13841. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  13842. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  13843. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  13844. var token string
  13845. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13846. var api string
  13847. if miConfig.MdtrtareaAdmvs == "320921" {
  13848. 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 +
  13849. "&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
  13850. fmt.Println(api)
  13851. } else {
  13852. 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 +
  13853. "&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
  13854. }
  13855. resp, requestErr := http.Get(api)
  13856. if requestErr != nil {
  13857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13858. return ""
  13859. }
  13860. body, ioErr := ioutil.ReadAll(resp.Body)
  13861. if ioErr != nil {
  13862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13864. return ""
  13865. }
  13866. var respJSON map[string]interface{}
  13867. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13870. return ""
  13871. }
  13872. var status string
  13873. status = respJSON["data"].(map[string]interface{})["status"].(string)
  13874. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  13875. var res ResultTwo //1101结果
  13876. var res10265 ResultTwo10265 //1101结果
  13877. if status == "0" { //读卡成功
  13878. var card_info string //卡信息
  13879. var busi_card_info string
  13880. token = respJSON["data"].(map[string]interface{})["token"].(string)
  13881. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  13882. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  13883. fmt.Println(card_info)
  13884. fmt.Println(busi_card_info)
  13885. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  13886. result, _ := json.Marshal(respJSON)
  13887. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13888. utils.ErrorLog("解析失败:%v", err)
  13889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13890. return ""
  13891. }
  13892. res.ErrMsg = res10265.ErrMsg
  13893. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13894. res.Infcode = infocode
  13895. res.Output = res10265.Output
  13896. res.InfRefmsgid = res10265.InfRefmsgid
  13897. if res.Infcode == 0 {
  13898. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13899. if err == gorm.ErrRecordNotFound {
  13900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13901. return ""
  13902. } else if err != nil {
  13903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13904. return ""
  13905. } else {
  13906. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13907. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13908. infoStr := string(Iinfos)
  13909. idetinfoStr := string(Idetinfos)
  13910. psn := &models.HisPsn{
  13911. PsnNo: res.Output.Baseinfo.PsnNo,
  13912. Age: res.Output.Baseinfo.Age,
  13913. PatientId: patient.ID,
  13914. Certno: res.Output.Baseinfo.Certno,
  13915. Brdy: res.Output.Baseinfo.Brdy,
  13916. Gend: res.Output.Baseinfo.Gend,
  13917. Naty: res.Output.Baseinfo.Naty,
  13918. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13919. PsnName: res.Output.Baseinfo.PsnName,
  13920. Idetinfo: idetinfoStr,
  13921. Insuinfo: infoStr,
  13922. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13923. CardInfo: card_info,
  13924. VerifyNumber: token,
  13925. }
  13926. service.CreateHisPsn(psn)
  13927. return token
  13928. }
  13929. }
  13930. } else {
  13931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13932. return ""
  13933. }
  13934. } else { //读卡失败
  13935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13936. return ""
  13937. }
  13938. return token
  13939. }
  13940. func DeleteExtraSpaceTwo(s string) string {
  13941. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  13942. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  13943. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  13944. reg, _ := regexp.Compile(regstr) //编译正则表达式
  13945. s2 := make([]byte, len(s1)) //定义字符数组切片
  13946. copy(s2, s1) //将字符串复制到切片
  13947. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  13948. for len(spc_index) > 0 { //找到适配项
  13949. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  13950. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  13951. }
  13952. return string(s2)
  13953. }
  13954. func Remove0000(s string) string {
  13955. str := make([]rune, 0, len(s))
  13956. for _, v := range []rune(s) {
  13957. if v == 0 {
  13958. continue
  13959. }
  13960. str = append(str, v)
  13961. }
  13962. return string(str)
  13963. }
  13964. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  13965. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  13966. readCard := DllDef.MustFindProc("EcQuery")
  13967. pCardInfo := make([]byte, 8192)
  13968. pBusiCardInfo := make([]byte, 8192)
  13969. data := make(map[string]interface{})
  13970. //pData := make(map[string]interface{})
  13971. inputData := make(map[string]interface{})
  13972. inputData["orgId"] = code
  13973. inputData["businessType"] = "01101"
  13974. inputData["operatorId"] = operator_id
  13975. inputData["operatorName"] = operator_name
  13976. inputData["officeId"] = "001"
  13977. inputData["officeName"] = "血透室"
  13978. //
  13979. data["data"] = inputData
  13980. data["transType"] = "ec.query"
  13981. data["orgId"] = code
  13982. bytesData, _ := json.Marshal(data)
  13983. pCardInfo = bytesData
  13984. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  13985. fmt.Println(ret2)
  13986. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  13987. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  13988. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  13989. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  13990. if ret2 != 0 {
  13991. return "", ""
  13992. }
  13993. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  13994. }
  13995. func DeleteExtraSpace(s string) string {
  13996. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  13997. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  13998. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  13999. reg, _ := regexp.Compile(regstr) //编译正则表达式
  14000. s2 := make([]byte, len(s1)) //定义字符数组切片
  14001. copy(s2, s1) //将字符串复制到切片
  14002. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  14003. for len(spc_index) > 0 { //找到适配项
  14004. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  14005. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  14006. }
  14007. return string(s2)
  14008. }
  14009. //对账
  14010. func (c *HisApiController) Post3202() {
  14011. start_time := c.GetString("start_time")
  14012. end_time := c.GetString("end_time")
  14013. //insutype := c.GetString("insutype")
  14014. clr_type := c.GetString("clr_type")
  14015. clr_org := c.GetString("clr_optins")
  14016. admin_user_id, _ := c.GetInt64("admin_user_id")
  14017. adminUser := c.GetAdminUserInfo()
  14018. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14019. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14020. if len(clr_org) == 0 {
  14021. clr_org = miConfig.MdtrtareaAdmvs
  14022. }
  14023. timeLayout := "2006-01-02"
  14024. loc, _ := time.LoadLocation("Local")
  14025. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  14026. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  14027. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  14028. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  14029. //fixmedins_setl_cnt := int64(len(orders))
  14030. var medfee_sumamt float64
  14031. var acct_pay float64
  14032. var fund_pay_sumamt float64
  14033. for _, item := range orders {
  14034. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  14035. acct_pay = acct_pay + item.AcctPay
  14036. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  14037. }
  14038. //var medfee_sumamt_two float64
  14039. //var acct_pay_two float64
  14040. //var fund_pay_sumamt_two float64
  14041. //for _, item := range orders_two {
  14042. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  14043. // acct_pay_two = acct_pay_two + item.AcctPay
  14044. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  14045. //}
  14046. //var user_name string
  14047. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14048. //if role.ID == 0 {
  14049. // user_name = "xxx"
  14050. //} else {
  14051. // user_name = role.UserName
  14052. //}
  14053. var res ResultSix
  14054. if config.IsOpen == 1 {
  14055. var bps []*models.BusinessParamsTwo
  14056. var bp models.BusinessParamsTwo
  14057. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  14058. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  14059. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  14060. bp.MedfeeSumamt = medfee_sumamt_str
  14061. bp.AcctPay = acct_pay_str
  14062. bp.FundPaySumamt = fund_pay_sumamt_str
  14063. bp.Insutype = "390"
  14064. bp.StmtBegndate = start_time
  14065. bp.ClrType = clr_type
  14066. bp.SetlOptins = clr_org
  14067. bp.StmtEnddate = end_time
  14068. bps = append(bps, &bp)
  14069. data := make(map[string]interface{})
  14070. data["bps"] = bps
  14071. data["org_name"] = miConfig.OrgName
  14072. data["doctor"] = role.UserName
  14073. data["fixmedins_code"] = miConfig.Code
  14074. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14075. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14076. if miConfig.MdtrtareaAdmvs == "421300" {
  14077. client := &http.Client{}
  14078. bytesData, _ := json.Marshal(data)
  14079. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  14080. resp, _ := client.Do(req)
  14081. defer resp.Body.Close()
  14082. body, ioErr := ioutil.ReadAll(resp.Body)
  14083. if ioErr != nil {
  14084. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14086. return
  14087. }
  14088. var respJSON map[string]interface{}
  14089. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14092. return
  14093. }
  14094. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14095. userJSONBytes, _ := json.Marshal(respJSON)
  14096. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14097. utils.ErrorLog("解析失败:%v", err)
  14098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14099. return
  14100. }
  14101. }
  14102. if res.Infcode == 0 {
  14103. c.ServeSuccessJSON(map[string]interface{}{
  14104. "msg": "发起成功",
  14105. })
  14106. } else {
  14107. c.ServeSuccessJSON(map[string]interface{}{
  14108. "code": -10,
  14109. "msg": res.ErrMsg,
  14110. })
  14111. }
  14112. }
  14113. }
  14114. func (c *HisApiController) Post3501() {
  14115. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14116. data := make(map[string]interface{})
  14117. var struct3501s []models.Struct3501
  14118. var struct3501 models.Struct3501
  14119. struct3501.OrgName = miConfig.OrgName
  14120. struct3501.AccessKey = miConfig.AccessKey
  14121. struct3501.RequestUrl = miConfig.Url
  14122. struct3501.SecretKey = miConfig.SecretKey
  14123. struct3501.ManuDate = "2022-08-17"
  14124. struct3501.FixmedinsBchno = ""
  14125. struct3501.ManuLotnum = ""
  14126. struct3501.RxFlag = "0"
  14127. struct3501.ExpyEnd = "2022-08-17"
  14128. struct3501.Invdate = "2022-08-17"
  14129. struct3501.InvCnt = "20.25"
  14130. struct3501.Memo = ""
  14131. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14132. struct3501.FixmedinsHilistId = miConfig.Code
  14133. struct3501.FixmedinsHilistName = miConfig.OrgName
  14134. struct3501s = append(struct3501s, struct3501)
  14135. data["struct_3501s"] = struct3501s
  14136. client := &http.Client{}
  14137. bytesData, _ := json.Marshal(data)
  14138. var req *http.Request
  14139. if miConfig.MdtrtareaAdmvs == "320921" {
  14140. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14141. } else {
  14142. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14143. }
  14144. resp, _ := client.Do(req)
  14145. defer resp.Body.Close()
  14146. body, ioErr := ioutil.ReadAll(resp.Body)
  14147. if ioErr != nil {
  14148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14150. return
  14151. }
  14152. var respJSON map[string]interface{}
  14153. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14156. return
  14157. }
  14158. var res ResultSix
  14159. var resSix10265 ResultSix10265 //1101结果
  14160. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14161. result, _ := json.Marshal(respJSON)
  14162. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14163. utils.ErrorLog("解析失败:%v", err)
  14164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14165. return
  14166. }
  14167. res.InfRefmsgid = resSix10265.InfRefmsgid
  14168. res.Output = resSix10265.Output
  14169. res.ErrMsg = resSix10265.ErrMsg
  14170. res.Cainfo = resSix10265.Cainfo
  14171. res.WarnMsg = resSix10265.WarnMsg
  14172. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14173. res.Infcode = infocode
  14174. if infocode == 0 {
  14175. c.ServeSuccessJSON(map[string]interface{}{
  14176. "msg": "上传成功",
  14177. })
  14178. return
  14179. } else {
  14180. c.ServeSuccessJSON(map[string]interface{}{
  14181. "failed_code": -10,
  14182. "msg": res.ErrMsg,
  14183. })
  14184. return
  14185. }
  14186. }
  14187. func (c *HisApiController) Post3502() {
  14188. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14189. data := make(map[string]interface{})
  14190. var struct3502s []models.Struct3502
  14191. var struct3502 models.Struct3502
  14192. struct3502.OrgName = miConfig.OrgName
  14193. struct3502.AccessKey = miConfig.AccessKey
  14194. struct3502.RequestUrl = miConfig.Url
  14195. struct3502.SecretKey = miConfig.SecretKey
  14196. struct3502.ManuDate = "2022-08-15"
  14197. struct3502.FixmedinsBchno = ""
  14198. struct3502.ManuLotnum = ""
  14199. struct3502.RxFlag = "0"
  14200. struct3502.ExpyEnd = "2022-08-15"
  14201. struct3502.Invdate = "2022-08-15"
  14202. struct3502.InvCnt = "20.25"
  14203. struct3502.Memo = ""
  14204. struct3502.MedListCodg = "XB01ABD056B002020200517"
  14205. struct3502.FixmedinsHilistId = miConfig.Code
  14206. struct3502.FixmedinsHilistName = miConfig.OrgName
  14207. struct3502s = append(struct3502s, struct3502)
  14208. data["struct_3502s"] = struct3502s
  14209. client := &http.Client{}
  14210. bytesData, _ := json.Marshal(data)
  14211. var req *http.Request
  14212. if miConfig.MdtrtareaAdmvs == "320921" {
  14213. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14214. } else {
  14215. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14216. }
  14217. resp, _ := client.Do(req)
  14218. defer resp.Body.Close()
  14219. body, ioErr := ioutil.ReadAll(resp.Body)
  14220. if ioErr != nil {
  14221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14223. return
  14224. }
  14225. var respJSON map[string]interface{}
  14226. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14229. return
  14230. }
  14231. var res ResultSix
  14232. var resSix10265 ResultSix10265 //1101结果
  14233. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14234. result, _ := json.Marshal(respJSON)
  14235. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14236. utils.ErrorLog("解析失败:%v", err)
  14237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14238. return
  14239. }
  14240. res.InfRefmsgid = resSix10265.InfRefmsgid
  14241. res.Output = resSix10265.Output
  14242. res.ErrMsg = resSix10265.ErrMsg
  14243. res.Cainfo = resSix10265.Cainfo
  14244. res.WarnMsg = resSix10265.WarnMsg
  14245. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14246. res.Infcode = infocode
  14247. if infocode == 0 {
  14248. c.ServeSuccessJSON(map[string]interface{}{
  14249. "msg": "上传成功",
  14250. })
  14251. return
  14252. } else {
  14253. c.ServeSuccessJSON(map[string]interface{}{
  14254. "failed_code": -10,
  14255. "msg": res.ErrMsg,
  14256. })
  14257. return
  14258. }
  14259. }
  14260. func (c *HisApiController) Post3503() {
  14261. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14262. data := make(map[string]interface{})
  14263. var struct3501s []models.Struct3501
  14264. var struct3501 models.Struct3501
  14265. struct3501.OrgName = miConfig.OrgName
  14266. struct3501.AccessKey = miConfig.AccessKey
  14267. struct3501.RequestUrl = miConfig.Url
  14268. struct3501.SecretKey = miConfig.SecretKey
  14269. struct3501.ManuDate = "2022-08-15"
  14270. struct3501.FixmedinsBchno = ""
  14271. struct3501.ManuLotnum = ""
  14272. struct3501.RxFlag = "0"
  14273. struct3501.ExpyEnd = "2022-08-15"
  14274. struct3501.Invdate = "2022-08-15"
  14275. struct3501.InvCnt = "20.25"
  14276. struct3501.Memo = ""
  14277. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14278. struct3501.FixmedinsHilistId = miConfig.Code
  14279. struct3501.FixmedinsHilistName = miConfig.OrgName
  14280. struct3501s = append(struct3501s, struct3501)
  14281. data["struct_3501s"] = struct3501s
  14282. client := &http.Client{}
  14283. bytesData, _ := json.Marshal(data)
  14284. var req *http.Request
  14285. if miConfig.MdtrtareaAdmvs == "320921" {
  14286. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14287. } else {
  14288. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14289. }
  14290. resp, _ := client.Do(req)
  14291. defer resp.Body.Close()
  14292. body, ioErr := ioutil.ReadAll(resp.Body)
  14293. if ioErr != nil {
  14294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14296. return
  14297. }
  14298. var respJSON map[string]interface{}
  14299. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14302. return
  14303. }
  14304. var res ResultSix
  14305. var resSix10265 ResultSix10265 //1101结果
  14306. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14307. result, _ := json.Marshal(respJSON)
  14308. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14309. utils.ErrorLog("解析失败:%v", err)
  14310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14311. return
  14312. }
  14313. res.InfRefmsgid = resSix10265.InfRefmsgid
  14314. res.Output = resSix10265.Output
  14315. res.ErrMsg = resSix10265.ErrMsg
  14316. res.Cainfo = resSix10265.Cainfo
  14317. res.WarnMsg = resSix10265.WarnMsg
  14318. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14319. res.Infcode = infocode
  14320. if infocode == 0 {
  14321. c.ServeSuccessJSON(map[string]interface{}{
  14322. "msg": "上传成功",
  14323. })
  14324. return
  14325. } else {
  14326. c.ServeSuccessJSON(map[string]interface{}{
  14327. "failed_code": -10,
  14328. "msg": res.ErrMsg,
  14329. })
  14330. return
  14331. }
  14332. }
  14333. func (c *HisApiController) Post3504() {
  14334. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14335. data := make(map[string]interface{})
  14336. var struct3501s []models.Struct3501
  14337. var struct3501 models.Struct3501
  14338. struct3501.OrgName = miConfig.OrgName
  14339. struct3501.AccessKey = miConfig.AccessKey
  14340. struct3501.RequestUrl = miConfig.Url
  14341. struct3501.SecretKey = miConfig.SecretKey
  14342. struct3501.ManuDate = "2022-08-15"
  14343. struct3501.FixmedinsBchno = ""
  14344. struct3501.ManuLotnum = ""
  14345. struct3501.RxFlag = "0"
  14346. struct3501.ExpyEnd = "2022-08-15"
  14347. struct3501.Invdate = "2022-08-15"
  14348. struct3501.InvCnt = "20.25"
  14349. struct3501.Memo = ""
  14350. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14351. struct3501.FixmedinsHilistId = miConfig.Code
  14352. struct3501.FixmedinsHilistName = miConfig.OrgName
  14353. struct3501s = append(struct3501s, struct3501)
  14354. data["struct_3501s"] = struct3501s
  14355. client := &http.Client{}
  14356. bytesData, _ := json.Marshal(data)
  14357. var req *http.Request
  14358. if miConfig.MdtrtareaAdmvs == "320921" {
  14359. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14360. } else {
  14361. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14362. }
  14363. resp, _ := client.Do(req)
  14364. defer resp.Body.Close()
  14365. body, ioErr := ioutil.ReadAll(resp.Body)
  14366. if ioErr != nil {
  14367. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14369. return
  14370. }
  14371. var respJSON map[string]interface{}
  14372. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14375. return
  14376. }
  14377. var res ResultSix
  14378. var resSix10265 ResultSix10265 //1101结果
  14379. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14380. result, _ := json.Marshal(respJSON)
  14381. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14382. utils.ErrorLog("解析失败:%v", err)
  14383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14384. return
  14385. }
  14386. res.InfRefmsgid = resSix10265.InfRefmsgid
  14387. res.Output = resSix10265.Output
  14388. res.ErrMsg = resSix10265.ErrMsg
  14389. res.Cainfo = resSix10265.Cainfo
  14390. res.WarnMsg = resSix10265.WarnMsg
  14391. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14392. res.Infcode = infocode
  14393. if infocode == 0 {
  14394. c.ServeSuccessJSON(map[string]interface{}{
  14395. "msg": "上传成功",
  14396. })
  14397. return
  14398. } else {
  14399. c.ServeSuccessJSON(map[string]interface{}{
  14400. "failed_code": -10,
  14401. "msg": res.ErrMsg,
  14402. })
  14403. return
  14404. }
  14405. }
  14406. func (c *HisApiController) Post3505() {
  14407. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14408. data := make(map[string]interface{})
  14409. var struct3501s []models.Struct3501
  14410. var struct3501 models.Struct3501
  14411. struct3501.OrgName = miConfig.OrgName
  14412. struct3501.AccessKey = miConfig.AccessKey
  14413. struct3501.RequestUrl = miConfig.Url
  14414. struct3501.SecretKey = miConfig.SecretKey
  14415. struct3501.ManuDate = "2022-08-15"
  14416. struct3501.FixmedinsBchno = ""
  14417. struct3501.ManuLotnum = ""
  14418. struct3501.RxFlag = "0"
  14419. struct3501.ExpyEnd = "2022-08-15"
  14420. struct3501.Invdate = "2022-08-15"
  14421. struct3501.InvCnt = "20.25"
  14422. struct3501.Memo = ""
  14423. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14424. struct3501.FixmedinsHilistId = miConfig.Code
  14425. struct3501.FixmedinsHilistName = miConfig.OrgName
  14426. struct3501s = append(struct3501s, struct3501)
  14427. data["struct_3501s"] = struct3501s
  14428. client := &http.Client{}
  14429. bytesData, _ := json.Marshal(data)
  14430. var req *http.Request
  14431. if miConfig.MdtrtareaAdmvs == "320921" {
  14432. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14433. } else {
  14434. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14435. }
  14436. resp, _ := client.Do(req)
  14437. defer resp.Body.Close()
  14438. body, ioErr := ioutil.ReadAll(resp.Body)
  14439. if ioErr != nil {
  14440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14442. return
  14443. }
  14444. var respJSON map[string]interface{}
  14445. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14448. return
  14449. }
  14450. var res ResultSix
  14451. var resSix10265 ResultSix10265 //1101结果
  14452. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14453. result, _ := json.Marshal(respJSON)
  14454. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14455. utils.ErrorLog("解析失败:%v", err)
  14456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14457. return
  14458. }
  14459. res.InfRefmsgid = resSix10265.InfRefmsgid
  14460. res.Output = resSix10265.Output
  14461. res.ErrMsg = resSix10265.ErrMsg
  14462. res.Cainfo = resSix10265.Cainfo
  14463. res.WarnMsg = resSix10265.WarnMsg
  14464. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14465. res.Infcode = infocode
  14466. if infocode == 0 {
  14467. c.ServeSuccessJSON(map[string]interface{}{
  14468. "msg": "上传成功",
  14469. })
  14470. return
  14471. } else {
  14472. c.ServeSuccessJSON(map[string]interface{}{
  14473. "failed_code": -10,
  14474. "msg": res.ErrMsg,
  14475. })
  14476. return
  14477. }
  14478. }
  14479. func (c *HisApiController) Post3506() {
  14480. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14481. data := make(map[string]interface{})
  14482. var struct3501s []models.Struct3501
  14483. var struct3501 models.Struct3501
  14484. struct3501.OrgName = miConfig.OrgName
  14485. struct3501.AccessKey = miConfig.AccessKey
  14486. struct3501.RequestUrl = miConfig.Url
  14487. struct3501.SecretKey = miConfig.SecretKey
  14488. struct3501.ManuDate = "2022-08-15"
  14489. struct3501.FixmedinsBchno = ""
  14490. struct3501.ManuLotnum = ""
  14491. struct3501.RxFlag = "0"
  14492. struct3501.ExpyEnd = "2022-08-15"
  14493. struct3501.Invdate = "2022-08-15"
  14494. struct3501.InvCnt = "20.25"
  14495. struct3501.Memo = ""
  14496. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14497. struct3501.FixmedinsHilistId = miConfig.Code
  14498. struct3501.FixmedinsHilistName = miConfig.OrgName
  14499. struct3501s = append(struct3501s, struct3501)
  14500. data["struct_3501s"] = struct3501s
  14501. client := &http.Client{}
  14502. bytesData, _ := json.Marshal(data)
  14503. var req *http.Request
  14504. if miConfig.MdtrtareaAdmvs == "320921" {
  14505. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14506. } else {
  14507. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14508. }
  14509. resp, _ := client.Do(req)
  14510. defer resp.Body.Close()
  14511. body, ioErr := ioutil.ReadAll(resp.Body)
  14512. if ioErr != nil {
  14513. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14515. return
  14516. }
  14517. var respJSON map[string]interface{}
  14518. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14521. return
  14522. }
  14523. var res ResultSix
  14524. var resSix10265 ResultSix10265 //1101结果
  14525. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14526. result, _ := json.Marshal(respJSON)
  14527. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14528. utils.ErrorLog("解析失败:%v", err)
  14529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14530. return
  14531. }
  14532. res.InfRefmsgid = resSix10265.InfRefmsgid
  14533. res.Output = resSix10265.Output
  14534. res.ErrMsg = resSix10265.ErrMsg
  14535. res.Cainfo = resSix10265.Cainfo
  14536. res.WarnMsg = resSix10265.WarnMsg
  14537. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14538. res.Infcode = infocode
  14539. if infocode == 0 {
  14540. c.ServeSuccessJSON(map[string]interface{}{
  14541. "msg": "上传成功",
  14542. })
  14543. return
  14544. } else {
  14545. c.ServeSuccessJSON(map[string]interface{}{
  14546. "failed_code": -10,
  14547. "msg": res.ErrMsg,
  14548. })
  14549. return
  14550. }
  14551. }
  14552. func (c *HisApiController) Post3507() {
  14553. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14554. data := make(map[string]interface{})
  14555. var struct3501s []models.Struct3501
  14556. var struct3501 models.Struct3501
  14557. struct3501.OrgName = miConfig.OrgName
  14558. struct3501.AccessKey = miConfig.AccessKey
  14559. struct3501.RequestUrl = miConfig.Url
  14560. struct3501.SecretKey = miConfig.SecretKey
  14561. struct3501.ManuDate = "2022-08-15"
  14562. struct3501.FixmedinsBchno = ""
  14563. struct3501.ManuLotnum = ""
  14564. struct3501.RxFlag = "0"
  14565. struct3501.ExpyEnd = "2022-08-15"
  14566. struct3501.Invdate = "2022-08-15"
  14567. struct3501.InvCnt = "20.25"
  14568. struct3501.Memo = ""
  14569. struct3501.MedListCodg = "XB01ABD056B002020200517"
  14570. struct3501.FixmedinsHilistId = miConfig.Code
  14571. struct3501.FixmedinsHilistName = miConfig.OrgName
  14572. struct3501s = append(struct3501s, struct3501)
  14573. data["struct_3501s"] = struct3501s
  14574. client := &http.Client{}
  14575. bytesData, _ := json.Marshal(data)
  14576. var req *http.Request
  14577. if miConfig.MdtrtareaAdmvs == "320921" {
  14578. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14579. } else {
  14580. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  14581. }
  14582. resp, _ := client.Do(req)
  14583. defer resp.Body.Close()
  14584. body, ioErr := ioutil.ReadAll(resp.Body)
  14585. if ioErr != nil {
  14586. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14588. return
  14589. }
  14590. var respJSON map[string]interface{}
  14591. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14594. return
  14595. }
  14596. var res ResultSix
  14597. var resSix10265 ResultSix10265 //1101结果
  14598. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14599. result, _ := json.Marshal(respJSON)
  14600. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  14601. utils.ErrorLog("解析失败:%v", err)
  14602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14603. return
  14604. }
  14605. res.InfRefmsgid = resSix10265.InfRefmsgid
  14606. res.Output = resSix10265.Output
  14607. res.ErrMsg = resSix10265.ErrMsg
  14608. res.Cainfo = resSix10265.Cainfo
  14609. res.WarnMsg = resSix10265.WarnMsg
  14610. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  14611. res.Infcode = infocode
  14612. if infocode == 0 {
  14613. c.ServeSuccessJSON(map[string]interface{}{
  14614. "msg": "上传成功",
  14615. })
  14616. return
  14617. } else {
  14618. c.ServeSuccessJSON(map[string]interface{}{
  14619. "failed_code": -10,
  14620. "msg": res.ErrMsg,
  14621. })
  14622. return
  14623. }
  14624. }