his_api_controller.go 330KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179
  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/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  65. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  66. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  67. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  68. }
  69. func (c *HisApiController) GetPsnNcdsInfo() {
  70. admin_user_id, _ := c.GetInt64("admin_user_id")
  71. id, _ := c.GetInt64("id")
  72. adminUser := c.GetAdminUserInfo()
  73. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  74. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  75. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  76. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  77. psn_record, _ := service.GetPsnNCDSRecordById(id)
  78. if psn_record.ID == 0 {
  79. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  80. return
  81. }
  82. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  83. var dat map[string]interface{}
  84. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  85. fmt.Println(dat)
  86. } else {
  87. fmt.Println(err)
  88. }
  89. userJSONBytes, _ := json.Marshal(dat)
  90. var res Result5301
  91. var res10265 Result5301For10265
  92. if miConfig.Code == "H15049901371" {
  93. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  94. utils.ErrorLog("解析失败:%v", err)
  95. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  96. return
  97. }
  98. res.InfRefmsgid = res10265.InfRefmsgid
  99. res.Output = res10265.Output
  100. res.ErrMsg = res10265.ErrMsg
  101. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  102. res.Infcode = infocode
  103. } else {
  104. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  105. utils.ErrorLog("解析失败:%v", err)
  106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  107. return
  108. }
  109. }
  110. if res.Infcode == 0 {
  111. c.ServeSuccessJSON(map[string]interface{}{
  112. "result": res.Output.Result,
  113. })
  114. }
  115. }
  116. func (c *HisApiController) CheckInsutype() {
  117. his_patient_id, _ := c.GetInt64("his_patient_id")
  118. admin_user_id, _ := c.GetInt64("admin_user_id")
  119. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  120. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  121. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  122. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  123. var dat map[string]interface{}
  124. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  125. fmt.Println(dat)
  126. } else {
  127. fmt.Println(err)
  128. }
  129. userJSONBytes, _ := json.Marshal(dat)
  130. var res Result90100
  131. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  132. utils.ErrorLog("解析失败:%v", err)
  133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  134. return
  135. }
  136. if res.Infcode != 0 {
  137. c.ServeSuccessJSON(map[string]interface{}{
  138. "failed_code": -10,
  139. "msg": res.ErrMsg,
  140. })
  141. return
  142. } else {
  143. fmt.Println(res)
  144. }
  145. }
  146. func (c *HisApiController) CheckCardPWD() {
  147. card_pwd := c.GetString("card_pwd")
  148. his_patient_id, _ := c.GetInt64("his_patient_id")
  149. admin_user_id, _ := c.GetInt64("admin_user_id")
  150. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  151. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  152. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  153. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  154. var dat map[string]interface{}
  155. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  156. fmt.Println(dat)
  157. } else {
  158. fmt.Println(err)
  159. }
  160. userJSONBytes, _ := json.Marshal(dat)
  161. var res Result90991
  162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  163. utils.ErrorLog("解析失败:%v", err)
  164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  165. return
  166. }
  167. if res.Infcode != 0 {
  168. c.ServeSuccessJSON(map[string]interface{}{
  169. "failed_code": -10,
  170. "msg": res.ErrMsg,
  171. })
  172. return
  173. } else {
  174. if res.Output.Result.CheckStat == "0" {
  175. var msg string
  176. switch res.Output.Result.CardStat {
  177. case "00":
  178. msg = "未激活"
  179. break
  180. case "10":
  181. msg = "激活"
  182. break
  183. case "20":
  184. msg = "窗口挂失"
  185. break
  186. case "21":
  187. msg = "电话挂失"
  188. break
  189. case "22":
  190. msg = "单位网上申报挂失"
  191. break
  192. case "23":
  193. msg = "保健办挂失"
  194. break
  195. case "24":
  196. msg = "个人网上挂失"
  197. break
  198. case "25":
  199. msg = "网上服务大厅挂失"
  200. break
  201. case "30":
  202. msg = "注销"
  203. break
  204. case "40":
  205. msg = "回收"
  206. break
  207. case "99":
  208. msg = "制卡中(无效卡)"
  209. break
  210. }
  211. c.ServeSuccessJSON(map[string]interface{}{
  212. "failed_code": -10,
  213. "msg": msg,
  214. })
  215. return
  216. } else {
  217. c.ServeSuccessJSON(map[string]interface{}{
  218. "msg": "校验成功",
  219. })
  220. return
  221. }
  222. }
  223. }
  224. func (c *HisApiController) ReadCard() {
  225. id_card_type, _ := c.GetInt64("id_card_type")
  226. admin_user_id, _ := c.GetInt64("admin_user_id")
  227. certificates, _ := c.GetInt64("certificates")
  228. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  229. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  230. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  231. switch id_card_type {
  232. case 1:
  233. if miConfig.MdtrtareaAdmvs == "421300" {
  234. var res ResultTwo
  235. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  236. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  237. "&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)
  238. resp, requestErr := http.Get(api)
  239. if requestErr != nil {
  240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  241. return
  242. }
  243. body, ioErr := ioutil.ReadAll(resp.Body)
  244. if ioErr != nil {
  245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  247. return
  248. }
  249. var respJSON map[string]interface{}
  250. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  253. return
  254. }
  255. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  256. result, _ := json.Marshal(respJSON)
  257. fmt.Println("log")
  258. fmt.Println(string(result))
  259. if err := json.Unmarshal([]byte(result), &res); err != nil {
  260. utils.ErrorLog("解析失败:%v", err)
  261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  262. return
  263. }
  264. if res.Infcode == 0 {
  265. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  266. if err == gorm.ErrRecordNotFound {
  267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  268. return
  269. } else if err != nil {
  270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  271. return
  272. } else {
  273. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  274. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  275. infoStr := string(Iinfos)
  276. idetinfoStr := string(Idetinfos)
  277. psn := &models.HisPsn{
  278. PsnNo: res.Output.Baseinfo.PsnNo,
  279. Age: res.Output.Baseinfo.Age,
  280. PatientId: patient.ID,
  281. Certno: res.Output.Baseinfo.Certno,
  282. Brdy: res.Output.Baseinfo.Brdy,
  283. Gend: res.Output.Baseinfo.Gend,
  284. Naty: res.Output.Baseinfo.Naty,
  285. PsnCertType: res.Output.Baseinfo.PsnCertType,
  286. PsnName: res.Output.Baseinfo.PsnName,
  287. Idetinfo: idetinfoStr,
  288. Insuinfo: infoStr,
  289. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  290. }
  291. service.CreateHisPsn(psn)
  292. c.ServeSuccessJSON(map[string]interface{}{
  293. "patient": patient,
  294. "number": res.Output.Baseinfo.Certno,
  295. })
  296. }
  297. } else {
  298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  299. return
  300. }
  301. } else {
  302. if initFlag == 0 {
  303. c.TestGetBasBaseInit()
  304. }
  305. basStr := c.GetBasBaseInfo()
  306. if len(basStr) == 0 {
  307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  308. return
  309. }
  310. fmt.Println(basStr)
  311. bas := strings.Split(basStr, "|")
  312. basNumber := bas[1]
  313. fmt.Println(basNumber)
  314. card_sn := bas[3]
  315. fmt.Println(card_sn)
  316. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  317. var dat map[string]interface{}
  318. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  319. fmt.Println(dat)
  320. } else {
  321. fmt.Println(err)
  322. }
  323. userJSONBytes, _ := json.Marshal(dat)
  324. var res ResultTwo
  325. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  326. utils.ErrorLog("解析失败:%v", err)
  327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  328. return
  329. }
  330. if res.Infcode == 0 {
  331. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  332. if err == gorm.ErrRecordNotFound {
  333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  334. return
  335. } else if err != nil {
  336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  337. return
  338. } else {
  339. c.ServeSuccessJSON(map[string]interface{}{
  340. "patient": patient,
  341. "number": basNumber,
  342. })
  343. }
  344. } else {
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  346. return
  347. }
  348. break
  349. }
  350. case 2:
  351. SFZStr := c.GetSFZBaseInfo()
  352. id_card_str := strings.Split(SFZStr, "^")
  353. id_card_number := id_card_str[0]
  354. card_sn := ""
  355. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  356. var dat map[string]interface{}
  357. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  358. fmt.Println(dat)
  359. } else {
  360. fmt.Println(err)
  361. }
  362. userJSONBytes, _ := json.Marshal(dat)
  363. var res ResultTwo
  364. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  365. utils.ErrorLog("解析失败:%v", err)
  366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  367. return
  368. }
  369. if res.Infcode == 0 {
  370. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  371. if err == gorm.ErrRecordNotFound {
  372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  373. return
  374. } else if err != nil {
  375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  376. return
  377. } else {
  378. c.ServeSuccessJSON(map[string]interface{}{
  379. "patient": patient,
  380. "number": id_card_number,
  381. })
  382. }
  383. } else {
  384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  385. return
  386. }
  387. break
  388. case 3:
  389. break
  390. }
  391. }
  392. var initFlag int64 = 0
  393. func (c *HisApiController) TestGetBasBaseInit() {
  394. DllDef := syscall.MustLoadDLL("SSCard.dll")
  395. Iinit := DllDef.MustFindProc("Init")
  396. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  397. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  398. if ret != 0 {
  399. fmt.Println("SSCard的报错原因:", err)
  400. fmt.Println("SSCard的运算结果为:", ret)
  401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  402. return
  403. }
  404. result := int(ret)
  405. fmt.Println("SSCard的运算结果为1:", result)
  406. initFlag = 1
  407. return
  408. }
  409. func (c *HisApiController) GetSFZBaseInfo() string {
  410. DllDef := syscall.MustLoadDLL("SSCard.dll")
  411. readCard := DllDef.MustFindProc("ReadSFZ")
  412. if readCard == nil {
  413. fmt.Println("readcard is nil")
  414. readCard = DllDef.MustFindProc("ReadSFZ")
  415. }
  416. str := make([]byte, 256)
  417. str1 := make([]byte, 256)
  418. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  419. fmt.Println(r)
  420. return string(str)
  421. }
  422. func (c *HisApiController) GetBasBaseInfo() string {
  423. DllDef := syscall.MustLoadDLL("SSCard.dll")
  424. readCard := DllDef.MustFindProc("ReadCardBas")
  425. if readCard == nil {
  426. fmt.Println("readcard is nil")
  427. readCard = DllDef.MustFindProc("ReadCardBas")
  428. }
  429. str := make([]byte, 1024)
  430. str1 := make([]byte, 1024)
  431. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  432. fmt.Println(string(str1))
  433. fmt.Println(string(str))
  434. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  435. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  436. if ret2 != 0 {
  437. return ""
  438. }
  439. return string(str)
  440. }
  441. type CustomFundPay struct {
  442. FundPayType string `json:"fund_pay_type"`
  443. FundPayamt float64 `json:"fund_payamt"`
  444. }
  445. func (c *HisApiController) GetSettleList() {
  446. order_id, _ := c.GetInt64("order_id")
  447. admin_user_id, _ := c.GetInt64("admin_user_id")
  448. order, _ := service.GetHisOrderByIDTwo(order_id)
  449. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  450. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  451. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  452. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  453. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  454. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  455. if order.ID == 0 {
  456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  457. return
  458. }
  459. struct4101 := service.Struct4101{
  460. PsnNo: order.PsnNo,
  461. MdtrtId: order.MdtrtId,
  462. SetlId: order.SetlId,
  463. PsnName: order.PsnName,
  464. Gend: order.Gend,
  465. Brdy: his.Brdy,
  466. Age: his.Age,
  467. Naty: order.Naty,
  468. PatnCertType: "01",
  469. Certno: order.Certno,
  470. Prfs: "90",
  471. ConerName: roles[0].UserName,
  472. PatnRlts: "99",
  473. ConerAddr: miConfig.OrgName,
  474. ConerTel: admin.Mobile,
  475. HiType: order.Insutype,
  476. Insuplc: miConfig.InsuplcAdmdvs,
  477. MaindiagFlag: "1",
  478. BillCode: order.FaPiaoCode,
  479. BillNo: order.FaPiaoNumber,
  480. BizSn: order.Number,
  481. PsnSelfPay: order.PsnPartAmt,
  482. PsnOwnPay: order.PsnPartAmt,
  483. AcctPay: order.AcctPay,
  484. PsnCashpay: order.PsnCashPay,
  485. HiPaymtd: "1",
  486. Hsorg: miConfig.InsuplcAdmdvs,
  487. HsorgOpter: miConfig.InsuplcAdmdvs,
  488. MedinsFillPsn: curRoles.UserName,
  489. MedinsFillDept: depart.Name,
  490. IptMedType: "2",
  491. }
  492. struct4101.SetlBegnDate = order.SetlTime
  493. struct4101.SetlEndDate = order.SetlTime
  494. //if order.SettleType == 1 {
  495. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  496. // dateStr := t.Format("2006-01-02")
  497. // struct4101.SetlBegnDate = dateStr
  498. // struct4101.SetlEndDate = dateStr
  499. //} else {
  500. // t := time.Unix(int64(order.SettleStartTime), 0)
  501. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  502. // dateStartStr := t.Format("2006-01-02")
  503. // dateEndStr := t2.Format("2006-01-02")
  504. // struct4101.SetlBegnDate = dateStartStr
  505. // struct4101.SetlEndDate = dateEndStr
  506. //}
  507. var rf []CustomFundPay
  508. json.Unmarshal([]byte(order.SetlDetail), &rf)
  509. var tempFunPays []service.CustomStruct
  510. for _, item := range rf {
  511. var tempFunPay service.CustomStruct
  512. tempFunPay.FundPayamt = item.FundPayamt
  513. tempFunPay.FundPayType = item.FundPayType
  514. tempFunPays = append(tempFunPays, tempFunPay)
  515. }
  516. struct4101.CustomStruct = tempFunPays
  517. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  518. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  519. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  520. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  521. var config []*models.HisXtDiagnoseConfig
  522. for _, item := range diagnosis_ids {
  523. id, _ := strconv.ParseInt(item, 10, 64)
  524. diagnosisConfig, _ := service.FindDiagnoseById(id)
  525. config = append(config, &diagnosisConfig)
  526. }
  527. for _, item := range config {
  528. var tempOpspdiseinfo service.OpspdiseinfoStruct
  529. tempOpspdiseinfo.DiagCode = item.CountryCode
  530. tempOpspdiseinfo.DiagName = item.CountryContentName
  531. tempOpspdiseinfo.MaindiagFlag = "1"
  532. tempOpspdiseinfo.OprnOprtCode = ""
  533. tempOpspdiseinfo.OprnOprtName = ""
  534. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  535. }
  536. sickConfigTwo, _ := service.FindSickById(his.SickType)
  537. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  538. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  539. tempOpspdiseinfo2.MaindiagFlag = "2"
  540. tempOpspdiseinfo2.OprnOprtCode = ""
  541. tempOpspdiseinfo2.OprnOprtName = ""
  542. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  543. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  544. var iteminfo service.IteminfoStruct
  545. var bedCostTotal float64 = 0 //床位总费
  546. var bedCostSelfTotal float64 = 0 //床位自费
  547. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  548. var operationCostTotal float64 = 0 //手术费
  549. var operationCostSelfTotal float64 = 0 //手术费
  550. var operationCostPartSelfTotal float64 = 0 //手术费
  551. var otherCostTotal float64 = 0 //其他费用
  552. var otherCostSelfTotal float64 = 0 //其他费用
  553. var otherCostPartSelfTotal float64 = 0 //其他费用
  554. var materialCostTotal float64 = 0 //材料费
  555. var materialCostSelfTotal float64 = 0 //材料费
  556. var materialCostPartSelfTotal float64 = 0 //材料费
  557. var westernMedicineCostTotal float64 = 0 //西药费
  558. var westernMedicineCostSelfTotal float64 = 0 //西药费
  559. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  560. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  561. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  562. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  563. var checkCostTotal float64 = 0 //检查费
  564. var checkCostSelfTotal float64 = 0 //检查费
  565. var checkCostPartSelfTotal float64 = 0 //检查费
  566. var laboratoryCostTotal float64 = 0 //化验费
  567. var laboratoryCostSelfTotal float64 = 0 //化验费
  568. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  569. var treatCostTotal float64 = 0 //治疗费用
  570. var treatCostSelfTotal float64 = 0 //治疗费用
  571. var treatCostPartSelfTotal float64 = 0 //治疗费用
  572. decimal.DivisionPrecision = 2
  573. var bed_fulamt_ownpay_amt float64 = 0
  574. var operation_fulamt_ownpay_amt float64 = 0
  575. var other_fulamt_ownpay_amt float64 = 0
  576. var westernMedicine_fulamt_ownpay_amt float64 = 0
  577. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  578. var check_fulamt_ownpay_amt float64 = 0
  579. var material_fulamt_ownpay_amt float64 = 0
  580. var laboratory_fulamt_ownpay_amt float64 = 0
  581. var treat_fulamt_ownpay_amt float64 = 0
  582. var bed_claa_sunmfee float64 = 0
  583. var bed_clab_amt float64 = 0
  584. var bed_other_amt float64 = 0
  585. var operation_claa_sunmfee float64 = 0
  586. var operation_clab_amt float64 = 0
  587. var operation_other_amt float64 = 0
  588. var other_claa_sunmfee float64 = 0
  589. var other_clab_amt float64 = 0
  590. var other_other_amt float64 = 0
  591. var westernMedicine_claa_sunmfee float64 = 0
  592. var westernMedicine_clab_amt float64 = 0
  593. var westernMedicine_other_amt float64 = 0
  594. var chineseTraditional_claa_sunmfee float64 = 0
  595. var chineseTraditional_clab_amt float64 = 0
  596. var chineseTraditional_other_amt float64 = 0
  597. var check_claa_sunmfee float64 = 0
  598. var check_clab_amt float64 = 0
  599. var check_other_amt float64 = 0
  600. var material_claa_sunmfee float64 = 0
  601. var material_clab_amt float64 = 0
  602. var material_other_amt float64 = 0
  603. var laboratory_claa_sunmfee float64 = 0
  604. var laboratory_clab_amt float64 = 0
  605. var laboratory_other_amt float64 = 0
  606. var treat_claa_sunmfee float64 = 0
  607. var treat_clab_amt float64 = 0
  608. var treat_other_amt float64 = 0
  609. for _, item := range order.HisOrderInfo {
  610. if item.MedChrgitmType == "01" { //床位费
  611. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  612. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  613. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  614. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  615. if item.ChrgitmLv == "1" {
  616. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  617. }
  618. if item.ChrgitmLv == "2" {
  619. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  620. }
  621. if item.ChrgitmLv == "3" {
  622. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  623. }
  624. }
  625. if item.MedChrgitmType == "03" { //检查费
  626. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  627. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  628. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  629. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  630. if item.ChrgitmLv == "1" {
  631. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  632. }
  633. if item.ChrgitmLv == "2" {
  634. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  635. }
  636. if item.ChrgitmLv == "3" {
  637. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  638. }
  639. }
  640. if item.MedChrgitmType == "04" { //化验费
  641. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  642. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  643. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  644. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  645. if item.ChrgitmLv == "1" {
  646. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  647. }
  648. if item.ChrgitmLv == "2" {
  649. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  650. }
  651. if item.ChrgitmLv == "3" {
  652. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  653. }
  654. }
  655. if item.MedChrgitmType == "05" { //治疗费
  656. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  657. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  658. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  659. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  660. if item.ChrgitmLv == "1" {
  661. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  662. }
  663. if item.ChrgitmLv == "2" {
  664. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  665. }
  666. if item.ChrgitmLv == "3" {
  667. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  668. }
  669. }
  670. if item.MedChrgitmType == "06" { //手术费
  671. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  672. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  673. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  674. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  675. if item.ChrgitmLv == "1" {
  676. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  677. }
  678. if item.ChrgitmLv == "2" {
  679. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  680. }
  681. if item.ChrgitmLv == "3" {
  682. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  683. }
  684. }
  685. if item.MedChrgitmType == "08" { //材料费
  686. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  687. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  688. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  689. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  690. if item.ChrgitmLv == "1" {
  691. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  692. }
  693. if item.ChrgitmLv == "2" {
  694. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  695. }
  696. if item.ChrgitmLv == "3" {
  697. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  698. }
  699. }
  700. if item.MedChrgitmType == "09" { //西药费
  701. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  702. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  703. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  704. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  705. if item.ChrgitmLv == "1" {
  706. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  707. }
  708. if item.ChrgitmLv == "2" {
  709. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  710. }
  711. if item.ChrgitmLv == "3" {
  712. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  713. }
  714. }
  715. if item.MedChrgitmType == "11" { //中成费
  716. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  717. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  718. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  719. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  720. if item.ChrgitmLv == "1" {
  721. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  722. }
  723. if item.ChrgitmLv == "2" {
  724. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  725. }
  726. if item.ChrgitmLv == "3" {
  727. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  728. }
  729. }
  730. if item.MedChrgitmType == "14" { //其他费
  731. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  732. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  733. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  734. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  735. if item.ChrgitmLv == "1" {
  736. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  737. }
  738. if item.ChrgitmLv == "2" {
  739. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  740. }
  741. if item.ChrgitmLv == "3" {
  742. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  743. }
  744. }
  745. }
  746. var iteminfoStructs []service.IteminfoStruct
  747. if bedCostTotal != 0 {
  748. iteminfo.MedChrgitm = "01"
  749. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  750. iteminfo.Amt = bedCostTotal
  751. iteminfo.ClaaSumfee = bed_claa_sunmfee
  752. iteminfo.ClabAmt = bed_clab_amt
  753. iteminfo.OthAmt = bed_other_amt
  754. iteminfoStructs = append(iteminfoStructs, iteminfo)
  755. }
  756. if checkCostTotal != 0 {
  757. iteminfo.MedChrgitm = "03"
  758. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  759. iteminfo.Amt = checkCostTotal
  760. iteminfo.ClaaSumfee = check_claa_sunmfee
  761. iteminfo.ClabAmt = check_clab_amt
  762. iteminfo.OthAmt = check_other_amt
  763. iteminfoStructs = append(iteminfoStructs, iteminfo)
  764. }
  765. if laboratoryCostTotal != 0 {
  766. iteminfo.MedChrgitm = "04"
  767. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  768. iteminfo.Amt = laboratoryCostTotal
  769. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  770. iteminfo.ClabAmt = laboratory_clab_amt
  771. iteminfo.OthAmt = laboratory_other_amt
  772. iteminfoStructs = append(iteminfoStructs, iteminfo)
  773. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  774. }
  775. if treatCostTotal != 0 {
  776. iteminfo.MedChrgitm = "05"
  777. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  778. iteminfo.Amt = treatCostTotal
  779. iteminfo.ClaaSumfee = treat_claa_sunmfee
  780. iteminfo.ClabAmt = treat_clab_amt
  781. iteminfo.OthAmt = treat_other_amt
  782. iteminfoStructs = append(iteminfoStructs, iteminfo)
  783. //(struct4101.IteminfoStruct, iteminfo)
  784. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  785. }
  786. if operationCostTotal != 0 {
  787. iteminfo.MedChrgitm = "06"
  788. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  789. iteminfo.Amt = operationCostTotal
  790. iteminfo.ClaaSumfee = operation_claa_sunmfee
  791. iteminfo.ClabAmt = operation_clab_amt
  792. iteminfo.OthAmt = operation_other_amt
  793. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  794. iteminfoStructs = append(iteminfoStructs, iteminfo)
  795. }
  796. if materialCostTotal != 0 {
  797. iteminfo.MedChrgitm = "08"
  798. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  799. iteminfo.Amt = materialCostTotal
  800. iteminfo.ClaaSumfee = material_claa_sunmfee
  801. iteminfo.ClabAmt = material_clab_amt
  802. iteminfo.OthAmt = material_other_amt
  803. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  804. iteminfoStructs = append(iteminfoStructs, iteminfo)
  805. }
  806. if westernMedicineCostTotal != 0 {
  807. iteminfo.MedChrgitm = "09"
  808. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  809. iteminfo.Amt = westernMedicineCostTotal
  810. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  811. iteminfo.ClabAmt = westernMedicine_clab_amt
  812. iteminfo.OthAmt = westernMedicine_other_amt
  813. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  814. iteminfoStructs = append(iteminfoStructs, iteminfo)
  815. }
  816. if chineseTraditionalMedicineCostTotal != 0 {
  817. iteminfo.MedChrgitm = "11"
  818. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  819. iteminfo.Amt = westernMedicineCostTotal
  820. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  821. iteminfo.ClabAmt = westernMedicine_clab_amt
  822. iteminfo.OthAmt = westernMedicine_other_amt
  823. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  824. iteminfoStructs = append(iteminfoStructs, iteminfo)
  825. }
  826. if otherCostTotal != 0 {
  827. iteminfo.MedChrgitm = "14"
  828. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  829. iteminfo.Amt = otherCostTotal
  830. iteminfo.ClaaSumfee = other_claa_sunmfee
  831. iteminfo.ClabAmt = other_clab_amt
  832. iteminfo.OthAmt = other_other_amt
  833. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  834. iteminfoStructs = append(iteminfoStructs, iteminfo)
  835. }
  836. struct4101.IteminfoStruct = iteminfoStructs
  837. struct4101.Ntly = "中国"
  838. struct4101.AdmCaty = "A03.06"
  839. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  840. fmt.Println(result)
  841. var dat map[string]interface{}
  842. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  843. fmt.Println(dat)
  844. } else {
  845. fmt.Println(err)
  846. }
  847. userJSONBytes, _ := json.Marshal(dat)
  848. var res ResultSeventeen
  849. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  850. utils.ErrorLog("解析失败:%v", err)
  851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  852. return
  853. }
  854. if res.Infcode != 0 {
  855. c.ServeSuccessJSON(map[string]interface{}{
  856. "failed_code": -10,
  857. "msg": res.ErrMsg,
  858. })
  859. return
  860. } else {
  861. hisFundSettleListResult := &models.HisFundSettleListResult{
  862. Number: res.Output.SetlListId,
  863. Status: 1,
  864. Ctime: time.Now().Unix(),
  865. Mtime: time.Now().Unix(),
  866. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  867. IsUpload: 1,
  868. OrderId: order_id,
  869. }
  870. service.CreateUploadRecord(hisFundSettleListResult)
  871. c.ServeSuccessJSON(map[string]interface{}{
  872. "msg": "上传成功",
  873. "result": hisFundSettleListResult,
  874. })
  875. return
  876. }
  877. }
  878. func (c *HisApiController) GetBatchSettleList() {
  879. org_id, _ := beego.AppConfig.Int64("org_id")
  880. //stage, _ := c.GetInt64("stage")
  881. orders, _ := service.GetAllHisOrder(org_id)
  882. for _, item := range orders {
  883. order_id := item.ID
  884. order, _ := service.GetHisOrderByIDTwo(order_id)
  885. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  886. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  887. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  888. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2500)
  889. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  890. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  891. if order.ID == 0 {
  892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  893. return
  894. }
  895. if his.BalanceAccountsType == 2 {
  896. continue
  897. }
  898. struct4101 := service.Struct4101{
  899. PsnNo: order.PsnNo,
  900. MdtrtId: order.MdtrtId,
  901. SetlId: order.SetlId,
  902. PsnName: order.PsnName,
  903. Gend: order.Gend,
  904. Brdy: his.Brdy,
  905. Age: his.Age,
  906. Naty: order.Naty,
  907. PatnCertType: "01",
  908. Certno: order.Certno,
  909. Prfs: "90",
  910. ConerName: roles[0].UserName,
  911. PatnRlts: "99",
  912. ConerAddr: miConfig.OrgName,
  913. ConerTel: admin.Mobile,
  914. HiType: order.Insutype,
  915. Insuplc: miConfig.InsuplcAdmdvs,
  916. MaindiagFlag: "1",
  917. BillCode: order.FaPiaoCode,
  918. BillNo: order.FaPiaoNumber,
  919. BizSn: order.Number,
  920. PsnSelfPay: order.PsnPartAmt,
  921. PsnOwnPay: order.PsnPartAmt,
  922. AcctPay: order.AcctPay,
  923. PsnCashpay: order.PsnCashPay,
  924. HiPaymtd: "1",
  925. Hsorg: miConfig.InsuplcAdmdvs,
  926. HsorgOpter: miConfig.InsuplcAdmdvs,
  927. MedinsFillPsn: curRoles.UserName,
  928. MedinsFillDept: depart.Name,
  929. IptMedType: "2",
  930. }
  931. struct4101.SetlBegnDate = order.SetlTime
  932. struct4101.SetlEndDate = order.SetlTime
  933. //if order.SettleType == 1 {
  934. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  935. // dateStr := t.Format("2006-01-02")
  936. // struct4101.SetlBegnDate = dateStr
  937. // struct4101.SetlEndDate = dateStr
  938. //} else {
  939. // t := time.Unix(int64(order.SettleStartTime), 0)
  940. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  941. // dateStartStr := t.Format("2006-01-02")
  942. // dateEndStr := t2.Format("2006-01-02")
  943. // struct4101.SetlBegnDate = dateStartStr
  944. // struct4101.SetlEndDate = dateEndStr
  945. //}
  946. var rf []CustomFundPay
  947. json.Unmarshal([]byte(order.SetlDetail), &rf)
  948. var tempFunPays []service.CustomStruct
  949. var tempFunPay610100 service.CustomStruct
  950. for _, item := range rf {
  951. if item.FundPayType == "610100" {
  952. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  953. tempFunPay610100.FundPayType = item.FundPayType
  954. } else {
  955. var tempFunPay service.CustomStruct
  956. tempFunPay.FundPayamt = item.FundPayamt
  957. tempFunPay.FundPayType = item.FundPayType
  958. tempFunPays = append(tempFunPays, tempFunPay)
  959. }
  960. }
  961. tempFunPays = append(tempFunPays, tempFunPay610100)
  962. struct4101.CustomStruct = tempFunPays
  963. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  964. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  965. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  966. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  967. var config []*models.HisXtDiagnoseConfig
  968. for _, item := range diagnosis_ids {
  969. id, _ := strconv.ParseInt(item, 10, 64)
  970. diagnosisConfig, _ := service.FindDiagnoseById(id)
  971. config = append(config, &diagnosisConfig)
  972. }
  973. for _, item := range config {
  974. var tempOpspdiseinfo service.OpspdiseinfoStruct
  975. tempOpspdiseinfo.DiagCode = item.CountryCode
  976. tempOpspdiseinfo.DiagName = item.CountryContentName
  977. tempOpspdiseinfo.MaindiagFlag = "1"
  978. tempOpspdiseinfo.OprnOprtCode = ""
  979. tempOpspdiseinfo.OprnOprtName = ""
  980. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  981. }
  982. sickConfigTwo, _ := service.FindSickById(his.SickType)
  983. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  984. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  985. tempOpspdiseinfo2.MaindiagFlag = "2"
  986. tempOpspdiseinfo2.OprnOprtCode = ""
  987. tempOpspdiseinfo2.OprnOprtName = ""
  988. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  989. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  990. var iteminfo service.IteminfoStruct
  991. var bedCostTotal float64 = 0 //床位总费
  992. var bedCostSelfTotal float64 = 0 //床位自费
  993. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  994. var examineCostTotal float64 = 0 //诊查总费
  995. var examineCostSelfTotal float64 = 0 //诊查自费
  996. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  997. var nursingCostTotal float64 = 0 //护理总费
  998. var nursingCostSelfTotal float64 = 0 //护理自费
  999. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1000. var chineseMedicineCostTotal float64 = 0 //中成药
  1001. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1002. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1003. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1004. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1005. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1006. var registerCostTotal float64 = 0 //一般诊疗费
  1007. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1008. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1009. var operationCostTotal float64 = 0 //手术费
  1010. var operationCostSelfTotal float64 = 0 //手术费
  1011. var operationCostPartSelfTotal float64 = 0 //手术费
  1012. var otherCostTotal float64 = 0 //其他费用
  1013. var otherCostSelfTotal float64 = 0 //其他费用
  1014. var otherCostPartSelfTotal float64 = 0 //其他费用
  1015. var materialCostTotal float64 = 0 //材料费
  1016. var materialCostSelfTotal float64 = 0 //材料费
  1017. var materialCostPartSelfTotal float64 = 0 //材料费
  1018. var westernMedicineCostTotal float64 = 0 //西药费
  1019. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1020. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1021. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1022. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1023. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1024. var checkCostTotal float64 = 0 //检查费
  1025. var checkCostSelfTotal float64 = 0 //检查费
  1026. var checkCostPartSelfTotal float64 = 0 //检查费
  1027. var laboratoryCostTotal float64 = 0 //化验费
  1028. var laboratoryCostSelfTotal float64 = 0 //化验费
  1029. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1030. var treatCostTotal float64 = 0 //治疗费用
  1031. var treatCostSelfTotal float64 = 0 //治疗费用
  1032. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1033. decimal.DivisionPrecision = 2
  1034. var bed_fulamt_ownpay_amt float64 = 0
  1035. var examine_fulamt_ownpay_amt float64 = 0
  1036. var nursing_fulamt_ownpay_amt float64 = 0
  1037. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1038. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1039. var register_fulamt_ownpay_amt float64 = 0
  1040. var operation_fulamt_ownpay_amt float64 = 0
  1041. var other_fulamt_ownpay_amt float64 = 0
  1042. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1043. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1044. var check_fulamt_ownpay_amt float64 = 0
  1045. var material_fulamt_ownpay_amt float64 = 0
  1046. var laboratory_fulamt_ownpay_amt float64 = 0
  1047. var treat_fulamt_ownpay_amt float64 = 0
  1048. var bed_claa_sunmfee float64 = 0
  1049. var bed_clab_amt float64 = 0
  1050. var bed_other_amt float64 = 0
  1051. var examine_claa_sunmfee float64 = 0
  1052. var examine_clab_amt float64 = 0
  1053. var examine_other_amt float64 = 0
  1054. var nursing_claa_sunmfee float64 = 0
  1055. var nursing_clab_amt float64 = 0
  1056. var nursing_other_amt float64 = 0
  1057. var chinese_medicine_claa_sunmfee float64 = 0
  1058. var chinese_medicine_clab_amt float64 = 0
  1059. var chinese_medicine_other_amt float64 = 0
  1060. var commonly_treatment_claa_sunmfee float64 = 0
  1061. var commonly_treatment_clab_amt float64 = 0
  1062. var commonly_treatment_other_amt float64 = 0
  1063. var operation_claa_sunmfee float64 = 0
  1064. var operation_clab_amt float64 = 0
  1065. var operation_other_amt float64 = 0
  1066. var other_claa_sunmfee float64 = 0
  1067. var other_clab_amt float64 = 0
  1068. var other_other_amt float64 = 0
  1069. var westernMedicine_claa_sunmfee float64 = 0
  1070. var westernMedicine_clab_amt float64 = 0
  1071. var westernMedicine_other_amt float64 = 0
  1072. var chineseTraditional_claa_sunmfee float64 = 0
  1073. var chineseTraditional_clab_amt float64 = 0
  1074. var chineseTraditional_other_amt float64 = 0
  1075. var check_claa_sunmfee float64 = 0
  1076. var check_clab_amt float64 = 0
  1077. var check_other_amt float64 = 0
  1078. var material_claa_sunmfee float64 = 0
  1079. var material_clab_amt float64 = 0
  1080. var material_other_amt float64 = 0
  1081. var laboratory_claa_sunmfee float64 = 0
  1082. var laboratory_clab_amt float64 = 0
  1083. var laboratory_other_amt float64 = 0
  1084. var treat_claa_sunmfee float64 = 0
  1085. var treat_clab_amt float64 = 0
  1086. var treat_other_amt float64 = 0
  1087. var register_claa_sunmfee float64 = 0
  1088. var register_clab_amt float64 = 0
  1089. var register_other_amt float64 = 0
  1090. for _, item := range order.HisOrderInfo {
  1091. if item.MedChrgitmType == "01" { //床位费
  1092. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1093. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1094. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1095. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1096. if item.ChrgitmLv == "1" {
  1097. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1098. }
  1099. if item.ChrgitmLv == "2" {
  1100. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1101. }
  1102. if item.ChrgitmLv == "3" {
  1103. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1104. }
  1105. }
  1106. if item.MedChrgitmType == "02" { //诊查
  1107. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1108. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1109. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1110. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1111. if item.ChrgitmLv == "1" {
  1112. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1113. }
  1114. if item.ChrgitmLv == "2" {
  1115. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1116. }
  1117. if item.ChrgitmLv == "3" {
  1118. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1119. }
  1120. }
  1121. if item.MedChrgitmType == "03" { //检查费
  1122. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1123. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1124. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1125. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1126. if item.ChrgitmLv == "1" {
  1127. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1128. }
  1129. if item.ChrgitmLv == "2" {
  1130. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1131. }
  1132. if item.ChrgitmLv == "3" {
  1133. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1134. }
  1135. }
  1136. if item.MedChrgitmType == "04" { //化验费
  1137. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1138. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1139. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1140. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1141. if item.ChrgitmLv == "1" {
  1142. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1143. }
  1144. if item.ChrgitmLv == "2" {
  1145. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1146. }
  1147. if item.ChrgitmLv == "3" {
  1148. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1149. }
  1150. }
  1151. if item.MedChrgitmType == "05" { //治疗费
  1152. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1153. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1154. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1155. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1156. if item.ChrgitmLv == "1" {
  1157. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1158. }
  1159. if item.ChrgitmLv == "2" {
  1160. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1161. }
  1162. if item.ChrgitmLv == "3" {
  1163. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1164. }
  1165. }
  1166. if item.MedChrgitmType == "06" { //手术费
  1167. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1168. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1169. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1170. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1171. if item.ChrgitmLv == "1" {
  1172. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1173. }
  1174. if item.ChrgitmLv == "2" {
  1175. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1176. }
  1177. if item.ChrgitmLv == "3" {
  1178. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1179. }
  1180. }
  1181. if item.MedChrgitmType == "07" { //手术费
  1182. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1183. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1184. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1185. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1186. if item.ChrgitmLv == "1" {
  1187. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1188. }
  1189. if item.ChrgitmLv == "2" {
  1190. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1191. }
  1192. if item.ChrgitmLv == "3" {
  1193. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1194. }
  1195. }
  1196. if item.MedChrgitmType == "08" { //材料费
  1197. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1198. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1199. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1200. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1201. if item.ChrgitmLv == "1" {
  1202. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1203. }
  1204. if item.ChrgitmLv == "2" {
  1205. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1206. }
  1207. if item.ChrgitmLv == "3" {
  1208. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1209. }
  1210. }
  1211. if item.MedChrgitmType == "09" { //西药费
  1212. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1213. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1214. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1215. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1216. if item.ChrgitmLv == "1" {
  1217. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1218. }
  1219. if item.ChrgitmLv == "2" {
  1220. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1221. }
  1222. if item.ChrgitmLv == "3" {
  1223. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1224. }
  1225. }
  1226. if item.MedChrgitmType == "10" { //中药饮片
  1227. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1228. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1229. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1230. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1231. if item.ChrgitmLv == "1" {
  1232. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1233. }
  1234. if item.ChrgitmLv == "2" {
  1235. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1236. }
  1237. if item.ChrgitmLv == "3" {
  1238. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1239. }
  1240. }
  1241. if item.MedChrgitmType == "11" { //中成费
  1242. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1243. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1244. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1245. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1246. if item.ChrgitmLv == "1" {
  1247. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1248. }
  1249. if item.ChrgitmLv == "2" {
  1250. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1251. }
  1252. if item.ChrgitmLv == "3" {
  1253. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1254. }
  1255. }
  1256. if item.MedChrgitmType == "12" { //中成费
  1257. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1258. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1259. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1260. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1261. if item.ChrgitmLv == "1" {
  1262. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1263. }
  1264. if item.ChrgitmLv == "2" {
  1265. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1266. }
  1267. if item.ChrgitmLv == "3" {
  1268. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1269. }
  1270. }
  1271. if item.MedChrgitmType == "13" { //中成费
  1272. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1273. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1274. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1275. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1276. if item.ChrgitmLv == "1" {
  1277. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1278. }
  1279. if item.ChrgitmLv == "2" {
  1280. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1281. }
  1282. if item.ChrgitmLv == "3" {
  1283. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1284. }
  1285. }
  1286. if item.MedChrgitmType == "14" { //其他费
  1287. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1288. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1289. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1290. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1291. if item.ChrgitmLv == "1" {
  1292. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1293. }
  1294. if item.ChrgitmLv == "2" {
  1295. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1296. }
  1297. if item.ChrgitmLv == "3" {
  1298. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1299. }
  1300. }
  1301. }
  1302. var iteminfoStructs []service.IteminfoStruct
  1303. if bedCostTotal != 0 {
  1304. iteminfo.MedChrgitm = "01"
  1305. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1306. iteminfo.Amt = bedCostTotal
  1307. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1308. iteminfo.ClabAmt = bed_clab_amt
  1309. iteminfo.OthAmt = bed_other_amt
  1310. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1311. }
  1312. if examineCostTotal != 0 {
  1313. iteminfo.MedChrgitm = "02"
  1314. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1315. iteminfo.Amt = examineCostTotal
  1316. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1317. iteminfo.ClabAmt = examine_clab_amt
  1318. iteminfo.OthAmt = examine_other_amt
  1319. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1320. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1321. }
  1322. if checkCostTotal != 0 {
  1323. iteminfo.MedChrgitm = "03"
  1324. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1325. iteminfo.Amt = checkCostTotal
  1326. iteminfo.ClaaSumfee = check_claa_sunmfee
  1327. iteminfo.ClabAmt = check_clab_amt
  1328. iteminfo.OthAmt = check_other_amt
  1329. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1330. }
  1331. if laboratoryCostTotal != 0 {
  1332. iteminfo.MedChrgitm = "04"
  1333. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1334. iteminfo.Amt = laboratoryCostTotal
  1335. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1336. iteminfo.ClabAmt = laboratory_clab_amt
  1337. iteminfo.OthAmt = laboratory_other_amt
  1338. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1339. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1340. }
  1341. if treatCostTotal != 0 {
  1342. iteminfo.MedChrgitm = "05"
  1343. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1344. iteminfo.Amt = treatCostTotal
  1345. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1346. iteminfo.ClabAmt = treat_clab_amt
  1347. iteminfo.OthAmt = treat_other_amt
  1348. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1349. //(struct4101.IteminfoStruct, iteminfo)
  1350. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1351. }
  1352. if operationCostTotal != 0 {
  1353. iteminfo.MedChrgitm = "06"
  1354. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1355. iteminfo.Amt = operationCostTotal
  1356. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1357. iteminfo.ClabAmt = operation_clab_amt
  1358. iteminfo.OthAmt = operation_other_amt
  1359. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1360. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1361. }
  1362. if nursingCostTotal != 0 {
  1363. iteminfo.MedChrgitm = "07"
  1364. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  1365. iteminfo.Amt = nursingCostTotal
  1366. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  1367. iteminfo.ClabAmt = nursing_clab_amt
  1368. iteminfo.OthAmt = nursing_other_amt
  1369. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1370. }
  1371. if materialCostTotal != 0 {
  1372. iteminfo.MedChrgitm = "08"
  1373. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1374. iteminfo.Amt = materialCostTotal
  1375. iteminfo.ClaaSumfee = material_claa_sunmfee
  1376. iteminfo.ClabAmt = material_clab_amt
  1377. iteminfo.OthAmt = material_other_amt
  1378. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1379. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1380. }
  1381. if westernMedicineCostTotal != 0 {
  1382. iteminfo.MedChrgitm = "09"
  1383. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1384. iteminfo.Amt = westernMedicineCostTotal
  1385. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1386. iteminfo.ClabAmt = westernMedicine_clab_amt
  1387. iteminfo.OthAmt = westernMedicine_other_amt
  1388. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1389. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1390. }
  1391. if chineseMedicineCostTotal != 0 {
  1392. iteminfo.MedChrgitm = "10"
  1393. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  1394. iteminfo.Amt = chineseMedicineCostTotal
  1395. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  1396. iteminfo.ClabAmt = chinese_medicine_clab_amt
  1397. iteminfo.OthAmt = chinese_medicine_other_amt
  1398. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1399. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1400. }
  1401. if chineseTraditionalMedicineCostTotal != 0 {
  1402. iteminfo.MedChrgitm = "11"
  1403. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1404. iteminfo.Amt = westernMedicineCostTotal
  1405. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1406. iteminfo.ClabAmt = westernMedicine_clab_amt
  1407. iteminfo.OthAmt = westernMedicine_other_amt
  1408. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1409. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1410. }
  1411. if commonlyTreatmentCostTotal != 0 {
  1412. iteminfo.MedChrgitm = "12"
  1413. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  1414. iteminfo.Amt = commonlyTreatmentCostTotal
  1415. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  1416. iteminfo.ClabAmt = commonly_treatment_clab_amt
  1417. iteminfo.OthAmt = commonly_treatment_other_amt
  1418. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1419. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1420. }
  1421. if registerCostTotal != 0 {
  1422. iteminfo.MedChrgitm = "13"
  1423. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  1424. iteminfo.Amt = registerCostTotal
  1425. iteminfo.ClaaSumfee = register_claa_sunmfee
  1426. iteminfo.ClabAmt = register_clab_amt
  1427. iteminfo.OthAmt = register_other_amt
  1428. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1429. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1430. }
  1431. if otherCostTotal != 0 {
  1432. iteminfo.MedChrgitm = "14"
  1433. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1434. iteminfo.Amt = otherCostTotal
  1435. iteminfo.ClaaSumfee = other_claa_sunmfee
  1436. iteminfo.ClabAmt = other_clab_amt
  1437. iteminfo.OthAmt = other_other_amt
  1438. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1439. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1440. }
  1441. struct4101.IteminfoStruct = iteminfoStructs
  1442. struct4101.Ntly = "中国"
  1443. struct4101.AdmCaty = "A03.06"
  1444. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, org_id)
  1445. fmt.Println(result)
  1446. var dat map[string]interface{}
  1447. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1448. fmt.Println(dat)
  1449. } else {
  1450. fmt.Println(err)
  1451. }
  1452. userJSONBytes, _ := json.Marshal(dat)
  1453. var res ResultSeventeen
  1454. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1455. utils.ErrorLog("解析失败:%v", err)
  1456. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1457. adminUser := c.GetAdminUserInfo()
  1458. errlog := &models.HisOrderError{
  1459. UserOrgId: adminUser.CurrentOrgId,
  1460. Ctime: time.Now().Unix(),
  1461. Mtime: time.Now().Unix(),
  1462. ErrMsg: res.ErrMsg + "解析失败",
  1463. Status: 1,
  1464. PatientId: order_id,
  1465. Stage: 120,
  1466. }
  1467. service.CreateErrMsgLog(errlog)
  1468. continue
  1469. }
  1470. if res.Infcode != 0 {
  1471. adminUser := c.GetAdminUserInfo()
  1472. errlog := &models.HisOrderError{
  1473. UserOrgId: adminUser.CurrentOrgId,
  1474. Ctime: time.Now().Unix(),
  1475. Mtime: time.Now().Unix(),
  1476. ErrMsg: res.ErrMsg,
  1477. Status: 1,
  1478. PatientId: order_id,
  1479. Stage: 200,
  1480. }
  1481. service.CreateErrMsgLog(errlog)
  1482. continue
  1483. } else {
  1484. hisFundSettleListResult := &models.HisFundSettleListResult{
  1485. Number: res.Output.SetlListId,
  1486. Status: 1,
  1487. Ctime: time.Now().Unix(),
  1488. Mtime: time.Now().Unix(),
  1489. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1490. IsUpload: 1,
  1491. OrderId: order_id,
  1492. }
  1493. service.CreateUploadRecord(hisFundSettleListResult)
  1494. continue
  1495. }
  1496. }
  1497. }
  1498. func (c *HisApiController) GetOrgInfo() {
  1499. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  1500. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  1501. }
  1502. func (c *HisApiController) GetHisPatientInfo() {
  1503. medical_insurance_card := c.GetString("medical_insurance_card")
  1504. id_card_type, _ := c.GetInt64("id_card_type")
  1505. id_card := c.GetString("id_card")
  1506. adminInfo := c.GetAdminUserInfo()
  1507. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  1508. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1509. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  1510. IdCardNo := ""
  1511. if id_card_type == 1 {
  1512. IdCardNo = medical_insurance_card
  1513. } else if id_card_type == 2 {
  1514. IdCardNo = id_card
  1515. }
  1516. if config.IsOpen == 1 {
  1517. 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
  1518. resp, requestErr := http.Get(api)
  1519. if requestErr != nil {
  1520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1521. return
  1522. }
  1523. defer resp.Body.Close()
  1524. body, ioErr := ioutil.ReadAll(resp.Body)
  1525. if ioErr != nil {
  1526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1528. return
  1529. }
  1530. var respJSON map[string]interface{}
  1531. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1534. return
  1535. }
  1536. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1537. userJSONBytes, _ := json.Marshal(userJSON)
  1538. var res ResultTwo
  1539. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1540. utils.ErrorLog("解析失败:%v", err)
  1541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1542. return
  1543. }
  1544. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1545. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1546. infoStr := string(Iinfos)
  1547. idetinfoStr := string(Idetinfos)
  1548. if res.Infcode == 0 {
  1549. his := models.VMHisPatient{
  1550. Status: 1,
  1551. Ctime: time.Now().Unix(),
  1552. Mtime: time.Now().Unix(),
  1553. PsnNo: res.Output.Baseinfo.PsnNo,
  1554. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1555. Certno: res.Output.Baseinfo.Certno,
  1556. PsnName: res.Output.Baseinfo.PsnName,
  1557. Gend: res.Output.Baseinfo.Gend,
  1558. Naty: res.Output.Baseinfo.Naty,
  1559. Brdy: res.Output.Baseinfo.Brdy,
  1560. Age: res.Output.Baseinfo.Age,
  1561. Iinfo: infoStr,
  1562. Idetinfo: idetinfoStr,
  1563. UserOrgId: adminInfo.CurrentOrgId,
  1564. IsReturn: 1,
  1565. IdCardType: id_card_type,
  1566. }
  1567. c.ServeSuccessJSON(map[string]interface{}{
  1568. "info": his,
  1569. })
  1570. } else {
  1571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1572. return
  1573. }
  1574. }
  1575. }
  1576. //func GetBasBaseInfo() (jsonStr string, err error) {
  1577. //
  1578. // handle := syscall.NewLazyDLL("SSCard.dll")
  1579. // add := handle.NewProc("ReadCardBas")
  1580. // str := make([]byte, 1024)
  1581. // str1 := make([]byte, 1024)
  1582. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1583. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  1584. //
  1585. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  1586. //
  1587. // fmt.Println("> Add(4,5)的结果为:", ret)
  1588. // handle.Release()
  1589. //
  1590. // return "", nil
  1591. //
  1592. //}
  1593. //func GetQRBaseInfo() (jsonStr string, err error) {
  1594. // handle := syscall.LoadDLL("SSCard.dll")
  1595. // ReadCardBas := handle.FindProc("GetQRBase")
  1596. //
  1597. // str := make([]byte, 256)
  1598. // str1 := make([]byte, 256)
  1599. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1600. //
  1601. // fmt.Println(string(str))
  1602. // fmt.Println(r)
  1603. // return string(str), nil
  1604. //}
  1605. //func CardInit() int {
  1606. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  1607. // add := DllTestDef.MustFindProc("Init")
  1608. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1609. // if err != nil {
  1610. // fmt.Println("SSCard的运算结果为:", ret)
  1611. // }
  1612. // result := int(ret)
  1613. // return result
  1614. //}
  1615. //func CardInit() int {
  1616. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1617. // if err != nil {
  1618. // fmt.Println("SSCard的运算结果为:", ret)
  1619. // }
  1620. // fmt.Println(err)
  1621. // result := int(ret)
  1622. // return result
  1623. //}
  1624. func IntPtr(n int) uintptr {
  1625. return uintptr(n)
  1626. }
  1627. func StrPtr(s string) uintptr {
  1628. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  1629. }
  1630. type Result2001 struct {
  1631. Cainfo interface{} `json:"cainfo"`
  1632. ErrMsg string `json:"err_msg"`
  1633. InfRefmsgid string `json:"inf_refmsgid"`
  1634. Infcode int64 `json:"infcode"`
  1635. Output struct {
  1636. Trtinfo struct {
  1637. PsnNo string `json:"psn_no"`
  1638. TrtChkType string `json:"trt_chk_type"`
  1639. FundPayType string `json:"fund_pay_type"`
  1640. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  1641. Begndate string `json:"begndate"`
  1642. Enddate string `json:"enddate"`
  1643. TrtChkRslt string `json:"trt_chk_rslt"`
  1644. } `json:"trtinfo"`
  1645. } `json:"output"`
  1646. RefmsgTime string `json:"refmsg_time"`
  1647. RespondTime string `json:"respond_time"`
  1648. Signtype interface{} `json:"signtype"`
  1649. WarnMsg interface{} `json:"warn_msg"`
  1650. }
  1651. type Result2001Org10265 struct {
  1652. Cainfo interface{} `json:"cainfo"`
  1653. ErrMsg string `json:"err_msg"`
  1654. InfRefmsgid string `json:"inf_refmsgid"`
  1655. Infcode string `json:"infcode"`
  1656. Output struct {
  1657. Trtinfo struct {
  1658. PsnNo string `json:"psn_no"`
  1659. TrtChkType string `json:"trt_chk_type"`
  1660. FundPayType string `json:"fund_pay_type"`
  1661. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  1662. Begndate string `json:"begndate"`
  1663. Enddate string `json:"enddate"`
  1664. TrtChkRslt string `json:"trt_chk_rslt"`
  1665. } `json:"trtinfo"`
  1666. } `json:"output"`
  1667. RefmsgTime string `json:"refmsg_time"`
  1668. RespondTime string `json:"respond_time"`
  1669. Signtype interface{} `json:"signtype"`
  1670. WarnMsg interface{} `json:"warn_msg"`
  1671. }
  1672. type ResultTwo struct {
  1673. ErrMsg string `json:"err_msg"`
  1674. InfRefmsgid string `json:"inf_refmsgid"`
  1675. Infcode int64 `json:"infcode"`
  1676. Output struct {
  1677. Baseinfo struct {
  1678. Age float64 `json:"age"`
  1679. Brdy string `json:"brdy"`
  1680. Certno string `json:"certno"`
  1681. Gend string `json:"gend"`
  1682. Naty string `json:"naty"`
  1683. PsnCertType string `json:"psn_cert_type"`
  1684. PsnName string `json:"psn_name"`
  1685. PsnNo string `json:"psn_no"`
  1686. } `json:"baseinfo"`
  1687. Idetinfo []interface{} `json:"idetinfo"`
  1688. Iinfo []struct {
  1689. Balc float64 `json:"balc"`
  1690. CvlservFlag string `json:"cvlserv_flag"`
  1691. EmpName string `json:"emp_name"`
  1692. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1693. Insutype string `json:"insutype"`
  1694. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1695. PausInsuDate string `json:"paus_insu_date"`
  1696. PsnInsuDate string `json:"psn_insu_date"`
  1697. PsnInsuStas string `json:"psn_insu_stas"`
  1698. PsnType string `json:"psn_type"`
  1699. } `json:"insuinfo"`
  1700. } `json:"output"`
  1701. RefmsgTime string `json:"refmsg_time"`
  1702. RespondTime string `json:"respond_time"`
  1703. Signtype interface{} `json:"signtype"`
  1704. WarnInfo interface{} `json:"warn_info"`
  1705. }
  1706. type ResultTwo10265 struct {
  1707. ErrMsg string `json:"err_msg"`
  1708. InfRefmsgid string `json:"inf_refmsgid"`
  1709. Infcode string `json:"infcode"`
  1710. Output struct {
  1711. Baseinfo struct {
  1712. Age float64 `json:"age"`
  1713. Brdy string `json:"brdy"`
  1714. Certno string `json:"certno"`
  1715. Gend string `json:"gend"`
  1716. Naty string `json:"naty"`
  1717. PsnCertType string `json:"psn_cert_type"`
  1718. PsnName string `json:"psn_name"`
  1719. PsnNo string `json:"psn_no"`
  1720. } `json:"baseinfo"`
  1721. Idetinfo []interface{} `json:"idetinfo"`
  1722. Iinfo []struct {
  1723. Balc float64 `json:"balc"`
  1724. CvlservFlag string `json:"cvlserv_flag"`
  1725. EmpName string `json:"emp_name"`
  1726. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1727. Insutype string `json:"insutype"`
  1728. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1729. PausInsuDate string `json:"paus_insu_date"`
  1730. PsnInsuDate string `json:"psn_insu_date"`
  1731. PsnInsuStas string `json:"psn_insu_stas"`
  1732. PsnType string `json:"psn_type"`
  1733. } `json:"insuinfo"`
  1734. } `json:"output"`
  1735. RefmsgTime string `json:"refmsg_time"`
  1736. RespondTime string `json:"respond_time"`
  1737. Signtype interface{} `json:"signtype"`
  1738. WarnInfo interface{} `json:"warn_info"`
  1739. }
  1740. type ResultThree struct {
  1741. Cainfo interface{} `json:"cainfo"`
  1742. ErrMsg string `json:"err_msg"`
  1743. InfRefmsgid string `json:"inf_refmsgid"`
  1744. Infcode int64 `json:"infcode"`
  1745. Output struct {
  1746. Data struct {
  1747. IptOtpNo string `json:"ipt_otp_no"`
  1748. MdtrtID string `json:"mdtrt_id"`
  1749. PsnNo string `json:"psn_no"`
  1750. } `json:"data"`
  1751. } `json:"output"`
  1752. RefmsgTime string `json:"refmsg_time"`
  1753. RespondTime string `json:"respond_time"`
  1754. Signtype interface{} `json:"signtype"`
  1755. WarnMsg interface{} `json:"warn_msg"`
  1756. }
  1757. type ResultThree10265 struct {
  1758. Cainfo interface{} `json:"cainfo"`
  1759. ErrMsg string `json:"err_msg"`
  1760. InfRefmsgid string `json:"inf_refmsgid"`
  1761. Infcode string `json:"infcode"`
  1762. Output struct {
  1763. Data struct {
  1764. IptOtpNo string `json:"ipt_otp_no"`
  1765. MdtrtID string `json:"mdtrt_id"`
  1766. PsnNo string `json:"psn_no"`
  1767. } `json:"data"`
  1768. } `json:"output"`
  1769. RefmsgTime string `json:"refmsg_time"`
  1770. RespondTime string `json:"respond_time"`
  1771. Signtype interface{} `json:"signtype"`
  1772. WarnMsg interface{} `json:"warn_msg"`
  1773. }
  1774. type ResultFour struct {
  1775. Cainfo string `json:"cainfo"`
  1776. ErrMsg string `json:"err_msg"`
  1777. InfRefmsgid string `json:"inf_refmsgid"`
  1778. Infcode int64 `json:"infcode"`
  1779. Output struct {
  1780. Result []struct {
  1781. BasMednFlag string `json:"bas_medn_flag"`
  1782. ChldMedcFlag string `json:"chld_medc_flag"`
  1783. ChrgitmLv string `json:"chrgitm_lv"`
  1784. Cnt float64 `json:"cnt"`
  1785. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1786. DrtReimFlag string `json:"drt_reim_flag"`
  1787. FeedetlSn string `json:"feedetl_sn"`
  1788. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1789. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1790. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1791. ListSpItemFlag string `json:"list_sp_item_flag"`
  1792. LmtUsedFlag string `json:"lmt_used_flag"`
  1793. MedChrgitmType string `json:"med_chrgitm_type"`
  1794. Memo string `json:"memo"`
  1795. OverlmtAmt float64 `json:"overlmt_amt"`
  1796. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1797. Pric float64 `json:"pric"`
  1798. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1799. SelfpayProp float64 `json:"selfpay_prop"`
  1800. } `json:"result"`
  1801. } `json:"output"`
  1802. RefmsgTime string `json:"refmsg_time"`
  1803. RespondTime string `json:"respond_time"`
  1804. Signtype string `json:"signtype"`
  1805. WarnMsg string `json:"warn_msg"`
  1806. }
  1807. type ResultFour10265 struct {
  1808. Cainfo string `json:"cainfo"`
  1809. ErrMsg string `json:"err_msg"`
  1810. InfRefmsgid string `json:"inf_refmsgid"`
  1811. Infcode string `json:"infcode"`
  1812. Output struct {
  1813. Result []struct {
  1814. BasMednFlag string `json:"bas_medn_flag"`
  1815. ChldMedcFlag string `json:"chld_medc_flag"`
  1816. ChrgitmLv string `json:"chrgitm_lv"`
  1817. Cnt float64 `json:"cnt"`
  1818. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1819. DrtReimFlag string `json:"drt_reim_flag"`
  1820. FeedetlSn string `json:"feedetl_sn"`
  1821. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1822. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1823. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1824. ListSpItemFlag string `json:"list_sp_item_flag"`
  1825. LmtUsedFlag string `json:"lmt_used_flag"`
  1826. MedChrgitmType string `json:"med_chrgitm_type"`
  1827. Memo string `json:"memo"`
  1828. OverlmtAmt float64 `json:"overlmt_amt"`
  1829. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1830. Pric float64 `json:"pric"`
  1831. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1832. SelfpayProp float64 `json:"selfpay_prop"`
  1833. } `json:"result"`
  1834. } `json:"output"`
  1835. RefmsgTime string `json:"refmsg_time"`
  1836. RespondTime string `json:"respond_time"`
  1837. Signtype string `json:"signtype"`
  1838. WarnMsg string `json:"warn_msg"`
  1839. }
  1840. type ResultFive struct {
  1841. Balc float64 `json:"balc"`
  1842. CvlservFlag string `json:"cvlserv_flag"`
  1843. EmpName string `json:"emp_name"`
  1844. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1845. Insutype string `json:"insutype"`
  1846. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1847. PausInsuDate string `json:"paus_insu_date"`
  1848. PsnInsuDate string `json:"psn_insu_date"`
  1849. PsnInsuStas string `json:"psn_insu_stas"`
  1850. PsnType string `json:"psn_type"`
  1851. }
  1852. type ResultSix struct {
  1853. Cainfo interface{} `json:"cainfo"`
  1854. ErrMsg string `json:"err_msg"`
  1855. InfRefmsgid string `json:"inf_refmsgid"`
  1856. Infcode int64 `json:"infcode"`
  1857. Output struct {
  1858. } `json:"output"`
  1859. RefmsgTime string `json:"refmsg_time"`
  1860. RespondTime string `json:"respond_time"`
  1861. Signtype interface{} `json:"signtype"`
  1862. WarnMsg interface{} `json:"warn_msg"`
  1863. }
  1864. type ResultSix10265 struct {
  1865. Cainfo interface{} `json:"cainfo"`
  1866. ErrMsg string `json:"err_msg"`
  1867. InfRefmsgid string `json:"inf_refmsgid"`
  1868. Infcode string `json:"infcode"`
  1869. Output struct {
  1870. } `json:"output"`
  1871. RefmsgTime string `json:"refmsg_time"`
  1872. RespondTime string `json:"respond_time"`
  1873. Signtype interface{} `json:"signtype"`
  1874. WarnMsg interface{} `json:"warn_msg"`
  1875. }
  1876. type ResultSeven struct {
  1877. Cainfo string `json:"cainfo"`
  1878. ErrMsg string `json:"err_msg"`
  1879. InfRefmsgid string `json:"inf_refmsgid"`
  1880. Infcode int64 `json:"infcode"`
  1881. Output struct {
  1882. Setldetail []interface{} `json:"setldetail"`
  1883. Setlinfo struct {
  1884. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1885. AcctPay float64 `json:"acct_pay"`
  1886. ActPayDedc float64 `json:"act_pay_dedc"`
  1887. Age float64 `json:"age"`
  1888. Balc float64 `json:"balc"`
  1889. Brdy string `json:"brdy"`
  1890. Certno string `json:"certno"`
  1891. ClrOptins string `json:"clr_optins"`
  1892. ClrType string `json:"clr_type"`
  1893. ClrWay string `json:"clr_way"`
  1894. CvlservFlag string `json:"cvlserv_flag"`
  1895. CvlservPay float64 `json:"cvlserv_pay"`
  1896. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1897. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1898. Gend string `json:"gend"`
  1899. HifesPay float64 `json:"hifes_pay"`
  1900. HifmiPay float64 `json:"hifmi_pay"`
  1901. HifpPay float64 `json:"hifp_pay"`
  1902. HospPartAmt float64 `json:"hosp_part_amt"`
  1903. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1904. Insutype string `json:"insutype"`
  1905. MafPay float64 `json:"maf_pay"`
  1906. MdtrtCertType string `json:"mdtrt_cert_type"`
  1907. HifobPay float64 `json:"hifob_pay"`
  1908. MdtrtID string `json:"mdtrt_id"`
  1909. MedType string `json:"med_type"`
  1910. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1911. MedinsSetlID string `json:"medins_setl_id"`
  1912. Naty string `json:"naty"`
  1913. OthPay float64 `json:"oth_pay"`
  1914. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1915. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1916. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1917. PsnCashPay float64 `json:"psn_cash_pay"`
  1918. PsnCertType string `json:"psn_cert_type"`
  1919. PsnName string `json:"psn_name"`
  1920. PsnNo string `json:"psn_no"`
  1921. PsnPartAmt float64 `json:"psn_part_amt"`
  1922. PsnType string `json:"psn_type"`
  1923. SetlID string `json:"setl_id"`
  1924. SetlTime string `json:"setl_time"`
  1925. } `json:"setlinfo"`
  1926. } `json:"output"`
  1927. RefmsgTime string `json:"refmsg_time"`
  1928. RespondTime string `json:"respond_time"`
  1929. Signtype interface{} `json:"signtype"`
  1930. WarnMsg interface{} `json:"warn_msg"`
  1931. }
  1932. type ResultSeven10265 struct {
  1933. Cainfo string `json:"cainfo"`
  1934. ErrMsg string `json:"err_msg"`
  1935. InfRefmsgid string `json:"inf_refmsgid"`
  1936. Infcode string `json:"infcode"`
  1937. Output struct {
  1938. Setldetail []interface{} `json:"setldetail"`
  1939. Setlinfo struct {
  1940. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1941. AcctPay float64 `json:"acct_pay"`
  1942. ActPayDedc float64 `json:"act_pay_dedc"`
  1943. Age float64 `json:"age"`
  1944. Balc float64 `json:"balc"`
  1945. Brdy string `json:"brdy"`
  1946. Certno string `json:"certno"`
  1947. ClrOptins string `json:"clr_optins"`
  1948. ClrType string `json:"clr_type"`
  1949. ClrWay string `json:"clr_way"`
  1950. CvlservFlag string `json:"cvlserv_flag"`
  1951. CvlservPay float64 `json:"cvlserv_pay"`
  1952. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1953. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1954. Gend string `json:"gend"`
  1955. HifesPay float64 `json:"hifes_pay"`
  1956. HifmiPay float64 `json:"hifmi_pay"`
  1957. HifpPay float64 `json:"hifp_pay"`
  1958. HospPartAmt float64 `json:"hosp_part_amt"`
  1959. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1960. Insutype string `json:"insutype"`
  1961. MafPay float64 `json:"maf_pay"`
  1962. MdtrtCertType string `json:"mdtrt_cert_type"`
  1963. HifobPay float64 `json:"hifob_pay"`
  1964. MdtrtID string `json:"mdtrt_id"`
  1965. MedType string `json:"med_type"`
  1966. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1967. MedinsSetlID string `json:"medins_setl_id"`
  1968. Naty string `json:"naty"`
  1969. OthPay float64 `json:"oth_pay"`
  1970. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1971. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1972. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1973. PsnCashPay float64 `json:"psn_cash_pay"`
  1974. PsnCertType string `json:"psn_cert_type"`
  1975. PsnName string `json:"psn_name"`
  1976. PsnNo string `json:"psn_no"`
  1977. PsnPartAmt float64 `json:"psn_part_amt"`
  1978. PsnType string `json:"psn_type"`
  1979. SetlID string `json:"setl_id"`
  1980. SetlTime string `json:"setl_time"`
  1981. } `json:"setlinfo"`
  1982. } `json:"output"`
  1983. RefmsgTime string `json:"refmsg_time"`
  1984. RespondTime string `json:"respond_time"`
  1985. Signtype interface{} `json:"signtype"`
  1986. WarnMsg interface{} `json:"warn_msg"`
  1987. }
  1988. type ResultEight struct {
  1989. Cainfo string `json:"cainfo"`
  1990. ErrMsg string `json:"err_msg"`
  1991. InfRefmsgid string `json:"inf_refmsgid"`
  1992. Infcode int64 `json:"infcode"`
  1993. Output struct {
  1994. Stmtinfo struct {
  1995. SetlOptins string `json:"setl_optins"`
  1996. StmtRslt string `json:"stmt_rslt"`
  1997. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  1998. } `json:"stmtinfo"`
  1999. } `json:"output"`
  2000. RefmsgTime string `json:"refmsg_time"`
  2001. RespondTime string `json:"respond_time"`
  2002. Signtype interface{} `json:"signtype"`
  2003. WarnMsg interface{} `json:"warn_msg"`
  2004. }
  2005. type ResultNine struct {
  2006. Cainfo string `json:"cainfo"`
  2007. ErrMsg string `json:"err_msg"`
  2008. InfRefmsgid string `json:"inf_refmsgid"`
  2009. Infcode int64 `json:"infcode"`
  2010. Output struct {
  2011. FileQuryNo string `json:"file_qury_no"`
  2012. } `json:"output"`
  2013. RefmsgTime string `json:"refmsg_time"`
  2014. RespondTime string `json:"respond_time"`
  2015. Signtype interface{} `json:"signtype"`
  2016. WarnMsg interface{} `json:"warn_msg"`
  2017. }
  2018. type ResultTen struct {
  2019. Cainfo string `json:"cainfo"`
  2020. ErrMsg string `json:"err_msg"`
  2021. InfRefmsgid string `json:"inf_refmsgid"`
  2022. Infcode int64 `json:"infcode"`
  2023. Output struct {
  2024. DldEndtime string `json:"dld_endtime"`
  2025. FileQuryNo string `json:"file_qury_no"`
  2026. Filename string `json:"filename"`
  2027. } `json:"output"`
  2028. RefmsgTime string `json:"refmsg_time"`
  2029. RespondTime string `json:"respond_time"`
  2030. Signtype interface{} `json:"signtype"`
  2031. WarnMsg interface{} `json:"warn_msg"`
  2032. }
  2033. //type Autogenerated struct {
  2034. // Output struct {
  2035. // Setlinfo struct {
  2036. // SetlTime string `json:"setl_time"`
  2037. // CvlservPay float64 `json:"cvlserv_pay"`
  2038. // Year string `json:"year"`
  2039. // MedType string `json:"med_type"`
  2040. // PsnPay float64 `json:"psn_pay"`
  2041. // OpterID string `json:"opter_id"`
  2042. // Begndate string `json:"begndate"`
  2043. // FlxempeFlag string `json:"flxempe_flag"`
  2044. // HifmiPay float64 `json:"hifmi_pay"`
  2045. // PsnNo string `json:"psn_no"`
  2046. // ActPayDedc float64 `json:"act_pay_dedc"`
  2047. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2048. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2049. // ClrWay string `json:"clr_way"`
  2050. // OthPay float64 `json:"oth_pay"`
  2051. // Gend string `json:"gend"`
  2052. // MdtrtID string `json:"mdtrt_id"`
  2053. // AcctPay float64 `json:"acct_pay"`
  2054. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2055. // Insutype string `json:"insutype"`
  2056. // Invono interface{} `json:"invono"`
  2057. // Enddate string `json:"enddate"`
  2058. // CashPayamt float64 `json:"cash_payamt"`
  2059. // PsnType string `json:"psn_type"`
  2060. // FixmedinsName string `json:"fixmedins_name"`
  2061. // HifpPay float64 `json:"hifp_pay"`
  2062. // NewFlag interface{} `json:"new_flag"`
  2063. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2064. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2065. // PayLoc string `json:"pay_loc"`
  2066. // ClrType string `json:"clr_type"`
  2067. // RefdSetlFlag string `json:"refd_setl_flag"`
  2068. // CvlservFlag string `json:"cvlserv_flag"`
  2069. // EmpName string `json:"emp_name"`
  2070. // Brdy string `json:"brdy"`
  2071. // Naty string `json:"naty"`
  2072. // Certno string `json:"certno"`
  2073. // DiseCode string `json:"dise_code"`
  2074. // FixmedinsCode string `json:"fixmedins_code"`
  2075. // DedcHospLv string `json:"dedc_hosp_lv"`
  2076. // OpterName string `json:"opter_name"`
  2077. // Balc float64 `json:"balc"`
  2078. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2079. // PsnCertType string `json:"psn_cert_type"`
  2080. // HifobPay float64 `json:"hifob_pay"`
  2081. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2082. // HifesPay float64 `json:"hifes_pay"`
  2083. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2084. // OptTime string `json:"opt_time"`
  2085. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2086. // SetlID string `json:"setl_id"`
  2087. // MafPay float64 `json:"maf_pay"`
  2088. // PsnName string `json:"psn_name"`
  2089. // InsuOptins interface{} `json:"insu_optins"`
  2090. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2091. // ClrOptins string `json:"clr_optins"`
  2092. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2093. // DiseName string `json:"dise_name"`
  2094. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2095. // Age float64 `json:"age"`
  2096. // DtrtCertType string `json:"dtrt_cert_type"`
  2097. // HospLv string `json:"hosp_lv"`
  2098. // } `json:"setlinfo"`
  2099. // Setldetail []struct {
  2100. // FundPayType string `json:"fund_pay_type"`
  2101. // FundPayamt float64 `json:"fund_payamt"`
  2102. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2103. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2104. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2105. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2106. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2107. // } `json:"setldetail"`
  2108. // } `json:"output"`
  2109. // Infcode int `json:"infcode"`
  2110. // WarnMsg interface{} `json:"warn_msg"`
  2111. // Cainfo interface{} `json:"cainfo"`
  2112. // ErrMsg interface{} `json:"err_msg"`
  2113. // RefmsgTime string `json:"refmsg_time"`
  2114. // Signtype interface{} `json:"signtype"`
  2115. // RespondTime string `json:"respond_time"`
  2116. // InfRefmsgid string `json:"inf_refmsgid"`
  2117. //}
  2118. type ResultEleven struct {
  2119. Cainfo string `json:"cainfo"`
  2120. ErrMsg string `json:"err_msg"`
  2121. InfRefmsgid string `json:"inf_refmsgid"`
  2122. Infcode int64 `json:"infcode"`
  2123. Output struct {
  2124. Setlinfo struct {
  2125. SetlTime string `json:"setl_time"`
  2126. CvlservPay float64 `json:"cvlserv_pay"`
  2127. Year string `json:"year"`
  2128. MedType string `json:"med_type"`
  2129. PsnPay float64 `json:"psn_pay"`
  2130. OpterID string `json:"opter_id"`
  2131. Begndate string `json:"begndate"`
  2132. FlxempeFlag string `json:"flxempe_flag"`
  2133. HifmiPay float64 `json:"hifmi_pay"`
  2134. PsnNo string `json:"psn_no"`
  2135. ActPayDedc float64 `json:"act_pay_dedc"`
  2136. MedinsSetlID interface{} `json:"medins_setl_id"`
  2137. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2138. ClrWay string `json:"clr_way"`
  2139. OthPay float64 `json:"oth_pay"`
  2140. Gend string `json:"gend"`
  2141. MdtrtID string `json:"mdtrt_id"`
  2142. AcctPay float64 `json:"acct_pay"`
  2143. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2144. Insutype string `json:"insutype"`
  2145. Invono interface{} `json:"invono"`
  2146. Enddate string `json:"enddate"`
  2147. CashPayamt float64 `json:"cash_payamt"`
  2148. PsnType string `json:"psn_type"`
  2149. FixmedinsName string `json:"fixmedins_name"`
  2150. HifpPay float64 `json:"hifp_pay"`
  2151. NewFlag interface{} `json:"new_flag"`
  2152. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2153. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2154. PayLoc string `json:"pay_loc"`
  2155. ClrType string `json:"clr_type"`
  2156. RefdSetlFlag string `json:"refd_setl_flag"`
  2157. CvlservFlag string `json:"cvlserv_flag"`
  2158. EmpName string `json:"emp_name"`
  2159. Brdy string `json:"brdy"`
  2160. Naty string `json:"naty"`
  2161. Certno string `json:"certno"`
  2162. DiseCode string `json:"dise_code"`
  2163. FixmedinsCode string `json:"fixmedins_code"`
  2164. DedcHospLv string `json:"dedc_hosp_lv"`
  2165. OpterName string `json:"opter_name"`
  2166. Balc float64 `json:"balc"`
  2167. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2168. PsnCertType string `json:"psn_cert_type"`
  2169. HifobPay float64 `json:"hifob_pay"`
  2170. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2171. HifesPay float64 `json:"hifes_pay"`
  2172. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2173. OptTime string `json:"opt_time"`
  2174. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2175. SetlID string `json:"setl_id"`
  2176. MafPay float64 `json:"maf_pay"`
  2177. PsnName string `json:"psn_name"`
  2178. InsuOptins interface{} `json:"insu_optins"`
  2179. PrefFundPay interface{} `json:"pref_fund_pay"`
  2180. ClrOptins string `json:"clr_optins"`
  2181. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2182. DiseName string `json:"dise_name"`
  2183. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2184. Age float64 `json:"age"`
  2185. DtrtCertType string `json:"dtrt_cert_type"`
  2186. HospLv string `json:"hosp_lv"`
  2187. } `json:"setlinfo"`
  2188. } `json:"output"`
  2189. RefmsgTime string `json:"refmsg_time"`
  2190. RespondTime string `json:"respond_time"`
  2191. Signtype interface{} `json:"signtype"`
  2192. WarnMsg interface{} `json:"warn_msg"`
  2193. }
  2194. type ResultEleven10265 struct {
  2195. Cainfo string `json:"cainfo"`
  2196. ErrMsg string `json:"err_msg"`
  2197. InfRefmsgid string `json:"inf_refmsgid"`
  2198. Infcode string `json:"infcode"`
  2199. Output struct {
  2200. Setlinfo struct {
  2201. SetlTime string `json:"setl_time"`
  2202. CvlservPay float64 `json:"cvlserv_pay"`
  2203. Year string `json:"year"`
  2204. MedType string `json:"med_type"`
  2205. PsnPay float64 `json:"psn_pay"`
  2206. OpterID string `json:"opter_id"`
  2207. Begndate string `json:"begndate"`
  2208. FlxempeFlag string `json:"flxempe_flag"`
  2209. HifmiPay float64 `json:"hifmi_pay"`
  2210. PsnNo string `json:"psn_no"`
  2211. ActPayDedc float64 `json:"act_pay_dedc"`
  2212. MedinsSetlID interface{} `json:"medins_setl_id"`
  2213. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2214. ClrWay string `json:"clr_way"`
  2215. OthPay float64 `json:"oth_pay"`
  2216. Gend string `json:"gend"`
  2217. MdtrtID string `json:"mdtrt_id"`
  2218. AcctPay float64 `json:"acct_pay"`
  2219. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2220. Insutype string `json:"insutype"`
  2221. Invono interface{} `json:"invono"`
  2222. Enddate string `json:"enddate"`
  2223. CashPayamt float64 `json:"cash_payamt"`
  2224. PsnType string `json:"psn_type"`
  2225. FixmedinsName string `json:"fixmedins_name"`
  2226. HifpPay float64 `json:"hifp_pay"`
  2227. NewFlag interface{} `json:"new_flag"`
  2228. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2229. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2230. PayLoc string `json:"pay_loc"`
  2231. ClrType string `json:"clr_type"`
  2232. RefdSetlFlag string `json:"refd_setl_flag"`
  2233. CvlservFlag string `json:"cvlserv_flag"`
  2234. EmpName string `json:"emp_name"`
  2235. Brdy string `json:"brdy"`
  2236. Naty string `json:"naty"`
  2237. Certno string `json:"certno"`
  2238. DiseCode string `json:"dise_code"`
  2239. FixmedinsCode string `json:"fixmedins_code"`
  2240. DedcHospLv string `json:"dedc_hosp_lv"`
  2241. OpterName string `json:"opter_name"`
  2242. Balc float64 `json:"balc"`
  2243. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2244. PsnCertType string `json:"psn_cert_type"`
  2245. HifobPay float64 `json:"hifob_pay"`
  2246. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2247. HifesPay float64 `json:"hifes_pay"`
  2248. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2249. OptTime string `json:"opt_time"`
  2250. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2251. SetlID string `json:"setl_id"`
  2252. MafPay float64 `json:"maf_pay"`
  2253. PsnName string `json:"psn_name"`
  2254. InsuOptins interface{} `json:"insu_optins"`
  2255. PrefFundPay interface{} `json:"pref_fund_pay"`
  2256. ClrOptins string `json:"clr_optins"`
  2257. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2258. DiseName string `json:"dise_name"`
  2259. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2260. Age float64 `json:"age"`
  2261. DtrtCertType string `json:"dtrt_cert_type"`
  2262. HospLv string `json:"hosp_lv"`
  2263. } `json:"setlinfo"`
  2264. } `json:"output"`
  2265. RefmsgTime string `json:"refmsg_time"`
  2266. RespondTime string `json:"respond_time"`
  2267. Signtype interface{} `json:"signtype"`
  2268. WarnMsg interface{} `json:"warn_msg"`
  2269. }
  2270. type ResultTwelve struct {
  2271. Cainfo string `json:"cainfo"`
  2272. ErrMsg string `json:"err_msg"`
  2273. InfRefmsgid string `json:"inf_refmsgid"`
  2274. Infcode int64 `json:"infcode"`
  2275. Output struct {
  2276. MdtrtId string `json:"mdtrt_id"`
  2277. ChrgBchno string `json:"chrg_bchno"`
  2278. PsnNo string `json:"psn_no"`
  2279. } `json:"output"`
  2280. RefmsgTime string `json:"refmsg_time"`
  2281. RespondTime string `json:"respond_time"`
  2282. Signtype interface{} `json:"signtype"`
  2283. WarnMsg interface{} `json:"warn_msg"`
  2284. }
  2285. type ResultThirteen struct {
  2286. ErrMsg string `json:"err_msg"`
  2287. InfRefmsgid string `json:"inf_refmsgid"`
  2288. Infcode int64 `json:"infcode"`
  2289. Output struct {
  2290. Result struct {
  2291. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2292. } `json:"result"`
  2293. } `json:"output"`
  2294. RefmsgTime string `json:"refmsg_time"`
  2295. RespondTime string `json:"respond_time"`
  2296. Signtype interface{} `json:"signtype"`
  2297. WarnInfo interface{} `json:"warn_info"`
  2298. }
  2299. type ResultThirteen10265 struct {
  2300. ErrMsg string `json:"err_msg"`
  2301. InfRefmsgid string `json:"inf_refmsgid"`
  2302. Infcode string `json:"infcode"`
  2303. Output struct {
  2304. Result struct {
  2305. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2306. } `json:"result"`
  2307. } `json:"output"`
  2308. RefmsgTime string `json:"refmsg_time"`
  2309. RespondTime string `json:"respond_time"`
  2310. Signtype interface{} `json:"signtype"`
  2311. WarnInfo interface{} `json:"warn_info"`
  2312. }
  2313. type ResultFourteen struct {
  2314. ErrMsg string `json:"err_msg"`
  2315. InfRefmsgid string `json:"inf_refmsgid"`
  2316. Infcode int64 `json:"infcode"`
  2317. Output struct {
  2318. } `json:"output"`
  2319. RefmsgTime string `json:"refmsg_time"`
  2320. RespondTime string `json:"respond_time"`
  2321. Signtype interface{} `json:"signtype"`
  2322. WarnInfo interface{} `json:"warn_info"`
  2323. }
  2324. type ResultFourteen10265 struct {
  2325. ErrMsg string `json:"err_msg"`
  2326. InfRefmsgid string `json:"inf_refmsgid"`
  2327. Infcode string `json:"infcode"`
  2328. Output struct {
  2329. } `json:"output"`
  2330. RefmsgTime string `json:"refmsg_time"`
  2331. RespondTime string `json:"respond_time"`
  2332. Signtype interface{} `json:"signtype"`
  2333. WarnInfo interface{} `json:"warn_info"`
  2334. }
  2335. type ResultSixteen struct {
  2336. Cainfo string `json:"cainfo"`
  2337. ErrMsg string `json:"err_msg"`
  2338. InfRefmsgid string `json:"inf_refmsgid"`
  2339. Infcode int64 `json:"infcode"`
  2340. Output struct {
  2341. Setldetail []interface{} `json:"setldetail"`
  2342. Setlinfo struct {
  2343. MdtrtID string `json:"mdtrt_id"`
  2344. SetlID string `json:"setl_id"`
  2345. ClrOptins string `json:"clr_optins"`
  2346. SetlTime string `json:"setl_time"`
  2347. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2348. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2349. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2350. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2351. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2352. ActPayDedc float64 `json:"act_pay_dedc"`
  2353. HifpPay float64 `json:"hifp_pay"`
  2354. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2355. Lfpay float64 `json:"selfpay"`
  2356. CvlservPay float64 `json:"cvlserv_pay"`
  2357. HifesPay float64 `json:"hifes_pay"`
  2358. HifmiPay float64 `json:"hifmi_pay"`
  2359. HifobPay float64 `json:"hifob_pay"`
  2360. MafPay float64 `json:"maf_pay"`
  2361. OthPay float64 `json:"oth_pay"`
  2362. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2363. PsnPartAmt float64 `json:"psn_part_amt"`
  2364. AcctPay float64 `json:"acct_pay"`
  2365. Balc float64 `json:"balc"`
  2366. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2367. HospPartAmt float64 `json:"hosp_part_amt"`
  2368. MedinsSetlID string `json:"medins_setl_id"`
  2369. PdnCashPay string `json:"pdn_cash_pay"`
  2370. } `json:"setlinfo"`
  2371. } `json:"output"`
  2372. RefmsgTime string `json:"refmsg_time"`
  2373. RespondTime string `json:"respond_time"`
  2374. Signtype interface{} `json:"signtype"`
  2375. WarnMsg interface{} `json:"warn_msg"`
  2376. }
  2377. type ResultSixteen10265 struct {
  2378. Cainfo string `json:"cainfo"`
  2379. ErrMsg string `json:"err_msg"`
  2380. InfRefmsgid string `json:"inf_refmsgid"`
  2381. Infcode string `json:"infcode"`
  2382. Output struct {
  2383. Setldetail []interface{} `json:"setldetail"`
  2384. Setlinfo struct {
  2385. MdtrtID string `json:"mdtrt_id"`
  2386. SetlID string `json:"setl_id"`
  2387. ClrOptins string `json:"clr_optins"`
  2388. SetlTime string `json:"setl_time"`
  2389. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2390. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2391. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2392. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2393. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2394. ActPayDedc float64 `json:"act_pay_dedc"`
  2395. HifpPay float64 `json:"hifp_pay"`
  2396. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2397. Lfpay float64 `json:"selfpay"`
  2398. CvlservPay float64 `json:"cvlserv_pay"`
  2399. HifesPay float64 `json:"hifes_pay"`
  2400. HifmiPay float64 `json:"hifmi_pay"`
  2401. HifobPay float64 `json:"hifob_pay"`
  2402. MafPay float64 `json:"maf_pay"`
  2403. OthPay float64 `json:"oth_pay"`
  2404. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2405. PsnPartAmt float64 `json:"psn_part_amt"`
  2406. AcctPay float64 `json:"acct_pay"`
  2407. Balc float64 `json:"balc"`
  2408. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2409. HospPartAmt float64 `json:"hosp_part_amt"`
  2410. MedinsSetlID string `json:"medins_setl_id"`
  2411. PdnCashPay string `json:"pdn_cash_pay"`
  2412. } `json:"setlinfo"`
  2413. } `json:"output"`
  2414. RefmsgTime string `json:"refmsg_time"`
  2415. RespondTime string `json:"respond_time"`
  2416. Signtype interface{} `json:"signtype"`
  2417. WarnMsg interface{} `json:"warn_msg"`
  2418. }
  2419. type ResultSeventeen struct {
  2420. ErrMsg string `json:"err_msg"`
  2421. InfRefmsgid string `json:"inf_refmsgid"`
  2422. Infcode int64 `json:"infcode"`
  2423. Output struct {
  2424. SetlListId string `json:"setl_list_id"`
  2425. } `json:"output"`
  2426. RefmsgTime string `json:"refmsg_time"`
  2427. RespondTime string `json:"respond_time"`
  2428. Signtype string `json:"signtype"`
  2429. WarnInfo string `json:"warn_info"`
  2430. }
  2431. type Result90991 struct {
  2432. ErrMsg string `json:"err_msg"`
  2433. InfRefmsgid string `json:"inf_refmsgid"`
  2434. Infcode int64 `json:"infcode"`
  2435. Output struct {
  2436. Result struct {
  2437. PsnNo string `json:"psn_no"`
  2438. CardStat string `json:"card_stat"`
  2439. Certno string `json:"certno"`
  2440. PsnName string `json:"psn_name"`
  2441. CheckStat string `json:"check_stat"`
  2442. } `json:"result"`
  2443. } `json:"output"`
  2444. RefmsgTime string `json:"refmsg_time"`
  2445. RespondTime string `json:"respond_time"`
  2446. Signtype interface{} `json:"signtype"`
  2447. WarnInfo interface{} `json:"warn_info"`
  2448. }
  2449. type Result90100 struct {
  2450. ErrMsg string `json:"err_msg"`
  2451. InfRefmsgid string `json:"inf_refmsgid"`
  2452. Infcode int64 `json:"infcode"`
  2453. Output struct {
  2454. PoolareaNo string `json:"poolarea_no"`
  2455. PoolareaNoName string `json:"poolarea_no_name"`
  2456. Insutype string `json:"insutype"`
  2457. InsutypeName string `json:"insutype_name"`
  2458. ClctType string `json:"clct_type"`
  2459. ClctTypeName string `json:"clct_type_name"`
  2460. ClctFlag string `json:"clct_flag"`
  2461. ClctFlagName string `json:"clct_flag_name"`
  2462. AccrymBegn string `json:"accrym_begn"`
  2463. AccrymEnd string `json:"accrym_end"`
  2464. ClctTime string `json:"clct_time"`
  2465. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  2466. } `json:"output"`
  2467. RefmsgTime string `json:"refmsg_time"`
  2468. RespondTime string `json:"respond_time"`
  2469. Signtype interface{} `json:"signtype"`
  2470. WarnInfo interface{} `json:"warn_info"`
  2471. }
  2472. type Custom struct {
  2473. DetItemFeeSumamt string
  2474. Cut string
  2475. FeedetlSn string
  2476. Price string
  2477. MedListCodg string
  2478. Type int64
  2479. AdviceId int64
  2480. ProjectId int64
  2481. ItemId int64
  2482. }
  2483. type Result5301 struct {
  2484. ErrMsg string `json:"err_msg"`
  2485. InfRefmsgid string `json:"inf_refmsgid"`
  2486. Infcode int64 `json:"infcode"`
  2487. Output struct {
  2488. Result struct {
  2489. OpspDiseCode string `json:"opsp_dise_code"`
  2490. OpspDiseName string `json:"opsp_dise_name"`
  2491. Begndate string `json:"begndate"`
  2492. Enddate string `json:"enddate"`
  2493. } `json:"feedetail"`
  2494. } `json:"output"`
  2495. RefmsgTime string `json:"refmsg_time"`
  2496. RespondTime string `json:"respond_time"`
  2497. Signtype interface{} `json:"signtype"`
  2498. WarnInfo interface{} `json:"warn_info"`
  2499. }
  2500. type Result5301For10265 struct {
  2501. ErrMsg string `json:"err_msg"`
  2502. InfRefmsgid string `json:"inf_refmsgid"`
  2503. Infcode string `json:"infcode"`
  2504. Output struct {
  2505. Result struct {
  2506. OpspDiseCode string `json:"opsp_dise_code"`
  2507. OpspDiseName string `json:"opsp_dise_name"`
  2508. Begndate string `json:"begndate"`
  2509. Enddate string `json:"enddate"`
  2510. } `json:"feedetail"`
  2511. } `json:"output"`
  2512. RefmsgTime string `json:"refmsg_time"`
  2513. RespondTime string `json:"respond_time"`
  2514. Signtype interface{} `json:"signtype"`
  2515. WarnInfo interface{} `json:"warn_info"`
  2516. }
  2517. //获取个人信息----挂号-----上传就诊信息
  2518. func (c *HisApiController) GetRegisterInfo() {
  2519. id, _ := c.GetInt64("id")
  2520. record_time := c.GetString("record_time")
  2521. settlementValue, _ := c.GetInt64("settlement_value")
  2522. medical_insurance_card := c.GetString("medical_insurance_card")
  2523. name := c.GetString("name")
  2524. id_card_type, _ := c.GetInt64("id_card_type")
  2525. certificates, _ := c.GetInt64("certificates")
  2526. medical_care, _ := c.GetInt64("medical_care")
  2527. birthday := c.GetString("birthday")
  2528. //age, _ := c.GetInt64("age")
  2529. id_card := c.GetString("id_card")
  2530. register_type, _ := c.GetInt64("register")
  2531. doctor, _ := c.GetInt64("doctor")
  2532. department, _ := c.GetInt64("department")
  2533. gender, _ := c.GetInt64("sex")
  2534. //phone := c.GetString("phone")
  2535. registration_fee, _ := c.GetFloat("registration_fee")
  2536. medical_expenses, _ := c.GetFloat("medical_expenses")
  2537. social_type, _ := c.GetInt64("social_type")
  2538. med_type := c.GetString("social_type")
  2539. admin_user_id, _ := c.GetInt64("admin_user_id")
  2540. timeLayout := "2006-01-02"
  2541. loc, _ := time.LoadLocation("Local")
  2542. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  2543. birthUnix := birthdays.Unix()
  2544. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2545. if err != nil {
  2546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2547. return
  2548. }
  2549. recordDateTime := theTime.Unix()
  2550. adminInfo := c.GetAdminUserInfo()
  2551. var patient service.Patients
  2552. if id == 0 {
  2553. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  2554. } else {
  2555. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  2556. }
  2557. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2558. if patientPrescription.ID == 0 {
  2559. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2560. }
  2561. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2562. if patient.ID == 0 {
  2563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  2564. return
  2565. }
  2566. if len(patient.IdCardNo) == 0 {
  2567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  2568. return
  2569. }
  2570. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2571. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  2572. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  2573. //就诊结算未完成,不能进行二次挂号
  2574. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  2575. if len(his) >= 1 {
  2576. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  2577. if len(his) >= 1 && order.ID == 0 {
  2578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  2579. return
  2580. }
  2581. }
  2582. //var register_log string
  2583. if config.IsOpen == 1 {
  2584. var res ResultTwo
  2585. var res10265 ResultTwo10265
  2586. var PsnNo string
  2587. var PsnCertType string
  2588. var Certno string
  2589. var PsnName string
  2590. var Gend string
  2591. var Naty string
  2592. var Brdy string
  2593. var Age float64
  2594. var infoStr string
  2595. var idetinfoStr string
  2596. var infocode int64
  2597. if miConfig.MdtrtareaAdmvs == "421300" {
  2598. psn_info, _ := service.GetPsnByPatientId(id)
  2599. PsnNo = psn_info.PsnNo
  2600. PsnCertType = psn_info.PsnCertType
  2601. Certno = psn_info.Certno
  2602. PsnName = psn_info.PsnName
  2603. Gend = psn_info.Gend
  2604. Naty = psn_info.Naty
  2605. Brdy = psn_info.Brdy
  2606. Age = psn_info.Age
  2607. infoStr = psn_info.Insuinfo
  2608. idetinfoStr = psn_info.Idetinfo
  2609. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2610. var res ResultTwo
  2611. api := "http://192.168.3.111:9532/" + "jsyb/1101?cert_no=" + "" +
  2612. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2613. "&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) + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  2614. fmt.Println(api)
  2615. resp, requestErr := http.Get(api)
  2616. if requestErr != nil {
  2617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2618. return
  2619. }
  2620. body, ioErr := ioutil.ReadAll(resp.Body)
  2621. if ioErr != nil {
  2622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2624. return
  2625. }
  2626. var respJSON map[string]interface{}
  2627. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2630. return
  2631. }
  2632. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2633. result, _ := json.Marshal(respJSON)
  2634. fmt.Println("log")
  2635. fmt.Println(string(result))
  2636. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2637. utils.ErrorLog("解析失败:%v", err)
  2638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2639. return
  2640. }
  2641. PsnNo = res.Output.Baseinfo.PsnNo
  2642. PsnCertType = res.Output.Baseinfo.PsnCertType
  2643. Certno = res.Output.Baseinfo.Certno
  2644. PsnName = res.Output.Baseinfo.PsnName
  2645. Gend = res.Output.Baseinfo.Gend
  2646. Naty = res.Output.Baseinfo.Naty
  2647. Brdy = res.Output.Baseinfo.Brdy
  2648. Age = res.Output.Baseinfo.Age
  2649. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2650. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2651. infoStr = string(Iinfos)
  2652. idetinfoStr = string(Idetinfos)
  2653. infocode = res.Infcode
  2654. } else {
  2655. 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)
  2656. saveLog(result, requestLog, "1101", "人员基本信息获取")
  2657. if miConfig.Code == "H15049901371" {
  2658. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2659. utils.ErrorLog("解析失败:%v", err)
  2660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2661. return
  2662. }
  2663. res.ErrMsg = res10265.ErrMsg
  2664. res.Output = res10265.Output
  2665. res.InfRefmsgid = res10265.InfRefmsgid
  2666. } else {
  2667. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2668. utils.ErrorLog("解析失败:%v", err)
  2669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2670. return
  2671. }
  2672. }
  2673. PsnNo = res.Output.Baseinfo.PsnNo
  2674. PsnCertType = res.Output.Baseinfo.PsnCertType
  2675. Certno = res.Output.Baseinfo.Certno
  2676. PsnName = res.Output.Baseinfo.PsnName
  2677. Gend = res.Output.Baseinfo.Gend
  2678. Naty = res.Output.Baseinfo.Naty
  2679. Brdy = res.Output.Baseinfo.Brdy
  2680. Age = res.Output.Baseinfo.Age
  2681. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2682. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2683. infoStr = string(Iinfos)
  2684. idetinfoStr = string(Idetinfos)
  2685. if miConfig.Code == "H15049901371" {
  2686. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  2687. } else {
  2688. infocode = res.Infcode
  2689. }
  2690. }
  2691. if infocode == 0 {
  2692. his := models.VMHisPatient{
  2693. Name: name,
  2694. Gender: gender,
  2695. Birthday: birthUnix,
  2696. MedicalTreatmentType: medical_care,
  2697. IdType: certificates,
  2698. IdCardNo: id_card,
  2699. BalanceAccountsType: settlementValue,
  2700. SocialType: social_type,
  2701. MedicalInsuranceNumber: medical_insurance_card,
  2702. RegisterType: register_type,
  2703. RegisterCost: registration_fee,
  2704. TreatmentCost: medical_expenses,
  2705. Status: 1,
  2706. Ctime: time.Now().Unix(),
  2707. Mtime: time.Now().Unix(),
  2708. PsnNo: PsnNo,
  2709. PsnCertType: PsnCertType,
  2710. Certno: Certno,
  2711. PsnName: PsnName,
  2712. Gend: Gend,
  2713. Naty: Naty,
  2714. Brdy: Brdy,
  2715. Age: Age,
  2716. Iinfo: infoStr,
  2717. Idetinfo: idetinfoStr,
  2718. PatientId: patient.ID,
  2719. RecordDate: theTime.Unix(),
  2720. UserOrgId: adminInfo.CurrentOrgId,
  2721. AdminUserId: admin_user_id,
  2722. IsReturn: 1,
  2723. IdCardType: id_card_type,
  2724. Doctor: doctor,
  2725. Departments: department,
  2726. }
  2727. timestamp := time.Now().Unix()
  2728. tempTime := time.Unix(timestamp, 0)
  2729. timeFormat := tempTime.Format("20060102150405")
  2730. chrgBchno := rand.Intn(100000) + 10000
  2731. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2732. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  2733. department, _ := service.GetDepartMentDetail(department)
  2734. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  2735. IdCardNo := ""
  2736. if id_card_type == 1 {
  2737. // IdCardNo = medical_insurance_card
  2738. IdCardNo = patient.IdCardNo
  2739. } else {
  2740. IdCardNo = patient.IdCardNo
  2741. }
  2742. var rf []*ResultFive
  2743. json.Unmarshal([]byte(his.Iinfo), &rf)
  2744. var insutypes []*ResultFive
  2745. var insutype string
  2746. var insuplc_admdvs string
  2747. var is390 int = 0
  2748. var is310 int = 0
  2749. for _, item := range rf {
  2750. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2751. insutypes = append(insutypes, item)
  2752. }
  2753. }
  2754. if len(insutypes) == 1 {
  2755. insutype = insutypes[0].Insutype
  2756. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2757. } else {
  2758. for _, i := range insutypes {
  2759. if i.Insutype == "390" {
  2760. is390 = 1
  2761. }
  2762. if i.Insutype == "310" {
  2763. is310 = 1
  2764. }
  2765. }
  2766. }
  2767. if is390 == 1 {
  2768. insutype = "390"
  2769. }
  2770. if is310 == 1 {
  2771. insutype = "310"
  2772. }
  2773. if len(insutypes) == 0 {
  2774. insutype = "310"
  2775. }
  2776. if len(insutypes) == 2 {
  2777. insutype = med_type
  2778. }
  2779. if len(med_type) > 0 {
  2780. insutype = med_type
  2781. }
  2782. for _, item := range rf {
  2783. if item.Insutype == insutype {
  2784. insuplc_admdvs = item.InsuplcAdmdvs
  2785. }
  2786. }
  2787. var infocode int64
  2788. var resThree ResultThree
  2789. var resThree10265 ResultThree10265
  2790. if miConfig.MdtrtareaAdmvs == "421300" {
  2791. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  2792. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2793. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id
  2794. resp, requestErr := http.Get(api)
  2795. if requestErr != nil {
  2796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2797. return
  2798. }
  2799. body, ioErr := ioutil.ReadAll(resp.Body)
  2800. if ioErr != nil {
  2801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2803. return
  2804. }
  2805. var respJSON map[string]interface{}
  2806. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2809. return
  2810. }
  2811. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2812. result, _ := json.Marshal(respJSON)
  2813. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2814. utils.ErrorLog("解析失败:%v", err)
  2815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2816. return
  2817. }
  2818. infocode = resThree.Infcode
  2819. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2820. api := "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  2821. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2822. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  2823. resp, requestErr := http.Get(api)
  2824. if requestErr != nil {
  2825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2826. return
  2827. }
  2828. body, ioErr := ioutil.ReadAll(resp.Body)
  2829. if ioErr != nil {
  2830. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2832. return
  2833. }
  2834. var respJSON map[string]interface{}
  2835. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2838. return
  2839. }
  2840. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2841. result, _ := json.Marshal(respJSON)
  2842. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2843. utils.ErrorLog("解析失败:%v", err)
  2844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2845. return
  2846. }
  2847. infocode = resThree.Infcode
  2848. } else {
  2849. 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, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  2850. saveLog(result, requestLog, "2201", "挂号")
  2851. if miConfig.Code == "H15049901371" {
  2852. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  2853. utils.ErrorLog("解析失败:%v", err)
  2854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2855. return
  2856. }
  2857. resThree.ErrMsg = resThree10265.ErrMsg
  2858. resThree.Output = resThree10265.Output
  2859. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  2860. } else {
  2861. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2862. utils.ErrorLog("解析失败:%v", err)
  2863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2864. return
  2865. }
  2866. }
  2867. if miConfig.Code == "H15049901371" {
  2868. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  2869. } else {
  2870. infocode = resThree.Infcode
  2871. }
  2872. }
  2873. if infocode != 0 {
  2874. adminUser := c.GetAdminUserInfo()
  2875. errlog := &models.HisOrderError{
  2876. UserOrgId: adminUser.CurrentOrgId,
  2877. Ctime: time.Now().Unix(),
  2878. Mtime: time.Now().Unix(),
  2879. ErrMsg: resThree.ErrMsg,
  2880. Status: 1,
  2881. PatientId: id,
  2882. RecordTime: recordDateTime,
  2883. Stage: 2,
  2884. }
  2885. service.CreateErrMsgLog(errlog)
  2886. c.ServeSuccessJSON(map[string]interface{}{
  2887. "failed_code": -10,
  2888. "msg": resThree.ErrMsg,
  2889. })
  2890. return
  2891. }
  2892. his.Number = resThree.Output.Data.MdtrtID
  2893. his.PsnNo = resThree.Output.Data.PsnNo
  2894. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  2895. his.IdCardNo = patient.IdCardNo
  2896. his.PhoneNumber = patient.Phone
  2897. his.UserOrgId = adminInfo.CurrentOrgId
  2898. his.Insutype = insutype
  2899. his.Ctime = time.Now().Unix()
  2900. his.Mtime = time.Now().Unix()
  2901. his.InsuplcAdmdvs = insuplc_admdvs
  2902. his.Status = 1
  2903. service.UpdateHisPatientStatus(&his)
  2904. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  2905. c.ServeSuccessJSON(map[string]interface{}{
  2906. "his_info": his,
  2907. })
  2908. } else {
  2909. adminUser := c.GetAdminUserInfo()
  2910. errlog := &models.HisOrderError{
  2911. UserOrgId: adminUser.CurrentOrgId,
  2912. Ctime: time.Now().Unix(),
  2913. Mtime: time.Now().Unix(),
  2914. ErrMsg: res.ErrMsg,
  2915. Status: 1,
  2916. PatientId: id,
  2917. RecordTime: recordDateTime,
  2918. Stage: 1,
  2919. }
  2920. service.CreateErrMsgLog(errlog)
  2921. c.ServeSuccessJSON(map[string]interface{}{
  2922. "failed_code": -10,
  2923. "msg": res.ErrMsg,
  2924. })
  2925. return
  2926. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  2927. }
  2928. }
  2929. }
  2930. //上传明细----预结算----确认订单
  2931. func (c *HisApiController) GetUploadInfo() {
  2932. id, _ := c.GetInt64("id")
  2933. record_time := c.GetString("record_time")
  2934. his_patient_id, _ := c.GetInt64("his_patient_id")
  2935. order_id, _ := c.GetInt64("order_id")
  2936. pay_way, _ := c.GetInt64("pay_way")
  2937. pay_price, _ := c.GetFloat("pay_price")
  2938. pay_card_no := c.GetString("pay_card_no")
  2939. discount_price, _ := c.GetFloat("discount_price")
  2940. preferential_price, _ := c.GetFloat("preferential_price")
  2941. reality_price, _ := c.GetFloat("reality_price")
  2942. found_price, _ := c.GetFloat("found_price")
  2943. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2944. private_price, _ := c.GetFloat("private_price")
  2945. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2946. admin_user_id, _ := c.GetInt64("admin_user_id")
  2947. fapiao_code := c.GetString("fapiao_code")
  2948. fapiao_number := c.GetString("fapiao_number")
  2949. diagnosis_id := c.GetString("diagnosis")
  2950. sick_type, _ := c.GetInt64("sick_type")
  2951. reg_type, _ := c.GetInt64("p_type")
  2952. id_str := c.GetString("ids")
  2953. ids_arr := strings.Split(id_str, ",")
  2954. timeLayout := "2006-01-02"
  2955. loc, _ := time.LoadLocation("Local")
  2956. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2957. if err != nil {
  2958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2959. return
  2960. }
  2961. recordDateTime := theTime.Unix()
  2962. adminUser := c.GetAdminUserInfo()
  2963. var tempOrder models.HisOrder
  2964. tempOrder, _ = service.GetHisOrderByID(order_id)
  2965. var prescriptions []*models.HisPrescription
  2966. var start_time int64
  2967. var end_time int64
  2968. //if adminUser.CurrentOrgId == 10106{
  2969. // if len(fapiao_code) == 0{
  2970. // fapiao_code = "144072080589"
  2971. // }
  2972. // if len(fapiao_number) == 0{
  2973. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  2974. // if order.ID == 0{
  2975. // fapiao_number = "00001520"
  2976. // }else{
  2977. // //fapiao_code = "00001520"
  2978. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  2979. // var zero string
  2980. // if fpNumber >= 1000{
  2981. // zero = "0000" + strconv.Itoa(fpNumber)
  2982. // }else if fpNumber >= 10000{
  2983. // zero = "000" + strconv.Itoa(fpNumber)
  2984. // } else if fpNumber >= 100000{
  2985. // zero = "00" + strconv.Itoa(fpNumber)
  2986. // } else if fpNumber >= 1000000{
  2987. // zero = "0" + strconv.Itoa(fpNumber)
  2988. // }else {
  2989. // zero = strconv.Itoa(fpNumber)
  2990. // }
  2991. // fapiao_number = zero
  2992. // }
  2993. // }
  2994. //}
  2995. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2996. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2997. var patientPrescription models.HisPrescriptionInfo
  2998. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2999. if patientPrescription.ID == 0 {
  3000. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3001. }
  3002. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3003. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3004. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3005. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3006. var config []*models.HisXtDiagnoseConfig
  3007. for _, item := range diagnosis_ids {
  3008. id, _ := strconv.ParseInt(item, 10, 64)
  3009. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3010. config = append(config, &diagnosisConfig)
  3011. }
  3012. sickConfig, _ := service.FindSickById(sick_type)
  3013. if tempOrder.ID == 0 {
  3014. tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3015. }
  3016. if tempOrder.ID == 0 {
  3017. var result string
  3018. var requestLog string
  3019. var res2 ResultSix
  3020. var ressix10265 ResultSix10265
  3021. if miConfig.InsuplcAdmdvs == "421300" {
  3022. data := make(map[string]interface{})
  3023. client := &http.Client{}
  3024. data["psn_no"] = his.PsnNo
  3025. data["mdtrt_id"] = his.Number
  3026. data["doctor"] = roles.UserName
  3027. data["department"] = department.Name
  3028. data["org_name"] = miConfig.OrgName
  3029. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3030. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3031. data["fixmedins_code"] = miConfig.Code
  3032. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3033. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3034. data["secret_key"] = miConfig.SecretKey
  3035. data["sick_code"] = sickConfig.CountryCode
  3036. data["sick_name"] = sickConfig.ClassName
  3037. data["dept"] = strconv.FormatInt(department.ID, 10)
  3038. data["config"] = config
  3039. bytesData, _ := json.Marshal(data)
  3040. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3041. resp, _ := client.Do(req)
  3042. defer resp.Body.Close()
  3043. body, ioErr := ioutil.ReadAll(resp.Body)
  3044. if ioErr != nil {
  3045. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3047. return
  3048. }
  3049. var respJSON map[string]interface{}
  3050. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3053. return
  3054. }
  3055. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3056. userJSONBytes, _ := json.Marshal(respJSON)
  3057. fmt.Println("log")
  3058. fmt.Println(string(userJSONBytes))
  3059. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3060. utils.ErrorLog("解析失败:%v", err)
  3061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3062. return
  3063. }
  3064. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3065. data := make(map[string]interface{})
  3066. client := &http.Client{}
  3067. data["psn_no"] = his.PsnNo
  3068. data["mdtrt_id"] = his.Number
  3069. data["doctor"] = roles.UserName
  3070. data["department"] = department.Name
  3071. data["org_name"] = miConfig.OrgName
  3072. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3073. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3074. data["fixmedins_code"] = miConfig.Code
  3075. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3076. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3077. data["secret_key"] = miConfig.SecretKey
  3078. data["sick_code"] = sickConfig.CountryCode
  3079. data["sick_name"] = sickConfig.ClassName
  3080. data["url"] = miConfig.Url
  3081. data["ak"] = miConfig.ChannelNumber
  3082. data["dept"] = strconv.FormatInt(department.ID, 10)
  3083. data["config"] = config
  3084. bytesData, _ := json.Marshal(data)
  3085. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3086. resp, _ := client.Do(req)
  3087. defer resp.Body.Close()
  3088. body, ioErr := ioutil.ReadAll(resp.Body)
  3089. if ioErr != nil {
  3090. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3092. return
  3093. }
  3094. var respJSON map[string]interface{}
  3095. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3098. return
  3099. }
  3100. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3101. userJSONBytes, _ := json.Marshal(respJSON)
  3102. fmt.Println("log")
  3103. fmt.Println(string(userJSONBytes))
  3104. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3105. utils.ErrorLog("解析失败:%v", err)
  3106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3107. return
  3108. }
  3109. } else {
  3110. if miConfig.MdtrtareaAdmvs == "440781" { //
  3111. 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)
  3112. } else {
  3113. if miConfig.Code == "H15049901371" {
  3114. //赤峰地区国家医保医疗类别
  3115. //职工透析:医疗类别选特殊情况门诊990502
  3116. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3117. var med_type string
  3118. if his.Insutype == "390" {
  3119. if reg_type == 14 {
  3120. med_type = "9933"
  3121. } else if reg_type == 11 {
  3122. med_type = "11"
  3123. }
  3124. } else if his.Insutype == "310" {
  3125. if reg_type == 14 {
  3126. med_type = "990502"
  3127. } else if reg_type == 11 {
  3128. med_type = "11"
  3129. }
  3130. }
  3131. 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)
  3132. } else {
  3133. 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)
  3134. }
  3135. }
  3136. saveLog(result, requestLog, "2203", "上传就诊信息")
  3137. var respJSON2 map[string]interface{}
  3138. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3141. return
  3142. }
  3143. userJSONBytes2, _ := json.Marshal(respJSON2)
  3144. if miConfig.Code == "H15049901371" {
  3145. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3146. utils.ErrorLog("解析失败:%v", err)
  3147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3148. return
  3149. }
  3150. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3151. res2.Output = ressix10265.Output
  3152. res2.ErrMsg = ressix10265.ErrMsg
  3153. res2.Cainfo = ressix10265.Cainfo
  3154. res2.WarnMsg = ressix10265.WarnMsg
  3155. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3156. res2.Infcode = infocode
  3157. } else {
  3158. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3159. utils.ErrorLog("解析失败:%v", err)
  3160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3161. return
  3162. }
  3163. }
  3164. }
  3165. if res2.Infcode != 0 {
  3166. adminUser := c.GetAdminUserInfo()
  3167. errlog := &models.HisOrderError{
  3168. UserOrgId: adminUser.CurrentOrgId,
  3169. Ctime: time.Now().Unix(),
  3170. Mtime: time.Now().Unix(),
  3171. ErrMsg: res2.ErrMsg,
  3172. Status: 1,
  3173. PatientId: id,
  3174. RecordTime: recordDateTime,
  3175. Stage: 3,
  3176. }
  3177. service.CreateErrMsgLog(errlog)
  3178. c.ServeSuccessJSON(map[string]interface{}{
  3179. "failed_code": -10,
  3180. "msg": res2.ErrMsg,
  3181. })
  3182. return
  3183. } else {
  3184. his.Diagnosis = diagnosis_id
  3185. his.SickType = sickConfig.ID
  3186. var p_type int64
  3187. if reg_type == 1111 || reg_type == 1112 {
  3188. p_type = 11
  3189. }
  3190. his.PType = fmt.Sprintf("%d", p_type)
  3191. service.UpdateHisPatientThree(&his)
  3192. data := make(map[string]interface{})
  3193. if settle_accounts_type == 1 { //日结
  3194. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3195. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3196. } else {
  3197. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3198. }
  3199. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3200. data["pre"] = prescriptions
  3201. } else { //月结
  3202. start_time_str := c.GetString("start_time")
  3203. end_time_str := c.GetString("end_time")
  3204. timeLayout := "2006-01-02"
  3205. loc, _ := time.LoadLocation("Local")
  3206. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3207. if err != nil {
  3208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3209. return
  3210. }
  3211. recordStartTime := theStartTime.Unix()
  3212. start_time = recordStartTime
  3213. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3214. if err != nil {
  3215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3216. return
  3217. }
  3218. recordEndTime := theEndTime.Unix()
  3219. end_time = recordEndTime
  3220. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3221. data["pre"] = prescriptions
  3222. }
  3223. timestamp := time.Now().Unix()
  3224. tempTime := time.Unix(timestamp, 0)
  3225. timeFormat := tempTime.Format("20060102150405")
  3226. chrgBchno := rand.Intn(100000) + 10000
  3227. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3228. strconv.FormatInt(his.PatientId, 10)
  3229. client := &http.Client{}
  3230. data["psn_no"] = his.PsnNo
  3231. data["mdtrt_id"] = his.Number
  3232. data["chrg_bchno"] = chrg_bchno
  3233. data["org_name"] = miConfig.OrgName
  3234. data["doctor"] = roles.UserName
  3235. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3236. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3237. data["fixmedins_code"] = miConfig.Code
  3238. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3239. data["dept_code"] = "15"
  3240. } else {
  3241. data["dept_code"] = department.Number
  3242. }
  3243. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3244. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3245. data["secret_key"] = miConfig.SecretKey
  3246. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3247. data["url"] = miConfig.Url
  3248. data["ak"] = miConfig.ChannelNumber
  3249. data["new_doctor_name"] = patientPrescription.Doctor
  3250. var ids []int64
  3251. for _, item := range prescriptions {
  3252. ids = append(ids, item.ID)
  3253. }
  3254. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3255. if config.IsOpen == 1 { //对接了医保,走医保流程
  3256. var res ResultFour
  3257. var resFour10265 ResultFour10265
  3258. if miConfig.MdtrtareaAdmvs == "421300" {
  3259. bytesData, _ := json.Marshal(data)
  3260. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3261. resp, _ := client.Do(req)
  3262. defer resp.Body.Close()
  3263. body, ioErr := ioutil.ReadAll(resp.Body)
  3264. if ioErr != nil {
  3265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3267. return
  3268. }
  3269. var respJSON map[string]interface{}
  3270. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3273. return
  3274. }
  3275. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3276. userJSONBytes, _ := json.Marshal(respJSON)
  3277. fmt.Println("log")
  3278. fmt.Println(string(userJSONBytes))
  3279. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3280. utils.ErrorLog("解析失败:%v", err)
  3281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3282. return
  3283. }
  3284. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3285. bytesData, _ := json.Marshal(data)
  3286. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3287. resp, _ := client.Do(req)
  3288. defer resp.Body.Close()
  3289. body, ioErr := ioutil.ReadAll(resp.Body)
  3290. if ioErr != nil {
  3291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3293. return
  3294. }
  3295. var respJSON map[string]interface{}
  3296. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3299. return
  3300. }
  3301. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3302. userJSONBytes, _ := json.Marshal(respJSON)
  3303. fmt.Println("log")
  3304. fmt.Println(string(userJSONBytes))
  3305. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3306. utils.ErrorLog("解析失败:%v", err)
  3307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3308. return
  3309. }
  3310. } else {
  3311. if miConfig.Code == "H15049901371" {
  3312. 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)
  3313. var dat map[string]interface{}
  3314. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3315. fmt.Println(dat)
  3316. } else {
  3317. fmt.Println(err)
  3318. }
  3319. saveLog(result, request_log, "2204", "上传费用明细")
  3320. userJSONBytes, _ := json.Marshal(dat)
  3321. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3322. utils.ErrorLog("解析失败:%v", err)
  3323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3324. return
  3325. }
  3326. res.InfRefmsgid = resFour10265.InfRefmsgid
  3327. res.Output = resFour10265.Output
  3328. res.ErrMsg = resFour10265.ErrMsg
  3329. res.Cainfo = resFour10265.Cainfo
  3330. res.WarnMsg = resFour10265.WarnMsg
  3331. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3332. res.Infcode = infocode
  3333. } else {
  3334. 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), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  3335. var dat map[string]interface{}
  3336. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3337. fmt.Println(dat)
  3338. } else {
  3339. fmt.Println(err)
  3340. }
  3341. saveLog(result, request_log, "2204", "上传费用明细")
  3342. userJSONBytes, _ := json.Marshal(dat)
  3343. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3344. utils.ErrorLog("解析失败:%v", err)
  3345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3346. return
  3347. }
  3348. }
  3349. }
  3350. if res.Infcode == 0 {
  3351. order := &models.HisOrder{
  3352. UserOrgId: adminUser.CurrentOrgId,
  3353. HisPatientId: his.ID,
  3354. PatientId: his.PatientId,
  3355. SettleAccountsDate: recordDateTime,
  3356. Ctime: time.Now().Unix(),
  3357. Mtime: time.Now().Unix(),
  3358. Status: 1,
  3359. Number: chrg_bchno,
  3360. Infcode: res.Infcode,
  3361. WarnMsg: res.WarnMsg,
  3362. Cainfo: res.Cainfo,
  3363. ErrMsg: res.ErrMsg,
  3364. RespondTime: res.RefmsgTime,
  3365. InfRefmsgid: res.InfRefmsgid,
  3366. OrderStatus: 1,
  3367. PayWay: pay_way,
  3368. PayPrice: pay_price,
  3369. PayCardNo: pay_card_no,
  3370. DiscountPrice: discount_price,
  3371. PreferentialPrice: preferential_price,
  3372. RealityPrice: reality_price,
  3373. FoundPrice: found_price,
  3374. MedicalInsurancePrice: medical_insurance_price,
  3375. PrivatePrice: private_price,
  3376. IsMedicineInsurance: 1,
  3377. SettleType: settle_accounts_type,
  3378. SettleStartTime: start_time,
  3379. SettleEndTime: end_time,
  3380. Creator: roles.AdminUserId,
  3381. Modify: roles.AdminUserId,
  3382. FaPiaoNumber: fapiao_number,
  3383. FaPiaoCode: fapiao_code,
  3384. PType: 2,
  3385. Diagnosis: diagnosis_id,
  3386. }
  3387. err = service.CreateOrder(order)
  3388. if err != nil {
  3389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3390. return
  3391. }
  3392. for _, item := range res.Output.Result {
  3393. temp := strings.Split(item.FeedetlSn, "-")
  3394. var advice_id int64 = 0
  3395. var project_id int64 = 0
  3396. var types int64 = 0
  3397. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3398. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3399. if temp[1] == "1" {
  3400. advice_id = id
  3401. project_id = 0
  3402. } else if temp[1] == "2" {
  3403. advice_id = 0
  3404. project_id = id
  3405. }
  3406. info := &models.HisOrderInfo{
  3407. OrderNumber: order.Number,
  3408. FeedetlSn: item.FeedetlSn,
  3409. UploadDate: time.Now().Unix(),
  3410. AdviceId: advice_id,
  3411. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3412. Cnt: item.Cnt,
  3413. Pric: float64(item.Pric),
  3414. PatientId: his.PatientId,
  3415. PricUplmtAmt: item.PricUplmtAmt,
  3416. SelfpayProp: item.SelfpayProp,
  3417. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3418. OverlmtAmt: item.OverlmtAmt,
  3419. PreselfpayAmt: item.PreselfpayAmt,
  3420. BasMednFlag: item.BasMednFlag,
  3421. MedChrgitmType: item.MedChrgitmType,
  3422. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3423. Status: 1,
  3424. Memo: item.Memo,
  3425. Mtime: time.Now().Unix(),
  3426. InscpScpAmt: item.InscpScpAmt,
  3427. DrtReimFlag: item.DrtReimFlag,
  3428. Ctime: time.Now().Unix(),
  3429. ListSpItemFlag: item.ListSpItemFlag,
  3430. ChldMedcFlag: item.ChldMedcFlag,
  3431. LmtUsedFlag: item.LmtUsedFlag,
  3432. ChrgitmLv: item.ChrgitmLv,
  3433. UserOrgId: adminUser.CurrentOrgId,
  3434. HisPatientId: his.ID,
  3435. OrderId: order.ID,
  3436. ProjectId: project_id,
  3437. Type: types,
  3438. }
  3439. service.CreateOrderInfo(info)
  3440. }
  3441. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3442. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3443. var total float64
  3444. for _, item := range prescriptions {
  3445. if item.Type == 1 { //药品
  3446. for _, subItem := range item.HisDoctorAdviceInfo {
  3447. total = total + (subItem.Price * subItem.PrescribingNumber)
  3448. }
  3449. }
  3450. if item.Type == 2 { //项目
  3451. for _, subItem := range item.HisPrescriptionProject {
  3452. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3453. total = total + (subItem.Price * cnt)
  3454. }
  3455. }
  3456. }
  3457. for _, item := range prescriptions {
  3458. for _, subItem := range item.HisAdditionalCharge {
  3459. total = total + (subItem.Price * float64(subItem.Count))
  3460. }
  3461. }
  3462. var allTotal string
  3463. if adminUser.CurrentOrgId == 9919 {
  3464. allTotal = fmt.Sprintf("%.4f", total)
  3465. } else {
  3466. allTotal = fmt.Sprintf("%.4f", total)
  3467. }
  3468. if res.Infcode == 0 {
  3469. var rf []*ResultFive
  3470. json.Unmarshal([]byte(his.Iinfo), &rf)
  3471. chrg_bchno := chrg_bchno
  3472. cert_no := his.Certno
  3473. var insutypes []string
  3474. var insutype string
  3475. var is390 int = 0
  3476. var is310 int = 0
  3477. for _, item := range rf {
  3478. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3479. insutypes = append(insutypes, item.Insutype)
  3480. }
  3481. }
  3482. if len(insutypes) == 1 {
  3483. insutype = insutypes[0]
  3484. } else {
  3485. for _, i := range insutypes {
  3486. if i == "390" {
  3487. is390 = 1
  3488. }
  3489. if i == "310" {
  3490. is310 = 1
  3491. }
  3492. }
  3493. }
  3494. if is390 == 1 {
  3495. insutype = "390"
  3496. }
  3497. if is310 == 1 {
  3498. insutype = "310"
  3499. }
  3500. if len(insutypes) == 0 {
  3501. insutype = "310"
  3502. }
  3503. if len(insutypes) == 2 {
  3504. insutype = strconv.FormatInt(his.SocialType, 10)
  3505. }
  3506. insutype = strconv.FormatInt(his.SocialType, 10)
  3507. //insutype = "390"
  3508. if his.IdCardType == 1 {
  3509. // cert_no = his.MedicalInsuranceNumber
  3510. cert_no = his.Certno
  3511. } else {
  3512. cert_no = his.Certno
  3513. }
  3514. var res ResultSeven
  3515. var resSeven10265 ResultSeven10265
  3516. var src_resquest string
  3517. var result2 string
  3518. var acct_used_flag string
  3519. fmt.Println("pay_way")
  3520. fmt.Println(pay_way)
  3521. fmt.Println("pay_way")
  3522. if pay_way == 4 {
  3523. acct_used_flag = "1"
  3524. } else {
  3525. acct_used_flag = "0"
  3526. }
  3527. if miConfig.MdtrtareaAdmvs == "421300" {
  3528. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3529. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3530. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3531. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3532. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3533. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3534. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3535. resp, requestErr := http.Get(api)
  3536. if requestErr != nil {
  3537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3538. return
  3539. }
  3540. body, ioErr := ioutil.ReadAll(resp.Body)
  3541. if ioErr != nil {
  3542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3544. return
  3545. }
  3546. var respJSON map[string]interface{}
  3547. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3550. return
  3551. }
  3552. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3553. result, _ := json.Marshal(respJSON)
  3554. if miConfig.Code == "H15049901371" {
  3555. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3556. utils.ErrorLog("解析失败:%v", err)
  3557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3558. return
  3559. }
  3560. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3561. res.Output = resSeven10265.Output
  3562. res.ErrMsg = resSeven10265.ErrMsg
  3563. res.Cainfo = resSeven10265.Cainfo
  3564. res.WarnMsg = resSeven10265.WarnMsg
  3565. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3566. res.Infcode = infocode
  3567. } else {
  3568. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3569. utils.ErrorLog("解析失败:%v", err)
  3570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3571. return
  3572. }
  3573. }
  3574. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3575. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3576. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3577. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3578. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3579. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3580. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3581. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  3582. resp, requestErr := http.Get(api)
  3583. if requestErr != nil {
  3584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3585. return
  3586. }
  3587. body, ioErr := ioutil.ReadAll(resp.Body)
  3588. if ioErr != nil {
  3589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3591. return
  3592. }
  3593. var respJSON map[string]interface{}
  3594. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3597. return
  3598. }
  3599. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3600. result, _ := json.Marshal(respJSON)
  3601. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3602. utils.ErrorLog("解析失败:%v", err)
  3603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3604. return
  3605. }
  3606. } else {
  3607. if miConfig.Code == "H15049901371" {
  3608. //赤峰地区国家医保医疗类别
  3609. //职工透析:医疗类别选特殊情况门诊990502
  3610. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3611. var med_type string
  3612. if his.Insutype == "390" {
  3613. if reg_type == 14 {
  3614. med_type = "9933"
  3615. } else if reg_type == 11 {
  3616. med_type = "11"
  3617. }
  3618. } else if his.Insutype == "310" {
  3619. if reg_type == 14 {
  3620. med_type = "990502"
  3621. } else if reg_type == 11 {
  3622. med_type = "11"
  3623. }
  3624. }
  3625. 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)
  3626. } else {
  3627. 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, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  3628. }
  3629. //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)
  3630. var dat map[string]interface{}
  3631. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3632. fmt.Println(dat)
  3633. } else {
  3634. fmt.Println(err)
  3635. }
  3636. saveLog(result2, src_resquest, "2207", "结算")
  3637. userJSONBytes, _ := json.Marshal(dat)
  3638. if miConfig.Code == "H15049901371" {
  3639. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3640. utils.ErrorLog("解析失败:%v", err)
  3641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3642. return
  3643. }
  3644. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3645. res.Output = resSeven10265.Output
  3646. res.ErrMsg = resSeven10265.ErrMsg
  3647. res.Cainfo = resSeven10265.Cainfo
  3648. res.WarnMsg = resSeven10265.WarnMsg
  3649. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3650. res.Infcode = infocode
  3651. } else {
  3652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3653. utils.ErrorLog("解析失败:%v", err)
  3654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3655. return
  3656. }
  3657. }
  3658. }
  3659. if res.Infcode != 0 {
  3660. errlog := &models.HisOrderError{
  3661. UserOrgId: adminUser.CurrentOrgId,
  3662. Ctime: time.Now().Unix(),
  3663. Mtime: time.Now().Unix(),
  3664. Number: chrg_bchno,
  3665. ErrMsg: res.ErrMsg,
  3666. Status: 1,
  3667. PatientId: id,
  3668. RecordTime: recordDateTime,
  3669. Stage: 6,
  3670. }
  3671. service.CreateErrMsgLog(errlog)
  3672. c.ServeSuccessJSON(map[string]interface{}{
  3673. "failed_code": -10,
  3674. "msg": res.ErrMsg,
  3675. })
  3676. return
  3677. } else {
  3678. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3679. order.OrderStatus = 2
  3680. order.Status = 1
  3681. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3682. order.SetlId = res.Output.Setlinfo.SetlID
  3683. order.PsnNo = res.Output.Setlinfo.PsnNo
  3684. order.PsnName = res.Output.Setlinfo.PsnName
  3685. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3686. order.Certno = res.Output.Setlinfo.Certno
  3687. order.Gend = res.Output.Setlinfo.Gend
  3688. order.Naty = res.Output.Setlinfo.Naty
  3689. order.Age = res.Output.Setlinfo.Age
  3690. order.Insutype = res.Output.Setlinfo.Insutype
  3691. order.PsnType = res.Output.Setlinfo.PsnType
  3692. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3693. order.SetlTime = res.Output.Setlinfo.SetlTime
  3694. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3695. if res.Output.Setlinfo.MedType == "140101" {
  3696. order.MedType = "14"
  3697. } else {
  3698. order.MedType = res.Output.Setlinfo.MedType
  3699. }
  3700. if reg_type == 1112 {
  3701. order.MedType = "1112"
  3702. }
  3703. if reg_type == 1111 {
  3704. order.MedType = "1111"
  3705. }
  3706. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3707. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3708. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3709. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3710. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3711. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3712. order.HifpPay = res.Output.Setlinfo.HifpPay
  3713. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3714. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3715. order.HifesPay = res.Output.Setlinfo.HifesPay
  3716. order.HifobPay = res.Output.Setlinfo.HifobPay
  3717. order.MafPay = res.Output.Setlinfo.MafPay
  3718. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3719. order.OthPay = res.Output.Setlinfo.OthPay
  3720. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3721. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3722. order.AcctPay = res.Output.Setlinfo.AcctPay
  3723. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3724. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3725. order.Balc = res.Output.Setlinfo.Balc
  3726. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3727. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3728. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3729. order.ClrWay = res.Output.Setlinfo.ClrWay
  3730. order.Creator = order.Creator
  3731. order.Modify = roles.AdminUserId
  3732. order.RequestLog = src_resquest
  3733. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3734. detailStr := string(setlDetail)
  3735. order.SetlDetail = detailStr
  3736. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3737. err = service.UpDateOrder(order)
  3738. if err == nil {
  3739. c.ServeSuccessJSON(map[string]interface{}{
  3740. "msg": "结算成功",
  3741. })
  3742. } else {
  3743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3744. return
  3745. }
  3746. }
  3747. } else {
  3748. adminUser := c.GetAdminUserInfo()
  3749. errlog := &models.HisOrderError{
  3750. UserOrgId: adminUser.CurrentOrgId,
  3751. Ctime: time.Now().Unix(),
  3752. Mtime: time.Now().Unix(),
  3753. ErrMsg: res.ErrMsg,
  3754. Status: 1,
  3755. PatientId: id,
  3756. RecordTime: recordDateTime,
  3757. Stage: 4,
  3758. }
  3759. service.CreateErrMsgLog(errlog)
  3760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3761. return
  3762. }
  3763. } else {
  3764. adminUser := c.GetAdminUserInfo()
  3765. errlog := &models.HisOrderError{
  3766. UserOrgId: adminUser.CurrentOrgId,
  3767. Ctime: time.Now().Unix(),
  3768. Mtime: time.Now().Unix(),
  3769. ErrMsg: res.ErrMsg,
  3770. Status: 1,
  3771. PatientId: id,
  3772. RecordTime: recordDateTime,
  3773. Stage: 4,
  3774. }
  3775. service.CreateErrMsgLog(errlog)
  3776. c.ServeSuccessJSON(map[string]interface{}{
  3777. "failed_code": -10,
  3778. "msg": res.ErrMsg,
  3779. })
  3780. return
  3781. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3782. //return
  3783. }
  3784. }
  3785. }
  3786. } else if tempOrder.ID > 0 {
  3787. if tempOrder.IsPre == 1 {
  3788. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  3789. var rf []*ResultFive
  3790. json.Unmarshal([]byte(his.Iinfo), &rf)
  3791. chrg_bchno := tempOrder.Number
  3792. cert_no := his.Certno
  3793. var insutypes []string
  3794. var insutype string
  3795. var is390 int = 0
  3796. var is310 int = 0
  3797. for _, item := range rf {
  3798. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3799. insutypes = append(insutypes, item.Insutype)
  3800. }
  3801. }
  3802. if len(insutypes) == 1 {
  3803. insutype = insutypes[0]
  3804. } else {
  3805. for _, i := range insutypes {
  3806. if i == "390" {
  3807. is390 = 1
  3808. }
  3809. if i == "310" {
  3810. is310 = 1
  3811. }
  3812. }
  3813. }
  3814. if is390 == 1 {
  3815. insutype = "390"
  3816. }
  3817. if is310 == 1 {
  3818. insutype = "310"
  3819. }
  3820. if len(insutypes) == 0 {
  3821. insutype = "310"
  3822. }
  3823. if len(insutypes) == 2 {
  3824. insutype = strconv.FormatInt(his.SocialType, 64)
  3825. }
  3826. //insutype = "390"
  3827. if his.IdCardType == 1 {
  3828. // cert_no = his.MedicalInsuranceNumber
  3829. cert_no = his.Certno
  3830. } else {
  3831. cert_no = his.Certno
  3832. }
  3833. var res ResultSeven
  3834. var resSeven10265 ResultSeven10265
  3835. var src_resquest string
  3836. var result2 string
  3837. var acct_used_flag string
  3838. fmt.Println("pay_way")
  3839. fmt.Println(pay_way)
  3840. fmt.Println("pay_way")
  3841. if pay_way == 4 {
  3842. acct_used_flag = "1"
  3843. } else {
  3844. acct_used_flag = "0"
  3845. }
  3846. if miConfig.MdtrtareaAdmvs == "421300" {
  3847. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3848. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3849. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3850. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3851. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3852. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3853. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3854. resp, requestErr := http.Get(api)
  3855. if requestErr != nil {
  3856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3857. return
  3858. }
  3859. body, ioErr := ioutil.ReadAll(resp.Body)
  3860. if ioErr != nil {
  3861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3863. return
  3864. }
  3865. var respJSON map[string]interface{}
  3866. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3869. return
  3870. }
  3871. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3872. result, _ := json.Marshal(respJSON)
  3873. fmt.Println("log")
  3874. fmt.Println(string(result))
  3875. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3876. utils.ErrorLog("解析失败:%v", err)
  3877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3878. return
  3879. }
  3880. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3881. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3882. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3883. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3884. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3885. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3886. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3887. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  3888. resp, requestErr := http.Get(api)
  3889. if requestErr != nil {
  3890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3891. return
  3892. }
  3893. body, ioErr := ioutil.ReadAll(resp.Body)
  3894. if ioErr != nil {
  3895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3897. return
  3898. }
  3899. var respJSON map[string]interface{}
  3900. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3903. return
  3904. }
  3905. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3906. result, _ := json.Marshal(respJSON)
  3907. fmt.Println("log")
  3908. fmt.Println(string(result))
  3909. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3910. utils.ErrorLog("解析失败:%v", err)
  3911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3912. return
  3913. }
  3914. } else {
  3915. var src_resquest string
  3916. if miConfig.Code == "H15049901371" {
  3917. //赤峰地区国家医保医疗类别
  3918. //职工透析:医疗类别选特殊情况门诊990502
  3919. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3920. var med_type string
  3921. if his.Insutype == "390" {
  3922. if reg_type == 14 {
  3923. med_type = "9933"
  3924. } else if reg_type == 11 {
  3925. med_type = "11"
  3926. }
  3927. } else if his.Insutype == "310" {
  3928. if reg_type == 14 {
  3929. med_type = "990502"
  3930. } else if reg_type == 11 {
  3931. med_type = "11"
  3932. }
  3933. }
  3934. 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)
  3935. } else {
  3936. 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, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  3937. }
  3938. var dat map[string]interface{}
  3939. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3940. fmt.Println(dat)
  3941. } else {
  3942. fmt.Println(err)
  3943. }
  3944. saveLog(result2, src_resquest, "2207", "结算")
  3945. userJSONBytes, _ := json.Marshal(dat)
  3946. if miConfig.Code == "H15049901371" {
  3947. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3948. utils.ErrorLog("解析失败:%v", err)
  3949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3950. return
  3951. }
  3952. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3953. res.Output = resSeven10265.Output
  3954. res.ErrMsg = resSeven10265.ErrMsg
  3955. res.Cainfo = resSeven10265.Cainfo
  3956. res.WarnMsg = resSeven10265.WarnMsg
  3957. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3958. res.Infcode = infocode
  3959. } else {
  3960. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3961. utils.ErrorLog("解析失败:%v", err)
  3962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3963. return
  3964. }
  3965. }
  3966. }
  3967. if res.Infcode != 0 {
  3968. errlog := &models.HisOrderError{
  3969. UserOrgId: adminUser.CurrentOrgId,
  3970. Ctime: time.Now().Unix(),
  3971. Mtime: time.Now().Unix(),
  3972. Number: chrg_bchno,
  3973. ErrMsg: res.ErrMsg,
  3974. Status: 1,
  3975. PatientId: id,
  3976. RecordTime: recordDateTime,
  3977. Stage: 6,
  3978. }
  3979. service.CreateErrMsgLog(errlog)
  3980. c.ServeSuccessJSON(map[string]interface{}{
  3981. "failed_code": -10,
  3982. "msg": res.ErrMsg,
  3983. })
  3984. return
  3985. } else {
  3986. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3987. order.OrderStatus = 2
  3988. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3989. order.SetlId = res.Output.Setlinfo.SetlID
  3990. order.PsnNo = res.Output.Setlinfo.PsnNo
  3991. order.PsnName = res.Output.Setlinfo.PsnName
  3992. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3993. order.Certno = res.Output.Setlinfo.Certno
  3994. order.Gend = res.Output.Setlinfo.Gend
  3995. order.Naty = res.Output.Setlinfo.Naty
  3996. order.Age = res.Output.Setlinfo.Age
  3997. order.Insutype = res.Output.Setlinfo.Insutype
  3998. order.PsnType = res.Output.Setlinfo.PsnType
  3999. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4000. order.SetlTime = res.Output.Setlinfo.SetlTime
  4001. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4002. //order.MedType = res.Output.Setlinfo.MedType
  4003. if reg_type == 1112 {
  4004. order.MedType = "1112"
  4005. }
  4006. if reg_type == 1111 {
  4007. order.MedType = "1111"
  4008. }
  4009. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4010. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4011. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4012. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4013. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4014. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4015. order.HifpPay = res.Output.Setlinfo.HifpPay
  4016. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4017. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4018. order.HifesPay = res.Output.Setlinfo.HifesPay
  4019. order.HifobPay = res.Output.Setlinfo.HifobPay
  4020. order.MafPay = res.Output.Setlinfo.MafPay
  4021. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4022. order.OthPay = res.Output.Setlinfo.OthPay
  4023. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4024. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4025. order.AcctPay = res.Output.Setlinfo.AcctPay
  4026. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4027. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4028. order.Balc = res.Output.Setlinfo.Balc
  4029. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4030. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4031. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4032. order.ClrWay = res.Output.Setlinfo.ClrWay
  4033. order.Creator = order.Creator
  4034. order.Modify = roles.AdminUserId
  4035. order.RequestLog = src_resquest
  4036. order.Diagnosis = diagnosis_id
  4037. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4038. detailStr := string(setlDetail)
  4039. order.SetlDetail = detailStr
  4040. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4041. err = service.UpDateOrder(order)
  4042. if err == nil {
  4043. c.ServeSuccessJSON(map[string]interface{}{
  4044. "msg": "结算成功",
  4045. })
  4046. } else {
  4047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4048. return
  4049. }
  4050. }
  4051. }
  4052. }
  4053. }
  4054. //func (c *HisApiController) GetPreUploadInfo() {
  4055. // id, _ := c.GetInt64("id")
  4056. // record_time := c.GetString("record_time")
  4057. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4058. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4059. //
  4060. // timeLayout := "2006-01-02"
  4061. // loc, _ := time.LoadLocation("Local")
  4062. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4063. // if err != nil {
  4064. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4065. // return
  4066. // }
  4067. // recordDateTime := theTime.Unix()
  4068. // adminUser := c.GetAdminUserInfo()
  4069. //
  4070. // var prescriptions []*models.HisPrescription
  4071. //
  4072. // var start_time int64
  4073. // var end_time int64
  4074. //
  4075. // data := make(map[string]interface{})
  4076. // if settle_accounts_type == 1 { //日结
  4077. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4078. // data["pre"] = prescriptions
  4079. //
  4080. // } else { //月结
  4081. // start_time_str := c.GetString("start_time")
  4082. // end_time_str := c.GetString("end_time")
  4083. // timeLayout := "2006-01-02"
  4084. // loc, _ := time.LoadLocation("Local")
  4085. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4086. // if err != nil {
  4087. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4088. // return
  4089. // }
  4090. // recordStartTime := theStartTime.Unix()
  4091. // start_time = recordStartTime
  4092. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4093. // if err != nil {
  4094. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4095. // return
  4096. // }
  4097. // recordEndTime := theEndTime.Unix()
  4098. // end_time = recordEndTime
  4099. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4100. // data["pre"] = prescriptions
  4101. //
  4102. // }
  4103. //
  4104. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4105. //
  4106. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4107. // timestamp := time.Now().Unix()
  4108. // tempTime := time.Unix(timestamp, 0)
  4109. // timeFormat := tempTime.Format("20060102150405")
  4110. // chrgBchno := rand.Intn(100000) + 10000
  4111. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4112. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4113. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4114. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4115. // strconv.FormatInt(his.PatientId, 10)
  4116. // client := &http.Client{}
  4117. // data["psn_no"] = his.PsnNo
  4118. // data["mdtrt_id"] = his.Number
  4119. // data["chrg_bchno"] = chrg_bchno
  4120. // data["org_name"] = miConfig.OrgName
  4121. // data["doctor"] = roles.UserName
  4122. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4123. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4124. // data["fixmedins_code"] = miConfig.Code
  4125. // data["dept_code"] = department.Number
  4126. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4127. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4128. // data["secret_key"] = miConfig.SecretKey
  4129. // var ids []int64
  4130. //
  4131. // for _, item := range prescriptions {
  4132. // ids = append(ids, item.ID)
  4133. // }
  4134. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4135. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4136. // bytesData, _ := json.Marshal(data)
  4137. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4138. // resp, _ := client.Do(req)
  4139. // defer resp.Body.Close()
  4140. // body, ioErr := ioutil.ReadAll(resp.Body)
  4141. // if ioErr != nil {
  4142. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4143. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4144. // return
  4145. // }
  4146. // var respJSON map[string]interface{}
  4147. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4148. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4149. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4150. // return
  4151. // }
  4152. //
  4153. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4154. // userJSONBytes, _ := json.Marshal(respJSON)
  4155. // var res ResultFour
  4156. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4157. // utils.ErrorLog("解析失败:%v", err)
  4158. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4159. // return
  4160. // }
  4161. //
  4162. // if res.Infcode == 0 {
  4163. // order := &models.HisOrder{
  4164. // UserOrgId: adminUser.CurrentOrgId,
  4165. // HisPatientId: his.ID,
  4166. // PatientId: his.PatientId,
  4167. // SettleAccountsDate: recordDateTime,
  4168. // Ctime: time.Now().Unix(),
  4169. // Mtime: time.Now().Unix(),
  4170. // Status: 1,
  4171. // Number: chrg_bchno,
  4172. // Infcode: res.Infcode,
  4173. // WarnMsg: res.WarnMsg,
  4174. // Cainfo: res.Cainfo,
  4175. // ErrMsg: res.ErrMsg,
  4176. // RespondTime: res.RefmsgTime,
  4177. // InfRefmsgid: res.InfRefmsgid,
  4178. // OrderStatus: 1,
  4179. // IsMedicineInsurance: 1,
  4180. // SettleType: settle_accounts_type,
  4181. // SettleStartTime: start_time,
  4182. // SettleEndTime: end_time,
  4183. // Creator: roles.ID,
  4184. // Modify: roles.ID,
  4185. // PType: 2,
  4186. // }
  4187. // err = service.CreateOrder(order)
  4188. // if err != nil {
  4189. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4190. // return
  4191. // }
  4192. //
  4193. // for _, item := range res.Output.Result {
  4194. // temp := strings.Split(item.FeedetlSn, "-")
  4195. // var advice_id int64 = 0
  4196. // var project_id int64 = 0
  4197. // var types int64 = 0
  4198. //
  4199. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4200. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4201. //
  4202. // if temp[1] == "1" {
  4203. // advice_id = id
  4204. // project_id = 0
  4205. // } else if temp[1] == "2" {
  4206. // advice_id = 0
  4207. // project_id = id
  4208. // }
  4209. //
  4210. // info := &models.HisOrderInfo{
  4211. // OrderNumber: order.Number,
  4212. // FeedetlSn: item.FeedetlSn,
  4213. // UploadDate: time.Now().Unix(),
  4214. // AdviceId: advice_id,
  4215. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4216. // Cnt: item.Cnt,
  4217. // Pric: float64(item.Pric),
  4218. // PatientId: his.PatientId,
  4219. // PricUplmtAmt: item.PricUplmtAmt,
  4220. // SelfpayProp: item.SelfpayProp,
  4221. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4222. // OverlmtAmt: item.OverlmtAmt,
  4223. // PreselfpayAmt: item.PreselfpayAmt,
  4224. // BasMednFlag: item.BasMednFlag,
  4225. // MedChrgitmType: item.MedChrgitmType,
  4226. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4227. // Status: 1,
  4228. // Memo: item.Memo,
  4229. // Mtime: time.Now().Unix(),
  4230. // InscpScpAmt: item.InscpScpAmt,
  4231. // DrtReimFlag: item.DrtReimFlag,
  4232. // Ctime: time.Now().Unix(),
  4233. // ListSpItemFlag: item.ListSpItemFlag,
  4234. // ChldMedcFlag: item.ChldMedcFlag,
  4235. // LmtUsedFlag: item.LmtUsedFlag,
  4236. // ChrgitmLv: item.ChrgitmLv,
  4237. // UserOrgId: adminUser.CurrentOrgId,
  4238. // HisPatientId: his.ID,
  4239. // OrderId: order.ID,
  4240. // ProjectId: project_id,
  4241. // Type: types,
  4242. // }
  4243. // service.CreateOrderInfo(info)
  4244. //
  4245. // }
  4246. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4247. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4248. //
  4249. // var total float64
  4250. // for _, item := range prescriptions {
  4251. // if item.Type == 1 { //药品
  4252. // for _, subItem := range item.HisDoctorAdviceInfo {
  4253. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4254. // }
  4255. // }
  4256. // if item.Type == 2 { //项目
  4257. // for _, subItem := range item.HisPrescriptionProject {
  4258. // total = total + (subItem.Price * float64(subItem.Count))
  4259. // }
  4260. // }
  4261. // }
  4262. //
  4263. // for _, item := range prescriptions {
  4264. // for _, subItem := range item.HisAdditionalCharge {
  4265. // total = total + (subItem.Price * float64(subItem.Count))
  4266. // }
  4267. // }
  4268. //
  4269. // allTotal := fmt.Sprintf("%.2f", total)
  4270. // if res.Infcode == 0 {
  4271. // var rf []*ResultFive
  4272. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4273. // psn_no := his.PsnNo
  4274. // mdtrt_id := his.Number
  4275. // chrg_bchno := chrg_bchno
  4276. // cert_no := his.Certno
  4277. // insutype := rf[0].Insutype
  4278. //
  4279. // if his.IdCardType == 1 {
  4280. // cert_no = his.MedicalInsuranceNumber
  4281. //
  4282. // } else {
  4283. //
  4284. // cert_no = his.Certno
  4285. //
  4286. // }
  4287. //
  4288. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  4289. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  4290. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  4291. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  4292. // resp, requestErr := http.Get(api)
  4293. // if requestErr != nil {
  4294. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4295. // return
  4296. // }
  4297. // defer resp.Body.Close()
  4298. // body, ioErr := ioutil.ReadAll(resp.Body)
  4299. // if ioErr != nil {
  4300. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4301. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4302. // return
  4303. // }
  4304. // var respJSON map[string]interface{}
  4305. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4306. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4307. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4308. // return
  4309. // }
  4310. // fmt.Println(respJSON)
  4311. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4312. // userJSONBytes, _ := json.Marshal(respJSON)
  4313. // var res ResultSeven
  4314. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4315. // utils.ErrorLog("解析失败:%v", err)
  4316. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4317. // return
  4318. // }
  4319. // if res.Infcode != 0 {
  4320. // errlog := &models.HisOrderError{
  4321. // UserOrgId: adminUser.CurrentOrgId,
  4322. // Ctime: time.Now().Unix(),
  4323. // Mtime: time.Now().Unix(),
  4324. // Number: chrg_bchno,
  4325. // ErrMsg: res.ErrMsg,
  4326. // Status: 1,
  4327. // PatientId: id,
  4328. // RecordTime: recordDateTime,
  4329. // Stage: 7,
  4330. // }
  4331. // service.CreateErrMsgLog(errlog)
  4332. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4333. // return
  4334. // } else {
  4335. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4336. // order.OrderStatus = 1
  4337. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4338. // order.SetlId = res.Output.Setlinfo.SetlID
  4339. // order.PsnNo = res.Output.Setlinfo.PsnNo
  4340. // order.PsnName = res.Output.Setlinfo.PsnName
  4341. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4342. // order.Certno = res.Output.Setlinfo.Certno
  4343. // order.Gend = res.Output.Setlinfo.Gend
  4344. // order.Naty = res.Output.Setlinfo.Naty
  4345. // order.Age = res.Output.Setlinfo.Age
  4346. // order.Insutype = res.Output.Setlinfo.Insutype
  4347. // order.PsnType = res.Output.Setlinfo.PsnType
  4348. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4349. // order.SetlTime = res.Output.Setlinfo.SetlTime
  4350. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4351. // order.MedType = res.Output.Setlinfo.MedType
  4352. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4353. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4354. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4355. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4356. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4357. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4358. // order.HifpPay = res.Output.Setlinfo.HifpPay
  4359. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4360. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4361. // order.HifesPay = res.Output.Setlinfo.HifesPay
  4362. // order.HifobPay = res.Output.Setlinfo.HifobPay
  4363. // order.MafPay = res.Output.Setlinfo.MafPay
  4364. // order.OthPay = res.Output.Setlinfo.OthPay
  4365. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4366. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4367. // order.AcctPay = res.Output.Setlinfo.AcctPay
  4368. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4369. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4370. // order.Balc = res.Output.Setlinfo.Balc
  4371. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4372. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4373. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4374. // order.ClrWay = res.Output.Setlinfo.ClrWay
  4375. // order.Creator = order.Creator
  4376. // order.Modify = roles.ID
  4377. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4378. // detailStr := string(setlDetail)
  4379. // order.SetlDetail = detailStr
  4380. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4381. // err = service.UpDateOrder(order)
  4382. // if err == nil {
  4383. // c.ServeSuccessJSON(map[string]interface{}{
  4384. // "msg": "预结算成功",
  4385. // })
  4386. // } else {
  4387. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4388. // return
  4389. // }
  4390. // }
  4391. // } else {
  4392. // adminUser := c.GetAdminUserInfo()
  4393. // errlog := &models.HisOrderError{
  4394. // UserOrgId: adminUser.CurrentOrgId,
  4395. // Ctime: time.Now().Unix(),
  4396. // Mtime: time.Now().Unix(),
  4397. // ErrMsg: res.ErrMsg,
  4398. // Status: 1,
  4399. // PatientId: id,
  4400. // RecordTime: recordDateTime,
  4401. // Stage: 4,
  4402. // }
  4403. // service.CreateErrMsgLog(errlog)
  4404. //
  4405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4406. // return
  4407. // }
  4408. // } else {
  4409. // adminUser := c.GetAdminUserInfo()
  4410. // errlog := &models.HisOrderError{
  4411. // UserOrgId: adminUser.CurrentOrgId,
  4412. // Ctime: time.Now().Unix(),
  4413. // Mtime: time.Now().Unix(),
  4414. // ErrMsg: res.ErrMsg,
  4415. // Status: 1,
  4416. // PatientId: id,
  4417. // RecordTime: recordDateTime,
  4418. // Stage: 4,
  4419. // }
  4420. // service.CreateErrMsgLog(errlog)
  4421. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4422. // return
  4423. // }
  4424. //
  4425. // } else {
  4426. // var total float64
  4427. // for _, item := range prescriptions {
  4428. // if item.Type == 1 { //药品
  4429. // for _, subItem := range item.HisDoctorAdviceInfo {
  4430. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4431. // }
  4432. // }
  4433. // if item.Type == 2 { //项目
  4434. // for _, subItem := range item.HisPrescriptionProject {
  4435. // total = total + (subItem.Price * float64(subItem.Count))
  4436. // }
  4437. // }
  4438. //
  4439. // for _, subItem := range item.HisAdditionalCharge {
  4440. // total = total + (subItem.Price * float64(subItem.Count))
  4441. // }
  4442. // }
  4443. //
  4444. // allTotal := fmt.Sprintf("%.2f", total)
  4445. // totals, _ := strconv.ParseFloat(allTotal, 64)
  4446. // order := &models.HisOrder{
  4447. // UserOrgId: adminUser.CurrentOrgId,
  4448. // HisPatientId: his.ID,
  4449. // PatientId: id,
  4450. // SettleAccountsDate: recordDateTime,
  4451. // Ctime: time.Now().Unix(),
  4452. // Mtime: time.Now().Unix(),
  4453. // Status: 1,
  4454. // OrderStatus: 2,
  4455. // Number: chrg_bchno,
  4456. // MedfeeSumamt: totals,
  4457. // }
  4458. // err = service.CreateOrder(order)
  4459. // if err != nil {
  4460. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4461. // return
  4462. // }
  4463. //
  4464. // var customs []*Custom
  4465. // for _, item := range prescriptions {
  4466. //
  4467. // if item.Type == 1 { //药品
  4468. // for _, subItem := range item.HisDoctorAdviceInfo {
  4469. // cus := &Custom{
  4470. // AdviceId: subItem.ID,
  4471. // ProjectId: 0,
  4472. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  4473. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  4474. // FeedetlSn: subItem.FeedetlSn,
  4475. // Price: fmt.Sprintf("%.2f", subItem.Price),
  4476. // MedListCodg: subItem.MedListCodg,
  4477. // Type: 1,
  4478. // }
  4479. // customs = append(customs, cus)
  4480. // }
  4481. // }
  4482. //
  4483. // if item.Type == 2 { //项目
  4484. // for _, subItem := range item.HisPrescriptionProject {
  4485. //
  4486. // cus := &Custom{
  4487. // AdviceId: 0,
  4488. // ProjectId: subItem.ID,
  4489. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  4490. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  4491. // FeedetlSn: subItem.FeedetlSn,
  4492. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  4493. // MedListCodg: subItem.MedListCodg,
  4494. // Type: 2,
  4495. // }
  4496. //
  4497. // customs = append(customs, cus)
  4498. // }
  4499. // }
  4500. //
  4501. // for _, item := range item.HisAdditionalCharge {
  4502. // cus := &Custom{
  4503. // ItemId: item.ID,
  4504. // AdviceId: 0,
  4505. // ProjectId: 0,
  4506. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  4507. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  4508. // FeedetlSn: item.FeedetlSn,
  4509. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  4510. // MedListCodg: item.XtHisAddtionConfig.Code,
  4511. // Type: 3,
  4512. // }
  4513. //
  4514. // customs = append(customs, cus)
  4515. // }
  4516. //
  4517. // }
  4518. //
  4519. // for _, item := range customs {
  4520. // var advice_id int64 = 0
  4521. // var project_id int64 = 0
  4522. // var item_id int64 = 0
  4523. //
  4524. // var types int64 = 0
  4525. //
  4526. // if item.Type == 1 {
  4527. // advice_id = item.AdviceId
  4528. // project_id = 0
  4529. // item_id = 0
  4530. // } else if item.Type == 2 {
  4531. // advice_id = 0
  4532. // item_id = 0
  4533. //
  4534. // project_id = item.ProjectId
  4535. // } else if item.Type == 3 {
  4536. // advice_id = 0
  4537. // item_id = item.ItemId
  4538. // project_id = 0
  4539. // }
  4540. //
  4541. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  4542. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  4543. // pric, _ := strconv.ParseFloat(item.Price, 32)
  4544. //
  4545. // info := &models.HisOrderInfo{
  4546. // OrderNumber: order.Number,
  4547. // UploadDate: time.Now().Unix(),
  4548. // AdviceId: advice_id,
  4549. // DetItemFeeSumamt: detItemFeeSumamt,
  4550. // Cnt: cut,
  4551. // Pric: pric,
  4552. // PatientId: id,
  4553. // Status: 1,
  4554. // Mtime: time.Now().Unix(),
  4555. // Ctime: time.Now().Unix(),
  4556. // UserOrgId: adminUser.CurrentOrgId,
  4557. // HisPatientId: his.ID,
  4558. // OrderId: order.ID,
  4559. // ProjectId: project_id,
  4560. // Type: types,
  4561. // ItemId: item_id,
  4562. // }
  4563. // service.CreateOrderInfo(info)
  4564. // }
  4565. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4566. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4567. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  4568. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4569. // if err == nil {
  4570. // c.ServeSuccessJSON(map[string]interface{}{
  4571. // "msg": "结算成功",
  4572. // })
  4573. // } else {
  4574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4575. // return
  4576. // }
  4577. // }
  4578. //}
  4579. //上传明细-预结算-
  4580. func (c *HisApiController) GetPreUploadInfo() {
  4581. id, _ := c.GetInt64("id")
  4582. record_time := c.GetString("record_time")
  4583. his_patient_id, _ := c.GetInt64("his_patient_id")
  4584. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4585. admin_user_id, _ := c.GetInt64("admin_user_id")
  4586. diagnosis_id := c.GetString("diagnosis")
  4587. sick_type, _ := c.GetInt64("sick_type")
  4588. reg_type, _ := c.GetInt64("p_type")
  4589. id_str := c.GetString("ids")
  4590. ids_arr := strings.Split(id_str, ",")
  4591. timeLayout := "2006-01-02"
  4592. loc, _ := time.LoadLocation("Local")
  4593. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4594. if err != nil {
  4595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4596. return
  4597. }
  4598. recordDateTime := theTime.Unix()
  4599. adminUser := c.GetAdminUserInfo()
  4600. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4601. var config []*models.HisXtDiagnoseConfig
  4602. for _, item := range diagnosis_ids {
  4603. id, _ := strconv.ParseInt(item, 10, 64)
  4604. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4605. config = append(config, &diagnosisConfig)
  4606. }
  4607. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4608. sickConfig, _ := service.FindSickById(sick_type)
  4609. var prescriptions []*models.HisPrescription
  4610. var start_time int64
  4611. var end_time int64
  4612. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4613. fmt.Println(his_patient_id)
  4614. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4615. timestamp := time.Now().Unix()
  4616. tempTime := time.Unix(timestamp, 0)
  4617. timeFormat := tempTime.Format("20060102150405")
  4618. chrgBchno := rand.Intn(100000) + 10000
  4619. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4620. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4621. var patientPrescription models.HisPrescriptionInfo
  4622. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4623. if patientPrescription.ID == 0 {
  4624. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4625. }
  4626. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4627. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4628. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4629. strconv.FormatInt(his.PatientId, 10)
  4630. var res2 ResultSix
  4631. var resSix10265 ResultSix10265
  4632. if miConfig.InsuplcAdmdvs == "421300" {
  4633. data := make(map[string]interface{})
  4634. client := &http.Client{}
  4635. data["psn_no"] = his.PsnNo
  4636. data["mdtrt_id"] = his.Number
  4637. data["doctor"] = roles.UserName
  4638. data["department"] = department.Name
  4639. data["org_name"] = miConfig.OrgName
  4640. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4641. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4642. data["fixmedins_code"] = miConfig.Code
  4643. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4644. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4645. data["secret_key"] = miConfig.SecretKey
  4646. data["sick_code"] = sickConfig.CountryCode
  4647. data["sick_name"] = sickConfig.ClassName
  4648. data["dept"] = strconv.FormatInt(department.ID, 10)
  4649. data["config"] = config
  4650. fmt.Println(data)
  4651. bytesData, _ := json.Marshal(data)
  4652. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4653. resp, _ := client.Do(req)
  4654. defer resp.Body.Close()
  4655. body, ioErr := ioutil.ReadAll(resp.Body)
  4656. if ioErr != nil {
  4657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4659. return
  4660. }
  4661. var respJSON map[string]interface{}
  4662. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4665. return
  4666. }
  4667. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4668. userJSONBytes, _ := json.Marshal(respJSON)
  4669. fmt.Println("log")
  4670. fmt.Println(string(userJSONBytes))
  4671. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4672. utils.ErrorLog("解析失败:%v", err)
  4673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4674. return
  4675. }
  4676. } else {
  4677. var result string
  4678. var requestLog string
  4679. if miConfig.InsuplcAdmdvs == "440781" { //
  4680. 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)
  4681. } else {
  4682. if miConfig.Code == "H15049901371" {
  4683. //赤峰地区国家医保医疗类别
  4684. //职工透析:医疗类别选特殊情况门诊990502
  4685. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4686. var med_type string
  4687. if his.Insutype == "390" {
  4688. if reg_type == 14 {
  4689. med_type = "9933"
  4690. } else if reg_type == 11 {
  4691. med_type = "11"
  4692. }
  4693. } else if his.Insutype == "310" {
  4694. if reg_type == 14 {
  4695. med_type = "990502"
  4696. } else if reg_type == 11 {
  4697. med_type = "11"
  4698. }
  4699. }
  4700. 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)
  4701. } else {
  4702. 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, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config)
  4703. }
  4704. saveLog(result, requestLog, "2203", "上传就诊信息")
  4705. var respJSON2 map[string]interface{}
  4706. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4709. return
  4710. }
  4711. //userJSONBytes2, _ := json.Marshal(respJSON2)
  4712. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4713. // utils.ErrorLog("解析失败:%v", err)
  4714. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4715. // return
  4716. //}
  4717. userJSONBytes2, _ := json.Marshal(respJSON2)
  4718. if miConfig.Code == "H15049901371" {
  4719. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  4720. utils.ErrorLog("解析失败:%v", err)
  4721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4722. return
  4723. }
  4724. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4725. res2.Output = resSix10265.Output
  4726. res2.ErrMsg = resSix10265.ErrMsg
  4727. res2.Cainfo = resSix10265.Cainfo
  4728. res2.WarnMsg = resSix10265.WarnMsg
  4729. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  4730. res2.Infcode = infocode
  4731. } else {
  4732. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4733. utils.ErrorLog("解析失败:%v", err)
  4734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4735. return
  4736. }
  4737. }
  4738. }
  4739. }
  4740. if res2.Infcode != 0 {
  4741. adminUser := c.GetAdminUserInfo()
  4742. errlog := &models.HisOrderError{
  4743. UserOrgId: adminUser.CurrentOrgId,
  4744. Ctime: time.Now().Unix(),
  4745. Mtime: time.Now().Unix(),
  4746. ErrMsg: res2.ErrMsg,
  4747. Status: 1,
  4748. PatientId: id,
  4749. RecordTime: recordDateTime,
  4750. Stage: 3,
  4751. }
  4752. service.CreateErrMsgLog(errlog)
  4753. c.ServeSuccessJSON(map[string]interface{}{
  4754. "failed_code": -10,
  4755. "msg": res2.ErrMsg,
  4756. })
  4757. return
  4758. } else {
  4759. his.Diagnosis = diagnosis_id
  4760. his.SickType = sickConfig.ID
  4761. his.PType = fmt.Sprintf("%d", reg_type)
  4762. service.UpdateHisPatientThree(&his)
  4763. data := make(map[string]interface{})
  4764. if settle_accounts_type == 1 { //日结
  4765. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4766. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4767. } else {
  4768. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4769. }
  4770. data["pre"] = prescriptions
  4771. } else { //月结
  4772. start_time_str := c.GetString("start_time")
  4773. end_time_str := c.GetString("end_time")
  4774. timeLayout := "2006-01-02"
  4775. loc, _ := time.LoadLocation("Local")
  4776. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4777. if err != nil {
  4778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4779. return
  4780. }
  4781. recordStartTime := theStartTime.Unix()
  4782. start_time = recordStartTime
  4783. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4784. if err != nil {
  4785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4786. return
  4787. }
  4788. recordEndTime := theEndTime.Unix()
  4789. end_time = recordEndTime
  4790. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4791. data["pre"] = prescriptions
  4792. }
  4793. client := &http.Client{}
  4794. data["psn_no"] = his.PsnNo
  4795. data["mdtrt_id"] = his.Number
  4796. data["chrg_bchno"] = chrg_bchno
  4797. data["org_name"] = miConfig.OrgName
  4798. data["doctor"] = roles.UserName
  4799. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4800. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4801. data["fixmedins_code"] = miConfig.Code
  4802. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4803. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4804. data["dept_code"] = "15"
  4805. } else {
  4806. data["dept_code"] = department.Number
  4807. }
  4808. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4809. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4810. data["secret_key"] = miConfig.SecretKey
  4811. data["url"] = miConfig.Url
  4812. data["ak"] = miConfig.ChannelNumber
  4813. data["new_doctor_name"] = patientPrescription.Doctor
  4814. var ids []int64
  4815. for _, item := range prescriptions {
  4816. ids = append(ids, item.ID)
  4817. }
  4818. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4819. if config.IsOpen == 1 { //对接了医保,走医保流程
  4820. var res ResultFour
  4821. var resFour10265 ResultFour10265
  4822. if miConfig.MdtrtareaAdmvs == "421300" {
  4823. bytesData, _ := json.Marshal(data)
  4824. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4825. resp, _ := client.Do(req)
  4826. defer resp.Body.Close()
  4827. body, ioErr := ioutil.ReadAll(resp.Body)
  4828. if ioErr != nil {
  4829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4831. return
  4832. }
  4833. var respJSON map[string]interface{}
  4834. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4837. return
  4838. }
  4839. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4840. userJSONBytes, _ := json.Marshal(respJSON)
  4841. fmt.Println("log")
  4842. fmt.Println(string(userJSONBytes))
  4843. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4844. utils.ErrorLog("解析失败:%v", err)
  4845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4846. return
  4847. }
  4848. } else if miConfig.MdtrtareaAdmvs == "320921" {
  4849. bytesData, _ := json.Marshal(data)
  4850. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4851. resp, _ := client.Do(req)
  4852. defer resp.Body.Close()
  4853. body, ioErr := ioutil.ReadAll(resp.Body)
  4854. if ioErr != nil {
  4855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4857. return
  4858. }
  4859. var respJSON map[string]interface{}
  4860. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4863. return
  4864. }
  4865. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4866. userJSONBytes, _ := json.Marshal(respJSON)
  4867. fmt.Println("log")
  4868. fmt.Println(string(userJSONBytes))
  4869. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4870. utils.ErrorLog("解析失败:%v", err)
  4871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4872. return
  4873. }
  4874. } else {
  4875. if miConfig.Code == "H15049901371" {
  4876. 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)
  4877. var dat map[string]interface{}
  4878. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4879. fmt.Println(dat)
  4880. } else {
  4881. fmt.Println(err)
  4882. }
  4883. saveLog(result, request_log, "2204", "上传费用明细")
  4884. userJSONBytes, _ := json.Marshal(dat)
  4885. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4886. utils.ErrorLog("解析失败:%v", err)
  4887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4888. return
  4889. }
  4890. res.InfRefmsgid = resFour10265.InfRefmsgid
  4891. res.Output = resFour10265.Output
  4892. res.ErrMsg = resFour10265.ErrMsg
  4893. res.Cainfo = resFour10265.Cainfo
  4894. res.WarnMsg = resFour10265.WarnMsg
  4895. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4896. res.Infcode = infocode
  4897. } else {
  4898. 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)
  4899. var dat map[string]interface{}
  4900. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4901. fmt.Println(dat)
  4902. } else {
  4903. fmt.Println(err)
  4904. }
  4905. saveLog(result, request_log, "2204", "上传费用明细")
  4906. userJSONBytes, _ := json.Marshal(dat)
  4907. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4908. utils.ErrorLog("解析失败:%v", err)
  4909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4910. return
  4911. }
  4912. }
  4913. }
  4914. if res.Infcode == 0 {
  4915. order := &models.HisOrder{
  4916. UserOrgId: adminUser.CurrentOrgId,
  4917. HisPatientId: his.ID,
  4918. PatientId: his.PatientId,
  4919. SettleAccountsDate: recordDateTime,
  4920. Ctime: time.Now().Unix(),
  4921. Mtime: time.Now().Unix(),
  4922. Status: 1,
  4923. Number: chrg_bchno,
  4924. Infcode: res.Infcode,
  4925. WarnMsg: res.WarnMsg,
  4926. Cainfo: res.Cainfo,
  4927. ErrMsg: res.ErrMsg,
  4928. RespondTime: res.RefmsgTime,
  4929. InfRefmsgid: res.InfRefmsgid,
  4930. OrderStatus: 1,
  4931. IsMedicineInsurance: 1,
  4932. SettleType: settle_accounts_type,
  4933. SettleStartTime: start_time,
  4934. SettleEndTime: end_time,
  4935. Creator: roles.AdminUserId,
  4936. Modify: roles.AdminUserId,
  4937. PType: 2,
  4938. Diagnosis: diagnosis_id,
  4939. }
  4940. err = service.CreateOrder(order)
  4941. if err != nil {
  4942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4943. return
  4944. }
  4945. for _, item := range res.Output.Result {
  4946. temp := strings.Split(item.FeedetlSn, "-")
  4947. var advice_id int64 = 0
  4948. var project_id int64 = 0
  4949. var types int64 = 0
  4950. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4951. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4952. if temp[1] == "1" {
  4953. advice_id = id
  4954. project_id = 0
  4955. } else if temp[1] == "2" {
  4956. advice_id = 0
  4957. project_id = id
  4958. }
  4959. info := &models.HisOrderInfo{
  4960. OrderNumber: order.Number,
  4961. FeedetlSn: item.FeedetlSn,
  4962. UploadDate: time.Now().Unix(),
  4963. AdviceId: advice_id,
  4964. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4965. Cnt: item.Cnt,
  4966. Pric: float64(item.Pric),
  4967. PatientId: his.PatientId,
  4968. PricUplmtAmt: item.PricUplmtAmt,
  4969. SelfpayProp: item.SelfpayProp,
  4970. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4971. OverlmtAmt: item.OverlmtAmt,
  4972. PreselfpayAmt: item.PreselfpayAmt,
  4973. BasMednFlag: item.BasMednFlag,
  4974. MedChrgitmType: item.MedChrgitmType,
  4975. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4976. Status: 1,
  4977. Memo: item.Memo,
  4978. Mtime: time.Now().Unix(),
  4979. InscpScpAmt: item.InscpScpAmt,
  4980. DrtReimFlag: item.DrtReimFlag,
  4981. Ctime: time.Now().Unix(),
  4982. ListSpItemFlag: item.ListSpItemFlag,
  4983. ChldMedcFlag: item.ChldMedcFlag,
  4984. LmtUsedFlag: item.LmtUsedFlag,
  4985. ChrgitmLv: item.ChrgitmLv,
  4986. UserOrgId: adminUser.CurrentOrgId,
  4987. HisPatientId: his.ID,
  4988. OrderId: order.ID,
  4989. ProjectId: project_id,
  4990. Type: types,
  4991. }
  4992. service.CreateOrderInfo(info)
  4993. }
  4994. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4995. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4996. var total float64
  4997. for _, item := range prescriptions {
  4998. if item.Type == 1 { //药品
  4999. for _, subItem := range item.HisDoctorAdviceInfo {
  5000. total = total + (subItem.Price * subItem.PrescribingNumber)
  5001. }
  5002. }
  5003. if item.Type == 2 { //项目
  5004. for _, subItem := range item.HisPrescriptionProject {
  5005. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5006. total = total + (subItem.Price * cnt)
  5007. }
  5008. }
  5009. }
  5010. for _, item := range prescriptions {
  5011. for _, subItem := range item.HisAdditionalCharge {
  5012. total = total + (subItem.Price * float64(subItem.Count))
  5013. }
  5014. }
  5015. allTotal := fmt.Sprintf("%.4f", total)
  5016. if res.Infcode == 0 {
  5017. var rf []*ResultFive
  5018. json.Unmarshal([]byte(his.Iinfo), &rf)
  5019. chrg_bchno := chrg_bchno
  5020. cert_no := his.Certno
  5021. var insutypes []string
  5022. var insutype string
  5023. var is390 int = 0
  5024. var is310 int = 0
  5025. for _, item := range rf {
  5026. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5027. insutypes = append(insutypes, item.Insutype)
  5028. }
  5029. }
  5030. if len(insutypes) == 1 {
  5031. insutype = insutypes[0]
  5032. } else {
  5033. for _, i := range insutypes {
  5034. if i == "390" {
  5035. is390 = 1
  5036. }
  5037. if i == "310" {
  5038. is310 = 1
  5039. }
  5040. }
  5041. }
  5042. if is390 == 1 {
  5043. insutype = "390"
  5044. }
  5045. if is310 == 1 {
  5046. insutype = "310"
  5047. }
  5048. if len(insutypes) == 0 {
  5049. insutype = "310"
  5050. }
  5051. if len(insutypes) == 2 {
  5052. insutype = strconv.FormatInt(his.SocialType, 64)
  5053. }
  5054. //insutype = "390"
  5055. if his.IdCardType == 1 {
  5056. cert_no = his.MedicalInsuranceNumber
  5057. } else {
  5058. cert_no = his.Certno
  5059. }
  5060. var res ResultSeven
  5061. var resSeven10265 ResultSeven10265
  5062. if miConfig.MdtrtareaAdmvs == "421300" {
  5063. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5064. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5065. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5066. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5067. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5068. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5069. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5070. resp, requestErr := http.Get(api)
  5071. if requestErr != nil {
  5072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5073. return
  5074. }
  5075. body, ioErr := ioutil.ReadAll(resp.Body)
  5076. if ioErr != nil {
  5077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5079. return
  5080. }
  5081. var respJSON map[string]interface{}
  5082. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5085. return
  5086. }
  5087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5088. result, _ := json.Marshal(respJSON)
  5089. fmt.Println("log")
  5090. fmt.Println(string(result))
  5091. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5092. utils.ErrorLog("解析失败:%v", err)
  5093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5094. return
  5095. }
  5096. } else {
  5097. var result string
  5098. var request_log string
  5099. if miConfig.Code == "H15049901371" {
  5100. //赤峰地区国家医保医疗类别
  5101. //职工透析:医疗类别选特殊情况门诊990502
  5102. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5103. var med_type string
  5104. if his.Insutype == "390" {
  5105. if reg_type == 14 {
  5106. med_type = "9933"
  5107. } else if reg_type == 11 {
  5108. med_type = "11"
  5109. }
  5110. } else if his.Insutype == "310" {
  5111. if reg_type == 14 {
  5112. med_type = "990502"
  5113. } else if reg_type == 11 {
  5114. med_type = "11"
  5115. }
  5116. }
  5117. 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)
  5118. } else {
  5119. result, request_log = service.Gdyb2206(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)
  5120. }
  5121. var dat map[string]interface{}
  5122. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5123. fmt.Println(dat)
  5124. } else {
  5125. fmt.Println(err)
  5126. }
  5127. saveLog(result, request_log, "2206", "预结算")
  5128. //userJSONBytes, _ := json.Marshal(dat)
  5129. //
  5130. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5131. // utils.ErrorLog("解析失败:%v", err)
  5132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5133. // return
  5134. //}
  5135. userJSONBytes, _ := json.Marshal(dat)
  5136. if miConfig.Code == "H15049901371" {
  5137. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5138. utils.ErrorLog("解析失败:%v", err)
  5139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5140. return
  5141. }
  5142. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5143. res.Output = resSeven10265.Output
  5144. res.ErrMsg = resSeven10265.ErrMsg
  5145. res.Cainfo = resSeven10265.Cainfo
  5146. res.WarnMsg = resSeven10265.WarnMsg
  5147. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5148. res.Infcode = infocode
  5149. } else {
  5150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5151. utils.ErrorLog("解析失败:%v", err)
  5152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5153. return
  5154. }
  5155. }
  5156. }
  5157. if res.Infcode != 0 {
  5158. errlog := &models.HisOrderError{
  5159. UserOrgId: adminUser.CurrentOrgId,
  5160. Ctime: time.Now().Unix(),
  5161. Mtime: time.Now().Unix(),
  5162. Number: chrg_bchno,
  5163. ErrMsg: res.ErrMsg,
  5164. Status: 1,
  5165. PatientId: id,
  5166. RecordTime: recordDateTime,
  5167. Stage: 20,
  5168. }
  5169. service.CreateErrMsgLog(errlog)
  5170. c.ServeSuccessJSON(map[string]interface{}{
  5171. "failed_code": -10,
  5172. "msg": res.ErrMsg,
  5173. })
  5174. return
  5175. } else {
  5176. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5177. order.OrderStatus = 1
  5178. order.IsPre = 1
  5179. order.Status = 1
  5180. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5181. order.SetlId = res.Output.Setlinfo.SetlID
  5182. order.PsnNo = res.Output.Setlinfo.PsnNo
  5183. order.PsnName = res.Output.Setlinfo.PsnName
  5184. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5185. order.Certno = res.Output.Setlinfo.Certno
  5186. order.Gend = res.Output.Setlinfo.Gend
  5187. order.Naty = res.Output.Setlinfo.Naty
  5188. order.Age = res.Output.Setlinfo.Age
  5189. order.Insutype = res.Output.Setlinfo.Insutype
  5190. order.PsnType = res.Output.Setlinfo.PsnType
  5191. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5192. order.SetlTime = res.Output.Setlinfo.SetlTime
  5193. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5194. if res.Output.Setlinfo.MedType == "140101" {
  5195. order.MedType = "14"
  5196. } else {
  5197. order.MedType = res.Output.Setlinfo.MedType
  5198. }
  5199. if reg_type == 1112 {
  5200. order.MedType = "1112"
  5201. }
  5202. if reg_type == 1111 {
  5203. order.MedType = "1111"
  5204. }
  5205. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5206. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5207. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5208. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5209. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5210. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5211. order.HifpPay = res.Output.Setlinfo.HifpPay
  5212. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5213. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5214. order.HifesPay = res.Output.Setlinfo.HifesPay
  5215. order.HifobPay = res.Output.Setlinfo.HifobPay
  5216. order.MafPay = res.Output.Setlinfo.MafPay
  5217. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5218. order.OthPay = res.Output.Setlinfo.OthPay
  5219. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5220. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5221. order.AcctPay = res.Output.Setlinfo.AcctPay
  5222. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5223. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5224. order.Balc = res.Output.Setlinfo.Balc
  5225. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5226. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5227. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5228. order.ClrWay = res.Output.Setlinfo.ClrWay
  5229. order.Creator = order.Creator
  5230. order.Modify = roles.AdminUserId
  5231. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5232. detailStr := string(setlDetail)
  5233. order.SetlDetail = detailStr
  5234. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5235. err = service.UpDateOrder(order)
  5236. if err == nil {
  5237. c.ServeSuccessJSON(map[string]interface{}{
  5238. "msg": "预结算成功",
  5239. })
  5240. } else {
  5241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5242. return
  5243. }
  5244. }
  5245. } else {
  5246. adminUser := c.GetAdminUserInfo()
  5247. errlog := &models.HisOrderError{
  5248. UserOrgId: adminUser.CurrentOrgId,
  5249. Ctime: time.Now().Unix(),
  5250. Mtime: time.Now().Unix(),
  5251. ErrMsg: res.ErrMsg,
  5252. Status: 1,
  5253. PatientId: id,
  5254. RecordTime: recordDateTime,
  5255. Stage: 4,
  5256. }
  5257. service.CreateErrMsgLog(errlog)
  5258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5259. return
  5260. }
  5261. } else {
  5262. adminUser := c.GetAdminUserInfo()
  5263. errlog := &models.HisOrderError{
  5264. UserOrgId: adminUser.CurrentOrgId,
  5265. Ctime: time.Now().Unix(),
  5266. Mtime: time.Now().Unix(),
  5267. ErrMsg: res.ErrMsg,
  5268. Status: 1,
  5269. PatientId: id,
  5270. RecordTime: recordDateTime,
  5271. Stage: 4,
  5272. }
  5273. service.CreateErrMsgLog(errlog)
  5274. c.ServeSuccessJSON(map[string]interface{}{
  5275. "failed_code": -10,
  5276. "msg": res.ErrMsg,
  5277. })
  5278. return
  5279. }
  5280. }
  5281. }
  5282. }
  5283. //func (c *HisApiController) GetSettleInfo() {
  5284. // id, _ := c.GetInt64("id")
  5285. // order_id, _ := c.GetInt64("order_id")
  5286. //
  5287. // record_time := c.GetString("record_time")
  5288. // pay_way, _ := c.GetInt64("pay_way")
  5289. // pay_price, _ := c.GetFloat("pay_price")
  5290. // pay_card_no := c.GetString("pay_card_no")
  5291. // discount_price, _ := c.GetFloat("discount_price")
  5292. // preferential_price, _ := c.GetFloat("preferential_price")
  5293. // reality_price, _ := c.GetFloat("reality_price")
  5294. // found_price, _ := c.GetFloat("found_price")
  5295. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5296. // private_price, _ := c.GetFloat("private_price")
  5297. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5298. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5299. //
  5300. // timeLayout := "2006-01-02"
  5301. // loc, _ := time.LoadLocation("Local")
  5302. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5303. // if err != nil {
  5304. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5305. // return
  5306. // }
  5307. // recordDateTime := theTime.Unix()
  5308. // adminUser := c.GetAdminUserInfo()
  5309. //
  5310. // var prescriptions []*models.HisPrescription
  5311. //
  5312. // data := make(map[string]interface{})
  5313. // if settle_accounts_type == 1 { //日结
  5314. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5315. // data["pre"] = prescriptions
  5316. //
  5317. // } else { //月结
  5318. // start_time_str := c.GetString("start_time")
  5319. // end_time_str := c.GetString("end_time")
  5320. // timeLayout := "2006-01-02"
  5321. // loc, _ := time.LoadLocation("Local")
  5322. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5323. // if err != nil {
  5324. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5325. // return
  5326. // }
  5327. // recordStartTime := theStartTime.Unix()
  5328. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5329. // if err != nil {
  5330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5331. // return
  5332. // }
  5333. // recordEndTime := theEndTime.Unix()
  5334. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5335. // data["pre"] = prescriptions
  5336. //
  5337. // }
  5338. //
  5339. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5340. //
  5341. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5342. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5343. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5344. // strconv.FormatInt(his.PatientId, 10)
  5345. //
  5346. // order_src, _ := service.GetHisOrderByID(order_id)
  5347. //
  5348. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5349. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5350. //
  5351. // var total float64
  5352. // for _, item := range prescriptions {
  5353. // if item.Type == 1 { //药品
  5354. // for _, subItem := range item.HisDoctorAdviceInfo {
  5355. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5356. // }
  5357. // }
  5358. // if item.Type == 2 { //项目
  5359. // for _, subItem := range item.HisPrescriptionProject {
  5360. // total = total + (subItem.Price * float64(subItem.Count))
  5361. // }
  5362. // }
  5363. // }
  5364. //
  5365. // for _, item := range prescriptions {
  5366. // for _, subItem := range item.HisAdditionalCharge {
  5367. // total = total + (subItem.Price * float64(subItem.Count))
  5368. // }
  5369. // }
  5370. //
  5371. // allTotal := fmt.Sprintf("%.2f", total)
  5372. // var rf []*ResultFive
  5373. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5374. // psn_no := order_src.PsnNo
  5375. // mdtrt_id := order_src.MdtrtId
  5376. // chrg_bchno := order_src.Number
  5377. // cert_no := order_src.Certno
  5378. // insutype := rf[0].Insutype
  5379. //
  5380. // if his.IdCardType == 1 {
  5381. // cert_no = his.MedicalInsuranceNumber
  5382. // } else {
  5383. // cert_no = his.Certno
  5384. // }
  5385. //
  5386. // 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)
  5387. // var dat map[string]interface{}
  5388. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5389. // fmt.Println(dat)
  5390. // } else {
  5391. // fmt.Println(err)
  5392. // }
  5393. //
  5394. // userJSONBytes, _ := json.Marshal(dat)
  5395. //
  5396. //
  5397. //
  5398. // var res ResultSeven
  5399. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5400. // utils.ErrorLog("解析失败:%v", err)
  5401. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5402. // return
  5403. // }
  5404. // if res.Infcode == -1 {
  5405. // errlog := &models.HisOrderError{
  5406. // UserOrgId: adminUser.CurrentOrgId,
  5407. // Ctime: time.Now().Unix(),
  5408. // Mtime: time.Now().Unix(),
  5409. // Number: chrg_bchno,
  5410. // ErrMsg: res.ErrMsg,
  5411. // Status: 1,
  5412. // PatientId: id,
  5413. // RecordTime: recordDateTime,
  5414. // Stage: 6,
  5415. // }
  5416. // service.CreateErrMsgLog(errlog)
  5417. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5418. // return
  5419. // } else {
  5420. // order_src.OrderStatus = 2
  5421. // order_src.PayWay = pay_way
  5422. // order_src.PayPrice = pay_price
  5423. // order_src.PayCardNo = pay_card_no
  5424. // order_src.DiscountPrice = discount_price
  5425. // order_src.PreferentialPrice = preferential_price
  5426. // order_src.RealityPrice = reality_price
  5427. // order_src.FoundPrice = found_price
  5428. // order_src.MedicalInsurancePrice = medical_insurance_price
  5429. // order_src.PrivatePrice = private_price
  5430. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  5431. // order_src.SetlId = res.Output.Setlinfo.SetlID
  5432. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  5433. // order_src.PsnName = res.Output.Setlinfo.PsnName
  5434. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  5435. // order_src.Certno = res.Output.Setlinfo.Certno
  5436. // order_src.Gend = res.Output.Setlinfo.Gend
  5437. // order_src.Naty = res.Output.Setlinfo.Naty
  5438. // order_src.Age = res.Output.Setlinfo.Age
  5439. // order_src.Insutype = res.Output.Setlinfo.Insutype
  5440. // order_src.PsnType = res.Output.Setlinfo.PsnType
  5441. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5442. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  5443. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5444. // order_src.MedType = res.Output.Setlinfo.MedType
  5445. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5446. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5447. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5448. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5449. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5450. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5451. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  5452. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  5453. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5454. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  5455. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  5456. // order_src.MafPay = res.Output.Setlinfo.MafPay
  5457. // order_src.OthPay = res.Output.Setlinfo.OthPay
  5458. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5459. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5460. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  5461. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5462. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5463. // order_src.Balc = res.Output.Setlinfo.Balc
  5464. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5465. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5466. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  5467. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  5468. // order_src.Creator = order_src.Creator
  5469. // order_src.Modify = roles.ID
  5470. // order_src.RequestLog = src_resquest
  5471. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5472. // detailStr := string(setlDetail)
  5473. // order_src.SetlDetail = detailStr
  5474. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5475. // err = service.UpDateOrder(order_src)
  5476. //
  5477. // if err == nil {
  5478. // c.ServeSuccessJSON(map[string]interface{}{
  5479. // "msg": "结算成功",
  5480. // })
  5481. // } else {
  5482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5483. // return
  5484. // }
  5485. // }
  5486. // }
  5487. //}
  5488. //退款
  5489. func (c *HisApiController) Refund() {
  5490. order_id, _ := c.GetInt64("order_id")
  5491. admin_user_id, _ := c.GetInt64("admin_user_id")
  5492. adminUser := c.GetAdminUserInfo()
  5493. var order models.HisOrder
  5494. order, _ = service.GetHisOrderByID(order_id)
  5495. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5496. if order.ID == 0 {
  5497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5498. return
  5499. }
  5500. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5501. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5502. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5503. if config.IsOpen == 1 { //对接了医保,走医保流程
  5504. var res ResultSixteen
  5505. var resSixteen10265 ResultSixteen10265
  5506. var src_resquest string
  5507. var result string
  5508. if miConfig.MdtrtareaAdmvs == "421300" {
  5509. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  5510. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5511. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5512. resp3, requestErr3 := http.Get(api3)
  5513. if requestErr3 != nil {
  5514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5515. return
  5516. }
  5517. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5518. if ioErr3 != nil {
  5519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5521. return
  5522. }
  5523. var respJSON3 map[string]interface{}
  5524. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5527. return
  5528. }
  5529. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5530. userJSONBytes3, _ := json.Marshal(respJSON3)
  5531. fmt.Println("log")
  5532. fmt.Println(string(userJSONBytes3))
  5533. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5534. utils.ErrorLog("解析失败:%v", err)
  5535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5536. return
  5537. }
  5538. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5539. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  5540. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5541. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5542. resp3, requestErr3 := http.Get(api3)
  5543. if requestErr3 != nil {
  5544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5545. return
  5546. }
  5547. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5548. if ioErr3 != nil {
  5549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5551. return
  5552. }
  5553. var respJSON3 map[string]interface{}
  5554. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5557. return
  5558. }
  5559. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5560. userJSONBytes3, _ := json.Marshal(respJSON3)
  5561. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5562. utils.ErrorLog("解析失败:%v", err)
  5563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5564. return
  5565. }
  5566. } else {
  5567. if miConfig.Code == "H15049901371" {
  5568. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5569. var dat map[string]interface{}
  5570. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5571. fmt.Println(dat)
  5572. } else {
  5573. fmt.Println(err)
  5574. }
  5575. saveLog(result, src_resquest, "2208", "退费")
  5576. userJSONBytes, _ := json.Marshal(dat)
  5577. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  5578. utils.ErrorLog("解析失败:%v", err)
  5579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5580. return
  5581. }
  5582. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5583. res.Output = resSixteen10265.Output
  5584. res.ErrMsg = resSixteen10265.ErrMsg
  5585. res.Cainfo = resSixteen10265.Cainfo
  5586. res.WarnMsg = resSixteen10265.WarnMsg
  5587. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5588. res.Infcode = infocode
  5589. } else {
  5590. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5591. var dat map[string]interface{}
  5592. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5593. fmt.Println(dat)
  5594. } else {
  5595. fmt.Println(err)
  5596. }
  5597. saveLog(result, src_resquest, "2208", "退费")
  5598. userJSONBytes, _ := json.Marshal(dat)
  5599. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5600. utils.ErrorLog("解析失败:%v", err)
  5601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5602. return
  5603. }
  5604. }
  5605. }
  5606. if res.Infcode == 0 {
  5607. var res2 ResultSix
  5608. var resSix10265 ResultSix10265
  5609. if miConfig.MdtrtareaAdmvs == "421300" {
  5610. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  5611. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5612. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5613. resp3, requestErr3 := http.Get(api3)
  5614. if requestErr3 != nil {
  5615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5616. return
  5617. }
  5618. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5619. if ioErr3 != nil {
  5620. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5622. return
  5623. }
  5624. var respJSON3 map[string]interface{}
  5625. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5628. return
  5629. }
  5630. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5631. userJSONBytes3, _ := json.Marshal(respJSON3)
  5632. fmt.Println("log")
  5633. fmt.Println(string(userJSONBytes3))
  5634. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5635. utils.ErrorLog("解析失败:%v", err)
  5636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5637. return
  5638. }
  5639. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5640. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  5641. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5642. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5643. resp3, requestErr3 := http.Get(api3)
  5644. if requestErr3 != nil {
  5645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5646. return
  5647. }
  5648. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5649. if ioErr3 != nil {
  5650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5652. return
  5653. }
  5654. var respJSON3 map[string]interface{}
  5655. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5658. return
  5659. }
  5660. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5661. userJSONBytes3, _ := json.Marshal(respJSON3)
  5662. fmt.Println("log")
  5663. fmt.Println(string(userJSONBytes3))
  5664. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5665. utils.ErrorLog("解析失败:%v", err)
  5666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5667. return
  5668. }
  5669. } else {
  5670. if miConfig.Code == "H15049901371" {
  5671. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5672. var dat map[string]interface{}
  5673. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5674. fmt.Println(dat)
  5675. } else {
  5676. fmt.Println(err)
  5677. }
  5678. saveLog(result2, src_request, "2205", "撤销明细")
  5679. userJSONBytes, _ := json.Marshal(dat)
  5680. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5681. utils.ErrorLog("解析失败:%v", err)
  5682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5683. return
  5684. }
  5685. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5686. res2.Output = resSix10265.Output
  5687. res2.ErrMsg = resSix10265.ErrMsg
  5688. res2.Cainfo = resSix10265.Cainfo
  5689. res2.WarnMsg = resSix10265.WarnMsg
  5690. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5691. res2.Infcode = infocode
  5692. } else {
  5693. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5694. var dat map[string]interface{}
  5695. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5696. fmt.Println(dat)
  5697. } else {
  5698. fmt.Println(err)
  5699. }
  5700. saveLog(result2, src_request, "2205", "撤销明细")
  5701. userJSONBytes, _ := json.Marshal(dat)
  5702. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5703. utils.ErrorLog("解析失败:%v", err)
  5704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5705. return
  5706. }
  5707. }
  5708. }
  5709. if res2.Infcode == 0 {
  5710. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  5711. if err == nil {
  5712. c.ServeSuccessJSON(map[string]interface{}{
  5713. "msg": "退费成功",
  5714. })
  5715. } else {
  5716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5717. return
  5718. }
  5719. } else {
  5720. c.ServeSuccessJSON(map[string]interface{}{
  5721. "code": -10,
  5722. "msg": res2.ErrMsg,
  5723. })
  5724. }
  5725. } else {
  5726. c.ServeSuccessJSON(map[string]interface{}{
  5727. "code": -10,
  5728. "msg": res.ErrMsg,
  5729. })
  5730. }
  5731. }
  5732. }
  5733. func (c *HisApiController) RefundNumber() {
  5734. record_time := c.GetString("record_time")
  5735. //patient_id, _ := c.GetInt64("patient_id")
  5736. admin_user_id, _ := c.GetInt64("admin_user_id")
  5737. his_patient_id, _ := c.GetInt64("id")
  5738. timeLayout := "2006-01-02"
  5739. loc, _ := time.LoadLocation("Local")
  5740. adminUser := c.GetAdminUserInfo()
  5741. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5742. fmt.Println(err)
  5743. if err != nil {
  5744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5745. return
  5746. }
  5747. recordDateTime := theTime.Unix()
  5748. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5749. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  5750. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5751. //order, _ := service.GetHisOrderByID(order_id)
  5752. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5753. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5754. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5755. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  5756. if count > 0 {
  5757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  5758. return
  5759. }
  5760. if config.IsOpen == 1 { //对接了医保,走医保流程
  5761. var res2 ResultSix
  5762. var resSix10265 ResultSix10265
  5763. if miConfig.MdtrtareaAdmvs == "421300" {
  5764. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  5765. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5766. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5767. resp3, requestErr3 := http.Get(api3)
  5768. if requestErr3 != nil {
  5769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5770. return
  5771. }
  5772. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5773. if ioErr3 != nil {
  5774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5776. return
  5777. }
  5778. var respJSON3 map[string]interface{}
  5779. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5782. return
  5783. }
  5784. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5785. userJSONBytes3, _ := json.Marshal(respJSON3)
  5786. fmt.Println("log")
  5787. fmt.Println(string(userJSONBytes3))
  5788. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5789. utils.ErrorLog("解析失败:%v", err)
  5790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5791. return
  5792. }
  5793. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5794. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  5795. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5796. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5797. resp3, requestErr3 := http.Get(api3)
  5798. if requestErr3 != nil {
  5799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5800. return
  5801. }
  5802. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5803. if ioErr3 != nil {
  5804. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5806. return
  5807. }
  5808. var respJSON3 map[string]interface{}
  5809. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5812. return
  5813. }
  5814. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5815. userJSONBytes3, _ := json.Marshal(respJSON3)
  5816. fmt.Println("log")
  5817. fmt.Println(string(userJSONBytes3))
  5818. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5819. utils.ErrorLog("解析失败:%v", err)
  5820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5821. return
  5822. }
  5823. } else {
  5824. var api3 string
  5825. if miConfig.Code == "H15049901371" {
  5826. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  5827. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5828. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5829. } else {
  5830. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  5831. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5832. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5833. }
  5834. resp3, requestErr3 := http.Get(api3)
  5835. if requestErr3 != nil {
  5836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5837. return
  5838. }
  5839. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5840. if ioErr3 != nil {
  5841. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5843. return
  5844. }
  5845. var respJSON3 map[string]interface{}
  5846. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5849. return
  5850. }
  5851. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5852. userJSONBytes3, _ := json.Marshal(respJSON3)
  5853. if miConfig.Code == "H15049901371" {
  5854. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  5855. utils.ErrorLog("解析失败:%v", err)
  5856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5857. return
  5858. }
  5859. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5860. res2.Output = resSix10265.Output
  5861. res2.ErrMsg = resSix10265.ErrMsg
  5862. res2.Cainfo = resSix10265.Cainfo
  5863. res2.WarnMsg = resSix10265.WarnMsg
  5864. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5865. res2.Infcode = infocode
  5866. } else {
  5867. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5868. utils.ErrorLog("解析失败:%v", err)
  5869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5870. return
  5871. }
  5872. }
  5873. }
  5874. if res2.Infcode == 0 {
  5875. if err == nil {
  5876. c.ServeSuccessJSON(map[string]interface{}{
  5877. "msg": "退号成功",
  5878. })
  5879. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  5880. } else {
  5881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5882. return
  5883. }
  5884. } else {
  5885. c.ServeSuccessJSON(map[string]interface{}{
  5886. "code": -10,
  5887. "msg": res2.ErrMsg,
  5888. })
  5889. }
  5890. } else {
  5891. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  5892. //if err == nil {
  5893. // c.ServeSuccessJSON(map[string]interface{}{
  5894. // "msg": "退费成功",
  5895. // })
  5896. //} else {
  5897. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5898. // return
  5899. //}
  5900. }
  5901. }
  5902. func (c *HisApiController) RefundDetail() {
  5903. order_id, _ := c.GetInt64("order_id")
  5904. //admin_user_id, _ := c.GetInt64("admin_user_id")
  5905. //his_patient_id, _ := c.GetInt64("his_patient_id")
  5906. number := c.GetString("number")
  5907. record_time := c.GetString("record_time")
  5908. patient_id, _ := c.GetInt64("patient_id")
  5909. timeLayout := "2006-01-02"
  5910. loc, _ := time.LoadLocation("Local")
  5911. adminUser := c.GetAdminUserInfo()
  5912. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5913. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5914. fmt.Println(err)
  5915. if err != nil {
  5916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5917. return
  5918. }
  5919. recordDateTime := theTime.Unix()
  5920. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5921. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5922. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5923. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5924. var order models.HisOrder
  5925. order, _ = service.GetHisOrderByID(order_id)
  5926. if order.ID == 0 {
  5927. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  5928. }
  5929. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5930. if config.IsOpen == 1 { //对接了医保,走医保流程
  5931. var res2 ResultSix
  5932. if miConfig.MdtrtareaAdmvs == "421300" {
  5933. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  5934. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5935. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5936. resp3, requestErr3 := http.Get(api3)
  5937. if requestErr3 != nil {
  5938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5939. return
  5940. }
  5941. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5942. if ioErr3 != nil {
  5943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5945. return
  5946. }
  5947. var respJSON3 map[string]interface{}
  5948. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5949. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5951. return
  5952. }
  5953. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5954. userJSONBytes3, _ := json.Marshal(respJSON3)
  5955. fmt.Println("log")
  5956. fmt.Println(string(userJSONBytes3))
  5957. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5958. utils.ErrorLog("解析失败:%v", err)
  5959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5960. return
  5961. }
  5962. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  5963. if err == nil {
  5964. c.ServeSuccessJSON(map[string]interface{}{
  5965. "msg": "撤销明细成功",
  5966. })
  5967. return
  5968. } else {
  5969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5970. return
  5971. }
  5972. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5973. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  5974. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5975. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5976. resp3, requestErr3 := http.Get(api3)
  5977. if requestErr3 != nil {
  5978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5979. return
  5980. }
  5981. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5982. if ioErr3 != nil {
  5983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5985. return
  5986. }
  5987. var respJSON3 map[string]interface{}
  5988. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5991. return
  5992. }
  5993. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5994. userJSONBytes3, _ := json.Marshal(respJSON3)
  5995. fmt.Println("log")
  5996. fmt.Println(string(userJSONBytes3))
  5997. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5998. utils.ErrorLog("解析失败:%v", err)
  5999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6000. return
  6001. }
  6002. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6003. if err == nil {
  6004. c.ServeSuccessJSON(map[string]interface{}{
  6005. "msg": "撤销明细成功",
  6006. })
  6007. return
  6008. } else {
  6009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6010. return
  6011. }
  6012. } else {
  6013. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6014. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6015. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6016. resp2, requestErr2 := http.Get(api2)
  6017. if requestErr2 != nil {
  6018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6019. return
  6020. }
  6021. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6022. if ioErr2 != nil {
  6023. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6025. return
  6026. }
  6027. var respJSON2 map[string]interface{}
  6028. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6031. return
  6032. }
  6033. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6034. if err == nil {
  6035. c.ServeSuccessJSON(map[string]interface{}{
  6036. "msg": "撤销明细成功",
  6037. })
  6038. return
  6039. } else {
  6040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6041. return
  6042. }
  6043. }
  6044. } else {
  6045. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6046. if err == nil {
  6047. c.ServeSuccessJSON(map[string]interface{}{
  6048. "msg": "退费成功",
  6049. })
  6050. } else {
  6051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6052. return
  6053. }
  6054. }
  6055. }
  6056. //对账
  6057. func (c *HisApiController) GetCheckAccount() {
  6058. start_time := c.GetString("start_time")
  6059. end_time := c.GetString("end_time")
  6060. insutype := c.GetString("insutype")
  6061. clr_type := c.GetString("clr_type")
  6062. clr_org := c.GetString("clr_optins")
  6063. admin_user_id, _ := c.GetInt64("admin_user_id")
  6064. adminUser := c.GetAdminUserInfo()
  6065. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6066. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6067. if len(clr_org) == 0 {
  6068. clr_org = miConfig.MdtrtareaAdmvs
  6069. }
  6070. timeLayout := "2006-01-02"
  6071. loc, _ := time.LoadLocation("Local")
  6072. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6073. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6074. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6075. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  6076. fixmedins_setl_cnt := int64(len(orders))
  6077. //
  6078. ////撤销的算2条数据为一笔
  6079. //for _, item := range orders_two {
  6080. // if item.OrderStatus == 3 {
  6081. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  6082. // }
  6083. //}
  6084. var medfee_sumamt float64
  6085. var acct_pay float64
  6086. var fund_pay_sumamt float64
  6087. for _, item := range orders {
  6088. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6089. acct_pay = acct_pay + item.AcctPay
  6090. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6091. }
  6092. var user_name string
  6093. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6094. if role.ID == 0 {
  6095. user_name = "xxx"
  6096. } else {
  6097. user_name = role.UserName
  6098. }
  6099. if config.IsOpen == 1 {
  6100. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6101. "insutype=" + insutype +
  6102. "&clr_type=" + clr_type +
  6103. "&setl_optins=" + clr_org +
  6104. "&stmt_begndate=" + start_time +
  6105. "&stm_enddate=" + end_time +
  6106. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6107. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6108. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  6109. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6110. "&fixmedins_code=" + miConfig.Code +
  6111. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6112. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6113. "&secret_key=" + miConfig.SecretKey +
  6114. "&org_name=" + miConfig.OrgName +
  6115. "&doctor=" + user_name
  6116. fmt.Println(api)
  6117. resp, requestErr := http.Get(api)
  6118. if requestErr != nil {
  6119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6120. return
  6121. }
  6122. body, ioErr := ioutil.ReadAll(resp.Body)
  6123. fmt.Println(body)
  6124. if ioErr != nil {
  6125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6127. return
  6128. }
  6129. var respJSON map[string]interface{}
  6130. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6133. return
  6134. }
  6135. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6136. userJSONBytes, _ := json.Marshal(respJSON)
  6137. var res ResultEight
  6138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6139. utils.ErrorLog("解析失败:%v", err)
  6140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6141. return
  6142. }
  6143. if res.Infcode == 0 {
  6144. if res.Output.Stmtinfo.StmtRslt == "0" {
  6145. micc := &models.MedicalInsuranceCostCompare{
  6146. StartTime: startime.Unix(),
  6147. EndTime: endtime.Unix(),
  6148. Insutype: insutype,
  6149. CheckType: 1,
  6150. Num: fixmedins_setl_cnt,
  6151. Mtime: time.Now().Unix(),
  6152. Status: 1,
  6153. UserOrgId: adminUser.CurrentOrgId,
  6154. CostTotal: medfee_sumamt,
  6155. FuncTotal: fund_pay_sumamt,
  6156. PsnPay: acct_pay,
  6157. Creator: admin_user_id,
  6158. Ctime: time.Now().Unix(),
  6159. }
  6160. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  6161. if err == nil {
  6162. c.ServeSuccessJSON(map[string]interface{}{
  6163. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6164. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6165. })
  6166. } else {
  6167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6168. }
  6169. } else {
  6170. c.ServeSuccessJSON(map[string]interface{}{
  6171. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6172. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6173. })
  6174. }
  6175. } else {
  6176. c.ServeSuccessJSON(map[string]interface{}{
  6177. "code": -10,
  6178. "msg": res.ErrMsg,
  6179. })
  6180. }
  6181. }
  6182. }
  6183. func (c *HisApiController) Check310() {
  6184. adminUser := c.GetAdminUserInfo()
  6185. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6186. var user_name string
  6187. user_name = "xxx"
  6188. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6189. "insutype=" + "310" +
  6190. "&clr_type=" + "11" +
  6191. "&setl_optins=" + "定点医保中心" +
  6192. "&stmt_begndate=" + "2021-03-01" +
  6193. "&stm_enddate=" + "2021-03-31" +
  6194. "&medfee_sumamt=" + "11521" +
  6195. "&fund_pay_sumamt=" + "10166.66" +
  6196. "&acct_pay=" + "0" +
  6197. "&fixmedins_setl_cnt=" + "7" +
  6198. "&fixmedins_code=" + miConfig.Code +
  6199. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6200. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6201. "&secret_key=" + miConfig.SecretKey +
  6202. "&org_name=" + miConfig.OrgName +
  6203. "&doctor=" + user_name
  6204. fmt.Println(api)
  6205. resp, requestErr := http.Get(api)
  6206. if requestErr != nil {
  6207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6208. return
  6209. }
  6210. body, ioErr := ioutil.ReadAll(resp.Body)
  6211. fmt.Println(body)
  6212. if ioErr != nil {
  6213. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6215. return
  6216. }
  6217. var respJSON map[string]interface{}
  6218. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6221. return
  6222. }
  6223. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6224. userJSONBytes, _ := json.Marshal(respJSON)
  6225. var res ResultEight
  6226. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6227. utils.ErrorLog("解析失败:%v", err)
  6228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6229. return
  6230. }
  6231. }
  6232. func (c *HisApiController) Check390() {
  6233. adminUser := c.GetAdminUserInfo()
  6234. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6235. var user_name string
  6236. user_name = "张俊杰"
  6237. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6238. "insutype=" + "390" +
  6239. "&clr_type=" + "11" +
  6240. "&setl_optins=" + "定点医保中心" +
  6241. "&stmt_begndate=" + "2021-03-01" +
  6242. "&stm_enddate=" + "2021-03-31" +
  6243. "&medfee_sumamt=" + "209318.43" +
  6244. "&fund_pay_sumamt=" + "188029.12" +
  6245. "&acct_pay=" + "0" +
  6246. "&fixmedins_setl_cnt=" + "48" +
  6247. "&fixmedins_code=" + miConfig.Code +
  6248. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6249. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6250. "&secret_key=" + miConfig.SecretKey +
  6251. "&org_name=" + miConfig.OrgName +
  6252. "&doctor=" + user_name
  6253. fmt.Println(api)
  6254. resp, requestErr := http.Get(api)
  6255. if requestErr != nil {
  6256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6257. return
  6258. }
  6259. body, ioErr := ioutil.ReadAll(resp.Body)
  6260. fmt.Println(body)
  6261. if ioErr != nil {
  6262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6264. return
  6265. }
  6266. var respJSON map[string]interface{}
  6267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6270. return
  6271. }
  6272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6273. userJSONBytes, _ := json.Marshal(respJSON)
  6274. var res ResultEight
  6275. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6276. utils.ErrorLog("解析失败:%v", err)
  6277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6278. return
  6279. }
  6280. }
  6281. //对账明细
  6282. func (c *HisApiController) GetCheckDetailAccount() {
  6283. start_time := c.GetString("start_time")
  6284. end_time := c.GetString("end_time")
  6285. admin_user_id, _ := c.GetInt64("admin_user_id")
  6286. adminUser := c.GetAdminUserInfo()
  6287. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6288. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6289. timeLayout := "2006-01-02"
  6290. loc, _ := time.LoadLocation("Local")
  6291. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6292. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6293. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  6294. Mkdir(miConfig.OrgName)
  6295. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  6296. file_name := file + ".txt"
  6297. zip_name := file + ".zip"
  6298. zip_path := miConfig.OrgName + "/" + zip_name
  6299. file_path := miConfig.OrgName + "/" + file_name
  6300. decimal.DivisionPrecision = 2
  6301. var medfee_sumamt float64
  6302. var psn_cash_pay float64
  6303. var fund_pay_sumamt float64
  6304. fixmedins_setl_cnt := int64(len(orders))
  6305. for _, item := range orders {
  6306. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6307. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  6308. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6309. }
  6310. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  6311. defer f.Close()
  6312. if err != nil {
  6313. fmt.Println(err.Error())
  6314. } else {
  6315. for _, item := range orders {
  6316. var refd_setl_flag string
  6317. if item.OrderStatus == 2 {
  6318. refd_setl_flag = "0"
  6319. var str string
  6320. str = item.SetlId + " " +
  6321. item.MdtrtId + " " +
  6322. item.PsnNo + " " +
  6323. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6324. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6325. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  6326. _, err = f.Write([]byte(str))
  6327. }
  6328. if item.OrderStatus == 3 {
  6329. var str string
  6330. str = item.SetlId + " " +
  6331. item.MdtrtId + " " +
  6332. item.PsnNo + " " +
  6333. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6334. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6335. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  6336. _, err = f.Write([]byte(str))
  6337. var str2 string
  6338. str2 = item.SetlId + " " +
  6339. item.MdtrtId + " " +
  6340. item.PsnNo + " " +
  6341. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  6342. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  6343. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  6344. _, err = f.Write([]byte(str2))
  6345. }
  6346. }
  6347. }
  6348. Zip(file_path, zip_path)
  6349. fmt.Println(ReadFile(zip_path))
  6350. fmt.Println(string(ReadFile(zip_path)))
  6351. if config.IsOpen == 1 {
  6352. var user_name string
  6353. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6354. if role.ID == 0 {
  6355. user_name = "管理员"
  6356. } else {
  6357. user_name = role.UserName
  6358. }
  6359. baseParams := models.BaseParams{
  6360. SecretKey: miConfig.SecretKey,
  6361. FixmedinsCode: miConfig.Code,
  6362. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6363. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6364. OrgName: miConfig.OrgName,
  6365. Doctor: user_name,
  6366. }
  6367. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  6368. var dat map[string]interface{}
  6369. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6370. fmt.Println(dat)
  6371. } else {
  6372. fmt.Println(err)
  6373. }
  6374. userJSONBytes, _ := json.Marshal(dat)
  6375. var res ResultNine
  6376. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6377. utils.ErrorLog("解析失败:%v", err)
  6378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6379. return
  6380. }
  6381. if res.Infcode == 0 {
  6382. fileNo := res.Output.FileQuryNo
  6383. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  6384. "file_qury_no=" + fileNo +
  6385. "&setl_optins=" + "定点医保中心" +
  6386. "&stmt_begndate=" + start_time +
  6387. "&stm_enddate=" + end_time +
  6388. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6389. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6390. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  6391. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6392. "&fixmedins_code=" + miConfig.Code +
  6393. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6394. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6395. "&secret_key=" + miConfig.SecretKey +
  6396. "&org_name=" + miConfig.OrgName +
  6397. "&doctor=" + user_name
  6398. resp, requestErr := http.Get(api)
  6399. if requestErr != nil {
  6400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6401. return
  6402. }
  6403. body, ioErr := ioutil.ReadAll(resp.Body)
  6404. if ioErr != nil {
  6405. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6407. return
  6408. }
  6409. var respJSON map[string]interface{}
  6410. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6413. return
  6414. }
  6415. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6416. userJSONBytes, _ := json.Marshal(respJSON)
  6417. var res ResultTen
  6418. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6419. utils.ErrorLog("解析失败:%v", err)
  6420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6421. return
  6422. }
  6423. if res.Infcode == 0 {
  6424. service.Gdyb9102(baseParams, zip_name, fileNo)
  6425. micc := &models.MedicalInsuranceCostCompare{
  6426. StartTime: startime.Unix(),
  6427. EndTime: endtime.Unix(),
  6428. Insutype: "0",
  6429. CheckType: 2,
  6430. Num: fixmedins_setl_cnt,
  6431. Mtime: time.Now().Unix(),
  6432. Status: 1,
  6433. UserOrgId: adminUser.CurrentOrgId,
  6434. CostTotal: medfee_sumamt,
  6435. FuncTotal: fund_pay_sumamt,
  6436. PsnPay: psn_cash_pay,
  6437. Creator: admin_user_id,
  6438. Ctime: time.Now().Unix(),
  6439. }
  6440. service.CreateMedicalInsuranceCostCompareRecord(micc)
  6441. c.ServeSuccessJSON(map[string]interface{}{
  6442. "msg": "明细对账成功",
  6443. })
  6444. }
  6445. } else {
  6446. }
  6447. }
  6448. }
  6449. type CustomOrderInfo struct {
  6450. Name string
  6451. Spec string
  6452. Unit string
  6453. Count float64
  6454. Price float64
  6455. Total float64
  6456. }
  6457. func (c *HisApiController) GetSettleAccounts() {
  6458. //id, _ := c.GetInt64("id")
  6459. //record_time := c.GetString("record_time")
  6460. order_id, _ := c.GetInt64("order_id")
  6461. admin_user_id, _ := c.GetInt64("admin_user_id")
  6462. //timeLayout := "2006-01-02"
  6463. //loc, _ := time.LoadLocation("Local")
  6464. //
  6465. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6466. //if err != nil {
  6467. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6468. // return
  6469. //}
  6470. //recordDateTime := theTime.Unix()
  6471. adminUser := c.GetAdminUserInfo()
  6472. order, _ := service.GetHisOrderByID(order_id)
  6473. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6474. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  6475. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  6476. orderInfos = append(orderInfos, orderInfos_two...)
  6477. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  6478. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6479. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  6480. //var config []*models.HisXtDiagnoseConfig
  6481. var name string
  6482. for _, item := range diagnosis_ids {
  6483. id, _ := strconv.ParseInt(item, 10, 64)
  6484. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6485. if len(name) == 0 {
  6486. name = diagnosisConfig.ClassName
  6487. } else {
  6488. name = name + "," + diagnosisConfig.ClassName
  6489. }
  6490. }
  6491. var bedCostTotal float64 = 0 //床位总费
  6492. var bedCostSelfTotal float64 = 0 //床位自费
  6493. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6494. var operationCostTotal float64 = 0 //手术费
  6495. var operationCostSelfTotal float64 = 0 //手术费
  6496. var operationCostPartSelfTotal float64 = 0 //手术费
  6497. var otherCostTotal float64 = 0 //其他费用
  6498. var otherCostSelfTotal float64 = 0 //其他费用
  6499. var otherCostPartSelfTotal float64 = 0 //其他费用
  6500. var materialCostTotal float64 = 0 //材料费
  6501. var materialCostSelfTotal float64 = 0 //材料费
  6502. var materialCostPartSelfTotal float64 = 0 //材料费
  6503. var westernMedicineCostTotal float64 = 0 //西药费
  6504. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6505. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6506. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6507. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6508. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6509. var checkCostTotal float64 = 0 //检查费
  6510. var checkCostSelfTotal float64 = 0 //检查费
  6511. var checkCostPartSelfTotal float64 = 0 //检查费
  6512. var laboratoryCostTotal float64 = 0 //化验费
  6513. var laboratoryCostSelfTotal float64 = 0 //化验费
  6514. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6515. var treatCostTotal float64 = 0 //治疗费用
  6516. var treatCostSelfTotal float64 = 0 //治疗费用
  6517. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6518. decimal.DivisionPrecision = 2
  6519. for _, item := range orderInfos {
  6520. if item.MedChrgitmType == "01" { //床位费
  6521. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6522. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6523. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6524. }
  6525. if item.MedChrgitmType == "03" { //检查费
  6526. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6527. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6528. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6529. }
  6530. if item.MedChrgitmType == "04" { //化验费
  6531. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6532. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6533. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6534. }
  6535. if item.MedChrgitmType == "05" { //治疗费
  6536. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6537. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6538. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6539. }
  6540. if item.MedChrgitmType == "06" { //手术费
  6541. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6542. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6543. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6544. }
  6545. if item.MedChrgitmType == "08" { //材料费
  6546. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6547. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6548. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6549. }
  6550. if item.MedChrgitmType == "09" { //西药费
  6551. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6552. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6553. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6554. }
  6555. if item.MedChrgitmType == "11" { //中成费
  6556. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6557. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6558. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6559. }
  6560. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  6561. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6562. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6563. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6564. }
  6565. }
  6566. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6567. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6568. var user_name string
  6569. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6570. if role.ID == 0 {
  6571. user_name = "管理员"
  6572. } else {
  6573. user_name = role.UserName
  6574. }
  6575. baseParams := models.BaseParams{
  6576. SecretKey: miConfig.SecretKey,
  6577. FixmedinsCode: miConfig.Code,
  6578. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6579. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6580. OrgName: miConfig.OrgName,
  6581. Doctor: user_name,
  6582. }
  6583. businessParams := models.BusinessParams{
  6584. PsnNo: order.PsnNo,
  6585. MdtrtId: order.MdtrtId,
  6586. SetlId: order.SetlId,
  6587. }
  6588. var res ResultEleven
  6589. var resEleven10265 ResultEleven10265
  6590. if config.IsOpen == 1 {
  6591. if miConfig.MdtrtareaAdmvs == "421300" {
  6592. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6593. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6594. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6595. resp, requestErr := http.Get(api)
  6596. if requestErr != nil {
  6597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6598. return
  6599. }
  6600. body, ioErr := ioutil.ReadAll(resp.Body)
  6601. if ioErr != nil {
  6602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6604. return
  6605. }
  6606. var respJSON map[string]interface{}
  6607. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6610. return
  6611. }
  6612. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6613. result, _ := json.Marshal(respJSON)
  6614. fmt.Println("log")
  6615. fmt.Println(string(result))
  6616. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6617. utils.ErrorLog("解析失败:%v", err)
  6618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6619. return
  6620. }
  6621. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6622. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6623. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6624. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6625. resp, requestErr := http.Get(api)
  6626. if requestErr != nil {
  6627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6628. return
  6629. }
  6630. body, ioErr := ioutil.ReadAll(resp.Body)
  6631. if ioErr != nil {
  6632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6634. return
  6635. }
  6636. var respJSON map[string]interface{}
  6637. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6640. return
  6641. }
  6642. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6643. result, _ := json.Marshal(respJSON)
  6644. fmt.Println("log")
  6645. fmt.Println(string(result))
  6646. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6647. utils.ErrorLog("解析失败:%v", err)
  6648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6649. return
  6650. }
  6651. } else {
  6652. result2 := service.Gdyb5204(baseParams, businessParams)
  6653. fmt.Println(result2)
  6654. result := service.Gdyb5203(baseParams, businessParams)
  6655. var dat map[string]interface{}
  6656. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6657. fmt.Println(dat)
  6658. } else {
  6659. fmt.Println(err)
  6660. }
  6661. userJSONBytes, _ := json.Marshal(dat)
  6662. if miConfig.Code == "H15049901371" {
  6663. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  6664. utils.ErrorLog("解析失败:%v", err)
  6665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6666. return
  6667. }
  6668. res.InfRefmsgid = resEleven10265.InfRefmsgid
  6669. res.Output = resEleven10265.Output
  6670. res.ErrMsg = resEleven10265.ErrMsg
  6671. res.Cainfo = resEleven10265.Cainfo
  6672. res.WarnMsg = resEleven10265.WarnMsg
  6673. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  6674. res.Infcode = infocode
  6675. } else {
  6676. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6677. utils.ErrorLog("解析失败:%v", err)
  6678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6679. return
  6680. }
  6681. }
  6682. }
  6683. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6684. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  6685. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  6686. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6687. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6688. var doctor_name string
  6689. if roles.ID == 0 {
  6690. doctor_name = "管理员"
  6691. } else {
  6692. doctor_name = roles.UserName
  6693. }
  6694. yiliao_leibie := ""
  6695. switch order.MedType {
  6696. case "11":
  6697. yiliao_leibie = "普通门诊"
  6698. break
  6699. case "12":
  6700. yiliao_leibie = "门诊挂号"
  6701. break
  6702. case "13":
  6703. yiliao_leibie = "急诊"
  6704. break
  6705. case "14":
  6706. yiliao_leibie = "门诊特殊病"
  6707. break
  6708. case "15":
  6709. yiliao_leibie = "门诊统筹"
  6710. break
  6711. case "16":
  6712. yiliao_leibie = "门诊慢性病"
  6713. break
  6714. case "21":
  6715. yiliao_leibie = "普通住院"
  6716. break
  6717. }
  6718. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6719. if res.Infcode == 0 {
  6720. c.ServeSuccessJSON(map[string]interface{}{
  6721. "diagnosis": name,
  6722. "order_infos": orderInfos,
  6723. "number": order.MdtrtId,
  6724. "date": order.SettleAccountsDate,
  6725. "charge_admin": charge_admin,
  6726. "printor_admin": printor_admin,
  6727. "info": res.Output.Setlinfo,
  6728. "bedCostTotal": bedCostTotal,
  6729. "bedCostSelfTotal": bedCostSelfTotal,
  6730. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  6731. "operationCostTotal": operationCostTotal,
  6732. "operationCostSelfTotal": operationCostSelfTotal,
  6733. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  6734. "otherCostTotal": otherCostTotal,
  6735. "otherCostSelfTotal": otherCostSelfTotal,
  6736. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  6737. "materialCostTotal": materialCostTotal,
  6738. "materialCostSelfTotal": materialCostSelfTotal,
  6739. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  6740. "westernMedicineCostTotal": westernMedicineCostTotal,
  6741. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  6742. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  6743. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  6744. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  6745. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  6746. "checkCostTotal": checkCostTotal,
  6747. "checkCostSelfTotal": checkCostSelfTotal,
  6748. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  6749. "laboratoryCostTotal": laboratoryCostTotal,
  6750. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  6751. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  6752. "treatCostTotal": treatCostTotal,
  6753. "treatCostSelfTotal": treatCostSelfTotal,
  6754. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  6755. "doctor_code": adminRole_two.DoctorCode,
  6756. "doctor_name": doctor_name,
  6757. "health_card_no": order.PsnNo,
  6758. "department": departments.Name,
  6759. "yiliao_leibie": yiliao_leibie,
  6760. "after_money": order.AccountPrice,
  6761. "patient": patient,
  6762. "org_name": miConfig.OrgName,
  6763. "org_code": miConfig.Code,
  6764. "order_number": order.Number,
  6765. //"check_order_info": cus_slice,
  6766. })
  6767. }
  6768. }
  6769. }
  6770. func (c *HisApiController) CheckTreatment() {
  6771. patient_id, _ := c.GetInt64("patient_id")
  6772. id_card_no := c.GetString("id_card_no")
  6773. insutype := c.GetString("insutype")
  6774. med_type := c.GetString("med_type")
  6775. admin_user_id, _ := c.GetInt64("admin_user_id")
  6776. adminUser := c.GetAdminUserInfo()
  6777. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6778. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6779. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6780. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6781. if miConfig.MdtrtareaAdmvs == "421300" {
  6782. var res ResultTwo
  6783. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  6784. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6785. "&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)
  6786. resp, requestErr := http.Get(api)
  6787. if requestErr != nil {
  6788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6789. return
  6790. }
  6791. body, ioErr := ioutil.ReadAll(resp.Body)
  6792. if ioErr != nil {
  6793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6795. return
  6796. }
  6797. var respJSON map[string]interface{}
  6798. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6801. return
  6802. }
  6803. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6804. result, _ := json.Marshal(respJSON)
  6805. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6806. utils.ErrorLog("解析失败:%v", err)
  6807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6808. return
  6809. }
  6810. if res.Infcode == 0 {
  6811. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  6812. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6813. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  6814. resp, requestErr := http.Get(api)
  6815. if requestErr != nil {
  6816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6817. return
  6818. }
  6819. body, ioErr := ioutil.ReadAll(resp.Body)
  6820. if ioErr != nil {
  6821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6823. return
  6824. }
  6825. var respJSON map[string]interface{}
  6826. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6829. return
  6830. }
  6831. var res Result2001
  6832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6833. result2, _ := json.Marshal(respJSON)
  6834. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  6835. utils.ErrorLog("解析失败:%v", err)
  6836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6837. return
  6838. }
  6839. if res.Infcode == 0 {
  6840. c.ServeSuccessJSON(map[string]interface{}{
  6841. "msg": res.Output.Trtinfo,
  6842. })
  6843. }
  6844. } else {
  6845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6846. return
  6847. }
  6848. } else {
  6849. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  6850. var dat map[string]interface{}
  6851. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6852. fmt.Println(dat)
  6853. } else {
  6854. fmt.Println(err)
  6855. }
  6856. userJSONBytes, _ := json.Marshal(dat)
  6857. var res ResultTwo
  6858. var res10265 ResultTwo10265
  6859. if miConfig.Code == "H15049901371" {
  6860. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  6861. utils.ErrorLog("解析失败:%v", err)
  6862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6863. return
  6864. }
  6865. res.ErrMsg = res10265.ErrMsg
  6866. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6867. res.Infcode = infocode
  6868. res.Output = res10265.Output
  6869. res.InfRefmsgid = res10265.InfRefmsgid
  6870. } else {
  6871. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6872. utils.ErrorLog("解析失败:%v", err)
  6873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6874. return
  6875. }
  6876. }
  6877. var user_name string
  6878. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  6879. if role.ID == 0 {
  6880. user_name = "xxx"
  6881. } else {
  6882. user_name = role.UserName
  6883. }
  6884. baseParams := models.BaseParams{
  6885. SecretKey: miConfig.SecretKey,
  6886. FixmedinsCode: miConfig.Code,
  6887. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6888. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6889. OrgName: miConfig.OrgName,
  6890. Doctor: user_name,
  6891. }
  6892. if config.IsOpen == 1 {
  6893. if miConfig.Code == "H15049901371" {
  6894. if med_type == "14" {
  6895. if insutype == "390" {
  6896. med_type = "9933"
  6897. } else if insutype == "310" {
  6898. med_type = "990502"
  6899. }
  6900. } else if med_type == "11" {
  6901. med_type = "11"
  6902. }
  6903. }
  6904. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  6905. var dat map[string]interface{}
  6906. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6907. fmt.Println(dat)
  6908. } else {
  6909. fmt.Println(err)
  6910. }
  6911. var res Result2001
  6912. var res10265 Result2001Org10265
  6913. if miConfig.Code == "H15049901371" {
  6914. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6915. utils.ErrorLog("解析失败:%v", err)
  6916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6917. return
  6918. }
  6919. res.ErrMsg = res10265.ErrMsg
  6920. res.Output = res10265.Output
  6921. res.InfRefmsgid = res10265.InfRefmsgid
  6922. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6923. res.Infcode = infocode
  6924. } else {
  6925. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6926. utils.ErrorLog("解析失败:%v", err)
  6927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6928. return
  6929. }
  6930. }
  6931. if res.Infcode == 0 {
  6932. c.ServeSuccessJSON(map[string]interface{}{
  6933. "msg": res.Output.Trtinfo,
  6934. })
  6935. }
  6936. }
  6937. }
  6938. }
  6939. //func (c *HisApiController) PutRecord() {
  6940. // id, _ := c.GetInt64("id")
  6941. // record_time := c.GetString("record_time")
  6942. // timeLayout := "2006-01-02"
  6943. // loc, _ := time.LoadLocation("Local")
  6944. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6945. // if err != nil {
  6946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6947. // return
  6948. // }
  6949. // recordDateTime := theTime.Unix()
  6950. //
  6951. // adminInfo := c.GetAdminUserInfo()
  6952. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  6953. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6954. //
  6955. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6956. //
  6957. // fmt.Println(miConfig.SecretKey)
  6958. //
  6959. // if patient == nil {
  6960. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6961. // return
  6962. // }
  6963. // if len(patient.IdCardNo) == 0 {
  6964. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6965. // return
  6966. // }
  6967. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6968. // if config.IsOpen == 1 {
  6969. // 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
  6970. // resp, requestErr := http.Get(api)
  6971. // if requestErr != nil {
  6972. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6973. // return
  6974. // }
  6975. // defer resp.Body.Close()
  6976. // body, ioErr := ioutil.ReadAll(resp.Body)
  6977. // if ioErr != nil {
  6978. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6979. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6980. // return
  6981. // }
  6982. // var respJSON map[string]interface{}
  6983. //
  6984. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6985. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6986. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6987. // return
  6988. // }
  6989. //
  6990. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6991. // userJSONBytes, _ := json.Marshal(userJSON)
  6992. // var res ResultTwo
  6993. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6994. // utils.ErrorLog("解析失败:%v", err)
  6995. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6996. // return
  6997. // }
  6998. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6999. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7000. // infoStr := string(Iinfos)
  7001. // idetinfoStr := string(Idetinfos)
  7002. //
  7003. // if res.Infcode == 0 {
  7004. // his := models.VMHisPatient{
  7005. // Status: 1,
  7006. // Ctime: time.Now().Unix(),
  7007. // Mtime: time.Now().Unix(),
  7008. // PsnNo: res.Output.Baseinfo.PsnNo,
  7009. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7010. // Certno: res.Output.Baseinfo.Certno,
  7011. // PsnName: res.Output.Baseinfo.PsnName,
  7012. // Gend: res.Output.Baseinfo.Gend,
  7013. // Naty: res.Output.Baseinfo.Naty,
  7014. // Brdy: res.Output.Baseinfo.Brdy,
  7015. // Age: res.Output.Baseinfo.Age,
  7016. // Iinfo: infoStr,
  7017. // Idetinfo: idetinfoStr,
  7018. // PatientId: patient.ID,
  7019. // RecordDate: theTime.Unix(),
  7020. // UserOrgId: adminInfo.CurrentOrgId,
  7021. // AdminUserId: adminInfo.AdminUser.Id,
  7022. // IsReturn: 1,
  7023. // }
  7024. //
  7025. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  7026. // //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")
  7027. // //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")
  7028. //
  7029. // //var dat map[string]interface{}
  7030. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7031. // // fmt.Println(dat)
  7032. // //} else {
  7033. // // fmt.Println(err)
  7034. // //}
  7035. //
  7036. // var dat2 map[string]interface{}
  7037. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  7038. // fmt.Println(dat2)
  7039. // } else {
  7040. // fmt.Println(err)
  7041. // }
  7042. //
  7043. // } else {
  7044. // adminUser := c.GetAdminUserInfo()
  7045. // errlog := &models.HisOrderError{
  7046. // UserOrgId: adminUser.CurrentOrgId,
  7047. // Ctime: time.Now().Unix(),
  7048. // Mtime: time.Now().Unix(),
  7049. // ErrMsg: res.ErrMsg,
  7050. // Status: 1,
  7051. // PatientId: id,
  7052. // RecordTime: recordDateTime,
  7053. // Stage: 1,
  7054. // }
  7055. // service.CreateErrMsgLog(errlog)
  7056. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7057. // return
  7058. // }
  7059. // }
  7060. //
  7061. //}
  7062. //func (c *HisApiController) GetUploadDiag() {
  7063. // id, _ := c.GetInt64("id")
  7064. // record_time := c.GetString("record_time")
  7065. //
  7066. // diagnosis_id, _ := c.GetInt64("diagnosis")
  7067. // sick_type, _ := c.GetInt64("sick_type")
  7068. // reg_type, _ := c.GetInt64("reg_type")
  7069. //
  7070. // timeLayout := "2006-01-02"
  7071. // loc, _ := time.LoadLocation("Local")
  7072. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7073. // if err != nil {
  7074. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7075. // return
  7076. // }
  7077. //
  7078. // var patientPrescription models.HisPrescriptionInfo
  7079. // recordDateTime := theTime.Unix()
  7080. // adminInfo := c.GetAdminUserInfo()
  7081. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7082. //
  7083. // if patientPrescription.ID == 0 {
  7084. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7085. // }
  7086. //
  7087. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7088. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7089. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7090. // sickConfig, _ := service.FindSickById(sick_type)
  7091. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7092. //
  7093. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  7094. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  7095. // "&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 +
  7096. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  7097. // resp2, requestErr2 := http.Get(api2)
  7098. // if requestErr2 != nil {
  7099. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7100. // return
  7101. // }
  7102. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7103. // if ioErr2 != nil {
  7104. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7105. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7106. // return
  7107. // }
  7108. // var respJSON2 map[string]interface{}
  7109. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7110. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7112. // return
  7113. // }
  7114. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7115. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7116. //
  7117. // var res2 ResultSix
  7118. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7119. // utils.ErrorLog("解析失败:%v", err)
  7120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7121. // return
  7122. // }
  7123. // if res2.Infcode != 0 {
  7124. // adminUser := c.GetAdminUserInfo()
  7125. // errlog := &models.HisOrderError{
  7126. // UserOrgId: adminUser.CurrentOrgId,
  7127. // Ctime: time.Now().Unix(),
  7128. // Mtime: time.Now().Unix(),
  7129. // ErrMsg: res2.ErrMsg,
  7130. // Status: 1,
  7131. // PatientId: id,
  7132. // RecordTime: recordDateTime,
  7133. // Stage: 3,
  7134. // }
  7135. // service.CreateErrMsgLog(errlog)
  7136. //
  7137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  7138. // return
  7139. // }
  7140. //
  7141. // c.ServeSuccessJSON(map[string]interface{}{
  7142. // "msg": "上传成功",
  7143. // })
  7144. //
  7145. //}
  7146. type QueryResult struct {
  7147. ID int64
  7148. Name string
  7149. Code string
  7150. List_type_code string
  7151. }
  7152. func (c *HisApiController) GetCheckCode() {
  7153. ids_str := c.GetString("ids")
  7154. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7155. ids_arr := strings.Split(ids_str, ",")
  7156. var queryResult []QueryResult
  7157. ids := make([]int64, 0)
  7158. for _, item := range ids_arr {
  7159. id, _ := strconv.ParseInt(item, 10, 64)
  7160. ids = append(ids, id)
  7161. }
  7162. if record_type == 1 {
  7163. drugs, _ := service.GetBatchDrugList(ids)
  7164. for _, item := range drugs {
  7165. result := QueryResult{
  7166. ID: item.ID,
  7167. Name: item.DrugName,
  7168. Code: item.MedicalInsuranceNumber,
  7169. List_type_code: "101",
  7170. }
  7171. queryResult = append(queryResult, result)
  7172. }
  7173. } else if record_type == 2 {
  7174. goods, _ := service.GetBatchGoodInformationList(ids)
  7175. for _, item := range goods {
  7176. result := QueryResult{
  7177. ID: item.ID,
  7178. Name: item.GoodName,
  7179. Code: item.MedicalInsuranceNumber,
  7180. List_type_code: "301",
  7181. }
  7182. queryResult = append(queryResult, result)
  7183. }
  7184. } else if record_type == 3 {
  7185. projects, _ := service.GetBathchMyPorjecgList(ids)
  7186. for _, item := range projects {
  7187. result := QueryResult{
  7188. ID: item.ID,
  7189. Name: item.ProjectName,
  7190. Code: item.MedicalCode,
  7191. List_type_code: "201",
  7192. }
  7193. queryResult = append(queryResult, result)
  7194. }
  7195. }
  7196. admin_user_id, _ := c.GetInt64("admin_user_id")
  7197. adminUser := c.GetAdminUserInfo()
  7198. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7199. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7200. var user_name string
  7201. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7202. if role.ID == 0 {
  7203. user_name = "xxx"
  7204. } else {
  7205. user_name = role.UserName
  7206. }
  7207. baseParams := &models.BaseParams{
  7208. SecretKey: miConfig.SecretKey,
  7209. FixmedinsCode: miConfig.Code,
  7210. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7211. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7212. OrgName: miConfig.OrgName,
  7213. Doctor: user_name,
  7214. }
  7215. if config.IsOpen == 1 {
  7216. for _, item := range queryResult {
  7217. var result string
  7218. if record_type == 1 {
  7219. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7220. } else if record_type == 2 {
  7221. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7222. } else if record_type == 3 {
  7223. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7224. }
  7225. var dat map[string]interface{}
  7226. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7227. fmt.Println(dat)
  7228. } else {
  7229. fmt.Println(err)
  7230. }
  7231. userJSONBytes, _ := json.Marshal(dat)
  7232. var res ResultSix
  7233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7234. utils.ErrorLog("解析失败:%v", err)
  7235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7236. return
  7237. }
  7238. if res.Infcode == 0 {
  7239. if record_type == 1 {
  7240. service.UpdateBaseDrugById(item.ID)
  7241. } else if record_type == 2 {
  7242. service.UpdateGoodInformaitonByDetail(item.ID)
  7243. } else if record_type == 3 {
  7244. service.UpdateProjectById(item.ID)
  7245. }
  7246. c.ServeSuccessJSON(map[string]interface{}{
  7247. "failed_code": 0,
  7248. "msg": "目录对照成功",
  7249. })
  7250. } else {
  7251. c.ServeSuccessJSON(map[string]interface{}{
  7252. "failed_code": -10,
  7253. "msg": res.ErrMsg,
  7254. })
  7255. }
  7256. }
  7257. }
  7258. }
  7259. func (c *HisApiController) UnCheckCode() {
  7260. ids_str := c.GetString("ids")
  7261. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7262. admin_user_id, _ := c.GetInt64("admin_user_id")
  7263. ids_arr := strings.Split(ids_str, ",")
  7264. var queryResult []QueryResult
  7265. ids := make([]int64, 0)
  7266. for _, item := range ids_arr {
  7267. id, _ := strconv.ParseInt(item, 10, 64)
  7268. ids = append(ids, id)
  7269. }
  7270. if record_type == 1 {
  7271. drugs, _ := service.GetBatchDrugList(ids)
  7272. for _, item := range drugs {
  7273. result := QueryResult{
  7274. ID: item.ID,
  7275. Name: item.DrugName,
  7276. Code: item.MedicalInsuranceNumber,
  7277. List_type_code: "101",
  7278. }
  7279. queryResult = append(queryResult, result)
  7280. }
  7281. } else if record_type == 2 {
  7282. goods, _ := service.GetBatchGoodInformationList(ids)
  7283. for _, item := range goods {
  7284. result := QueryResult{
  7285. ID: item.ID,
  7286. Name: item.GoodName,
  7287. Code: item.MedicalInsuranceNumber,
  7288. List_type_code: "301",
  7289. }
  7290. queryResult = append(queryResult, result)
  7291. }
  7292. } else if record_type == 3 {
  7293. projects, _ := service.GetBathchMyPorjecgList(ids)
  7294. for _, item := range projects {
  7295. result := QueryResult{
  7296. ID: item.ID,
  7297. Name: item.ProjectName,
  7298. Code: item.MedicalCode,
  7299. List_type_code: "201",
  7300. }
  7301. queryResult = append(queryResult, result)
  7302. }
  7303. }
  7304. adminUser := c.GetAdminUserInfo()
  7305. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7306. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7307. var user_name string
  7308. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7309. if role.ID == 0 {
  7310. user_name = "xxx"
  7311. } else {
  7312. user_name = role.UserName
  7313. }
  7314. baseParams := &models.BaseParams{
  7315. SecretKey: miConfig.SecretKey,
  7316. FixmedinsCode: miConfig.Code,
  7317. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7318. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7319. OrgName: miConfig.OrgName,
  7320. Doctor: user_name,
  7321. }
  7322. if config.IsOpen == 1 {
  7323. for _, item := range queryResult {
  7324. var result string
  7325. if record_type == 1 {
  7326. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7327. } else if record_type == 2 {
  7328. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7329. } else if record_type == 3 {
  7330. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7331. }
  7332. var dat2 map[string]interface{}
  7333. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  7334. fmt.Println(dat2)
  7335. } else {
  7336. fmt.Println(err)
  7337. }
  7338. userJSONBytes, _ := json.Marshal(dat2)
  7339. var res ResultSix
  7340. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7341. utils.ErrorLog("解析失败:%v", err)
  7342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7343. return
  7344. }
  7345. if res.Infcode == 0 {
  7346. if record_type == 1 {
  7347. service.UpdateDrugByIdDetail(item.ID)
  7348. } else if record_type == 2 {
  7349. service.UpdateGoodInfoById(item.ID)
  7350. } else if record_type == 3 {
  7351. service.UpdateMyProjectById(item.ID)
  7352. }
  7353. c.ServeSuccessJSON(map[string]interface{}{
  7354. "failed_code": 0,
  7355. "msg": "撤销目录对照成功",
  7356. })
  7357. } else {
  7358. c.ServeSuccessJSON(map[string]interface{}{
  7359. "failed_code": -10,
  7360. "msg": res.ErrMsg,
  7361. })
  7362. }
  7363. }
  7364. }
  7365. }
  7366. func (c *HisApiController) GetPatientInfo() {
  7367. id_card_no := c.GetString("id_card_no")
  7368. admin_user_id, _ := c.GetInt64("admin_user_id")
  7369. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  7370. if patient.ID == 0 {
  7371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7372. return
  7373. }
  7374. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7375. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7376. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  7377. if config.IsOpen == 1 {
  7378. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7379. var dat map[string]interface{}
  7380. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7381. fmt.Println(dat)
  7382. } else {
  7383. fmt.Println(err)
  7384. }
  7385. userJSONBytes, _ := json.Marshal(dat)
  7386. var res ResultTwo
  7387. var res10265 ResultTwo10265
  7388. if miConfig.Code == "H15049901371" {
  7389. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7390. utils.ErrorLog("解析失败:%v", err)
  7391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7392. return
  7393. }
  7394. res.ErrMsg = res10265.ErrMsg
  7395. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7396. res.Infcode = infocode
  7397. res.Output = res10265.Output
  7398. res.InfRefmsgid = res10265.InfRefmsgid
  7399. } else {
  7400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7401. utils.ErrorLog("解析失败:%v", err)
  7402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7403. return
  7404. }
  7405. }
  7406. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7407. // utils.ErrorLog("解析失败:%v", err)
  7408. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7409. // return
  7410. //}
  7411. if res.Infcode != 0 {
  7412. c.ServeSuccessJSON(map[string]interface{}{
  7413. "failed_code": -10,
  7414. "msg": res.ErrMsg,
  7415. })
  7416. } else {
  7417. c.ServeSuccessJSON(map[string]interface{}{
  7418. "failed_code": 0,
  7419. "info": res,
  7420. })
  7421. }
  7422. }
  7423. }
  7424. func (c *HisApiController) PsnPutOnRecord() {
  7425. record_type, _ := c.GetInt64("type")
  7426. patient_id, _ := c.GetInt64("patient_id")
  7427. admin_user_id, _ := c.GetInt64("admin_user_id")
  7428. start_time := c.GetString("start_time")
  7429. end_time := c.GetString("end_time")
  7430. adminUser := c.GetAdminUserInfo()
  7431. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7432. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7433. var patients []*models.Patients
  7434. if record_type == 1 { //全部备案
  7435. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  7436. patients = append(patients, patient...)
  7437. } else { //单个备案
  7438. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7439. patients = append(patients, patient)
  7440. }
  7441. var user_name string
  7442. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7443. if role.ID == 0 {
  7444. user_name = "xxx"
  7445. } else {
  7446. user_name = role.UserName
  7447. }
  7448. if config.IsOpen == 1 {
  7449. for _, item := range patients {
  7450. 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
  7451. resp, requestErr := http.Get(api)
  7452. if requestErr != nil {
  7453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7454. return
  7455. }
  7456. defer resp.Body.Close()
  7457. body, ioErr := ioutil.ReadAll(resp.Body)
  7458. if ioErr != nil {
  7459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7461. return
  7462. }
  7463. var respJSON map[string]interface{}
  7464. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7465. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7467. return
  7468. }
  7469. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7470. userJSONBytes, _ := json.Marshal(userJSON)
  7471. var res ResultTwo
  7472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7473. utils.ErrorLog("解析失败:%v", err)
  7474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7475. return
  7476. }
  7477. if res.Infcode == 0 {
  7478. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  7479. var dat map[string]interface{}
  7480. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7481. fmt.Println(dat)
  7482. } else {
  7483. fmt.Println(err)
  7484. }
  7485. userJSONBytes, _ := json.Marshal(dat)
  7486. var res2 ResultThirteen
  7487. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7488. utils.ErrorLog("解析失败:%v", err)
  7489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7490. return
  7491. }
  7492. if res2.Infcode == 0 {
  7493. psnResult := &models.GdybPsnRecord{
  7494. UserOrgId: adminUser.CurrentOrgId,
  7495. PatientId: item.ID,
  7496. PsnNo: res.Output.Baseinfo.PsnNo,
  7497. Ctime: time.Now().Unix(),
  7498. Mtime: time.Now().Unix(),
  7499. Status: 1,
  7500. IsCancel: 1,
  7501. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7502. }
  7503. service.CreatePsnRecord(psnResult)
  7504. } else {
  7505. c.ServeSuccessJSON(map[string]interface{}{
  7506. "failed_code": -10,
  7507. "msg": res2.ErrMsg,
  7508. })
  7509. return
  7510. }
  7511. }
  7512. }
  7513. }
  7514. }
  7515. func (c *HisApiController) PsnUnPutOnRecord() {
  7516. id, _ := c.GetInt64("id")
  7517. //record_type, _ := c.GetInt64("type")
  7518. admin_user_id, _ := c.GetInt64("admin_user_id")
  7519. adminUser := c.GetAdminUserInfo()
  7520. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7521. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7522. var user_name string
  7523. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7524. if role.ID == 0 {
  7525. user_name = "xxx"
  7526. } else {
  7527. user_name = role.UserName
  7528. }
  7529. psn_record, _ := service.GetPsnRecordById(id)
  7530. if psn_record.ID == 0 {
  7531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7532. return
  7533. }
  7534. if config.IsOpen == 1 {
  7535. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  7536. var dat map[string]interface{}
  7537. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7538. fmt.Println(dat)
  7539. } else {
  7540. fmt.Println(err)
  7541. }
  7542. userJSONBytes, _ := json.Marshal(dat)
  7543. var res ResultFourteen
  7544. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7545. utils.ErrorLog("解析失败:%v", err)
  7546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7547. return
  7548. }
  7549. if res.Infcode == 0 {
  7550. psn_record.IsCancel = 2
  7551. service.CreatePsnRecord(&psn_record)
  7552. } else {
  7553. c.ServeSuccessJSON(map[string]interface{}{
  7554. "failed_code": -10,
  7555. "msg": res.ErrMsg,
  7556. })
  7557. return
  7558. }
  7559. }
  7560. }
  7561. func (c *HisApiController) PsnPutNCDSOnRecord() {
  7562. patient_id, _ := c.GetInt64("patient_id")
  7563. insutype_two := c.GetString("insutype")
  7564. psn_no := c.GetString("psn_no")
  7565. doctor_id, _ := c.GetInt64("doctor_id")
  7566. sick_id, _ := c.GetInt64("sick_id")
  7567. department_id, _ := c.GetInt64("department_id")
  7568. start_time := c.GetString("start_time")
  7569. end_time := c.GetString("end_time")
  7570. check_time := c.GetString("check_time")
  7571. adminUser := c.GetAdminUserInfo()
  7572. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7573. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7574. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7575. sick, _ := service.FindSickById(sick_id)
  7576. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7577. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7578. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7579. var res ResultTwo
  7580. var res10265 ResultTwo10265
  7581. if miConfig.Code == "H15049901371" {
  7582. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7583. utils.ErrorLog("解析失败:%v", err)
  7584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7585. return
  7586. }
  7587. res.ErrMsg = res10265.ErrMsg
  7588. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7589. res.Infcode = infocode
  7590. res.Output = res10265.Output
  7591. res.InfRefmsgid = res10265.InfRefmsgid
  7592. } else {
  7593. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7594. utils.ErrorLog("解析失败:%v", err)
  7595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7596. return
  7597. }
  7598. }
  7599. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7600. infoStr := string(Iinfos)
  7601. var rf []*ResultFive
  7602. json.Unmarshal([]byte(infoStr), &rf)
  7603. var insuplc_admdvs string
  7604. var insutype string
  7605. var is390 int = 0
  7606. var is310 int = 0
  7607. var insutypes []*ResultFive
  7608. for _, item := range rf {
  7609. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7610. insutypes = append(insutypes, item)
  7611. }
  7612. }
  7613. if len(insutypes) == 1 {
  7614. insutype = insutypes[0].Insutype
  7615. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7616. } else {
  7617. for _, i := range insutypes {
  7618. if i.Insutype == "390" {
  7619. is390 = 1
  7620. }
  7621. if i.Insutype == "310" {
  7622. is310 = 1
  7623. }
  7624. }
  7625. }
  7626. if is390 == 1 {
  7627. insutype = "390"
  7628. }
  7629. if is310 == 1 {
  7630. insutype = "310"
  7631. }
  7632. if len(insutypes) == 2 {
  7633. insutype = insutype_two
  7634. }
  7635. if len(insutypes) == 0 {
  7636. insutype = "310"
  7637. }
  7638. insutype = insutype_two
  7639. fmt.Println(insutype)
  7640. for _, item := range rf {
  7641. fmt.Println(item.Insutype)
  7642. fmt.Println(insutype)
  7643. if item.Insutype == insutype {
  7644. fmt.Println(item.Insutype)
  7645. fmt.Println(insutype)
  7646. insuplc_admdvs = item.InsuplcAdmdvs
  7647. }
  7648. }
  7649. fmt.Println(insuplc_admdvs)
  7650. if config.IsOpen == 1 {
  7651. 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)
  7652. var dat map[string]interface{}
  7653. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7654. fmt.Println(dat)
  7655. } else {
  7656. fmt.Println(err)
  7657. }
  7658. userJSONBytes, _ := json.Marshal(dat)
  7659. var res2 ResultThirteen
  7660. var res10265 ResultThirteen10265
  7661. if miConfig.Code == "H15049901371" {
  7662. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7663. utils.ErrorLog("解析失败:%v", err)
  7664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7665. return
  7666. }
  7667. res2.ErrMsg = res10265.ErrMsg
  7668. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7669. res2.Infcode = infocode
  7670. res2.Output = res10265.Output
  7671. res2.InfRefmsgid = res10265.InfRefmsgid
  7672. } else {
  7673. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7674. utils.ErrorLog("解析失败:%v", err)
  7675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7676. return
  7677. }
  7678. }
  7679. if res2.Infcode == 0 {
  7680. psnResult := &models.GdybPsnNcdsRecord{
  7681. UserOrgId: adminUser.CurrentOrgId,
  7682. PatientId: patient.ID,
  7683. PsnNo: psn_no,
  7684. DoctorId: doctor.AdminUserId,
  7685. DepartmentId: department_id,
  7686. SickType: sick_id,
  7687. Insutype: insutype,
  7688. Ctime: time.Now().Unix(),
  7689. Mtime: time.Now().Unix(),
  7690. Status: 1,
  7691. IsCancel: 1,
  7692. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7693. }
  7694. service.CreatePsnNCDSRecord(psnResult)
  7695. c.ServeSuccessJSON(map[string]interface{}{
  7696. "failed_code": 0,
  7697. "msg": "备案成功",
  7698. "result": psnResult,
  7699. })
  7700. } else {
  7701. c.ServeSuccessJSON(map[string]interface{}{
  7702. "failed_code": -10,
  7703. "msg": res2.ErrMsg,
  7704. })
  7705. return
  7706. }
  7707. }
  7708. }
  7709. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  7710. id, _ := c.GetInt64("id")
  7711. admin_user_id, _ := c.GetInt64("admin_user_id")
  7712. adminUser := c.GetAdminUserInfo()
  7713. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7714. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7715. //config, _ := service.Ge(adminUser.CurrentOrgId)
  7716. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  7717. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7718. //var user_name string
  7719. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7720. //if role.ID == 0 {
  7721. // user_name = "xxx"
  7722. //} else {
  7723. // user_name = role.UserName
  7724. //}
  7725. psn_record, _ := service.GetPsnNCDSRecordById(id)
  7726. if psn_record.ID == 0 {
  7727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7728. return
  7729. }
  7730. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7731. var res ResultTwo
  7732. var res10265 ResultTwo10265
  7733. if miConfig.Code == "H15049901371" {
  7734. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7735. utils.ErrorLog("解析失败:%v", err)
  7736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7737. return
  7738. }
  7739. res.ErrMsg = res10265.ErrMsg
  7740. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7741. res.Infcode = infocode
  7742. res.Output = res10265.Output
  7743. res.InfRefmsgid = res10265.InfRefmsgid
  7744. } else {
  7745. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7746. utils.ErrorLog("解析失败:%v", err)
  7747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7748. return
  7749. }
  7750. }
  7751. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7752. infoStr := string(Iinfos)
  7753. var rf []*ResultFive
  7754. json.Unmarshal([]byte(infoStr), &rf)
  7755. var insuplc_admdvs string
  7756. var insutype string
  7757. var is390 int = 0
  7758. var is310 int = 0
  7759. var insutypes []*ResultFive
  7760. for _, item := range rf {
  7761. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7762. insutypes = append(insutypes, item)
  7763. }
  7764. }
  7765. if len(insutypes) == 1 {
  7766. insutype = insutypes[0].Insutype
  7767. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7768. } else {
  7769. for _, i := range insutypes {
  7770. if i.Insutype == "390" {
  7771. is390 = 1
  7772. }
  7773. if i.Insutype == "310" {
  7774. is310 = 1
  7775. }
  7776. }
  7777. }
  7778. if is390 == 1 {
  7779. insutype = "390"
  7780. }
  7781. if is310 == 1 {
  7782. insutype = "310"
  7783. }
  7784. if len(insutypes) == 0 {
  7785. insutype = "310"
  7786. }
  7787. insutype = psn_record.Insutype
  7788. for _, item := range rf {
  7789. if item.Insutype == insutype {
  7790. insuplc_admdvs = item.InsuplcAdmdvs
  7791. }
  7792. }
  7793. if config.IsOpen == 1 {
  7794. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  7795. var dat map[string]interface{}
  7796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7797. fmt.Println(dat)
  7798. } else {
  7799. fmt.Println(err)
  7800. }
  7801. userJSONBytes, _ := json.Marshal(dat)
  7802. var res ResultFourteen
  7803. var res10265 ResultFourteen10265
  7804. if miConfig.Code == "H15049901371" {
  7805. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7806. utils.ErrorLog("解析失败:%v", err)
  7807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7808. return
  7809. }
  7810. res.ErrMsg = res10265.ErrMsg
  7811. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7812. res.Infcode = infocode
  7813. res.Output = res10265.Output
  7814. res.InfRefmsgid = res10265.InfRefmsgid
  7815. } else {
  7816. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7817. utils.ErrorLog("解析失败:%v", err)
  7818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7819. return
  7820. }
  7821. }
  7822. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7823. // utils.ErrorLog("解析失败:%v", err)
  7824. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7825. // return
  7826. //}
  7827. if res.Infcode == 0 {
  7828. psn_record.IsCancel = 2
  7829. service.CreatePsnNCDSRecord(&psn_record)
  7830. c.ServeSuccessJSON(map[string]interface{}{
  7831. "failed_code": 0,
  7832. "msg": "撤销备案成功",
  7833. })
  7834. } else {
  7835. c.ServeSuccessJSON(map[string]interface{}{
  7836. "failed_code": -10,
  7837. "msg": res.ErrMsg,
  7838. })
  7839. return
  7840. }
  7841. }
  7842. }
  7843. func (c *HisApiController) TestTest() {
  7844. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  7845. fmt.Println(patient.Iinfo)
  7846. }
  7847. type CustomData struct {
  7848. MsgId string
  7849. PsnNo string
  7850. Info string
  7851. }
  7852. func (c *HisApiController) ReversalData() {
  7853. var customData []*CustomData
  7854. custom := &CustomData{
  7855. MsgId: "H44022900158202103301714472004",
  7856. PsnNo: "44020000001101329945",
  7857. Info: "2207",
  7858. }
  7859. customData = append(customData, custom)
  7860. custom1 := &CustomData{
  7861. MsgId: "H4402290015820210330172057803",
  7862. PsnNo: "44020000001101161813",
  7863. Info: "2207",
  7864. }
  7865. customData = append(customData, custom1)
  7866. custom2 := &CustomData{
  7867. MsgId: "H44022900158202103301705198813",
  7868. PsnNo: "44190000133097375417",
  7869. Info: "2207",
  7870. }
  7871. customData = append(customData, custom2)
  7872. custom3 := &CustomData{
  7873. MsgId: "H44022900158202103301715524756",
  7874. PsnNo: "44020000001100187221",
  7875. Info: "2207",
  7876. }
  7877. customData = append(customData, custom3)
  7878. custom4 := &CustomData{
  7879. MsgId: "H44022900158202103301730376224",
  7880. PsnNo: "44020000001101959155",
  7881. Info: "2207",
  7882. }
  7883. customData = append(customData, custom4)
  7884. custom5 := &CustomData{
  7885. MsgId: "H44022900158202103301748008725",
  7886. PsnNo: "44020000001104246641",
  7887. Info: "2207",
  7888. }
  7889. customData = append(customData, custom5)
  7890. custom6 := &CustomData{
  7891. MsgId: "H44022900158202103301718096755",
  7892. PsnNo: "44020000001102211860",
  7893. Info: "2207",
  7894. }
  7895. customData = append(customData, custom6)
  7896. custom7 := &CustomData{
  7897. MsgId: "H44022900158202103301736551640",
  7898. PsnNo: "44020000001102687718",
  7899. Info: "2207",
  7900. }
  7901. customData = append(customData, custom7)
  7902. custom8 := &CustomData{
  7903. MsgId: "H44022900158202103301743097676",
  7904. PsnNo: "44020000001102127785",
  7905. Info: "2207",
  7906. }
  7907. customData = append(customData, custom8)
  7908. custom9 := &CustomData{
  7909. MsgId: "H44022900158202103301712304203",
  7910. PsnNo: "44020000001101518097",
  7911. Info: "2207",
  7912. }
  7913. customData = append(customData, custom9)
  7914. custom10 := &CustomData{
  7915. MsgId: "H44022900158202103301738448785",
  7916. PsnNo: "44020000001100500813",
  7917. Info: "2207",
  7918. }
  7919. customData = append(customData, custom10)
  7920. custom11 := &CustomData{
  7921. MsgId: "H44022900158202103301732455843",
  7922. PsnNo: "44020000001102690557",
  7923. Info: "2207",
  7924. }
  7925. customData = append(customData, custom11)
  7926. custom12 := &CustomData{
  7927. MsgId: "H44022900158202103301745421708",
  7928. PsnNo: "44020000001102211928",
  7929. Info: "2207",
  7930. }
  7931. customData = append(customData, custom12)
  7932. custom1212 := &CustomData{
  7933. MsgId: "H440229001582021033017351627",
  7934. PsnNo: "44020000001102481733",
  7935. Info: "2207",
  7936. }
  7937. customData = append(customData, custom1212)
  7938. custom13 := &CustomData{
  7939. MsgId: "H44022900158202103301740327951",
  7940. PsnNo: "44020000001103174866",
  7941. Info: "2207",
  7942. }
  7943. customData = append(customData, custom13)
  7944. custom14 := &CustomData{
  7945. MsgId: "H4402290015820210330174922668",
  7946. PsnNo: "44020000001102927272",
  7947. Info: "2207",
  7948. }
  7949. customData = append(customData, custom14)
  7950. custom15 := &CustomData{
  7951. MsgId: "H44022900158202103301752362273",
  7952. PsnNo: "44020000001102942890",
  7953. Info: "2207",
  7954. }
  7955. customData = append(customData, custom15)
  7956. custom16 := &CustomData{
  7957. MsgId: "H44022900158202103301751082917",
  7958. PsnNo: "44020000001101662162",
  7959. Info: "2207",
  7960. }
  7961. customData = append(customData, custom16)
  7962. custom17 := &CustomData{
  7963. MsgId: "H44022900158202103301754147728",
  7964. PsnNo: "44020000000229014511",
  7965. Info: "2207",
  7966. }
  7967. customData = append(customData, custom17)
  7968. adminUser := c.GetAdminUserInfo()
  7969. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7970. for _, item := range customData {
  7971. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7972. fmt.Println(result)
  7973. }
  7974. }
  7975. func (c *HisApiController) ReversalOtherData() {
  7976. var customData []*CustomData
  7977. custom := &CustomData{
  7978. MsgId: "H44022900158202103301714472004",
  7979. PsnNo: "44020000001101329945",
  7980. Info: "2208",
  7981. }
  7982. customData = append(customData, custom)
  7983. custom1 := &CustomData{
  7984. MsgId: "H4402290015820210330172057803",
  7985. PsnNo: "44020000001101161813",
  7986. Info: "2208",
  7987. }
  7988. customData = append(customData, custom1)
  7989. custom2 := &CustomData{
  7990. MsgId: "H44022900158202103301705198813",
  7991. PsnNo: "44190000133097375417",
  7992. Info: "2208",
  7993. }
  7994. customData = append(customData, custom2)
  7995. custom3 := &CustomData{
  7996. MsgId: "H44022900158202103301715524756",
  7997. PsnNo: "44020000001100187221",
  7998. Info: "2208",
  7999. }
  8000. customData = append(customData, custom3)
  8001. custom4 := &CustomData{
  8002. MsgId: "H44022900158202103301730376224",
  8003. PsnNo: "44020000001101959155",
  8004. Info: "2208",
  8005. }
  8006. customData = append(customData, custom4)
  8007. custom5 := &CustomData{
  8008. MsgId: "H44022900158202103301748008725",
  8009. PsnNo: "44020000001104246641",
  8010. Info: "2208",
  8011. }
  8012. customData = append(customData, custom5)
  8013. custom6 := &CustomData{
  8014. MsgId: "H44022900158202103301718096755",
  8015. PsnNo: "44020000001102211860",
  8016. Info: "2208",
  8017. }
  8018. customData = append(customData, custom6)
  8019. custom7 := &CustomData{
  8020. MsgId: "H44022900158202103301736551640",
  8021. PsnNo: "44020000001102687718",
  8022. Info: "2208",
  8023. }
  8024. customData = append(customData, custom7)
  8025. custom8 := &CustomData{
  8026. MsgId: "H44022900158202103301743097676",
  8027. PsnNo: "44020000001102127785",
  8028. Info: "2208",
  8029. }
  8030. customData = append(customData, custom8)
  8031. custom9 := &CustomData{
  8032. MsgId: "H44022900158202103301712304203",
  8033. PsnNo: "44020000001101518097",
  8034. Info: "2208",
  8035. }
  8036. customData = append(customData, custom9)
  8037. custom10 := &CustomData{
  8038. MsgId: "H44022900158202103301738448785",
  8039. PsnNo: "44020000001100500813",
  8040. Info: "2208",
  8041. }
  8042. customData = append(customData, custom10)
  8043. custom11 := &CustomData{
  8044. MsgId: "H44022900158202103301732455843",
  8045. PsnNo: "44020000001102690557",
  8046. Info: "2208",
  8047. }
  8048. customData = append(customData, custom11)
  8049. custom12 := &CustomData{
  8050. MsgId: "H44022900158202103301745421708",
  8051. PsnNo: "44020000001102211928",
  8052. Info: "2208",
  8053. }
  8054. customData = append(customData, custom12)
  8055. custom1212 := &CustomData{
  8056. MsgId: "H440229001582021033017351627",
  8057. PsnNo: "44020000001102481733",
  8058. Info: "2208",
  8059. }
  8060. customData = append(customData, custom1212)
  8061. custom13 := &CustomData{
  8062. MsgId: "H44022900158202103301740327951",
  8063. PsnNo: "44020000001103174866",
  8064. Info: "2208",
  8065. }
  8066. customData = append(customData, custom13)
  8067. custom14 := &CustomData{
  8068. MsgId: "H4402290015820210330174922668",
  8069. PsnNo: "44020000001102927272",
  8070. Info: "2208",
  8071. }
  8072. customData = append(customData, custom14)
  8073. custom15 := &CustomData{
  8074. MsgId: "H44022900158202103301752362273",
  8075. PsnNo: "44020000001102942890",
  8076. Info: "2208",
  8077. }
  8078. customData = append(customData, custom15)
  8079. custom16 := &CustomData{
  8080. MsgId: "H44022900158202103301751082917",
  8081. PsnNo: "44020000001101662162",
  8082. Info: "2208",
  8083. }
  8084. customData = append(customData, custom16)
  8085. custom17 := &CustomData{
  8086. MsgId: "H44022900158202103301754147728",
  8087. PsnNo: "44020000000229014511",
  8088. Info: "2208",
  8089. }
  8090. customData = append(customData, custom17)
  8091. adminUser := c.GetAdminUserInfo()
  8092. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8093. for _, item := range customData {
  8094. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8095. fmt.Println(result)
  8096. }
  8097. }
  8098. func PathExists(path string) (bool, error) {
  8099. _, err := os.Stat(path)
  8100. if err == nil {
  8101. return true, nil
  8102. }
  8103. if os.IsNotExist(err) {
  8104. return false, nil
  8105. }
  8106. return false, err
  8107. }
  8108. //创建文件夹
  8109. func Mkdir(dir string) {
  8110. // 创建文件夹
  8111. exist, err := PathExists(dir)
  8112. if err != nil {
  8113. fmt.Println(err.Error())
  8114. } else {
  8115. if exist {
  8116. fmt.Println(dir + "文件夹已存在!")
  8117. } else {
  8118. // 文件夹名称,权限
  8119. err := os.Mkdir(dir, os.ModePerm)
  8120. if err != nil {
  8121. fmt.Println(dir+"文件夹创建失败:", err.Error())
  8122. } else {
  8123. fmt.Println(dir + "文件夹创建成功!")
  8124. }
  8125. }
  8126. }
  8127. }
  8128. //压缩文件
  8129. func Zip(srcFile string, destZip string) error {
  8130. zipfile, err := os.Create(destZip)
  8131. if err != nil {
  8132. return err
  8133. }
  8134. defer zipfile.Close()
  8135. archive := zip.NewWriter(zipfile)
  8136. defer archive.Close()
  8137. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  8138. if err != nil {
  8139. return err
  8140. }
  8141. header, err := zip.FileInfoHeader(info)
  8142. if err != nil {
  8143. return err
  8144. }
  8145. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  8146. // header.Name = path
  8147. if info.IsDir() {
  8148. header.Name += "/"
  8149. } else {
  8150. header.Method = zip.Deflate
  8151. }
  8152. writer, err := archive.CreateHeader(header)
  8153. if err != nil {
  8154. return err
  8155. }
  8156. if !info.IsDir() {
  8157. file, err := os.Open(path)
  8158. if err != nil {
  8159. return err
  8160. }
  8161. defer file.Close()
  8162. _, err = io.Copy(writer, file)
  8163. }
  8164. return err
  8165. })
  8166. return err
  8167. }
  8168. func ReadFile(filePath string) []byte {
  8169. f, err := os.Open(filePath)
  8170. if err != nil {
  8171. fmt.Println("read file fail", err)
  8172. return nil
  8173. }
  8174. defer f.Close()
  8175. fd, err := ioutil.ReadAll(f)
  8176. if err != nil {
  8177. fmt.Println("read to fd fail", err)
  8178. return nil
  8179. }
  8180. return fd
  8181. }
  8182. func RemoveRepeatedTeam(arr []*models.HisOrderInfo) (newArr []*models.HisOrderInfo) {
  8183. newArr = make([]*models.HisOrderInfo, 0)
  8184. for i := 0; i < len(arr); i++ {
  8185. repeat := false
  8186. for j := i + 1; j < len(arr); j++ {
  8187. if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
  8188. repeat = true
  8189. break
  8190. }
  8191. }
  8192. if !repeat {
  8193. newArr = append(newArr, arr[i])
  8194. }
  8195. }
  8196. return
  8197. }
  8198. func saveRegisterLog(result string) {
  8199. org_id, _ := beego.AppConfig.Int64("org_id")
  8200. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  8201. dir := miConfig.OrgName + "日志"
  8202. utils.Mkdir(dir)
  8203. month := time.Unix(1557042972, 0).Format("1")
  8204. year := time.Now().Format("2006")
  8205. month = time.Now().Format("01")
  8206. day := time.Now().Format("02")
  8207. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  8208. file_name := file + ".txt"
  8209. file_path := miConfig.OrgName + "日志" + "/" + file_name
  8210. exist, _ := utils.PathExists(file_path)
  8211. if exist { //存在
  8212. fmt.Println("存在")
  8213. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  8214. if err != nil {
  8215. fmt.Println("read fail")
  8216. }
  8217. content := "\r\n" + result
  8218. n, _ := f.Seek(0, 2)
  8219. _, err = f.WriteAt([]byte(content), n)
  8220. } else { //不存在
  8221. fmt.Println("文件不存在,创建文件")
  8222. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  8223. defer f.Close()
  8224. if err != nil {
  8225. } else {
  8226. _, err = f.Write([]byte("记录日志"))
  8227. }
  8228. }
  8229. }
  8230. func saveLog(result string, request string, infno string, desc string) {
  8231. org_id, _ := beego.AppConfig.Int64("org_id")
  8232. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  8233. dir := miConfig.OrgName + "日志"
  8234. utils.Mkdir(dir)
  8235. month := time.Unix(1557042972, 0).Format("1")
  8236. year := time.Now().Format("2006")
  8237. month = time.Now().Format("01")
  8238. day := time.Now().Format("02")
  8239. hour := time.Now().Format("15")
  8240. min := time.Now().Format("04")
  8241. sec := time.Now().Format("05")
  8242. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  8243. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  8244. file_name := file + ".txt"
  8245. file_path := miConfig.OrgName + "日志" + "/" + file_name
  8246. exist, _ := utils.PathExists(file_path)
  8247. if exist { //存在
  8248. fmt.Println("存在")
  8249. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  8250. if err != nil {
  8251. fmt.Println("read fail")
  8252. }
  8253. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  8254. n, _ := f.Seek(0, 2)
  8255. _, err = f.WriteAt([]byte(content), n)
  8256. } else { //不存在
  8257. fmt.Println("文件不存在,创建文件")
  8258. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  8259. defer f.Close()
  8260. if err != nil {
  8261. } else {
  8262. _, err = f.Write([]byte("记录日志"))
  8263. }
  8264. }
  8265. }
  8266. type Charset string
  8267. const (
  8268. UTF8 = Charset("UTF-8")
  8269. GB18030 = Charset("GB18030")
  8270. )
  8271. func ConvertToString(src string, srcCode string, tagCode string) string {
  8272. srcCoder := mahonia.NewDecoder(srcCode)
  8273. srcResult := srcCoder.ConvertString(src)
  8274. tagCoder := mahonia.NewDecoder(tagCode)
  8275. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  8276. result := string(cdata)
  8277. return result
  8278. }