his_api_controller.go 403KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972
  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. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. }
  74. func (c *HisApiController) Check() {
  75. psn_no := c.GetString("psn_no")
  76. in := c.GetString("in")
  77. mt := c.GetString("mt")
  78. baseParams := models.BaseParams{
  79. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  80. FixmedinsCode: "H15049901371",
  81. InsuplcAdmdvs: "150499",
  82. MdtrtareaAdmvs: "150499",
  83. OrgName: "赤峰费森血液透析中心",
  84. Doctor: "1111",
  85. }
  86. service.Gdyb2001(baseParams, psn_no, in, mt)
  87. }
  88. func (c *HisApiController) GetPsnNcdsInfo() {
  89. admin_user_id, _ := c.GetInt64("admin_user_id")
  90. patient_id, _ := c.GetInt64("patient_id")
  91. id, _ := c.GetInt64("id")
  92. adminUser := c.GetAdminUserInfo()
  93. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  94. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  95. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  96. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  97. psn_record, _ := service.GetPsnNCDSRecordById(id)
  98. //
  99. //if psn_record.ID == 0 {
  100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  101. // return
  102. //}
  103. var res Result5301
  104. var res10265 Result5301For10265
  105. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  106. psn_info, _ := service.GetPsnByPatientId(patient_id)
  107. var api string
  108. if miConfig.MdtrtareaAdmvs == "320921" {
  109. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  110. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  111. } else {
  112. 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 +
  113. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  114. }
  115. resp, requestErr := http.Get(api)
  116. if requestErr != nil {
  117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  118. return
  119. }
  120. body, ioErr := ioutil.ReadAll(resp.Body)
  121. if ioErr != nil {
  122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  124. return
  125. }
  126. var respJSON map[string]interface{}
  127. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  130. return
  131. }
  132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  133. result, _ := json.Marshal(respJSON)
  134. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  135. utils.ErrorLog("解析失败:%v", err)
  136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  137. return
  138. }
  139. res.ErrMsg = res10265.ErrMsg
  140. res.Output = res10265.Output
  141. res.InfRefmsgid = res10265.InfRefmsgid
  142. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  143. res.Infcode = infocode
  144. } else {
  145. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  146. var dat map[string]interface{}
  147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  148. fmt.Println(dat)
  149. } else {
  150. fmt.Println(err)
  151. }
  152. userJSONBytes, _ := json.Marshal(dat)
  153. if miConfig.Code == "H15049901371" {
  154. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  155. utils.ErrorLog("解析失败:%v", err)
  156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  157. return
  158. }
  159. res.InfRefmsgid = res10265.InfRefmsgid
  160. res.Output = res10265.Output
  161. res.ErrMsg = res10265.ErrMsg
  162. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  163. res.Infcode = infocode
  164. } else {
  165. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  166. utils.ErrorLog("解析失败:%v", err)
  167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  168. return
  169. }
  170. }
  171. }
  172. if res.Infcode == 0 {
  173. c.ServeSuccessJSON(map[string]interface{}{
  174. "result": res.Output.Result,
  175. })
  176. }
  177. }
  178. func (c *HisApiController) CheckInsutype() {
  179. his_patient_id, _ := c.GetInt64("his_patient_id")
  180. admin_user_id, _ := c.GetInt64("admin_user_id")
  181. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  182. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  183. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  184. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  185. var dat map[string]interface{}
  186. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  187. fmt.Println(dat)
  188. } else {
  189. fmt.Println(err)
  190. }
  191. userJSONBytes, _ := json.Marshal(dat)
  192. var res Result90100
  193. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  194. utils.ErrorLog("解析失败:%v", err)
  195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  196. return
  197. }
  198. if res.Infcode != 0 {
  199. c.ServeSuccessJSON(map[string]interface{}{
  200. "failed_code": -10,
  201. "msg": res.ErrMsg,
  202. })
  203. return
  204. } else {
  205. fmt.Println(res)
  206. }
  207. }
  208. func (c *HisApiController) CheckCardPWD() {
  209. card_pwd := c.GetString("card_pwd")
  210. his_patient_id, _ := c.GetInt64("his_patient_id")
  211. admin_user_id, _ := c.GetInt64("admin_user_id")
  212. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  213. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  214. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  215. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  216. var dat map[string]interface{}
  217. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  218. fmt.Println(dat)
  219. } else {
  220. fmt.Println(err)
  221. }
  222. userJSONBytes, _ := json.Marshal(dat)
  223. var res Result90991
  224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  225. utils.ErrorLog("解析失败:%v", err)
  226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  227. return
  228. }
  229. if res.Infcode != 0 {
  230. c.ServeSuccessJSON(map[string]interface{}{
  231. "failed_code": -10,
  232. "msg": res.ErrMsg,
  233. })
  234. return
  235. } else {
  236. if res.Output.Result.CheckStat == "0" {
  237. var msg string
  238. switch res.Output.Result.CardStat {
  239. case "00":
  240. msg = "未激活"
  241. break
  242. case "10":
  243. msg = "激活"
  244. break
  245. case "20":
  246. msg = "窗口挂失"
  247. break
  248. case "21":
  249. msg = "电话挂失"
  250. break
  251. case "22":
  252. msg = "单位网上申报挂失"
  253. break
  254. case "23":
  255. msg = "保健办挂失"
  256. break
  257. case "24":
  258. msg = "个人网上挂失"
  259. break
  260. case "25":
  261. msg = "网上服务大厅挂失"
  262. break
  263. case "30":
  264. msg = "注销"
  265. break
  266. case "40":
  267. msg = "回收"
  268. break
  269. case "99":
  270. msg = "制卡中(无效卡)"
  271. break
  272. }
  273. c.ServeSuccessJSON(map[string]interface{}{
  274. "failed_code": -10,
  275. "msg": msg,
  276. })
  277. return
  278. } else {
  279. c.ServeSuccessJSON(map[string]interface{}{
  280. "msg": "校验成功",
  281. })
  282. return
  283. }
  284. }
  285. }
  286. func (c *HisApiController) ReadCard() {
  287. id_card_type, _ := c.GetInt64("id_card_type")
  288. admin_user_id, _ := c.GetInt64("admin_user_id")
  289. certificates, _ := c.GetInt64("certificates")
  290. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  291. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  292. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  293. switch id_card_type {
  294. case 1:
  295. if miConfig.MdtrtareaAdmvs == "421300" {
  296. var res ResultTwo
  297. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  298. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  299. "&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)
  300. resp, requestErr := http.Get(api)
  301. if requestErr != nil {
  302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  303. return
  304. }
  305. body, ioErr := ioutil.ReadAll(resp.Body)
  306. if ioErr != nil {
  307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. var respJSON map[string]interface{}
  312. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  315. return
  316. }
  317. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  318. result, _ := json.Marshal(respJSON)
  319. fmt.Println("log")
  320. fmt.Println(string(result))
  321. if err := json.Unmarshal([]byte(result), &res); err != nil {
  322. utils.ErrorLog("解析失败:%v", err)
  323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  324. return
  325. }
  326. if res.Infcode == 0 {
  327. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  328. if err == gorm.ErrRecordNotFound {
  329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  330. return
  331. } else if err != nil {
  332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  333. return
  334. } else {
  335. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  336. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  337. infoStr := string(Iinfos)
  338. idetinfoStr := string(Idetinfos)
  339. psn := &models.HisPsn{
  340. PsnNo: res.Output.Baseinfo.PsnNo,
  341. Age: res.Output.Baseinfo.Age,
  342. PatientId: patient.ID,
  343. Certno: res.Output.Baseinfo.Certno,
  344. Brdy: res.Output.Baseinfo.Brdy,
  345. Gend: res.Output.Baseinfo.Gend,
  346. Naty: res.Output.Baseinfo.Naty,
  347. PsnCertType: res.Output.Baseinfo.PsnCertType,
  348. PsnName: res.Output.Baseinfo.PsnName,
  349. Idetinfo: idetinfoStr,
  350. Insuinfo: infoStr,
  351. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  352. }
  353. service.CreateHisPsn(psn)
  354. c.ServeSuccessJSON(map[string]interface{}{
  355. "patient": patient,
  356. "number": res.Output.Baseinfo.Certno,
  357. })
  358. }
  359. } else {
  360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  361. return
  362. }
  363. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  364. var api string
  365. if miConfig.MdtrtareaAdmvs == "320921" {
  366. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  367. "&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
  368. fmt.Println(api)
  369. } else {
  370. 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 +
  371. "&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)
  372. }
  373. resp, requestErr := http.Get(api)
  374. if requestErr != nil {
  375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  376. return
  377. }
  378. body, ioErr := ioutil.ReadAll(resp.Body)
  379. if ioErr != nil {
  380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  382. return
  383. }
  384. var respJSON map[string]interface{}
  385. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  388. return
  389. }
  390. var status string
  391. status = respJSON["data"].(map[string]interface{})["status"].(string)
  392. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  393. //console.log()
  394. fmt.Println("type===")
  395. fmt.Println(card_type)
  396. var token string
  397. var res ResultTwo //1101结果
  398. var res10265 ResultTwo10265 //1101结果
  399. var card_info string //卡信息
  400. var busi_card_info string
  401. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  402. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  403. if status == "0" { //读卡成功
  404. if card_type == "1" {
  405. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  406. result, _ := json.Marshal(respJSON)
  407. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  408. utils.ErrorLog("解析失败:%v", err)
  409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  410. return
  411. }
  412. res.ErrMsg = res10265.ErrMsg
  413. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  414. res.Infcode = infocode
  415. res.Output = res10265.Output
  416. res.InfRefmsgid = res10265.InfRefmsgid
  417. } else {
  418. //var card_info string //卡信息
  419. //var busi_card_info string
  420. token = respJSON["data"].(map[string]interface{})["token"].(string)
  421. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  422. //fmt.Println(card_info)
  423. //fmt.Println(busi_card_info)
  424. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  425. result, _ := json.Marshal(respJSON)
  426. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  427. utils.ErrorLog("解析失败:%v", err)
  428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  429. return
  430. }
  431. res.ErrMsg = res10265.ErrMsg
  432. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  433. res.Infcode = infocode
  434. res.Output = res10265.Output
  435. res.InfRefmsgid = res10265.InfRefmsgid
  436. }
  437. if res.Infcode == 0 {
  438. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  439. if err == gorm.ErrRecordNotFound {
  440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  441. return
  442. } else if err != nil {
  443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  444. return
  445. } else {
  446. if card_type == "1" {
  447. bas := strings.Split(card_info, "|")
  448. basNumber := bas[2]
  449. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  450. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  451. infoStr := string(Iinfos)
  452. idetinfoStr := string(Idetinfos)
  453. psn := &models.HisPsn{
  454. PsnNo: res.Output.Baseinfo.PsnNo,
  455. Age: res.Output.Baseinfo.Age,
  456. PatientId: patient.ID,
  457. Certno: res.Output.Baseinfo.Certno,
  458. Brdy: res.Output.Baseinfo.Brdy,
  459. Gend: res.Output.Baseinfo.Gend,
  460. Naty: res.Output.Baseinfo.Naty,
  461. PsnCertType: res.Output.Baseinfo.PsnCertType,
  462. PsnName: res.Output.Baseinfo.PsnName,
  463. Idetinfo: idetinfoStr,
  464. Insuinfo: infoStr,
  465. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  466. CardInfo: card_info,
  467. VerifyNumber: busi_card_info,
  468. }
  469. service.CreateHisPsn(psn)
  470. c.ServeSuccessJSON(map[string]interface{}{
  471. "patient": patient,
  472. "number": basNumber,
  473. })
  474. } else {
  475. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  476. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  477. infoStr := string(Iinfos)
  478. idetinfoStr := string(Idetinfos)
  479. psn := &models.HisPsn{
  480. PsnNo: res.Output.Baseinfo.PsnNo,
  481. Age: res.Output.Baseinfo.Age,
  482. PatientId: patient.ID,
  483. Certno: res.Output.Baseinfo.Certno,
  484. Brdy: res.Output.Baseinfo.Brdy,
  485. Gend: res.Output.Baseinfo.Gend,
  486. Naty: res.Output.Baseinfo.Naty,
  487. PsnCertType: res.Output.Baseinfo.PsnCertType,
  488. PsnName: res.Output.Baseinfo.PsnName,
  489. Idetinfo: idetinfoStr,
  490. Insuinfo: infoStr,
  491. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  492. CardInfo: card_info,
  493. VerifyNumber: token,
  494. }
  495. service.CreateHisPsn(psn)
  496. c.ServeSuccessJSON(map[string]interface{}{
  497. "patient": patient,
  498. "number": token,
  499. })
  500. }
  501. }
  502. } else {
  503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  504. return
  505. }
  506. } else { //读卡失败
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  508. return
  509. }
  510. } else {
  511. if initFlag == 0 {
  512. c.TestGetBasBaseInit()
  513. }
  514. basStr := c.GetBasBaseInfo()
  515. if len(basStr) == 0 {
  516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  517. return
  518. }
  519. fmt.Println(basStr)
  520. bas := strings.Split(basStr, "|")
  521. basNumber := bas[1]
  522. fmt.Println(basNumber)
  523. card_sn := bas[3]
  524. fmt.Println(card_sn)
  525. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  526. var dat map[string]interface{}
  527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  528. fmt.Println(dat)
  529. } else {
  530. fmt.Println(err)
  531. }
  532. userJSONBytes, _ := json.Marshal(dat)
  533. var res ResultTwo
  534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  535. utils.ErrorLog("解析失败:%v", err)
  536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  537. return
  538. }
  539. if res.Infcode == 0 {
  540. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  541. if err == gorm.ErrRecordNotFound {
  542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  543. return
  544. } else if err != nil {
  545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  546. return
  547. } else {
  548. c.ServeSuccessJSON(map[string]interface{}{
  549. "patient": patient,
  550. "number": basNumber,
  551. })
  552. }
  553. } else {
  554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  555. return
  556. }
  557. break
  558. }
  559. case 2:
  560. SFZStr := c.GetSFZBaseInfo()
  561. id_card_str := strings.Split(SFZStr, "^")
  562. id_card_number := id_card_str[0]
  563. card_sn := ""
  564. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  565. var dat map[string]interface{}
  566. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  567. fmt.Println(dat)
  568. } else {
  569. fmt.Println(err)
  570. }
  571. userJSONBytes, _ := json.Marshal(dat)
  572. var res ResultTwo
  573. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  574. utils.ErrorLog("解析失败:%v", err)
  575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  576. return
  577. }
  578. if res.Infcode == 0 {
  579. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  580. if err == gorm.ErrRecordNotFound {
  581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  582. return
  583. } else if err != nil {
  584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  585. return
  586. } else {
  587. c.ServeSuccessJSON(map[string]interface{}{
  588. "patient": patient,
  589. "number": id_card_number,
  590. })
  591. }
  592. } else {
  593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  594. return
  595. }
  596. break
  597. case 3:
  598. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  599. var api string
  600. if miConfig.MdtrtareaAdmvs == "320921" {
  601. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  602. "&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
  603. fmt.Println(api)
  604. } else {
  605. 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 +
  606. "&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)
  607. }
  608. resp, requestErr := http.Get(api)
  609. if requestErr != nil {
  610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  611. return
  612. }
  613. body, ioErr := ioutil.ReadAll(resp.Body)
  614. if ioErr != nil {
  615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  617. return
  618. }
  619. var respJSON map[string]interface{}
  620. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  623. return
  624. }
  625. var status string
  626. status = respJSON["data"].(map[string]interface{})["status"].(string)
  627. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  628. var token string
  629. var res ResultTwo //1101结果
  630. var res10265 ResultTwo10265 //1101结果
  631. var card_info string //卡信息
  632. var busi_card_info string
  633. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  634. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  635. if status == "0" { //读卡成功
  636. if card_type == "1" {
  637. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  638. result, _ := json.Marshal(respJSON)
  639. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  640. utils.ErrorLog("解析失败:%v", err)
  641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  642. return
  643. }
  644. res.ErrMsg = res10265.ErrMsg
  645. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  646. res.Infcode = infocode
  647. res.Output = res10265.Output
  648. res.InfRefmsgid = res10265.InfRefmsgid
  649. } else {
  650. //var card_info string //卡信息
  651. //var busi_card_info string
  652. token = respJSON["data"].(map[string]interface{})["token"].(string)
  653. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  654. //fmt.Println(card_info)
  655. //fmt.Println(busi_card_info)
  656. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  657. result, _ := json.Marshal(respJSON)
  658. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  659. utils.ErrorLog("解析失败:%v", err)
  660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  661. return
  662. }
  663. res.ErrMsg = res10265.ErrMsg
  664. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  665. res.Infcode = infocode
  666. res.Output = res10265.Output
  667. res.InfRefmsgid = res10265.InfRefmsgid
  668. }
  669. if res.Infcode == 0 {
  670. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  671. if err == gorm.ErrRecordNotFound {
  672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  673. return
  674. } else if err != nil {
  675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  676. return
  677. } else {
  678. if card_type == "1" {
  679. bas := strings.Split(card_info, "|")
  680. basNumber := bas[2]
  681. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  682. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  683. infoStr := string(Iinfos)
  684. idetinfoStr := string(Idetinfos)
  685. psn := &models.HisPsn{
  686. PsnNo: res.Output.Baseinfo.PsnNo,
  687. Age: res.Output.Baseinfo.Age,
  688. PatientId: patient.ID,
  689. Certno: res.Output.Baseinfo.Certno,
  690. Brdy: res.Output.Baseinfo.Brdy,
  691. Gend: res.Output.Baseinfo.Gend,
  692. Naty: res.Output.Baseinfo.Naty,
  693. PsnCertType: res.Output.Baseinfo.PsnCertType,
  694. PsnName: res.Output.Baseinfo.PsnName,
  695. Idetinfo: idetinfoStr,
  696. Insuinfo: infoStr,
  697. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  698. CardInfo: card_info,
  699. VerifyNumber: busi_card_info,
  700. }
  701. service.CreateHisPsn(psn)
  702. c.ServeSuccessJSON(map[string]interface{}{
  703. "patient": patient,
  704. "number": basNumber,
  705. })
  706. } else {
  707. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  708. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  709. infoStr := string(Iinfos)
  710. idetinfoStr := string(Idetinfos)
  711. psn := &models.HisPsn{
  712. PsnNo: res.Output.Baseinfo.PsnNo,
  713. Age: res.Output.Baseinfo.Age,
  714. PatientId: patient.ID,
  715. Certno: res.Output.Baseinfo.Certno,
  716. Brdy: res.Output.Baseinfo.Brdy,
  717. Gend: res.Output.Baseinfo.Gend,
  718. Naty: res.Output.Baseinfo.Naty,
  719. PsnCertType: res.Output.Baseinfo.PsnCertType,
  720. PsnName: res.Output.Baseinfo.PsnName,
  721. Idetinfo: idetinfoStr,
  722. Insuinfo: infoStr,
  723. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  724. CardInfo: card_info,
  725. VerifyNumber: token,
  726. }
  727. service.CreateHisPsn(psn)
  728. c.ServeSuccessJSON(map[string]interface{}{
  729. "patient": patient,
  730. "number": token,
  731. })
  732. }
  733. }
  734. } else {
  735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  736. return
  737. }
  738. } else { //读卡失败
  739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  740. return
  741. }
  742. }
  743. break
  744. case 4:
  745. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  746. var api string
  747. if miConfig.MdtrtareaAdmvs == "320921" {
  748. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  749. "&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
  750. fmt.Println(api)
  751. } else {
  752. 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 +
  753. "&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)
  754. }
  755. resp, requestErr := http.Get(api)
  756. if requestErr != nil {
  757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  758. return
  759. }
  760. body, ioErr := ioutil.ReadAll(resp.Body)
  761. if ioErr != nil {
  762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  764. return
  765. }
  766. var respJSON map[string]interface{}
  767. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  770. return
  771. }
  772. var status string
  773. status = respJSON["data"].(map[string]interface{})["status"].(string)
  774. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  775. var token string
  776. var res ResultTwo //1101结果
  777. var res10265 ResultTwo10265 //1101结果
  778. if status == "0" { //读卡成功
  779. var card_info string //卡信息
  780. var busi_card_info string
  781. token = respJSON["data"].(map[string]interface{})["token"].(string)
  782. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  783. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  784. fmt.Println(card_info)
  785. fmt.Println(busi_card_info)
  786. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  787. result, _ := json.Marshal(respJSON)
  788. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  789. utils.ErrorLog("解析失败:%v", err)
  790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  791. return
  792. }
  793. res.ErrMsg = res10265.ErrMsg
  794. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  795. res.Infcode = infocode
  796. res.Output = res10265.Output
  797. res.InfRefmsgid = res10265.InfRefmsgid
  798. if res.Infcode == 0 {
  799. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  800. if err == gorm.ErrRecordNotFound {
  801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  802. return
  803. } else if err != nil {
  804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  805. return
  806. } else {
  807. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  808. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  809. infoStr := string(Iinfos)
  810. idetinfoStr := string(Idetinfos)
  811. psn := &models.HisPsn{
  812. PsnNo: res.Output.Baseinfo.PsnNo,
  813. Age: res.Output.Baseinfo.Age,
  814. PatientId: patient.ID,
  815. Certno: res.Output.Baseinfo.Certno,
  816. Brdy: res.Output.Baseinfo.Brdy,
  817. Gend: res.Output.Baseinfo.Gend,
  818. Naty: res.Output.Baseinfo.Naty,
  819. PsnCertType: res.Output.Baseinfo.PsnCertType,
  820. PsnName: res.Output.Baseinfo.PsnName,
  821. Idetinfo: idetinfoStr,
  822. Insuinfo: infoStr,
  823. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  824. CardInfo: card_info,
  825. VerifyNumber: token,
  826. }
  827. service.CreateHisPsn(psn)
  828. c.ServeSuccessJSON(map[string]interface{}{
  829. "patient": patient,
  830. "number": token,
  831. })
  832. }
  833. } else {
  834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  835. return
  836. }
  837. } else { //读卡失败
  838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  839. return
  840. }
  841. }
  842. break
  843. }
  844. }
  845. var initFlag int64 = 0
  846. func (c *HisApiController) TestGetBasBaseInit() {
  847. DllDef := syscall.MustLoadDLL("SSCard.dll")
  848. Iinit := DllDef.MustFindProc("Init")
  849. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  850. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  851. if ret != 0 {
  852. fmt.Println("SSCard的报错原因:", err)
  853. fmt.Println("SSCard的运算结果为:", ret)
  854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  855. return
  856. }
  857. result := int(ret)
  858. fmt.Println("SSCard的运算结果为1:", result)
  859. initFlag = 1
  860. return
  861. }
  862. func (c *HisApiController) GetSFZBaseInfo() string {
  863. DllDef := syscall.MustLoadDLL("SSCard.dll")
  864. readCard := DllDef.MustFindProc("ReadSFZ")
  865. if readCard == nil {
  866. fmt.Println("readcard is nil")
  867. readCard = DllDef.MustFindProc("ReadSFZ")
  868. }
  869. str := make([]byte, 256)
  870. str1 := make([]byte, 256)
  871. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  872. fmt.Println(r)
  873. return string(str)
  874. }
  875. func (c *HisApiController) GetBasBaseInfo() string {
  876. DllDef := syscall.MustLoadDLL("SSCard.dll")
  877. readCard := DllDef.MustFindProc("ReadCardBas")
  878. if readCard == nil {
  879. fmt.Println("readcard is nil")
  880. readCard = DllDef.MustFindProc("ReadCardBas")
  881. }
  882. str := make([]byte, 1024)
  883. str1 := make([]byte, 1024)
  884. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  885. fmt.Println(string(str1))
  886. fmt.Println(string(str))
  887. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  888. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  889. if ret2 != 0 {
  890. return ""
  891. }
  892. return string(str)
  893. }
  894. type CustomFundPay struct {
  895. FundPayType string `json:"fund_pay_type"`
  896. FundPayamt float64 `json:"fund_payamt"`
  897. }
  898. func (c *HisApiController) GetSettleList() {
  899. order_id, _ := c.GetInt64("order_id")
  900. admin_user_id, _ := c.GetInt64("admin_user_id")
  901. order, _ := service.GetHisOrderByIDTwo(order_id)
  902. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  903. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  904. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  905. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  906. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  907. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  908. if order.ID == 0 {
  909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  910. return
  911. }
  912. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  913. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  914. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  915. fmt.Println(count)
  916. var zero string
  917. number := count + 1
  918. if number >= 1000 {
  919. zero = "0000" + strconv.FormatInt(number, 10)
  920. } else if number >= 10000 {
  921. zero = "000" + strconv.FormatInt(number, 10)
  922. } else if number >= 100000 {
  923. zero = "00" + strconv.FormatInt(number, 10)
  924. } else if number >= 1000000 {
  925. zero = "0" + strconv.FormatInt(number, 10)
  926. } else {
  927. zero = strconv.FormatInt(number, 10)
  928. }
  929. fmt.Println(zero)
  930. struct4101 := service.Struct4101{
  931. PsnNo: order.PsnNo,
  932. MdtrtId: order.MdtrtId,
  933. SetlId: order.SetlId,
  934. PsnName: order.PsnName,
  935. Gend: order.Gend,
  936. Brdy: his.Brdy,
  937. Age: his.Age,
  938. Naty: order.Naty,
  939. PatnCertType: "01",
  940. Certno: order.Certno,
  941. Prfs: "90",
  942. ConerName: roles[0].UserName,
  943. PatnRlts: "99",
  944. ConerAddr: miConfig.OrgName,
  945. ConerTel: admin.Mobile,
  946. HiType: order.Insutype,
  947. Insuplc: miConfig.InsuplcAdmdvs,
  948. MaindiagFlag: "1",
  949. BillCode: last_order.FaPiaoCode,
  950. BillNo: zero,
  951. BizSn: order.Number,
  952. PsnSelfPay: order.PsnPartAmt,
  953. PsnOwnPay: order.PsnPartAmt,
  954. AcctPay: order.AcctPay,
  955. PsnCashpay: order.PsnCashPay,
  956. HiPaymtd: "1",
  957. Hsorg: miConfig.InsuplcAdmdvs,
  958. HsorgOpter: miConfig.InsuplcAdmdvs,
  959. MedinsFillPsn: curRoles.UserName,
  960. MedinsFillDept: depart.Name,
  961. IptMedType: "2",
  962. }
  963. struct4101.SetlBegnDate = order.SetlTime
  964. struct4101.SetlEndDate = order.SetlTime
  965. time_arr := strings.Split(order.SetlTime, " ")
  966. struct4101.AdmTime = time_arr[0]
  967. struct4101.AdmEndTime = time_arr[0]
  968. var rf []CustomFundPay
  969. json.Unmarshal([]byte(order.SetlDetail), &rf)
  970. var tempFunPays []service.CustomStruct
  971. for _, item := range rf {
  972. var tempFunPay service.CustomStruct
  973. tempFunPay.FundPayamt = item.FundPayamt
  974. tempFunPay.FundPayType = item.FundPayType
  975. tempFunPays = append(tempFunPays, tempFunPay)
  976. }
  977. struct4101.CustomStruct = tempFunPays
  978. var tempDiaginfos []service.DiaginfoStructTwo
  979. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  980. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  981. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  982. var config []*models.HisXtDiagnoseConfig
  983. for _, item := range diagnosis_ids {
  984. id, _ := strconv.ParseInt(item, 10, 64)
  985. diagnosisConfig, _ := service.FindDiagnoseById(id)
  986. config = append(config, &diagnosisConfig)
  987. }
  988. for index, item := range config {
  989. if index == 0 {
  990. var tempDiaginfo service.DiaginfoStructTwo
  991. tempDiaginfo.DiagCode = item.CountryCode
  992. tempDiaginfo.DiagName = item.CountryContentName
  993. tempDiaginfo.DiagType = "1"
  994. tempDiaginfo.MaindiagFlag = "1"
  995. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  996. } else {
  997. var tempDiaginfo service.DiaginfoStructTwo
  998. tempDiaginfo.DiagCode = item.CountryCode
  999. tempDiaginfo.DiagName = item.CountryContentName
  1000. tempDiaginfo.DiagType = "2"
  1001. tempDiaginfo.MaindiagFlag = "0"
  1002. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1003. }
  1004. }
  1005. struct4101.Diseinfo = tempDiaginfos
  1006. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1007. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1008. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1009. tempOpspdiseinfo2.OprnOprtCode = ""
  1010. tempOpspdiseinfo2.OprnOprtName = ""
  1011. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1012. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1013. var iteminfo service.IteminfoStruct
  1014. var bedCostTotal float64 = 0 //床位总费
  1015. var bedCostSelfTotal float64 = 0 //床位自费
  1016. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1017. var operationCostTotal float64 = 0 //手术费
  1018. var operationCostSelfTotal float64 = 0 //手术费
  1019. var operationCostPartSelfTotal float64 = 0 //手术费
  1020. var otherCostTotal float64 = 0 //其他费用
  1021. var otherCostSelfTotal float64 = 0 //其他费用
  1022. var otherCostPartSelfTotal float64 = 0 //其他费用
  1023. var materialCostTotal float64 = 0 //材料费
  1024. var materialCostSelfTotal float64 = 0 //材料费
  1025. var materialCostPartSelfTotal float64 = 0 //材料费
  1026. var westernMedicineCostTotal float64 = 0 //西药费
  1027. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1028. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1029. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1030. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1031. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1032. var checkCostTotal float64 = 0 //检查费
  1033. var checkCostSelfTotal float64 = 0 //检查费
  1034. var checkCostPartSelfTotal float64 = 0 //检查费
  1035. var laboratoryCostTotal float64 = 0 //化验费
  1036. var laboratoryCostSelfTotal float64 = 0 //化验费
  1037. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1038. var treatCostTotal float64 = 0 //治疗费用
  1039. var treatCostSelfTotal float64 = 0 //治疗费用
  1040. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1041. decimal.DivisionPrecision = 2
  1042. var bed_fulamt_ownpay_amt float64 = 0
  1043. var operation_fulamt_ownpay_amt float64 = 0
  1044. var other_fulamt_ownpay_amt float64 = 0
  1045. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1046. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1047. var check_fulamt_ownpay_amt float64 = 0
  1048. var material_fulamt_ownpay_amt float64 = 0
  1049. var laboratory_fulamt_ownpay_amt float64 = 0
  1050. var treat_fulamt_ownpay_amt float64 = 0
  1051. var bed_claa_sunmfee float64 = 0
  1052. var bed_clab_amt float64 = 0
  1053. var bed_other_amt float64 = 0
  1054. var operation_claa_sunmfee float64 = 0
  1055. var operation_clab_amt float64 = 0
  1056. var operation_other_amt float64 = 0
  1057. var other_claa_sunmfee float64 = 0
  1058. var other_clab_amt float64 = 0
  1059. var other_other_amt float64 = 0
  1060. var westernMedicine_claa_sunmfee float64 = 0
  1061. var westernMedicine_clab_amt float64 = 0
  1062. var westernMedicine_other_amt float64 = 0
  1063. var chineseTraditional_claa_sunmfee float64 = 0
  1064. var chineseTraditional_clab_amt float64 = 0
  1065. var chineseTraditional_other_amt float64 = 0
  1066. var check_claa_sunmfee float64 = 0
  1067. var check_clab_amt float64 = 0
  1068. var check_other_amt float64 = 0
  1069. var material_claa_sunmfee float64 = 0
  1070. var material_clab_amt float64 = 0
  1071. var material_other_amt float64 = 0
  1072. var laboratory_claa_sunmfee float64 = 0
  1073. var laboratory_clab_amt float64 = 0
  1074. var laboratory_other_amt float64 = 0
  1075. var treat_claa_sunmfee float64 = 0
  1076. var treat_clab_amt float64 = 0
  1077. var treat_other_amt float64 = 0
  1078. for _, item := range order.HisOrderInfo {
  1079. if item.MedChrgitmType == "01" { //床位费
  1080. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1081. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1082. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1083. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1084. if item.ChrgitmLv == "1" {
  1085. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1086. }
  1087. if item.ChrgitmLv == "2" {
  1088. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1089. }
  1090. if item.ChrgitmLv == "3" {
  1091. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1092. }
  1093. }
  1094. if item.MedChrgitmType == "03" { //检查费
  1095. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1096. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1097. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1098. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1099. if item.ChrgitmLv == "1" {
  1100. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1101. }
  1102. if item.ChrgitmLv == "2" {
  1103. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1104. }
  1105. if item.ChrgitmLv == "3" {
  1106. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1107. }
  1108. }
  1109. if item.MedChrgitmType == "04" { //化验费
  1110. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1111. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1112. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1113. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1114. if item.ChrgitmLv == "1" {
  1115. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1116. }
  1117. if item.ChrgitmLv == "2" {
  1118. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1119. }
  1120. if item.ChrgitmLv == "3" {
  1121. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1122. }
  1123. }
  1124. if item.MedChrgitmType == "05" { //治疗费
  1125. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1126. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1127. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1128. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1129. if item.ChrgitmLv == "1" {
  1130. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1131. }
  1132. if item.ChrgitmLv == "2" {
  1133. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1134. }
  1135. if item.ChrgitmLv == "3" {
  1136. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1137. }
  1138. }
  1139. if item.MedChrgitmType == "06" { //手术费
  1140. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1141. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1142. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1143. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1144. if item.ChrgitmLv == "1" {
  1145. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1146. }
  1147. if item.ChrgitmLv == "2" {
  1148. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1149. }
  1150. if item.ChrgitmLv == "3" {
  1151. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1152. }
  1153. }
  1154. if item.MedChrgitmType == "08" { //材料费
  1155. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1156. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1157. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1158. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1159. if item.ChrgitmLv == "1" {
  1160. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1161. }
  1162. if item.ChrgitmLv == "2" {
  1163. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1164. }
  1165. if item.ChrgitmLv == "3" {
  1166. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1167. }
  1168. }
  1169. if item.MedChrgitmType == "09" { //西药费
  1170. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1171. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1172. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1173. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1174. if item.ChrgitmLv == "1" {
  1175. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1176. }
  1177. if item.ChrgitmLv == "2" {
  1178. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1179. }
  1180. if item.ChrgitmLv == "3" {
  1181. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1182. }
  1183. }
  1184. if item.MedChrgitmType == "11" { //中成费
  1185. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1186. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1187. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1188. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1189. if item.ChrgitmLv == "1" {
  1190. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1191. }
  1192. if item.ChrgitmLv == "2" {
  1193. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1194. }
  1195. if item.ChrgitmLv == "3" {
  1196. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1197. }
  1198. }
  1199. if item.MedChrgitmType == "14" { //其他费
  1200. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1201. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1202. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1203. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1204. if item.ChrgitmLv == "1" {
  1205. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1206. }
  1207. if item.ChrgitmLv == "2" {
  1208. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1209. }
  1210. if item.ChrgitmLv == "3" {
  1211. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1212. }
  1213. }
  1214. }
  1215. var iteminfoStructs []service.IteminfoStruct
  1216. if bedCostTotal != 0 {
  1217. iteminfo.MedChrgitm = "01"
  1218. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1219. iteminfo.Amt = bedCostTotal
  1220. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1221. iteminfo.ClabAmt = bed_clab_amt
  1222. iteminfo.OthAmt = bed_other_amt
  1223. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1224. }
  1225. if checkCostTotal != 0 {
  1226. iteminfo.MedChrgitm = "03"
  1227. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1228. iteminfo.Amt = checkCostTotal
  1229. iteminfo.ClaaSumfee = check_claa_sunmfee
  1230. iteminfo.ClabAmt = check_clab_amt
  1231. iteminfo.OthAmt = check_other_amt
  1232. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1233. }
  1234. if laboratoryCostTotal != 0 {
  1235. iteminfo.MedChrgitm = "04"
  1236. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1237. iteminfo.Amt = laboratoryCostTotal
  1238. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1239. iteminfo.ClabAmt = laboratory_clab_amt
  1240. iteminfo.OthAmt = laboratory_other_amt
  1241. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1242. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1243. }
  1244. if treatCostTotal != 0 {
  1245. iteminfo.MedChrgitm = "05"
  1246. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1247. iteminfo.Amt = treatCostTotal
  1248. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1249. iteminfo.ClabAmt = treat_clab_amt
  1250. iteminfo.OthAmt = treat_other_amt
  1251. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1252. //(struct4101.IteminfoStruct, iteminfo)
  1253. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1254. }
  1255. if operationCostTotal != 0 {
  1256. iteminfo.MedChrgitm = "06"
  1257. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1258. iteminfo.Amt = operationCostTotal
  1259. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1260. iteminfo.ClabAmt = operation_clab_amt
  1261. iteminfo.OthAmt = operation_other_amt
  1262. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1263. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1264. }
  1265. if materialCostTotal != 0 {
  1266. iteminfo.MedChrgitm = "08"
  1267. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1268. iteminfo.Amt = materialCostTotal
  1269. iteminfo.ClaaSumfee = material_claa_sunmfee
  1270. iteminfo.ClabAmt = material_clab_amt
  1271. iteminfo.OthAmt = material_other_amt
  1272. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1273. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1274. }
  1275. if westernMedicineCostTotal != 0 {
  1276. iteminfo.MedChrgitm = "09"
  1277. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1278. iteminfo.Amt = westernMedicineCostTotal
  1279. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1280. iteminfo.ClabAmt = westernMedicine_clab_amt
  1281. iteminfo.OthAmt = westernMedicine_other_amt
  1282. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1283. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1284. }
  1285. if chineseTraditionalMedicineCostTotal != 0 {
  1286. iteminfo.MedChrgitm = "11"
  1287. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1288. iteminfo.Amt = westernMedicineCostTotal
  1289. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1290. iteminfo.ClabAmt = westernMedicine_clab_amt
  1291. iteminfo.OthAmt = westernMedicine_other_amt
  1292. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1293. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1294. }
  1295. if otherCostTotal != 0 {
  1296. iteminfo.MedChrgitm = "14"
  1297. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1298. iteminfo.Amt = otherCostTotal
  1299. iteminfo.ClaaSumfee = other_claa_sunmfee
  1300. iteminfo.ClabAmt = other_clab_amt
  1301. iteminfo.OthAmt = other_other_amt
  1302. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1303. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1304. }
  1305. struct4101.IteminfoStruct = iteminfoStructs
  1306. struct4101.Ntly = "中国"
  1307. struct4101.AdmCaty = "A03.06"
  1308. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1309. fmt.Println(result)
  1310. var dat map[string]interface{}
  1311. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1312. fmt.Println(dat)
  1313. } else {
  1314. fmt.Println(err)
  1315. }
  1316. userJSONBytes, _ := json.Marshal(dat)
  1317. var res ResultSeventeen
  1318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1319. utils.ErrorLog("解析失败:%v", err)
  1320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1321. return
  1322. }
  1323. if res.Infcode != 0 {
  1324. c.ServeSuccessJSON(map[string]interface{}{
  1325. "failed_code": -10,
  1326. "msg": res.ErrMsg,
  1327. })
  1328. return
  1329. } else {
  1330. order.FaPiaoNumber = zero
  1331. order.FaPiaoCode = last_order.FaPiaoCode
  1332. service.UpdateOrder(order)
  1333. hisFundSettleListResult := &models.HisFundSettleListResult{
  1334. Number: res.Output.SetlListId,
  1335. Status: 1,
  1336. Ctime: time.Now().Unix(),
  1337. Mtime: time.Now().Unix(),
  1338. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1339. IsUpload: 1,
  1340. OrderId: order_id,
  1341. }
  1342. service.CreateUploadRecord(hisFundSettleListResult)
  1343. c.ServeSuccessJSON(map[string]interface{}{
  1344. "msg": "上传成功",
  1345. "result": hisFundSettleListResult,
  1346. })
  1347. return
  1348. }
  1349. }
  1350. func (c *HisApiController) GetSettleListHospital() {
  1351. order_id, _ := c.GetInt64("order_id")
  1352. admin_user_id, _ := c.GetInt64("admin_user_id")
  1353. order, _ := service.GetHisOrderByIDTwo(order_id)
  1354. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1355. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1356. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1357. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1358. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1359. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1360. if order.ID == 0 {
  1361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1362. return
  1363. }
  1364. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1365. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1366. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1367. fmt.Println(count)
  1368. var zero string
  1369. number := count + 1
  1370. if number >= 1000 {
  1371. zero = "0000" + strconv.FormatInt(number, 10)
  1372. } else if number >= 10000 {
  1373. zero = "000" + strconv.FormatInt(number, 10)
  1374. } else if number >= 100000 {
  1375. zero = "00" + strconv.FormatInt(number, 10)
  1376. } else if number >= 1000000 {
  1377. zero = "0" + strconv.FormatInt(number, 10)
  1378. } else {
  1379. zero = strconv.FormatInt(number, 10)
  1380. }
  1381. fmt.Println(zero)
  1382. struct4101 := service.Struct4101{
  1383. PsnNo: order.PsnNo,
  1384. MdtrtId: order.MdtrtId,
  1385. SetlId: order.SetlId,
  1386. PsnName: order.PsnName,
  1387. Gend: order.Gend,
  1388. Brdy: his.Brdy,
  1389. Age: int64(order.Age),
  1390. Naty: order.Naty,
  1391. PatnCertType: "01",
  1392. Certno: order.Certno,
  1393. Prfs: "90",
  1394. ConerName: roles[0].UserName,
  1395. PatnRlts: "99",
  1396. ConerAddr: miConfig.OrgName,
  1397. ConerTel: admin.Mobile,
  1398. HiType: order.Insutype,
  1399. Insuplc: miConfig.InsuplcAdmdvs,
  1400. MaindiagFlag: "1",
  1401. BillCode: last_order.FaPiaoCode,
  1402. BillNo: zero,
  1403. BizSn: order.Number,
  1404. PsnSelfPay: order.PsnPartAmt,
  1405. PsnOwnPay: order.PsnPartAmt,
  1406. AcctPay: order.AcctPay,
  1407. PsnCashpay: order.PsnCashPay,
  1408. HiPaymtd: "1",
  1409. Hsorg: miConfig.InsuplcAdmdvs,
  1410. HsorgOpter: miConfig.InsuplcAdmdvs,
  1411. MedinsFillPsn: curRoles.UserName,
  1412. MedinsFillDept: depart.Name,
  1413. IptMedType: "2",
  1414. AdmTime: his.InHosptialTime,
  1415. AdmEndTime: his.OutHosptialTime,
  1416. }
  1417. struct4101.SetlBegnDate = order.SetlTime
  1418. struct4101.SetlEndDate = order.SetlTime
  1419. var rf []CustomFundPay
  1420. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1421. var tempFunPays []service.CustomStruct
  1422. for _, item := range rf {
  1423. var tempFunPay service.CustomStruct
  1424. tempFunPay.FundPayamt = item.FundPayamt
  1425. tempFunPay.FundPayType = item.FundPayType
  1426. tempFunPays = append(tempFunPays, tempFunPay)
  1427. }
  1428. struct4101.CustomStruct = tempFunPays
  1429. var tempDiaginfos []service.DiaginfoStructTwo
  1430. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1431. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1432. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1433. var config []*models.HisXtDiagnoseConfig
  1434. for _, item := range diagnosis_ids {
  1435. id, _ := strconv.ParseInt(item, 10, 64)
  1436. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1437. config = append(config, &diagnosisConfig)
  1438. }
  1439. for index, item := range config {
  1440. if index == 0 {
  1441. var tempDiaginfo service.DiaginfoStructTwo
  1442. tempDiaginfo.DiagCode = item.CountryCode
  1443. tempDiaginfo.DiagName = item.CountryContentName
  1444. tempDiaginfo.DiagType = "1"
  1445. tempDiaginfo.MaindiagFlag = "1"
  1446. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1447. } else {
  1448. var tempDiaginfo service.DiaginfoStructTwo
  1449. tempDiaginfo.DiagCode = item.CountryCode
  1450. tempDiaginfo.DiagName = item.CountryContentName
  1451. tempDiaginfo.DiagType = "2"
  1452. tempDiaginfo.MaindiagFlag = "0"
  1453. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1454. }
  1455. }
  1456. struct4101.Diseinfo = tempDiaginfos
  1457. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1458. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1459. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1460. tempOpspdiseinfo2.OprnOprtCode = ""
  1461. tempOpspdiseinfo2.OprnOprtName = ""
  1462. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1463. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1464. var iteminfo service.IteminfoStruct
  1465. var bedCostTotal float64 = 0 //床位总费
  1466. var bedCostSelfTotal float64 = 0 //床位自费
  1467. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1468. var operationCostTotal float64 = 0 //手术费
  1469. var operationCostSelfTotal float64 = 0 //手术费
  1470. var operationCostPartSelfTotal float64 = 0 //手术费
  1471. var otherCostTotal float64 = 0 //其他费用
  1472. var otherCostSelfTotal float64 = 0 //其他费用
  1473. var otherCostPartSelfTotal float64 = 0 //其他费用
  1474. var materialCostTotal float64 = 0 //材料费
  1475. var materialCostSelfTotal float64 = 0 //材料费
  1476. var materialCostPartSelfTotal float64 = 0 //材料费
  1477. var westernMedicineCostTotal float64 = 0 //西药费
  1478. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1479. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1480. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1481. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1482. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1483. var checkCostTotal float64 = 0 //检查费
  1484. var checkCostSelfTotal float64 = 0 //检查费
  1485. var checkCostPartSelfTotal float64 = 0 //检查费
  1486. var laboratoryCostTotal float64 = 0 //化验费
  1487. var laboratoryCostSelfTotal float64 = 0 //化验费
  1488. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1489. var treatCostTotal float64 = 0 //治疗费用
  1490. var treatCostSelfTotal float64 = 0 //治疗费用
  1491. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1492. decimal.DivisionPrecision = 2
  1493. var bed_fulamt_ownpay_amt float64 = 0
  1494. var operation_fulamt_ownpay_amt float64 = 0
  1495. var other_fulamt_ownpay_amt float64 = 0
  1496. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1497. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1498. var check_fulamt_ownpay_amt float64 = 0
  1499. var material_fulamt_ownpay_amt float64 = 0
  1500. var laboratory_fulamt_ownpay_amt float64 = 0
  1501. var treat_fulamt_ownpay_amt float64 = 0
  1502. var bed_claa_sunmfee float64 = 0
  1503. var bed_clab_amt float64 = 0
  1504. var bed_other_amt float64 = 0
  1505. var operation_claa_sunmfee float64 = 0
  1506. var operation_clab_amt float64 = 0
  1507. var operation_other_amt float64 = 0
  1508. var other_claa_sunmfee float64 = 0
  1509. var other_clab_amt float64 = 0
  1510. var other_other_amt float64 = 0
  1511. var westernMedicine_claa_sunmfee float64 = 0
  1512. var westernMedicine_clab_amt float64 = 0
  1513. var westernMedicine_other_amt float64 = 0
  1514. var chineseTraditional_claa_sunmfee float64 = 0
  1515. var chineseTraditional_clab_amt float64 = 0
  1516. var chineseTraditional_other_amt float64 = 0
  1517. var check_claa_sunmfee float64 = 0
  1518. var check_clab_amt float64 = 0
  1519. var check_other_amt float64 = 0
  1520. var material_claa_sunmfee float64 = 0
  1521. var material_clab_amt float64 = 0
  1522. var material_other_amt float64 = 0
  1523. var laboratory_claa_sunmfee float64 = 0
  1524. var laboratory_clab_amt float64 = 0
  1525. var laboratory_other_amt float64 = 0
  1526. var treat_claa_sunmfee float64 = 0
  1527. var treat_clab_amt float64 = 0
  1528. var treat_other_amt float64 = 0
  1529. for _, item := range order.HisOrderInfo {
  1530. if item.MedChrgitmType == "01" { //床位费
  1531. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1532. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1533. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1534. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1535. if item.ChrgitmLv == "1" {
  1536. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1537. }
  1538. if item.ChrgitmLv == "2" {
  1539. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1540. }
  1541. if item.ChrgitmLv == "3" {
  1542. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1543. }
  1544. }
  1545. if item.MedChrgitmType == "03" { //检查费
  1546. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1547. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1548. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1549. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1550. if item.ChrgitmLv == "1" {
  1551. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1552. }
  1553. if item.ChrgitmLv == "2" {
  1554. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1555. }
  1556. if item.ChrgitmLv == "3" {
  1557. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1558. }
  1559. }
  1560. if item.MedChrgitmType == "04" { //化验费
  1561. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1562. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1563. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1564. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1565. if item.ChrgitmLv == "1" {
  1566. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1567. }
  1568. if item.ChrgitmLv == "2" {
  1569. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1570. }
  1571. if item.ChrgitmLv == "3" {
  1572. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1573. }
  1574. }
  1575. if item.MedChrgitmType == "05" { //治疗费
  1576. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1577. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1578. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1579. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1580. if item.ChrgitmLv == "1" {
  1581. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1582. }
  1583. if item.ChrgitmLv == "2" {
  1584. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1585. }
  1586. if item.ChrgitmLv == "3" {
  1587. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1588. }
  1589. }
  1590. if item.MedChrgitmType == "06" { //手术费
  1591. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1592. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1593. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1594. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1595. if item.ChrgitmLv == "1" {
  1596. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1597. }
  1598. if item.ChrgitmLv == "2" {
  1599. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1600. }
  1601. if item.ChrgitmLv == "3" {
  1602. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1603. }
  1604. }
  1605. if item.MedChrgitmType == "08" { //材料费
  1606. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1607. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1608. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1609. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1610. if item.ChrgitmLv == "1" {
  1611. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1612. }
  1613. if item.ChrgitmLv == "2" {
  1614. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1615. }
  1616. if item.ChrgitmLv == "3" {
  1617. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1618. }
  1619. }
  1620. if item.MedChrgitmType == "09" { //西药费
  1621. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1622. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1623. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1624. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1625. if item.ChrgitmLv == "1" {
  1626. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1627. }
  1628. if item.ChrgitmLv == "2" {
  1629. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1630. }
  1631. if item.ChrgitmLv == "3" {
  1632. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1633. }
  1634. }
  1635. if item.MedChrgitmType == "11" { //中成费
  1636. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1637. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1638. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1639. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1640. if item.ChrgitmLv == "1" {
  1641. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1642. }
  1643. if item.ChrgitmLv == "2" {
  1644. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1645. }
  1646. if item.ChrgitmLv == "3" {
  1647. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1648. }
  1649. }
  1650. if item.MedChrgitmType == "14" { //其他费
  1651. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1652. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1653. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1654. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1655. if item.ChrgitmLv == "1" {
  1656. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1657. }
  1658. if item.ChrgitmLv == "2" {
  1659. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1660. }
  1661. if item.ChrgitmLv == "3" {
  1662. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1663. }
  1664. }
  1665. }
  1666. var iteminfoStructs []service.IteminfoStruct
  1667. if bedCostTotal != 0 {
  1668. iteminfo.MedChrgitm = "01"
  1669. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1670. iteminfo.Amt = bedCostTotal
  1671. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1672. iteminfo.ClabAmt = bed_clab_amt
  1673. iteminfo.OthAmt = bed_other_amt
  1674. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1675. }
  1676. if checkCostTotal != 0 {
  1677. iteminfo.MedChrgitm = "03"
  1678. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1679. iteminfo.Amt = checkCostTotal
  1680. iteminfo.ClaaSumfee = check_claa_sunmfee
  1681. iteminfo.ClabAmt = check_clab_amt
  1682. iteminfo.OthAmt = check_other_amt
  1683. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1684. }
  1685. if laboratoryCostTotal != 0 {
  1686. iteminfo.MedChrgitm = "04"
  1687. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1688. iteminfo.Amt = laboratoryCostTotal
  1689. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1690. iteminfo.ClabAmt = laboratory_clab_amt
  1691. iteminfo.OthAmt = laboratory_other_amt
  1692. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1693. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1694. }
  1695. if treatCostTotal != 0 {
  1696. iteminfo.MedChrgitm = "05"
  1697. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1698. iteminfo.Amt = treatCostTotal
  1699. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1700. iteminfo.ClabAmt = treat_clab_amt
  1701. iteminfo.OthAmt = treat_other_amt
  1702. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1703. //(struct4101.IteminfoStruct, iteminfo)
  1704. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1705. }
  1706. if operationCostTotal != 0 {
  1707. iteminfo.MedChrgitm = "06"
  1708. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1709. iteminfo.Amt = operationCostTotal
  1710. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1711. iteminfo.ClabAmt = operation_clab_amt
  1712. iteminfo.OthAmt = operation_other_amt
  1713. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1714. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1715. }
  1716. if materialCostTotal != 0 {
  1717. iteminfo.MedChrgitm = "08"
  1718. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1719. iteminfo.Amt = materialCostTotal
  1720. iteminfo.ClaaSumfee = material_claa_sunmfee
  1721. iteminfo.ClabAmt = material_clab_amt
  1722. iteminfo.OthAmt = material_other_amt
  1723. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1724. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1725. }
  1726. if westernMedicineCostTotal != 0 {
  1727. iteminfo.MedChrgitm = "09"
  1728. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1729. iteminfo.Amt = westernMedicineCostTotal
  1730. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1731. iteminfo.ClabAmt = westernMedicine_clab_amt
  1732. iteminfo.OthAmt = westernMedicine_other_amt
  1733. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1734. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1735. }
  1736. if chineseTraditionalMedicineCostTotal != 0 {
  1737. iteminfo.MedChrgitm = "11"
  1738. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1739. iteminfo.Amt = westernMedicineCostTotal
  1740. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1741. iteminfo.ClabAmt = westernMedicine_clab_amt
  1742. iteminfo.OthAmt = westernMedicine_other_amt
  1743. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1744. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1745. }
  1746. if otherCostTotal != 0 {
  1747. iteminfo.MedChrgitm = "14"
  1748. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1749. iteminfo.Amt = otherCostTotal
  1750. iteminfo.ClaaSumfee = other_claa_sunmfee
  1751. iteminfo.ClabAmt = other_clab_amt
  1752. iteminfo.OthAmt = other_other_amt
  1753. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1754. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1755. }
  1756. struct4101.IteminfoStruct = iteminfoStructs
  1757. struct4101.Ntly = "中国"
  1758. struct4101.AdmCaty = "A03.06"
  1759. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1760. fmt.Println(result)
  1761. var dat map[string]interface{}
  1762. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1763. fmt.Println(dat)
  1764. } else {
  1765. fmt.Println(err)
  1766. }
  1767. userJSONBytes, _ := json.Marshal(dat)
  1768. var res ResultSeventeen
  1769. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1770. utils.ErrorLog("解析失败:%v", err)
  1771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1772. return
  1773. }
  1774. if res.Infcode != 0 {
  1775. c.ServeSuccessJSON(map[string]interface{}{
  1776. "failed_code": -10,
  1777. "msg": res.ErrMsg,
  1778. })
  1779. return
  1780. } else {
  1781. order.FaPiaoNumber = zero
  1782. order.FaPiaoCode = last_order.FaPiaoCode
  1783. service.UpdateOrder(order)
  1784. hisFundSettleListResult := &models.HisFundSettleListResult{
  1785. Number: res.Output.SetlListId,
  1786. Status: 1,
  1787. Ctime: time.Now().Unix(),
  1788. Mtime: time.Now().Unix(),
  1789. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1790. IsUpload: 1,
  1791. OrderId: order_id,
  1792. }
  1793. service.CreateUploadRecord(hisFundSettleListResult)
  1794. c.ServeSuccessJSON(map[string]interface{}{
  1795. "msg": "上传成功",
  1796. "result": hisFundSettleListResult,
  1797. })
  1798. return
  1799. }
  1800. }
  1801. func (c *HisApiController) GetBatchSettleList() {
  1802. orders, _ := service.GetAllHisOrder(10106)
  1803. for _, item := range orders {
  1804. order_id := item.ID
  1805. order, _ := service.GetHisOrderByIDTwo(order_id)
  1806. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1807. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1808. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1809. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  1810. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1811. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1812. if order.ID == 0 {
  1813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1814. return
  1815. }
  1816. if his.BalanceAccountsType == 2 {
  1817. continue
  1818. }
  1819. struct4101 := service.Struct4101{
  1820. PsnNo: order.PsnNo,
  1821. MdtrtId: order.MdtrtId,
  1822. SetlId: order.SetlId,
  1823. PsnName: order.PsnName,
  1824. Gend: order.Gend,
  1825. Brdy: his.Brdy,
  1826. Age: his.Age,
  1827. Naty: order.Naty,
  1828. PatnCertType: "01",
  1829. Certno: order.Certno,
  1830. Prfs: "90",
  1831. ConerName: roles[0].UserName,
  1832. PatnRlts: "99",
  1833. ConerAddr: miConfig.OrgName,
  1834. ConerTel: admin.Mobile,
  1835. HiType: order.Insutype,
  1836. Insuplc: his.InsuplcAdmdvs,
  1837. MaindiagFlag: "1",
  1838. BillCode: order.FaPiaoCode,
  1839. BillNo: order.FaPiaoNumber,
  1840. BizSn: order.Number,
  1841. PsnSelfPay: order.PsnPartAmt,
  1842. PsnOwnPay: order.PsnPartAmt,
  1843. AcctPay: order.AcctPay,
  1844. PsnCashpay: order.PsnCashPay,
  1845. HiPaymtd: "1",
  1846. Hsorg: his.InsuplcAdmdvs,
  1847. HsorgOpter: his.InsuplcAdmdvs,
  1848. MedinsFillPsn: curRoles.UserName,
  1849. MedinsFillDept: depart.Name,
  1850. IptMedType: "2",
  1851. }
  1852. struct4101.SetlBegnDate = order.SetlTime
  1853. struct4101.SetlEndDate = order.SetlTime
  1854. //if order.SettleType == 1 {
  1855. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1856. // dateStr := t.Format("2006-01-02")
  1857. // struct4101.SetlBegnDate = dateStr
  1858. // struct4101.SetlEndDate = dateStr
  1859. //} else {
  1860. // t := time.Unix(int64(order.SettleStartTime), 0)
  1861. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1862. // dateStartStr := t.Format("2006-01-02")
  1863. // dateEndStr := t2.Format("2006-01-02")
  1864. // struct4101.SetlBegnDate = dateStartStr
  1865. // struct4101.SetlEndDate = dateEndStr
  1866. //}
  1867. var rf []CustomFundPay
  1868. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1869. var tempFunPays []service.CustomStruct
  1870. var tempFunPay610100 service.CustomStruct
  1871. for _, item := range rf {
  1872. if item.FundPayType == "610100" {
  1873. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1874. tempFunPay610100.FundPayType = item.FundPayType
  1875. } else {
  1876. var tempFunPay service.CustomStruct
  1877. tempFunPay.FundPayamt = item.FundPayamt
  1878. tempFunPay.FundPayType = item.FundPayType
  1879. tempFunPays = append(tempFunPays, tempFunPay)
  1880. }
  1881. }
  1882. tempFunPays = append(tempFunPays, tempFunPay610100)
  1883. struct4101.CustomStruct = tempFunPays
  1884. var tempDiaginfos []service.DiaginfoStructTwo
  1885. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1886. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1887. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1888. var config []*models.HisXtDiagnoseConfig
  1889. for _, item := range diagnosis_ids {
  1890. id, _ := strconv.ParseInt(item, 10, 64)
  1891. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1892. config = append(config, &diagnosisConfig)
  1893. }
  1894. for index, item := range config {
  1895. if index == 0 {
  1896. var tempDiaginfo service.DiaginfoStructTwo
  1897. tempDiaginfo.DiagCode = item.CountryCode
  1898. tempDiaginfo.DiagName = item.CountryContentName
  1899. tempDiaginfo.DiagType = "1"
  1900. tempDiaginfo.MaindiagFlag = "1"
  1901. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1902. } else {
  1903. var tempDiaginfo service.DiaginfoStructTwo
  1904. tempDiaginfo.DiagCode = item.CountryCode
  1905. tempDiaginfo.DiagName = item.CountryContentName
  1906. tempDiaginfo.DiagType = "2"
  1907. tempDiaginfo.MaindiagFlag = "0"
  1908. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1909. }
  1910. }
  1911. struct4101.Diseinfo = tempDiaginfos
  1912. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1913. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1914. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1915. tempOpspdiseinfo2.OprnOprtCode = ""
  1916. tempOpspdiseinfo2.OprnOprtName = ""
  1917. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1918. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1919. var iteminfo service.IteminfoStruct
  1920. var bedCostTotal float64 = 0 //床位总费
  1921. var bedCostSelfTotal float64 = 0 //床位自费
  1922. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1923. var examineCostTotal float64 = 0 //诊查总费
  1924. var examineCostSelfTotal float64 = 0 //诊查自费
  1925. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1926. var nursingCostTotal float64 = 0 //护理总费
  1927. var nursingCostSelfTotal float64 = 0 //护理自费
  1928. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1929. var chineseMedicineCostTotal float64 = 0 //中成药
  1930. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1931. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1932. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1933. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1934. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1935. var registerCostTotal float64 = 0 //一般诊疗费
  1936. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1937. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1938. var operationCostTotal float64 = 0 //手术费
  1939. var operationCostSelfTotal float64 = 0 //手术费
  1940. var operationCostPartSelfTotal float64 = 0 //手术费
  1941. var otherCostTotal float64 = 0 //其他费用
  1942. var otherCostSelfTotal float64 = 0 //其他费用
  1943. var otherCostPartSelfTotal float64 = 0 //其他费用
  1944. var materialCostTotal float64 = 0 //材料费
  1945. var materialCostSelfTotal float64 = 0 //材料费
  1946. var materialCostPartSelfTotal float64 = 0 //材料费
  1947. var westernMedicineCostTotal float64 = 0 //西药费
  1948. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1949. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1950. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1951. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1952. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1953. var checkCostTotal float64 = 0 //检查费
  1954. var checkCostSelfTotal float64 = 0 //检查费
  1955. var checkCostPartSelfTotal float64 = 0 //检查费
  1956. var laboratoryCostTotal float64 = 0 //化验费
  1957. var laboratoryCostSelfTotal float64 = 0 //化验费
  1958. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1959. var treatCostTotal float64 = 0 //治疗费用
  1960. var treatCostSelfTotal float64 = 0 //治疗费用
  1961. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1962. decimal.DivisionPrecision = 2
  1963. var bed_fulamt_ownpay_amt float64 = 0
  1964. var examine_fulamt_ownpay_amt float64 = 0
  1965. var nursing_fulamt_ownpay_amt float64 = 0
  1966. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1967. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1968. var register_fulamt_ownpay_amt float64 = 0
  1969. var operation_fulamt_ownpay_amt float64 = 0
  1970. var other_fulamt_ownpay_amt float64 = 0
  1971. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1972. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1973. var check_fulamt_ownpay_amt float64 = 0
  1974. var material_fulamt_ownpay_amt float64 = 0
  1975. var laboratory_fulamt_ownpay_amt float64 = 0
  1976. var treat_fulamt_ownpay_amt float64 = 0
  1977. var bed_claa_sunmfee float64 = 0
  1978. var bed_clab_amt float64 = 0
  1979. var bed_other_amt float64 = 0
  1980. var examine_claa_sunmfee float64 = 0
  1981. var examine_clab_amt float64 = 0
  1982. var examine_other_amt float64 = 0
  1983. var nursing_claa_sunmfee float64 = 0
  1984. var nursing_clab_amt float64 = 0
  1985. var nursing_other_amt float64 = 0
  1986. var chinese_medicine_claa_sunmfee float64 = 0
  1987. var chinese_medicine_clab_amt float64 = 0
  1988. var chinese_medicine_other_amt float64 = 0
  1989. var commonly_treatment_claa_sunmfee float64 = 0
  1990. var commonly_treatment_clab_amt float64 = 0
  1991. var commonly_treatment_other_amt float64 = 0
  1992. var operation_claa_sunmfee float64 = 0
  1993. var operation_clab_amt float64 = 0
  1994. var operation_other_amt float64 = 0
  1995. var other_claa_sunmfee float64 = 0
  1996. var other_clab_amt float64 = 0
  1997. var other_other_amt float64 = 0
  1998. var westernMedicine_claa_sunmfee float64 = 0
  1999. var westernMedicine_clab_amt float64 = 0
  2000. var westernMedicine_other_amt float64 = 0
  2001. var chineseTraditional_claa_sunmfee float64 = 0
  2002. var chineseTraditional_clab_amt float64 = 0
  2003. var chineseTraditional_other_amt float64 = 0
  2004. var check_claa_sunmfee float64 = 0
  2005. var check_clab_amt float64 = 0
  2006. var check_other_amt float64 = 0
  2007. var material_claa_sunmfee float64 = 0
  2008. var material_clab_amt float64 = 0
  2009. var material_other_amt float64 = 0
  2010. var laboratory_claa_sunmfee float64 = 0
  2011. var laboratory_clab_amt float64 = 0
  2012. var laboratory_other_amt float64 = 0
  2013. var treat_claa_sunmfee float64 = 0
  2014. var treat_clab_amt float64 = 0
  2015. var treat_other_amt float64 = 0
  2016. var register_claa_sunmfee float64 = 0
  2017. var register_clab_amt float64 = 0
  2018. var register_other_amt float64 = 0
  2019. for _, item := range order.HisOrderInfo {
  2020. if item.MedChrgitmType == "01" { //床位费
  2021. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2022. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2023. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2024. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2025. if item.ChrgitmLv == "1" {
  2026. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2027. }
  2028. if item.ChrgitmLv == "2" {
  2029. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2030. }
  2031. if item.ChrgitmLv == "3" {
  2032. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2033. }
  2034. }
  2035. if item.MedChrgitmType == "02" { //诊查
  2036. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2037. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2038. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2039. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2040. if item.ChrgitmLv == "1" {
  2041. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2042. }
  2043. if item.ChrgitmLv == "2" {
  2044. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2045. }
  2046. if item.ChrgitmLv == "3" {
  2047. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2048. }
  2049. }
  2050. if item.MedChrgitmType == "03" { //检查费
  2051. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2052. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2053. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2054. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2055. if item.ChrgitmLv == "1" {
  2056. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2057. }
  2058. if item.ChrgitmLv == "2" {
  2059. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2060. }
  2061. if item.ChrgitmLv == "3" {
  2062. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2063. }
  2064. }
  2065. if item.MedChrgitmType == "04" { //化验费
  2066. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2067. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2068. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2069. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2070. if item.ChrgitmLv == "1" {
  2071. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2072. }
  2073. if item.ChrgitmLv == "2" {
  2074. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2075. }
  2076. if item.ChrgitmLv == "3" {
  2077. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2078. }
  2079. }
  2080. if item.MedChrgitmType == "05" { //治疗费
  2081. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2082. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2083. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2084. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2085. if item.ChrgitmLv == "1" {
  2086. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2087. }
  2088. if item.ChrgitmLv == "2" {
  2089. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2090. }
  2091. if item.ChrgitmLv == "3" {
  2092. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2093. }
  2094. }
  2095. if item.MedChrgitmType == "06" { //手术费
  2096. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2097. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2098. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2099. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2100. if item.ChrgitmLv == "1" {
  2101. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2102. }
  2103. if item.ChrgitmLv == "2" {
  2104. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2105. }
  2106. if item.ChrgitmLv == "3" {
  2107. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2108. }
  2109. }
  2110. if item.MedChrgitmType == "07" { //手术费
  2111. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2112. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2113. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2114. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2115. if item.ChrgitmLv == "1" {
  2116. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2117. }
  2118. if item.ChrgitmLv == "2" {
  2119. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2120. }
  2121. if item.ChrgitmLv == "3" {
  2122. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2123. }
  2124. }
  2125. if item.MedChrgitmType == "08" { //材料费
  2126. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2127. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2128. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2129. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2130. if item.ChrgitmLv == "1" {
  2131. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2132. }
  2133. if item.ChrgitmLv == "2" {
  2134. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2135. }
  2136. if item.ChrgitmLv == "3" {
  2137. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2138. }
  2139. }
  2140. if item.MedChrgitmType == "09" { //西药费
  2141. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2142. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2143. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2144. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2145. if item.ChrgitmLv == "1" {
  2146. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2147. }
  2148. if item.ChrgitmLv == "2" {
  2149. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2150. }
  2151. if item.ChrgitmLv == "3" {
  2152. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2153. }
  2154. }
  2155. if item.MedChrgitmType == "10" { //中药饮片
  2156. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2157. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2158. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2159. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2160. if item.ChrgitmLv == "1" {
  2161. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2162. }
  2163. if item.ChrgitmLv == "2" {
  2164. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2165. }
  2166. if item.ChrgitmLv == "3" {
  2167. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2168. }
  2169. }
  2170. if item.MedChrgitmType == "11" { //中成费
  2171. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2172. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2173. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2174. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2175. if item.ChrgitmLv == "1" {
  2176. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2177. }
  2178. if item.ChrgitmLv == "2" {
  2179. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2180. }
  2181. if item.ChrgitmLv == "3" {
  2182. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2183. }
  2184. }
  2185. if item.MedChrgitmType == "12" { //中成费
  2186. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2187. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2188. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2189. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2190. if item.ChrgitmLv == "1" {
  2191. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2192. }
  2193. if item.ChrgitmLv == "2" {
  2194. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2195. }
  2196. if item.ChrgitmLv == "3" {
  2197. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2198. }
  2199. }
  2200. if item.MedChrgitmType == "13" { //中成费
  2201. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2202. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2203. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2204. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2205. if item.ChrgitmLv == "1" {
  2206. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2207. }
  2208. if item.ChrgitmLv == "2" {
  2209. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2210. }
  2211. if item.ChrgitmLv == "3" {
  2212. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2213. }
  2214. }
  2215. if item.MedChrgitmType == "14" { //其他费
  2216. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2217. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2218. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2219. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2220. if item.ChrgitmLv == "1" {
  2221. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2222. }
  2223. if item.ChrgitmLv == "2" {
  2224. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2225. }
  2226. if item.ChrgitmLv == "3" {
  2227. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2228. }
  2229. }
  2230. }
  2231. var iteminfoStructs []service.IteminfoStruct
  2232. if bedCostTotal != 0 {
  2233. iteminfo.MedChrgitm = "01"
  2234. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2235. iteminfo.Amt = bedCostTotal
  2236. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2237. iteminfo.ClabAmt = bed_clab_amt
  2238. iteminfo.OthAmt = bed_other_amt
  2239. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2240. }
  2241. if examineCostTotal != 0 {
  2242. iteminfo.MedChrgitm = "02"
  2243. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2244. iteminfo.Amt = examineCostTotal
  2245. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2246. iteminfo.ClabAmt = examine_clab_amt
  2247. iteminfo.OthAmt = examine_other_amt
  2248. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2249. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2250. }
  2251. if checkCostTotal != 0 {
  2252. iteminfo.MedChrgitm = "03"
  2253. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2254. iteminfo.Amt = checkCostTotal
  2255. iteminfo.ClaaSumfee = check_claa_sunmfee
  2256. iteminfo.ClabAmt = check_clab_amt
  2257. iteminfo.OthAmt = check_other_amt
  2258. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2259. }
  2260. if laboratoryCostTotal != 0 {
  2261. iteminfo.MedChrgitm = "04"
  2262. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2263. iteminfo.Amt = laboratoryCostTotal
  2264. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2265. iteminfo.ClabAmt = laboratory_clab_amt
  2266. iteminfo.OthAmt = laboratory_other_amt
  2267. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2268. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2269. }
  2270. if treatCostTotal != 0 {
  2271. iteminfo.MedChrgitm = "05"
  2272. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2273. iteminfo.Amt = treatCostTotal
  2274. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2275. iteminfo.ClabAmt = treat_clab_amt
  2276. iteminfo.OthAmt = treat_other_amt
  2277. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2278. //(struct4101.IteminfoStruct, iteminfo)
  2279. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2280. }
  2281. if operationCostTotal != 0 {
  2282. iteminfo.MedChrgitm = "06"
  2283. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2284. iteminfo.Amt = operationCostTotal
  2285. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2286. iteminfo.ClabAmt = operation_clab_amt
  2287. iteminfo.OthAmt = operation_other_amt
  2288. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2289. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2290. }
  2291. if nursingCostTotal != 0 {
  2292. iteminfo.MedChrgitm = "07"
  2293. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2294. iteminfo.Amt = nursingCostTotal
  2295. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2296. iteminfo.ClabAmt = nursing_clab_amt
  2297. iteminfo.OthAmt = nursing_other_amt
  2298. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2299. }
  2300. if materialCostTotal != 0 {
  2301. iteminfo.MedChrgitm = "08"
  2302. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2303. iteminfo.Amt = materialCostTotal
  2304. iteminfo.ClaaSumfee = material_claa_sunmfee
  2305. iteminfo.ClabAmt = material_clab_amt
  2306. iteminfo.OthAmt = material_other_amt
  2307. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2308. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2309. }
  2310. if westernMedicineCostTotal != 0 {
  2311. iteminfo.MedChrgitm = "09"
  2312. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2313. iteminfo.Amt = westernMedicineCostTotal
  2314. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2315. iteminfo.ClabAmt = westernMedicine_clab_amt
  2316. iteminfo.OthAmt = westernMedicine_other_amt
  2317. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2318. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2319. }
  2320. if chineseMedicineCostTotal != 0 {
  2321. iteminfo.MedChrgitm = "10"
  2322. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2323. iteminfo.Amt = chineseMedicineCostTotal
  2324. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2325. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2326. iteminfo.OthAmt = chinese_medicine_other_amt
  2327. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2328. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2329. }
  2330. if chineseTraditionalMedicineCostTotal != 0 {
  2331. iteminfo.MedChrgitm = "11"
  2332. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2333. iteminfo.Amt = westernMedicineCostTotal
  2334. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2335. iteminfo.ClabAmt = westernMedicine_clab_amt
  2336. iteminfo.OthAmt = westernMedicine_other_amt
  2337. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2338. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2339. }
  2340. if commonlyTreatmentCostTotal != 0 {
  2341. iteminfo.MedChrgitm = "12"
  2342. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2343. iteminfo.Amt = commonlyTreatmentCostTotal
  2344. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2345. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2346. iteminfo.OthAmt = commonly_treatment_other_amt
  2347. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2348. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2349. }
  2350. if registerCostTotal != 0 {
  2351. iteminfo.MedChrgitm = "13"
  2352. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2353. iteminfo.Amt = registerCostTotal
  2354. iteminfo.ClaaSumfee = register_claa_sunmfee
  2355. iteminfo.ClabAmt = register_clab_amt
  2356. iteminfo.OthAmt = register_other_amt
  2357. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2358. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2359. }
  2360. if otherCostTotal != 0 {
  2361. iteminfo.MedChrgitm = "14"
  2362. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2363. iteminfo.Amt = otherCostTotal
  2364. iteminfo.ClaaSumfee = other_claa_sunmfee
  2365. iteminfo.ClabAmt = other_clab_amt
  2366. iteminfo.OthAmt = other_other_amt
  2367. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2368. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2369. }
  2370. struct4101.IteminfoStruct = iteminfoStructs
  2371. struct4101.Ntly = "中国"
  2372. struct4101.AdmCaty = "A03.06"
  2373. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2374. fmt.Println(result)
  2375. var dat map[string]interface{}
  2376. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2377. fmt.Println(dat)
  2378. } else {
  2379. fmt.Println(err)
  2380. }
  2381. userJSONBytes, _ := json.Marshal(dat)
  2382. var res ResultSeventeen
  2383. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2384. utils.ErrorLog("解析失败:%v", err)
  2385. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2386. adminUser := c.GetAdminUserInfo()
  2387. errlog := &models.HisOrderError{
  2388. UserOrgId: adminUser.CurrentOrgId,
  2389. Ctime: time.Now().Unix(),
  2390. Mtime: time.Now().Unix(),
  2391. ErrMsg: res.ErrMsg + "解析失败",
  2392. Status: 1,
  2393. PatientId: order_id,
  2394. Stage: 10106,
  2395. }
  2396. service.CreateErrMsgLog(errlog)
  2397. continue
  2398. }
  2399. if res.Infcode != 0 {
  2400. adminUser := c.GetAdminUserInfo()
  2401. errlog := &models.HisOrderError{
  2402. UserOrgId: adminUser.CurrentOrgId,
  2403. Ctime: time.Now().Unix(),
  2404. Mtime: time.Now().Unix(),
  2405. ErrMsg: res.ErrMsg,
  2406. Status: 1,
  2407. PatientId: order_id,
  2408. Stage: 10106,
  2409. }
  2410. service.CreateErrMsgLog(errlog)
  2411. continue
  2412. } else {
  2413. hisFundSettleListResult := &models.HisFundSettleListResult{
  2414. Number: res.Output.SetlListId,
  2415. Status: 1,
  2416. Ctime: time.Now().Unix(),
  2417. Mtime: time.Now().Unix(),
  2418. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2419. IsUpload: 1,
  2420. OrderId: order_id,
  2421. }
  2422. service.CreateUploadRecord(hisFundSettleListResult)
  2423. continue
  2424. }
  2425. }
  2426. }
  2427. func (c *HisApiController) GetOrgInfo() {
  2428. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2429. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2430. }
  2431. func (c *HisApiController) GetHisPatientInfo() {
  2432. medical_insurance_card := c.GetString("medical_insurance_card")
  2433. id_card_type, _ := c.GetInt64("id_card_type")
  2434. id_card := c.GetString("id_card")
  2435. adminInfo := c.GetAdminUserInfo()
  2436. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2437. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2438. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2439. IdCardNo := ""
  2440. if id_card_type == 1 {
  2441. IdCardNo = medical_insurance_card
  2442. } else if id_card_type == 2 {
  2443. IdCardNo = id_card
  2444. }
  2445. if config.IsOpen == 1 {
  2446. 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
  2447. resp, requestErr := http.Get(api)
  2448. if requestErr != nil {
  2449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2450. return
  2451. }
  2452. defer resp.Body.Close()
  2453. body, ioErr := ioutil.ReadAll(resp.Body)
  2454. if ioErr != nil {
  2455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2457. return
  2458. }
  2459. var respJSON map[string]interface{}
  2460. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2463. return
  2464. }
  2465. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2466. userJSONBytes, _ := json.Marshal(userJSON)
  2467. var res ResultTwo
  2468. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2469. utils.ErrorLog("解析失败:%v", err)
  2470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2471. return
  2472. }
  2473. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2474. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2475. infoStr := string(Iinfos)
  2476. idetinfoStr := string(Idetinfos)
  2477. if res.Infcode == 0 {
  2478. his := models.VMHisPatient{
  2479. Status: 1,
  2480. Ctime: time.Now().Unix(),
  2481. Mtime: time.Now().Unix(),
  2482. PsnNo: res.Output.Baseinfo.PsnNo,
  2483. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2484. Certno: res.Output.Baseinfo.Certno,
  2485. PsnName: res.Output.Baseinfo.PsnName,
  2486. Gend: res.Output.Baseinfo.Gend,
  2487. Naty: res.Output.Baseinfo.Naty,
  2488. Brdy: res.Output.Baseinfo.Brdy,
  2489. Age: res.Output.Baseinfo.Age,
  2490. Iinfo: infoStr,
  2491. Idetinfo: idetinfoStr,
  2492. UserOrgId: adminInfo.CurrentOrgId,
  2493. IsReturn: 1,
  2494. IdCardType: id_card_type,
  2495. }
  2496. c.ServeSuccessJSON(map[string]interface{}{
  2497. "info": his,
  2498. })
  2499. } else {
  2500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2501. return
  2502. }
  2503. }
  2504. }
  2505. //func GetBasBaseInfo() (jsonStr string, err error) {
  2506. //
  2507. // handle := syscall.NewLazyDLL("SSCard.dll")
  2508. // add := handle.NewProc("ReadCardBas")
  2509. // str := make([]byte, 1024)
  2510. // str1 := make([]byte, 1024)
  2511. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2512. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2513. //
  2514. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2515. //
  2516. // fmt.Println("> Add(4,5)的结果为:", ret)
  2517. // handle.Release()
  2518. //
  2519. // return "", nil
  2520. //
  2521. //}
  2522. //func GetQRBaseInfo() (jsonStr string, err error) {
  2523. // handle := syscall.LoadDLL("SSCard.dll")
  2524. // ReadCardBas := handle.FindProc("GetQRBase")
  2525. //
  2526. // str := make([]byte, 256)
  2527. // str1 := make([]byte, 256)
  2528. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2529. //
  2530. // fmt.Println(string(str))
  2531. // fmt.Println(r)
  2532. // return string(str), nil
  2533. //}
  2534. //func CardInit() int {
  2535. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2536. // add := DllTestDef.MustFindProc("Init")
  2537. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2538. // if err != nil {
  2539. // fmt.Println("SSCard的运算结果为:", ret)
  2540. // }
  2541. // result := int(ret)
  2542. // return result
  2543. //}
  2544. //func CardInit() int {
  2545. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2546. // if err != nil {
  2547. // fmt.Println("SSCard的运算结果为:", ret)
  2548. // }
  2549. // fmt.Println(err)
  2550. // result := int(ret)
  2551. // return result
  2552. //}
  2553. func IntPtr(n int) uintptr {
  2554. return uintptr(n)
  2555. }
  2556. func StrPtr(s string) uintptr {
  2557. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2558. }
  2559. type Result2001 struct {
  2560. Cainfo interface{} `json:"cainfo"`
  2561. ErrMsg string `json:"err_msg"`
  2562. InfRefmsgid string `json:"inf_refmsgid"`
  2563. Infcode int64 `json:"infcode"`
  2564. Output struct {
  2565. Trtinfo struct {
  2566. PsnNo string `json:"psn_no"`
  2567. TrtChkType string `json:"trt_chk_type"`
  2568. FundPayType string `json:"fund_pay_type"`
  2569. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2570. Begndate string `json:"begndate"`
  2571. Enddate string `json:"enddate"`
  2572. TrtChkRslt string `json:"trt_chk_rslt"`
  2573. } `json:"trtinfo"`
  2574. } `json:"output"`
  2575. RefmsgTime string `json:"refmsg_time"`
  2576. RespondTime string `json:"respond_time"`
  2577. Signtype interface{} `json:"signtype"`
  2578. WarnMsg interface{} `json:"warn_msg"`
  2579. }
  2580. type Result2001Org10265 struct {
  2581. Cainfo interface{} `json:"cainfo"`
  2582. ErrMsg string `json:"err_msg"`
  2583. InfRefmsgid string `json:"inf_refmsgid"`
  2584. Infcode string `json:"infcode"`
  2585. Output struct {
  2586. Trtinfo struct {
  2587. PsnNo string `json:"psn_no"`
  2588. TrtChkType string `json:"trt_chk_type"`
  2589. FundPayType string `json:"fund_pay_type"`
  2590. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2591. Begndate string `json:"begndate"`
  2592. Enddate string `json:"enddate"`
  2593. TrtChkRslt string `json:"trt_chk_rslt"`
  2594. } `json:"trtinfo"`
  2595. } `json:"output"`
  2596. RefmsgTime string `json:"refmsg_time"`
  2597. RespondTime string `json:"respond_time"`
  2598. Signtype interface{} `json:"signtype"`
  2599. WarnMsg interface{} `json:"warn_msg"`
  2600. }
  2601. type ResultTwo struct {
  2602. ErrMsg string `json:"err_msg"`
  2603. InfRefmsgid string `json:"inf_refmsgid"`
  2604. Infcode int64 `json:"infcode"`
  2605. Output struct {
  2606. Baseinfo struct {
  2607. Age float64 `json:"age"`
  2608. Brdy string `json:"brdy"`
  2609. Certno string `json:"certno"`
  2610. Gend string `json:"gend"`
  2611. Naty string `json:"naty"`
  2612. PsnCertType string `json:"psn_cert_type"`
  2613. PsnName string `json:"psn_name"`
  2614. PsnNo string `json:"psn_no"`
  2615. } `json:"baseinfo"`
  2616. Idetinfo []interface{} `json:"idetinfo"`
  2617. Iinfo []struct {
  2618. Balc float64 `json:"balc"`
  2619. CvlservFlag string `json:"cvlserv_flag"`
  2620. EmpName string `json:"emp_name"`
  2621. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2622. Insutype string `json:"insutype"`
  2623. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2624. PausInsuDate string `json:"paus_insu_date"`
  2625. PsnInsuDate string `json:"psn_insu_date"`
  2626. PsnInsuStas string `json:"psn_insu_stas"`
  2627. PsnType string `json:"psn_type"`
  2628. } `json:"insuinfo"`
  2629. } `json:"output"`
  2630. RefmsgTime string `json:"refmsg_time"`
  2631. RespondTime string `json:"respond_time"`
  2632. Signtype interface{} `json:"signtype"`
  2633. WarnInfo interface{} `json:"warn_info"`
  2634. }
  2635. type ResultTwo10265 struct {
  2636. ErrMsg string `json:"err_msg"`
  2637. InfRefmsgid string `json:"inf_refmsgid"`
  2638. Infcode string `json:"infcode"`
  2639. Output struct {
  2640. Baseinfo struct {
  2641. Age float64 `json:"age"`
  2642. Brdy string `json:"brdy"`
  2643. Certno string `json:"certno"`
  2644. Gend string `json:"gend"`
  2645. Naty string `json:"naty"`
  2646. PsnCertType string `json:"psn_cert_type"`
  2647. PsnName string `json:"psn_name"`
  2648. PsnNo string `json:"psn_no"`
  2649. } `json:"baseinfo"`
  2650. Idetinfo []interface{} `json:"idetinfo"`
  2651. Iinfo []struct {
  2652. Balc float64 `json:"balc"`
  2653. CvlservFlag string `json:"cvlserv_flag"`
  2654. EmpName string `json:"emp_name"`
  2655. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2656. Insutype string `json:"insutype"`
  2657. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2658. PausInsuDate string `json:"paus_insu_date"`
  2659. PsnInsuDate string `json:"psn_insu_date"`
  2660. PsnInsuStas string `json:"psn_insu_stas"`
  2661. PsnType string `json:"psn_type"`
  2662. } `json:"insuinfo"`
  2663. } `json:"output"`
  2664. RefmsgTime string `json:"refmsg_time"`
  2665. RespondTime string `json:"respond_time"`
  2666. Signtype interface{} `json:"signtype"`
  2667. WarnInfo interface{} `json:"warn_info"`
  2668. }
  2669. type ResultThree struct {
  2670. Cainfo interface{} `json:"cainfo"`
  2671. ErrMsg string `json:"err_msg"`
  2672. InfRefmsgid string `json:"inf_refmsgid"`
  2673. Infcode int64 `json:"infcode"`
  2674. Output struct {
  2675. Data struct {
  2676. IptOtpNo string `json:"ipt_otp_no"`
  2677. MdtrtID string `json:"mdtrt_id"`
  2678. PsnNo string `json:"psn_no"`
  2679. } `json:"data"`
  2680. } `json:"output"`
  2681. RefmsgTime string `json:"refmsg_time"`
  2682. RespondTime string `json:"respond_time"`
  2683. Signtype interface{} `json:"signtype"`
  2684. WarnMsg interface{} `json:"warn_msg"`
  2685. }
  2686. type ResultThree10265 struct {
  2687. Cainfo interface{} `json:"cainfo"`
  2688. ErrMsg string `json:"err_msg"`
  2689. InfRefmsgid string `json:"inf_refmsgid"`
  2690. Infcode string `json:"infcode"`
  2691. Output struct {
  2692. Data struct {
  2693. IptOtpNo string `json:"ipt_otp_no"`
  2694. MdtrtID string `json:"mdtrt_id"`
  2695. PsnNo string `json:"psn_no"`
  2696. } `json:"data"`
  2697. } `json:"output"`
  2698. RefmsgTime string `json:"refmsg_time"`
  2699. RespondTime string `json:"respond_time"`
  2700. Signtype interface{} `json:"signtype"`
  2701. WarnMsg interface{} `json:"warn_msg"`
  2702. }
  2703. type ResultFour struct {
  2704. Cainfo string `json:"cainfo"`
  2705. ErrMsg string `json:"err_msg"`
  2706. InfRefmsgid string `json:"inf_refmsgid"`
  2707. Infcode int64 `json:"infcode"`
  2708. Output struct {
  2709. Result []struct {
  2710. BasMednFlag string `json:"bas_medn_flag"`
  2711. ChldMedcFlag string `json:"chld_medc_flag"`
  2712. ChrgitmLv string `json:"chrgitm_lv"`
  2713. Cnt float64 `json:"cnt"`
  2714. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2715. DrtReimFlag string `json:"drt_reim_flag"`
  2716. FeedetlSn string `json:"feedetl_sn"`
  2717. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2718. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2719. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2720. ListSpItemFlag string `json:"list_sp_item_flag"`
  2721. LmtUsedFlag string `json:"lmt_used_flag"`
  2722. MedChrgitmType string `json:"med_chrgitm_type"`
  2723. Memo string `json:"memo"`
  2724. OverlmtAmt float64 `json:"overlmt_amt"`
  2725. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2726. Pric float64 `json:"pric"`
  2727. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2728. SelfpayProp float64 `json:"selfpay_prop"`
  2729. } `json:"result"`
  2730. } `json:"output"`
  2731. RefmsgTime string `json:"refmsg_time"`
  2732. RespondTime string `json:"respond_time"`
  2733. Signtype string `json:"signtype"`
  2734. WarnMsg string `json:"warn_msg"`
  2735. }
  2736. type ResultFour10265 struct {
  2737. Cainfo string `json:"cainfo"`
  2738. ErrMsg string `json:"err_msg"`
  2739. InfRefmsgid string `json:"inf_refmsgid"`
  2740. Infcode string `json:"infcode"`
  2741. Output struct {
  2742. Result []struct {
  2743. BasMednFlag string `json:"bas_medn_flag"`
  2744. ChldMedcFlag string `json:"chld_medc_flag"`
  2745. ChrgitmLv string `json:"chrgitm_lv"`
  2746. Cnt float64 `json:"cnt"`
  2747. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2748. DrtReimFlag string `json:"drt_reim_flag"`
  2749. FeedetlSn string `json:"feedetl_sn"`
  2750. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2751. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2752. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2753. ListSpItemFlag string `json:"list_sp_item_flag"`
  2754. LmtUsedFlag string `json:"lmt_used_flag"`
  2755. MedChrgitmType string `json:"med_chrgitm_type"`
  2756. Memo string `json:"memo"`
  2757. OverlmtAmt float64 `json:"overlmt_amt"`
  2758. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2759. Pric float64 `json:"pric"`
  2760. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2761. SelfpayProp float64 `json:"selfpay_prop"`
  2762. } `json:"result"`
  2763. } `json:"output"`
  2764. RefmsgTime string `json:"refmsg_time"`
  2765. RespondTime string `json:"respond_time"`
  2766. Signtype string `json:"signtype"`
  2767. WarnMsg string `json:"warn_msg"`
  2768. }
  2769. type ResultFive struct {
  2770. Balc float64 `json:"balc"`
  2771. CvlservFlag string `json:"cvlserv_flag"`
  2772. EmpName string `json:"emp_name"`
  2773. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2774. Insutype string `json:"insutype"`
  2775. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2776. PausInsuDate string `json:"paus_insu_date"`
  2777. PsnInsuDate string `json:"psn_insu_date"`
  2778. PsnInsuStas string `json:"psn_insu_stas"`
  2779. PsnType string `json:"psn_type"`
  2780. }
  2781. type ResultSix struct {
  2782. Cainfo interface{} `json:"cainfo"`
  2783. ErrMsg string `json:"err_msg"`
  2784. InfRefmsgid string `json:"inf_refmsgid"`
  2785. Infcode int64 `json:"infcode"`
  2786. Output struct {
  2787. } `json:"output"`
  2788. RefmsgTime string `json:"refmsg_time"`
  2789. RespondTime string `json:"respond_time"`
  2790. Signtype interface{} `json:"signtype"`
  2791. WarnMsg interface{} `json:"warn_msg"`
  2792. }
  2793. type ResultSix10265 struct {
  2794. Cainfo interface{} `json:"cainfo"`
  2795. ErrMsg string `json:"err_msg"`
  2796. InfRefmsgid string `json:"inf_refmsgid"`
  2797. Infcode string `json:"infcode"`
  2798. Output struct {
  2799. } `json:"output"`
  2800. RefmsgTime string `json:"refmsg_time"`
  2801. RespondTime string `json:"respond_time"`
  2802. Signtype interface{} `json:"signtype"`
  2803. WarnMsg interface{} `json:"warn_msg"`
  2804. }
  2805. type ResultSeven struct {
  2806. Cainfo string `json:"cainfo"`
  2807. ErrMsg string `json:"err_msg"`
  2808. InfRefmsgid string `json:"inf_refmsgid"`
  2809. Infcode int64 `json:"infcode"`
  2810. Output struct {
  2811. Setldetail []interface{} `json:"setldetail"`
  2812. Setlinfo struct {
  2813. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2814. AcctPay float64 `json:"acct_pay"`
  2815. ActPayDedc float64 `json:"act_pay_dedc"`
  2816. Age float64 `json:"age"`
  2817. Balc float64 `json:"balc"`
  2818. Brdy string `json:"brdy"`
  2819. Certno string `json:"certno"`
  2820. ClrOptins string `json:"clr_optins"`
  2821. ClrType string `json:"clr_type"`
  2822. ClrWay string `json:"clr_way"`
  2823. CvlservFlag string `json:"cvlserv_flag"`
  2824. CvlservPay float64 `json:"cvlserv_pay"`
  2825. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2826. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2827. Gend string `json:"gend"`
  2828. HifesPay float64 `json:"hifes_pay"`
  2829. HifmiPay float64 `json:"hifmi_pay"`
  2830. HifpPay float64 `json:"hifp_pay"`
  2831. HospPartAmt float64 `json:"hosp_part_amt"`
  2832. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2833. Insutype string `json:"insutype"`
  2834. MafPay float64 `json:"maf_pay"`
  2835. MdtrtCertType string `json:"mdtrt_cert_type"`
  2836. HifobPay float64 `json:"hifob_pay"`
  2837. MdtrtID string `json:"mdtrt_id"`
  2838. MedType string `json:"med_type"`
  2839. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2840. MedinsSetlID string `json:"medins_setl_id"`
  2841. Naty string `json:"naty"`
  2842. OthPay float64 `json:"oth_pay"`
  2843. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2844. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2845. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2846. PsnCashPay float64 `json:"psn_cash_pay"`
  2847. PsnCertType string `json:"psn_cert_type"`
  2848. PsnName string `json:"psn_name"`
  2849. PsnNo string `json:"psn_no"`
  2850. PsnPartAmt float64 `json:"psn_part_amt"`
  2851. PsnType string `json:"psn_type"`
  2852. SetlID string `json:"setl_id"`
  2853. SetlTime string `json:"setl_time"`
  2854. } `json:"setlinfo"`
  2855. } `json:"output"`
  2856. RefmsgTime string `json:"refmsg_time"`
  2857. RespondTime string `json:"respond_time"`
  2858. Signtype interface{} `json:"signtype"`
  2859. WarnMsg interface{} `json:"warn_msg"`
  2860. }
  2861. type ResultSeven10265 struct {
  2862. Cainfo string `json:"cainfo"`
  2863. ErrMsg string `json:"err_msg"`
  2864. InfRefmsgid string `json:"inf_refmsgid"`
  2865. Infcode string `json:"infcode"`
  2866. Output struct {
  2867. Setldetail []interface{} `json:"setldetail"`
  2868. Setlinfo struct {
  2869. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2870. AcctPay float64 `json:"acct_pay"`
  2871. ActPayDedc float64 `json:"act_pay_dedc"`
  2872. Age float64 `json:"age"`
  2873. Balc float64 `json:"balc"`
  2874. Brdy string `json:"brdy"`
  2875. Certno string `json:"certno"`
  2876. ClrOptins string `json:"clr_optins"`
  2877. ClrType string `json:"clr_type"`
  2878. ClrWay string `json:"clr_way"`
  2879. CvlservFlag string `json:"cvlserv_flag"`
  2880. CvlservPay float64 `json:"cvlserv_pay"`
  2881. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2882. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2883. Gend string `json:"gend"`
  2884. HifesPay float64 `json:"hifes_pay"`
  2885. HifmiPay float64 `json:"hifmi_pay"`
  2886. HifpPay float64 `json:"hifp_pay"`
  2887. HospPartAmt float64 `json:"hosp_part_amt"`
  2888. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2889. Insutype string `json:"insutype"`
  2890. MafPay float64 `json:"maf_pay"`
  2891. MdtrtCertType string `json:"mdtrt_cert_type"`
  2892. HifobPay float64 `json:"hifob_pay"`
  2893. MdtrtID string `json:"mdtrt_id"`
  2894. MedType string `json:"med_type"`
  2895. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2896. MedinsSetlID string `json:"medins_setl_id"`
  2897. Naty string `json:"naty"`
  2898. OthPay float64 `json:"oth_pay"`
  2899. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2900. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2901. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2902. PsnCashPay float64 `json:"psn_cash_pay"`
  2903. PsnCertType string `json:"psn_cert_type"`
  2904. PsnName string `json:"psn_name"`
  2905. PsnNo string `json:"psn_no"`
  2906. PsnPartAmt float64 `json:"psn_part_amt"`
  2907. PsnType string `json:"psn_type"`
  2908. SetlID string `json:"setl_id"`
  2909. SetlTime string `json:"setl_time"`
  2910. } `json:"setlinfo"`
  2911. } `json:"output"`
  2912. RefmsgTime string `json:"refmsg_time"`
  2913. RespondTime string `json:"respond_time"`
  2914. Signtype interface{} `json:"signtype"`
  2915. WarnMsg interface{} `json:"warn_msg"`
  2916. }
  2917. type ResultEight struct {
  2918. Cainfo string `json:"cainfo"`
  2919. ErrMsg string `json:"err_msg"`
  2920. InfRefmsgid string `json:"inf_refmsgid"`
  2921. Infcode int64 `json:"infcode"`
  2922. Output struct {
  2923. Stmtinfo struct {
  2924. SetlOptins string `json:"setl_optins"`
  2925. StmtRslt string `json:"stmt_rslt"`
  2926. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2927. } `json:"stmtinfo"`
  2928. } `json:"output"`
  2929. RefmsgTime string `json:"refmsg_time"`
  2930. RespondTime string `json:"respond_time"`
  2931. Signtype interface{} `json:"signtype"`
  2932. WarnMsg interface{} `json:"warn_msg"`
  2933. }
  2934. type ResultEightFor10188 struct {
  2935. Cainfo string `json:"cainfo"`
  2936. ErrMsg string `json:"err_msg"`
  2937. InfRefmsgid string `json:"inf_refmsgid"`
  2938. Infcode string `json:"infcode"`
  2939. Output struct {
  2940. Stmtinfo struct {
  2941. SetlOptins string `json:"setl_optins"`
  2942. StmtRslt string `json:"stmt_rslt"`
  2943. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2944. } `json:"stmtinfo"`
  2945. } `json:"output"`
  2946. RefmsgTime string `json:"refmsg_time"`
  2947. RespondTime string `json:"respond_time"`
  2948. Signtype interface{} `json:"signtype"`
  2949. WarnMsg interface{} `json:"warn_msg"`
  2950. }
  2951. type ResultNine struct {
  2952. Cainfo string `json:"cainfo"`
  2953. ErrMsg string `json:"err_msg"`
  2954. InfRefmsgid string `json:"inf_refmsgid"`
  2955. Infcode int64 `json:"infcode"`
  2956. Output struct {
  2957. FileQuryNo string `json:"file_qury_no"`
  2958. } `json:"output"`
  2959. RefmsgTime string `json:"refmsg_time"`
  2960. RespondTime string `json:"respond_time"`
  2961. Signtype interface{} `json:"signtype"`
  2962. WarnMsg interface{} `json:"warn_msg"`
  2963. }
  2964. type ResultTen struct {
  2965. Cainfo string `json:"cainfo"`
  2966. ErrMsg string `json:"err_msg"`
  2967. InfRefmsgid string `json:"inf_refmsgid"`
  2968. Infcode int64 `json:"infcode"`
  2969. Output struct {
  2970. DldEndtime string `json:"dld_endtime"`
  2971. FileQuryNo string `json:"file_qury_no"`
  2972. Filename string `json:"filename"`
  2973. } `json:"output"`
  2974. RefmsgTime string `json:"refmsg_time"`
  2975. RespondTime string `json:"respond_time"`
  2976. Signtype interface{} `json:"signtype"`
  2977. WarnMsg interface{} `json:"warn_msg"`
  2978. }
  2979. //type Autogenerated struct {
  2980. // Output struct {
  2981. // Setlinfo struct {
  2982. // SetlTime string `json:"setl_time"`
  2983. // CvlservPay float64 `json:"cvlserv_pay"`
  2984. // Year string `json:"year"`
  2985. // MedType string `json:"med_type"`
  2986. // PsnPay float64 `json:"psn_pay"`
  2987. // OpterID string `json:"opter_id"`
  2988. // Begndate string `json:"begndate"`
  2989. // FlxempeFlag string `json:"flxempe_flag"`
  2990. // HifmiPay float64 `json:"hifmi_pay"`
  2991. // PsnNo string `json:"psn_no"`
  2992. // ActPayDedc float64 `json:"act_pay_dedc"`
  2993. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2994. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2995. // ClrWay string `json:"clr_way"`
  2996. // OthPay float64 `json:"oth_pay"`
  2997. // Gend string `json:"gend"`
  2998. // MdtrtID string `json:"mdtrt_id"`
  2999. // AcctPay float64 `json:"acct_pay"`
  3000. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3001. // Insutype string `json:"insutype"`
  3002. // Invono interface{} `json:"invono"`
  3003. // Enddate string `json:"enddate"`
  3004. // CashPayamt float64 `json:"cash_payamt"`
  3005. // PsnType string `json:"psn_type"`
  3006. // FixmedinsName string `json:"fixmedins_name"`
  3007. // HifpPay float64 `json:"hifp_pay"`
  3008. // NewFlag interface{} `json:"new_flag"`
  3009. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3010. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3011. // PayLoc string `json:"pay_loc"`
  3012. // ClrType string `json:"clr_type"`
  3013. // RefdSetlFlag string `json:"refd_setl_flag"`
  3014. // CvlservFlag string `json:"cvlserv_flag"`
  3015. // EmpName string `json:"emp_name"`
  3016. // Brdy string `json:"brdy"`
  3017. // Naty string `json:"naty"`
  3018. // Certno string `json:"certno"`
  3019. // DiseCode string `json:"dise_code"`
  3020. // FixmedinsCode string `json:"fixmedins_code"`
  3021. // DedcHospLv string `json:"dedc_hosp_lv"`
  3022. // OpterName string `json:"opter_name"`
  3023. // Balc float64 `json:"balc"`
  3024. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3025. // PsnCertType string `json:"psn_cert_type"`
  3026. // HifobPay float64 `json:"hifob_pay"`
  3027. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3028. // HifesPay float64 `json:"hifes_pay"`
  3029. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3030. // OptTime string `json:"opt_time"`
  3031. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3032. // SetlID string `json:"setl_id"`
  3033. // MafPay float64 `json:"maf_pay"`
  3034. // PsnName string `json:"psn_name"`
  3035. // InsuOptins interface{} `json:"insu_optins"`
  3036. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3037. // ClrOptins string `json:"clr_optins"`
  3038. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3039. // DiseName string `json:"dise_name"`
  3040. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3041. // Age float64 `json:"age"`
  3042. // DtrtCertType string `json:"dtrt_cert_type"`
  3043. // HospLv string `json:"hosp_lv"`
  3044. // } `json:"setlinfo"`
  3045. // Setldetail []struct {
  3046. // FundPayType string `json:"fund_pay_type"`
  3047. // FundPayamt float64 `json:"fund_payamt"`
  3048. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3049. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3050. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3051. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3052. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3053. // } `json:"setldetail"`
  3054. // } `json:"output"`
  3055. // Infcode int `json:"infcode"`
  3056. // WarnMsg interface{} `json:"warn_msg"`
  3057. // Cainfo interface{} `json:"cainfo"`
  3058. // ErrMsg interface{} `json:"err_msg"`
  3059. // RefmsgTime string `json:"refmsg_time"`
  3060. // Signtype interface{} `json:"signtype"`
  3061. // RespondTime string `json:"respond_time"`
  3062. // InfRefmsgid string `json:"inf_refmsgid"`
  3063. //}
  3064. type ResultEleven struct {
  3065. Cainfo string `json:"cainfo"`
  3066. ErrMsg string `json:"err_msg"`
  3067. InfRefmsgid string `json:"inf_refmsgid"`
  3068. Infcode int64 `json:"infcode"`
  3069. Output struct {
  3070. Setlinfo struct {
  3071. SetlTime string `json:"setl_time"`
  3072. CvlservPay float64 `json:"cvlserv_pay"`
  3073. Year string `json:"year"`
  3074. MedType string `json:"med_type"`
  3075. PsnPay float64 `json:"psn_pay"`
  3076. OpterID string `json:"opter_id"`
  3077. Begndate string `json:"begndate"`
  3078. FlxempeFlag string `json:"flxempe_flag"`
  3079. HifmiPay float64 `json:"hifmi_pay"`
  3080. PsnNo string `json:"psn_no"`
  3081. ActPayDedc float64 `json:"act_pay_dedc"`
  3082. MedinsSetlID interface{} `json:"medins_setl_id"`
  3083. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3084. ClrWay string `json:"clr_way"`
  3085. OthPay float64 `json:"oth_pay"`
  3086. Gend string `json:"gend"`
  3087. MdtrtID string `json:"mdtrt_id"`
  3088. AcctPay float64 `json:"acct_pay"`
  3089. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3090. Insutype string `json:"insutype"`
  3091. Invono interface{} `json:"invono"`
  3092. Enddate string `json:"enddate"`
  3093. CashPayamt float64 `json:"cash_payamt"`
  3094. PsnType string `json:"psn_type"`
  3095. FixmedinsName string `json:"fixmedins_name"`
  3096. HifpPay float64 `json:"hifp_pay"`
  3097. NewFlag interface{} `json:"new_flag"`
  3098. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3099. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3100. PayLoc string `json:"pay_loc"`
  3101. ClrType string `json:"clr_type"`
  3102. RefdSetlFlag string `json:"refd_setl_flag"`
  3103. CvlservFlag string `json:"cvlserv_flag"`
  3104. EmpName string `json:"emp_name"`
  3105. Brdy string `json:"brdy"`
  3106. Naty string `json:"naty"`
  3107. Certno string `json:"certno"`
  3108. DiseCode string `json:"dise_code"`
  3109. FixmedinsCode string `json:"fixmedins_code"`
  3110. DedcHospLv string `json:"dedc_hosp_lv"`
  3111. OpterName string `json:"opter_name"`
  3112. Balc float64 `json:"balc"`
  3113. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3114. PsnCertType string `json:"psn_cert_type"`
  3115. HifobPay float64 `json:"hifob_pay"`
  3116. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3117. HifesPay float64 `json:"hifes_pay"`
  3118. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3119. OptTime string `json:"opt_time"`
  3120. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3121. SetlID string `json:"setl_id"`
  3122. MafPay float64 `json:"maf_pay"`
  3123. PsnName string `json:"psn_name"`
  3124. InsuOptins interface{} `json:"insu_optins"`
  3125. PrefFundPay interface{} `json:"pref_fund_pay"`
  3126. ClrOptins string `json:"clr_optins"`
  3127. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3128. DiseName string `json:"dise_name"`
  3129. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3130. Age float64 `json:"age"`
  3131. DtrtCertType string `json:"dtrt_cert_type"`
  3132. HospLv string `json:"hosp_lv"`
  3133. } `json:"setlinfo"`
  3134. } `json:"output"`
  3135. RefmsgTime string `json:"refmsg_time"`
  3136. RespondTime string `json:"respond_time"`
  3137. Signtype interface{} `json:"signtype"`
  3138. WarnMsg interface{} `json:"warn_msg"`
  3139. }
  3140. type ResultEleven10265 struct {
  3141. Cainfo string `json:"cainfo"`
  3142. ErrMsg string `json:"err_msg"`
  3143. InfRefmsgid string `json:"inf_refmsgid"`
  3144. Infcode string `json:"infcode"`
  3145. Output struct {
  3146. Setlinfo struct {
  3147. SetlTime string `json:"setl_time"`
  3148. CvlservPay float64 `json:"cvlserv_pay"`
  3149. Year string `json:"year"`
  3150. MedType string `json:"med_type"`
  3151. PsnPay float64 `json:"psn_pay"`
  3152. OpterID string `json:"opter_id"`
  3153. Begndate string `json:"begndate"`
  3154. FlxempeFlag string `json:"flxempe_flag"`
  3155. HifmiPay float64 `json:"hifmi_pay"`
  3156. PsnNo string `json:"psn_no"`
  3157. ActPayDedc float64 `json:"act_pay_dedc"`
  3158. MedinsSetlID interface{} `json:"medins_setl_id"`
  3159. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3160. ClrWay string `json:"clr_way"`
  3161. OthPay float64 `json:"oth_pay"`
  3162. Gend string `json:"gend"`
  3163. MdtrtID string `json:"mdtrt_id"`
  3164. AcctPay float64 `json:"acct_pay"`
  3165. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3166. Insutype string `json:"insutype"`
  3167. Invono interface{} `json:"invono"`
  3168. Enddate string `json:"enddate"`
  3169. CashPayamt float64 `json:"cash_payamt"`
  3170. PsnType string `json:"psn_type"`
  3171. FixmedinsName string `json:"fixmedins_name"`
  3172. HifpPay float64 `json:"hifp_pay"`
  3173. NewFlag interface{} `json:"new_flag"`
  3174. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3175. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3176. PayLoc string `json:"pay_loc"`
  3177. ClrType string `json:"clr_type"`
  3178. RefdSetlFlag string `json:"refd_setl_flag"`
  3179. CvlservFlag string `json:"cvlserv_flag"`
  3180. EmpName string `json:"emp_name"`
  3181. Brdy string `json:"brdy"`
  3182. Naty string `json:"naty"`
  3183. Certno string `json:"certno"`
  3184. DiseCode string `json:"dise_code"`
  3185. FixmedinsCode string `json:"fixmedins_code"`
  3186. DedcHospLv string `json:"dedc_hosp_lv"`
  3187. OpterName string `json:"opter_name"`
  3188. Balc float64 `json:"balc"`
  3189. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3190. PsnCertType string `json:"psn_cert_type"`
  3191. HifobPay float64 `json:"hifob_pay"`
  3192. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3193. HifesPay float64 `json:"hifes_pay"`
  3194. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3195. OptTime string `json:"opt_time"`
  3196. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3197. SetlID string `json:"setl_id"`
  3198. MafPay float64 `json:"maf_pay"`
  3199. PsnName string `json:"psn_name"`
  3200. InsuOptins interface{} `json:"insu_optins"`
  3201. PrefFundPay interface{} `json:"pref_fund_pay"`
  3202. ClrOptins string `json:"clr_optins"`
  3203. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3204. DiseName string `json:"dise_name"`
  3205. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3206. Age float64 `json:"age"`
  3207. DtrtCertType string `json:"dtrt_cert_type"`
  3208. HospLv string `json:"hosp_lv"`
  3209. } `json:"setlinfo"`
  3210. } `json:"output"`
  3211. RefmsgTime string `json:"refmsg_time"`
  3212. RespondTime string `json:"respond_time"`
  3213. Signtype interface{} `json:"signtype"`
  3214. WarnMsg interface{} `json:"warn_msg"`
  3215. }
  3216. type ResultTwelve struct {
  3217. Cainfo string `json:"cainfo"`
  3218. ErrMsg string `json:"err_msg"`
  3219. InfRefmsgid string `json:"inf_refmsgid"`
  3220. Infcode int64 `json:"infcode"`
  3221. Output struct {
  3222. MdtrtId string `json:"mdtrt_id"`
  3223. ChrgBchno string `json:"chrg_bchno"`
  3224. PsnNo string `json:"psn_no"`
  3225. } `json:"output"`
  3226. RefmsgTime string `json:"refmsg_time"`
  3227. RespondTime string `json:"respond_time"`
  3228. Signtype interface{} `json:"signtype"`
  3229. WarnMsg interface{} `json:"warn_msg"`
  3230. }
  3231. type ResultThirteen struct {
  3232. ErrMsg string `json:"err_msg"`
  3233. InfRefmsgid string `json:"inf_refmsgid"`
  3234. Infcode int64 `json:"infcode"`
  3235. Output struct {
  3236. Result struct {
  3237. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3238. } `json:"result"`
  3239. } `json:"output"`
  3240. RefmsgTime string `json:"refmsg_time"`
  3241. RespondTime string `json:"respond_time"`
  3242. Signtype interface{} `json:"signtype"`
  3243. WarnInfo interface{} `json:"warn_info"`
  3244. }
  3245. type ResultThirteen10265 struct {
  3246. ErrMsg string `json:"err_msg"`
  3247. InfRefmsgid string `json:"inf_refmsgid"`
  3248. Infcode string `json:"infcode"`
  3249. Output struct {
  3250. Result struct {
  3251. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3252. } `json:"result"`
  3253. } `json:"output"`
  3254. RefmsgTime string `json:"refmsg_time"`
  3255. RespondTime string `json:"respond_time"`
  3256. Signtype interface{} `json:"signtype"`
  3257. WarnInfo interface{} `json:"warn_info"`
  3258. }
  3259. type ResultFourteen struct {
  3260. ErrMsg string `json:"err_msg"`
  3261. InfRefmsgid string `json:"inf_refmsgid"`
  3262. Infcode int64 `json:"infcode"`
  3263. Output struct {
  3264. } `json:"output"`
  3265. RefmsgTime string `json:"refmsg_time"`
  3266. RespondTime string `json:"respond_time"`
  3267. Signtype interface{} `json:"signtype"`
  3268. WarnInfo interface{} `json:"warn_info"`
  3269. }
  3270. type ResultFourteen10265 struct {
  3271. ErrMsg string `json:"err_msg"`
  3272. InfRefmsgid string `json:"inf_refmsgid"`
  3273. Infcode string `json:"infcode"`
  3274. Output struct {
  3275. } `json:"output"`
  3276. RefmsgTime string `json:"refmsg_time"`
  3277. RespondTime string `json:"respond_time"`
  3278. Signtype interface{} `json:"signtype"`
  3279. WarnInfo interface{} `json:"warn_info"`
  3280. }
  3281. type ResultSixteen struct {
  3282. Cainfo string `json:"cainfo"`
  3283. ErrMsg string `json:"err_msg"`
  3284. InfRefmsgid string `json:"inf_refmsgid"`
  3285. Infcode int64 `json:"infcode"`
  3286. Output struct {
  3287. Setldetail []interface{} `json:"setldetail"`
  3288. Setlinfo struct {
  3289. MdtrtID string `json:"mdtrt_id"`
  3290. SetlID string `json:"setl_id"`
  3291. ClrOptins string `json:"clr_optins"`
  3292. SetlTime string `json:"setl_time"`
  3293. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3294. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3295. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3296. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3297. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3298. ActPayDedc float64 `json:"act_pay_dedc"`
  3299. HifpPay float64 `json:"hifp_pay"`
  3300. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3301. Lfpay float64 `json:"selfpay"`
  3302. CvlservPay float64 `json:"cvlserv_pay"`
  3303. HifesPay float64 `json:"hifes_pay"`
  3304. HifmiPay float64 `json:"hifmi_pay"`
  3305. HifobPay float64 `json:"hifob_pay"`
  3306. MafPay float64 `json:"maf_pay"`
  3307. OthPay float64 `json:"oth_pay"`
  3308. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3309. PsnPartAmt float64 `json:"psn_part_amt"`
  3310. AcctPay float64 `json:"acct_pay"`
  3311. Balc float64 `json:"balc"`
  3312. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3313. HospPartAmt float64 `json:"hosp_part_amt"`
  3314. MedinsSetlID string `json:"medins_setl_id"`
  3315. PdnCashPay string `json:"pdn_cash_pay"`
  3316. } `json:"setlinfo"`
  3317. } `json:"output"`
  3318. RefmsgTime string `json:"refmsg_time"`
  3319. RespondTime string `json:"respond_time"`
  3320. Signtype interface{} `json:"signtype"`
  3321. WarnMsg interface{} `json:"warn_msg"`
  3322. }
  3323. type ResultSixteen10265 struct {
  3324. Cainfo string `json:"cainfo"`
  3325. ErrMsg string `json:"err_msg"`
  3326. InfRefmsgid string `json:"inf_refmsgid"`
  3327. Infcode string `json:"infcode"`
  3328. Output struct {
  3329. Setldetail []interface{} `json:"setldetail"`
  3330. Setlinfo struct {
  3331. MdtrtID string `json:"mdtrt_id"`
  3332. SetlID string `json:"setl_id"`
  3333. ClrOptins string `json:"clr_optins"`
  3334. SetlTime string `json:"setl_time"`
  3335. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3336. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3337. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3338. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3339. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3340. ActPayDedc float64 `json:"act_pay_dedc"`
  3341. HifpPay float64 `json:"hifp_pay"`
  3342. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3343. Lfpay float64 `json:"selfpay"`
  3344. CvlservPay float64 `json:"cvlserv_pay"`
  3345. HifesPay float64 `json:"hifes_pay"`
  3346. HifmiPay float64 `json:"hifmi_pay"`
  3347. HifobPay float64 `json:"hifob_pay"`
  3348. MafPay float64 `json:"maf_pay"`
  3349. OthPay float64 `json:"oth_pay"`
  3350. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3351. PsnPartAmt float64 `json:"psn_part_amt"`
  3352. AcctPay float64 `json:"acct_pay"`
  3353. Balc float64 `json:"balc"`
  3354. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3355. HospPartAmt float64 `json:"hosp_part_amt"`
  3356. MedinsSetlID string `json:"medins_setl_id"`
  3357. PdnCashPay string `json:"pdn_cash_pay"`
  3358. } `json:"setlinfo"`
  3359. } `json:"output"`
  3360. RefmsgTime string `json:"refmsg_time"`
  3361. RespondTime string `json:"respond_time"`
  3362. Signtype interface{} `json:"signtype"`
  3363. WarnMsg interface{} `json:"warn_msg"`
  3364. }
  3365. type ResultSeventeen struct {
  3366. ErrMsg string `json:"err_msg"`
  3367. InfRefmsgid string `json:"inf_refmsgid"`
  3368. Infcode int64 `json:"infcode"`
  3369. Output struct {
  3370. SetlListId string `json:"setl_list_id"`
  3371. } `json:"output"`
  3372. RefmsgTime string `json:"refmsg_time"`
  3373. RespondTime string `json:"respond_time"`
  3374. Signtype string `json:"signtype"`
  3375. WarnInfo string `json:"warn_info"`
  3376. }
  3377. type Result90991 struct {
  3378. ErrMsg string `json:"err_msg"`
  3379. InfRefmsgid string `json:"inf_refmsgid"`
  3380. Infcode int64 `json:"infcode"`
  3381. Output struct {
  3382. Result struct {
  3383. PsnNo string `json:"psn_no"`
  3384. CardStat string `json:"card_stat"`
  3385. Certno string `json:"certno"`
  3386. PsnName string `json:"psn_name"`
  3387. CheckStat string `json:"check_stat"`
  3388. } `json:"result"`
  3389. } `json:"output"`
  3390. RefmsgTime string `json:"refmsg_time"`
  3391. RespondTime string `json:"respond_time"`
  3392. Signtype interface{} `json:"signtype"`
  3393. WarnInfo interface{} `json:"warn_info"`
  3394. }
  3395. type Result90100 struct {
  3396. ErrMsg string `json:"err_msg"`
  3397. InfRefmsgid string `json:"inf_refmsgid"`
  3398. Infcode int64 `json:"infcode"`
  3399. Output struct {
  3400. PoolareaNo string `json:"poolarea_no"`
  3401. PoolareaNoName string `json:"poolarea_no_name"`
  3402. Insutype string `json:"insutype"`
  3403. InsutypeName string `json:"insutype_name"`
  3404. ClctType string `json:"clct_type"`
  3405. ClctTypeName string `json:"clct_type_name"`
  3406. ClctFlag string `json:"clct_flag"`
  3407. ClctFlagName string `json:"clct_flag_name"`
  3408. AccrymBegn string `json:"accrym_begn"`
  3409. AccrymEnd string `json:"accrym_end"`
  3410. ClctTime string `json:"clct_time"`
  3411. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3412. } `json:"output"`
  3413. RefmsgTime string `json:"refmsg_time"`
  3414. RespondTime string `json:"respond_time"`
  3415. Signtype interface{} `json:"signtype"`
  3416. WarnInfo interface{} `json:"warn_info"`
  3417. }
  3418. type Custom struct {
  3419. DetItemFeeSumamt string
  3420. Cut string
  3421. FeedetlSn string
  3422. Price string
  3423. MedListCodg string
  3424. Type int64
  3425. AdviceId int64
  3426. ProjectId int64
  3427. ItemId int64
  3428. }
  3429. type Result5301 struct {
  3430. ErrMsg string `json:"err_msg"`
  3431. InfRefmsgid string `json:"inf_refmsgid"`
  3432. Infcode int64 `json:"infcode"`
  3433. Output struct {
  3434. Result []struct {
  3435. OpspDiseCode string `json:"opsp_dise_code"`
  3436. OpspDiseName string `json:"opsp_dise_name"`
  3437. Begndate string `json:"begndate"`
  3438. Enddate string `json:"enddate"`
  3439. } `json:"feedetail"`
  3440. } `json:"output"`
  3441. RefmsgTime string `json:"refmsg_time"`
  3442. RespondTime string `json:"respond_time"`
  3443. Signtype interface{} `json:"signtype"`
  3444. WarnInfo interface{} `json:"warn_info"`
  3445. }
  3446. type Result5301For10265 struct {
  3447. ErrMsg string `json:"err_msg"`
  3448. InfRefmsgid string `json:"inf_refmsgid"`
  3449. Infcode string `json:"infcode"`
  3450. Output struct {
  3451. Result []struct {
  3452. OpspDiseCode string `json:"opsp_dise_code"`
  3453. OpspDiseName string `json:"opsp_dise_name"`
  3454. Begndate string `json:"begndate"`
  3455. Enddate string `json:"enddate"`
  3456. } `json:"feedetail"`
  3457. } `json:"output"`
  3458. RefmsgTime string `json:"refmsg_time"`
  3459. RespondTime string `json:"respond_time"`
  3460. Signtype interface{} `json:"signtype"`
  3461. WarnInfo interface{} `json:"warn_info"`
  3462. }
  3463. //获取个人信息----挂号-----上传就诊信息
  3464. func (c *HisApiController) GetRegisterInfo() {
  3465. id, _ := c.GetInt64("id")
  3466. record_time := c.GetString("record_time")
  3467. settlementValue, _ := c.GetInt64("settlement_value")
  3468. medical_insurance_card := c.GetString("medical_insurance_card")
  3469. name := c.GetString("name")
  3470. id_card_type, _ := c.GetInt64("id_card_type")
  3471. certificates, _ := c.GetInt64("certificates")
  3472. medical_care, _ := c.GetInt64("medical_care")
  3473. birthday := c.GetString("birthday")
  3474. id_card := c.GetString("id_card")
  3475. register_type, _ := c.GetInt64("register")
  3476. doctor, _ := c.GetInt64("doctor")
  3477. department, _ := c.GetInt64("department")
  3478. gender, _ := c.GetInt64("sex")
  3479. registration_fee, _ := c.GetFloat("registration_fee")
  3480. medical_expenses, _ := c.GetFloat("medical_expenses")
  3481. social_type, _ := c.GetInt64("social_type")
  3482. med_type := c.GetString("social_type")
  3483. admin_user_id, _ := c.GetInt64("admin_user_id")
  3484. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3485. timeLayout := "2006-01-02"
  3486. loc, _ := time.LoadLocation("Local")
  3487. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3488. birthUnix := birthdays.Unix()
  3489. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3490. if err != nil {
  3491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3492. return
  3493. }
  3494. recordDateTime := theTime.Unix()
  3495. adminInfo := c.GetAdminUserInfo()
  3496. var patient service.Patients
  3497. if id == 0 {
  3498. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3499. } else {
  3500. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3501. }
  3502. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3503. if patientPrescription.ID == 0 {
  3504. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3505. }
  3506. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3507. if patient.ID == 0 {
  3508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3509. return
  3510. }
  3511. if len(patient.IdCardNo) == 0 {
  3512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3513. return
  3514. }
  3515. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3516. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3517. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3518. //就诊结算未完成,不能进行二次挂号
  3519. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3520. if len(his) >= 1 {
  3521. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3522. if len(his) >= 1 && order.ID == 0 {
  3523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3524. return
  3525. }
  3526. }
  3527. //var register_log string
  3528. if config.IsOpen == 1 {
  3529. var res ResultTwo
  3530. var res10265 ResultTwo10265
  3531. var PsnNo string
  3532. var PsnCertType string
  3533. var Certno string
  3534. var PsnName string
  3535. var Gend string
  3536. var Naty string
  3537. var Brdy string
  3538. var Age float64
  3539. var infoStr string
  3540. var idetinfoStr string
  3541. var infocode int64
  3542. var verify_number string
  3543. fmt.Println(verify_number)
  3544. if miConfig.MdtrtareaAdmvs == "421300" {
  3545. psn_info, _ := service.GetPsnByPatientId(id)
  3546. PsnNo = psn_info.PsnNo
  3547. PsnCertType = psn_info.PsnCertType
  3548. Certno = psn_info.Certno
  3549. PsnName = psn_info.PsnName
  3550. Gend = psn_info.Gend
  3551. Naty = psn_info.Naty
  3552. Brdy = psn_info.Brdy
  3553. Age = psn_info.Age
  3554. infoStr = psn_info.Insuinfo
  3555. idetinfoStr = psn_info.Idetinfo
  3556. infocode = 0
  3557. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3558. psn_info, _ := service.GetPsnByPatientId(id)
  3559. PsnNo = psn_info.PsnNo
  3560. PsnCertType = psn_info.PsnCertType
  3561. Certno = psn_info.Certno
  3562. PsnName = psn_info.PsnName
  3563. Gend = psn_info.Gend
  3564. Naty = psn_info.Naty
  3565. Brdy = psn_info.Brdy
  3566. Age = psn_info.Age
  3567. infoStr = psn_info.Insuinfo
  3568. idetinfoStr = psn_info.Idetinfo
  3569. infocode = 0
  3570. verify_number = psn_info.VerifyNumber
  3571. } else {
  3572. var result string
  3573. var requestLog string
  3574. if miConfig.UserOrgId == 10138 {
  3575. 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)
  3576. } else {
  3577. 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)
  3578. }
  3579. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3580. if miConfig.Code == "H15049901371" {
  3581. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3582. utils.ErrorLog("解析失败:%v", err)
  3583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3584. return
  3585. }
  3586. res.ErrMsg = res10265.ErrMsg
  3587. res.Output = res10265.Output
  3588. res.InfRefmsgid = res10265.InfRefmsgid
  3589. } else {
  3590. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3591. utils.ErrorLog("解析失败:%v", err)
  3592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3593. return
  3594. }
  3595. }
  3596. PsnNo = res.Output.Baseinfo.PsnNo
  3597. PsnCertType = res.Output.Baseinfo.PsnCertType
  3598. Certno = res.Output.Baseinfo.Certno
  3599. PsnName = res.Output.Baseinfo.PsnName
  3600. Gend = res.Output.Baseinfo.Gend
  3601. Naty = res.Output.Baseinfo.Naty
  3602. Brdy = res.Output.Baseinfo.Brdy
  3603. Age = res.Output.Baseinfo.Age
  3604. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3605. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3606. infoStr = string(Iinfos)
  3607. idetinfoStr = string(Idetinfos)
  3608. if miConfig.Code == "H15049901371" {
  3609. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3610. } else {
  3611. infocode = res.Infcode
  3612. }
  3613. }
  3614. if infocode == 0 {
  3615. his := models.VMHisPatient{
  3616. Name: name,
  3617. Gender: gender,
  3618. Birthday: birthUnix,
  3619. MedicalTreatmentType: medical_care,
  3620. IdType: certificates,
  3621. IdCardNo: id_card,
  3622. BalanceAccountsType: settlementValue,
  3623. SocialType: social_type,
  3624. MedicalInsuranceNumber: medical_insurance_card,
  3625. RegisterType: register_type,
  3626. RegisterCost: registration_fee,
  3627. TreatmentCost: medical_expenses,
  3628. Status: 1,
  3629. Ctime: time.Now().Unix(),
  3630. Mtime: time.Now().Unix(),
  3631. PsnNo: PsnNo,
  3632. PsnCertType: PsnCertType,
  3633. Certno: Certno,
  3634. PsnName: PsnName,
  3635. Gend: Gend,
  3636. Naty: Naty,
  3637. Brdy: Brdy,
  3638. Age: Age,
  3639. Iinfo: infoStr,
  3640. Idetinfo: idetinfoStr,
  3641. PatientId: patient.ID,
  3642. RecordDate: theTime.Unix(),
  3643. UserOrgId: adminInfo.CurrentOrgId,
  3644. AdminUserId: admin_user_id,
  3645. IsReturn: 1,
  3646. IdCardType: id_card_type,
  3647. Doctor: doctor,
  3648. Departments: department,
  3649. }
  3650. timestamp := time.Now().Unix()
  3651. tempTime := time.Unix(timestamp, 0)
  3652. timeFormat := tempTime.Format("20060102150405")
  3653. chrgBchno := rand.Intn(100000) + 10000
  3654. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3655. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3656. department, _ := service.GetDepartMentDetail(department)
  3657. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3658. IdCardNo := ""
  3659. if id_card_type == 1 {
  3660. // IdCardNo = medical_insurance_card
  3661. IdCardNo = patient.IdCardNo
  3662. } else {
  3663. IdCardNo = patient.IdCardNo
  3664. }
  3665. var rf []*ResultFive
  3666. json.Unmarshal([]byte(his.Iinfo), &rf)
  3667. var insutypes []*ResultFive
  3668. var insutype string
  3669. var insuplc_admdvs_temp string
  3670. var is390 int = 0
  3671. var is310 int = 0
  3672. for _, item := range rf {
  3673. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3674. insutypes = append(insutypes, item)
  3675. }
  3676. }
  3677. if len(insutypes) == 1 {
  3678. insutype = insutypes[0].Insutype
  3679. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3680. } else {
  3681. for _, i := range insutypes {
  3682. if i.Insutype == "390" {
  3683. is390 = 1
  3684. }
  3685. if i.Insutype == "310" {
  3686. is310 = 1
  3687. }
  3688. }
  3689. }
  3690. if is390 == 1 {
  3691. insutype = "390"
  3692. }
  3693. if is310 == 1 {
  3694. insutype = "310"
  3695. }
  3696. if len(insutypes) == 0 {
  3697. insutype = "310"
  3698. }
  3699. if len(insutypes) == 2 {
  3700. insutype = med_type
  3701. }
  3702. if len(med_type) > 0 {
  3703. insutype = med_type
  3704. }
  3705. //for _, item := range rf {
  3706. // if item.Insutype == insutype {
  3707. // insuplc_admdvs = item.InsuplcAdmdvs
  3708. // }
  3709. //}
  3710. var infocode int64
  3711. var resThree ResultThree
  3712. var resThree10265 ResultThree10265
  3713. if len(insuplc_admdvs) == 0 {
  3714. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3715. } else {
  3716. insuplc_admdvs_temp = insuplc_admdvs
  3717. }
  3718. if miConfig.MdtrtareaAdmvs == "421300" {
  3719. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3720. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3721. "&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_id + "&doctor_name=" + doctor_info.UserName
  3722. resp, requestErr := http.Get(api)
  3723. if requestErr != nil {
  3724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3725. return
  3726. }
  3727. body, ioErr := ioutil.ReadAll(resp.Body)
  3728. if ioErr != nil {
  3729. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3731. return
  3732. }
  3733. var respJSON map[string]interface{}
  3734. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3735. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3737. return
  3738. }
  3739. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3740. result, _ := json.Marshal(respJSON)
  3741. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3742. utils.ErrorLog("解析失败:%v", err)
  3743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3744. return
  3745. }
  3746. infocode = resThree.Infcode
  3747. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3748. psn_info, _ := service.GetPsnByPatientId(id)
  3749. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3750. var cert_no string
  3751. if id_card_type == 3 {
  3752. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  3753. cert_no = IdCardNo
  3754. } else {
  3755. bas := strings.Split(psn_info.CardInfo, "|")
  3756. cert_no = bas[2]
  3757. }
  3758. var api string
  3759. if miConfig.MdtrtareaAdmvs == "320921" {
  3760. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3761. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3762. "&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_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3763. } else {
  3764. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3765. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3766. "&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_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3767. }
  3768. resp, requestErr := http.Get(api)
  3769. if requestErr != nil {
  3770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3771. return
  3772. }
  3773. body, ioErr := ioutil.ReadAll(resp.Body)
  3774. if ioErr != nil {
  3775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3777. return
  3778. }
  3779. var respJSON map[string]interface{}
  3780. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3783. return
  3784. }
  3785. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3786. result, _ := json.Marshal(respJSON)
  3787. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3788. utils.ErrorLog("解析失败:%v", err)
  3789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3790. return
  3791. }
  3792. resThree.ErrMsg = resThree10265.ErrMsg
  3793. resThree.Output = resThree10265.Output
  3794. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3795. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3796. } else {
  3797. result, requestLog := service.Gdyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  3798. saveLog(result, requestLog, "2201", "挂号")
  3799. if miConfig.Code == "H15049901371" {
  3800. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3801. utils.ErrorLog("解析失败:%v", err)
  3802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3803. return
  3804. }
  3805. resThree.ErrMsg = resThree10265.ErrMsg
  3806. resThree.Output = resThree10265.Output
  3807. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3808. } else {
  3809. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3810. utils.ErrorLog("解析失败:%v", err)
  3811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3812. return
  3813. }
  3814. }
  3815. if miConfig.Code == "H15049901371" {
  3816. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3817. } else {
  3818. infocode = resThree.Infcode
  3819. }
  3820. }
  3821. if infocode != 0 {
  3822. adminUser := c.GetAdminUserInfo()
  3823. errlog := &models.HisOrderError{
  3824. UserOrgId: adminUser.CurrentOrgId,
  3825. Ctime: time.Now().Unix(),
  3826. Mtime: time.Now().Unix(),
  3827. ErrMsg: resThree.ErrMsg,
  3828. Status: 1,
  3829. PatientId: id,
  3830. RecordTime: recordDateTime,
  3831. Stage: 2,
  3832. }
  3833. service.CreateErrMsgLog(errlog)
  3834. c.ServeSuccessJSON(map[string]interface{}{
  3835. "failed_code": -10,
  3836. "msg": resThree.ErrMsg,
  3837. })
  3838. return
  3839. }
  3840. his.Number = resThree.Output.Data.MdtrtID
  3841. his.PsnNo = resThree.Output.Data.PsnNo
  3842. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3843. his.IdCardNo = patient.IdCardNo
  3844. his.PhoneNumber = patient.Phone
  3845. his.UserOrgId = adminInfo.CurrentOrgId
  3846. his.Insutype = insutype
  3847. his.Ctime = time.Now().Unix()
  3848. his.Mtime = time.Now().Unix()
  3849. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3850. his.Status = 1
  3851. service.UpdateHisPatientStatus(&his)
  3852. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3853. c.ServeSuccessJSON(map[string]interface{}{
  3854. "his_info": his,
  3855. })
  3856. } else {
  3857. adminUser := c.GetAdminUserInfo()
  3858. errlog := &models.HisOrderError{
  3859. UserOrgId: adminUser.CurrentOrgId,
  3860. Ctime: time.Now().Unix(),
  3861. Mtime: time.Now().Unix(),
  3862. ErrMsg: res.ErrMsg,
  3863. Status: 1,
  3864. PatientId: id,
  3865. RecordTime: recordDateTime,
  3866. Stage: 1,
  3867. }
  3868. service.CreateErrMsgLog(errlog)
  3869. c.ServeSuccessJSON(map[string]interface{}{
  3870. "failed_code": -10,
  3871. "msg": res.ErrMsg,
  3872. })
  3873. return
  3874. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3875. }
  3876. }
  3877. }
  3878. //上传明细----预结算----确认订单
  3879. func (c *HisApiController) GetUploadInfo() {
  3880. id, _ := c.GetInt64("id")
  3881. record_time := c.GetString("record_time")
  3882. his_patient_id, _ := c.GetInt64("his_patient_id")
  3883. order_id, _ := c.GetInt64("order_id")
  3884. pay_way, _ := c.GetInt64("pay_way")
  3885. pay_price, _ := c.GetFloat("pay_price")
  3886. pay_card_no := c.GetString("pay_card_no")
  3887. discount_price, _ := c.GetFloat("discount_price")
  3888. preferential_price, _ := c.GetFloat("preferential_price")
  3889. reality_price, _ := c.GetFloat("reality_price")
  3890. found_price, _ := c.GetFloat("found_price")
  3891. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3892. private_price, _ := c.GetFloat("private_price")
  3893. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3894. admin_user_id, _ := c.GetInt64("admin_user_id")
  3895. fapiao_code := c.GetString("fapiao_code")
  3896. fapiao_number := c.GetString("fapiao_number")
  3897. diagnosis_id := c.GetString("diagnosis")
  3898. sick_type, _ := c.GetInt64("sick_type")
  3899. reg_type, _ := c.GetInt64("p_type")
  3900. begin_time := c.GetString("begin_time")
  3901. id_str := c.GetString("ids")
  3902. ids_arr := strings.Split(id_str, ",")
  3903. timeLayout := "2006-01-02"
  3904. loc, _ := time.LoadLocation("Local")
  3905. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3906. if err != nil {
  3907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3908. return
  3909. }
  3910. recordDateTime := theTime.Unix()
  3911. adminUser := c.GetAdminUserInfo()
  3912. var tempOrder models.HisOrder
  3913. tempOrder, _ = service.GetHisOrderByID(order_id)
  3914. var prescriptions []*models.HisPrescription
  3915. var start_time int64
  3916. var end_time int64
  3917. //if adminUser.CurrentOrgId == 10106{
  3918. // if len(fapiao_code) == 0{
  3919. // fapiao_code = "144072080589"
  3920. // }
  3921. // if len(fapiao_number) == 0{
  3922. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3923. // if order.ID == 0{
  3924. // fapiao_number = "00001520"
  3925. // }else{
  3926. // //fapiao_code = "00001520"
  3927. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3928. // var zero string
  3929. // if fpNumber >= 1000{
  3930. // zero = "0000" + strconv.Itoa(fpNumber)
  3931. // }else if fpNumber >= 10000{
  3932. // zero = "000" + strconv.Itoa(fpNumber)
  3933. // } else if fpNumber >= 100000{
  3934. // zero = "00" + strconv.Itoa(fpNumber)
  3935. // } else if fpNumber >= 1000000{
  3936. // zero = "0" + strconv.Itoa(fpNumber)
  3937. // }else {
  3938. // zero = strconv.Itoa(fpNumber)
  3939. // }
  3940. // fapiao_number = zero
  3941. // }
  3942. // }
  3943. //}
  3944. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3945. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3946. var patientPrescription models.HisPrescriptionInfo
  3947. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3948. if patientPrescription.ID == 0 {
  3949. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3950. }
  3951. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3952. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3953. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3954. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3955. var config []*models.HisXtDiagnoseConfig
  3956. for _, item := range diagnosis_ids {
  3957. id, _ := strconv.ParseInt(item, 10, 64)
  3958. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3959. config = append(config, &diagnosisConfig)
  3960. }
  3961. sickConfig, _ := service.FindSickById(sick_type)
  3962. //if tempOrder.ID == 0 {
  3963. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3964. //}
  3965. if tempOrder.ID == 0 {
  3966. var result string
  3967. var requestLog string
  3968. var res2 ResultSix
  3969. var ressix10265 ResultSix10265
  3970. if miConfig.MdtrtareaAdmvs == "421300" {
  3971. data := make(map[string]interface{})
  3972. client := &http.Client{}
  3973. data["psn_no"] = his.PsnNo
  3974. data["mdtrt_id"] = his.Number
  3975. data["doctor"] = roles.UserName
  3976. data["department"] = department.Name
  3977. data["org_name"] = miConfig.OrgName
  3978. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3979. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3980. data["fixmedins_code"] = miConfig.Code
  3981. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3982. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3983. data["secret_key"] = miConfig.SecretKey
  3984. data["sick_code"] = sickConfig.CountryCode
  3985. data["sick_name"] = sickConfig.ClassName
  3986. data["dept"] = strconv.FormatInt(department.ID, 10)
  3987. data["config"] = config
  3988. data["begin_time"] = begin_time
  3989. bytesData, _ := json.Marshal(data)
  3990. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3991. resp, _ := client.Do(req)
  3992. defer resp.Body.Close()
  3993. body, ioErr := ioutil.ReadAll(resp.Body)
  3994. if ioErr != nil {
  3995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3997. return
  3998. }
  3999. var respJSON map[string]interface{}
  4000. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4003. return
  4004. }
  4005. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4006. userJSONBytes, _ := json.Marshal(respJSON)
  4007. fmt.Println("log")
  4008. fmt.Println(string(userJSONBytes))
  4009. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4010. utils.ErrorLog("解析失败:%v", err)
  4011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4012. return
  4013. }
  4014. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4015. //江苏地区国家医保医疗类别
  4016. //职工透析:医疗类别选特殊情况门诊9933
  4017. //居民血透门慢: 医疗类别选门诊慢病1402
  4018. //var med_type string
  4019. //if his.Insutype == "310" {
  4020. // if reg_type == 14 {
  4021. // med_type = "9933"
  4022. // } else if reg_type == 11 {
  4023. // med_type = "11"
  4024. //
  4025. // }
  4026. //} else if his.Insutype == "390" {
  4027. // if reg_type == 14 {
  4028. // med_type = "1402"
  4029. // } else if reg_type == 11 {
  4030. // med_type = "11"
  4031. // }
  4032. //}
  4033. data := make(map[string]interface{})
  4034. client := &http.Client{}
  4035. data["psn_no"] = his.PsnNo
  4036. data["mdtrt_id"] = his.Number
  4037. data["doctor"] = roles.UserName
  4038. data["department"] = department.Name
  4039. data["org_name"] = miConfig.OrgName
  4040. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4041. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4042. data["fixmedins_code"] = miConfig.Code
  4043. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4044. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4045. data["secret_key"] = miConfig.SecretKey
  4046. data["sick_code"] = sickConfig.CountryCode
  4047. data["sick_name"] = sickConfig.ClassName
  4048. data["url"] = miConfig.Url
  4049. data["ak"] = miConfig.AccessKey
  4050. data["begin_time"] = begin_time
  4051. data["cainfo"] = miConfig.Cainfo
  4052. data["dept"] = strconv.FormatInt(department.ID, 10)
  4053. data["config"] = config
  4054. bytesData, _ := json.Marshal(data)
  4055. var req *http.Request
  4056. if miConfig.MdtrtareaAdmvs == "320921" {
  4057. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4058. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4059. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4060. } else {
  4061. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4062. }
  4063. resp, _ := client.Do(req)
  4064. defer resp.Body.Close()
  4065. body, ioErr := ioutil.ReadAll(resp.Body)
  4066. if ioErr != nil {
  4067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4069. return
  4070. }
  4071. var respJSON map[string]interface{}
  4072. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4075. return
  4076. }
  4077. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4078. userJSONBytes, _ := json.Marshal(respJSON)
  4079. fmt.Println("log")
  4080. fmt.Println(string(userJSONBytes))
  4081. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4082. utils.ErrorLog("解析失败:%v", err)
  4083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4084. return
  4085. }
  4086. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4087. res2.Output = ressix10265.Output
  4088. res2.ErrMsg = ressix10265.ErrMsg
  4089. res2.Cainfo = ressix10265.Cainfo
  4090. res2.WarnMsg = ressix10265.WarnMsg
  4091. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4092. res2.Infcode = infocode
  4093. } else {
  4094. if miConfig.MdtrtareaAdmvs == "440781" { //
  4095. 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)
  4096. } else {
  4097. if miConfig.Code == "H15049901371" {
  4098. //赤峰地区国家医保医疗类别
  4099. //职工透析:医疗类别选特殊情况门诊990502
  4100. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4101. var med_type string
  4102. if his.Insutype == "390" {
  4103. if reg_type == 14 {
  4104. med_type = "9933"
  4105. } else if reg_type == 11 {
  4106. med_type = "11"
  4107. }
  4108. } else if his.Insutype == "310" {
  4109. if reg_type == 14 {
  4110. med_type = "990502"
  4111. } else if reg_type == 11 {
  4112. med_type = "11"
  4113. }
  4114. }
  4115. 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)
  4116. } else {
  4117. 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)
  4118. }
  4119. }
  4120. saveLog(result, requestLog, "2203", "上传就诊信息")
  4121. var respJSON2 map[string]interface{}
  4122. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4125. return
  4126. }
  4127. userJSONBytes2, _ := json.Marshal(respJSON2)
  4128. if miConfig.Code == "H15049901371" {
  4129. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4130. utils.ErrorLog("解析失败:%v", err)
  4131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4132. return
  4133. }
  4134. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4135. res2.Output = ressix10265.Output
  4136. res2.ErrMsg = ressix10265.ErrMsg
  4137. res2.Cainfo = ressix10265.Cainfo
  4138. res2.WarnMsg = ressix10265.WarnMsg
  4139. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4140. res2.Infcode = infocode
  4141. } else {
  4142. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4143. utils.ErrorLog("解析失败:%v", err)
  4144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4145. return
  4146. }
  4147. }
  4148. }
  4149. if res2.Infcode != 0 {
  4150. adminUser := c.GetAdminUserInfo()
  4151. errlog := &models.HisOrderError{
  4152. UserOrgId: adminUser.CurrentOrgId,
  4153. Ctime: time.Now().Unix(),
  4154. Mtime: time.Now().Unix(),
  4155. ErrMsg: res2.ErrMsg,
  4156. Status: 1,
  4157. PatientId: id,
  4158. RecordTime: recordDateTime,
  4159. Stage: 3,
  4160. }
  4161. service.CreateErrMsgLog(errlog)
  4162. c.ServeSuccessJSON(map[string]interface{}{
  4163. "failed_code": -10,
  4164. "msg": res2.ErrMsg,
  4165. })
  4166. return
  4167. } else {
  4168. his.Diagnosis = diagnosis_id
  4169. his.SickType = sickConfig.ID
  4170. //var p_type int64
  4171. //if reg_type == 1111 || reg_type == 1112 {
  4172. // p_type = 11
  4173. //
  4174. //}
  4175. his.PType = fmt.Sprintf("%d", reg_type)
  4176. service.UpdateHisPatientThree(&his)
  4177. data := make(map[string]interface{})
  4178. if settle_accounts_type == 1 { //日结
  4179. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4180. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4181. } else {
  4182. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4183. }
  4184. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4185. data["pre"] = prescriptions
  4186. } else { //月结
  4187. start_time_str := c.GetString("start_time")
  4188. end_time_str := c.GetString("end_time")
  4189. timeLayout := "2006-01-02"
  4190. loc, _ := time.LoadLocation("Local")
  4191. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4192. if err != nil {
  4193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4194. return
  4195. }
  4196. recordStartTime := theStartTime.Unix()
  4197. start_time = recordStartTime
  4198. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4199. if err != nil {
  4200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4201. return
  4202. }
  4203. recordEndTime := theEndTime.Unix()
  4204. end_time = recordEndTime
  4205. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4206. data["pre"] = prescriptions
  4207. }
  4208. timestamp := time.Now().Unix()
  4209. tempTime := time.Unix(timestamp, 0)
  4210. timeFormat := tempTime.Format("20060102150405")
  4211. chrgBchno := rand.Intn(100000) + 10000
  4212. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4213. strconv.FormatInt(his.PatientId, 10)
  4214. client := &http.Client{}
  4215. data["psn_no"] = his.PsnNo
  4216. data["mdtrt_id"] = his.Number
  4217. data["chrg_bchno"] = chrg_bchno
  4218. data["org_name"] = miConfig.OrgName
  4219. data["doctor"] = roles.UserName
  4220. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4221. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4222. data["fixmedins_code"] = miConfig.Code
  4223. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4224. // data["dept_code"] = "15"
  4225. //} else {
  4226. data["dept_code"] = department.Number
  4227. //}
  4228. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4229. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4230. data["secret_key"] = miConfig.SecretKey
  4231. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4232. data["url"] = miConfig.Url
  4233. data["ak"] = miConfig.AccessKey
  4234. data["new_doctor_name"] = patientPrescription.Doctor
  4235. data["diag_code"] = sickConfig.CountryCode
  4236. data["cainfo"] = miConfig.Cainfo
  4237. var ids []int64
  4238. for _, item := range prescriptions {
  4239. ids = append(ids, item.ID)
  4240. }
  4241. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4242. if config.IsOpen == 1 { //对接了医保,走医保流程
  4243. var res ResultFour
  4244. var resFour10265 ResultFour10265
  4245. if miConfig.MdtrtareaAdmvs == "421300" {
  4246. bytesData, _ := json.Marshal(data)
  4247. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4248. resp, _ := client.Do(req)
  4249. defer resp.Body.Close()
  4250. body, ioErr := ioutil.ReadAll(resp.Body)
  4251. if ioErr != nil {
  4252. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4254. return
  4255. }
  4256. var respJSON map[string]interface{}
  4257. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4260. return
  4261. }
  4262. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4263. userJSONBytes, _ := json.Marshal(respJSON)
  4264. fmt.Println("log")
  4265. fmt.Println(string(userJSONBytes))
  4266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4267. utils.ErrorLog("解析失败:%v", err)
  4268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4269. return
  4270. }
  4271. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4272. bytesData, _ := json.Marshal(data)
  4273. var req *http.Request
  4274. if miConfig.MdtrtareaAdmvs == "320921" {
  4275. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4276. } else {
  4277. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4278. }
  4279. resp, _ := client.Do(req)
  4280. defer resp.Body.Close()
  4281. body, ioErr := ioutil.ReadAll(resp.Body)
  4282. if ioErr != nil {
  4283. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4285. return
  4286. }
  4287. var respJSON map[string]interface{}
  4288. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4291. return
  4292. }
  4293. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4294. userJSONBytes, _ := json.Marshal(respJSON)
  4295. fmt.Println("log")
  4296. fmt.Println(string(userJSONBytes))
  4297. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4298. utils.ErrorLog("解析失败:%v", err)
  4299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4300. return
  4301. }
  4302. res.InfRefmsgid = resFour10265.InfRefmsgid
  4303. res.Output = resFour10265.Output
  4304. res.ErrMsg = resFour10265.ErrMsg
  4305. res.Cainfo = resFour10265.Cainfo
  4306. res.WarnMsg = resFour10265.WarnMsg
  4307. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4308. res.Infcode = infocode
  4309. } else {
  4310. if miConfig.Code == "H15049901371" {
  4311. 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)
  4312. var dat map[string]interface{}
  4313. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4314. fmt.Println(dat)
  4315. } else {
  4316. fmt.Println(err)
  4317. }
  4318. saveLog(result, request_log, "2204", "上传费用明细")
  4319. userJSONBytes, _ := json.Marshal(dat)
  4320. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4321. utils.ErrorLog("解析失败:%v", err)
  4322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4323. return
  4324. }
  4325. res.InfRefmsgid = resFour10265.InfRefmsgid
  4326. res.Output = resFour10265.Output
  4327. res.ErrMsg = resFour10265.ErrMsg
  4328. res.Cainfo = resFour10265.Cainfo
  4329. res.WarnMsg = resFour10265.WarnMsg
  4330. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4331. res.Infcode = infocode
  4332. } else {
  4333. 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)
  4334. var dat map[string]interface{}
  4335. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4336. fmt.Println(dat)
  4337. } else {
  4338. fmt.Println(err)
  4339. }
  4340. saveLog(result, request_log, "2204", "上传费用明细")
  4341. userJSONBytes, _ := json.Marshal(dat)
  4342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4343. utils.ErrorLog("解析失败:%v", err)
  4344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4345. return
  4346. }
  4347. }
  4348. }
  4349. if res.Infcode == 0 {
  4350. order := &models.HisOrder{
  4351. UserOrgId: adminUser.CurrentOrgId,
  4352. HisPatientId: his.ID,
  4353. PatientId: his.PatientId,
  4354. SettleAccountsDate: recordDateTime,
  4355. MdtrtId: his.Number,
  4356. PsnNo: his.PsnNo,
  4357. MedType: strconv.FormatInt(reg_type, 10),
  4358. Ctime: time.Now().Unix(),
  4359. Mtime: time.Now().Unix(),
  4360. Status: 1,
  4361. Number: chrg_bchno,
  4362. Infcode: res.Infcode,
  4363. WarnMsg: res.WarnMsg,
  4364. Cainfo: res.Cainfo,
  4365. ErrMsg: res.ErrMsg,
  4366. RespondTime: res.RefmsgTime,
  4367. InfRefmsgid: res.InfRefmsgid,
  4368. OrderStatus: 1,
  4369. PayWay: pay_way,
  4370. PayPrice: pay_price,
  4371. PayCardNo: pay_card_no,
  4372. DiscountPrice: discount_price,
  4373. PreferentialPrice: preferential_price,
  4374. RealityPrice: reality_price,
  4375. FoundPrice: found_price,
  4376. MedicalInsurancePrice: medical_insurance_price,
  4377. PrivatePrice: private_price,
  4378. IsMedicineInsurance: 1,
  4379. SettleType: settle_accounts_type,
  4380. SettleStartTime: start_time,
  4381. SettleEndTime: end_time,
  4382. Creator: roles.AdminUserId,
  4383. Modify: roles.AdminUserId,
  4384. FaPiaoNumber: fapiao_number,
  4385. FaPiaoCode: fapiao_code,
  4386. PType: 2,
  4387. Diagnosis: diagnosis_id,
  4388. }
  4389. err = service.CreateOrder(order)
  4390. if err != nil {
  4391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4392. return
  4393. }
  4394. for _, item := range res.Output.Result {
  4395. temp := strings.Split(item.FeedetlSn, "-")
  4396. var advice_id int64 = 0
  4397. var project_id int64 = 0
  4398. var types int64 = 0
  4399. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4400. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4401. if temp[1] == "1" {
  4402. advice_id = id
  4403. project_id = 0
  4404. } else if temp[1] == "2" {
  4405. advice_id = 0
  4406. project_id = id
  4407. }
  4408. info := &models.HisOrderInfo{
  4409. OrderNumber: order.Number,
  4410. FeedetlSn: item.FeedetlSn,
  4411. UploadDate: time.Now().Unix(),
  4412. AdviceId: advice_id,
  4413. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4414. Cnt: item.Cnt,
  4415. Pric: float64(item.Pric),
  4416. PatientId: his.PatientId,
  4417. PricUplmtAmt: item.PricUplmtAmt,
  4418. SelfpayProp: item.SelfpayProp,
  4419. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4420. OverlmtAmt: item.OverlmtAmt,
  4421. PreselfpayAmt: item.PreselfpayAmt,
  4422. BasMednFlag: item.BasMednFlag,
  4423. MedChrgitmType: item.MedChrgitmType,
  4424. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4425. Status: 1,
  4426. Memo: item.Memo,
  4427. Mtime: time.Now().Unix(),
  4428. InscpScpAmt: item.InscpScpAmt,
  4429. DrtReimFlag: item.DrtReimFlag,
  4430. Ctime: time.Now().Unix(),
  4431. ListSpItemFlag: item.ListSpItemFlag,
  4432. ChldMedcFlag: item.ChldMedcFlag,
  4433. LmtUsedFlag: item.LmtUsedFlag,
  4434. ChrgitmLv: item.ChrgitmLv,
  4435. UserOrgId: adminUser.CurrentOrgId,
  4436. HisPatientId: his.ID,
  4437. OrderId: order.ID,
  4438. ProjectId: project_id,
  4439. Type: types,
  4440. }
  4441. service.CreateOrderInfo(info)
  4442. }
  4443. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4444. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4445. var total float64
  4446. for _, item := range prescriptions {
  4447. if item.Type == 1 { //药品
  4448. for _, subItem := range item.HisDoctorAdviceInfo {
  4449. total = total + (subItem.Price * subItem.PrescribingNumber)
  4450. }
  4451. }
  4452. if item.Type == 2 { //项目
  4453. for _, subItem := range item.HisPrescriptionProject {
  4454. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4455. total = total + (subItem.Price * cnt)
  4456. }
  4457. }
  4458. }
  4459. for _, item := range prescriptions {
  4460. for _, subItem := range item.HisAdditionalCharge {
  4461. total = total + (subItem.Price * float64(subItem.Count))
  4462. }
  4463. }
  4464. var allTotal string
  4465. if adminUser.CurrentOrgId == 9919 {
  4466. allTotal = fmt.Sprintf("%.4f", total)
  4467. } else {
  4468. allTotal = fmt.Sprintf("%.4f", total)
  4469. }
  4470. if res.Infcode == 0 {
  4471. var rf []*ResultFive
  4472. json.Unmarshal([]byte(his.Iinfo), &rf)
  4473. chrg_bchno := chrg_bchno
  4474. cert_no := his.Certno
  4475. var insutypes []string
  4476. var insutype string
  4477. var is390 int = 0
  4478. var is310 int = 0
  4479. for _, item := range rf {
  4480. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4481. insutypes = append(insutypes, item.Insutype)
  4482. }
  4483. }
  4484. if len(insutypes) == 1 {
  4485. insutype = insutypes[0]
  4486. } else {
  4487. for _, i := range insutypes {
  4488. if i == "390" {
  4489. is390 = 1
  4490. }
  4491. if i == "310" {
  4492. is310 = 1
  4493. }
  4494. }
  4495. }
  4496. if is390 == 1 {
  4497. insutype = "390"
  4498. }
  4499. if is310 == 1 {
  4500. insutype = "310"
  4501. }
  4502. if len(insutypes) == 0 {
  4503. insutype = "310"
  4504. }
  4505. if len(insutypes) == 2 {
  4506. insutype = strconv.FormatInt(his.SocialType, 10)
  4507. }
  4508. insutype = strconv.FormatInt(his.SocialType, 10)
  4509. //insutype = "390"
  4510. if his.IdCardType == 1 {
  4511. // cert_no = his.MedicalInsuranceNumber
  4512. cert_no = his.Certno
  4513. } else {
  4514. cert_no = his.Certno
  4515. }
  4516. var res ResultSeven
  4517. var resSeven10265 ResultSeven10265
  4518. var src_resquest string
  4519. var result2 string
  4520. var acct_used_flag string
  4521. fmt.Println("pay_way")
  4522. fmt.Println(pay_way)
  4523. fmt.Println("pay_way")
  4524. if pay_way == 4 {
  4525. acct_used_flag = "1"
  4526. } else {
  4527. acct_used_flag = "0"
  4528. }
  4529. if miConfig.MdtrtareaAdmvs == "421300" {
  4530. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4531. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4532. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4533. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4534. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4535. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4536. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4537. resp, requestErr := http.Get(api)
  4538. if requestErr != nil {
  4539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4540. return
  4541. }
  4542. body, ioErr := ioutil.ReadAll(resp.Body)
  4543. if ioErr != nil {
  4544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4546. return
  4547. }
  4548. var respJSON map[string]interface{}
  4549. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4552. return
  4553. }
  4554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4555. result, _ := json.Marshal(respJSON)
  4556. if miConfig.Code == "H15049901371" {
  4557. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4558. utils.ErrorLog("解析失败:%v", err)
  4559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4560. return
  4561. }
  4562. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4563. res.Output = resSeven10265.Output
  4564. res.ErrMsg = resSeven10265.ErrMsg
  4565. res.Cainfo = resSeven10265.Cainfo
  4566. res.WarnMsg = resSeven10265.WarnMsg
  4567. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4568. res.Infcode = infocode
  4569. } else {
  4570. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4571. utils.ErrorLog("解析失败:%v", err)
  4572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4573. return
  4574. }
  4575. }
  4576. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4577. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4578. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4579. //psn_info, _ := service.GetPsnByPatientId(id)
  4580. bas := strings.Split(psn_info.CardInfo, "|")
  4581. if his.IdCardType == 1 {
  4582. cert_no = bas[2]
  4583. } else if his.IdCardType == 3 {
  4584. cert_no = his.Certno
  4585. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  4586. } else {
  4587. cert_no = bas[1]
  4588. }
  4589. //江苏地区国家医保医疗类别
  4590. //职工透析:医疗类别选特殊情况门诊9933
  4591. //居民血透门慢: 医疗类别选门诊慢病1402
  4592. //var med_type string
  4593. //if his.Insutype == "310" {
  4594. // if reg_type == 14 {
  4595. // med_type = "9933"
  4596. // } else if reg_type == 11 {
  4597. // med_type = "11"
  4598. //
  4599. // }
  4600. //} else if his.Insutype == "390" {
  4601. // if reg_type == 14 {
  4602. // med_type = "1402"
  4603. // } else if reg_type == 11 {
  4604. // med_type = "11"
  4605. // }
  4606. //}
  4607. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4608. var api string
  4609. if miConfig.MdtrtareaAdmvs == "320921" {
  4610. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4611. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4612. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4613. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4614. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4615. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4616. "&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
  4617. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4618. } else {
  4619. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4620. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4621. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4622. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4623. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4624. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4625. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4626. "&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
  4627. }
  4628. resp, requestErr := http.Get(api)
  4629. if requestErr != nil {
  4630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4631. return
  4632. }
  4633. body, ioErr := ioutil.ReadAll(resp.Body)
  4634. if ioErr != nil {
  4635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4637. return
  4638. }
  4639. var respJSON map[string]interface{}
  4640. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4643. return
  4644. }
  4645. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4646. result, _ := json.Marshal(respJSON)
  4647. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4648. utils.ErrorLog("解析失败:%v", err)
  4649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4650. return
  4651. }
  4652. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4653. res.Output = resSeven10265.Output
  4654. res.ErrMsg = resSeven10265.ErrMsg
  4655. res.Cainfo = resSeven10265.Cainfo
  4656. res.WarnMsg = resSeven10265.WarnMsg
  4657. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4658. res.Infcode = infocode
  4659. } else {
  4660. if miConfig.Code == "H15049901371" {
  4661. //赤峰地区国家医保医疗类别
  4662. //职工透析:医疗类别选特殊情况门诊990502
  4663. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4664. var med_type string
  4665. if his.Insutype == "390" {
  4666. if reg_type == 14 {
  4667. med_type = "9933"
  4668. } else if reg_type == 11 {
  4669. med_type = "11"
  4670. }
  4671. } else if his.Insutype == "310" {
  4672. if reg_type == 14 {
  4673. med_type = "990502"
  4674. } else if reg_type == 11 {
  4675. med_type = "11"
  4676. }
  4677. }
  4678. 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)
  4679. } else {
  4680. 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)
  4681. }
  4682. //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)
  4683. var dat map[string]interface{}
  4684. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4685. fmt.Println(dat)
  4686. } else {
  4687. fmt.Println(err)
  4688. }
  4689. saveLog(result2, src_resquest, "2207", "结算")
  4690. userJSONBytes, _ := json.Marshal(dat)
  4691. if miConfig.Code == "H15049901371" {
  4692. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4693. utils.ErrorLog("解析失败:%v", err)
  4694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4695. return
  4696. }
  4697. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4698. res.Output = resSeven10265.Output
  4699. res.ErrMsg = resSeven10265.ErrMsg
  4700. res.Cainfo = resSeven10265.Cainfo
  4701. res.WarnMsg = resSeven10265.WarnMsg
  4702. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4703. res.Infcode = infocode
  4704. } else {
  4705. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4706. utils.ErrorLog("解析失败:%v", err)
  4707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4708. return
  4709. }
  4710. }
  4711. }
  4712. if res.Infcode != 0 {
  4713. errlog := &models.HisOrderError{
  4714. UserOrgId: adminUser.CurrentOrgId,
  4715. Ctime: time.Now().Unix(),
  4716. Mtime: time.Now().Unix(),
  4717. Number: chrg_bchno,
  4718. ErrMsg: res.ErrMsg,
  4719. Status: 1,
  4720. PatientId: id,
  4721. RecordTime: recordDateTime,
  4722. Stage: 6,
  4723. }
  4724. service.CreateErrMsgLog(errlog)
  4725. c.ServeSuccessJSON(map[string]interface{}{
  4726. "failed_code": -10,
  4727. "msg": res.ErrMsg,
  4728. })
  4729. return
  4730. } else {
  4731. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4732. order.OrderStatus = 2
  4733. order.Status = 1
  4734. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4735. order.SetlId = res.Output.Setlinfo.SetlID
  4736. order.PsnNo = res.Output.Setlinfo.PsnNo
  4737. order.PsnName = res.Output.Setlinfo.PsnName
  4738. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4739. order.Certno = res.Output.Setlinfo.Certno
  4740. order.Gend = res.Output.Setlinfo.Gend
  4741. order.Naty = res.Output.Setlinfo.Naty
  4742. order.Age = res.Output.Setlinfo.Age
  4743. order.Insutype = res.Output.Setlinfo.Insutype
  4744. order.PsnType = res.Output.Setlinfo.PsnType
  4745. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4746. order.SetlTime = res.Output.Setlinfo.SetlTime
  4747. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4748. if res.Output.Setlinfo.MedType == "140101" {
  4749. order.MedType = "14"
  4750. } else {
  4751. order.MedType = res.Output.Setlinfo.MedType
  4752. }
  4753. if reg_type == 1112 {
  4754. order.MedType = "1112"
  4755. }
  4756. if reg_type == 1111 {
  4757. order.MedType = "1111"
  4758. }
  4759. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4760. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4761. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4762. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4763. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4764. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4765. order.HifpPay = res.Output.Setlinfo.HifpPay
  4766. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4767. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4768. order.HifesPay = res.Output.Setlinfo.HifesPay
  4769. order.HifobPay = res.Output.Setlinfo.HifobPay
  4770. order.MafPay = res.Output.Setlinfo.MafPay
  4771. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4772. order.OthPay = res.Output.Setlinfo.OthPay
  4773. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4774. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4775. order.AcctPay = res.Output.Setlinfo.AcctPay
  4776. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4777. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4778. order.Balc = res.Output.Setlinfo.Balc
  4779. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4780. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4781. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4782. order.ClrType = res.Output.Setlinfo.ClrType
  4783. order.ClrWay = res.Output.Setlinfo.ClrWay
  4784. order.Creator = order.Creator
  4785. order.Modify = roles.AdminUserId
  4786. order.RequestLog = src_resquest
  4787. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4788. detailStr := string(setlDetail)
  4789. order.SetlDetail = detailStr
  4790. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4791. err = service.UpDateOrder(order)
  4792. if err == nil {
  4793. c.ServeSuccessJSON(map[string]interface{}{
  4794. "msg": "结算成功",
  4795. })
  4796. } else {
  4797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4798. return
  4799. }
  4800. }
  4801. } else {
  4802. adminUser := c.GetAdminUserInfo()
  4803. errlog := &models.HisOrderError{
  4804. UserOrgId: adminUser.CurrentOrgId,
  4805. Ctime: time.Now().Unix(),
  4806. Mtime: time.Now().Unix(),
  4807. ErrMsg: res.ErrMsg,
  4808. Status: 1,
  4809. PatientId: id,
  4810. RecordTime: recordDateTime,
  4811. Stage: 4,
  4812. }
  4813. service.CreateErrMsgLog(errlog)
  4814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4815. return
  4816. }
  4817. } else {
  4818. adminUser := c.GetAdminUserInfo()
  4819. errlog := &models.HisOrderError{
  4820. UserOrgId: adminUser.CurrentOrgId,
  4821. Ctime: time.Now().Unix(),
  4822. Mtime: time.Now().Unix(),
  4823. ErrMsg: res.ErrMsg,
  4824. Status: 1,
  4825. PatientId: id,
  4826. RecordTime: recordDateTime,
  4827. Stage: 4,
  4828. }
  4829. service.CreateErrMsgLog(errlog)
  4830. c.ServeSuccessJSON(map[string]interface{}{
  4831. "failed_code": -10,
  4832. "msg": res.ErrMsg,
  4833. })
  4834. return
  4835. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4836. //return
  4837. }
  4838. }
  4839. }
  4840. } else if tempOrder.ID > 0 {
  4841. if tempOrder.IsPre == 1 {
  4842. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4843. var rf []*ResultFive
  4844. json.Unmarshal([]byte(his.Iinfo), &rf)
  4845. chrg_bchno := tempOrder.Number
  4846. cert_no := his.Certno
  4847. var insutypes []string
  4848. var insutype string
  4849. var is390 int = 0
  4850. var is310 int = 0
  4851. for _, item := range rf {
  4852. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4853. insutypes = append(insutypes, item.Insutype)
  4854. }
  4855. }
  4856. if len(insutypes) == 1 {
  4857. insutype = insutypes[0]
  4858. } else {
  4859. for _, i := range insutypes {
  4860. if i == "390" {
  4861. is390 = 1
  4862. }
  4863. if i == "310" {
  4864. is310 = 1
  4865. }
  4866. }
  4867. }
  4868. if is390 == 1 {
  4869. insutype = "390"
  4870. }
  4871. if is310 == 1 {
  4872. insutype = "310"
  4873. }
  4874. if len(insutypes) == 0 {
  4875. insutype = "310"
  4876. }
  4877. if len(insutypes) == 2 {
  4878. insutype = strconv.FormatInt(his.SocialType, 64)
  4879. }
  4880. //insutype = "390"
  4881. if his.IdCardType == 1 {
  4882. // cert_no = his.MedicalInsuranceNumber
  4883. cert_no = his.Certno
  4884. } else {
  4885. cert_no = his.Certno
  4886. }
  4887. var res ResultSeven
  4888. var resSeven10265 ResultSeven10265
  4889. var src_resquest string
  4890. var result2 string
  4891. var acct_used_flag string
  4892. fmt.Println("pay_way")
  4893. fmt.Println(pay_way)
  4894. fmt.Println("pay_way")
  4895. if pay_way == 4 {
  4896. acct_used_flag = "1"
  4897. } else {
  4898. acct_used_flag = "0"
  4899. }
  4900. if miConfig.MdtrtareaAdmvs == "421300" {
  4901. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4902. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4903. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4904. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4905. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4906. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4907. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4908. resp, requestErr := http.Get(api)
  4909. if requestErr != nil {
  4910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4911. return
  4912. }
  4913. body, ioErr := ioutil.ReadAll(resp.Body)
  4914. if ioErr != nil {
  4915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4917. return
  4918. }
  4919. var respJSON map[string]interface{}
  4920. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4923. return
  4924. }
  4925. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4926. result, _ := json.Marshal(respJSON)
  4927. fmt.Println("log")
  4928. fmt.Println(string(result))
  4929. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4930. utils.ErrorLog("解析失败:%v", err)
  4931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4932. return
  4933. }
  4934. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4935. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4936. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4937. //psn_info, _ := service.GetPsnByPatientId(id)
  4938. bas := strings.Split(psn_info.CardInfo, "|")
  4939. if his.IdCardType == 1 {
  4940. cert_no = bas[2]
  4941. } else {
  4942. cert_no = bas[1]
  4943. }
  4944. //江苏地区国家医保医疗类别
  4945. //职工透析:医疗类别选特殊情况门诊9933
  4946. //居民血透门慢: 医疗类别选门诊慢病1402
  4947. //var med_type string
  4948. //if his.Insutype == "310" {
  4949. // if reg_type == 14 {
  4950. // med_type = "9933"
  4951. // } else if reg_type == 11 {
  4952. // med_type = "11"
  4953. //
  4954. // }
  4955. //} else if his.Insutype == "390" {
  4956. // if reg_type == 14 {
  4957. // med_type = "1402"
  4958. // } else if reg_type == 11 {
  4959. // med_type = "11"
  4960. // }
  4961. //}
  4962. var api string
  4963. if miConfig.MdtrtareaAdmvs == "320921" {
  4964. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4965. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4966. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4967. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4968. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4969. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4970. "&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
  4971. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4972. } else {
  4973. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4974. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4975. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4976. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4977. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4978. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4979. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4980. "&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
  4981. }
  4982. resp, requestErr := http.Get(api)
  4983. if requestErr != nil {
  4984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4985. return
  4986. }
  4987. body, ioErr := ioutil.ReadAll(resp.Body)
  4988. if ioErr != nil {
  4989. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4991. return
  4992. }
  4993. var respJSON map[string]interface{}
  4994. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4997. return
  4998. }
  4999. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5000. result, _ := json.Marshal(respJSON)
  5001. fmt.Println("log")
  5002. fmt.Println(string(result))
  5003. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5004. utils.ErrorLog("解析失败:%v", err)
  5005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5006. return
  5007. }
  5008. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5009. res.Output = resSeven10265.Output
  5010. res.ErrMsg = resSeven10265.ErrMsg
  5011. res.Cainfo = resSeven10265.Cainfo
  5012. res.WarnMsg = resSeven10265.WarnMsg
  5013. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5014. res.Infcode = infocode
  5015. } else {
  5016. var src_resquest string
  5017. if miConfig.Code == "H15049901371" {
  5018. //赤峰地区国家医保医疗类别
  5019. //职工透析:医疗类别选特殊情况门诊990502
  5020. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5021. var med_type string
  5022. if his.Insutype == "390" {
  5023. if reg_type == 14 {
  5024. med_type = "9933"
  5025. } else if reg_type == 11 {
  5026. med_type = "11"
  5027. }
  5028. } else if his.Insutype == "310" {
  5029. if reg_type == 14 {
  5030. med_type = "990502"
  5031. } else if reg_type == 11 {
  5032. med_type = "11"
  5033. }
  5034. }
  5035. 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)
  5036. } else {
  5037. 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)
  5038. }
  5039. var dat map[string]interface{}
  5040. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5041. fmt.Println(dat)
  5042. } else {
  5043. fmt.Println(err)
  5044. }
  5045. saveLog(result2, src_resquest, "2207", "结算")
  5046. userJSONBytes, _ := json.Marshal(dat)
  5047. if miConfig.Code == "H15049901371" {
  5048. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5049. utils.ErrorLog("解析失败:%v", err)
  5050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5051. return
  5052. }
  5053. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5054. res.Output = resSeven10265.Output
  5055. res.ErrMsg = resSeven10265.ErrMsg
  5056. res.Cainfo = resSeven10265.Cainfo
  5057. res.WarnMsg = resSeven10265.WarnMsg
  5058. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5059. res.Infcode = infocode
  5060. } else {
  5061. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5062. utils.ErrorLog("解析失败:%v", err)
  5063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5064. return
  5065. }
  5066. }
  5067. }
  5068. if res.Infcode != 0 {
  5069. errlog := &models.HisOrderError{
  5070. UserOrgId: adminUser.CurrentOrgId,
  5071. Ctime: time.Now().Unix(),
  5072. Mtime: time.Now().Unix(),
  5073. Number: chrg_bchno,
  5074. ErrMsg: res.ErrMsg,
  5075. Status: 1,
  5076. PatientId: id,
  5077. RecordTime: recordDateTime,
  5078. Stage: 6,
  5079. }
  5080. service.CreateErrMsgLog(errlog)
  5081. c.ServeSuccessJSON(map[string]interface{}{
  5082. "failed_code": -10,
  5083. "msg": res.ErrMsg,
  5084. })
  5085. return
  5086. } else {
  5087. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5088. order.OrderStatus = 2
  5089. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5090. order.SetlId = res.Output.Setlinfo.SetlID
  5091. order.PsnNo = res.Output.Setlinfo.PsnNo
  5092. order.PsnName = res.Output.Setlinfo.PsnName
  5093. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5094. order.Certno = res.Output.Setlinfo.Certno
  5095. order.Gend = res.Output.Setlinfo.Gend
  5096. order.Naty = res.Output.Setlinfo.Naty
  5097. order.Age = res.Output.Setlinfo.Age
  5098. order.Insutype = res.Output.Setlinfo.Insutype
  5099. order.PsnType = res.Output.Setlinfo.PsnType
  5100. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5101. order.SetlTime = res.Output.Setlinfo.SetlTime
  5102. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5103. //order.MedType = res.Output.Setlinfo.MedType
  5104. if reg_type == 1112 {
  5105. order.MedType = "1112"
  5106. }
  5107. if reg_type == 1111 {
  5108. order.MedType = "1111"
  5109. }
  5110. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5111. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5112. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5113. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5114. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5115. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5116. order.HifpPay = res.Output.Setlinfo.HifpPay
  5117. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5118. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5119. order.HifesPay = res.Output.Setlinfo.HifesPay
  5120. order.HifobPay = res.Output.Setlinfo.HifobPay
  5121. order.MafPay = res.Output.Setlinfo.MafPay
  5122. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5123. order.OthPay = res.Output.Setlinfo.OthPay
  5124. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5125. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5126. order.AcctPay = res.Output.Setlinfo.AcctPay
  5127. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5128. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5129. order.Balc = res.Output.Setlinfo.Balc
  5130. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5131. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5132. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5133. order.ClrWay = res.Output.Setlinfo.ClrWay
  5134. order.Creator = order.Creator
  5135. order.Modify = roles.AdminUserId
  5136. order.RequestLog = src_resquest
  5137. order.Diagnosis = diagnosis_id
  5138. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5139. detailStr := string(setlDetail)
  5140. order.SetlDetail = detailStr
  5141. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5142. err = service.UpDateOrder(order)
  5143. if err == nil {
  5144. c.ServeSuccessJSON(map[string]interface{}{
  5145. "msg": "结算成功",
  5146. })
  5147. } else {
  5148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5149. return
  5150. }
  5151. }
  5152. }
  5153. }
  5154. }
  5155. //func (c *HisApiController) GetPreUploadInfo() {
  5156. // id, _ := c.GetInt64("id")
  5157. // record_time := c.GetString("record_time")
  5158. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5159. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5160. //
  5161. // timeLayout := "2006-01-02"
  5162. // loc, _ := time.LoadLocation("Local")
  5163. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5164. // if err != nil {
  5165. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5166. // return
  5167. // }
  5168. // recordDateTime := theTime.Unix()
  5169. // adminUser := c.GetAdminUserInfo()
  5170. //
  5171. // var prescriptions []*models.HisPrescription
  5172. //
  5173. // var start_time int64
  5174. // var end_time int64
  5175. //
  5176. // data := make(map[string]interface{})
  5177. // if settle_accounts_type == 1 { //日结
  5178. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5179. // data["pre"] = prescriptions
  5180. //
  5181. // } else { //月结
  5182. // start_time_str := c.GetString("start_time")
  5183. // end_time_str := c.GetString("end_time")
  5184. // timeLayout := "2006-01-02"
  5185. // loc, _ := time.LoadLocation("Local")
  5186. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5187. // if err != nil {
  5188. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5189. // return
  5190. // }
  5191. // recordStartTime := theStartTime.Unix()
  5192. // start_time = recordStartTime
  5193. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5194. // if err != nil {
  5195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5196. // return
  5197. // }
  5198. // recordEndTime := theEndTime.Unix()
  5199. // end_time = recordEndTime
  5200. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5201. // data["pre"] = prescriptions
  5202. //
  5203. // }
  5204. //
  5205. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5206. //
  5207. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5208. // timestamp := time.Now().Unix()
  5209. // tempTime := time.Unix(timestamp, 0)
  5210. // timeFormat := tempTime.Format("20060102150405")
  5211. // chrgBchno := rand.Intn(100000) + 10000
  5212. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5213. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5214. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5215. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5216. // strconv.FormatInt(his.PatientId, 10)
  5217. // client := &http.Client{}
  5218. // data["psn_no"] = his.PsnNo
  5219. // data["mdtrt_id"] = his.Number
  5220. // data["chrg_bchno"] = chrg_bchno
  5221. // data["org_name"] = miConfig.OrgName
  5222. // data["doctor"] = roles.UserName
  5223. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5224. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5225. // data["fixmedins_code"] = miConfig.Code
  5226. // data["dept_code"] = department.Number
  5227. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5228. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5229. // data["secret_key"] = miConfig.SecretKey
  5230. // var ids []int64
  5231. //
  5232. // for _, item := range prescriptions {
  5233. // ids = append(ids, item.ID)
  5234. // }
  5235. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5236. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5237. // bytesData, _ := json.Marshal(data)
  5238. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5239. // resp, _ := client.Do(req)
  5240. // defer resp.Body.Close()
  5241. // body, ioErr := ioutil.ReadAll(resp.Body)
  5242. // if ioErr != nil {
  5243. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5244. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5245. // return
  5246. // }
  5247. // var respJSON map[string]interface{}
  5248. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5249. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5251. // return
  5252. // }
  5253. //
  5254. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5255. // userJSONBytes, _ := json.Marshal(respJSON)
  5256. // var res ResultFour
  5257. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5258. // utils.ErrorLog("解析失败:%v", err)
  5259. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5260. // return
  5261. // }
  5262. //
  5263. // if res.Infcode == 0 {
  5264. // order := &models.HisOrder{
  5265. // UserOrgId: adminUser.CurrentOrgId,
  5266. // HisPatientId: his.ID,
  5267. // PatientId: his.PatientId,
  5268. // SettleAccountsDate: recordDateTime,
  5269. // Ctime: time.Now().Unix(),
  5270. // Mtime: time.Now().Unix(),
  5271. // Status: 1,
  5272. // Number: chrg_bchno,
  5273. // Infcode: res.Infcode,
  5274. // WarnMsg: res.WarnMsg,
  5275. // Cainfo: res.Cainfo,
  5276. // ErrMsg: res.ErrMsg,
  5277. // RespondTime: res.RefmsgTime,
  5278. // InfRefmsgid: res.InfRefmsgid,
  5279. // OrderStatus: 1,
  5280. // IsMedicineInsurance: 1,
  5281. // SettleType: settle_accounts_type,
  5282. // SettleStartTime: start_time,
  5283. // SettleEndTime: end_time,
  5284. // Creator: roles.ID,
  5285. // Modify: roles.ID,
  5286. // PType: 2,
  5287. // }
  5288. // err = service.CreateOrder(order)
  5289. // if err != nil {
  5290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5291. // return
  5292. // }
  5293. //
  5294. // for _, item := range res.Output.Result {
  5295. // temp := strings.Split(item.FeedetlSn, "-")
  5296. // var advice_id int64 = 0
  5297. // var project_id int64 = 0
  5298. // var types int64 = 0
  5299. //
  5300. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5301. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5302. //
  5303. // if temp[1] == "1" {
  5304. // advice_id = id
  5305. // project_id = 0
  5306. // } else if temp[1] == "2" {
  5307. // advice_id = 0
  5308. // project_id = id
  5309. // }
  5310. //
  5311. // info := &models.HisOrderInfo{
  5312. // OrderNumber: order.Number,
  5313. // FeedetlSn: item.FeedetlSn,
  5314. // UploadDate: time.Now().Unix(),
  5315. // AdviceId: advice_id,
  5316. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5317. // Cnt: item.Cnt,
  5318. // Pric: float64(item.Pric),
  5319. // PatientId: his.PatientId,
  5320. // PricUplmtAmt: item.PricUplmtAmt,
  5321. // SelfpayProp: item.SelfpayProp,
  5322. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5323. // OverlmtAmt: item.OverlmtAmt,
  5324. // PreselfpayAmt: item.PreselfpayAmt,
  5325. // BasMednFlag: item.BasMednFlag,
  5326. // MedChrgitmType: item.MedChrgitmType,
  5327. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5328. // Status: 1,
  5329. // Memo: item.Memo,
  5330. // Mtime: time.Now().Unix(),
  5331. // InscpScpAmt: item.InscpScpAmt,
  5332. // DrtReimFlag: item.DrtReimFlag,
  5333. // Ctime: time.Now().Unix(),
  5334. // ListSpItemFlag: item.ListSpItemFlag,
  5335. // ChldMedcFlag: item.ChldMedcFlag,
  5336. // LmtUsedFlag: item.LmtUsedFlag,
  5337. // ChrgitmLv: item.ChrgitmLv,
  5338. // UserOrgId: adminUser.CurrentOrgId,
  5339. // HisPatientId: his.ID,
  5340. // OrderId: order.ID,
  5341. // ProjectId: project_id,
  5342. // Type: types,
  5343. // }
  5344. // service.CreateOrderInfo(info)
  5345. //
  5346. // }
  5347. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5348. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5349. //
  5350. // var total float64
  5351. // for _, item := range prescriptions {
  5352. // if item.Type == 1 { //药品
  5353. // for _, subItem := range item.HisDoctorAdviceInfo {
  5354. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5355. // }
  5356. // }
  5357. // if item.Type == 2 { //项目
  5358. // for _, subItem := range item.HisPrescriptionProject {
  5359. // total = total + (subItem.Price * float64(subItem.Count))
  5360. // }
  5361. // }
  5362. // }
  5363. //
  5364. // for _, item := range prescriptions {
  5365. // for _, subItem := range item.HisAdditionalCharge {
  5366. // total = total + (subItem.Price * float64(subItem.Count))
  5367. // }
  5368. // }
  5369. //
  5370. // allTotal := fmt.Sprintf("%.2f", total)
  5371. // if res.Infcode == 0 {
  5372. // var rf []*ResultFive
  5373. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5374. // psn_no := his.PsnNo
  5375. // mdtrt_id := his.Number
  5376. // chrg_bchno := chrg_bchno
  5377. // cert_no := his.Certno
  5378. // insutype := rf[0].Insutype
  5379. //
  5380. // if his.IdCardType == 1 {
  5381. // cert_no = his.MedicalInsuranceNumber
  5382. //
  5383. // } else {
  5384. //
  5385. // cert_no = his.Certno
  5386. //
  5387. // }
  5388. //
  5389. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5390. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5391. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5392. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5393. // resp, requestErr := http.Get(api)
  5394. // if requestErr != nil {
  5395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5396. // return
  5397. // }
  5398. // defer resp.Body.Close()
  5399. // body, ioErr := ioutil.ReadAll(resp.Body)
  5400. // if ioErr != nil {
  5401. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5402. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5403. // return
  5404. // }
  5405. // var respJSON map[string]interface{}
  5406. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5407. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5408. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5409. // return
  5410. // }
  5411. // fmt.Println(respJSON)
  5412. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5413. // userJSONBytes, _ := json.Marshal(respJSON)
  5414. // var res ResultSeven
  5415. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5416. // utils.ErrorLog("解析失败:%v", err)
  5417. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5418. // return
  5419. // }
  5420. // if res.Infcode != 0 {
  5421. // errlog := &models.HisOrderError{
  5422. // UserOrgId: adminUser.CurrentOrgId,
  5423. // Ctime: time.Now().Unix(),
  5424. // Mtime: time.Now().Unix(),
  5425. // Number: chrg_bchno,
  5426. // ErrMsg: res.ErrMsg,
  5427. // Status: 1,
  5428. // PatientId: id,
  5429. // RecordTime: recordDateTime,
  5430. // Stage: 7,
  5431. // }
  5432. // service.CreateErrMsgLog(errlog)
  5433. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5434. // return
  5435. // } else {
  5436. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5437. // order.OrderStatus = 1
  5438. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5439. // order.SetlId = res.Output.Setlinfo.SetlID
  5440. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5441. // order.PsnName = res.Output.Setlinfo.PsnName
  5442. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5443. // order.Certno = res.Output.Setlinfo.Certno
  5444. // order.Gend = res.Output.Setlinfo.Gend
  5445. // order.Naty = res.Output.Setlinfo.Naty
  5446. // order.Age = res.Output.Setlinfo.Age
  5447. // order.Insutype = res.Output.Setlinfo.Insutype
  5448. // order.PsnType = res.Output.Setlinfo.PsnType
  5449. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5450. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5451. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5452. // order.MedType = res.Output.Setlinfo.MedType
  5453. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5454. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5455. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5456. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5457. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5458. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5459. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5460. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5461. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5462. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5463. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5464. // order.MafPay = res.Output.Setlinfo.MafPay
  5465. // order.OthPay = res.Output.Setlinfo.OthPay
  5466. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5467. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5468. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5469. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5470. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5471. // order.Balc = res.Output.Setlinfo.Balc
  5472. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5473. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5474. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5475. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5476. // order.Creator = order.Creator
  5477. // order.Modify = roles.ID
  5478. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5479. // detailStr := string(setlDetail)
  5480. // order.SetlDetail = detailStr
  5481. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5482. // err = service.UpDateOrder(order)
  5483. // if err == nil {
  5484. // c.ServeSuccessJSON(map[string]interface{}{
  5485. // "msg": "预结算成功",
  5486. // })
  5487. // } else {
  5488. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5489. // return
  5490. // }
  5491. // }
  5492. // } else {
  5493. // adminUser := c.GetAdminUserInfo()
  5494. // errlog := &models.HisOrderError{
  5495. // UserOrgId: adminUser.CurrentOrgId,
  5496. // Ctime: time.Now().Unix(),
  5497. // Mtime: time.Now().Unix(),
  5498. // ErrMsg: res.ErrMsg,
  5499. // Status: 1,
  5500. // PatientId: id,
  5501. // RecordTime: recordDateTime,
  5502. // Stage: 4,
  5503. // }
  5504. // service.CreateErrMsgLog(errlog)
  5505. //
  5506. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5507. // return
  5508. // }
  5509. // } else {
  5510. // adminUser := c.GetAdminUserInfo()
  5511. // errlog := &models.HisOrderError{
  5512. // UserOrgId: adminUser.CurrentOrgId,
  5513. // Ctime: time.Now().Unix(),
  5514. // Mtime: time.Now().Unix(),
  5515. // ErrMsg: res.ErrMsg,
  5516. // Status: 1,
  5517. // PatientId: id,
  5518. // RecordTime: recordDateTime,
  5519. // Stage: 4,
  5520. // }
  5521. // service.CreateErrMsgLog(errlog)
  5522. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5523. // return
  5524. // }
  5525. //
  5526. // } else {
  5527. // var total float64
  5528. // for _, item := range prescriptions {
  5529. // if item.Type == 1 { //药品
  5530. // for _, subItem := range item.HisDoctorAdviceInfo {
  5531. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5532. // }
  5533. // }
  5534. // if item.Type == 2 { //项目
  5535. // for _, subItem := range item.HisPrescriptionProject {
  5536. // total = total + (subItem.Price * float64(subItem.Count))
  5537. // }
  5538. // }
  5539. //
  5540. // for _, subItem := range item.HisAdditionalCharge {
  5541. // total = total + (subItem.Price * float64(subItem.Count))
  5542. // }
  5543. // }
  5544. //
  5545. // allTotal := fmt.Sprintf("%.2f", total)
  5546. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5547. // order := &models.HisOrder{
  5548. // UserOrgId: adminUser.CurrentOrgId,
  5549. // HisPatientId: his.ID,
  5550. // PatientId: id,
  5551. // SettleAccountsDate: recordDateTime,
  5552. // Ctime: time.Now().Unix(),
  5553. // Mtime: time.Now().Unix(),
  5554. // Status: 1,
  5555. // OrderStatus: 2,
  5556. // Number: chrg_bchno,
  5557. // MedfeeSumamt: totals,
  5558. // }
  5559. // err = service.CreateOrder(order)
  5560. // if err != nil {
  5561. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5562. // return
  5563. // }
  5564. //
  5565. // var customs []*Custom
  5566. // for _, item := range prescriptions {
  5567. //
  5568. // if item.Type == 1 { //药品
  5569. // for _, subItem := range item.HisDoctorAdviceInfo {
  5570. // cus := &Custom{
  5571. // AdviceId: subItem.ID,
  5572. // ProjectId: 0,
  5573. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5574. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5575. // FeedetlSn: subItem.FeedetlSn,
  5576. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5577. // MedListCodg: subItem.MedListCodg,
  5578. // Type: 1,
  5579. // }
  5580. // customs = append(customs, cus)
  5581. // }
  5582. // }
  5583. //
  5584. // if item.Type == 2 { //项目
  5585. // for _, subItem := range item.HisPrescriptionProject {
  5586. //
  5587. // cus := &Custom{
  5588. // AdviceId: 0,
  5589. // ProjectId: subItem.ID,
  5590. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5591. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5592. // FeedetlSn: subItem.FeedetlSn,
  5593. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5594. // MedListCodg: subItem.MedListCodg,
  5595. // Type: 2,
  5596. // }
  5597. //
  5598. // customs = append(customs, cus)
  5599. // }
  5600. // }
  5601. //
  5602. // for _, item := range item.HisAdditionalCharge {
  5603. // cus := &Custom{
  5604. // ItemId: item.ID,
  5605. // AdviceId: 0,
  5606. // ProjectId: 0,
  5607. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5608. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5609. // FeedetlSn: item.FeedetlSn,
  5610. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5611. // MedListCodg: item.XtHisAddtionConfig.Code,
  5612. // Type: 3,
  5613. // }
  5614. //
  5615. // customs = append(customs, cus)
  5616. // }
  5617. //
  5618. // }
  5619. //
  5620. // for _, item := range customs {
  5621. // var advice_id int64 = 0
  5622. // var project_id int64 = 0
  5623. // var item_id int64 = 0
  5624. //
  5625. // var types int64 = 0
  5626. //
  5627. // if item.Type == 1 {
  5628. // advice_id = item.AdviceId
  5629. // project_id = 0
  5630. // item_id = 0
  5631. // } else if item.Type == 2 {
  5632. // advice_id = 0
  5633. // item_id = 0
  5634. //
  5635. // project_id = item.ProjectId
  5636. // } else if item.Type == 3 {
  5637. // advice_id = 0
  5638. // item_id = item.ItemId
  5639. // project_id = 0
  5640. // }
  5641. //
  5642. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5643. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5644. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5645. //
  5646. // info := &models.HisOrderInfo{
  5647. // OrderNumber: order.Number,
  5648. // UploadDate: time.Now().Unix(),
  5649. // AdviceId: advice_id,
  5650. // DetItemFeeSumamt: detItemFeeSumamt,
  5651. // Cnt: cut,
  5652. // Pric: pric,
  5653. // PatientId: id,
  5654. // Status: 1,
  5655. // Mtime: time.Now().Unix(),
  5656. // Ctime: time.Now().Unix(),
  5657. // UserOrgId: adminUser.CurrentOrgId,
  5658. // HisPatientId: his.ID,
  5659. // OrderId: order.ID,
  5660. // ProjectId: project_id,
  5661. // Type: types,
  5662. // ItemId: item_id,
  5663. // }
  5664. // service.CreateOrderInfo(info)
  5665. // }
  5666. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5667. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5668. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5669. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5670. // if err == nil {
  5671. // c.ServeSuccessJSON(map[string]interface{}{
  5672. // "msg": "结算成功",
  5673. // })
  5674. // } else {
  5675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5676. // return
  5677. // }
  5678. // }
  5679. //}
  5680. //上传明细-预结算-
  5681. func (c *HisApiController) GetPreUploadInfo() {
  5682. id, _ := c.GetInt64("id")
  5683. record_time := c.GetString("record_time")
  5684. his_patient_id, _ := c.GetInt64("his_patient_id")
  5685. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5686. admin_user_id, _ := c.GetInt64("admin_user_id")
  5687. diagnosis_id := c.GetString("diagnosis")
  5688. sick_type, _ := c.GetInt64("sick_type")
  5689. reg_type, _ := c.GetInt64("p_type")
  5690. begin_time := c.GetString("begin_time")
  5691. id_str := c.GetString("ids")
  5692. ids_arr := strings.Split(id_str, ",")
  5693. timeLayout := "2006-01-02"
  5694. loc, _ := time.LoadLocation("Local")
  5695. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5696. if err != nil {
  5697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5698. return
  5699. }
  5700. recordDateTime := theTime.Unix()
  5701. adminUser := c.GetAdminUserInfo()
  5702. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5703. var config []*models.HisXtDiagnoseConfig
  5704. for _, item := range diagnosis_ids {
  5705. id, _ := strconv.ParseInt(item, 10, 64)
  5706. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5707. config = append(config, &diagnosisConfig)
  5708. }
  5709. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5710. sickConfig, _ := service.FindSickById(sick_type)
  5711. var prescriptions []*models.HisPrescription
  5712. var start_time int64
  5713. var end_time int64
  5714. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5715. fmt.Println(his_patient_id)
  5716. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5717. timestamp := time.Now().Unix()
  5718. tempTime := time.Unix(timestamp, 0)
  5719. timeFormat := tempTime.Format("20060102150405")
  5720. chrgBchno := rand.Intn(100000) + 10000
  5721. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5722. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5723. var patientPrescription models.HisPrescriptionInfo
  5724. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5725. if patientPrescription.ID == 0 {
  5726. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5727. }
  5728. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5729. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5730. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5731. strconv.FormatInt(his.PatientId, 10)
  5732. var res2 ResultSix
  5733. var resSix10265 ResultSix10265
  5734. var time_stamp string
  5735. if miConfig.MdtrtareaAdmvs == "421300" {
  5736. data := make(map[string]interface{})
  5737. client := &http.Client{}
  5738. data["psn_no"] = his.PsnNo
  5739. data["mdtrt_id"] = his.Number
  5740. data["doctor"] = roles.UserName
  5741. data["department"] = department.Name
  5742. data["org_name"] = miConfig.OrgName
  5743. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5744. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5745. data["fixmedins_code"] = miConfig.Code
  5746. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5747. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5748. data["secret_key"] = miConfig.SecretKey
  5749. data["sick_code"] = sickConfig.CountryCode
  5750. data["sick_name"] = sickConfig.ClassName
  5751. data["begin_time"] = begin_time
  5752. data["dept"] = strconv.FormatInt(department.ID, 10)
  5753. data["config"] = config
  5754. fmt.Println(data)
  5755. bytesData, _ := json.Marshal(data)
  5756. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5757. resp, _ := client.Do(req)
  5758. defer resp.Body.Close()
  5759. body, ioErr := ioutil.ReadAll(resp.Body)
  5760. if ioErr != nil {
  5761. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5763. return
  5764. }
  5765. var respJSON map[string]interface{}
  5766. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5769. return
  5770. }
  5771. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5772. userJSONBytes, _ := json.Marshal(respJSON)
  5773. fmt.Println("log")
  5774. fmt.Println(string(userJSONBytes))
  5775. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5776. utils.ErrorLog("解析失败:%v", err)
  5777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5778. return
  5779. }
  5780. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5781. //江苏地区国家医保医疗类别
  5782. //职工透析:医疗类别选特殊情况门诊9933
  5783. //居民血透门慢: 医疗类别选门诊慢病1402
  5784. //var med_type string
  5785. //if his.Insutype == "310" {
  5786. // if reg_type == 14 {
  5787. // med_type = "9933"
  5788. // } else if reg_type == 11 {
  5789. // med_type = "11"
  5790. //
  5791. // }
  5792. //} else if his.Insutype == "390" {
  5793. // if reg_type == 14 {
  5794. // med_type = "1402"
  5795. // } else if reg_type == 11 {
  5796. // med_type = "11"
  5797. // }
  5798. //}
  5799. data := make(map[string]interface{})
  5800. client := &http.Client{}
  5801. data["psn_no"] = his.PsnNo
  5802. data["mdtrt_id"] = his.Number
  5803. data["doctor"] = roles.UserName
  5804. data["department"] = department.Name
  5805. data["org_name"] = miConfig.OrgName
  5806. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5807. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5808. data["fixmedins_code"] = miConfig.Code
  5809. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5810. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5811. data["secret_key"] = miConfig.SecretKey
  5812. data["sick_code"] = sickConfig.CountryCode
  5813. data["sick_name"] = sickConfig.ClassName
  5814. data["begin_time"] = begin_time
  5815. data["dept"] = strconv.FormatInt(department.ID, 10)
  5816. data["config"] = config
  5817. data["url"] = miConfig.Url
  5818. data["ak"] = miConfig.AccessKey
  5819. data["cainfo"] = miConfig.Cainfo
  5820. bytesData, _ := json.Marshal(data)
  5821. var req *http.Request
  5822. if miConfig.MdtrtareaAdmvs == "320921" {
  5823. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5824. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5825. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5826. } else {
  5827. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5828. }
  5829. resp, _ := client.Do(req)
  5830. defer resp.Body.Close()
  5831. body, ioErr := ioutil.ReadAll(resp.Body)
  5832. if ioErr != nil {
  5833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5835. return
  5836. }
  5837. var respJSON map[string]interface{}
  5838. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5841. return
  5842. }
  5843. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5844. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5845. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5847. userJSONBytes, _ := json.Marshal(respJSON)
  5848. fmt.Println("log")
  5849. fmt.Println(string(userJSONBytes))
  5850. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5851. utils.ErrorLog("解析失败:%v", err)
  5852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5853. return
  5854. }
  5855. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5856. res2.Output = resSix10265.Output
  5857. res2.ErrMsg = resSix10265.ErrMsg
  5858. res2.Cainfo = resSix10265.Cainfo
  5859. res2.WarnMsg = resSix10265.WarnMsg
  5860. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5861. res2.Infcode = infocode
  5862. } else {
  5863. var result string
  5864. var requestLog string
  5865. if miConfig.MdtrtareaAdmvs == "440781" { //
  5866. 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)
  5867. } else {
  5868. if miConfig.Code == "H15049901371" {
  5869. //赤峰地区国家医保医疗类别
  5870. //职工透析:医疗类别选特殊情况门诊990502
  5871. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5872. var med_type string
  5873. if his.Insutype == "390" {
  5874. if reg_type == 14 {
  5875. med_type = "9933"
  5876. } else if reg_type == 11 {
  5877. med_type = "11"
  5878. }
  5879. } else if his.Insutype == "310" {
  5880. if reg_type == 14 {
  5881. med_type = "990502"
  5882. } else if reg_type == 11 {
  5883. med_type = "11"
  5884. }
  5885. }
  5886. 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)
  5887. } else {
  5888. 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)
  5889. }
  5890. saveLog(result, requestLog, "2203", "上传就诊信息")
  5891. var respJSON2 map[string]interface{}
  5892. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5895. return
  5896. }
  5897. userJSONBytes2, _ := json.Marshal(respJSON2)
  5898. if miConfig.Code == "H15049901371" {
  5899. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5900. utils.ErrorLog("解析失败:%v", err)
  5901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5902. return
  5903. }
  5904. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5905. res2.Output = resSix10265.Output
  5906. res2.ErrMsg = resSix10265.ErrMsg
  5907. res2.Cainfo = resSix10265.Cainfo
  5908. res2.WarnMsg = resSix10265.WarnMsg
  5909. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5910. res2.Infcode = infocode
  5911. } else {
  5912. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5913. utils.ErrorLog("解析失败:%v", err)
  5914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5915. return
  5916. }
  5917. }
  5918. }
  5919. }
  5920. if res2.Infcode != 0 {
  5921. adminUser := c.GetAdminUserInfo()
  5922. errlog := &models.HisOrderError{
  5923. UserOrgId: adminUser.CurrentOrgId,
  5924. Ctime: time.Now().Unix(),
  5925. Mtime: time.Now().Unix(),
  5926. ErrMsg: res2.ErrMsg,
  5927. Status: 1,
  5928. PatientId: id,
  5929. RecordTime: recordDateTime,
  5930. Stage: 3,
  5931. }
  5932. service.CreateErrMsgLog(errlog)
  5933. c.ServeSuccessJSON(map[string]interface{}{
  5934. "failed_code": -10,
  5935. "msg": res2.ErrMsg,
  5936. })
  5937. return
  5938. } else {
  5939. his.Diagnosis = diagnosis_id
  5940. his.SickType = sickConfig.ID
  5941. his.PType = fmt.Sprintf("%d", reg_type)
  5942. service.UpdateHisPatientThree(&his)
  5943. data := make(map[string]interface{})
  5944. if settle_accounts_type == 1 { //日结
  5945. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5946. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5947. } else {
  5948. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5949. }
  5950. data["pre"] = prescriptions
  5951. } else { //月结
  5952. start_time_str := c.GetString("start_time")
  5953. end_time_str := c.GetString("end_time")
  5954. timeLayout := "2006-01-02"
  5955. loc, _ := time.LoadLocation("Local")
  5956. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5957. if err != nil {
  5958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5959. return
  5960. }
  5961. recordStartTime := theStartTime.Unix()
  5962. start_time = recordStartTime
  5963. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5964. if err != nil {
  5965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5966. return
  5967. }
  5968. recordEndTime := theEndTime.Unix()
  5969. end_time = recordEndTime
  5970. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5971. data["pre"] = prescriptions
  5972. }
  5973. client := &http.Client{}
  5974. data["psn_no"] = his.PsnNo
  5975. data["mdtrt_id"] = his.Number
  5976. data["chrg_bchno"] = chrg_bchno
  5977. data["org_name"] = miConfig.OrgName
  5978. data["doctor"] = roles.UserName
  5979. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5980. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5981. data["fixmedins_code"] = miConfig.Code
  5982. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5983. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5984. data["dept_code"] = "15"
  5985. } else {
  5986. data["dept_code"] = department.Number
  5987. }
  5988. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5989. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5990. data["secret_key"] = miConfig.SecretKey
  5991. data["url"] = miConfig.Url
  5992. data["ak"] = miConfig.AccessKey
  5993. data["new_doctor_name"] = patientPrescription.Doctor
  5994. data["diag_code"] = sickConfig.CountryCode
  5995. data["time_stamp"] = time_stamp
  5996. data["cainfo"] = miConfig.Cainfo
  5997. var ids []int64
  5998. for _, item := range prescriptions {
  5999. ids = append(ids, item.ID)
  6000. }
  6001. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6002. if config.IsOpen == 1 { //对接了医保,走医保流程
  6003. var res ResultFour
  6004. var resFour10265 ResultFour10265
  6005. if miConfig.MdtrtareaAdmvs == "421300" {
  6006. bytesData, _ := json.Marshal(data)
  6007. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6008. resp, _ := client.Do(req)
  6009. defer resp.Body.Close()
  6010. body, ioErr := ioutil.ReadAll(resp.Body)
  6011. if ioErr != nil {
  6012. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6014. return
  6015. }
  6016. var respJSON map[string]interface{}
  6017. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6018. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6020. return
  6021. }
  6022. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6023. userJSONBytes, _ := json.Marshal(respJSON)
  6024. fmt.Println("log")
  6025. fmt.Println(string(userJSONBytes))
  6026. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6027. utils.ErrorLog("解析失败:%v", err)
  6028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6029. return
  6030. }
  6031. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6032. bytesData, _ := json.Marshal(data)
  6033. var req *http.Request
  6034. if miConfig.MdtrtareaAdmvs == "320921" {
  6035. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6036. } else {
  6037. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6038. }
  6039. resp, _ := client.Do(req)
  6040. defer resp.Body.Close()
  6041. body, ioErr := ioutil.ReadAll(resp.Body)
  6042. if ioErr != nil {
  6043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6045. return
  6046. }
  6047. var respJSON map[string]interface{}
  6048. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6049. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6051. return
  6052. }
  6053. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6054. userJSONBytes, _ := json.Marshal(respJSON)
  6055. fmt.Println("log")
  6056. fmt.Println(string(userJSONBytes))
  6057. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6058. utils.ErrorLog("解析失败:%v", err)
  6059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6060. return
  6061. }
  6062. res.InfRefmsgid = resFour10265.InfRefmsgid
  6063. res.Output = resFour10265.Output
  6064. res.ErrMsg = resFour10265.ErrMsg
  6065. res.Cainfo = resFour10265.Cainfo
  6066. res.WarnMsg = resFour10265.WarnMsg
  6067. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6068. res.Infcode = infocode
  6069. } else {
  6070. if miConfig.Code == "H15049901371" {
  6071. 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)
  6072. var dat map[string]interface{}
  6073. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6074. fmt.Println(dat)
  6075. } else {
  6076. fmt.Println(err)
  6077. }
  6078. saveLog(result, request_log, "2204", "上传费用明细")
  6079. userJSONBytes, _ := json.Marshal(dat)
  6080. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6081. utils.ErrorLog("解析失败:%v", err)
  6082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6083. return
  6084. }
  6085. res.InfRefmsgid = resFour10265.InfRefmsgid
  6086. res.Output = resFour10265.Output
  6087. res.ErrMsg = resFour10265.ErrMsg
  6088. res.Cainfo = resFour10265.Cainfo
  6089. res.WarnMsg = resFour10265.WarnMsg
  6090. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6091. res.Infcode = infocode
  6092. } else {
  6093. 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)
  6094. var dat map[string]interface{}
  6095. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6096. fmt.Println(dat)
  6097. } else {
  6098. fmt.Println(err)
  6099. }
  6100. saveLog(result, request_log, "2204", "上传费用明细")
  6101. userJSONBytes, _ := json.Marshal(dat)
  6102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6103. utils.ErrorLog("解析失败:%v", err)
  6104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6105. return
  6106. }
  6107. }
  6108. }
  6109. if res.Infcode == 0 {
  6110. order := &models.HisOrder{
  6111. UserOrgId: adminUser.CurrentOrgId,
  6112. HisPatientId: his.ID,
  6113. PatientId: his.PatientId,
  6114. SettleAccountsDate: recordDateTime,
  6115. Ctime: time.Now().Unix(),
  6116. Mtime: time.Now().Unix(),
  6117. MdtrtId: his.Number,
  6118. PsnNo: his.PsnNo,
  6119. MedType: strconv.FormatInt(reg_type, 10),
  6120. Status: 1,
  6121. Number: chrg_bchno,
  6122. Infcode: res.Infcode,
  6123. WarnMsg: res.WarnMsg,
  6124. Cainfo: res.Cainfo,
  6125. ErrMsg: res.ErrMsg,
  6126. RespondTime: res.RefmsgTime,
  6127. InfRefmsgid: res.InfRefmsgid,
  6128. OrderStatus: 1,
  6129. IsMedicineInsurance: 1,
  6130. SettleType: settle_accounts_type,
  6131. SettleStartTime: start_time,
  6132. SettleEndTime: end_time,
  6133. Creator: roles.AdminUserId,
  6134. Modify: roles.AdminUserId,
  6135. PType: 2,
  6136. Diagnosis: diagnosis_id,
  6137. }
  6138. err = service.CreateOrder(order)
  6139. if err != nil {
  6140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6141. return
  6142. }
  6143. for _, item := range res.Output.Result {
  6144. temp := strings.Split(item.FeedetlSn, "-")
  6145. var advice_id int64 = 0
  6146. var project_id int64 = 0
  6147. var types int64 = 0
  6148. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6149. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6150. if temp[1] == "1" {
  6151. advice_id = id
  6152. project_id = 0
  6153. } else if temp[1] == "2" {
  6154. advice_id = 0
  6155. project_id = id
  6156. }
  6157. info := &models.HisOrderInfo{
  6158. OrderNumber: order.Number,
  6159. FeedetlSn: item.FeedetlSn,
  6160. UploadDate: time.Now().Unix(),
  6161. AdviceId: advice_id,
  6162. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6163. Cnt: item.Cnt,
  6164. Pric: float64(item.Pric),
  6165. PatientId: his.PatientId,
  6166. PricUplmtAmt: item.PricUplmtAmt,
  6167. SelfpayProp: item.SelfpayProp,
  6168. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6169. OverlmtAmt: item.OverlmtAmt,
  6170. PreselfpayAmt: item.PreselfpayAmt,
  6171. BasMednFlag: item.BasMednFlag,
  6172. MedChrgitmType: item.MedChrgitmType,
  6173. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6174. Status: 1,
  6175. Memo: item.Memo,
  6176. Mtime: time.Now().Unix(),
  6177. InscpScpAmt: item.InscpScpAmt,
  6178. DrtReimFlag: item.DrtReimFlag,
  6179. Ctime: time.Now().Unix(),
  6180. ListSpItemFlag: item.ListSpItemFlag,
  6181. ChldMedcFlag: item.ChldMedcFlag,
  6182. LmtUsedFlag: item.LmtUsedFlag,
  6183. ChrgitmLv: item.ChrgitmLv,
  6184. UserOrgId: adminUser.CurrentOrgId,
  6185. HisPatientId: his.ID,
  6186. OrderId: order.ID,
  6187. ProjectId: project_id,
  6188. Type: types,
  6189. }
  6190. service.CreateOrderInfo(info)
  6191. }
  6192. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6193. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6194. var total float64
  6195. for _, item := range prescriptions {
  6196. if item.Type == 1 { //药品
  6197. for _, subItem := range item.HisDoctorAdviceInfo {
  6198. total = total + (subItem.Price * subItem.PrescribingNumber)
  6199. }
  6200. }
  6201. if item.Type == 2 { //项目
  6202. for _, subItem := range item.HisPrescriptionProject {
  6203. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6204. total = total + (subItem.Price * cnt)
  6205. }
  6206. }
  6207. }
  6208. for _, item := range prescriptions {
  6209. for _, subItem := range item.HisAdditionalCharge {
  6210. total = total + (subItem.Price * float64(subItem.Count))
  6211. }
  6212. }
  6213. allTotal := fmt.Sprintf("%.4f", total)
  6214. if res.Infcode == 0 {
  6215. var rf []*ResultFive
  6216. json.Unmarshal([]byte(his.Iinfo), &rf)
  6217. chrg_bchno := chrg_bchno
  6218. cert_no := his.Certno
  6219. var insutypes []string
  6220. var insutype string
  6221. var is390 int = 0
  6222. var is310 int = 0
  6223. for _, item := range rf {
  6224. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6225. insutypes = append(insutypes, item.Insutype)
  6226. }
  6227. }
  6228. if len(insutypes) == 1 {
  6229. insutype = insutypes[0]
  6230. } else {
  6231. for _, i := range insutypes {
  6232. if i == "390" {
  6233. is390 = 1
  6234. }
  6235. if i == "310" {
  6236. is310 = 1
  6237. }
  6238. }
  6239. }
  6240. if is390 == 1 {
  6241. insutype = "390"
  6242. }
  6243. if is310 == 1 {
  6244. insutype = "310"
  6245. }
  6246. if len(insutypes) == 0 {
  6247. insutype = "310"
  6248. }
  6249. if len(insutypes) == 2 {
  6250. insutype = strconv.FormatInt(his.SocialType, 64)
  6251. }
  6252. //insutype = "390"
  6253. if his.IdCardType == 1 {
  6254. cert_no = his.MedicalInsuranceNumber
  6255. } else {
  6256. cert_no = his.Certno
  6257. }
  6258. var res ResultSeven
  6259. var resSeven10265 ResultSeven10265
  6260. if miConfig.MdtrtareaAdmvs == "421300" {
  6261. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6262. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6263. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6264. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6265. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6266. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6267. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6268. resp, requestErr := http.Get(api)
  6269. if requestErr != nil {
  6270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6271. return
  6272. }
  6273. body, ioErr := ioutil.ReadAll(resp.Body)
  6274. if ioErr != nil {
  6275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6277. return
  6278. }
  6279. var respJSON map[string]interface{}
  6280. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6283. return
  6284. }
  6285. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6286. result, _ := json.Marshal(respJSON)
  6287. fmt.Println("log")
  6288. fmt.Println(string(result))
  6289. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6290. utils.ErrorLog("解析失败:%v", err)
  6291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6292. return
  6293. }
  6294. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6295. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6296. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6297. bas := strings.Split(psn_info.CardInfo, "|")
  6298. if his.IdCardType == 1 {
  6299. cert_no = bas[2]
  6300. } else {
  6301. cert_no = bas[1]
  6302. }
  6303. //江苏地区国家医保医疗类别
  6304. //职工透析:医疗类别选特殊情况门诊9933
  6305. //居民血透门慢: 医疗类别选门诊慢病1402
  6306. //var med_type string
  6307. //if his.Insutype == "310" {
  6308. // if reg_type == 14 {
  6309. // med_type = "9933"
  6310. // } else if reg_type == 11 {
  6311. // med_type = "11"
  6312. //
  6313. // }
  6314. //} else if his.Insutype == "390" {
  6315. // if reg_type == 14 {
  6316. // med_type = "1402"
  6317. // } else if reg_type == 11 {
  6318. // med_type = "11"
  6319. // }
  6320. //}
  6321. var api string
  6322. if miConfig.MdtrtareaAdmvs == "320921" {
  6323. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6324. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6325. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6326. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6327. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6328. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6329. "&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
  6330. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6331. } else {
  6332. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6333. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6334. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6335. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6336. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6337. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6338. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6339. "&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
  6340. }
  6341. resp, requestErr := http.Get(api)
  6342. if requestErr != nil {
  6343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6344. return
  6345. }
  6346. body, ioErr := ioutil.ReadAll(resp.Body)
  6347. if ioErr != nil {
  6348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6350. return
  6351. }
  6352. var respJSON map[string]interface{}
  6353. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6356. return
  6357. }
  6358. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6359. result, _ := json.Marshal(respJSON)
  6360. fmt.Println("log")
  6361. fmt.Println(string(result))
  6362. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6363. utils.ErrorLog("解析失败:%v", err)
  6364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6365. return
  6366. }
  6367. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6368. res.Output = resSeven10265.Output
  6369. res.ErrMsg = resSeven10265.ErrMsg
  6370. res.Cainfo = resSeven10265.Cainfo
  6371. res.WarnMsg = resSeven10265.WarnMsg
  6372. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6373. res.Infcode = infocode
  6374. } else {
  6375. var result string
  6376. var request_log string
  6377. if miConfig.Code == "H15049901371" {
  6378. //赤峰地区国家医保医疗类别
  6379. //职工透析:医疗类别选特殊情况门诊990502
  6380. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6381. var med_type string
  6382. if his.Insutype == "390" {
  6383. if reg_type == 14 {
  6384. med_type = "9933"
  6385. } else if reg_type == 11 {
  6386. med_type = "11"
  6387. }
  6388. } else if his.Insutype == "310" {
  6389. if reg_type == 14 {
  6390. med_type = "990502"
  6391. } else if reg_type == 11 {
  6392. med_type = "11"
  6393. }
  6394. }
  6395. 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)
  6396. } else {
  6397. 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)
  6398. }
  6399. var dat map[string]interface{}
  6400. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6401. fmt.Println(dat)
  6402. } else {
  6403. fmt.Println(err)
  6404. }
  6405. saveLog(result, request_log, "2206", "预结算")
  6406. //userJSONBytes, _ := json.Marshal(dat)
  6407. //
  6408. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6409. // utils.ErrorLog("解析失败:%v", err)
  6410. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6411. // return
  6412. //}
  6413. userJSONBytes, _ := json.Marshal(dat)
  6414. if miConfig.Code == "H15049901371" {
  6415. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6416. utils.ErrorLog("解析失败:%v", err)
  6417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6418. return
  6419. }
  6420. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6421. res.Output = resSeven10265.Output
  6422. res.ErrMsg = resSeven10265.ErrMsg
  6423. res.Cainfo = resSeven10265.Cainfo
  6424. res.WarnMsg = resSeven10265.WarnMsg
  6425. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6426. res.Infcode = infocode
  6427. } else {
  6428. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6429. utils.ErrorLog("解析失败:%v", err)
  6430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6431. return
  6432. }
  6433. }
  6434. }
  6435. if res.Infcode != 0 {
  6436. errlog := &models.HisOrderError{
  6437. UserOrgId: adminUser.CurrentOrgId,
  6438. Ctime: time.Now().Unix(),
  6439. Mtime: time.Now().Unix(),
  6440. Number: chrg_bchno,
  6441. ErrMsg: res.ErrMsg,
  6442. Status: 1,
  6443. PatientId: id,
  6444. RecordTime: recordDateTime,
  6445. Stage: 20,
  6446. }
  6447. service.CreateErrMsgLog(errlog)
  6448. c.ServeSuccessJSON(map[string]interface{}{
  6449. "failed_code": -10,
  6450. "msg": res.ErrMsg,
  6451. })
  6452. return
  6453. } else {
  6454. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6455. order.OrderStatus = 1
  6456. order.IsPre = 1
  6457. order.Status = 1
  6458. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6459. order.SetlId = res.Output.Setlinfo.SetlID
  6460. order.PsnNo = res.Output.Setlinfo.PsnNo
  6461. order.PsnName = res.Output.Setlinfo.PsnName
  6462. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6463. order.Certno = res.Output.Setlinfo.Certno
  6464. order.Gend = res.Output.Setlinfo.Gend
  6465. order.Naty = res.Output.Setlinfo.Naty
  6466. order.Age = res.Output.Setlinfo.Age
  6467. order.Insutype = res.Output.Setlinfo.Insutype
  6468. order.PsnType = res.Output.Setlinfo.PsnType
  6469. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6470. order.SetlTime = res.Output.Setlinfo.SetlTime
  6471. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6472. if res.Output.Setlinfo.MedType == "140101" {
  6473. order.MedType = "14"
  6474. } else {
  6475. order.MedType = res.Output.Setlinfo.MedType
  6476. }
  6477. if reg_type == 1112 {
  6478. order.MedType = "1112"
  6479. }
  6480. if reg_type == 1111 {
  6481. order.MedType = "1111"
  6482. }
  6483. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6484. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6485. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6486. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6487. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6488. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6489. order.HifpPay = res.Output.Setlinfo.HifpPay
  6490. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6491. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6492. order.HifesPay = res.Output.Setlinfo.HifesPay
  6493. order.HifobPay = res.Output.Setlinfo.HifobPay
  6494. order.MafPay = res.Output.Setlinfo.MafPay
  6495. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6496. order.OthPay = res.Output.Setlinfo.OthPay
  6497. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6498. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6499. order.AcctPay = res.Output.Setlinfo.AcctPay
  6500. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6501. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6502. order.Balc = res.Output.Setlinfo.Balc
  6503. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6504. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6505. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6506. order.ClrWay = res.Output.Setlinfo.ClrWay
  6507. order.Creator = order.Creator
  6508. order.Modify = roles.AdminUserId
  6509. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6510. detailStr := string(setlDetail)
  6511. order.SetlDetail = detailStr
  6512. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6513. err = service.UpDateOrder(order)
  6514. if err == nil {
  6515. c.ServeSuccessJSON(map[string]interface{}{
  6516. "msg": "预结算成功",
  6517. })
  6518. } else {
  6519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6520. return
  6521. }
  6522. }
  6523. } else {
  6524. adminUser := c.GetAdminUserInfo()
  6525. errlog := &models.HisOrderError{
  6526. UserOrgId: adminUser.CurrentOrgId,
  6527. Ctime: time.Now().Unix(),
  6528. Mtime: time.Now().Unix(),
  6529. ErrMsg: res.ErrMsg,
  6530. Status: 1,
  6531. PatientId: id,
  6532. RecordTime: recordDateTime,
  6533. Stage: 4,
  6534. }
  6535. service.CreateErrMsgLog(errlog)
  6536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6537. return
  6538. }
  6539. } else {
  6540. adminUser := c.GetAdminUserInfo()
  6541. errlog := &models.HisOrderError{
  6542. UserOrgId: adminUser.CurrentOrgId,
  6543. Ctime: time.Now().Unix(),
  6544. Mtime: time.Now().Unix(),
  6545. ErrMsg: res.ErrMsg,
  6546. Status: 1,
  6547. PatientId: id,
  6548. RecordTime: recordDateTime,
  6549. Stage: 4,
  6550. }
  6551. service.CreateErrMsgLog(errlog)
  6552. c.ServeSuccessJSON(map[string]interface{}{
  6553. "failed_code": -10,
  6554. "msg": res.ErrMsg,
  6555. })
  6556. return
  6557. }
  6558. }
  6559. }
  6560. }
  6561. //func (c *HisApiController) GetSettleInfo() {
  6562. // id, _ := c.GetInt64("id")
  6563. // order_id, _ := c.GetInt64("order_id")
  6564. //
  6565. // record_time := c.GetString("record_time")
  6566. // pay_way, _ := c.GetInt64("pay_way")
  6567. // pay_price, _ := c.GetFloat("pay_price")
  6568. // pay_card_no := c.GetString("pay_card_no")
  6569. // discount_price, _ := c.GetFloat("discount_price")
  6570. // preferential_price, _ := c.GetFloat("preferential_price")
  6571. // reality_price, _ := c.GetFloat("reality_price")
  6572. // found_price, _ := c.GetFloat("found_price")
  6573. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6574. // private_price, _ := c.GetFloat("private_price")
  6575. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6576. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6577. //
  6578. // timeLayout := "2006-01-02"
  6579. // loc, _ := time.LoadLocation("Local")
  6580. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6581. // if err != nil {
  6582. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6583. // return
  6584. // }
  6585. // recordDateTime := theTime.Unix()
  6586. // adminUser := c.GetAdminUserInfo()
  6587. //
  6588. // var prescriptions []*models.HisPrescription
  6589. //
  6590. // data := make(map[string]interface{})
  6591. // if settle_accounts_type == 1 { //日结
  6592. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6593. // data["pre"] = prescriptions
  6594. //
  6595. // } else { //月结
  6596. // start_time_str := c.GetString("start_time")
  6597. // end_time_str := c.GetString("end_time")
  6598. // timeLayout := "2006-01-02"
  6599. // loc, _ := time.LoadLocation("Local")
  6600. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6601. // if err != nil {
  6602. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6603. // return
  6604. // }
  6605. // recordStartTime := theStartTime.Unix()
  6606. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6607. // if err != nil {
  6608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6609. // return
  6610. // }
  6611. // recordEndTime := theEndTime.Unix()
  6612. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6613. // data["pre"] = prescriptions
  6614. //
  6615. // }
  6616. //
  6617. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6618. //
  6619. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6620. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6621. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6622. // strconv.FormatInt(his.PatientId, 10)
  6623. //
  6624. // order_src, _ := service.GetHisOrderByID(order_id)
  6625. //
  6626. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6627. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6628. //
  6629. // var total float64
  6630. // for _, item := range prescriptions {
  6631. // if item.Type == 1 { //药品
  6632. // for _, subItem := range item.HisDoctorAdviceInfo {
  6633. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6634. // }
  6635. // }
  6636. // if item.Type == 2 { //项目
  6637. // for _, subItem := range item.HisPrescriptionProject {
  6638. // total = total + (subItem.Price * float64(subItem.Count))
  6639. // }
  6640. // }
  6641. // }
  6642. //
  6643. // for _, item := range prescriptions {
  6644. // for _, subItem := range item.HisAdditionalCharge {
  6645. // total = total + (subItem.Price * float64(subItem.Count))
  6646. // }
  6647. // }
  6648. //
  6649. // allTotal := fmt.Sprintf("%.2f", total)
  6650. // var rf []*ResultFive
  6651. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6652. // psn_no := order_src.PsnNo
  6653. // mdtrt_id := order_src.MdtrtId
  6654. // chrg_bchno := order_src.Number
  6655. // cert_no := order_src.Certno
  6656. // insutype := rf[0].Insutype
  6657. //
  6658. // if his.IdCardType == 1 {
  6659. // cert_no = his.MedicalInsuranceNumber
  6660. // } else {
  6661. // cert_no = his.Certno
  6662. // }
  6663. //
  6664. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  6665. // var dat map[string]interface{}
  6666. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6667. // fmt.Println(dat)
  6668. // } else {
  6669. // fmt.Println(err)
  6670. // }
  6671. //
  6672. // userJSONBytes, _ := json.Marshal(dat)
  6673. //
  6674. //
  6675. //
  6676. // var res ResultSeven
  6677. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6678. // utils.ErrorLog("解析失败:%v", err)
  6679. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6680. // return
  6681. // }
  6682. // if res.Infcode == -1 {
  6683. // errlog := &models.HisOrderError{
  6684. // UserOrgId: adminUser.CurrentOrgId,
  6685. // Ctime: time.Now().Unix(),
  6686. // Mtime: time.Now().Unix(),
  6687. // Number: chrg_bchno,
  6688. // ErrMsg: res.ErrMsg,
  6689. // Status: 1,
  6690. // PatientId: id,
  6691. // RecordTime: recordDateTime,
  6692. // Stage: 6,
  6693. // }
  6694. // service.CreateErrMsgLog(errlog)
  6695. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6696. // return
  6697. // } else {
  6698. // order_src.OrderStatus = 2
  6699. // order_src.PayWay = pay_way
  6700. // order_src.PayPrice = pay_price
  6701. // order_src.PayCardNo = pay_card_no
  6702. // order_src.DiscountPrice = discount_price
  6703. // order_src.PreferentialPrice = preferential_price
  6704. // order_src.RealityPrice = reality_price
  6705. // order_src.FoundPrice = found_price
  6706. // order_src.MedicalInsurancePrice = medical_insurance_price
  6707. // order_src.PrivatePrice = private_price
  6708. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6709. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6710. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6711. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6712. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6713. // order_src.Certno = res.Output.Setlinfo.Certno
  6714. // order_src.Gend = res.Output.Setlinfo.Gend
  6715. // order_src.Naty = res.Output.Setlinfo.Naty
  6716. // order_src.Age = res.Output.Setlinfo.Age
  6717. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6718. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6719. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6720. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6721. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6722. // order_src.MedType = res.Output.Setlinfo.MedType
  6723. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6724. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6725. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6726. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6727. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6728. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6729. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6730. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6731. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6732. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6733. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6734. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6735. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6736. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6737. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6738. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6739. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6740. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6741. // order_src.Balc = res.Output.Setlinfo.Balc
  6742. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6743. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6744. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6745. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6746. // order_src.Creator = order_src.Creator
  6747. // order_src.Modify = roles.ID
  6748. // order_src.RequestLog = src_resquest
  6749. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6750. // detailStr := string(setlDetail)
  6751. // order_src.SetlDetail = detailStr
  6752. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6753. // err = service.UpDateOrder(order_src)
  6754. //
  6755. // if err == nil {
  6756. // c.ServeSuccessJSON(map[string]interface{}{
  6757. // "msg": "结算成功",
  6758. // })
  6759. // } else {
  6760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6761. // return
  6762. // }
  6763. // }
  6764. // }
  6765. //}
  6766. //退款
  6767. func (c *HisApiController) Refund() {
  6768. order_id, _ := c.GetInt64("order_id")
  6769. admin_user_id, _ := c.GetInt64("admin_user_id")
  6770. adminUser := c.GetAdminUserInfo()
  6771. var order models.HisOrder
  6772. order, _ = service.GetHisOrderByID(order_id)
  6773. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6774. if order.ID == 0 {
  6775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6776. return
  6777. }
  6778. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6779. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6780. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6781. if config.IsOpen == 1 { //对接了医保,走医保流程
  6782. var res ResultSixteen
  6783. var resSixteen10265 ResultSixteen10265
  6784. var src_resquest string
  6785. var result string
  6786. if miConfig.MdtrtareaAdmvs == "421300" {
  6787. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6788. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6789. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6790. resp3, requestErr3 := http.Get(api3)
  6791. if requestErr3 != nil {
  6792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6793. return
  6794. }
  6795. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6796. if ioErr3 != nil {
  6797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6799. return
  6800. }
  6801. var respJSON3 map[string]interface{}
  6802. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6805. return
  6806. }
  6807. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6808. userJSONBytes3, _ := json.Marshal(respJSON3)
  6809. fmt.Println("log")
  6810. fmt.Println(string(userJSONBytes3))
  6811. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6812. utils.ErrorLog("解析失败:%v", err)
  6813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6814. return
  6815. }
  6816. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6817. var api3 string
  6818. if miConfig.MdtrtareaAdmvs == "320921" {
  6819. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6820. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6821. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6822. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6823. } else {
  6824. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6825. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6826. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6827. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6828. }
  6829. resp3, requestErr3 := http.Get(api3)
  6830. if requestErr3 != nil {
  6831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6832. return
  6833. }
  6834. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6835. if ioErr3 != nil {
  6836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6838. return
  6839. }
  6840. var respJSON3 map[string]interface{}
  6841. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6844. return
  6845. }
  6846. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6847. userJSONBytes3, _ := json.Marshal(respJSON3)
  6848. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6849. utils.ErrorLog("解析失败:%v", err)
  6850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6851. return
  6852. }
  6853. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6854. res.Output = resSixteen10265.Output
  6855. res.ErrMsg = resSixteen10265.ErrMsg
  6856. res.Cainfo = resSixteen10265.Cainfo
  6857. res.WarnMsg = resSixteen10265.WarnMsg
  6858. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6859. res.Infcode = infocode
  6860. } else {
  6861. if miConfig.Code == "H15049901371" {
  6862. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6863. var dat map[string]interface{}
  6864. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6865. fmt.Println(dat)
  6866. } else {
  6867. fmt.Println(err)
  6868. }
  6869. saveLog(result, src_resquest, "2208", "退费")
  6870. userJSONBytes, _ := json.Marshal(dat)
  6871. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6872. utils.ErrorLog("解析失败:%v", err)
  6873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6874. return
  6875. }
  6876. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6877. res.Output = resSixteen10265.Output
  6878. res.ErrMsg = resSixteen10265.ErrMsg
  6879. res.Cainfo = resSixteen10265.Cainfo
  6880. res.WarnMsg = resSixteen10265.WarnMsg
  6881. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6882. res.Infcode = infocode
  6883. } else {
  6884. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6885. var dat map[string]interface{}
  6886. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6887. fmt.Println(dat)
  6888. } else {
  6889. fmt.Println(err)
  6890. }
  6891. saveLog(result, src_resquest, "2208", "退费")
  6892. userJSONBytes, _ := json.Marshal(dat)
  6893. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6894. utils.ErrorLog("解析失败:%v", err)
  6895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6896. return
  6897. }
  6898. }
  6899. }
  6900. if res.Infcode == 0 {
  6901. var res2 ResultSix
  6902. var resSix10265 ResultSix10265
  6903. if miConfig.MdtrtareaAdmvs == "421300" {
  6904. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6905. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6906. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6907. resp3, requestErr3 := http.Get(api3)
  6908. if requestErr3 != nil {
  6909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6910. return
  6911. }
  6912. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6913. if ioErr3 != nil {
  6914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6916. return
  6917. }
  6918. var respJSON3 map[string]interface{}
  6919. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6922. return
  6923. }
  6924. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6925. userJSONBytes3, _ := json.Marshal(respJSON3)
  6926. fmt.Println("log")
  6927. fmt.Println(string(userJSONBytes3))
  6928. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6929. utils.ErrorLog("解析失败:%v", err)
  6930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6931. return
  6932. }
  6933. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6934. var api3 string
  6935. if miConfig.MdtrtareaAdmvs == "320921" {
  6936. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6937. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6938. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6939. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6940. } else {
  6941. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6942. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6943. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6944. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6945. }
  6946. resp3, requestErr3 := http.Get(api3)
  6947. if requestErr3 != nil {
  6948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6949. return
  6950. }
  6951. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6952. if ioErr3 != nil {
  6953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6955. return
  6956. }
  6957. var respJSON3 map[string]interface{}
  6958. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6961. return
  6962. }
  6963. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6964. userJSONBytes3, _ := json.Marshal(respJSON3)
  6965. fmt.Println("log")
  6966. fmt.Println(string(userJSONBytes3))
  6967. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6968. utils.ErrorLog("解析失败:%v", err)
  6969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6970. return
  6971. }
  6972. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6973. res2.Output = resSix10265.Output
  6974. res2.ErrMsg = resSix10265.ErrMsg
  6975. res2.Cainfo = resSix10265.Cainfo
  6976. res2.WarnMsg = resSix10265.WarnMsg
  6977. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6978. res2.Infcode = infocode
  6979. } else {
  6980. if miConfig.Code == "H15049901371" {
  6981. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6982. var dat map[string]interface{}
  6983. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6984. fmt.Println(dat)
  6985. } else {
  6986. fmt.Println(err)
  6987. }
  6988. saveLog(result2, src_request, "2205", "撤销明细")
  6989. userJSONBytes, _ := json.Marshal(dat)
  6990. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6991. utils.ErrorLog("解析失败:%v", err)
  6992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6993. return
  6994. }
  6995. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6996. res2.Output = resSix10265.Output
  6997. res2.ErrMsg = resSix10265.ErrMsg
  6998. res2.Cainfo = resSix10265.Cainfo
  6999. res2.WarnMsg = resSix10265.WarnMsg
  7000. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7001. res2.Infcode = infocode
  7002. } else {
  7003. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7004. var dat map[string]interface{}
  7005. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7006. fmt.Println(dat)
  7007. } else {
  7008. fmt.Println(err)
  7009. }
  7010. saveLog(result2, src_request, "2205", "撤销明细")
  7011. userJSONBytes, _ := json.Marshal(dat)
  7012. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7013. utils.ErrorLog("解析失败:%v", err)
  7014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7015. return
  7016. }
  7017. }
  7018. }
  7019. if res2.Infcode == 0 {
  7020. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7021. if err == nil {
  7022. c.ServeSuccessJSON(map[string]interface{}{
  7023. "msg": "退费成功",
  7024. })
  7025. } else {
  7026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7027. return
  7028. }
  7029. } else {
  7030. c.ServeSuccessJSON(map[string]interface{}{
  7031. "code": -10,
  7032. "msg": res2.ErrMsg,
  7033. })
  7034. }
  7035. } else {
  7036. c.ServeSuccessJSON(map[string]interface{}{
  7037. "code": -10,
  7038. "msg": res.ErrMsg,
  7039. })
  7040. }
  7041. }
  7042. }
  7043. func (c *HisApiController) RefundNumber() {
  7044. record_time := c.GetString("record_time")
  7045. //patient_id, _ := c.GetInt64("patient_id")
  7046. admin_user_id, _ := c.GetInt64("admin_user_id")
  7047. his_patient_id, _ := c.GetInt64("id")
  7048. timeLayout := "2006-01-02"
  7049. loc, _ := time.LoadLocation("Local")
  7050. adminUser := c.GetAdminUserInfo()
  7051. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7052. fmt.Println(err)
  7053. if err != nil {
  7054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7055. return
  7056. }
  7057. recordDateTime := theTime.Unix()
  7058. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7059. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7060. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7061. //order, _ := service.GetHisOrderByID(order_id)
  7062. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7063. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7064. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7065. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7066. if count > 0 {
  7067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7068. return
  7069. }
  7070. if config.IsOpen == 1 { //对接了医保,走医保流程
  7071. var res2 ResultSix
  7072. var resSix10265 ResultSix10265
  7073. if miConfig.MdtrtareaAdmvs == "421300" {
  7074. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7075. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7076. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7077. resp3, requestErr3 := http.Get(api3)
  7078. if requestErr3 != nil {
  7079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7080. return
  7081. }
  7082. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7083. if ioErr3 != nil {
  7084. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7086. return
  7087. }
  7088. var respJSON3 map[string]interface{}
  7089. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7092. return
  7093. }
  7094. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7095. userJSONBytes3, _ := json.Marshal(respJSON3)
  7096. fmt.Println("log")
  7097. fmt.Println(string(userJSONBytes3))
  7098. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7099. utils.ErrorLog("解析失败:%v", err)
  7100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7101. return
  7102. }
  7103. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7104. var api3 string
  7105. if miConfig.MdtrtareaAdmvs == "320921" {
  7106. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7107. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7108. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7109. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7110. } else {
  7111. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7112. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7113. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7114. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7115. }
  7116. resp3, requestErr3 := http.Get(api3)
  7117. if requestErr3 != nil {
  7118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7119. return
  7120. }
  7121. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7122. if ioErr3 != nil {
  7123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7125. return
  7126. }
  7127. var respJSON3 map[string]interface{}
  7128. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7131. return
  7132. }
  7133. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7134. userJSONBytes3, _ := json.Marshal(respJSON3)
  7135. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7136. utils.ErrorLog("解析失败:%v", err)
  7137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7138. return
  7139. }
  7140. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7141. res2.Output = resSix10265.Output
  7142. res2.ErrMsg = resSix10265.ErrMsg
  7143. res2.Cainfo = resSix10265.Cainfo
  7144. res2.WarnMsg = resSix10265.WarnMsg
  7145. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7146. res2.Infcode = infocode
  7147. } else {
  7148. var api3 string
  7149. if miConfig.Code == "H15049901371" {
  7150. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7151. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7152. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7153. } else {
  7154. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7155. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7156. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7157. }
  7158. resp3, requestErr3 := http.Get(api3)
  7159. if requestErr3 != nil {
  7160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7161. return
  7162. }
  7163. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7164. if ioErr3 != nil {
  7165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7167. return
  7168. }
  7169. var respJSON3 map[string]interface{}
  7170. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7173. return
  7174. }
  7175. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7176. userJSONBytes3, _ := json.Marshal(respJSON3)
  7177. if miConfig.Code == "H15049901371" {
  7178. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7179. utils.ErrorLog("解析失败:%v", err)
  7180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7181. return
  7182. }
  7183. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7184. res2.Output = resSix10265.Output
  7185. res2.ErrMsg = resSix10265.ErrMsg
  7186. res2.Cainfo = resSix10265.Cainfo
  7187. res2.WarnMsg = resSix10265.WarnMsg
  7188. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7189. res2.Infcode = infocode
  7190. } else {
  7191. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7192. utils.ErrorLog("解析失败:%v", err)
  7193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7194. return
  7195. }
  7196. }
  7197. }
  7198. if res2.Infcode == 0 {
  7199. if err == nil {
  7200. c.ServeSuccessJSON(map[string]interface{}{
  7201. "msg": "退号成功",
  7202. })
  7203. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7204. } else {
  7205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7206. return
  7207. }
  7208. } else {
  7209. c.ServeSuccessJSON(map[string]interface{}{
  7210. "code": -10,
  7211. "msg": res2.ErrMsg,
  7212. })
  7213. }
  7214. } else {
  7215. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7216. //if err == nil {
  7217. // c.ServeSuccessJSON(map[string]interface{}{
  7218. // "msg": "退费成功",
  7219. // })
  7220. //} else {
  7221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7222. // return
  7223. //}
  7224. }
  7225. }
  7226. func (c *HisApiController) RefundDetail() {
  7227. order_id, _ := c.GetInt64("order_id")
  7228. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7229. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7230. number := c.GetString("number")
  7231. record_time := c.GetString("record_time")
  7232. patient_id, _ := c.GetInt64("patient_id")
  7233. //med_type, _ := c.GetInt64("med_type")
  7234. timeLayout := "2006-01-02"
  7235. loc, _ := time.LoadLocation("Local")
  7236. adminUser := c.GetAdminUserInfo()
  7237. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7238. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7239. fmt.Println(err)
  7240. if err != nil {
  7241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7242. return
  7243. }
  7244. recordDateTime := theTime.Unix()
  7245. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7246. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7247. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7248. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7249. var order models.HisOrder
  7250. order, _ = service.GetHisOrderByID(order_id)
  7251. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7252. if config.IsOpen == 1 { //对接了医保,走医保流程
  7253. var res2 ResultSix
  7254. if miConfig.MdtrtareaAdmvs == "421300" {
  7255. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7256. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7257. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7258. resp3, requestErr3 := http.Get(api3)
  7259. if requestErr3 != nil {
  7260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7261. return
  7262. }
  7263. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7264. if ioErr3 != nil {
  7265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7267. return
  7268. }
  7269. var respJSON3 map[string]interface{}
  7270. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7273. return
  7274. }
  7275. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7276. userJSONBytes3, _ := json.Marshal(respJSON3)
  7277. fmt.Println("log")
  7278. fmt.Println(string(userJSONBytes3))
  7279. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7280. utils.ErrorLog("解析失败:%v", err)
  7281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7282. return
  7283. }
  7284. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7285. if err == nil {
  7286. c.ServeSuccessJSON(map[string]interface{}{
  7287. "msg": "撤销明细成功",
  7288. })
  7289. return
  7290. } else {
  7291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7292. return
  7293. }
  7294. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7295. var resSix10265 ResultSix10265
  7296. var api3 string
  7297. if miConfig.MdtrtareaAdmvs == "320921" {
  7298. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7299. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7300. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7301. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7302. } else {
  7303. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7304. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7305. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7306. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7307. }
  7308. resp3, requestErr3 := http.Get(api3)
  7309. if requestErr3 != nil {
  7310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7311. return
  7312. }
  7313. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7314. if ioErr3 != nil {
  7315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7317. return
  7318. }
  7319. var respJSON3 map[string]interface{}
  7320. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7323. return
  7324. }
  7325. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7326. userJSONBytes3, _ := json.Marshal(respJSON3)
  7327. fmt.Println("log")
  7328. fmt.Println(string(userJSONBytes3))
  7329. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7330. utils.ErrorLog("解析失败:%v", err)
  7331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7332. return
  7333. }
  7334. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7335. res2.Output = resSix10265.Output
  7336. res2.ErrMsg = resSix10265.ErrMsg
  7337. res2.Cainfo = resSix10265.Cainfo
  7338. res2.WarnMsg = resSix10265.WarnMsg
  7339. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7340. res2.Infcode = infocode
  7341. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7342. if err == nil {
  7343. c.ServeSuccessJSON(map[string]interface{}{
  7344. "msg": "撤销明细成功",
  7345. })
  7346. return
  7347. } else {
  7348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7349. return
  7350. }
  7351. } else {
  7352. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7353. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7354. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7355. resp2, requestErr2 := http.Get(api2)
  7356. if requestErr2 != nil {
  7357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7358. return
  7359. }
  7360. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7361. if ioErr2 != nil {
  7362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7364. return
  7365. }
  7366. var respJSON2 map[string]interface{}
  7367. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7370. return
  7371. }
  7372. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7373. if err == nil {
  7374. c.ServeSuccessJSON(map[string]interface{}{
  7375. "msg": "撤销明细成功",
  7376. })
  7377. return
  7378. } else {
  7379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7380. return
  7381. }
  7382. }
  7383. } else {
  7384. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7385. if err == nil {
  7386. c.ServeSuccessJSON(map[string]interface{}{
  7387. "msg": "退费成功",
  7388. })
  7389. } else {
  7390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7391. return
  7392. }
  7393. }
  7394. }
  7395. //对账
  7396. func (c *HisApiController) GetCheckAccount() {
  7397. start_time := c.GetString("start_time")
  7398. end_time := c.GetString("end_time")
  7399. insutype := c.GetString("insutype")
  7400. clr_type := c.GetString("clr_type")
  7401. clr_org := c.GetString("clr_optins")
  7402. admin_user_id, _ := c.GetInt64("admin_user_id")
  7403. adminUser := c.GetAdminUserInfo()
  7404. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7405. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7406. if len(clr_org) == 0 {
  7407. clr_org = miConfig.MdtrtareaAdmvs
  7408. }
  7409. timeLayout := "2006-01-02"
  7410. loc, _ := time.LoadLocation("Local")
  7411. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7412. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7413. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7414. fixmedins_setl_cnt := int64(len(orders))
  7415. var medfee_sumamt float64
  7416. var acct_pay float64
  7417. var fund_pay_sumamt float64
  7418. for _, item := range orders {
  7419. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7420. acct_pay = acct_pay + item.AcctPay
  7421. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7422. }
  7423. var user_name string
  7424. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7425. if role.ID == 0 {
  7426. user_name = "xxx"
  7427. } else {
  7428. user_name = role.UserName
  7429. }
  7430. var res ResultEight
  7431. var res10188 ResultEightFor10188
  7432. if config.IsOpen == 1 {
  7433. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7434. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7435. "insutype=" + insutype +
  7436. "&clr_type=" + "11" +
  7437. "&setl_optins=" + clr_org +
  7438. "&stmt_begndate=" + start_time +
  7439. "&stm_enddate=" + end_time +
  7440. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7441. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7442. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7443. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7444. "&fixmedins_code=" + miConfig.Code +
  7445. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7446. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7447. "&secret_key=" + miConfig.SecretKey +
  7448. "&org_name=" + miConfig.OrgName +
  7449. "&doctor=" + user_name +
  7450. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7451. fmt.Println(api)
  7452. resp, requestErr := http.Get(api)
  7453. if requestErr != nil {
  7454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7455. return
  7456. }
  7457. body, ioErr := ioutil.ReadAll(resp.Body)
  7458. fmt.Println(body)
  7459. if ioErr != nil {
  7460. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7462. return
  7463. }
  7464. var respJSON map[string]interface{}
  7465. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7468. return
  7469. }
  7470. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7471. userJSONBytes, _ := json.Marshal(respJSON)
  7472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7473. utils.ErrorLog("解析失败:%v", err)
  7474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7475. return
  7476. }
  7477. res.InfRefmsgid = res10188.InfRefmsgid
  7478. res.Output = res10188.Output
  7479. res.ErrMsg = res10188.ErrMsg
  7480. res.Cainfo = res10188.Cainfo
  7481. res.WarnMsg = res10188.WarnMsg
  7482. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7483. res.Infcode = infocode
  7484. } else {
  7485. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7486. "insutype=" + insutype +
  7487. "&clr_type=" + clr_type +
  7488. "&setl_optins=" + clr_org +
  7489. "&stmt_begndate=" + start_time +
  7490. "&stm_enddate=" + end_time +
  7491. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7492. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7493. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7494. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7495. "&fixmedins_code=" + miConfig.Code +
  7496. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7497. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7498. "&secret_key=" + miConfig.SecretKey +
  7499. "&org_name=" + miConfig.OrgName +
  7500. "&doctor=" + user_name
  7501. fmt.Println(api)
  7502. resp, requestErr := http.Get(api)
  7503. if requestErr != nil {
  7504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7505. return
  7506. }
  7507. body, ioErr := ioutil.ReadAll(resp.Body)
  7508. fmt.Println(body)
  7509. if ioErr != nil {
  7510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7512. return
  7513. }
  7514. var respJSON map[string]interface{}
  7515. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7518. return
  7519. }
  7520. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7521. userJSONBytes, _ := json.Marshal(respJSON)
  7522. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7523. utils.ErrorLog("解析失败:%v", err)
  7524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7525. return
  7526. }
  7527. }
  7528. if res.Infcode == 0 {
  7529. if res.Output.Stmtinfo.StmtRslt == "0" {
  7530. micc := &models.MedicalInsuranceCostCompare{
  7531. StartTime: startime.Unix(),
  7532. EndTime: endtime.Unix(),
  7533. Insutype: insutype,
  7534. CheckType: 1,
  7535. Num: fixmedins_setl_cnt,
  7536. Mtime: time.Now().Unix(),
  7537. Status: 1,
  7538. UserOrgId: adminUser.CurrentOrgId,
  7539. CostTotal: medfee_sumamt,
  7540. FuncTotal: fund_pay_sumamt,
  7541. PsnPay: acct_pay,
  7542. Creator: admin_user_id,
  7543. Ctime: time.Now().Unix(),
  7544. ClrType: clr_type,
  7545. }
  7546. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7547. if err == nil {
  7548. c.ServeSuccessJSON(map[string]interface{}{
  7549. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7550. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7551. })
  7552. } else {
  7553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7554. }
  7555. } else {
  7556. c.ServeSuccessJSON(map[string]interface{}{
  7557. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7558. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7559. })
  7560. }
  7561. } else {
  7562. c.ServeSuccessJSON(map[string]interface{}{
  7563. "code": -10,
  7564. "msg": res.ErrMsg,
  7565. })
  7566. }
  7567. }
  7568. }
  7569. func (c *HisApiController) Check310() {
  7570. adminUser := c.GetAdminUserInfo()
  7571. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7572. var user_name string
  7573. user_name = "高慧裕"
  7574. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7575. "insutype=" + "310" +
  7576. "&clr_type=" + "" +
  7577. "&setl_optins=" + "441202" +
  7578. "&stmt_begndate=" + "2022-03-01" +
  7579. "&stm_enddate=" + "2022-03-31" +
  7580. "&medfee_sumamt=" + "194930.12" +
  7581. "&fund_pay_sumamt=" + "188741.46" +
  7582. "&acct_pay=" + "0" +
  7583. "&fixmedins_setl_cnt=" + "452" +
  7584. "&fixmedins_code=" + miConfig.Code +
  7585. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7586. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7587. "&secret_key=" + miConfig.SecretKey +
  7588. "&org_name=" + miConfig.OrgName +
  7589. "&doctor=" + user_name
  7590. fmt.Println(api)
  7591. resp, requestErr := http.Get(api)
  7592. if requestErr != nil {
  7593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7594. return
  7595. }
  7596. body, ioErr := ioutil.ReadAll(resp.Body)
  7597. fmt.Println(body)
  7598. if ioErr != nil {
  7599. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7601. return
  7602. }
  7603. var respJSON map[string]interface{}
  7604. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7605. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7607. return
  7608. }
  7609. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7610. userJSONBytes, _ := json.Marshal(respJSON)
  7611. var res ResultEight
  7612. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7613. utils.ErrorLog("解析失败:%v", err)
  7614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7615. return
  7616. }
  7617. }
  7618. func (c *HisApiController) Check390() {
  7619. adminUser := c.GetAdminUserInfo()
  7620. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7621. var user_name string
  7622. user_name = "高慧裕"
  7623. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7624. "insutype=" + "390" +
  7625. "&clr_type=" + "" +
  7626. "&setl_optins=" + "441202" +
  7627. "&stmt_begndate=" + "2022-03-01" +
  7628. "&stm_enddate=" + "2022-03-31" +
  7629. "&medfee_sumamt=" + "1068448.89" +
  7630. "&fund_pay_sumamt=" + "1014677.62" +
  7631. "&acct_pay=" + "0" +
  7632. "&fixmedins_setl_cnt=" + "1950" +
  7633. "&fixmedins_code=" + miConfig.Code +
  7634. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7635. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7636. "&secret_key=" + miConfig.SecretKey +
  7637. "&org_name=" + miConfig.OrgName +
  7638. "&doctor=" + user_name
  7639. fmt.Println(api)
  7640. resp, requestErr := http.Get(api)
  7641. if requestErr != nil {
  7642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7643. return
  7644. }
  7645. body, ioErr := ioutil.ReadAll(resp.Body)
  7646. fmt.Println(body)
  7647. if ioErr != nil {
  7648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7650. return
  7651. }
  7652. var respJSON map[string]interface{}
  7653. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7656. return
  7657. }
  7658. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7659. userJSONBytes, _ := json.Marshal(respJSON)
  7660. var res ResultEight
  7661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7662. utils.ErrorLog("解析失败:%v", err)
  7663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7664. return
  7665. }
  7666. }
  7667. //对账明细
  7668. func (c *HisApiController) GetCheckDetailAccount() {
  7669. start_time := c.GetString("start_time")
  7670. end_time := c.GetString("end_time")
  7671. admin_user_id, _ := c.GetInt64("admin_user_id")
  7672. adminUser := c.GetAdminUserInfo()
  7673. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7674. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7675. timeLayout := "2006-01-02"
  7676. loc, _ := time.LoadLocation("Local")
  7677. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7678. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7679. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7680. Mkdir(miConfig.OrgName)
  7681. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7682. file_name := file + ".txt"
  7683. zip_name := file + ".zip"
  7684. zip_path := miConfig.OrgName + "/" + zip_name
  7685. file_path := miConfig.OrgName + "/" + file_name
  7686. decimal.DivisionPrecision = 2
  7687. var medfee_sumamt float64
  7688. var psn_cash_pay float64
  7689. var fund_pay_sumamt float64
  7690. fixmedins_setl_cnt := int64(len(orders))
  7691. for _, item := range orders {
  7692. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7693. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7694. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7695. }
  7696. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7697. defer f.Close()
  7698. if err != nil {
  7699. fmt.Println(err.Error())
  7700. } else {
  7701. for _, item := range orders {
  7702. var refd_setl_flag string
  7703. if item.OrderStatus == 2 {
  7704. refd_setl_flag = "0"
  7705. var str string
  7706. str = item.SetlId + " " +
  7707. item.MdtrtId + " " +
  7708. item.PsnNo + " " +
  7709. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7710. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7711. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7712. _, err = f.Write([]byte(str))
  7713. }
  7714. if item.OrderStatus == 3 {
  7715. var str string
  7716. str = item.SetlId + " " +
  7717. item.MdtrtId + " " +
  7718. item.PsnNo + " " +
  7719. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7720. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7721. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7722. _, err = f.Write([]byte(str))
  7723. var str2 string
  7724. str2 = item.SetlId + " " +
  7725. item.MdtrtId + " " +
  7726. item.PsnNo + " " +
  7727. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7728. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7729. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7730. _, err = f.Write([]byte(str2))
  7731. }
  7732. }
  7733. }
  7734. Zip(file_path, zip_path)
  7735. fmt.Println(ReadFile(zip_path))
  7736. fmt.Println(string(ReadFile(zip_path)))
  7737. if config.IsOpen == 1 {
  7738. var user_name string
  7739. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7740. if role.ID == 0 {
  7741. user_name = "管理员"
  7742. } else {
  7743. user_name = role.UserName
  7744. }
  7745. baseParams := models.BaseParams{
  7746. SecretKey: miConfig.SecretKey,
  7747. FixmedinsCode: miConfig.Code,
  7748. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7749. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7750. OrgName: miConfig.OrgName,
  7751. Doctor: user_name,
  7752. }
  7753. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7754. var dat map[string]interface{}
  7755. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7756. fmt.Println(dat)
  7757. } else {
  7758. fmt.Println(err)
  7759. }
  7760. userJSONBytes, _ := json.Marshal(dat)
  7761. var res ResultNine
  7762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7763. utils.ErrorLog("解析失败:%v", err)
  7764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7765. return
  7766. }
  7767. if res.Infcode == 0 {
  7768. fileNo := res.Output.FileQuryNo
  7769. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7770. "file_qury_no=" + fileNo +
  7771. "&setl_optins=" + "定点医保中心" +
  7772. "&stmt_begndate=" + start_time +
  7773. "&stm_enddate=" + end_time +
  7774. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7775. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7776. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7777. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7778. "&fixmedins_code=" + miConfig.Code +
  7779. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7780. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7781. "&secret_key=" + miConfig.SecretKey +
  7782. "&org_name=" + miConfig.OrgName +
  7783. "&doctor=" + user_name
  7784. resp, requestErr := http.Get(api)
  7785. if requestErr != nil {
  7786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7787. return
  7788. }
  7789. body, ioErr := ioutil.ReadAll(resp.Body)
  7790. if ioErr != nil {
  7791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7793. return
  7794. }
  7795. var respJSON map[string]interface{}
  7796. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7799. return
  7800. }
  7801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7802. userJSONBytes, _ := json.Marshal(respJSON)
  7803. var res ResultTen
  7804. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7805. utils.ErrorLog("解析失败:%v", err)
  7806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7807. return
  7808. }
  7809. if res.Infcode == 0 {
  7810. service.Gdyb9102(baseParams, zip_name, fileNo)
  7811. micc := &models.MedicalInsuranceCostCompare{
  7812. StartTime: startime.Unix(),
  7813. EndTime: endtime.Unix(),
  7814. Insutype: "0",
  7815. CheckType: 2,
  7816. Num: fixmedins_setl_cnt,
  7817. Mtime: time.Now().Unix(),
  7818. Status: 1,
  7819. UserOrgId: adminUser.CurrentOrgId,
  7820. CostTotal: medfee_sumamt,
  7821. FuncTotal: fund_pay_sumamt,
  7822. PsnPay: psn_cash_pay,
  7823. Creator: admin_user_id,
  7824. Ctime: time.Now().Unix(),
  7825. }
  7826. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7827. c.ServeSuccessJSON(map[string]interface{}{
  7828. "msg": "明细对账成功",
  7829. })
  7830. }
  7831. } else {
  7832. }
  7833. }
  7834. }
  7835. type CustomOrderInfo struct {
  7836. Name string
  7837. Spec string
  7838. Unit string
  7839. Count float64
  7840. Price float64
  7841. Total float64
  7842. }
  7843. func (c *HisApiController) GetSettleAccounts() {
  7844. //id, _ := c.GetInt64("id")
  7845. //record_time := c.GetString("record_time")
  7846. order_id, _ := c.GetInt64("order_id")
  7847. admin_user_id, _ := c.GetInt64("admin_user_id")
  7848. //timeLayout := "2006-01-02"
  7849. //loc, _ := time.LoadLocation("Local")
  7850. //
  7851. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7852. //if err != nil {
  7853. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7854. // return
  7855. //}
  7856. //recordDateTime := theTime.Unix()
  7857. adminUser := c.GetAdminUserInfo()
  7858. order, _ := service.GetHisOrderByID(order_id)
  7859. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7860. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7861. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7862. orderInfos = append(orderInfos, orderInfos_two...)
  7863. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7864. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7865. var diagnosis_ids []string
  7866. if his.ID > 0 {
  7867. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  7868. } else {
  7869. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  7870. }
  7871. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7872. var dia_config []*models.HisXtDiagnoseConfig
  7873. var name string
  7874. for _, item := range diagnosis_ids {
  7875. id, _ := strconv.ParseInt(item, 10, 64)
  7876. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7877. dia_config = append(dia_config, &diagnosisConfig)
  7878. if len(name) == 0 {
  7879. name = diagnosisConfig.ClassName
  7880. } else {
  7881. name = name + "," + diagnosisConfig.ClassName
  7882. }
  7883. }
  7884. var bedCostTotal float64 = 0 //床位总费
  7885. var bedCostSelfTotal float64 = 0 //床位自费
  7886. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7887. var operationCostTotal float64 = 0 //手术费
  7888. var operationCostSelfTotal float64 = 0 //手术费
  7889. var operationCostPartSelfTotal float64 = 0 //手术费
  7890. var otherCostTotal float64 = 0 //其他费用
  7891. var otherCostSelfTotal float64 = 0 //其他费用
  7892. var otherCostPartSelfTotal float64 = 0 //其他费用
  7893. var materialCostTotal float64 = 0 //材料费
  7894. var materialCostSelfTotal float64 = 0 //材料费
  7895. var materialCostPartSelfTotal float64 = 0 //材料费
  7896. var westernMedicineCostTotal float64 = 0 //西药费
  7897. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7898. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7899. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7900. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7901. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7902. var checkCostTotal float64 = 0 //检查费
  7903. var checkCostSelfTotal float64 = 0 //检查费
  7904. var checkCostPartSelfTotal float64 = 0 //检查费
  7905. var laboratoryCostTotal float64 = 0 //化验费
  7906. var laboratoryCostSelfTotal float64 = 0 //化验费
  7907. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7908. var treatCostTotal float64 = 0 //治疗费用
  7909. var treatCostSelfTotal float64 = 0 //治疗费用
  7910. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7911. decimal.DivisionPrecision = 2
  7912. for _, item := range orderInfos {
  7913. if item.MedChrgitmType == "01" { //床位费
  7914. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7915. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7916. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7917. }
  7918. if item.MedChrgitmType == "03" { //检查费
  7919. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7920. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7921. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7922. }
  7923. if item.MedChrgitmType == "04" { //化验费
  7924. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7925. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7926. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7927. }
  7928. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  7929. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7930. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7931. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7932. }
  7933. if item.MedChrgitmType == "06" { //手术费
  7934. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7935. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7936. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7937. }
  7938. if item.MedChrgitmType == "08" { //材料费
  7939. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7940. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7941. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7942. }
  7943. if item.MedChrgitmType == "09" { //西药费
  7944. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7945. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7946. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7947. }
  7948. if item.MedChrgitmType == "11" { //中成费
  7949. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7950. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7951. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7952. }
  7953. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  7954. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7955. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7956. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7957. }
  7958. }
  7959. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7960. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7961. var user_name string
  7962. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7963. if role.ID == 0 {
  7964. user_name = "管理员"
  7965. } else {
  7966. user_name = role.UserName
  7967. }
  7968. baseParams := models.BaseParams{
  7969. SecretKey: miConfig.SecretKey,
  7970. FixmedinsCode: miConfig.Code,
  7971. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7972. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7973. OrgName: miConfig.OrgName,
  7974. Doctor: user_name,
  7975. }
  7976. businessParams := models.BusinessParams{
  7977. PsnNo: order.PsnNo,
  7978. MdtrtId: order.MdtrtId,
  7979. SetlId: order.SetlId,
  7980. }
  7981. var res ResultEleven
  7982. var resEleven10265 ResultEleven10265
  7983. if config.IsOpen == 1 {
  7984. if miConfig.MdtrtareaAdmvs == "421300" {
  7985. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7986. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7987. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7988. resp, requestErr := http.Get(api)
  7989. if requestErr != nil {
  7990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7991. return
  7992. }
  7993. body, ioErr := ioutil.ReadAll(resp.Body)
  7994. if ioErr != nil {
  7995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7997. return
  7998. }
  7999. var respJSON map[string]interface{}
  8000. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8003. return
  8004. }
  8005. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8006. result, _ := json.Marshal(respJSON)
  8007. fmt.Println("log")
  8008. fmt.Println(string(result))
  8009. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8010. utils.ErrorLog("解析失败:%v", err)
  8011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8012. return
  8013. }
  8014. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8015. var api string
  8016. if miConfig.MdtrtareaAdmvs == "320921" {
  8017. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8018. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8019. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8020. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8021. } else {
  8022. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8023. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8024. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8025. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8026. }
  8027. resp, requestErr := http.Get(api)
  8028. if requestErr != nil {
  8029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8030. return
  8031. }
  8032. body, ioErr := ioutil.ReadAll(resp.Body)
  8033. if ioErr != nil {
  8034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8036. return
  8037. }
  8038. var respJSON map[string]interface{}
  8039. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8040. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8042. return
  8043. }
  8044. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8045. result, _ := json.Marshal(respJSON)
  8046. fmt.Println("log")
  8047. fmt.Println(string(result))
  8048. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8049. utils.ErrorLog("解析失败:%v", err)
  8050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8051. return
  8052. }
  8053. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8054. res.Output = resEleven10265.Output
  8055. res.ErrMsg = resEleven10265.ErrMsg
  8056. res.Cainfo = resEleven10265.Cainfo
  8057. res.WarnMsg = resEleven10265.WarnMsg
  8058. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8059. res.Infcode = infocode
  8060. } else {
  8061. //result2 := service.Gdyb1101()
  8062. //result2 := service.Gdyb5204(baseParams, businessParams)
  8063. //saveLog(result2, "", "5204", "查询")
  8064. result := service.Gdyb5203(baseParams, businessParams)
  8065. var dat map[string]interface{}
  8066. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8067. fmt.Println(dat)
  8068. } else {
  8069. fmt.Println(err)
  8070. }
  8071. userJSONBytes, _ := json.Marshal(dat)
  8072. if miConfig.Code == "H15049901371" {
  8073. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8074. utils.ErrorLog("解析失败:%v", err)
  8075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8076. return
  8077. }
  8078. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8079. res.Output = resEleven10265.Output
  8080. res.ErrMsg = resEleven10265.ErrMsg
  8081. res.Cainfo = resEleven10265.Cainfo
  8082. res.WarnMsg = resEleven10265.WarnMsg
  8083. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8084. res.Infcode = infocode
  8085. } else {
  8086. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8087. utils.ErrorLog("解析失败:%v", err)
  8088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8089. return
  8090. }
  8091. }
  8092. }
  8093. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8094. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8095. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8096. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8097. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8098. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8099. var doctor_name string
  8100. if roles.ID == 0 {
  8101. doctor_name = "管理员"
  8102. } else {
  8103. doctor_name = roles.UserName
  8104. }
  8105. yiliao_leibie := ""
  8106. switch order.MedType {
  8107. case "11":
  8108. yiliao_leibie = "普通门诊"
  8109. break
  8110. case "12":
  8111. yiliao_leibie = "门诊挂号"
  8112. break
  8113. case "13":
  8114. yiliao_leibie = "急诊"
  8115. break
  8116. case "14":
  8117. yiliao_leibie = "门诊特殊病"
  8118. break
  8119. case "15":
  8120. yiliao_leibie = "门诊统筹"
  8121. break
  8122. case "16":
  8123. yiliao_leibie = "门诊慢性病"
  8124. break
  8125. case "21":
  8126. yiliao_leibie = "普通住院"
  8127. break
  8128. }
  8129. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8130. if res.Infcode == 0 {
  8131. c.ServeSuccessJSON(map[string]interface{}{
  8132. "diagnosis": name,
  8133. "order_infos": orderInfos,
  8134. "number": order.MdtrtId,
  8135. "date": order.SettleAccountsDate,
  8136. "charge_admin": charge_admin,
  8137. "printor_admin": printor_admin,
  8138. "info": res.Output.Setlinfo,
  8139. "order": order,
  8140. "bedCostTotal": bedCostTotal,
  8141. "bedCostSelfTotal": bedCostSelfTotal,
  8142. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8143. "operationCostTotal": operationCostTotal,
  8144. "operationCostSelfTotal": operationCostSelfTotal,
  8145. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8146. "otherCostTotal": otherCostTotal,
  8147. "otherCostSelfTotal": otherCostSelfTotal,
  8148. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8149. "materialCostTotal": materialCostTotal,
  8150. "materialCostSelfTotal": materialCostSelfTotal,
  8151. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8152. "westernMedicineCostTotal": westernMedicineCostTotal,
  8153. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8154. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8155. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8156. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8157. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8158. "checkCostTotal": checkCostTotal,
  8159. "checkCostSelfTotal": checkCostSelfTotal,
  8160. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8161. "laboratoryCostTotal": laboratoryCostTotal,
  8162. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8163. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8164. "treatCostTotal": treatCostTotal,
  8165. "treatCostSelfTotal": treatCostSelfTotal,
  8166. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8167. "doctor_info": doctor_info,
  8168. "doctor_code": adminRole_two.DoctorCode,
  8169. "doctor_name": doctor_name,
  8170. "health_card_no": order.PsnNo,
  8171. "department": departments.Name,
  8172. "yiliao_leibie": yiliao_leibie,
  8173. "after_money": order.AccountPrice,
  8174. "patient": patient,
  8175. "org_name": miConfig.OrgName,
  8176. "org_code": miConfig.Code,
  8177. "order_number": order.Number,
  8178. "his_hospital": his_hospital,
  8179. "his": his,
  8180. "dia_config": dia_config,
  8181. //"check_order_info": cus_slice,
  8182. })
  8183. }
  8184. }
  8185. }
  8186. func (c *HisApiController) CheckTreatment() {
  8187. patient_id, _ := c.GetInt64("patient_id")
  8188. id_card_no := c.GetString("id_card_no")
  8189. insutype := c.GetString("insutype")
  8190. med_type := c.GetString("med_type")
  8191. admin_user_id, _ := c.GetInt64("admin_user_id")
  8192. adminUser := c.GetAdminUserInfo()
  8193. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8194. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8195. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8196. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8197. if miConfig.MdtrtareaAdmvs == "421300" {
  8198. var res ResultTwo
  8199. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8200. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8201. "&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)
  8202. resp, requestErr := http.Get(api)
  8203. if requestErr != nil {
  8204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8205. return
  8206. }
  8207. body, ioErr := ioutil.ReadAll(resp.Body)
  8208. if ioErr != nil {
  8209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8211. return
  8212. }
  8213. var respJSON map[string]interface{}
  8214. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8217. return
  8218. }
  8219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8220. result, _ := json.Marshal(respJSON)
  8221. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8222. utils.ErrorLog("解析失败:%v", err)
  8223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8224. return
  8225. }
  8226. if res.Infcode == 0 {
  8227. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8228. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8229. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8230. resp, requestErr := http.Get(api)
  8231. if requestErr != nil {
  8232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8233. return
  8234. }
  8235. body, ioErr := ioutil.ReadAll(resp.Body)
  8236. if ioErr != nil {
  8237. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8239. return
  8240. }
  8241. var respJSON map[string]interface{}
  8242. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8245. return
  8246. }
  8247. var res Result2001
  8248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8249. result2, _ := json.Marshal(respJSON)
  8250. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8251. utils.ErrorLog("解析失败:%v", err)
  8252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8253. return
  8254. }
  8255. if res.Infcode == 0 {
  8256. c.ServeSuccessJSON(map[string]interface{}{
  8257. "msg": res.Output.Trtinfo,
  8258. })
  8259. }
  8260. } else {
  8261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8262. return
  8263. }
  8264. } else {
  8265. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8266. var dat map[string]interface{}
  8267. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8268. fmt.Println(dat)
  8269. } else {
  8270. fmt.Println(err)
  8271. }
  8272. userJSONBytes, _ := json.Marshal(dat)
  8273. var res ResultTwo
  8274. var res10265 ResultTwo10265
  8275. if miConfig.Code == "H15049901371" {
  8276. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8277. utils.ErrorLog("解析失败:%v", err)
  8278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8279. return
  8280. }
  8281. res.ErrMsg = res10265.ErrMsg
  8282. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8283. res.Infcode = infocode
  8284. res.Output = res10265.Output
  8285. res.InfRefmsgid = res10265.InfRefmsgid
  8286. } else {
  8287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8288. utils.ErrorLog("解析失败:%v", err)
  8289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8290. return
  8291. }
  8292. }
  8293. var user_name string
  8294. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8295. if role.ID == 0 {
  8296. user_name = "xxx"
  8297. } else {
  8298. user_name = role.UserName
  8299. }
  8300. baseParams := models.BaseParams{
  8301. SecretKey: miConfig.SecretKey,
  8302. FixmedinsCode: miConfig.Code,
  8303. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8304. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8305. OrgName: miConfig.OrgName,
  8306. Doctor: user_name,
  8307. }
  8308. if config.IsOpen == 1 {
  8309. if miConfig.Code == "H15049901371" {
  8310. if med_type == "14" {
  8311. if insutype == "390" {
  8312. med_type = "9933"
  8313. } else if insutype == "310" {
  8314. med_type = "990502"
  8315. }
  8316. } else if med_type == "11" {
  8317. med_type = "11"
  8318. }
  8319. }
  8320. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8321. var dat map[string]interface{}
  8322. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8323. fmt.Println(dat)
  8324. } else {
  8325. fmt.Println(err)
  8326. }
  8327. var res Result2001
  8328. var res10265 Result2001Org10265
  8329. if miConfig.Code == "H15049901371" {
  8330. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8331. utils.ErrorLog("解析失败:%v", err)
  8332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8333. return
  8334. }
  8335. res.ErrMsg = res10265.ErrMsg
  8336. res.Output = res10265.Output
  8337. res.InfRefmsgid = res10265.InfRefmsgid
  8338. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8339. res.Infcode = infocode
  8340. } else {
  8341. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8342. utils.ErrorLog("解析失败:%v", err)
  8343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8344. return
  8345. }
  8346. }
  8347. if res.Infcode == 0 {
  8348. c.ServeSuccessJSON(map[string]interface{}{
  8349. "msg": res.Output.Trtinfo,
  8350. })
  8351. }
  8352. }
  8353. }
  8354. }
  8355. //func (c *HisApiController) PutRecord() {
  8356. // id, _ := c.GetInt64("id")
  8357. // record_time := c.GetString("record_time")
  8358. // timeLayout := "2006-01-02"
  8359. // loc, _ := time.LoadLocation("Local")
  8360. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8361. // if err != nil {
  8362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8363. // return
  8364. // }
  8365. // recordDateTime := theTime.Unix()
  8366. //
  8367. // adminInfo := c.GetAdminUserInfo()
  8368. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8369. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8370. //
  8371. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8372. //
  8373. // fmt.Println(miConfig.SecretKey)
  8374. //
  8375. // if patient == nil {
  8376. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8377. // return
  8378. // }
  8379. // if len(patient.IdCardNo) == 0 {
  8380. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8381. // return
  8382. // }
  8383. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8384. // if config.IsOpen == 1 {
  8385. // 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
  8386. // resp, requestErr := http.Get(api)
  8387. // if requestErr != nil {
  8388. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8389. // return
  8390. // }
  8391. // defer resp.Body.Close()
  8392. // body, ioErr := ioutil.ReadAll(resp.Body)
  8393. // if ioErr != nil {
  8394. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8396. // return
  8397. // }
  8398. // var respJSON map[string]interface{}
  8399. //
  8400. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8401. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8402. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8403. // return
  8404. // }
  8405. //
  8406. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8407. // userJSONBytes, _ := json.Marshal(userJSON)
  8408. // var res ResultTwo
  8409. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8410. // utils.ErrorLog("解析失败:%v", err)
  8411. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8412. // return
  8413. // }
  8414. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8415. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8416. // infoStr := string(Iinfos)
  8417. // idetinfoStr := string(Idetinfos)
  8418. //
  8419. // if res.Infcode == 0 {
  8420. // his := models.VMHisPatient{
  8421. // Status: 1,
  8422. // Ctime: time.Now().Unix(),
  8423. // Mtime: time.Now().Unix(),
  8424. // PsnNo: res.Output.Baseinfo.PsnNo,
  8425. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8426. // Certno: res.Output.Baseinfo.Certno,
  8427. // PsnName: res.Output.Baseinfo.PsnName,
  8428. // Gend: res.Output.Baseinfo.Gend,
  8429. // Naty: res.Output.Baseinfo.Naty,
  8430. // Brdy: res.Output.Baseinfo.Brdy,
  8431. // Age: res.Output.Baseinfo.Age,
  8432. // Iinfo: infoStr,
  8433. // Idetinfo: idetinfoStr,
  8434. // PatientId: patient.ID,
  8435. // RecordDate: theTime.Unix(),
  8436. // UserOrgId: adminInfo.CurrentOrgId,
  8437. // AdminUserId: adminInfo.AdminUser.Id,
  8438. // IsReturn: 1,
  8439. // }
  8440. //
  8441. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8442. // //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")
  8443. // //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")
  8444. //
  8445. // //var dat map[string]interface{}
  8446. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8447. // // fmt.Println(dat)
  8448. // //} else {
  8449. // // fmt.Println(err)
  8450. // //}
  8451. //
  8452. // var dat2 map[string]interface{}
  8453. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8454. // fmt.Println(dat2)
  8455. // } else {
  8456. // fmt.Println(err)
  8457. // }
  8458. //
  8459. // } else {
  8460. // adminUser := c.GetAdminUserInfo()
  8461. // errlog := &models.HisOrderError{
  8462. // UserOrgId: adminUser.CurrentOrgId,
  8463. // Ctime: time.Now().Unix(),
  8464. // Mtime: time.Now().Unix(),
  8465. // ErrMsg: res.ErrMsg,
  8466. // Status: 1,
  8467. // PatientId: id,
  8468. // RecordTime: recordDateTime,
  8469. // Stage: 1,
  8470. // }
  8471. // service.CreateErrMsgLog(errlog)
  8472. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8473. // return
  8474. // }
  8475. // }
  8476. //
  8477. //}
  8478. //func (c *HisApiController) GetUploadDiag() {
  8479. // id, _ := c.GetInt64("id")
  8480. // record_time := c.GetString("record_time")
  8481. //
  8482. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8483. // sick_type, _ := c.GetInt64("sick_type")
  8484. // reg_type, _ := c.GetInt64("reg_type")
  8485. //
  8486. // timeLayout := "2006-01-02"
  8487. // loc, _ := time.LoadLocation("Local")
  8488. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8489. // if err != nil {
  8490. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8491. // return
  8492. // }
  8493. //
  8494. // var patientPrescription models.HisPrescriptionInfo
  8495. // recordDateTime := theTime.Unix()
  8496. // adminInfo := c.GetAdminUserInfo()
  8497. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8498. //
  8499. // if patientPrescription.ID == 0 {
  8500. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8501. // }
  8502. //
  8503. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8504. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8505. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8506. // sickConfig, _ := service.FindSickById(sick_type)
  8507. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8508. //
  8509. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8510. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8511. // "&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 +
  8512. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8513. // resp2, requestErr2 := http.Get(api2)
  8514. // if requestErr2 != nil {
  8515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8516. // return
  8517. // }
  8518. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8519. // if ioErr2 != nil {
  8520. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8522. // return
  8523. // }
  8524. // var respJSON2 map[string]interface{}
  8525. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8526. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8528. // return
  8529. // }
  8530. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8531. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8532. //
  8533. // var res2 ResultSix
  8534. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8535. // utils.ErrorLog("解析失败:%v", err)
  8536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8537. // return
  8538. // }
  8539. // if res2.Infcode != 0 {
  8540. // adminUser := c.GetAdminUserInfo()
  8541. // errlog := &models.HisOrderError{
  8542. // UserOrgId: adminUser.CurrentOrgId,
  8543. // Ctime: time.Now().Unix(),
  8544. // Mtime: time.Now().Unix(),
  8545. // ErrMsg: res2.ErrMsg,
  8546. // Status: 1,
  8547. // PatientId: id,
  8548. // RecordTime: recordDateTime,
  8549. // Stage: 3,
  8550. // }
  8551. // service.CreateErrMsgLog(errlog)
  8552. //
  8553. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8554. // return
  8555. // }
  8556. //
  8557. // c.ServeSuccessJSON(map[string]interface{}{
  8558. // "msg": "上传成功",
  8559. // })
  8560. //
  8561. //}
  8562. type QueryResult struct {
  8563. ID int64
  8564. Name string
  8565. Code string
  8566. List_type_code string
  8567. }
  8568. func (c *HisApiController) GetCheckCode() {
  8569. ids_str := c.GetString("ids")
  8570. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8571. ids_arr := strings.Split(ids_str, ",")
  8572. var queryResult []QueryResult
  8573. ids := make([]int64, 0)
  8574. for _, item := range ids_arr {
  8575. id, _ := strconv.ParseInt(item, 10, 64)
  8576. ids = append(ids, id)
  8577. }
  8578. if record_type == 1 {
  8579. drugs, _ := service.GetBatchDrugList(ids)
  8580. for _, item := range drugs {
  8581. result := QueryResult{
  8582. ID: item.ID,
  8583. Name: item.DrugName,
  8584. Code: item.MedicalInsuranceNumber,
  8585. List_type_code: "101",
  8586. }
  8587. queryResult = append(queryResult, result)
  8588. }
  8589. } else if record_type == 2 {
  8590. goods, _ := service.GetBatchGoodInformationList(ids)
  8591. for _, item := range goods {
  8592. result := QueryResult{
  8593. ID: item.ID,
  8594. Name: item.GoodName,
  8595. Code: item.MedicalInsuranceNumber,
  8596. List_type_code: "301",
  8597. }
  8598. queryResult = append(queryResult, result)
  8599. }
  8600. } else if record_type == 3 {
  8601. projects, _ := service.GetBathchMyPorjecgList(ids)
  8602. for _, item := range projects {
  8603. result := QueryResult{
  8604. ID: item.ID,
  8605. Name: item.ProjectName,
  8606. Code: item.MedicalCode,
  8607. List_type_code: "201",
  8608. }
  8609. queryResult = append(queryResult, result)
  8610. }
  8611. }
  8612. admin_user_id, _ := c.GetInt64("admin_user_id")
  8613. adminUser := c.GetAdminUserInfo()
  8614. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8615. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8616. var user_name string
  8617. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8618. if role.ID == 0 {
  8619. user_name = "xxx"
  8620. } else {
  8621. user_name = role.UserName
  8622. }
  8623. baseParams := &models.BaseParams{
  8624. SecretKey: miConfig.SecretKey,
  8625. FixmedinsCode: miConfig.Code,
  8626. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8627. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8628. OrgName: miConfig.OrgName,
  8629. Doctor: user_name,
  8630. }
  8631. if config.IsOpen == 1 {
  8632. for _, item := range queryResult {
  8633. var result string
  8634. if record_type == 1 {
  8635. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8636. } else if record_type == 2 {
  8637. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8638. } else if record_type == 3 {
  8639. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8640. }
  8641. var dat map[string]interface{}
  8642. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8643. fmt.Println(dat)
  8644. } else {
  8645. fmt.Println(err)
  8646. }
  8647. userJSONBytes, _ := json.Marshal(dat)
  8648. var res ResultSix
  8649. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8650. utils.ErrorLog("解析失败:%v", err)
  8651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8652. return
  8653. }
  8654. if res.Infcode == 0 {
  8655. if record_type == 1 {
  8656. service.UpdateBaseDrugById(item.ID)
  8657. } else if record_type == 2 {
  8658. service.UpdateGoodInformaitonByDetail(item.ID)
  8659. } else if record_type == 3 {
  8660. service.UpdateProjectById(item.ID)
  8661. }
  8662. c.ServeSuccessJSON(map[string]interface{}{
  8663. "failed_code": 0,
  8664. "msg": "目录对照成功",
  8665. })
  8666. } else {
  8667. c.ServeSuccessJSON(map[string]interface{}{
  8668. "failed_code": -10,
  8669. "msg": res.ErrMsg,
  8670. })
  8671. }
  8672. }
  8673. }
  8674. }
  8675. func (c *HisApiController) UnCheckCode() {
  8676. ids_str := c.GetString("ids")
  8677. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8678. admin_user_id, _ := c.GetInt64("admin_user_id")
  8679. ids_arr := strings.Split(ids_str, ",")
  8680. var queryResult []QueryResult
  8681. ids := make([]int64, 0)
  8682. for _, item := range ids_arr {
  8683. id, _ := strconv.ParseInt(item, 10, 64)
  8684. ids = append(ids, id)
  8685. }
  8686. if record_type == 1 {
  8687. drugs, _ := service.GetBatchDrugList(ids)
  8688. for _, item := range drugs {
  8689. result := QueryResult{
  8690. ID: item.ID,
  8691. Name: item.DrugName,
  8692. Code: item.MedicalInsuranceNumber,
  8693. List_type_code: "101",
  8694. }
  8695. queryResult = append(queryResult, result)
  8696. }
  8697. } else if record_type == 2 {
  8698. goods, _ := service.GetBatchGoodInformationList(ids)
  8699. for _, item := range goods {
  8700. result := QueryResult{
  8701. ID: item.ID,
  8702. Name: item.GoodName,
  8703. Code: item.MedicalInsuranceNumber,
  8704. List_type_code: "301",
  8705. }
  8706. queryResult = append(queryResult, result)
  8707. }
  8708. } else if record_type == 3 {
  8709. projects, _ := service.GetBathchMyPorjecgList(ids)
  8710. for _, item := range projects {
  8711. result := QueryResult{
  8712. ID: item.ID,
  8713. Name: item.ProjectName,
  8714. Code: item.MedicalCode,
  8715. List_type_code: "201",
  8716. }
  8717. queryResult = append(queryResult, result)
  8718. }
  8719. }
  8720. adminUser := c.GetAdminUserInfo()
  8721. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8722. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8723. var user_name string
  8724. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8725. if role.ID == 0 {
  8726. user_name = "xxx"
  8727. } else {
  8728. user_name = role.UserName
  8729. }
  8730. baseParams := &models.BaseParams{
  8731. SecretKey: miConfig.SecretKey,
  8732. FixmedinsCode: miConfig.Code,
  8733. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8734. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8735. OrgName: miConfig.OrgName,
  8736. Doctor: user_name,
  8737. }
  8738. if config.IsOpen == 1 {
  8739. for _, item := range queryResult {
  8740. var result string
  8741. if record_type == 1 {
  8742. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8743. } else if record_type == 2 {
  8744. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8745. } else if record_type == 3 {
  8746. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8747. }
  8748. var dat2 map[string]interface{}
  8749. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8750. fmt.Println(dat2)
  8751. } else {
  8752. fmt.Println(err)
  8753. }
  8754. userJSONBytes, _ := json.Marshal(dat2)
  8755. var res ResultSix
  8756. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8757. utils.ErrorLog("解析失败:%v", err)
  8758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8759. return
  8760. }
  8761. if res.Infcode == 0 {
  8762. if record_type == 1 {
  8763. service.UpdateDrugByIdDetail(item.ID)
  8764. } else if record_type == 2 {
  8765. service.UpdateGoodInfoById(item.ID)
  8766. } else if record_type == 3 {
  8767. service.UpdateMyProjectById(item.ID)
  8768. }
  8769. c.ServeSuccessJSON(map[string]interface{}{
  8770. "failed_code": 0,
  8771. "msg": "撤销目录对照成功",
  8772. })
  8773. } else {
  8774. c.ServeSuccessJSON(map[string]interface{}{
  8775. "failed_code": -10,
  8776. "msg": res.ErrMsg,
  8777. })
  8778. }
  8779. }
  8780. }
  8781. }
  8782. func (c *HisApiController) GetPatientInfo() {
  8783. id_card_no := c.GetString("id_card_no")
  8784. admin_user_id, _ := c.GetInt64("admin_user_id")
  8785. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8786. if patient.ID == 0 {
  8787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8788. return
  8789. }
  8790. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8791. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8792. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8793. if config.IsOpen == 1 {
  8794. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8795. var dat map[string]interface{}
  8796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8797. fmt.Println(dat)
  8798. } else {
  8799. fmt.Println(err)
  8800. }
  8801. userJSONBytes, _ := json.Marshal(dat)
  8802. var res ResultTwo
  8803. var res10265 ResultTwo10265
  8804. if miConfig.Code == "H15049901371" {
  8805. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8806. utils.ErrorLog("解析失败:%v", err)
  8807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8808. return
  8809. }
  8810. res.ErrMsg = res10265.ErrMsg
  8811. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8812. res.Infcode = infocode
  8813. res.Output = res10265.Output
  8814. res.InfRefmsgid = res10265.InfRefmsgid
  8815. } else {
  8816. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8817. utils.ErrorLog("解析失败:%v", err)
  8818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8819. return
  8820. }
  8821. }
  8822. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8823. // utils.ErrorLog("解析失败:%v", err)
  8824. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8825. // return
  8826. //}
  8827. if res.Infcode != 0 {
  8828. c.ServeSuccessJSON(map[string]interface{}{
  8829. "failed_code": -10,
  8830. "msg": res.ErrMsg,
  8831. })
  8832. } else {
  8833. c.ServeSuccessJSON(map[string]interface{}{
  8834. "failed_code": 0,
  8835. "info": res,
  8836. })
  8837. }
  8838. }
  8839. }
  8840. func (c *HisApiController) PsnPutOnRecord() {
  8841. record_type, _ := c.GetInt64("type")
  8842. patient_id, _ := c.GetInt64("patient_id")
  8843. admin_user_id, _ := c.GetInt64("admin_user_id")
  8844. start_time := c.GetString("start_time")
  8845. end_time := c.GetString("end_time")
  8846. adminUser := c.GetAdminUserInfo()
  8847. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8848. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8849. var patients []*models.Patients
  8850. if record_type == 1 { //全部备案
  8851. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8852. patients = append(patients, patient...)
  8853. } else { //单个备案
  8854. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8855. patients = append(patients, patient)
  8856. }
  8857. var user_name string
  8858. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8859. if role.ID == 0 {
  8860. user_name = "xxx"
  8861. } else {
  8862. user_name = role.UserName
  8863. }
  8864. if config.IsOpen == 1 {
  8865. for _, item := range patients {
  8866. 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
  8867. resp, requestErr := http.Get(api)
  8868. if requestErr != nil {
  8869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8870. return
  8871. }
  8872. defer resp.Body.Close()
  8873. body, ioErr := ioutil.ReadAll(resp.Body)
  8874. if ioErr != nil {
  8875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8877. return
  8878. }
  8879. var respJSON map[string]interface{}
  8880. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8883. return
  8884. }
  8885. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8886. userJSONBytes, _ := json.Marshal(userJSON)
  8887. var res ResultTwo
  8888. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8889. utils.ErrorLog("解析失败:%v", err)
  8890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8891. return
  8892. }
  8893. if res.Infcode == 0 {
  8894. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8895. var dat map[string]interface{}
  8896. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8897. fmt.Println(dat)
  8898. } else {
  8899. fmt.Println(err)
  8900. }
  8901. userJSONBytes, _ := json.Marshal(dat)
  8902. var res2 ResultThirteen
  8903. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8904. utils.ErrorLog("解析失败:%v", err)
  8905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8906. return
  8907. }
  8908. if res2.Infcode == 0 {
  8909. psnResult := &models.GdybPsnRecord{
  8910. UserOrgId: adminUser.CurrentOrgId,
  8911. PatientId: item.ID,
  8912. PsnNo: res.Output.Baseinfo.PsnNo,
  8913. Ctime: time.Now().Unix(),
  8914. Mtime: time.Now().Unix(),
  8915. Status: 1,
  8916. IsCancel: 1,
  8917. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8918. }
  8919. service.CreatePsnRecord(psnResult)
  8920. } else {
  8921. c.ServeSuccessJSON(map[string]interface{}{
  8922. "failed_code": -10,
  8923. "msg": res2.ErrMsg,
  8924. })
  8925. return
  8926. }
  8927. }
  8928. }
  8929. }
  8930. }
  8931. func (c *HisApiController) PsnUnPutOnRecord() {
  8932. id, _ := c.GetInt64("id")
  8933. //record_type, _ := c.GetInt64("type")
  8934. admin_user_id, _ := c.GetInt64("admin_user_id")
  8935. adminUser := c.GetAdminUserInfo()
  8936. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8937. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8938. var user_name string
  8939. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8940. if role.ID == 0 {
  8941. user_name = "xxx"
  8942. } else {
  8943. user_name = role.UserName
  8944. }
  8945. psn_record, _ := service.GetPsnRecordById(id)
  8946. if psn_record.ID == 0 {
  8947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8948. return
  8949. }
  8950. if config.IsOpen == 1 {
  8951. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8952. var dat map[string]interface{}
  8953. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8954. fmt.Println(dat)
  8955. } else {
  8956. fmt.Println(err)
  8957. }
  8958. userJSONBytes, _ := json.Marshal(dat)
  8959. var res ResultFourteen
  8960. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8961. utils.ErrorLog("解析失败:%v", err)
  8962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8963. return
  8964. }
  8965. if res.Infcode == 0 {
  8966. psn_record.IsCancel = 2
  8967. service.CreatePsnRecord(&psn_record)
  8968. } else {
  8969. c.ServeSuccessJSON(map[string]interface{}{
  8970. "failed_code": -10,
  8971. "msg": res.ErrMsg,
  8972. })
  8973. return
  8974. }
  8975. }
  8976. }
  8977. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8978. patient_id, _ := c.GetInt64("patient_id")
  8979. insutype_two := c.GetString("insutype")
  8980. psn_no := c.GetString("psn_no")
  8981. doctor_id, _ := c.GetInt64("doctor_id")
  8982. sick_id, _ := c.GetInt64("sick_id")
  8983. department_id, _ := c.GetInt64("department_id")
  8984. start_time := c.GetString("start_time")
  8985. end_time := c.GetString("end_time")
  8986. check_time := c.GetString("check_time")
  8987. adminUser := c.GetAdminUserInfo()
  8988. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8989. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8990. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8991. sick, _ := service.FindSickById(sick_id)
  8992. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8993. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8994. var res ResultTwo
  8995. var res10265 ResultTwo10265
  8996. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8997. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8998. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8999. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9000. "&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
  9001. resp, requestErr := http.Get(api)
  9002. if requestErr != nil {
  9003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9004. return
  9005. }
  9006. body, ioErr := ioutil.ReadAll(resp.Body)
  9007. if ioErr != nil {
  9008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9010. return
  9011. }
  9012. var respJSON map[string]interface{}
  9013. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9016. return
  9017. }
  9018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9019. result, _ := json.Marshal(respJSON)
  9020. fmt.Println("log")
  9021. fmt.Println(string(result))
  9022. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9023. utils.ErrorLog("解析失败:%v", err)
  9024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9025. return
  9026. }
  9027. res.ErrMsg = res10265.ErrMsg
  9028. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9029. res.Infcode = infocode
  9030. res.Output = res10265.Output
  9031. res.InfRefmsgid = res10265.InfRefmsgid
  9032. } else {
  9033. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9034. if miConfig.Code == "H15049901371" {
  9035. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9036. utils.ErrorLog("解析失败:%v", err)
  9037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9038. return
  9039. }
  9040. res.ErrMsg = res10265.ErrMsg
  9041. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9042. res.Infcode = infocode
  9043. res.Output = res10265.Output
  9044. res.InfRefmsgid = res10265.InfRefmsgid
  9045. } else {
  9046. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9047. utils.ErrorLog("解析失败:%v", err)
  9048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9049. return
  9050. }
  9051. }
  9052. }
  9053. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9054. infoStr := string(Iinfos)
  9055. var rf []*ResultFive
  9056. json.Unmarshal([]byte(infoStr), &rf)
  9057. var insuplc_admdvs string
  9058. var insutype string
  9059. var is390 int = 0
  9060. var is310 int = 0
  9061. var insutypes []*ResultFive
  9062. for _, item := range rf {
  9063. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9064. insutypes = append(insutypes, item)
  9065. }
  9066. }
  9067. if len(insutypes) == 1 {
  9068. insutype = insutypes[0].Insutype
  9069. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9070. } else {
  9071. for _, i := range insutypes {
  9072. if i.Insutype == "390" {
  9073. is390 = 1
  9074. }
  9075. if i.Insutype == "310" {
  9076. is310 = 1
  9077. }
  9078. }
  9079. }
  9080. if is390 == 1 {
  9081. insutype = "390"
  9082. }
  9083. if is310 == 1 {
  9084. insutype = "310"
  9085. }
  9086. if len(insutypes) == 2 {
  9087. insutype = insutype_two
  9088. }
  9089. if len(insutypes) == 0 {
  9090. insutype = "310"
  9091. }
  9092. insutype = insutype_two
  9093. fmt.Println(insutype)
  9094. for _, item := range rf {
  9095. fmt.Println(item.Insutype)
  9096. fmt.Println(insutype)
  9097. if item.Insutype == insutype {
  9098. fmt.Println(item.Insutype)
  9099. fmt.Println(insutype)
  9100. insuplc_admdvs = item.InsuplcAdmdvs
  9101. }
  9102. }
  9103. fmt.Println(insuplc_admdvs)
  9104. var res2 ResultThirteen
  9105. var res10265_2 ResultThirteen10265
  9106. if config.IsOpen == 1 {
  9107. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9108. } else {
  9109. 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)
  9110. var dat map[string]interface{}
  9111. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9112. fmt.Println(dat)
  9113. } else {
  9114. fmt.Println(err)
  9115. }
  9116. userJSONBytes, _ := json.Marshal(dat)
  9117. if miConfig.Code == "H15049901371" {
  9118. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9119. utils.ErrorLog("解析失败:%v", err)
  9120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9121. return
  9122. }
  9123. res2.ErrMsg = res10265_2.ErrMsg
  9124. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9125. res2.Infcode = infocode
  9126. res2.Output = res10265_2.Output
  9127. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9128. } else {
  9129. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9130. utils.ErrorLog("解析失败:%v", err)
  9131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9132. return
  9133. }
  9134. }
  9135. }
  9136. if res2.Infcode == 0 {
  9137. psnResult := &models.GdybPsnNcdsRecord{
  9138. UserOrgId: adminUser.CurrentOrgId,
  9139. PatientId: patient.ID,
  9140. PsnNo: psn_no,
  9141. DoctorId: doctor.AdminUserId,
  9142. DepartmentId: department_id,
  9143. SickType: sick_id,
  9144. Insutype: insutype,
  9145. Ctime: time.Now().Unix(),
  9146. Mtime: time.Now().Unix(),
  9147. Status: 1,
  9148. IsCancel: 1,
  9149. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9150. }
  9151. service.CreatePsnNCDSRecord(psnResult)
  9152. c.ServeSuccessJSON(map[string]interface{}{
  9153. "failed_code": 0,
  9154. "msg": "备案成功",
  9155. "result": psnResult,
  9156. })
  9157. } else {
  9158. c.ServeSuccessJSON(map[string]interface{}{
  9159. "failed_code": -10,
  9160. "msg": res2.ErrMsg,
  9161. })
  9162. return
  9163. }
  9164. }
  9165. }
  9166. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9167. id, _ := c.GetInt64("id")
  9168. admin_user_id, _ := c.GetInt64("admin_user_id")
  9169. adminUser := c.GetAdminUserInfo()
  9170. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9171. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9172. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9173. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9174. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9175. //var user_name string
  9176. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9177. //if role.ID == 0 {
  9178. // user_name = "xxx"
  9179. //} else {
  9180. // user_name = role.UserName
  9181. //}
  9182. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9183. if psn_record.ID == 0 {
  9184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9185. return
  9186. }
  9187. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9188. var res ResultTwo
  9189. var res10265 ResultTwo10265
  9190. if miConfig.Code == "H15049901371" {
  9191. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9192. utils.ErrorLog("解析失败:%v", err)
  9193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9194. return
  9195. }
  9196. res.ErrMsg = res10265.ErrMsg
  9197. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9198. res.Infcode = infocode
  9199. res.Output = res10265.Output
  9200. res.InfRefmsgid = res10265.InfRefmsgid
  9201. } else {
  9202. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9203. utils.ErrorLog("解析失败:%v", err)
  9204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9205. return
  9206. }
  9207. }
  9208. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9209. infoStr := string(Iinfos)
  9210. var rf []*ResultFive
  9211. json.Unmarshal([]byte(infoStr), &rf)
  9212. var insuplc_admdvs string
  9213. var insutype string
  9214. var is390 int = 0
  9215. var is310 int = 0
  9216. var insutypes []*ResultFive
  9217. for _, item := range rf {
  9218. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9219. insutypes = append(insutypes, item)
  9220. }
  9221. }
  9222. if len(insutypes) == 1 {
  9223. insutype = insutypes[0].Insutype
  9224. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9225. } else {
  9226. for _, i := range insutypes {
  9227. if i.Insutype == "390" {
  9228. is390 = 1
  9229. }
  9230. if i.Insutype == "310" {
  9231. is310 = 1
  9232. }
  9233. }
  9234. }
  9235. if is390 == 1 {
  9236. insutype = "390"
  9237. }
  9238. if is310 == 1 {
  9239. insutype = "310"
  9240. }
  9241. if len(insutypes) == 0 {
  9242. insutype = "310"
  9243. }
  9244. insutype = psn_record.Insutype
  9245. for _, item := range rf {
  9246. if item.Insutype == insutype {
  9247. insuplc_admdvs = item.InsuplcAdmdvs
  9248. }
  9249. }
  9250. if config.IsOpen == 1 {
  9251. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9252. var dat map[string]interface{}
  9253. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9254. fmt.Println(dat)
  9255. } else {
  9256. fmt.Println(err)
  9257. }
  9258. userJSONBytes, _ := json.Marshal(dat)
  9259. var res ResultFourteen
  9260. var res10265 ResultFourteen10265
  9261. if miConfig.Code == "H15049901371" {
  9262. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9263. utils.ErrorLog("解析失败:%v", err)
  9264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9265. return
  9266. }
  9267. res.ErrMsg = res10265.ErrMsg
  9268. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9269. res.Infcode = infocode
  9270. res.Output = res10265.Output
  9271. res.InfRefmsgid = res10265.InfRefmsgid
  9272. } else {
  9273. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9274. utils.ErrorLog("解析失败:%v", err)
  9275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9276. return
  9277. }
  9278. }
  9279. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9280. // utils.ErrorLog("解析失败:%v", err)
  9281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9282. // return
  9283. //}
  9284. if res.Infcode == 0 {
  9285. psn_record.IsCancel = 2
  9286. service.CreatePsnNCDSRecord(&psn_record)
  9287. c.ServeSuccessJSON(map[string]interface{}{
  9288. "failed_code": 0,
  9289. "msg": "撤销备案成功",
  9290. })
  9291. } else {
  9292. c.ServeSuccessJSON(map[string]interface{}{
  9293. "failed_code": -10,
  9294. "msg": res.ErrMsg,
  9295. })
  9296. return
  9297. }
  9298. }
  9299. }
  9300. func (c *HisApiController) TestTest() {
  9301. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9302. fmt.Println(patient.Iinfo)
  9303. }
  9304. type CustomData struct {
  9305. MsgId string
  9306. PsnNo string
  9307. Info string
  9308. }
  9309. func (c *HisApiController) ReversalData() {
  9310. var customData []*CustomData
  9311. custom := &CustomData{
  9312. MsgId: "H44022900158202103301714472004",
  9313. PsnNo: "44020000001101329945",
  9314. Info: "2207",
  9315. }
  9316. customData = append(customData, custom)
  9317. custom1 := &CustomData{
  9318. MsgId: "H4402290015820210330172057803",
  9319. PsnNo: "44020000001101161813",
  9320. Info: "2207",
  9321. }
  9322. customData = append(customData, custom1)
  9323. custom2 := &CustomData{
  9324. MsgId: "H44022900158202103301705198813",
  9325. PsnNo: "44190000133097375417",
  9326. Info: "2207",
  9327. }
  9328. customData = append(customData, custom2)
  9329. custom3 := &CustomData{
  9330. MsgId: "H44022900158202103301715524756",
  9331. PsnNo: "44020000001100187221",
  9332. Info: "2207",
  9333. }
  9334. customData = append(customData, custom3)
  9335. custom4 := &CustomData{
  9336. MsgId: "H44022900158202103301730376224",
  9337. PsnNo: "44020000001101959155",
  9338. Info: "2207",
  9339. }
  9340. customData = append(customData, custom4)
  9341. custom5 := &CustomData{
  9342. MsgId: "H44022900158202103301748008725",
  9343. PsnNo: "44020000001104246641",
  9344. Info: "2207",
  9345. }
  9346. customData = append(customData, custom5)
  9347. custom6 := &CustomData{
  9348. MsgId: "H44022900158202103301718096755",
  9349. PsnNo: "44020000001102211860",
  9350. Info: "2207",
  9351. }
  9352. customData = append(customData, custom6)
  9353. custom7 := &CustomData{
  9354. MsgId: "H44022900158202103301736551640",
  9355. PsnNo: "44020000001102687718",
  9356. Info: "2207",
  9357. }
  9358. customData = append(customData, custom7)
  9359. custom8 := &CustomData{
  9360. MsgId: "H44022900158202103301743097676",
  9361. PsnNo: "44020000001102127785",
  9362. Info: "2207",
  9363. }
  9364. customData = append(customData, custom8)
  9365. custom9 := &CustomData{
  9366. MsgId: "H44022900158202103301712304203",
  9367. PsnNo: "44020000001101518097",
  9368. Info: "2207",
  9369. }
  9370. customData = append(customData, custom9)
  9371. custom10 := &CustomData{
  9372. MsgId: "H44022900158202103301738448785",
  9373. PsnNo: "44020000001100500813",
  9374. Info: "2207",
  9375. }
  9376. customData = append(customData, custom10)
  9377. custom11 := &CustomData{
  9378. MsgId: "H44022900158202103301732455843",
  9379. PsnNo: "44020000001102690557",
  9380. Info: "2207",
  9381. }
  9382. customData = append(customData, custom11)
  9383. custom12 := &CustomData{
  9384. MsgId: "H44022900158202103301745421708",
  9385. PsnNo: "44020000001102211928",
  9386. Info: "2207",
  9387. }
  9388. customData = append(customData, custom12)
  9389. custom1212 := &CustomData{
  9390. MsgId: "H440229001582021033017351627",
  9391. PsnNo: "44020000001102481733",
  9392. Info: "2207",
  9393. }
  9394. customData = append(customData, custom1212)
  9395. custom13 := &CustomData{
  9396. MsgId: "H44022900158202103301740327951",
  9397. PsnNo: "44020000001103174866",
  9398. Info: "2207",
  9399. }
  9400. customData = append(customData, custom13)
  9401. custom14 := &CustomData{
  9402. MsgId: "H4402290015820210330174922668",
  9403. PsnNo: "44020000001102927272",
  9404. Info: "2207",
  9405. }
  9406. customData = append(customData, custom14)
  9407. custom15 := &CustomData{
  9408. MsgId: "H44022900158202103301752362273",
  9409. PsnNo: "44020000001102942890",
  9410. Info: "2207",
  9411. }
  9412. customData = append(customData, custom15)
  9413. custom16 := &CustomData{
  9414. MsgId: "H44022900158202103301751082917",
  9415. PsnNo: "44020000001101662162",
  9416. Info: "2207",
  9417. }
  9418. customData = append(customData, custom16)
  9419. custom17 := &CustomData{
  9420. MsgId: "H44022900158202103301754147728",
  9421. PsnNo: "44020000000229014511",
  9422. Info: "2207",
  9423. }
  9424. customData = append(customData, custom17)
  9425. adminUser := c.GetAdminUserInfo()
  9426. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9427. for _, item := range customData {
  9428. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9429. fmt.Println(result)
  9430. }
  9431. }
  9432. func (c *HisApiController) GetAllopatry() {
  9433. year := c.GetString("year")
  9434. month := c.GetString("month")
  9435. admin_user_id, _ := c.GetInt64("admin_user_id")
  9436. adminUser := c.GetAdminUserInfo()
  9437. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9438. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9439. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9440. var dat map[string]interface{}
  9441. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9442. fmt.Println(dat)
  9443. } else {
  9444. fmt.Println(err)
  9445. }
  9446. userJSONBytes, _ := json.Marshal(dat)
  9447. var res models.Result9001
  9448. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9449. utils.ErrorLog("解析失败:%v", err)
  9450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9451. return
  9452. }
  9453. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9454. var dat2 map[string]interface{}
  9455. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9456. fmt.Println(dat)
  9457. } else {
  9458. fmt.Println(err)
  9459. }
  9460. userJSONBytes2, _ := json.Marshal(dat2)
  9461. var res2 models.Result3260
  9462. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9463. utils.ErrorLog("解析失败:%v", err)
  9464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9465. return
  9466. }
  9467. if res2.Infcode == 0 {
  9468. c.ServeSuccessJSON(map[string]interface{}{
  9469. "list": res2.Output.Data,
  9470. })
  9471. return
  9472. } else {
  9473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9474. return
  9475. }
  9476. }
  9477. func (c *HisApiController) ComfirmAllopatry() {
  9478. year := c.GetString("year")
  9479. month := c.GetString("month")
  9480. admin_user_id, _ := c.GetInt64("admin_user_id")
  9481. adminUser := c.GetAdminUserInfo()
  9482. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9483. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9484. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9485. var dat map[string]interface{}
  9486. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9487. fmt.Println(dat)
  9488. } else {
  9489. fmt.Println(err)
  9490. }
  9491. userJSONBytes, _ := json.Marshal(dat)
  9492. var res models.Result9001
  9493. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9494. utils.ErrorLog("解析失败:%v", err)
  9495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9496. return
  9497. }
  9498. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9499. var dat2 map[string]interface{}
  9500. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9501. fmt.Println(dat)
  9502. } else {
  9503. fmt.Println(err)
  9504. }
  9505. userJSONBytes2, _ := json.Marshal(dat2)
  9506. var res2 models.Result3260
  9507. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9508. utils.ErrorLog("解析失败:%v", err)
  9509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9510. return
  9511. }
  9512. if res2.Infcode == 0 {
  9513. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9514. var dat map[string]interface{}
  9515. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9516. fmt.Println(dat)
  9517. } else {
  9518. fmt.Println(err)
  9519. }
  9520. userJSONBytes, _ := json.Marshal(dat)
  9521. var res3 models.Result3261
  9522. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9523. utils.ErrorLog("解析失败:%v", err)
  9524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9525. return
  9526. }
  9527. if res3.Infcode == 0 {
  9528. record := &models.HisYidiClearRecord{
  9529. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9530. Ctime: time.Now().Unix(),
  9531. Mtime: time.Now().Unix(),
  9532. Status: 1,
  9533. MsgId: msgId,
  9534. }
  9535. service.SaveClearRecord(record)
  9536. c.ServeSuccessJSON(map[string]interface{}{
  9537. "msg": "提取成功",
  9538. })
  9539. }
  9540. }
  9541. }
  9542. func (c *HisApiController) RefundAllopatry() {
  9543. year := c.GetString("year")
  9544. month := c.GetString("month")
  9545. id, _ := c.GetInt64("id")
  9546. admin_user_id, _ := c.GetInt64("admin_user_id")
  9547. adminUser := c.GetAdminUserInfo()
  9548. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9549. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9550. record, _ := service.GetClearRecordById(id)
  9551. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9552. var dat map[string]interface{}
  9553. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9554. fmt.Println(dat)
  9555. } else {
  9556. fmt.Println(err)
  9557. }
  9558. userJSONBytes, _ := json.Marshal(dat)
  9559. var empty ResultFourteen
  9560. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9561. utils.ErrorLog("解析失败:%v", err)
  9562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9563. return
  9564. }
  9565. if empty.Infcode == 0 {
  9566. c.ServeSuccessJSON(map[string]interface{}{
  9567. "msg": "撤销成功",
  9568. })
  9569. return
  9570. }
  9571. }
  9572. func (c *HisApiController) ReversalOtherData() {
  9573. var customData []*CustomData
  9574. custom := &CustomData{
  9575. MsgId: "H44022900158202103301714472004",
  9576. PsnNo: "44020000001101329945",
  9577. Info: "2208",
  9578. }
  9579. customData = append(customData, custom)
  9580. custom1 := &CustomData{
  9581. MsgId: "H4402290015820210330172057803",
  9582. PsnNo: "44020000001101161813",
  9583. Info: "2208",
  9584. }
  9585. customData = append(customData, custom1)
  9586. custom2 := &CustomData{
  9587. MsgId: "H44022900158202103301705198813",
  9588. PsnNo: "44190000133097375417",
  9589. Info: "2208",
  9590. }
  9591. customData = append(customData, custom2)
  9592. custom3 := &CustomData{
  9593. MsgId: "H44022900158202103301715524756",
  9594. PsnNo: "44020000001100187221",
  9595. Info: "2208",
  9596. }
  9597. customData = append(customData, custom3)
  9598. custom4 := &CustomData{
  9599. MsgId: "H44022900158202103301730376224",
  9600. PsnNo: "44020000001101959155",
  9601. Info: "2208",
  9602. }
  9603. customData = append(customData, custom4)
  9604. custom5 := &CustomData{
  9605. MsgId: "H44022900158202103301748008725",
  9606. PsnNo: "44020000001104246641",
  9607. Info: "2208",
  9608. }
  9609. customData = append(customData, custom5)
  9610. custom6 := &CustomData{
  9611. MsgId: "H44022900158202103301718096755",
  9612. PsnNo: "44020000001102211860",
  9613. Info: "2208",
  9614. }
  9615. customData = append(customData, custom6)
  9616. custom7 := &CustomData{
  9617. MsgId: "H44022900158202103301736551640",
  9618. PsnNo: "44020000001102687718",
  9619. Info: "2208",
  9620. }
  9621. customData = append(customData, custom7)
  9622. custom8 := &CustomData{
  9623. MsgId: "H44022900158202103301743097676",
  9624. PsnNo: "44020000001102127785",
  9625. Info: "2208",
  9626. }
  9627. customData = append(customData, custom8)
  9628. custom9 := &CustomData{
  9629. MsgId: "H44022900158202103301712304203",
  9630. PsnNo: "44020000001101518097",
  9631. Info: "2208",
  9632. }
  9633. customData = append(customData, custom9)
  9634. custom10 := &CustomData{
  9635. MsgId: "H44022900158202103301738448785",
  9636. PsnNo: "44020000001100500813",
  9637. Info: "2208",
  9638. }
  9639. customData = append(customData, custom10)
  9640. custom11 := &CustomData{
  9641. MsgId: "H44022900158202103301732455843",
  9642. PsnNo: "44020000001102690557",
  9643. Info: "2208",
  9644. }
  9645. customData = append(customData, custom11)
  9646. custom12 := &CustomData{
  9647. MsgId: "H44022900158202103301745421708",
  9648. PsnNo: "44020000001102211928",
  9649. Info: "2208",
  9650. }
  9651. customData = append(customData, custom12)
  9652. custom1212 := &CustomData{
  9653. MsgId: "H440229001582021033017351627",
  9654. PsnNo: "44020000001102481733",
  9655. Info: "2208",
  9656. }
  9657. customData = append(customData, custom1212)
  9658. custom13 := &CustomData{
  9659. MsgId: "H44022900158202103301740327951",
  9660. PsnNo: "44020000001103174866",
  9661. Info: "2208",
  9662. }
  9663. customData = append(customData, custom13)
  9664. custom14 := &CustomData{
  9665. MsgId: "H4402290015820210330174922668",
  9666. PsnNo: "44020000001102927272",
  9667. Info: "2208",
  9668. }
  9669. customData = append(customData, custom14)
  9670. custom15 := &CustomData{
  9671. MsgId: "H44022900158202103301752362273",
  9672. PsnNo: "44020000001102942890",
  9673. Info: "2208",
  9674. }
  9675. customData = append(customData, custom15)
  9676. custom16 := &CustomData{
  9677. MsgId: "H44022900158202103301751082917",
  9678. PsnNo: "44020000001101662162",
  9679. Info: "2208",
  9680. }
  9681. customData = append(customData, custom16)
  9682. custom17 := &CustomData{
  9683. MsgId: "H44022900158202103301754147728",
  9684. PsnNo: "44020000000229014511",
  9685. Info: "2208",
  9686. }
  9687. customData = append(customData, custom17)
  9688. adminUser := c.GetAdminUserInfo()
  9689. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9690. for _, item := range customData {
  9691. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9692. fmt.Println(result)
  9693. }
  9694. }
  9695. func PathExists(path string) (bool, error) {
  9696. _, err := os.Stat(path)
  9697. if err == nil {
  9698. return true, nil
  9699. }
  9700. if os.IsNotExist(err) {
  9701. return false, nil
  9702. }
  9703. return false, err
  9704. }
  9705. //创建文件夹
  9706. func Mkdir(dir string) {
  9707. // 创建文件夹
  9708. exist, err := PathExists(dir)
  9709. if err != nil {
  9710. fmt.Println(err.Error())
  9711. } else {
  9712. if exist {
  9713. fmt.Println(dir + "文件夹已存在!")
  9714. } else {
  9715. // 文件夹名称,权限
  9716. err := os.Mkdir(dir, os.ModePerm)
  9717. if err != nil {
  9718. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9719. } else {
  9720. fmt.Println(dir + "文件夹创建成功!")
  9721. }
  9722. }
  9723. }
  9724. }
  9725. //压缩文件
  9726. func Zip(srcFile string, destZip string) error {
  9727. zipfile, err := os.Create(destZip)
  9728. if err != nil {
  9729. return err
  9730. }
  9731. defer zipfile.Close()
  9732. archive := zip.NewWriter(zipfile)
  9733. defer archive.Close()
  9734. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9735. if err != nil {
  9736. return err
  9737. }
  9738. header, err := zip.FileInfoHeader(info)
  9739. if err != nil {
  9740. return err
  9741. }
  9742. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9743. // header.Name = path
  9744. if info.IsDir() {
  9745. header.Name += "/"
  9746. } else {
  9747. header.Method = zip.Deflate
  9748. }
  9749. writer, err := archive.CreateHeader(header)
  9750. if err != nil {
  9751. return err
  9752. }
  9753. if !info.IsDir() {
  9754. file, err := os.Open(path)
  9755. if err != nil {
  9756. return err
  9757. }
  9758. defer file.Close()
  9759. _, err = io.Copy(writer, file)
  9760. }
  9761. return err
  9762. })
  9763. return err
  9764. }
  9765. func ReadFile(filePath string) []byte {
  9766. f, err := os.Open(filePath)
  9767. if err != nil {
  9768. fmt.Println("read file fail", err)
  9769. return nil
  9770. }
  9771. defer f.Close()
  9772. fd, err := ioutil.ReadAll(f)
  9773. if err != nil {
  9774. fmt.Println("read to fd fail", err)
  9775. return nil
  9776. }
  9777. return fd
  9778. }
  9779. func saveLog(result string, request string, infno string, desc string) {
  9780. org_id, _ := beego.AppConfig.Int64("org_id")
  9781. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9782. dir := miConfig.OrgName + "日志"
  9783. utils.Mkdir(dir)
  9784. month := time.Unix(1557042972, 0).Format("1")
  9785. year := time.Now().Format("2006")
  9786. month = time.Now().Format("01")
  9787. day := time.Now().Format("02")
  9788. hour := time.Now().Format("15")
  9789. min := time.Now().Format("04")
  9790. sec := time.Now().Format("05")
  9791. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9792. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9793. file_name := file + ".txt"
  9794. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9795. exist, _ := utils.PathExists(file_path)
  9796. if exist { //存在
  9797. fmt.Println("存在")
  9798. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9799. if err != nil {
  9800. fmt.Println("read fail")
  9801. }
  9802. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9803. n, _ := f.Seek(0, 2)
  9804. _, err = f.WriteAt([]byte(content), n)
  9805. } else { //不存在
  9806. fmt.Println("文件不存在,创建文件")
  9807. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9808. defer f.Close()
  9809. if err != nil {
  9810. } else {
  9811. _, err = f.Write([]byte("记录日志"))
  9812. }
  9813. }
  9814. }
  9815. type Charset string
  9816. const (
  9817. UTF8 = Charset("UTF-8")
  9818. GB18030 = Charset("GB18030")
  9819. )
  9820. func ConvertToString(src string, srcCode string, tagCode string) string {
  9821. srcCoder := mahonia.NewDecoder(srcCode)
  9822. srcResult := srcCoder.ConvertString(src)
  9823. tagCoder := mahonia.NewDecoder(tagCode)
  9824. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9825. result := string(cdata)
  9826. return result
  9827. }