his_api_controller.go 314KB

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