his_api_controller.go 310KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729
  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. admin_user_id, _ := c.GetInt64("admin_user_id")
  2543. timeLayout := "2006-01-02"
  2544. loc, _ := time.LoadLocation("Local")
  2545. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  2546. birthUnix := birthdays.Unix()
  2547. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2548. if err != nil {
  2549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2550. return
  2551. }
  2552. recordDateTime := theTime.Unix()
  2553. adminInfo := c.GetAdminUserInfo()
  2554. var patient service.Patients
  2555. if id == 0 {
  2556. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  2557. } else {
  2558. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  2559. }
  2560. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2561. if patientPrescription.ID == 0 {
  2562. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2563. }
  2564. //adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  2565. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  2566. //sickConfig, _ := service.FindSickById(sick_type)
  2567. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2568. if patient.ID == 0 {
  2569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  2570. return
  2571. }
  2572. if len(patient.IdCardNo) == 0 {
  2573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  2574. return
  2575. }
  2576. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2577. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  2578. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  2579. //就诊结算未完成,不能进行二次挂号
  2580. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  2581. if len(his) >= 1 {
  2582. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  2583. if len(his) >= 1 && order.ID == 0 {
  2584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  2585. return
  2586. }
  2587. }
  2588. //var register_log string
  2589. if config.IsOpen == 1 {
  2590. var res ResultTwo
  2591. var res10265 ResultTwo10265
  2592. var PsnNo string
  2593. var PsnCertType string
  2594. var Certno string
  2595. var PsnName string
  2596. var Gend string
  2597. var Naty string
  2598. var Brdy string
  2599. var Age float64
  2600. var infoStr string
  2601. var idetinfoStr string
  2602. var infocode int64
  2603. if miConfig.MdtrtareaAdmvs == "421300" {
  2604. psn_info, _ := service.GetPsnByPatientId(id)
  2605. PsnNo = psn_info.PsnNo
  2606. PsnCertType = psn_info.PsnCertType
  2607. Certno = psn_info.Certno
  2608. PsnName = psn_info.PsnName
  2609. Gend = psn_info.Gend
  2610. Naty = psn_info.Naty
  2611. Brdy = psn_info.Brdy
  2612. Age = psn_info.Age
  2613. infoStr = psn_info.Insuinfo
  2614. idetinfoStr = psn_info.Idetinfo
  2615. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2616. var res ResultTwo
  2617. api := "http://192.168.3.130:9532/" + "jsyb/1101?cert_no=" + "" +
  2618. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2619. "&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=" + "fb4f41a047934d588a89cdac7a102410"
  2620. resp, requestErr := http.Get(api)
  2621. if requestErr != nil {
  2622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2623. return
  2624. }
  2625. body, ioErr := ioutil.ReadAll(resp.Body)
  2626. if ioErr != nil {
  2627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2629. return
  2630. }
  2631. var respJSON map[string]interface{}
  2632. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2635. return
  2636. }
  2637. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2638. result, _ := json.Marshal(respJSON)
  2639. fmt.Println("log")
  2640. fmt.Println(string(result))
  2641. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2642. utils.ErrorLog("解析失败:%v", err)
  2643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2644. return
  2645. }
  2646. } else {
  2647. 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)
  2648. saveLog(result, requestLog, "1101", "人员基本信息获取")
  2649. if miConfig.Code == "H15049901371" {
  2650. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2651. utils.ErrorLog("解析失败:%v", err)
  2652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2653. return
  2654. }
  2655. res.ErrMsg = res10265.ErrMsg
  2656. res.Output = res10265.Output
  2657. res.InfRefmsgid = res10265.InfRefmsgid
  2658. } else {
  2659. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2660. utils.ErrorLog("解析失败:%v", err)
  2661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2662. return
  2663. }
  2664. }
  2665. PsnNo = res.Output.Baseinfo.PsnNo
  2666. PsnCertType = res.Output.Baseinfo.PsnCertType
  2667. Certno = res.Output.Baseinfo.Certno
  2668. PsnName = res.Output.Baseinfo.PsnName
  2669. Gend = res.Output.Baseinfo.Gend
  2670. Naty = res.Output.Baseinfo.Naty
  2671. Brdy = res.Output.Baseinfo.Brdy
  2672. Age = res.Output.Baseinfo.Age
  2673. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2674. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2675. infoStr = string(Iinfos)
  2676. idetinfoStr = string(Idetinfos)
  2677. if miConfig.Code == "H15049901371" {
  2678. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  2679. } else {
  2680. infocode = res.Infcode
  2681. }
  2682. }
  2683. if infocode == 0 {
  2684. his := models.VMHisPatient{
  2685. Name: name,
  2686. Gender: gender,
  2687. Birthday: birthUnix,
  2688. MedicalTreatmentType: medical_care,
  2689. IdType: certificates,
  2690. IdCardNo: id_card,
  2691. BalanceAccountsType: settlementValue,
  2692. SocialType: social_type,
  2693. MedicalInsuranceNumber: medical_insurance_card,
  2694. RegisterType: register_type,
  2695. RegisterCost: registration_fee,
  2696. TreatmentCost: medical_expenses,
  2697. Status: 1,
  2698. Ctime: time.Now().Unix(),
  2699. Mtime: time.Now().Unix(),
  2700. PsnNo: PsnNo,
  2701. PsnCertType: PsnCertType,
  2702. Certno: Certno,
  2703. PsnName: PsnName,
  2704. Gend: Gend,
  2705. Naty: Naty,
  2706. Brdy: Brdy,
  2707. Age: Age,
  2708. Iinfo: infoStr,
  2709. Idetinfo: idetinfoStr,
  2710. PatientId: patient.ID,
  2711. RecordDate: theTime.Unix(),
  2712. UserOrgId: adminInfo.CurrentOrgId,
  2713. AdminUserId: admin_user_id,
  2714. IsReturn: 1,
  2715. IdCardType: id_card_type,
  2716. Doctor: doctor,
  2717. Departments: department,
  2718. }
  2719. timestamp := time.Now().Unix()
  2720. tempTime := time.Unix(timestamp, 0)
  2721. timeFormat := tempTime.Format("20060102150405")
  2722. chrgBchno := rand.Intn(100000) + 10000
  2723. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2724. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  2725. department, _ := service.GetDepartMentDetail(department)
  2726. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  2727. IdCardNo := ""
  2728. if id_card_type == 1 {
  2729. // IdCardNo = medical_insurance_card
  2730. IdCardNo = patient.IdCardNo
  2731. } else {
  2732. IdCardNo = patient.IdCardNo
  2733. }
  2734. var rf []*ResultFive
  2735. json.Unmarshal([]byte(his.Iinfo), &rf)
  2736. var insutypes []*ResultFive
  2737. var insutype string
  2738. var insuplc_admdvs string
  2739. var is390 int = 0
  2740. var is310 int = 0
  2741. for _, item := range rf {
  2742. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2743. insutypes = append(insutypes, item)
  2744. }
  2745. }
  2746. if len(insutypes) == 1 {
  2747. insutype = insutypes[0].Insutype
  2748. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2749. } else {
  2750. for _, i := range insutypes {
  2751. if i.Insutype == "390" {
  2752. is390 = 1
  2753. }
  2754. if i.Insutype == "310" {
  2755. is310 = 1
  2756. }
  2757. }
  2758. }
  2759. if is390 == 1 {
  2760. insutype = "390"
  2761. }
  2762. if is310 == 1 {
  2763. insutype = "310"
  2764. }
  2765. if len(insutypes) == 0 {
  2766. insutype = "310"
  2767. }
  2768. if len(insutypes) == 2 {
  2769. insutype = med_type
  2770. }
  2771. if len(med_type) > 0 {
  2772. insutype = med_type
  2773. }
  2774. for _, item := range rf {
  2775. if item.Insutype == insutype {
  2776. insuplc_admdvs = item.InsuplcAdmdvs
  2777. }
  2778. }
  2779. var infocode int64
  2780. var resThree ResultThree
  2781. var resThree10265 ResultThree10265
  2782. if miConfig.MdtrtareaAdmvs == "421300" {
  2783. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  2784. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2785. "&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
  2786. resp, requestErr := http.Get(api)
  2787. if requestErr != nil {
  2788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2789. return
  2790. }
  2791. body, ioErr := ioutil.ReadAll(resp.Body)
  2792. if ioErr != nil {
  2793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2795. return
  2796. }
  2797. var respJSON map[string]interface{}
  2798. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2801. return
  2802. }
  2803. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2804. result, _ := json.Marshal(respJSON)
  2805. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2806. utils.ErrorLog("解析失败:%v", err)
  2807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2808. return
  2809. }
  2810. infocode = resThree.Infcode
  2811. } else {
  2812. 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)
  2813. saveLog(result, requestLog, "2201", "挂号")
  2814. if miConfig.Code == "H15049901371" {
  2815. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  2816. utils.ErrorLog("解析失败:%v", err)
  2817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2818. return
  2819. }
  2820. resThree.ErrMsg = resThree10265.ErrMsg
  2821. resThree.Output = resThree10265.Output
  2822. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  2823. } else {
  2824. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2825. utils.ErrorLog("解析失败:%v", err)
  2826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2827. return
  2828. }
  2829. }
  2830. if miConfig.Code == "H15049901371" {
  2831. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  2832. } else {
  2833. infocode = resThree.Infcode
  2834. }
  2835. }
  2836. if infocode != 0 {
  2837. adminUser := c.GetAdminUserInfo()
  2838. errlog := &models.HisOrderError{
  2839. UserOrgId: adminUser.CurrentOrgId,
  2840. Ctime: time.Now().Unix(),
  2841. Mtime: time.Now().Unix(),
  2842. ErrMsg: resThree.ErrMsg,
  2843. Status: 1,
  2844. PatientId: id,
  2845. RecordTime: recordDateTime,
  2846. Stage: 2,
  2847. }
  2848. service.CreateErrMsgLog(errlog)
  2849. c.ServeSuccessJSON(map[string]interface{}{
  2850. "failed_code": -10,
  2851. "msg": resThree.ErrMsg,
  2852. })
  2853. return
  2854. }
  2855. his.Number = resThree.Output.Data.MdtrtID
  2856. his.PsnNo = resThree.Output.Data.PsnNo
  2857. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  2858. his.IdCardNo = patient.IdCardNo
  2859. his.PhoneNumber = patient.Phone
  2860. his.UserOrgId = adminInfo.CurrentOrgId
  2861. his.Insutype = insutype
  2862. his.Ctime = time.Now().Unix()
  2863. his.Mtime = time.Now().Unix()
  2864. his.InsuplcAdmdvs = insuplc_admdvs
  2865. his.Status = 1
  2866. service.UpdateHisPatientStatus(&his)
  2867. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  2868. c.ServeSuccessJSON(map[string]interface{}{
  2869. "his_info": his,
  2870. })
  2871. } else {
  2872. adminUser := c.GetAdminUserInfo()
  2873. errlog := &models.HisOrderError{
  2874. UserOrgId: adminUser.CurrentOrgId,
  2875. Ctime: time.Now().Unix(),
  2876. Mtime: time.Now().Unix(),
  2877. ErrMsg: res.ErrMsg,
  2878. Status: 1,
  2879. PatientId: id,
  2880. RecordTime: recordDateTime,
  2881. Stage: 1,
  2882. }
  2883. service.CreateErrMsgLog(errlog)
  2884. c.ServeSuccessJSON(map[string]interface{}{
  2885. "failed_code": -10,
  2886. "msg": res.ErrMsg,
  2887. })
  2888. return
  2889. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  2890. }
  2891. }
  2892. }
  2893. //上传明细----预结算----确认订单
  2894. func (c *HisApiController) GetUploadInfo() {
  2895. id, _ := c.GetInt64("id")
  2896. record_time := c.GetString("record_time")
  2897. his_patient_id, _ := c.GetInt64("his_patient_id")
  2898. order_id, _ := c.GetInt64("order_id")
  2899. pay_way, _ := c.GetInt64("pay_way")
  2900. pay_price, _ := c.GetFloat("pay_price")
  2901. pay_card_no := c.GetString("pay_card_no")
  2902. discount_price, _ := c.GetFloat("discount_price")
  2903. preferential_price, _ := c.GetFloat("preferential_price")
  2904. reality_price, _ := c.GetFloat("reality_price")
  2905. found_price, _ := c.GetFloat("found_price")
  2906. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2907. private_price, _ := c.GetFloat("private_price")
  2908. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2909. admin_user_id, _ := c.GetInt64("admin_user_id")
  2910. fapiao_code := c.GetString("fapiao_code")
  2911. fapiao_number := c.GetString("fapiao_number")
  2912. diagnosis_id := c.GetString("diagnosis")
  2913. sick_type, _ := c.GetInt64("sick_type")
  2914. reg_type, _ := c.GetInt64("p_type")
  2915. id_str := c.GetString("ids")
  2916. ids_arr := strings.Split(id_str, ",")
  2917. timeLayout := "2006-01-02"
  2918. loc, _ := time.LoadLocation("Local")
  2919. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2920. if err != nil {
  2921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2922. return
  2923. }
  2924. recordDateTime := theTime.Unix()
  2925. adminUser := c.GetAdminUserInfo()
  2926. var tempOrder models.HisOrder
  2927. tempOrder, _ = service.GetHisOrderByID(order_id)
  2928. var prescriptions []*models.HisPrescription
  2929. var start_time int64
  2930. var end_time int64
  2931. //if adminUser.CurrentOrgId == 10106{
  2932. // if len(fapiao_code) == 0{
  2933. // fapiao_code = "144072080589"
  2934. // }
  2935. // if len(fapiao_number) == 0{
  2936. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  2937. // if order.ID == 0{
  2938. // fapiao_number = "00001520"
  2939. // }else{
  2940. // //fapiao_code = "00001520"
  2941. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  2942. // var zero string
  2943. // if fpNumber >= 1000{
  2944. // zero = "0000" + strconv.Itoa(fpNumber)
  2945. // }else if fpNumber >= 10000{
  2946. // zero = "000" + strconv.Itoa(fpNumber)
  2947. // } else if fpNumber >= 100000{
  2948. // zero = "00" + strconv.Itoa(fpNumber)
  2949. // } else if fpNumber >= 1000000{
  2950. // zero = "0" + strconv.Itoa(fpNumber)
  2951. // }else {
  2952. // zero = strconv.Itoa(fpNumber)
  2953. // }
  2954. // fapiao_number = zero
  2955. // }
  2956. // }
  2957. //}
  2958. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2959. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2960. var patientPrescription models.HisPrescriptionInfo
  2961. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2962. if patientPrescription.ID == 0 {
  2963. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2964. }
  2965. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2966. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2967. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2968. diagnosis_ids := strings.Split(diagnosis_id, ",")
  2969. var config []*models.HisXtDiagnoseConfig
  2970. for _, item := range diagnosis_ids {
  2971. id, _ := strconv.ParseInt(item, 10, 64)
  2972. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2973. config = append(config, &diagnosisConfig)
  2974. }
  2975. sickConfig, _ := service.FindSickById(sick_type)
  2976. if tempOrder.ID == 0 {
  2977. tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  2978. }
  2979. if tempOrder.ID == 0 {
  2980. var result string
  2981. var requestLog string
  2982. var res2 ResultSix
  2983. var ressix10265 ResultSix10265
  2984. if miConfig.InsuplcAdmdvs == "421300" {
  2985. data := make(map[string]interface{})
  2986. client := &http.Client{}
  2987. data["psn_no"] = his.PsnNo
  2988. data["mdtrt_id"] = his.Number
  2989. data["doctor"] = roles.UserName
  2990. data["department"] = department.Name
  2991. data["org_name"] = miConfig.OrgName
  2992. data["med_type"] = strconv.FormatInt(reg_type, 10)
  2993. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  2994. data["fixmedins_code"] = miConfig.Code
  2995. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2996. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2997. data["secret_key"] = miConfig.SecretKey
  2998. data["sick_code"] = sickConfig.CountryCode
  2999. data["sick_name"] = sickConfig.ClassName
  3000. data["dept"] = strconv.FormatInt(department.ID, 10)
  3001. data["config"] = config
  3002. bytesData, _ := json.Marshal(data)
  3003. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3004. resp, _ := client.Do(req)
  3005. defer resp.Body.Close()
  3006. body, ioErr := ioutil.ReadAll(resp.Body)
  3007. if ioErr != nil {
  3008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3010. return
  3011. }
  3012. var respJSON map[string]interface{}
  3013. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3016. return
  3017. }
  3018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3019. userJSONBytes, _ := json.Marshal(respJSON)
  3020. fmt.Println("log")
  3021. fmt.Println(string(userJSONBytes))
  3022. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3023. utils.ErrorLog("解析失败:%v", err)
  3024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3025. return
  3026. }
  3027. } else {
  3028. if miConfig.InsuplcAdmdvs == "440781" { //
  3029. 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)
  3030. } else {
  3031. if miConfig.Code == "H15049901371" {
  3032. //赤峰地区国家医保医疗类别
  3033. //职工透析:医疗类别选特殊情况门诊990502
  3034. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3035. var med_type string
  3036. if his.Insutype == "390" {
  3037. if reg_type == 14 {
  3038. med_type = "9933"
  3039. } else if reg_type == 11 {
  3040. med_type = "11"
  3041. }
  3042. } else if his.Insutype == "310" {
  3043. if reg_type == 14 {
  3044. med_type = "990502"
  3045. } else if reg_type == 11 {
  3046. med_type = "11"
  3047. }
  3048. }
  3049. 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)
  3050. } else {
  3051. 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)
  3052. }
  3053. }
  3054. saveLog(result, requestLog, "2203", "上传就诊信息")
  3055. var respJSON2 map[string]interface{}
  3056. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3059. return
  3060. }
  3061. userJSONBytes2, _ := json.Marshal(respJSON2)
  3062. if miConfig.Code == "H15049901371" {
  3063. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3064. utils.ErrorLog("解析失败:%v", err)
  3065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3066. return
  3067. }
  3068. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3069. res2.Output = ressix10265.Output
  3070. res2.ErrMsg = ressix10265.ErrMsg
  3071. res2.Cainfo = ressix10265.Cainfo
  3072. res2.WarnMsg = ressix10265.WarnMsg
  3073. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3074. res2.Infcode = infocode
  3075. } else {
  3076. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3077. utils.ErrorLog("解析失败:%v", err)
  3078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3079. return
  3080. }
  3081. }
  3082. }
  3083. if res2.Infcode != 0 {
  3084. adminUser := c.GetAdminUserInfo()
  3085. errlog := &models.HisOrderError{
  3086. UserOrgId: adminUser.CurrentOrgId,
  3087. Ctime: time.Now().Unix(),
  3088. Mtime: time.Now().Unix(),
  3089. ErrMsg: res2.ErrMsg,
  3090. Status: 1,
  3091. PatientId: id,
  3092. RecordTime: recordDateTime,
  3093. Stage: 3,
  3094. }
  3095. service.CreateErrMsgLog(errlog)
  3096. c.ServeSuccessJSON(map[string]interface{}{
  3097. "failed_code": -10,
  3098. "msg": res2.ErrMsg,
  3099. })
  3100. return
  3101. } else {
  3102. his.Diagnosis = diagnosis_id
  3103. his.SickType = sickConfig.ID
  3104. var p_type int64
  3105. if reg_type == 1111 || reg_type == 1112 {
  3106. p_type = 11
  3107. }
  3108. his.PType = fmt.Sprintf("%d", p_type)
  3109. service.UpdateHisPatientThree(&his)
  3110. data := make(map[string]interface{})
  3111. if settle_accounts_type == 1 { //日结
  3112. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3113. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3114. } else {
  3115. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3116. }
  3117. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3118. data["pre"] = prescriptions
  3119. } else { //月结
  3120. start_time_str := c.GetString("start_time")
  3121. end_time_str := c.GetString("end_time")
  3122. timeLayout := "2006-01-02"
  3123. loc, _ := time.LoadLocation("Local")
  3124. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3125. if err != nil {
  3126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3127. return
  3128. }
  3129. recordStartTime := theStartTime.Unix()
  3130. start_time = recordStartTime
  3131. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3132. if err != nil {
  3133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3134. return
  3135. }
  3136. recordEndTime := theEndTime.Unix()
  3137. end_time = recordEndTime
  3138. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3139. data["pre"] = prescriptions
  3140. }
  3141. timestamp := time.Now().Unix()
  3142. tempTime := time.Unix(timestamp, 0)
  3143. timeFormat := tempTime.Format("20060102150405")
  3144. chrgBchno := rand.Intn(100000) + 10000
  3145. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3146. strconv.FormatInt(his.PatientId, 10)
  3147. client := &http.Client{}
  3148. data["psn_no"] = his.PsnNo
  3149. data["mdtrt_id"] = his.Number
  3150. data["chrg_bchno"] = chrg_bchno
  3151. data["org_name"] = miConfig.OrgName
  3152. data["doctor"] = roles.UserName
  3153. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3154. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3155. data["fixmedins_code"] = miConfig.Code
  3156. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3157. data["dept_code"] = "15"
  3158. } else {
  3159. data["dept_code"] = department.Number
  3160. }
  3161. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3162. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3163. data["secret_key"] = miConfig.SecretKey
  3164. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3165. var ids []int64
  3166. for _, item := range prescriptions {
  3167. ids = append(ids, item.ID)
  3168. }
  3169. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3170. if config.IsOpen == 1 { //对接了医保,走医保流程
  3171. var res ResultFour
  3172. var resFour10265 ResultFour10265
  3173. if miConfig.MdtrtareaAdmvs == "421300" {
  3174. bytesData, _ := json.Marshal(data)
  3175. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3176. resp, _ := client.Do(req)
  3177. defer resp.Body.Close()
  3178. body, ioErr := ioutil.ReadAll(resp.Body)
  3179. if ioErr != nil {
  3180. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3182. return
  3183. }
  3184. var respJSON map[string]interface{}
  3185. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3188. return
  3189. }
  3190. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3191. userJSONBytes, _ := json.Marshal(respJSON)
  3192. fmt.Println("log")
  3193. fmt.Println(string(userJSONBytes))
  3194. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3195. utils.ErrorLog("解析失败:%v", err)
  3196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3197. return
  3198. }
  3199. } else {
  3200. if miConfig.Code == "H15049901371" {
  3201. 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)
  3202. var dat map[string]interface{}
  3203. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3204. fmt.Println(dat)
  3205. } else {
  3206. fmt.Println(err)
  3207. }
  3208. saveLog(result, request_log, "2204", "上传费用明细")
  3209. userJSONBytes, _ := json.Marshal(dat)
  3210. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3211. utils.ErrorLog("解析失败:%v", err)
  3212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3213. return
  3214. }
  3215. res.InfRefmsgid = resFour10265.InfRefmsgid
  3216. res.Output = resFour10265.Output
  3217. res.ErrMsg = resFour10265.ErrMsg
  3218. res.Cainfo = resFour10265.Cainfo
  3219. res.WarnMsg = resFour10265.WarnMsg
  3220. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3221. res.Infcode = infocode
  3222. } else {
  3223. 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)
  3224. var dat map[string]interface{}
  3225. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3226. fmt.Println(dat)
  3227. } else {
  3228. fmt.Println(err)
  3229. }
  3230. saveLog(result, request_log, "2204", "上传费用明细")
  3231. userJSONBytes, _ := json.Marshal(dat)
  3232. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3233. utils.ErrorLog("解析失败:%v", err)
  3234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3235. return
  3236. }
  3237. }
  3238. }
  3239. if res.Infcode == 0 {
  3240. order := &models.HisOrder{
  3241. UserOrgId: adminUser.CurrentOrgId,
  3242. HisPatientId: his.ID,
  3243. PatientId: his.PatientId,
  3244. SettleAccountsDate: recordDateTime,
  3245. Ctime: time.Now().Unix(),
  3246. Mtime: time.Now().Unix(),
  3247. Status: 1,
  3248. Number: chrg_bchno,
  3249. Infcode: res.Infcode,
  3250. WarnMsg: res.WarnMsg,
  3251. Cainfo: res.Cainfo,
  3252. ErrMsg: res.ErrMsg,
  3253. RespondTime: res.RefmsgTime,
  3254. InfRefmsgid: res.InfRefmsgid,
  3255. OrderStatus: 1,
  3256. PayWay: pay_way,
  3257. PayPrice: pay_price,
  3258. PayCardNo: pay_card_no,
  3259. DiscountPrice: discount_price,
  3260. PreferentialPrice: preferential_price,
  3261. RealityPrice: reality_price,
  3262. FoundPrice: found_price,
  3263. MedicalInsurancePrice: medical_insurance_price,
  3264. PrivatePrice: private_price,
  3265. IsMedicineInsurance: 1,
  3266. SettleType: settle_accounts_type,
  3267. SettleStartTime: start_time,
  3268. SettleEndTime: end_time,
  3269. Creator: roles.AdminUserId,
  3270. Modify: roles.AdminUserId,
  3271. FaPiaoNumber: fapiao_number,
  3272. FaPiaoCode: fapiao_code,
  3273. PType: 2,
  3274. Diagnosis: diagnosis_id,
  3275. }
  3276. err = service.CreateOrder(order)
  3277. if err != nil {
  3278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3279. return
  3280. }
  3281. for _, item := range res.Output.Result {
  3282. temp := strings.Split(item.FeedetlSn, "-")
  3283. var advice_id int64 = 0
  3284. var project_id int64 = 0
  3285. var types int64 = 0
  3286. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3287. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3288. if temp[1] == "1" {
  3289. advice_id = id
  3290. project_id = 0
  3291. } else if temp[1] == "2" {
  3292. advice_id = 0
  3293. project_id = id
  3294. }
  3295. info := &models.HisOrderInfo{
  3296. OrderNumber: order.Number,
  3297. FeedetlSn: item.FeedetlSn,
  3298. UploadDate: time.Now().Unix(),
  3299. AdviceId: advice_id,
  3300. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3301. Cnt: item.Cnt,
  3302. Pric: float64(item.Pric),
  3303. PatientId: his.PatientId,
  3304. PricUplmtAmt: item.PricUplmtAmt,
  3305. SelfpayProp: item.SelfpayProp,
  3306. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3307. OverlmtAmt: item.OverlmtAmt,
  3308. PreselfpayAmt: item.PreselfpayAmt,
  3309. BasMednFlag: item.BasMednFlag,
  3310. MedChrgitmType: item.MedChrgitmType,
  3311. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3312. Status: 1,
  3313. Memo: item.Memo,
  3314. Mtime: time.Now().Unix(),
  3315. InscpScpAmt: item.InscpScpAmt,
  3316. DrtReimFlag: item.DrtReimFlag,
  3317. Ctime: time.Now().Unix(),
  3318. ListSpItemFlag: item.ListSpItemFlag,
  3319. ChldMedcFlag: item.ChldMedcFlag,
  3320. LmtUsedFlag: item.LmtUsedFlag,
  3321. ChrgitmLv: item.ChrgitmLv,
  3322. UserOrgId: adminUser.CurrentOrgId,
  3323. HisPatientId: his.ID,
  3324. OrderId: order.ID,
  3325. ProjectId: project_id,
  3326. Type: types,
  3327. }
  3328. service.CreateOrderInfo(info)
  3329. }
  3330. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3331. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3332. var total float64
  3333. for _, item := range prescriptions {
  3334. if item.Type == 1 { //药品
  3335. for _, subItem := range item.HisDoctorAdviceInfo {
  3336. total = total + (subItem.Price * subItem.PrescribingNumber)
  3337. }
  3338. }
  3339. if item.Type == 2 { //项目
  3340. for _, subItem := range item.HisPrescriptionProject {
  3341. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3342. total = total + (subItem.Price * cnt)
  3343. }
  3344. }
  3345. }
  3346. for _, item := range prescriptions {
  3347. for _, subItem := range item.HisAdditionalCharge {
  3348. total = total + (subItem.Price * float64(subItem.Count))
  3349. }
  3350. }
  3351. var allTotal string
  3352. if adminUser.CurrentOrgId == 9919 {
  3353. allTotal = fmt.Sprintf("%.4f", total)
  3354. } else {
  3355. allTotal = fmt.Sprintf("%.4f", total)
  3356. }
  3357. if res.Infcode == 0 {
  3358. var rf []*ResultFive
  3359. json.Unmarshal([]byte(his.Iinfo), &rf)
  3360. chrg_bchno := chrg_bchno
  3361. cert_no := his.Certno
  3362. var insutypes []string
  3363. var insutype string
  3364. var is390 int = 0
  3365. var is310 int = 0
  3366. for _, item := range rf {
  3367. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3368. insutypes = append(insutypes, item.Insutype)
  3369. }
  3370. }
  3371. if len(insutypes) == 1 {
  3372. insutype = insutypes[0]
  3373. } else {
  3374. for _, i := range insutypes {
  3375. if i == "390" {
  3376. is390 = 1
  3377. }
  3378. if i == "310" {
  3379. is310 = 1
  3380. }
  3381. }
  3382. }
  3383. if is390 == 1 {
  3384. insutype = "390"
  3385. }
  3386. if is310 == 1 {
  3387. insutype = "310"
  3388. }
  3389. if len(insutypes) == 0 {
  3390. insutype = "310"
  3391. }
  3392. if len(insutypes) == 2 {
  3393. insutype = strconv.FormatInt(his.SocialType, 10)
  3394. }
  3395. insutype = strconv.FormatInt(his.SocialType, 10)
  3396. //insutype = "390"
  3397. if his.IdCardType == 1 {
  3398. // cert_no = his.MedicalInsuranceNumber
  3399. cert_no = his.Certno
  3400. } else {
  3401. cert_no = his.Certno
  3402. }
  3403. var res ResultSeven
  3404. var resSeven10265 ResultSeven10265
  3405. var src_resquest string
  3406. var result2 string
  3407. var acct_used_flag string
  3408. fmt.Println("pay_way")
  3409. fmt.Println(pay_way)
  3410. fmt.Println("pay_way")
  3411. if pay_way == 4 {
  3412. acct_used_flag = "1"
  3413. } else {
  3414. acct_used_flag = "0"
  3415. }
  3416. if miConfig.MdtrtareaAdmvs == "421300" {
  3417. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3418. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3419. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3420. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3421. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3422. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3423. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3424. resp, requestErr := http.Get(api)
  3425. if requestErr != nil {
  3426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3427. return
  3428. }
  3429. body, ioErr := ioutil.ReadAll(resp.Body)
  3430. if ioErr != nil {
  3431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3433. return
  3434. }
  3435. var respJSON map[string]interface{}
  3436. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3439. return
  3440. }
  3441. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3442. result, _ := json.Marshal(respJSON)
  3443. if miConfig.Code == "H15049901371" {
  3444. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3445. utils.ErrorLog("解析失败:%v", err)
  3446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3447. return
  3448. }
  3449. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3450. res.Output = resSeven10265.Output
  3451. res.ErrMsg = resSeven10265.ErrMsg
  3452. res.Cainfo = resSeven10265.Cainfo
  3453. res.WarnMsg = resSeven10265.WarnMsg
  3454. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3455. res.Infcode = infocode
  3456. } else {
  3457. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3458. utils.ErrorLog("解析失败:%v", err)
  3459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3460. return
  3461. }
  3462. }
  3463. } else {
  3464. if miConfig.Code == "H15049901371" {
  3465. //赤峰地区国家医保医疗类别
  3466. //职工透析:医疗类别选特殊情况门诊990502
  3467. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3468. var med_type string
  3469. if his.Insutype == "390" {
  3470. if reg_type == 14 {
  3471. med_type = "9933"
  3472. } else if reg_type == 11 {
  3473. med_type = "11"
  3474. }
  3475. } else if his.Insutype == "310" {
  3476. if reg_type == 14 {
  3477. med_type = "990502"
  3478. } else if reg_type == 11 {
  3479. med_type = "11"
  3480. }
  3481. }
  3482. 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)
  3483. } else {
  3484. 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)
  3485. }
  3486. //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)
  3487. var dat map[string]interface{}
  3488. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3489. fmt.Println(dat)
  3490. } else {
  3491. fmt.Println(err)
  3492. }
  3493. saveLog(result2, src_resquest, "2207", "结算")
  3494. userJSONBytes, _ := json.Marshal(dat)
  3495. if miConfig.Code == "H15049901371" {
  3496. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3497. utils.ErrorLog("解析失败:%v", err)
  3498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3499. return
  3500. }
  3501. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3502. res.Output = resSeven10265.Output
  3503. res.ErrMsg = resSeven10265.ErrMsg
  3504. res.Cainfo = resSeven10265.Cainfo
  3505. res.WarnMsg = resSeven10265.WarnMsg
  3506. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3507. res.Infcode = infocode
  3508. } else {
  3509. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3510. utils.ErrorLog("解析失败:%v", err)
  3511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3512. return
  3513. }
  3514. }
  3515. }
  3516. if res.Infcode != 0 {
  3517. errlog := &models.HisOrderError{
  3518. UserOrgId: adminUser.CurrentOrgId,
  3519. Ctime: time.Now().Unix(),
  3520. Mtime: time.Now().Unix(),
  3521. Number: chrg_bchno,
  3522. ErrMsg: res.ErrMsg,
  3523. Status: 1,
  3524. PatientId: id,
  3525. RecordTime: recordDateTime,
  3526. Stage: 6,
  3527. }
  3528. service.CreateErrMsgLog(errlog)
  3529. c.ServeSuccessJSON(map[string]interface{}{
  3530. "failed_code": -10,
  3531. "msg": res.ErrMsg,
  3532. })
  3533. return
  3534. } else {
  3535. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3536. order.OrderStatus = 2
  3537. order.Status = 1
  3538. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3539. order.SetlId = res.Output.Setlinfo.SetlID
  3540. order.PsnNo = res.Output.Setlinfo.PsnNo
  3541. order.PsnName = res.Output.Setlinfo.PsnName
  3542. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3543. order.Certno = res.Output.Setlinfo.Certno
  3544. order.Gend = res.Output.Setlinfo.Gend
  3545. order.Naty = res.Output.Setlinfo.Naty
  3546. order.Age = res.Output.Setlinfo.Age
  3547. order.Insutype = res.Output.Setlinfo.Insutype
  3548. order.PsnType = res.Output.Setlinfo.PsnType
  3549. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3550. order.SetlTime = res.Output.Setlinfo.SetlTime
  3551. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3552. if res.Output.Setlinfo.MedType == "140101" {
  3553. order.MedType = "14"
  3554. } else {
  3555. order.MedType = res.Output.Setlinfo.MedType
  3556. }
  3557. if reg_type == 1112 {
  3558. order.MedType = "1112"
  3559. }
  3560. if reg_type == 1111 {
  3561. order.MedType = "1111"
  3562. }
  3563. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3564. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3565. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3566. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3567. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3568. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3569. order.HifpPay = res.Output.Setlinfo.HifpPay
  3570. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3571. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3572. order.HifesPay = res.Output.Setlinfo.HifesPay
  3573. order.HifobPay = res.Output.Setlinfo.HifobPay
  3574. order.MafPay = res.Output.Setlinfo.MafPay
  3575. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3576. order.OthPay = res.Output.Setlinfo.OthPay
  3577. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3578. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3579. order.AcctPay = res.Output.Setlinfo.AcctPay
  3580. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3581. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3582. order.Balc = res.Output.Setlinfo.Balc
  3583. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3584. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3585. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3586. order.ClrWay = res.Output.Setlinfo.ClrWay
  3587. order.Creator = order.Creator
  3588. order.Modify = roles.AdminUserId
  3589. order.RequestLog = src_resquest
  3590. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3591. detailStr := string(setlDetail)
  3592. order.SetlDetail = detailStr
  3593. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3594. err = service.UpDateOrder(order)
  3595. if err == nil {
  3596. c.ServeSuccessJSON(map[string]interface{}{
  3597. "msg": "结算成功",
  3598. })
  3599. } else {
  3600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3601. return
  3602. }
  3603. }
  3604. } else {
  3605. adminUser := c.GetAdminUserInfo()
  3606. errlog := &models.HisOrderError{
  3607. UserOrgId: adminUser.CurrentOrgId,
  3608. Ctime: time.Now().Unix(),
  3609. Mtime: time.Now().Unix(),
  3610. ErrMsg: res.ErrMsg,
  3611. Status: 1,
  3612. PatientId: id,
  3613. RecordTime: recordDateTime,
  3614. Stage: 4,
  3615. }
  3616. service.CreateErrMsgLog(errlog)
  3617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3618. return
  3619. }
  3620. } else {
  3621. adminUser := c.GetAdminUserInfo()
  3622. errlog := &models.HisOrderError{
  3623. UserOrgId: adminUser.CurrentOrgId,
  3624. Ctime: time.Now().Unix(),
  3625. Mtime: time.Now().Unix(),
  3626. ErrMsg: res.ErrMsg,
  3627. Status: 1,
  3628. PatientId: id,
  3629. RecordTime: recordDateTime,
  3630. Stage: 4,
  3631. }
  3632. service.CreateErrMsgLog(errlog)
  3633. c.ServeSuccessJSON(map[string]interface{}{
  3634. "failed_code": -10,
  3635. "msg": res.ErrMsg,
  3636. })
  3637. return
  3638. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3639. //return
  3640. }
  3641. }
  3642. }
  3643. } else if tempOrder.ID > 0 {
  3644. if tempOrder.IsPre == 1 {
  3645. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  3646. var rf []*ResultFive
  3647. json.Unmarshal([]byte(his.Iinfo), &rf)
  3648. chrg_bchno := tempOrder.Number
  3649. cert_no := his.Certno
  3650. var insutypes []string
  3651. var insutype string
  3652. var is390 int = 0
  3653. var is310 int = 0
  3654. for _, item := range rf {
  3655. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3656. insutypes = append(insutypes, item.Insutype)
  3657. }
  3658. }
  3659. if len(insutypes) == 1 {
  3660. insutype = insutypes[0]
  3661. } else {
  3662. for _, i := range insutypes {
  3663. if i == "390" {
  3664. is390 = 1
  3665. }
  3666. if i == "310" {
  3667. is310 = 1
  3668. }
  3669. }
  3670. }
  3671. if is390 == 1 {
  3672. insutype = "390"
  3673. }
  3674. if is310 == 1 {
  3675. insutype = "310"
  3676. }
  3677. if len(insutypes) == 0 {
  3678. insutype = "310"
  3679. }
  3680. if len(insutypes) == 2 {
  3681. insutype = strconv.FormatInt(his.SocialType, 64)
  3682. }
  3683. //insutype = "390"
  3684. if his.IdCardType == 1 {
  3685. // cert_no = his.MedicalInsuranceNumber
  3686. cert_no = his.Certno
  3687. } else {
  3688. cert_no = his.Certno
  3689. }
  3690. var res ResultSeven
  3691. var resSeven10265 ResultSeven10265
  3692. var src_resquest string
  3693. var result2 string
  3694. var acct_used_flag string
  3695. fmt.Println("pay_way")
  3696. fmt.Println(pay_way)
  3697. fmt.Println("pay_way")
  3698. if pay_way == 4 {
  3699. acct_used_flag = "1"
  3700. } else {
  3701. acct_used_flag = "0"
  3702. }
  3703. if miConfig.MdtrtareaAdmvs == "421300" {
  3704. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3705. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3706. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3707. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3708. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3709. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3710. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3711. resp, requestErr := http.Get(api)
  3712. if requestErr != nil {
  3713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3714. return
  3715. }
  3716. body, ioErr := ioutil.ReadAll(resp.Body)
  3717. if ioErr != nil {
  3718. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3720. return
  3721. }
  3722. var respJSON map[string]interface{}
  3723. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3726. return
  3727. }
  3728. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3729. result, _ := json.Marshal(respJSON)
  3730. fmt.Println("log")
  3731. fmt.Println(string(result))
  3732. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3733. utils.ErrorLog("解析失败:%v", err)
  3734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3735. return
  3736. }
  3737. } else {
  3738. var src_resquest string
  3739. if miConfig.Code == "H15049901371" {
  3740. //赤峰地区国家医保医疗类别
  3741. //职工透析:医疗类别选特殊情况门诊990502
  3742. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3743. var med_type string
  3744. if his.Insutype == "390" {
  3745. if reg_type == 14 {
  3746. med_type = "9933"
  3747. } else if reg_type == 11 {
  3748. med_type = "11"
  3749. }
  3750. } else if his.Insutype == "310" {
  3751. if reg_type == 14 {
  3752. med_type = "990502"
  3753. } else if reg_type == 11 {
  3754. med_type = "11"
  3755. }
  3756. }
  3757. 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)
  3758. } else {
  3759. 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)
  3760. }
  3761. var dat map[string]interface{}
  3762. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3763. fmt.Println(dat)
  3764. } else {
  3765. fmt.Println(err)
  3766. }
  3767. saveLog(result2, src_resquest, "2207", "结算")
  3768. userJSONBytes, _ := json.Marshal(dat)
  3769. if miConfig.Code == "H15049901371" {
  3770. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3771. utils.ErrorLog("解析失败:%v", err)
  3772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3773. return
  3774. }
  3775. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3776. res.Output = resSeven10265.Output
  3777. res.ErrMsg = resSeven10265.ErrMsg
  3778. res.Cainfo = resSeven10265.Cainfo
  3779. res.WarnMsg = resSeven10265.WarnMsg
  3780. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3781. res.Infcode = infocode
  3782. } else {
  3783. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3784. utils.ErrorLog("解析失败:%v", err)
  3785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3786. return
  3787. }
  3788. }
  3789. }
  3790. if res.Infcode != 0 {
  3791. errlog := &models.HisOrderError{
  3792. UserOrgId: adminUser.CurrentOrgId,
  3793. Ctime: time.Now().Unix(),
  3794. Mtime: time.Now().Unix(),
  3795. Number: chrg_bchno,
  3796. ErrMsg: res.ErrMsg,
  3797. Status: 1,
  3798. PatientId: id,
  3799. RecordTime: recordDateTime,
  3800. Stage: 6,
  3801. }
  3802. service.CreateErrMsgLog(errlog)
  3803. c.ServeSuccessJSON(map[string]interface{}{
  3804. "failed_code": -10,
  3805. "msg": res.ErrMsg,
  3806. })
  3807. return
  3808. } else {
  3809. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3810. order.OrderStatus = 2
  3811. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3812. order.SetlId = res.Output.Setlinfo.SetlID
  3813. order.PsnNo = res.Output.Setlinfo.PsnNo
  3814. order.PsnName = res.Output.Setlinfo.PsnName
  3815. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3816. order.Certno = res.Output.Setlinfo.Certno
  3817. order.Gend = res.Output.Setlinfo.Gend
  3818. order.Naty = res.Output.Setlinfo.Naty
  3819. order.Age = res.Output.Setlinfo.Age
  3820. order.Insutype = res.Output.Setlinfo.Insutype
  3821. order.PsnType = res.Output.Setlinfo.PsnType
  3822. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3823. order.SetlTime = res.Output.Setlinfo.SetlTime
  3824. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3825. //order.MedType = res.Output.Setlinfo.MedType
  3826. if reg_type == 1112 {
  3827. order.MedType = "1112"
  3828. }
  3829. if reg_type == 1111 {
  3830. order.MedType = "1111"
  3831. }
  3832. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3833. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3834. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3835. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3836. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3837. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3838. order.HifpPay = res.Output.Setlinfo.HifpPay
  3839. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3840. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3841. order.HifesPay = res.Output.Setlinfo.HifesPay
  3842. order.HifobPay = res.Output.Setlinfo.HifobPay
  3843. order.MafPay = res.Output.Setlinfo.MafPay
  3844. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3845. order.OthPay = res.Output.Setlinfo.OthPay
  3846. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3847. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3848. order.AcctPay = res.Output.Setlinfo.AcctPay
  3849. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3850. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3851. order.Balc = res.Output.Setlinfo.Balc
  3852. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3853. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3854. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3855. order.ClrWay = res.Output.Setlinfo.ClrWay
  3856. order.Creator = order.Creator
  3857. order.Modify = roles.AdminUserId
  3858. order.RequestLog = src_resquest
  3859. order.Diagnosis = diagnosis_id
  3860. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3861. detailStr := string(setlDetail)
  3862. order.SetlDetail = detailStr
  3863. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3864. err = service.UpDateOrder(order)
  3865. if err == nil {
  3866. c.ServeSuccessJSON(map[string]interface{}{
  3867. "msg": "结算成功",
  3868. })
  3869. } else {
  3870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3871. return
  3872. }
  3873. }
  3874. }
  3875. }
  3876. }
  3877. //func (c *HisApiController) GetPreUploadInfo() {
  3878. // id, _ := c.GetInt64("id")
  3879. // record_time := c.GetString("record_time")
  3880. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3881. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3882. //
  3883. // timeLayout := "2006-01-02"
  3884. // loc, _ := time.LoadLocation("Local")
  3885. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3886. // if err != nil {
  3887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3888. // return
  3889. // }
  3890. // recordDateTime := theTime.Unix()
  3891. // adminUser := c.GetAdminUserInfo()
  3892. //
  3893. // var prescriptions []*models.HisPrescription
  3894. //
  3895. // var start_time int64
  3896. // var end_time int64
  3897. //
  3898. // data := make(map[string]interface{})
  3899. // if settle_accounts_type == 1 { //日结
  3900. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  3901. // data["pre"] = prescriptions
  3902. //
  3903. // } else { //月结
  3904. // start_time_str := c.GetString("start_time")
  3905. // end_time_str := c.GetString("end_time")
  3906. // timeLayout := "2006-01-02"
  3907. // loc, _ := time.LoadLocation("Local")
  3908. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3909. // if err != nil {
  3910. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3911. // return
  3912. // }
  3913. // recordStartTime := theStartTime.Unix()
  3914. // start_time = recordStartTime
  3915. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3916. // if err != nil {
  3917. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3918. // return
  3919. // }
  3920. // recordEndTime := theEndTime.Unix()
  3921. // end_time = recordEndTime
  3922. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  3923. // data["pre"] = prescriptions
  3924. //
  3925. // }
  3926. //
  3927. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3928. //
  3929. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3930. // timestamp := time.Now().Unix()
  3931. // tempTime := time.Unix(timestamp, 0)
  3932. // timeFormat := tempTime.Format("20060102150405")
  3933. // chrgBchno := rand.Intn(100000) + 10000
  3934. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3935. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3936. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3937. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3938. // strconv.FormatInt(his.PatientId, 10)
  3939. // client := &http.Client{}
  3940. // data["psn_no"] = his.PsnNo
  3941. // data["mdtrt_id"] = his.Number
  3942. // data["chrg_bchno"] = chrg_bchno
  3943. // data["org_name"] = miConfig.OrgName
  3944. // data["doctor"] = roles.UserName
  3945. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3946. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3947. // data["fixmedins_code"] = miConfig.Code
  3948. // data["dept_code"] = department.Number
  3949. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3950. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3951. // data["secret_key"] = miConfig.SecretKey
  3952. // var ids []int64
  3953. //
  3954. // for _, item := range prescriptions {
  3955. // ids = append(ids, item.ID)
  3956. // }
  3957. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3958. // if config.IsOpen == 1 { //对接了医保,走医保流程
  3959. // bytesData, _ := json.Marshal(data)
  3960. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  3961. // resp, _ := client.Do(req)
  3962. // defer resp.Body.Close()
  3963. // body, ioErr := ioutil.ReadAll(resp.Body)
  3964. // if ioErr != nil {
  3965. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3966. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3967. // return
  3968. // }
  3969. // var respJSON map[string]interface{}
  3970. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3971. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3972. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3973. // return
  3974. // }
  3975. //
  3976. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3977. // userJSONBytes, _ := json.Marshal(respJSON)
  3978. // var res ResultFour
  3979. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3980. // utils.ErrorLog("解析失败:%v", err)
  3981. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3982. // return
  3983. // }
  3984. //
  3985. // if res.Infcode == 0 {
  3986. // order := &models.HisOrder{
  3987. // UserOrgId: adminUser.CurrentOrgId,
  3988. // HisPatientId: his.ID,
  3989. // PatientId: his.PatientId,
  3990. // SettleAccountsDate: recordDateTime,
  3991. // Ctime: time.Now().Unix(),
  3992. // Mtime: time.Now().Unix(),
  3993. // Status: 1,
  3994. // Number: chrg_bchno,
  3995. // Infcode: res.Infcode,
  3996. // WarnMsg: res.WarnMsg,
  3997. // Cainfo: res.Cainfo,
  3998. // ErrMsg: res.ErrMsg,
  3999. // RespondTime: res.RefmsgTime,
  4000. // InfRefmsgid: res.InfRefmsgid,
  4001. // OrderStatus: 1,
  4002. // IsMedicineInsurance: 1,
  4003. // SettleType: settle_accounts_type,
  4004. // SettleStartTime: start_time,
  4005. // SettleEndTime: end_time,
  4006. // Creator: roles.ID,
  4007. // Modify: roles.ID,
  4008. // PType: 2,
  4009. // }
  4010. // err = service.CreateOrder(order)
  4011. // if err != nil {
  4012. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4013. // return
  4014. // }
  4015. //
  4016. // for _, item := range res.Output.Result {
  4017. // temp := strings.Split(item.FeedetlSn, "-")
  4018. // var advice_id int64 = 0
  4019. // var project_id int64 = 0
  4020. // var types int64 = 0
  4021. //
  4022. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4023. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4024. //
  4025. // if temp[1] == "1" {
  4026. // advice_id = id
  4027. // project_id = 0
  4028. // } else if temp[1] == "2" {
  4029. // advice_id = 0
  4030. // project_id = id
  4031. // }
  4032. //
  4033. // info := &models.HisOrderInfo{
  4034. // OrderNumber: order.Number,
  4035. // FeedetlSn: item.FeedetlSn,
  4036. // UploadDate: time.Now().Unix(),
  4037. // AdviceId: advice_id,
  4038. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4039. // Cnt: item.Cnt,
  4040. // Pric: float64(item.Pric),
  4041. // PatientId: his.PatientId,
  4042. // PricUplmtAmt: item.PricUplmtAmt,
  4043. // SelfpayProp: item.SelfpayProp,
  4044. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4045. // OverlmtAmt: item.OverlmtAmt,
  4046. // PreselfpayAmt: item.PreselfpayAmt,
  4047. // BasMednFlag: item.BasMednFlag,
  4048. // MedChrgitmType: item.MedChrgitmType,
  4049. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4050. // Status: 1,
  4051. // Memo: item.Memo,
  4052. // Mtime: time.Now().Unix(),
  4053. // InscpScpAmt: item.InscpScpAmt,
  4054. // DrtReimFlag: item.DrtReimFlag,
  4055. // Ctime: time.Now().Unix(),
  4056. // ListSpItemFlag: item.ListSpItemFlag,
  4057. // ChldMedcFlag: item.ChldMedcFlag,
  4058. // LmtUsedFlag: item.LmtUsedFlag,
  4059. // ChrgitmLv: item.ChrgitmLv,
  4060. // UserOrgId: adminUser.CurrentOrgId,
  4061. // HisPatientId: his.ID,
  4062. // OrderId: order.ID,
  4063. // ProjectId: project_id,
  4064. // Type: types,
  4065. // }
  4066. // service.CreateOrderInfo(info)
  4067. //
  4068. // }
  4069. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4070. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4071. //
  4072. // var total float64
  4073. // for _, item := range prescriptions {
  4074. // if item.Type == 1 { //药品
  4075. // for _, subItem := range item.HisDoctorAdviceInfo {
  4076. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4077. // }
  4078. // }
  4079. // if item.Type == 2 { //项目
  4080. // for _, subItem := range item.HisPrescriptionProject {
  4081. // total = total + (subItem.Price * float64(subItem.Count))
  4082. // }
  4083. // }
  4084. // }
  4085. //
  4086. // for _, item := range prescriptions {
  4087. // for _, subItem := range item.HisAdditionalCharge {
  4088. // total = total + (subItem.Price * float64(subItem.Count))
  4089. // }
  4090. // }
  4091. //
  4092. // allTotal := fmt.Sprintf("%.2f", total)
  4093. // if res.Infcode == 0 {
  4094. // var rf []*ResultFive
  4095. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4096. // psn_no := his.PsnNo
  4097. // mdtrt_id := his.Number
  4098. // chrg_bchno := chrg_bchno
  4099. // cert_no := his.Certno
  4100. // insutype := rf[0].Insutype
  4101. //
  4102. // if his.IdCardType == 1 {
  4103. // cert_no = his.MedicalInsuranceNumber
  4104. //
  4105. // } else {
  4106. //
  4107. // cert_no = his.Certno
  4108. //
  4109. // }
  4110. //
  4111. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  4112. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  4113. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  4114. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  4115. // resp, requestErr := http.Get(api)
  4116. // if requestErr != nil {
  4117. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4118. // return
  4119. // }
  4120. // defer resp.Body.Close()
  4121. // body, ioErr := ioutil.ReadAll(resp.Body)
  4122. // if ioErr != nil {
  4123. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4124. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4125. // return
  4126. // }
  4127. // var respJSON map[string]interface{}
  4128. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4129. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4131. // return
  4132. // }
  4133. // fmt.Println(respJSON)
  4134. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4135. // userJSONBytes, _ := json.Marshal(respJSON)
  4136. // var res ResultSeven
  4137. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4138. // utils.ErrorLog("解析失败:%v", err)
  4139. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4140. // return
  4141. // }
  4142. // if res.Infcode != 0 {
  4143. // errlog := &models.HisOrderError{
  4144. // UserOrgId: adminUser.CurrentOrgId,
  4145. // Ctime: time.Now().Unix(),
  4146. // Mtime: time.Now().Unix(),
  4147. // Number: chrg_bchno,
  4148. // ErrMsg: res.ErrMsg,
  4149. // Status: 1,
  4150. // PatientId: id,
  4151. // RecordTime: recordDateTime,
  4152. // Stage: 7,
  4153. // }
  4154. // service.CreateErrMsgLog(errlog)
  4155. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4156. // return
  4157. // } else {
  4158. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4159. // order.OrderStatus = 1
  4160. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4161. // order.SetlId = res.Output.Setlinfo.SetlID
  4162. // order.PsnNo = res.Output.Setlinfo.PsnNo
  4163. // order.PsnName = res.Output.Setlinfo.PsnName
  4164. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4165. // order.Certno = res.Output.Setlinfo.Certno
  4166. // order.Gend = res.Output.Setlinfo.Gend
  4167. // order.Naty = res.Output.Setlinfo.Naty
  4168. // order.Age = res.Output.Setlinfo.Age
  4169. // order.Insutype = res.Output.Setlinfo.Insutype
  4170. // order.PsnType = res.Output.Setlinfo.PsnType
  4171. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4172. // order.SetlTime = res.Output.Setlinfo.SetlTime
  4173. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4174. // order.MedType = res.Output.Setlinfo.MedType
  4175. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4176. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4177. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4178. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4179. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4180. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4181. // order.HifpPay = res.Output.Setlinfo.HifpPay
  4182. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4183. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4184. // order.HifesPay = res.Output.Setlinfo.HifesPay
  4185. // order.HifobPay = res.Output.Setlinfo.HifobPay
  4186. // order.MafPay = res.Output.Setlinfo.MafPay
  4187. // order.OthPay = res.Output.Setlinfo.OthPay
  4188. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4189. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4190. // order.AcctPay = res.Output.Setlinfo.AcctPay
  4191. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4192. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4193. // order.Balc = res.Output.Setlinfo.Balc
  4194. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4195. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4196. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4197. // order.ClrWay = res.Output.Setlinfo.ClrWay
  4198. // order.Creator = order.Creator
  4199. // order.Modify = roles.ID
  4200. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4201. // detailStr := string(setlDetail)
  4202. // order.SetlDetail = detailStr
  4203. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4204. // err = service.UpDateOrder(order)
  4205. // if err == nil {
  4206. // c.ServeSuccessJSON(map[string]interface{}{
  4207. // "msg": "预结算成功",
  4208. // })
  4209. // } else {
  4210. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4211. // return
  4212. // }
  4213. // }
  4214. // } else {
  4215. // adminUser := c.GetAdminUserInfo()
  4216. // errlog := &models.HisOrderError{
  4217. // UserOrgId: adminUser.CurrentOrgId,
  4218. // Ctime: time.Now().Unix(),
  4219. // Mtime: time.Now().Unix(),
  4220. // ErrMsg: res.ErrMsg,
  4221. // Status: 1,
  4222. // PatientId: id,
  4223. // RecordTime: recordDateTime,
  4224. // Stage: 4,
  4225. // }
  4226. // service.CreateErrMsgLog(errlog)
  4227. //
  4228. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4229. // return
  4230. // }
  4231. // } else {
  4232. // adminUser := c.GetAdminUserInfo()
  4233. // errlog := &models.HisOrderError{
  4234. // UserOrgId: adminUser.CurrentOrgId,
  4235. // Ctime: time.Now().Unix(),
  4236. // Mtime: time.Now().Unix(),
  4237. // ErrMsg: res.ErrMsg,
  4238. // Status: 1,
  4239. // PatientId: id,
  4240. // RecordTime: recordDateTime,
  4241. // Stage: 4,
  4242. // }
  4243. // service.CreateErrMsgLog(errlog)
  4244. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4245. // return
  4246. // }
  4247. //
  4248. // } else {
  4249. // var total float64
  4250. // for _, item := range prescriptions {
  4251. // if item.Type == 1 { //药品
  4252. // for _, subItem := range item.HisDoctorAdviceInfo {
  4253. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4254. // }
  4255. // }
  4256. // if item.Type == 2 { //项目
  4257. // for _, subItem := range item.HisPrescriptionProject {
  4258. // total = total + (subItem.Price * float64(subItem.Count))
  4259. // }
  4260. // }
  4261. //
  4262. // for _, subItem := range item.HisAdditionalCharge {
  4263. // total = total + (subItem.Price * float64(subItem.Count))
  4264. // }
  4265. // }
  4266. //
  4267. // allTotal := fmt.Sprintf("%.2f", total)
  4268. // totals, _ := strconv.ParseFloat(allTotal, 64)
  4269. // order := &models.HisOrder{
  4270. // UserOrgId: adminUser.CurrentOrgId,
  4271. // HisPatientId: his.ID,
  4272. // PatientId: id,
  4273. // SettleAccountsDate: recordDateTime,
  4274. // Ctime: time.Now().Unix(),
  4275. // Mtime: time.Now().Unix(),
  4276. // Status: 1,
  4277. // OrderStatus: 2,
  4278. // Number: chrg_bchno,
  4279. // MedfeeSumamt: totals,
  4280. // }
  4281. // err = service.CreateOrder(order)
  4282. // if err != nil {
  4283. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4284. // return
  4285. // }
  4286. //
  4287. // var customs []*Custom
  4288. // for _, item := range prescriptions {
  4289. //
  4290. // if item.Type == 1 { //药品
  4291. // for _, subItem := range item.HisDoctorAdviceInfo {
  4292. // cus := &Custom{
  4293. // AdviceId: subItem.ID,
  4294. // ProjectId: 0,
  4295. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  4296. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  4297. // FeedetlSn: subItem.FeedetlSn,
  4298. // Price: fmt.Sprintf("%.2f", subItem.Price),
  4299. // MedListCodg: subItem.MedListCodg,
  4300. // Type: 1,
  4301. // }
  4302. // customs = append(customs, cus)
  4303. // }
  4304. // }
  4305. //
  4306. // if item.Type == 2 { //项目
  4307. // for _, subItem := range item.HisPrescriptionProject {
  4308. //
  4309. // cus := &Custom{
  4310. // AdviceId: 0,
  4311. // ProjectId: subItem.ID,
  4312. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  4313. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  4314. // FeedetlSn: subItem.FeedetlSn,
  4315. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  4316. // MedListCodg: subItem.MedListCodg,
  4317. // Type: 2,
  4318. // }
  4319. //
  4320. // customs = append(customs, cus)
  4321. // }
  4322. // }
  4323. //
  4324. // for _, item := range item.HisAdditionalCharge {
  4325. // cus := &Custom{
  4326. // ItemId: item.ID,
  4327. // AdviceId: 0,
  4328. // ProjectId: 0,
  4329. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  4330. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  4331. // FeedetlSn: item.FeedetlSn,
  4332. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  4333. // MedListCodg: item.XtHisAddtionConfig.Code,
  4334. // Type: 3,
  4335. // }
  4336. //
  4337. // customs = append(customs, cus)
  4338. // }
  4339. //
  4340. // }
  4341. //
  4342. // for _, item := range customs {
  4343. // var advice_id int64 = 0
  4344. // var project_id int64 = 0
  4345. // var item_id int64 = 0
  4346. //
  4347. // var types int64 = 0
  4348. //
  4349. // if item.Type == 1 {
  4350. // advice_id = item.AdviceId
  4351. // project_id = 0
  4352. // item_id = 0
  4353. // } else if item.Type == 2 {
  4354. // advice_id = 0
  4355. // item_id = 0
  4356. //
  4357. // project_id = item.ProjectId
  4358. // } else if item.Type == 3 {
  4359. // advice_id = 0
  4360. // item_id = item.ItemId
  4361. // project_id = 0
  4362. // }
  4363. //
  4364. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  4365. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  4366. // pric, _ := strconv.ParseFloat(item.Price, 32)
  4367. //
  4368. // info := &models.HisOrderInfo{
  4369. // OrderNumber: order.Number,
  4370. // UploadDate: time.Now().Unix(),
  4371. // AdviceId: advice_id,
  4372. // DetItemFeeSumamt: detItemFeeSumamt,
  4373. // Cnt: cut,
  4374. // Pric: pric,
  4375. // PatientId: id,
  4376. // Status: 1,
  4377. // Mtime: time.Now().Unix(),
  4378. // Ctime: time.Now().Unix(),
  4379. // UserOrgId: adminUser.CurrentOrgId,
  4380. // HisPatientId: his.ID,
  4381. // OrderId: order.ID,
  4382. // ProjectId: project_id,
  4383. // Type: types,
  4384. // ItemId: item_id,
  4385. // }
  4386. // service.CreateOrderInfo(info)
  4387. // }
  4388. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4389. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4390. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  4391. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4392. // if err == nil {
  4393. // c.ServeSuccessJSON(map[string]interface{}{
  4394. // "msg": "结算成功",
  4395. // })
  4396. // } else {
  4397. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4398. // return
  4399. // }
  4400. // }
  4401. //}
  4402. //上传明细-预结算-
  4403. func (c *HisApiController) GetPreUploadInfo() {
  4404. id, _ := c.GetInt64("id")
  4405. record_time := c.GetString("record_time")
  4406. his_patient_id, _ := c.GetInt64("his_patient_id")
  4407. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4408. admin_user_id, _ := c.GetInt64("admin_user_id")
  4409. diagnosis_id := c.GetString("diagnosis")
  4410. sick_type, _ := c.GetInt64("sick_type")
  4411. reg_type, _ := c.GetInt64("p_type")
  4412. id_str := c.GetString("ids")
  4413. ids_arr := strings.Split(id_str, ",")
  4414. timeLayout := "2006-01-02"
  4415. loc, _ := time.LoadLocation("Local")
  4416. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4417. if err != nil {
  4418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4419. return
  4420. }
  4421. recordDateTime := theTime.Unix()
  4422. adminUser := c.GetAdminUserInfo()
  4423. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4424. var config []*models.HisXtDiagnoseConfig
  4425. for _, item := range diagnosis_ids {
  4426. id, _ := strconv.ParseInt(item, 10, 64)
  4427. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4428. config = append(config, &diagnosisConfig)
  4429. }
  4430. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4431. sickConfig, _ := service.FindSickById(sick_type)
  4432. var prescriptions []*models.HisPrescription
  4433. var start_time int64
  4434. var end_time int64
  4435. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4436. fmt.Println(his_patient_id)
  4437. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4438. timestamp := time.Now().Unix()
  4439. tempTime := time.Unix(timestamp, 0)
  4440. timeFormat := tempTime.Format("20060102150405")
  4441. chrgBchno := rand.Intn(100000) + 10000
  4442. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4443. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4444. var patientPrescription models.HisPrescriptionInfo
  4445. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4446. if patientPrescription.ID == 0 {
  4447. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4448. }
  4449. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4450. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4451. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4452. strconv.FormatInt(his.PatientId, 10)
  4453. var res2 ResultSix
  4454. var resSix10265 ResultSix10265
  4455. if miConfig.InsuplcAdmdvs == "421300" {
  4456. data := make(map[string]interface{})
  4457. client := &http.Client{}
  4458. data["psn_no"] = his.PsnNo
  4459. data["mdtrt_id"] = his.Number
  4460. data["doctor"] = roles.UserName
  4461. data["department"] = department.Name
  4462. data["org_name"] = miConfig.OrgName
  4463. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4464. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4465. data["fixmedins_code"] = miConfig.Code
  4466. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4467. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4468. data["secret_key"] = miConfig.SecretKey
  4469. data["sick_code"] = sickConfig.CountryCode
  4470. data["sick_name"] = sickConfig.ClassName
  4471. data["dept"] = strconv.FormatInt(department.ID, 10)
  4472. data["config"] = config
  4473. fmt.Println(data)
  4474. bytesData, _ := json.Marshal(data)
  4475. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4476. resp, _ := client.Do(req)
  4477. defer resp.Body.Close()
  4478. body, ioErr := ioutil.ReadAll(resp.Body)
  4479. if ioErr != nil {
  4480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4482. return
  4483. }
  4484. var respJSON map[string]interface{}
  4485. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4488. return
  4489. }
  4490. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4491. userJSONBytes, _ := json.Marshal(respJSON)
  4492. fmt.Println("log")
  4493. fmt.Println(string(userJSONBytes))
  4494. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4495. utils.ErrorLog("解析失败:%v", err)
  4496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4497. return
  4498. }
  4499. } else {
  4500. var result string
  4501. var requestLog string
  4502. if miConfig.InsuplcAdmdvs == "440781" { //
  4503. 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)
  4504. } else {
  4505. if miConfig.Code == "H15049901371" {
  4506. //赤峰地区国家医保医疗类别
  4507. //职工透析:医疗类别选特殊情况门诊990502
  4508. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4509. var med_type string
  4510. if his.Insutype == "390" {
  4511. if reg_type == 14 {
  4512. med_type = "9933"
  4513. } else if reg_type == 11 {
  4514. med_type = "11"
  4515. }
  4516. } else if his.Insutype == "310" {
  4517. if reg_type == 14 {
  4518. med_type = "990502"
  4519. } else if reg_type == 11 {
  4520. med_type = "11"
  4521. }
  4522. }
  4523. 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)
  4524. } else {
  4525. 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)
  4526. }
  4527. saveLog(result, requestLog, "2203", "上传就诊信息")
  4528. var respJSON2 map[string]interface{}
  4529. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4532. return
  4533. }
  4534. //userJSONBytes2, _ := json.Marshal(respJSON2)
  4535. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4536. // utils.ErrorLog("解析失败:%v", err)
  4537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4538. // return
  4539. //}
  4540. userJSONBytes2, _ := json.Marshal(respJSON2)
  4541. if miConfig.Code == "H15049901371" {
  4542. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  4543. utils.ErrorLog("解析失败:%v", err)
  4544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4545. return
  4546. }
  4547. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4548. res2.Output = resSix10265.Output
  4549. res2.ErrMsg = resSix10265.ErrMsg
  4550. res2.Cainfo = resSix10265.Cainfo
  4551. res2.WarnMsg = resSix10265.WarnMsg
  4552. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  4553. res2.Infcode = infocode
  4554. } else {
  4555. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4556. utils.ErrorLog("解析失败:%v", err)
  4557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4558. return
  4559. }
  4560. }
  4561. }
  4562. }
  4563. if res2.Infcode != 0 {
  4564. adminUser := c.GetAdminUserInfo()
  4565. errlog := &models.HisOrderError{
  4566. UserOrgId: adminUser.CurrentOrgId,
  4567. Ctime: time.Now().Unix(),
  4568. Mtime: time.Now().Unix(),
  4569. ErrMsg: res2.ErrMsg,
  4570. Status: 1,
  4571. PatientId: id,
  4572. RecordTime: recordDateTime,
  4573. Stage: 3,
  4574. }
  4575. service.CreateErrMsgLog(errlog)
  4576. c.ServeSuccessJSON(map[string]interface{}{
  4577. "failed_code": -10,
  4578. "msg": res2.ErrMsg,
  4579. })
  4580. return
  4581. } else {
  4582. his.Diagnosis = diagnosis_id
  4583. his.SickType = sickConfig.ID
  4584. his.PType = fmt.Sprintf("%d", reg_type)
  4585. service.UpdateHisPatientThree(&his)
  4586. data := make(map[string]interface{})
  4587. if settle_accounts_type == 1 { //日结
  4588. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4589. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4590. } else {
  4591. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4592. }
  4593. data["pre"] = prescriptions
  4594. } else { //月结
  4595. start_time_str := c.GetString("start_time")
  4596. end_time_str := c.GetString("end_time")
  4597. timeLayout := "2006-01-02"
  4598. loc, _ := time.LoadLocation("Local")
  4599. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4600. if err != nil {
  4601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4602. return
  4603. }
  4604. recordStartTime := theStartTime.Unix()
  4605. start_time = recordStartTime
  4606. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4607. if err != nil {
  4608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4609. return
  4610. }
  4611. recordEndTime := theEndTime.Unix()
  4612. end_time = recordEndTime
  4613. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4614. data["pre"] = prescriptions
  4615. }
  4616. client := &http.Client{}
  4617. data["psn_no"] = his.PsnNo
  4618. data["mdtrt_id"] = his.Number
  4619. data["chrg_bchno"] = chrg_bchno
  4620. data["org_name"] = miConfig.OrgName
  4621. data["doctor"] = roles.UserName
  4622. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4623. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4624. data["fixmedins_code"] = miConfig.Code
  4625. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4626. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4627. data["dept_code"] = "15"
  4628. } else {
  4629. data["dept_code"] = department.Number
  4630. }
  4631. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4632. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4633. data["secret_key"] = miConfig.SecretKey
  4634. var ids []int64
  4635. for _, item := range prescriptions {
  4636. ids = append(ids, item.ID)
  4637. }
  4638. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4639. if config.IsOpen == 1 { //对接了医保,走医保流程
  4640. var res ResultFour
  4641. var resFour10265 ResultFour10265
  4642. if miConfig.MdtrtareaAdmvs == "421300" {
  4643. bytesData, _ := json.Marshal(data)
  4644. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4645. resp, _ := client.Do(req)
  4646. defer resp.Body.Close()
  4647. body, ioErr := ioutil.ReadAll(resp.Body)
  4648. if ioErr != nil {
  4649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4651. return
  4652. }
  4653. var respJSON map[string]interface{}
  4654. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4657. return
  4658. }
  4659. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4660. userJSONBytes, _ := json.Marshal(respJSON)
  4661. fmt.Println("log")
  4662. fmt.Println(string(userJSONBytes))
  4663. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4664. utils.ErrorLog("解析失败:%v", err)
  4665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4666. return
  4667. }
  4668. } else {
  4669. if miConfig.Code == "H15049901371" {
  4670. 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)
  4671. var dat map[string]interface{}
  4672. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4673. fmt.Println(dat)
  4674. } else {
  4675. fmt.Println(err)
  4676. }
  4677. saveLog(result, request_log, "2204", "上传费用明细")
  4678. userJSONBytes, _ := json.Marshal(dat)
  4679. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4680. utils.ErrorLog("解析失败:%v", err)
  4681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4682. return
  4683. }
  4684. res.InfRefmsgid = resFour10265.InfRefmsgid
  4685. res.Output = resFour10265.Output
  4686. res.ErrMsg = resFour10265.ErrMsg
  4687. res.Cainfo = resFour10265.Cainfo
  4688. res.WarnMsg = resFour10265.WarnMsg
  4689. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4690. res.Infcode = infocode
  4691. } else {
  4692. 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)
  4693. var dat map[string]interface{}
  4694. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4695. fmt.Println(dat)
  4696. } else {
  4697. fmt.Println(err)
  4698. }
  4699. saveLog(result, request_log, "2204", "上传费用明细")
  4700. userJSONBytes, _ := json.Marshal(dat)
  4701. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4702. utils.ErrorLog("解析失败:%v", err)
  4703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4704. return
  4705. }
  4706. }
  4707. }
  4708. if res.Infcode == 0 {
  4709. order := &models.HisOrder{
  4710. UserOrgId: adminUser.CurrentOrgId,
  4711. HisPatientId: his.ID,
  4712. PatientId: his.PatientId,
  4713. SettleAccountsDate: recordDateTime,
  4714. Ctime: time.Now().Unix(),
  4715. Mtime: time.Now().Unix(),
  4716. Status: 1,
  4717. Number: chrg_bchno,
  4718. Infcode: res.Infcode,
  4719. WarnMsg: res.WarnMsg,
  4720. Cainfo: res.Cainfo,
  4721. ErrMsg: res.ErrMsg,
  4722. RespondTime: res.RefmsgTime,
  4723. InfRefmsgid: res.InfRefmsgid,
  4724. OrderStatus: 1,
  4725. IsMedicineInsurance: 1,
  4726. SettleType: settle_accounts_type,
  4727. SettleStartTime: start_time,
  4728. SettleEndTime: end_time,
  4729. Creator: roles.AdminUserId,
  4730. Modify: roles.AdminUserId,
  4731. PType: 2,
  4732. Diagnosis: diagnosis_id,
  4733. }
  4734. err = service.CreateOrder(order)
  4735. if err != nil {
  4736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4737. return
  4738. }
  4739. for _, item := range res.Output.Result {
  4740. temp := strings.Split(item.FeedetlSn, "-")
  4741. var advice_id int64 = 0
  4742. var project_id int64 = 0
  4743. var types int64 = 0
  4744. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4745. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4746. if temp[1] == "1" {
  4747. advice_id = id
  4748. project_id = 0
  4749. } else if temp[1] == "2" {
  4750. advice_id = 0
  4751. project_id = id
  4752. }
  4753. info := &models.HisOrderInfo{
  4754. OrderNumber: order.Number,
  4755. FeedetlSn: item.FeedetlSn,
  4756. UploadDate: time.Now().Unix(),
  4757. AdviceId: advice_id,
  4758. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4759. Cnt: item.Cnt,
  4760. Pric: float64(item.Pric),
  4761. PatientId: his.PatientId,
  4762. PricUplmtAmt: item.PricUplmtAmt,
  4763. SelfpayProp: item.SelfpayProp,
  4764. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4765. OverlmtAmt: item.OverlmtAmt,
  4766. PreselfpayAmt: item.PreselfpayAmt,
  4767. BasMednFlag: item.BasMednFlag,
  4768. MedChrgitmType: item.MedChrgitmType,
  4769. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4770. Status: 1,
  4771. Memo: item.Memo,
  4772. Mtime: time.Now().Unix(),
  4773. InscpScpAmt: item.InscpScpAmt,
  4774. DrtReimFlag: item.DrtReimFlag,
  4775. Ctime: time.Now().Unix(),
  4776. ListSpItemFlag: item.ListSpItemFlag,
  4777. ChldMedcFlag: item.ChldMedcFlag,
  4778. LmtUsedFlag: item.LmtUsedFlag,
  4779. ChrgitmLv: item.ChrgitmLv,
  4780. UserOrgId: adminUser.CurrentOrgId,
  4781. HisPatientId: his.ID,
  4782. OrderId: order.ID,
  4783. ProjectId: project_id,
  4784. Type: types,
  4785. }
  4786. service.CreateOrderInfo(info)
  4787. }
  4788. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4789. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4790. var total float64
  4791. for _, item := range prescriptions {
  4792. if item.Type == 1 { //药品
  4793. for _, subItem := range item.HisDoctorAdviceInfo {
  4794. total = total + (subItem.Price * subItem.PrescribingNumber)
  4795. }
  4796. }
  4797. if item.Type == 2 { //项目
  4798. for _, subItem := range item.HisPrescriptionProject {
  4799. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4800. total = total + (subItem.Price * cnt)
  4801. }
  4802. }
  4803. }
  4804. for _, item := range prescriptions {
  4805. for _, subItem := range item.HisAdditionalCharge {
  4806. total = total + (subItem.Price * float64(subItem.Count))
  4807. }
  4808. }
  4809. allTotal := fmt.Sprintf("%.4f", total)
  4810. if res.Infcode == 0 {
  4811. var rf []*ResultFive
  4812. json.Unmarshal([]byte(his.Iinfo), &rf)
  4813. chrg_bchno := chrg_bchno
  4814. cert_no := his.Certno
  4815. var insutypes []string
  4816. var insutype string
  4817. var is390 int = 0
  4818. var is310 int = 0
  4819. for _, item := range rf {
  4820. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4821. insutypes = append(insutypes, item.Insutype)
  4822. }
  4823. }
  4824. if len(insutypes) == 1 {
  4825. insutype = insutypes[0]
  4826. } else {
  4827. for _, i := range insutypes {
  4828. if i == "390" {
  4829. is390 = 1
  4830. }
  4831. if i == "310" {
  4832. is310 = 1
  4833. }
  4834. }
  4835. }
  4836. if is390 == 1 {
  4837. insutype = "390"
  4838. }
  4839. if is310 == 1 {
  4840. insutype = "310"
  4841. }
  4842. if len(insutypes) == 0 {
  4843. insutype = "310"
  4844. }
  4845. if len(insutypes) == 2 {
  4846. insutype = strconv.FormatInt(his.SocialType, 64)
  4847. }
  4848. //insutype = "390"
  4849. if his.IdCardType == 1 {
  4850. cert_no = his.MedicalInsuranceNumber
  4851. } else {
  4852. cert_no = his.Certno
  4853. }
  4854. var res ResultSeven
  4855. var resSeven10265 ResultSeven10265
  4856. if miConfig.MdtrtareaAdmvs == "421300" {
  4857. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4858. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4859. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4860. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4861. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4862. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4863. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  4864. resp, requestErr := http.Get(api)
  4865. if requestErr != nil {
  4866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4867. return
  4868. }
  4869. body, ioErr := ioutil.ReadAll(resp.Body)
  4870. if ioErr != nil {
  4871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4873. return
  4874. }
  4875. var respJSON map[string]interface{}
  4876. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4877. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4879. return
  4880. }
  4881. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4882. result, _ := json.Marshal(respJSON)
  4883. fmt.Println("log")
  4884. fmt.Println(string(result))
  4885. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4886. utils.ErrorLog("解析失败:%v", err)
  4887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4888. return
  4889. }
  4890. } else {
  4891. var result string
  4892. var request_log string
  4893. if miConfig.Code == "H15049901371" {
  4894. //赤峰地区国家医保医疗类别
  4895. //职工透析:医疗类别选特殊情况门诊990502
  4896. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4897. var med_type string
  4898. if his.Insutype == "390" {
  4899. if reg_type == 14 {
  4900. med_type = "9933"
  4901. } else if reg_type == 11 {
  4902. med_type = "11"
  4903. }
  4904. } else if his.Insutype == "310" {
  4905. if reg_type == 14 {
  4906. med_type = "990502"
  4907. } else if reg_type == 11 {
  4908. med_type = "11"
  4909. }
  4910. }
  4911. 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)
  4912. } else {
  4913. 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)
  4914. }
  4915. var dat map[string]interface{}
  4916. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4917. fmt.Println(dat)
  4918. } else {
  4919. fmt.Println(err)
  4920. }
  4921. saveLog(result, request_log, "2206", "预结算")
  4922. //userJSONBytes, _ := json.Marshal(dat)
  4923. //
  4924. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4925. // utils.ErrorLog("解析失败:%v", err)
  4926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4927. // return
  4928. //}
  4929. userJSONBytes, _ := json.Marshal(dat)
  4930. if miConfig.Code == "H15049901371" {
  4931. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4932. utils.ErrorLog("解析失败:%v", err)
  4933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4934. return
  4935. }
  4936. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4937. res.Output = resSeven10265.Output
  4938. res.ErrMsg = resSeven10265.ErrMsg
  4939. res.Cainfo = resSeven10265.Cainfo
  4940. res.WarnMsg = resSeven10265.WarnMsg
  4941. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4942. res.Infcode = infocode
  4943. } else {
  4944. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4945. utils.ErrorLog("解析失败:%v", err)
  4946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4947. return
  4948. }
  4949. }
  4950. }
  4951. if res.Infcode != 0 {
  4952. errlog := &models.HisOrderError{
  4953. UserOrgId: adminUser.CurrentOrgId,
  4954. Ctime: time.Now().Unix(),
  4955. Mtime: time.Now().Unix(),
  4956. Number: chrg_bchno,
  4957. ErrMsg: res.ErrMsg,
  4958. Status: 1,
  4959. PatientId: id,
  4960. RecordTime: recordDateTime,
  4961. Stage: 20,
  4962. }
  4963. service.CreateErrMsgLog(errlog)
  4964. c.ServeSuccessJSON(map[string]interface{}{
  4965. "failed_code": -10,
  4966. "msg": res.ErrMsg,
  4967. })
  4968. return
  4969. } else {
  4970. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4971. order.OrderStatus = 1
  4972. order.IsPre = 1
  4973. order.Status = 1
  4974. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4975. order.SetlId = res.Output.Setlinfo.SetlID
  4976. order.PsnNo = res.Output.Setlinfo.PsnNo
  4977. order.PsnName = res.Output.Setlinfo.PsnName
  4978. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4979. order.Certno = res.Output.Setlinfo.Certno
  4980. order.Gend = res.Output.Setlinfo.Gend
  4981. order.Naty = res.Output.Setlinfo.Naty
  4982. order.Age = res.Output.Setlinfo.Age
  4983. order.Insutype = res.Output.Setlinfo.Insutype
  4984. order.PsnType = res.Output.Setlinfo.PsnType
  4985. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4986. order.SetlTime = res.Output.Setlinfo.SetlTime
  4987. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4988. if res.Output.Setlinfo.MedType == "140101" {
  4989. order.MedType = "14"
  4990. } else {
  4991. order.MedType = res.Output.Setlinfo.MedType
  4992. }
  4993. if reg_type == 1112 {
  4994. order.MedType = "1112"
  4995. }
  4996. if reg_type == 1111 {
  4997. order.MedType = "1111"
  4998. }
  4999. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5000. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5001. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5002. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5003. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5004. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5005. order.HifpPay = res.Output.Setlinfo.HifpPay
  5006. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5007. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5008. order.HifesPay = res.Output.Setlinfo.HifesPay
  5009. order.HifobPay = res.Output.Setlinfo.HifobPay
  5010. order.MafPay = res.Output.Setlinfo.MafPay
  5011. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5012. order.OthPay = res.Output.Setlinfo.OthPay
  5013. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5014. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5015. order.AcctPay = res.Output.Setlinfo.AcctPay
  5016. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5017. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5018. order.Balc = res.Output.Setlinfo.Balc
  5019. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5020. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5021. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5022. order.ClrWay = res.Output.Setlinfo.ClrWay
  5023. order.Creator = order.Creator
  5024. order.Modify = roles.AdminUserId
  5025. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5026. detailStr := string(setlDetail)
  5027. order.SetlDetail = detailStr
  5028. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5029. err = service.UpDateOrder(order)
  5030. if err == nil {
  5031. c.ServeSuccessJSON(map[string]interface{}{
  5032. "msg": "预结算成功",
  5033. })
  5034. } else {
  5035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5036. return
  5037. }
  5038. }
  5039. } else {
  5040. adminUser := c.GetAdminUserInfo()
  5041. errlog := &models.HisOrderError{
  5042. UserOrgId: adminUser.CurrentOrgId,
  5043. Ctime: time.Now().Unix(),
  5044. Mtime: time.Now().Unix(),
  5045. ErrMsg: res.ErrMsg,
  5046. Status: 1,
  5047. PatientId: id,
  5048. RecordTime: recordDateTime,
  5049. Stage: 4,
  5050. }
  5051. service.CreateErrMsgLog(errlog)
  5052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5053. return
  5054. }
  5055. } else {
  5056. adminUser := c.GetAdminUserInfo()
  5057. errlog := &models.HisOrderError{
  5058. UserOrgId: adminUser.CurrentOrgId,
  5059. Ctime: time.Now().Unix(),
  5060. Mtime: time.Now().Unix(),
  5061. ErrMsg: res.ErrMsg,
  5062. Status: 1,
  5063. PatientId: id,
  5064. RecordTime: recordDateTime,
  5065. Stage: 4,
  5066. }
  5067. service.CreateErrMsgLog(errlog)
  5068. c.ServeSuccessJSON(map[string]interface{}{
  5069. "failed_code": -10,
  5070. "msg": res.ErrMsg,
  5071. })
  5072. return
  5073. }
  5074. }
  5075. }
  5076. }
  5077. //func (c *HisApiController) GetSettleInfo() {
  5078. // id, _ := c.GetInt64("id")
  5079. // order_id, _ := c.GetInt64("order_id")
  5080. //
  5081. // record_time := c.GetString("record_time")
  5082. // pay_way, _ := c.GetInt64("pay_way")
  5083. // pay_price, _ := c.GetFloat("pay_price")
  5084. // pay_card_no := c.GetString("pay_card_no")
  5085. // discount_price, _ := c.GetFloat("discount_price")
  5086. // preferential_price, _ := c.GetFloat("preferential_price")
  5087. // reality_price, _ := c.GetFloat("reality_price")
  5088. // found_price, _ := c.GetFloat("found_price")
  5089. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5090. // private_price, _ := c.GetFloat("private_price")
  5091. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5092. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5093. //
  5094. // timeLayout := "2006-01-02"
  5095. // loc, _ := time.LoadLocation("Local")
  5096. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5097. // if err != nil {
  5098. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5099. // return
  5100. // }
  5101. // recordDateTime := theTime.Unix()
  5102. // adminUser := c.GetAdminUserInfo()
  5103. //
  5104. // var prescriptions []*models.HisPrescription
  5105. //
  5106. // data := make(map[string]interface{})
  5107. // if settle_accounts_type == 1 { //日结
  5108. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5109. // data["pre"] = prescriptions
  5110. //
  5111. // } else { //月结
  5112. // start_time_str := c.GetString("start_time")
  5113. // end_time_str := c.GetString("end_time")
  5114. // timeLayout := "2006-01-02"
  5115. // loc, _ := time.LoadLocation("Local")
  5116. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5117. // if err != nil {
  5118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5119. // return
  5120. // }
  5121. // recordStartTime := theStartTime.Unix()
  5122. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5123. // if err != nil {
  5124. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5125. // return
  5126. // }
  5127. // recordEndTime := theEndTime.Unix()
  5128. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5129. // data["pre"] = prescriptions
  5130. //
  5131. // }
  5132. //
  5133. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5134. //
  5135. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5136. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5137. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5138. // strconv.FormatInt(his.PatientId, 10)
  5139. //
  5140. // order_src, _ := service.GetHisOrderByID(order_id)
  5141. //
  5142. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5143. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5144. //
  5145. // var total float64
  5146. // for _, item := range prescriptions {
  5147. // if item.Type == 1 { //药品
  5148. // for _, subItem := range item.HisDoctorAdviceInfo {
  5149. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5150. // }
  5151. // }
  5152. // if item.Type == 2 { //项目
  5153. // for _, subItem := range item.HisPrescriptionProject {
  5154. // total = total + (subItem.Price * float64(subItem.Count))
  5155. // }
  5156. // }
  5157. // }
  5158. //
  5159. // for _, item := range prescriptions {
  5160. // for _, subItem := range item.HisAdditionalCharge {
  5161. // total = total + (subItem.Price * float64(subItem.Count))
  5162. // }
  5163. // }
  5164. //
  5165. // allTotal := fmt.Sprintf("%.2f", total)
  5166. // var rf []*ResultFive
  5167. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5168. // psn_no := order_src.PsnNo
  5169. // mdtrt_id := order_src.MdtrtId
  5170. // chrg_bchno := order_src.Number
  5171. // cert_no := order_src.Certno
  5172. // insutype := rf[0].Insutype
  5173. //
  5174. // if his.IdCardType == 1 {
  5175. // cert_no = his.MedicalInsuranceNumber
  5176. // } else {
  5177. // cert_no = his.Certno
  5178. // }
  5179. //
  5180. // 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)
  5181. // var dat map[string]interface{}
  5182. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5183. // fmt.Println(dat)
  5184. // } else {
  5185. // fmt.Println(err)
  5186. // }
  5187. //
  5188. // userJSONBytes, _ := json.Marshal(dat)
  5189. //
  5190. //
  5191. //
  5192. // var res ResultSeven
  5193. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5194. // utils.ErrorLog("解析失败:%v", err)
  5195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5196. // return
  5197. // }
  5198. // if res.Infcode == -1 {
  5199. // errlog := &models.HisOrderError{
  5200. // UserOrgId: adminUser.CurrentOrgId,
  5201. // Ctime: time.Now().Unix(),
  5202. // Mtime: time.Now().Unix(),
  5203. // Number: chrg_bchno,
  5204. // ErrMsg: res.ErrMsg,
  5205. // Status: 1,
  5206. // PatientId: id,
  5207. // RecordTime: recordDateTime,
  5208. // Stage: 6,
  5209. // }
  5210. // service.CreateErrMsgLog(errlog)
  5211. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5212. // return
  5213. // } else {
  5214. // order_src.OrderStatus = 2
  5215. // order_src.PayWay = pay_way
  5216. // order_src.PayPrice = pay_price
  5217. // order_src.PayCardNo = pay_card_no
  5218. // order_src.DiscountPrice = discount_price
  5219. // order_src.PreferentialPrice = preferential_price
  5220. // order_src.RealityPrice = reality_price
  5221. // order_src.FoundPrice = found_price
  5222. // order_src.MedicalInsurancePrice = medical_insurance_price
  5223. // order_src.PrivatePrice = private_price
  5224. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  5225. // order_src.SetlId = res.Output.Setlinfo.SetlID
  5226. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  5227. // order_src.PsnName = res.Output.Setlinfo.PsnName
  5228. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  5229. // order_src.Certno = res.Output.Setlinfo.Certno
  5230. // order_src.Gend = res.Output.Setlinfo.Gend
  5231. // order_src.Naty = res.Output.Setlinfo.Naty
  5232. // order_src.Age = res.Output.Setlinfo.Age
  5233. // order_src.Insutype = res.Output.Setlinfo.Insutype
  5234. // order_src.PsnType = res.Output.Setlinfo.PsnType
  5235. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5236. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  5237. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5238. // order_src.MedType = res.Output.Setlinfo.MedType
  5239. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5240. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5241. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5242. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5243. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5244. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5245. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  5246. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  5247. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5248. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  5249. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  5250. // order_src.MafPay = res.Output.Setlinfo.MafPay
  5251. // order_src.OthPay = res.Output.Setlinfo.OthPay
  5252. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5253. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5254. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  5255. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5256. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5257. // order_src.Balc = res.Output.Setlinfo.Balc
  5258. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5259. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5260. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  5261. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  5262. // order_src.Creator = order_src.Creator
  5263. // order_src.Modify = roles.ID
  5264. // order_src.RequestLog = src_resquest
  5265. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5266. // detailStr := string(setlDetail)
  5267. // order_src.SetlDetail = detailStr
  5268. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5269. // err = service.UpDateOrder(order_src)
  5270. //
  5271. // if err == nil {
  5272. // c.ServeSuccessJSON(map[string]interface{}{
  5273. // "msg": "结算成功",
  5274. // })
  5275. // } else {
  5276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5277. // return
  5278. // }
  5279. // }
  5280. // }
  5281. //}
  5282. //退款
  5283. func (c *HisApiController) Refund() {
  5284. order_id, _ := c.GetInt64("order_id")
  5285. admin_user_id, _ := c.GetInt64("admin_user_id")
  5286. //record_time := c.GetString("record_time")
  5287. //patient_id, _ := c.GetInt64("patient_id")
  5288. //timeLayout := "2006-01-02"
  5289. //loc, _ := time.LoadLocation("Local")
  5290. adminUser := c.GetAdminUserInfo()
  5291. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5292. //if err != nil {
  5293. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5294. // return
  5295. //}
  5296. //recordDateTime := theTime.Unix()
  5297. var order models.HisOrder
  5298. order, _ = service.GetHisOrderByID(order_id)
  5299. //his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5300. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5301. if order.ID == 0 {
  5302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5303. return
  5304. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  5305. }
  5306. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5307. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5308. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5309. if config.IsOpen == 1 { //对接了医保,走医保流程
  5310. var res ResultSixteen
  5311. var resSixteen10265 ResultSixteen10265
  5312. var src_resquest string
  5313. var result string
  5314. if miConfig.MdtrtareaAdmvs == "421300" {
  5315. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  5316. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5317. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5318. resp3, requestErr3 := http.Get(api3)
  5319. if requestErr3 != nil {
  5320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5321. return
  5322. }
  5323. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5324. if ioErr3 != nil {
  5325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5327. return
  5328. }
  5329. var respJSON3 map[string]interface{}
  5330. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5333. return
  5334. }
  5335. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5336. userJSONBytes3, _ := json.Marshal(respJSON3)
  5337. fmt.Println("log")
  5338. fmt.Println(string(userJSONBytes3))
  5339. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5340. utils.ErrorLog("解析失败:%v", err)
  5341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5342. return
  5343. }
  5344. } else {
  5345. if miConfig.Code == "H15049901371" {
  5346. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5347. var dat map[string]interface{}
  5348. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5349. fmt.Println(dat)
  5350. } else {
  5351. fmt.Println(err)
  5352. }
  5353. saveLog(result, src_resquest, "2208", "退费")
  5354. userJSONBytes, _ := json.Marshal(dat)
  5355. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  5356. utils.ErrorLog("解析失败:%v", err)
  5357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5358. return
  5359. }
  5360. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5361. res.Output = resSixteen10265.Output
  5362. res.ErrMsg = resSixteen10265.ErrMsg
  5363. res.Cainfo = resSixteen10265.Cainfo
  5364. res.WarnMsg = resSixteen10265.WarnMsg
  5365. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5366. res.Infcode = infocode
  5367. } else {
  5368. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5369. var dat map[string]interface{}
  5370. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5371. fmt.Println(dat)
  5372. } else {
  5373. fmt.Println(err)
  5374. }
  5375. saveLog(result, src_resquest, "2208", "退费")
  5376. userJSONBytes, _ := json.Marshal(dat)
  5377. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5378. utils.ErrorLog("解析失败:%v", err)
  5379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5380. return
  5381. }
  5382. }
  5383. }
  5384. if res.Infcode == 0 {
  5385. var res2 ResultSix
  5386. var resSix10265 ResultSix10265
  5387. if miConfig.MdtrtareaAdmvs == "421300" {
  5388. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  5389. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5390. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5391. resp3, requestErr3 := http.Get(api3)
  5392. if requestErr3 != nil {
  5393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5394. return
  5395. }
  5396. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5397. if ioErr3 != nil {
  5398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5400. return
  5401. }
  5402. var respJSON3 map[string]interface{}
  5403. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5406. return
  5407. }
  5408. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5409. userJSONBytes3, _ := json.Marshal(respJSON3)
  5410. fmt.Println("log")
  5411. fmt.Println(string(userJSONBytes3))
  5412. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5413. utils.ErrorLog("解析失败:%v", err)
  5414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5415. return
  5416. }
  5417. } else {
  5418. if miConfig.Code == "H15049901371" {
  5419. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5420. var dat map[string]interface{}
  5421. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5422. fmt.Println(dat)
  5423. } else {
  5424. fmt.Println(err)
  5425. }
  5426. saveLog(result2, src_request, "2205", "撤销明细")
  5427. userJSONBytes, _ := json.Marshal(dat)
  5428. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5429. utils.ErrorLog("解析失败:%v", err)
  5430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5431. return
  5432. }
  5433. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5434. res2.Output = resSix10265.Output
  5435. res2.ErrMsg = resSix10265.ErrMsg
  5436. res2.Cainfo = resSix10265.Cainfo
  5437. res2.WarnMsg = resSix10265.WarnMsg
  5438. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5439. res2.Infcode = infocode
  5440. } else {
  5441. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5442. var dat map[string]interface{}
  5443. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5444. fmt.Println(dat)
  5445. } else {
  5446. fmt.Println(err)
  5447. }
  5448. saveLog(result2, src_request, "2205", "撤销明细")
  5449. userJSONBytes, _ := json.Marshal(dat)
  5450. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5451. utils.ErrorLog("解析失败:%v", err)
  5452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5453. return
  5454. }
  5455. }
  5456. }
  5457. if res2.Infcode == 0 {
  5458. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  5459. if err == nil {
  5460. c.ServeSuccessJSON(map[string]interface{}{
  5461. "msg": "退费成功",
  5462. })
  5463. } else {
  5464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5465. return
  5466. }
  5467. } else {
  5468. c.ServeSuccessJSON(map[string]interface{}{
  5469. "code": -10,
  5470. "msg": res2.ErrMsg,
  5471. })
  5472. }
  5473. } else {
  5474. c.ServeSuccessJSON(map[string]interface{}{
  5475. "code": -10,
  5476. "msg": res.ErrMsg,
  5477. })
  5478. }
  5479. }
  5480. }
  5481. func (c *HisApiController) RefundNumber() {
  5482. record_time := c.GetString("record_time")
  5483. //patient_id, _ := c.GetInt64("patient_id")
  5484. admin_user_id, _ := c.GetInt64("admin_user_id")
  5485. his_patient_id, _ := c.GetInt64("id")
  5486. timeLayout := "2006-01-02"
  5487. loc, _ := time.LoadLocation("Local")
  5488. adminUser := c.GetAdminUserInfo()
  5489. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5490. fmt.Println(err)
  5491. if err != nil {
  5492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5493. return
  5494. }
  5495. recordDateTime := theTime.Unix()
  5496. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5497. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  5498. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5499. //order, _ := service.GetHisOrderByID(order_id)
  5500. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5501. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5502. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5503. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  5504. if count > 0 {
  5505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  5506. return
  5507. }
  5508. if config.IsOpen == 1 { //对接了医保,走医保流程
  5509. var res2 ResultSix
  5510. var resSix10265 ResultSix10265
  5511. if miConfig.MdtrtareaAdmvs == "421300" {
  5512. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  5513. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5514. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5515. resp3, requestErr3 := http.Get(api3)
  5516. if requestErr3 != nil {
  5517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5518. return
  5519. }
  5520. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5521. if ioErr3 != nil {
  5522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5524. return
  5525. }
  5526. var respJSON3 map[string]interface{}
  5527. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5530. return
  5531. }
  5532. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5533. userJSONBytes3, _ := json.Marshal(respJSON3)
  5534. fmt.Println("log")
  5535. fmt.Println(string(userJSONBytes3))
  5536. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5537. utils.ErrorLog("解析失败:%v", err)
  5538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5539. return
  5540. }
  5541. } else {
  5542. var api3 string
  5543. if miConfig.Code == "H15049901371" {
  5544. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  5545. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5546. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5547. } else {
  5548. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  5549. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5550. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5551. }
  5552. resp3, requestErr3 := http.Get(api3)
  5553. if requestErr3 != nil {
  5554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5555. return
  5556. }
  5557. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5558. if ioErr3 != nil {
  5559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5561. return
  5562. }
  5563. var respJSON3 map[string]interface{}
  5564. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5567. return
  5568. }
  5569. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5570. userJSONBytes3, _ := json.Marshal(respJSON3)
  5571. if miConfig.Code == "H15049901371" {
  5572. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  5573. utils.ErrorLog("解析失败:%v", err)
  5574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5575. return
  5576. }
  5577. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5578. res2.Output = resSix10265.Output
  5579. res2.ErrMsg = resSix10265.ErrMsg
  5580. res2.Cainfo = resSix10265.Cainfo
  5581. res2.WarnMsg = resSix10265.WarnMsg
  5582. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5583. res2.Infcode = infocode
  5584. } else {
  5585. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5586. utils.ErrorLog("解析失败:%v", err)
  5587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5588. return
  5589. }
  5590. }
  5591. }
  5592. if res2.Infcode == 0 {
  5593. if err == nil {
  5594. c.ServeSuccessJSON(map[string]interface{}{
  5595. "msg": "退号成功",
  5596. })
  5597. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  5598. } else {
  5599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5600. return
  5601. }
  5602. } else {
  5603. c.ServeSuccessJSON(map[string]interface{}{
  5604. "code": -10,
  5605. "msg": res2.ErrMsg,
  5606. })
  5607. }
  5608. } else {
  5609. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  5610. //if err == nil {
  5611. // c.ServeSuccessJSON(map[string]interface{}{
  5612. // "msg": "退费成功",
  5613. // })
  5614. //} else {
  5615. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5616. // return
  5617. //}
  5618. }
  5619. }
  5620. func (c *HisApiController) RefundDetail() {
  5621. order_id, _ := c.GetInt64("order_id")
  5622. //admin_user_id, _ := c.GetInt64("admin_user_id")
  5623. //his_patient_id, _ := c.GetInt64("his_patient_id")
  5624. number := c.GetString("number")
  5625. record_time := c.GetString("record_time")
  5626. patient_id, _ := c.GetInt64("patient_id")
  5627. timeLayout := "2006-01-02"
  5628. loc, _ := time.LoadLocation("Local")
  5629. adminUser := c.GetAdminUserInfo()
  5630. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5631. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5632. fmt.Println(err)
  5633. if err != nil {
  5634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5635. return
  5636. }
  5637. recordDateTime := theTime.Unix()
  5638. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5639. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5640. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5641. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5642. var order models.HisOrder
  5643. order, _ = service.GetHisOrderByID(order_id)
  5644. if order.ID == 0 {
  5645. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  5646. }
  5647. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5648. if config.IsOpen == 1 { //对接了医保,走医保流程
  5649. var res2 ResultSix
  5650. if miConfig.MdtrtareaAdmvs == "421300" {
  5651. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  5652. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5653. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5654. resp3, requestErr3 := http.Get(api3)
  5655. if requestErr3 != nil {
  5656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5657. return
  5658. }
  5659. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5660. if ioErr3 != nil {
  5661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5663. return
  5664. }
  5665. var respJSON3 map[string]interface{}
  5666. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5669. return
  5670. }
  5671. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5672. userJSONBytes3, _ := json.Marshal(respJSON3)
  5673. fmt.Println("log")
  5674. fmt.Println(string(userJSONBytes3))
  5675. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5676. utils.ErrorLog("解析失败:%v", err)
  5677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5678. return
  5679. }
  5680. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  5681. if err == nil {
  5682. c.ServeSuccessJSON(map[string]interface{}{
  5683. "msg": "撤销明细成功",
  5684. })
  5685. return
  5686. } else {
  5687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5688. return
  5689. }
  5690. } else {
  5691. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  5692. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5693. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5694. resp2, requestErr2 := http.Get(api2)
  5695. if requestErr2 != nil {
  5696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5697. return
  5698. }
  5699. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5700. if ioErr2 != nil {
  5701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5703. return
  5704. }
  5705. var respJSON2 map[string]interface{}
  5706. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  5707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5709. return
  5710. }
  5711. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  5712. if err == nil {
  5713. c.ServeSuccessJSON(map[string]interface{}{
  5714. "msg": "撤销明细成功",
  5715. })
  5716. return
  5717. } else {
  5718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5719. return
  5720. }
  5721. }
  5722. } else {
  5723. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  5724. if err == nil {
  5725. c.ServeSuccessJSON(map[string]interface{}{
  5726. "msg": "退费成功",
  5727. })
  5728. } else {
  5729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5730. return
  5731. }
  5732. }
  5733. }
  5734. //对账
  5735. func (c *HisApiController) GetCheckAccount() {
  5736. start_time := c.GetString("start_time")
  5737. end_time := c.GetString("end_time")
  5738. insutype := c.GetString("insutype")
  5739. clr_type := c.GetString("clr_type")
  5740. clr_org := c.GetString("clr_optins")
  5741. admin_user_id, _ := c.GetInt64("admin_user_id")
  5742. adminUser := c.GetAdminUserInfo()
  5743. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5744. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5745. if len(clr_org) == 0 {
  5746. clr_org = miConfig.MdtrtareaAdmvs
  5747. }
  5748. timeLayout := "2006-01-02"
  5749. loc, _ := time.LoadLocation("Local")
  5750. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5751. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5752. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  5753. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  5754. fixmedins_setl_cnt := int64(len(orders))
  5755. //
  5756. ////撤销的算2条数据为一笔
  5757. //for _, item := range orders_two {
  5758. // if item.OrderStatus == 3 {
  5759. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  5760. // }
  5761. //}
  5762. var medfee_sumamt float64
  5763. var acct_pay float64
  5764. var fund_pay_sumamt float64
  5765. for _, item := range orders {
  5766. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  5767. acct_pay = acct_pay + item.AcctPay
  5768. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  5769. }
  5770. var user_name string
  5771. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5772. if role.ID == 0 {
  5773. user_name = "xxx"
  5774. } else {
  5775. user_name = role.UserName
  5776. }
  5777. if config.IsOpen == 1 {
  5778. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5779. "insutype=" + insutype +
  5780. "&clr_type=" + clr_type +
  5781. "&setl_optins=" + clr_org +
  5782. "&stmt_begndate=" + start_time +
  5783. "&stm_enddate=" + end_time +
  5784. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  5785. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  5786. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  5787. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  5788. "&fixmedins_code=" + miConfig.Code +
  5789. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5790. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5791. "&secret_key=" + miConfig.SecretKey +
  5792. "&org_name=" + miConfig.OrgName +
  5793. "&doctor=" + user_name
  5794. fmt.Println(api)
  5795. resp, requestErr := http.Get(api)
  5796. if requestErr != nil {
  5797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5798. return
  5799. }
  5800. body, ioErr := ioutil.ReadAll(resp.Body)
  5801. fmt.Println(body)
  5802. if ioErr != nil {
  5803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5805. return
  5806. }
  5807. var respJSON map[string]interface{}
  5808. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5811. return
  5812. }
  5813. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5814. userJSONBytes, _ := json.Marshal(respJSON)
  5815. var res ResultEight
  5816. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5817. utils.ErrorLog("解析失败:%v", err)
  5818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5819. return
  5820. }
  5821. if res.Infcode == 0 {
  5822. if res.Output.Stmtinfo.StmtRslt == "0" {
  5823. micc := &models.MedicalInsuranceCostCompare{
  5824. StartTime: startime.Unix(),
  5825. EndTime: endtime.Unix(),
  5826. Insutype: insutype,
  5827. CheckType: 1,
  5828. Num: fixmedins_setl_cnt,
  5829. Mtime: time.Now().Unix(),
  5830. Status: 1,
  5831. UserOrgId: adminUser.CurrentOrgId,
  5832. CostTotal: medfee_sumamt,
  5833. FuncTotal: fund_pay_sumamt,
  5834. PsnPay: acct_pay,
  5835. Creator: admin_user_id,
  5836. Ctime: time.Now().Unix(),
  5837. }
  5838. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  5839. if err == nil {
  5840. c.ServeSuccessJSON(map[string]interface{}{
  5841. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5842. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5843. })
  5844. } else {
  5845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5846. }
  5847. } else {
  5848. c.ServeSuccessJSON(map[string]interface{}{
  5849. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5850. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5851. })
  5852. }
  5853. } else {
  5854. c.ServeSuccessJSON(map[string]interface{}{
  5855. "code": -10,
  5856. "msg": res.ErrMsg,
  5857. })
  5858. }
  5859. }
  5860. }
  5861. func (c *HisApiController) Check310() {
  5862. adminUser := c.GetAdminUserInfo()
  5863. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5864. var user_name string
  5865. user_name = "xxx"
  5866. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5867. "insutype=" + "310" +
  5868. "&clr_type=" + "11" +
  5869. "&setl_optins=" + "定点医保中心" +
  5870. "&stmt_begndate=" + "2021-03-01" +
  5871. "&stm_enddate=" + "2021-03-31" +
  5872. "&medfee_sumamt=" + "11521" +
  5873. "&fund_pay_sumamt=" + "10166.66" +
  5874. "&acct_pay=" + "0" +
  5875. "&fixmedins_setl_cnt=" + "7" +
  5876. "&fixmedins_code=" + miConfig.Code +
  5877. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5878. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5879. "&secret_key=" + miConfig.SecretKey +
  5880. "&org_name=" + miConfig.OrgName +
  5881. "&doctor=" + user_name
  5882. fmt.Println(api)
  5883. resp, requestErr := http.Get(api)
  5884. if requestErr != nil {
  5885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5886. return
  5887. }
  5888. body, ioErr := ioutil.ReadAll(resp.Body)
  5889. fmt.Println(body)
  5890. if ioErr != nil {
  5891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5893. return
  5894. }
  5895. var respJSON map[string]interface{}
  5896. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5899. return
  5900. }
  5901. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5902. userJSONBytes, _ := json.Marshal(respJSON)
  5903. var res ResultEight
  5904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5905. utils.ErrorLog("解析失败:%v", err)
  5906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5907. return
  5908. }
  5909. }
  5910. func (c *HisApiController) Check390() {
  5911. adminUser := c.GetAdminUserInfo()
  5912. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5913. var user_name string
  5914. user_name = "张俊杰"
  5915. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5916. "insutype=" + "390" +
  5917. "&clr_type=" + "11" +
  5918. "&setl_optins=" + "定点医保中心" +
  5919. "&stmt_begndate=" + "2021-03-01" +
  5920. "&stm_enddate=" + "2021-03-31" +
  5921. "&medfee_sumamt=" + "209318.43" +
  5922. "&fund_pay_sumamt=" + "188029.12" +
  5923. "&acct_pay=" + "0" +
  5924. "&fixmedins_setl_cnt=" + "48" +
  5925. "&fixmedins_code=" + miConfig.Code +
  5926. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5927. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5928. "&secret_key=" + miConfig.SecretKey +
  5929. "&org_name=" + miConfig.OrgName +
  5930. "&doctor=" + user_name
  5931. fmt.Println(api)
  5932. resp, requestErr := http.Get(api)
  5933. if requestErr != nil {
  5934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5935. return
  5936. }
  5937. body, ioErr := ioutil.ReadAll(resp.Body)
  5938. fmt.Println(body)
  5939. if ioErr != nil {
  5940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5942. return
  5943. }
  5944. var respJSON map[string]interface{}
  5945. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5948. return
  5949. }
  5950. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5951. userJSONBytes, _ := json.Marshal(respJSON)
  5952. var res ResultEight
  5953. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5954. utils.ErrorLog("解析失败:%v", err)
  5955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5956. return
  5957. }
  5958. }
  5959. //对账明细
  5960. func (c *HisApiController) GetCheckDetailAccount() {
  5961. start_time := c.GetString("start_time")
  5962. end_time := c.GetString("end_time")
  5963. admin_user_id, _ := c.GetInt64("admin_user_id")
  5964. adminUser := c.GetAdminUserInfo()
  5965. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5966. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5967. timeLayout := "2006-01-02"
  5968. loc, _ := time.LoadLocation("Local")
  5969. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5970. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5971. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  5972. Mkdir(miConfig.OrgName)
  5973. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  5974. file_name := file + ".txt"
  5975. zip_name := file + ".zip"
  5976. zip_path := miConfig.OrgName + "/" + zip_name
  5977. file_path := miConfig.OrgName + "/" + file_name
  5978. decimal.DivisionPrecision = 2
  5979. var medfee_sumamt float64
  5980. var psn_cash_pay float64
  5981. var fund_pay_sumamt float64
  5982. fixmedins_setl_cnt := int64(len(orders))
  5983. for _, item := range orders {
  5984. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  5985. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  5986. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  5987. }
  5988. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  5989. defer f.Close()
  5990. if err != nil {
  5991. fmt.Println(err.Error())
  5992. } else {
  5993. for _, item := range orders {
  5994. var refd_setl_flag string
  5995. if item.OrderStatus == 2 {
  5996. refd_setl_flag = "0"
  5997. var str string
  5998. str = item.SetlId + " " +
  5999. item.MdtrtId + " " +
  6000. item.PsnNo + " " +
  6001. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6002. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6003. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  6004. _, err = f.Write([]byte(str))
  6005. }
  6006. if item.OrderStatus == 3 {
  6007. var str string
  6008. str = item.SetlId + " " +
  6009. item.MdtrtId + " " +
  6010. item.PsnNo + " " +
  6011. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6012. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6013. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  6014. _, err = f.Write([]byte(str))
  6015. var str2 string
  6016. str2 = item.SetlId + " " +
  6017. item.MdtrtId + " " +
  6018. item.PsnNo + " " +
  6019. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  6020. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  6021. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  6022. _, err = f.Write([]byte(str2))
  6023. }
  6024. }
  6025. }
  6026. Zip(file_path, zip_path)
  6027. fmt.Println(ReadFile(zip_path))
  6028. fmt.Println(string(ReadFile(zip_path)))
  6029. if config.IsOpen == 1 {
  6030. var user_name string
  6031. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6032. if role.ID == 0 {
  6033. user_name = "管理员"
  6034. } else {
  6035. user_name = role.UserName
  6036. }
  6037. baseParams := models.BaseParams{
  6038. SecretKey: miConfig.SecretKey,
  6039. FixmedinsCode: miConfig.Code,
  6040. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6041. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6042. OrgName: miConfig.OrgName,
  6043. Doctor: user_name,
  6044. }
  6045. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  6046. var dat map[string]interface{}
  6047. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6048. fmt.Println(dat)
  6049. } else {
  6050. fmt.Println(err)
  6051. }
  6052. userJSONBytes, _ := json.Marshal(dat)
  6053. var res ResultNine
  6054. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6055. utils.ErrorLog("解析失败:%v", err)
  6056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6057. return
  6058. }
  6059. if res.Infcode == 0 {
  6060. fileNo := res.Output.FileQuryNo
  6061. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  6062. "file_qury_no=" + fileNo +
  6063. "&setl_optins=" + "定点医保中心" +
  6064. "&stmt_begndate=" + start_time +
  6065. "&stm_enddate=" + end_time +
  6066. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6067. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6068. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  6069. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6070. "&fixmedins_code=" + miConfig.Code +
  6071. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6072. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6073. "&secret_key=" + miConfig.SecretKey +
  6074. "&org_name=" + miConfig.OrgName +
  6075. "&doctor=" + user_name
  6076. resp, requestErr := http.Get(api)
  6077. if requestErr != nil {
  6078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6079. return
  6080. }
  6081. body, ioErr := ioutil.ReadAll(resp.Body)
  6082. if ioErr != nil {
  6083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6085. return
  6086. }
  6087. var respJSON map[string]interface{}
  6088. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6091. return
  6092. }
  6093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6094. userJSONBytes, _ := json.Marshal(respJSON)
  6095. var res ResultTen
  6096. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6097. utils.ErrorLog("解析失败:%v", err)
  6098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6099. return
  6100. }
  6101. if res.Infcode == 0 {
  6102. service.Gdyb9102(baseParams, zip_name, fileNo)
  6103. micc := &models.MedicalInsuranceCostCompare{
  6104. StartTime: startime.Unix(),
  6105. EndTime: endtime.Unix(),
  6106. Insutype: "0",
  6107. CheckType: 2,
  6108. Num: fixmedins_setl_cnt,
  6109. Mtime: time.Now().Unix(),
  6110. Status: 1,
  6111. UserOrgId: adminUser.CurrentOrgId,
  6112. CostTotal: medfee_sumamt,
  6113. FuncTotal: fund_pay_sumamt,
  6114. PsnPay: psn_cash_pay,
  6115. Creator: admin_user_id,
  6116. Ctime: time.Now().Unix(),
  6117. }
  6118. service.CreateMedicalInsuranceCostCompareRecord(micc)
  6119. c.ServeSuccessJSON(map[string]interface{}{
  6120. "msg": "明细对账成功",
  6121. })
  6122. }
  6123. } else {
  6124. }
  6125. }
  6126. }
  6127. type CustomOrderInfo struct {
  6128. Name string
  6129. Spec string
  6130. Unit string
  6131. Count float64
  6132. Price float64
  6133. Total float64
  6134. }
  6135. func (c *HisApiController) GetSettleAccounts() {
  6136. //id, _ := c.GetInt64("id")
  6137. //record_time := c.GetString("record_time")
  6138. order_id, _ := c.GetInt64("order_id")
  6139. admin_user_id, _ := c.GetInt64("admin_user_id")
  6140. //timeLayout := "2006-01-02"
  6141. //loc, _ := time.LoadLocation("Local")
  6142. //
  6143. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6144. //if err != nil {
  6145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6146. // return
  6147. //}
  6148. //recordDateTime := theTime.Unix()
  6149. adminUser := c.GetAdminUserInfo()
  6150. order, _ := service.GetHisOrderByID(order_id)
  6151. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6152. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  6153. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  6154. orderInfos = append(orderInfos, orderInfos_two...)
  6155. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  6156. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6157. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  6158. //var config []*models.HisXtDiagnoseConfig
  6159. var name string
  6160. for _, item := range diagnosis_ids {
  6161. id, _ := strconv.ParseInt(item, 10, 64)
  6162. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6163. if len(name) == 0 {
  6164. name = diagnosisConfig.ClassName
  6165. } else {
  6166. name = name + "," + diagnosisConfig.ClassName
  6167. }
  6168. }
  6169. var bedCostTotal float64 = 0 //床位总费
  6170. var bedCostSelfTotal float64 = 0 //床位自费
  6171. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6172. var operationCostTotal float64 = 0 //手术费
  6173. var operationCostSelfTotal float64 = 0 //手术费
  6174. var operationCostPartSelfTotal float64 = 0 //手术费
  6175. var otherCostTotal float64 = 0 //其他费用
  6176. var otherCostSelfTotal float64 = 0 //其他费用
  6177. var otherCostPartSelfTotal float64 = 0 //其他费用
  6178. var materialCostTotal float64 = 0 //材料费
  6179. var materialCostSelfTotal float64 = 0 //材料费
  6180. var materialCostPartSelfTotal float64 = 0 //材料费
  6181. var westernMedicineCostTotal float64 = 0 //西药费
  6182. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6183. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6184. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6185. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6186. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6187. var checkCostTotal float64 = 0 //检查费
  6188. var checkCostSelfTotal float64 = 0 //检查费
  6189. var checkCostPartSelfTotal float64 = 0 //检查费
  6190. var laboratoryCostTotal float64 = 0 //化验费
  6191. var laboratoryCostSelfTotal float64 = 0 //化验费
  6192. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6193. var treatCostTotal float64 = 0 //治疗费用
  6194. var treatCostSelfTotal float64 = 0 //治疗费用
  6195. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6196. decimal.DivisionPrecision = 2
  6197. for _, item := range orderInfos {
  6198. if item.MedChrgitmType == "01" { //床位费
  6199. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6200. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6201. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6202. }
  6203. if item.MedChrgitmType == "03" { //检查费
  6204. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6205. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6206. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6207. }
  6208. if item.MedChrgitmType == "04" { //化验费
  6209. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6210. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6211. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6212. }
  6213. if item.MedChrgitmType == "05" { //治疗费
  6214. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6215. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6216. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6217. }
  6218. if item.MedChrgitmType == "06" { //手术费
  6219. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6220. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6221. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6222. }
  6223. if item.MedChrgitmType == "08" { //材料费
  6224. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6225. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6226. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6227. }
  6228. if item.MedChrgitmType == "09" { //西药费
  6229. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6230. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6231. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6232. }
  6233. if item.MedChrgitmType == "11" { //中成费
  6234. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6235. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6236. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6237. }
  6238. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  6239. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6240. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6241. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6242. }
  6243. }
  6244. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6245. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6246. var user_name string
  6247. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6248. if role.ID == 0 {
  6249. user_name = "管理员"
  6250. } else {
  6251. user_name = role.UserName
  6252. }
  6253. baseParams := models.BaseParams{
  6254. SecretKey: miConfig.SecretKey,
  6255. FixmedinsCode: miConfig.Code,
  6256. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6257. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6258. OrgName: miConfig.OrgName,
  6259. Doctor: user_name,
  6260. }
  6261. businessParams := models.BusinessParams{
  6262. PsnNo: order.PsnNo,
  6263. MdtrtId: order.MdtrtId,
  6264. SetlId: order.SetlId,
  6265. }
  6266. var res ResultEleven
  6267. var resEleven10265 ResultEleven10265
  6268. if config.IsOpen == 1 {
  6269. if miConfig.MdtrtareaAdmvs == "421300" {
  6270. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6271. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6272. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6273. resp, requestErr := http.Get(api)
  6274. if requestErr != nil {
  6275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6276. return
  6277. }
  6278. body, ioErr := ioutil.ReadAll(resp.Body)
  6279. if ioErr != nil {
  6280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6282. return
  6283. }
  6284. var respJSON map[string]interface{}
  6285. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6288. return
  6289. }
  6290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6291. result, _ := json.Marshal(respJSON)
  6292. fmt.Println("log")
  6293. fmt.Println(string(result))
  6294. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6295. utils.ErrorLog("解析失败:%v", err)
  6296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6297. return
  6298. }
  6299. } else {
  6300. result := service.Gdyb5203(baseParams, businessParams)
  6301. var dat map[string]interface{}
  6302. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6303. fmt.Println(dat)
  6304. } else {
  6305. fmt.Println(err)
  6306. }
  6307. userJSONBytes, _ := json.Marshal(dat)
  6308. if miConfig.Code == "H15049901371" {
  6309. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  6310. utils.ErrorLog("解析失败:%v", err)
  6311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6312. return
  6313. }
  6314. res.InfRefmsgid = resEleven10265.InfRefmsgid
  6315. res.Output = resEleven10265.Output
  6316. res.ErrMsg = resEleven10265.ErrMsg
  6317. res.Cainfo = resEleven10265.Cainfo
  6318. res.WarnMsg = resEleven10265.WarnMsg
  6319. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  6320. res.Infcode = infocode
  6321. } else {
  6322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6323. utils.ErrorLog("解析失败:%v", err)
  6324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6325. return
  6326. }
  6327. }
  6328. }
  6329. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6330. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  6331. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  6332. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6333. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6334. var doctor_name string
  6335. if roles.ID == 0 {
  6336. doctor_name = "管理员"
  6337. } else {
  6338. doctor_name = roles.UserName
  6339. }
  6340. yiliao_leibie := ""
  6341. switch order.MedType {
  6342. case "11":
  6343. yiliao_leibie = "普通门诊"
  6344. break
  6345. case "12":
  6346. yiliao_leibie = "门诊挂号"
  6347. break
  6348. case "13":
  6349. yiliao_leibie = "急诊"
  6350. break
  6351. case "14":
  6352. yiliao_leibie = "门诊特殊病"
  6353. break
  6354. case "15":
  6355. yiliao_leibie = "门诊统筹"
  6356. break
  6357. case "16":
  6358. yiliao_leibie = "门诊慢性病"
  6359. break
  6360. case "21":
  6361. yiliao_leibie = "普通住院"
  6362. break
  6363. }
  6364. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6365. if res.Infcode == 0 {
  6366. c.ServeSuccessJSON(map[string]interface{}{
  6367. "diagnosis": name,
  6368. "order_infos": orderInfos,
  6369. "number": order.MdtrtId,
  6370. "date": order.SettleAccountsDate,
  6371. "charge_admin": charge_admin,
  6372. "printor_admin": printor_admin,
  6373. "info": res.Output.Setlinfo,
  6374. "bedCostTotal": bedCostTotal,
  6375. "bedCostSelfTotal": bedCostSelfTotal,
  6376. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  6377. "operationCostTotal": operationCostTotal,
  6378. "operationCostSelfTotal": operationCostSelfTotal,
  6379. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  6380. "otherCostTotal": otherCostTotal,
  6381. "otherCostSelfTotal": otherCostSelfTotal,
  6382. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  6383. "materialCostTotal": materialCostTotal,
  6384. "materialCostSelfTotal": materialCostSelfTotal,
  6385. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  6386. "westernMedicineCostTotal": westernMedicineCostTotal,
  6387. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  6388. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  6389. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  6390. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  6391. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  6392. "checkCostTotal": checkCostTotal,
  6393. "checkCostSelfTotal": checkCostSelfTotal,
  6394. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  6395. "laboratoryCostTotal": laboratoryCostTotal,
  6396. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  6397. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  6398. "treatCostTotal": treatCostTotal,
  6399. "treatCostSelfTotal": treatCostSelfTotal,
  6400. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  6401. "doctor_code": adminRole_two.DoctorCode,
  6402. "doctor_name": doctor_name,
  6403. "health_card_no": order.PsnNo,
  6404. "department": departments.Name,
  6405. "yiliao_leibie": yiliao_leibie,
  6406. "after_money": order.AccountPrice,
  6407. "patient": patient,
  6408. "org_name": miConfig.OrgName,
  6409. "org_code": miConfig.Code,
  6410. "order_number": order.Number,
  6411. //"check_order_info": cus_slice,
  6412. })
  6413. }
  6414. }
  6415. }
  6416. func (c *HisApiController) CheckTreatment() {
  6417. patient_id, _ := c.GetInt64("patient_id")
  6418. id_card_no := c.GetString("id_card_no")
  6419. insutype := c.GetString("insutype")
  6420. med_type := c.GetString("med_type")
  6421. admin_user_id, _ := c.GetInt64("admin_user_id")
  6422. adminUser := c.GetAdminUserInfo()
  6423. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6424. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6425. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6426. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6427. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  6428. var dat map[string]interface{}
  6429. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6430. fmt.Println(dat)
  6431. } else {
  6432. fmt.Println(err)
  6433. }
  6434. userJSONBytes, _ := json.Marshal(dat)
  6435. var res ResultTwo
  6436. var res10265 ResultTwo10265
  6437. if miConfig.Code == "H15049901371" {
  6438. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  6439. utils.ErrorLog("解析失败:%v", err)
  6440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6441. return
  6442. }
  6443. res.ErrMsg = res10265.ErrMsg
  6444. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6445. res.Infcode = infocode
  6446. res.Output = res10265.Output
  6447. res.InfRefmsgid = res10265.InfRefmsgid
  6448. } else {
  6449. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6450. utils.ErrorLog("解析失败:%v", err)
  6451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6452. return
  6453. }
  6454. }
  6455. var user_name string
  6456. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  6457. if role.ID == 0 {
  6458. user_name = "xxx"
  6459. } else {
  6460. user_name = role.UserName
  6461. }
  6462. baseParams := models.BaseParams{
  6463. SecretKey: miConfig.SecretKey,
  6464. FixmedinsCode: miConfig.Code,
  6465. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6466. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6467. OrgName: miConfig.OrgName,
  6468. Doctor: user_name,
  6469. }
  6470. if config.IsOpen == 1 {
  6471. if miConfig.Code == "H15049901371" {
  6472. if med_type == "14" {
  6473. if insutype == "390" {
  6474. med_type = "9933"
  6475. } else if insutype == "310" {
  6476. med_type = "990502"
  6477. }
  6478. } else if med_type == "11" {
  6479. med_type = "11"
  6480. }
  6481. }
  6482. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  6483. var dat map[string]interface{}
  6484. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6485. fmt.Println(dat)
  6486. } else {
  6487. fmt.Println(err)
  6488. }
  6489. var res Result2001
  6490. var res10265 Result2001Org10265
  6491. if miConfig.Code == "H15049901371" {
  6492. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6493. utils.ErrorLog("解析失败:%v", err)
  6494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6495. return
  6496. }
  6497. res.ErrMsg = res10265.ErrMsg
  6498. res.Output = res10265.Output
  6499. res.InfRefmsgid = res10265.InfRefmsgid
  6500. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6501. res.Infcode = infocode
  6502. } else {
  6503. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6504. utils.ErrorLog("解析失败:%v", err)
  6505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6506. return
  6507. }
  6508. }
  6509. if res.Infcode == 0 {
  6510. c.ServeSuccessJSON(map[string]interface{}{
  6511. "msg": res.Output.Trtinfo,
  6512. })
  6513. }
  6514. }
  6515. }
  6516. //func (c *HisApiController) PutRecord() {
  6517. // id, _ := c.GetInt64("id")
  6518. // record_time := c.GetString("record_time")
  6519. // timeLayout := "2006-01-02"
  6520. // loc, _ := time.LoadLocation("Local")
  6521. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6522. // if err != nil {
  6523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6524. // return
  6525. // }
  6526. // recordDateTime := theTime.Unix()
  6527. //
  6528. // adminInfo := c.GetAdminUserInfo()
  6529. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  6530. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6531. //
  6532. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6533. //
  6534. // fmt.Println(miConfig.SecretKey)
  6535. //
  6536. // if patient == nil {
  6537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6538. // return
  6539. // }
  6540. // if len(patient.IdCardNo) == 0 {
  6541. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  6542. // return
  6543. // }
  6544. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  6545. // if config.IsOpen == 1 {
  6546. // 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
  6547. // resp, requestErr := http.Get(api)
  6548. // if requestErr != nil {
  6549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6550. // return
  6551. // }
  6552. // defer resp.Body.Close()
  6553. // body, ioErr := ioutil.ReadAll(resp.Body)
  6554. // if ioErr != nil {
  6555. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6557. // return
  6558. // }
  6559. // var respJSON map[string]interface{}
  6560. //
  6561. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6562. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6563. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6564. // return
  6565. // }
  6566. //
  6567. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6568. // userJSONBytes, _ := json.Marshal(userJSON)
  6569. // var res ResultTwo
  6570. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6571. // utils.ErrorLog("解析失败:%v", err)
  6572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6573. // return
  6574. // }
  6575. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6576. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6577. // infoStr := string(Iinfos)
  6578. // idetinfoStr := string(Idetinfos)
  6579. //
  6580. // if res.Infcode == 0 {
  6581. // his := models.VMHisPatient{
  6582. // Status: 1,
  6583. // Ctime: time.Now().Unix(),
  6584. // Mtime: time.Now().Unix(),
  6585. // PsnNo: res.Output.Baseinfo.PsnNo,
  6586. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  6587. // Certno: res.Output.Baseinfo.Certno,
  6588. // PsnName: res.Output.Baseinfo.PsnName,
  6589. // Gend: res.Output.Baseinfo.Gend,
  6590. // Naty: res.Output.Baseinfo.Naty,
  6591. // Brdy: res.Output.Baseinfo.Brdy,
  6592. // Age: res.Output.Baseinfo.Age,
  6593. // Iinfo: infoStr,
  6594. // Idetinfo: idetinfoStr,
  6595. // PatientId: patient.ID,
  6596. // RecordDate: theTime.Unix(),
  6597. // UserOrgId: adminInfo.CurrentOrgId,
  6598. // AdminUserId: adminInfo.AdminUser.Id,
  6599. // IsReturn: 1,
  6600. // }
  6601. //
  6602. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  6603. // //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")
  6604. // //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")
  6605. //
  6606. // //var dat map[string]interface{}
  6607. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6608. // // fmt.Println(dat)
  6609. // //} else {
  6610. // // fmt.Println(err)
  6611. // //}
  6612. //
  6613. // var dat2 map[string]interface{}
  6614. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  6615. // fmt.Println(dat2)
  6616. // } else {
  6617. // fmt.Println(err)
  6618. // }
  6619. //
  6620. // } else {
  6621. // adminUser := c.GetAdminUserInfo()
  6622. // errlog := &models.HisOrderError{
  6623. // UserOrgId: adminUser.CurrentOrgId,
  6624. // Ctime: time.Now().Unix(),
  6625. // Mtime: time.Now().Unix(),
  6626. // ErrMsg: res.ErrMsg,
  6627. // Status: 1,
  6628. // PatientId: id,
  6629. // RecordTime: recordDateTime,
  6630. // Stage: 1,
  6631. // }
  6632. // service.CreateErrMsgLog(errlog)
  6633. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  6634. // return
  6635. // }
  6636. // }
  6637. //
  6638. //}
  6639. func (c *HisApiController) GetUploadDiag() {
  6640. id, _ := c.GetInt64("id")
  6641. record_time := c.GetString("record_time")
  6642. diagnosis_id, _ := c.GetInt64("diagnosis")
  6643. sick_type, _ := c.GetInt64("sick_type")
  6644. reg_type, _ := c.GetInt64("reg_type")
  6645. timeLayout := "2006-01-02"
  6646. loc, _ := time.LoadLocation("Local")
  6647. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6648. if err != nil {
  6649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6650. return
  6651. }
  6652. var patientPrescription models.HisPrescriptionInfo
  6653. recordDateTime := theTime.Unix()
  6654. adminInfo := c.GetAdminUserInfo()
  6655. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6656. if patientPrescription.ID == 0 {
  6657. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6658. }
  6659. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  6660. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6661. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  6662. sickConfig, _ := service.FindSickById(sick_type)
  6663. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6664. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  6665. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  6666. "&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 +
  6667. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  6668. resp2, requestErr2 := http.Get(api2)
  6669. if requestErr2 != nil {
  6670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6671. return
  6672. }
  6673. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6674. if ioErr2 != nil {
  6675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6677. return
  6678. }
  6679. var respJSON2 map[string]interface{}
  6680. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6683. return
  6684. }
  6685. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6686. userJSONBytes2, _ := json.Marshal(respJSON2)
  6687. var res2 ResultSix
  6688. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6689. utils.ErrorLog("解析失败:%v", err)
  6690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6691. return
  6692. }
  6693. if res2.Infcode != 0 {
  6694. adminUser := c.GetAdminUserInfo()
  6695. errlog := &models.HisOrderError{
  6696. UserOrgId: adminUser.CurrentOrgId,
  6697. Ctime: time.Now().Unix(),
  6698. Mtime: time.Now().Unix(),
  6699. ErrMsg: res2.ErrMsg,
  6700. Status: 1,
  6701. PatientId: id,
  6702. RecordTime: recordDateTime,
  6703. Stage: 3,
  6704. }
  6705. service.CreateErrMsgLog(errlog)
  6706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  6707. return
  6708. }
  6709. c.ServeSuccessJSON(map[string]interface{}{
  6710. "msg": "上传成功",
  6711. })
  6712. }
  6713. type QueryResult struct {
  6714. ID int64
  6715. Name string
  6716. Code string
  6717. List_type_code string
  6718. }
  6719. func (c *HisApiController) GetCheckCode() {
  6720. ids_str := c.GetString("ids")
  6721. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  6722. ids_arr := strings.Split(ids_str, ",")
  6723. var queryResult []QueryResult
  6724. ids := make([]int64, 0)
  6725. for _, item := range ids_arr {
  6726. id, _ := strconv.ParseInt(item, 10, 64)
  6727. ids = append(ids, id)
  6728. }
  6729. if record_type == 1 {
  6730. drugs, _ := service.GetBatchDrugList(ids)
  6731. for _, item := range drugs {
  6732. result := QueryResult{
  6733. ID: item.ID,
  6734. Name: item.DrugName,
  6735. Code: item.MedicalInsuranceNumber,
  6736. List_type_code: "101",
  6737. }
  6738. queryResult = append(queryResult, result)
  6739. }
  6740. } else if record_type == 2 {
  6741. goods, _ := service.GetBatchGoodInformationList(ids)
  6742. for _, item := range goods {
  6743. result := QueryResult{
  6744. ID: item.ID,
  6745. Name: item.GoodName,
  6746. Code: item.MedicalInsuranceNumber,
  6747. List_type_code: "301",
  6748. }
  6749. queryResult = append(queryResult, result)
  6750. }
  6751. } else if record_type == 3 {
  6752. projects, _ := service.GetBathchMyPorjecgList(ids)
  6753. for _, item := range projects {
  6754. result := QueryResult{
  6755. ID: item.ID,
  6756. Name: item.ProjectName,
  6757. Code: item.MedicalCode,
  6758. List_type_code: "201",
  6759. }
  6760. queryResult = append(queryResult, result)
  6761. }
  6762. }
  6763. admin_user_id, _ := c.GetInt64("admin_user_id")
  6764. adminUser := c.GetAdminUserInfo()
  6765. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6766. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6767. var user_name string
  6768. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6769. if role.ID == 0 {
  6770. user_name = "xxx"
  6771. } else {
  6772. user_name = role.UserName
  6773. }
  6774. baseParams := &models.BaseParams{
  6775. SecretKey: miConfig.SecretKey,
  6776. FixmedinsCode: miConfig.Code,
  6777. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6778. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6779. OrgName: miConfig.OrgName,
  6780. Doctor: user_name,
  6781. }
  6782. if config.IsOpen == 1 {
  6783. for _, item := range queryResult {
  6784. var result string
  6785. if record_type == 1 {
  6786. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  6787. } else if record_type == 2 {
  6788. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  6789. } else if record_type == 3 {
  6790. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  6791. }
  6792. var dat map[string]interface{}
  6793. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6794. fmt.Println(dat)
  6795. } else {
  6796. fmt.Println(err)
  6797. }
  6798. userJSONBytes, _ := json.Marshal(dat)
  6799. var res ResultSix
  6800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6801. utils.ErrorLog("解析失败:%v", err)
  6802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6803. return
  6804. }
  6805. if res.Infcode == 0 {
  6806. if record_type == 1 {
  6807. service.UpdateBaseDrugById(item.ID)
  6808. } else if record_type == 2 {
  6809. service.UpdateGoodInformaitonByDetail(item.ID)
  6810. } else if record_type == 3 {
  6811. service.UpdateProjectById(item.ID)
  6812. }
  6813. c.ServeSuccessJSON(map[string]interface{}{
  6814. "failed_code": 0,
  6815. "msg": "目录对照成功",
  6816. })
  6817. } else {
  6818. c.ServeSuccessJSON(map[string]interface{}{
  6819. "failed_code": -10,
  6820. "msg": res.ErrMsg,
  6821. })
  6822. }
  6823. }
  6824. }
  6825. }
  6826. func (c *HisApiController) UnCheckCode() {
  6827. ids_str := c.GetString("ids")
  6828. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  6829. admin_user_id, _ := c.GetInt64("admin_user_id")
  6830. ids_arr := strings.Split(ids_str, ",")
  6831. var queryResult []QueryResult
  6832. ids := make([]int64, 0)
  6833. for _, item := range ids_arr {
  6834. id, _ := strconv.ParseInt(item, 10, 64)
  6835. ids = append(ids, id)
  6836. }
  6837. if record_type == 1 {
  6838. drugs, _ := service.GetBatchDrugList(ids)
  6839. for _, item := range drugs {
  6840. result := QueryResult{
  6841. ID: item.ID,
  6842. Name: item.DrugName,
  6843. Code: item.MedicalInsuranceNumber,
  6844. List_type_code: "101",
  6845. }
  6846. queryResult = append(queryResult, result)
  6847. }
  6848. } else if record_type == 2 {
  6849. goods, _ := service.GetBatchGoodInformationList(ids)
  6850. for _, item := range goods {
  6851. result := QueryResult{
  6852. ID: item.ID,
  6853. Name: item.GoodName,
  6854. Code: item.MedicalInsuranceNumber,
  6855. List_type_code: "301",
  6856. }
  6857. queryResult = append(queryResult, result)
  6858. }
  6859. } else if record_type == 3 {
  6860. projects, _ := service.GetBathchMyPorjecgList(ids)
  6861. for _, item := range projects {
  6862. result := QueryResult{
  6863. ID: item.ID,
  6864. Name: item.ProjectName,
  6865. Code: item.MedicalCode,
  6866. List_type_code: "201",
  6867. }
  6868. queryResult = append(queryResult, result)
  6869. }
  6870. }
  6871. adminUser := c.GetAdminUserInfo()
  6872. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6873. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6874. var user_name string
  6875. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6876. if role.ID == 0 {
  6877. user_name = "xxx"
  6878. } else {
  6879. user_name = role.UserName
  6880. }
  6881. baseParams := &models.BaseParams{
  6882. SecretKey: miConfig.SecretKey,
  6883. FixmedinsCode: miConfig.Code,
  6884. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6885. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6886. OrgName: miConfig.OrgName,
  6887. Doctor: user_name,
  6888. }
  6889. if config.IsOpen == 1 {
  6890. for _, item := range queryResult {
  6891. var result string
  6892. if record_type == 1 {
  6893. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6894. } else if record_type == 2 {
  6895. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6896. } else if record_type == 3 {
  6897. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6898. }
  6899. var dat2 map[string]interface{}
  6900. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  6901. fmt.Println(dat2)
  6902. } else {
  6903. fmt.Println(err)
  6904. }
  6905. userJSONBytes, _ := json.Marshal(dat2)
  6906. var res ResultSix
  6907. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6908. utils.ErrorLog("解析失败:%v", err)
  6909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6910. return
  6911. }
  6912. if res.Infcode == 0 {
  6913. if record_type == 1 {
  6914. service.UpdateDrugByIdDetail(item.ID)
  6915. } else if record_type == 2 {
  6916. service.UpdateGoodInfoById(item.ID)
  6917. } else if record_type == 3 {
  6918. service.UpdateMyProjectById(item.ID)
  6919. }
  6920. c.ServeSuccessJSON(map[string]interface{}{
  6921. "failed_code": 0,
  6922. "msg": "撤销目录对照成功",
  6923. })
  6924. } else {
  6925. c.ServeSuccessJSON(map[string]interface{}{
  6926. "failed_code": -10,
  6927. "msg": res.ErrMsg,
  6928. })
  6929. }
  6930. }
  6931. }
  6932. }
  6933. func (c *HisApiController) GetPatientInfo() {
  6934. id_card_no := c.GetString("id_card_no")
  6935. admin_user_id, _ := c.GetInt64("admin_user_id")
  6936. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  6937. if patient.ID == 0 {
  6938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6939. return
  6940. }
  6941. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6942. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6943. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  6944. if config.IsOpen == 1 {
  6945. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  6946. var dat map[string]interface{}
  6947. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6948. fmt.Println(dat)
  6949. } else {
  6950. fmt.Println(err)
  6951. }
  6952. userJSONBytes, _ := json.Marshal(dat)
  6953. var res ResultTwo
  6954. var res10265 ResultTwo10265
  6955. if miConfig.Code == "H15049901371" {
  6956. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  6957. utils.ErrorLog("解析失败:%v", err)
  6958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6959. return
  6960. }
  6961. res.ErrMsg = res10265.ErrMsg
  6962. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6963. res.Infcode = infocode
  6964. res.Output = res10265.Output
  6965. res.InfRefmsgid = res10265.InfRefmsgid
  6966. } else {
  6967. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6968. utils.ErrorLog("解析失败:%v", err)
  6969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6970. return
  6971. }
  6972. }
  6973. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6974. // utils.ErrorLog("解析失败:%v", err)
  6975. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6976. // return
  6977. //}
  6978. if res.Infcode != 0 {
  6979. c.ServeSuccessJSON(map[string]interface{}{
  6980. "failed_code": -10,
  6981. "msg": res.ErrMsg,
  6982. })
  6983. } else {
  6984. c.ServeSuccessJSON(map[string]interface{}{
  6985. "failed_code": 0,
  6986. "info": res,
  6987. })
  6988. }
  6989. }
  6990. }
  6991. func (c *HisApiController) PsnPutOnRecord() {
  6992. record_type, _ := c.GetInt64("type")
  6993. patient_id, _ := c.GetInt64("patient_id")
  6994. admin_user_id, _ := c.GetInt64("admin_user_id")
  6995. start_time := c.GetString("start_time")
  6996. end_time := c.GetString("end_time")
  6997. adminUser := c.GetAdminUserInfo()
  6998. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6999. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7000. var patients []*models.Patients
  7001. if record_type == 1 { //全部备案
  7002. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  7003. patients = append(patients, patient...)
  7004. } else { //单个备案
  7005. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7006. patients = append(patients, patient)
  7007. }
  7008. var user_name string
  7009. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7010. if role.ID == 0 {
  7011. user_name = "xxx"
  7012. } else {
  7013. user_name = role.UserName
  7014. }
  7015. if config.IsOpen == 1 {
  7016. for _, item := range patients {
  7017. 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
  7018. resp, requestErr := http.Get(api)
  7019. if requestErr != nil {
  7020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7021. return
  7022. }
  7023. defer resp.Body.Close()
  7024. body, ioErr := ioutil.ReadAll(resp.Body)
  7025. if ioErr != nil {
  7026. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7028. return
  7029. }
  7030. var respJSON map[string]interface{}
  7031. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7034. return
  7035. }
  7036. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7037. userJSONBytes, _ := json.Marshal(userJSON)
  7038. var res ResultTwo
  7039. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7040. utils.ErrorLog("解析失败:%v", err)
  7041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7042. return
  7043. }
  7044. if res.Infcode == 0 {
  7045. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  7046. var dat map[string]interface{}
  7047. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7048. fmt.Println(dat)
  7049. } else {
  7050. fmt.Println(err)
  7051. }
  7052. userJSONBytes, _ := json.Marshal(dat)
  7053. var res2 ResultThirteen
  7054. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7055. utils.ErrorLog("解析失败:%v", err)
  7056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7057. return
  7058. }
  7059. if res2.Infcode == 0 {
  7060. psnResult := &models.GdybPsnRecord{
  7061. UserOrgId: adminUser.CurrentOrgId,
  7062. PatientId: item.ID,
  7063. PsnNo: res.Output.Baseinfo.PsnNo,
  7064. Ctime: time.Now().Unix(),
  7065. Mtime: time.Now().Unix(),
  7066. Status: 1,
  7067. IsCancel: 1,
  7068. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7069. }
  7070. service.CreatePsnRecord(psnResult)
  7071. } else {
  7072. c.ServeSuccessJSON(map[string]interface{}{
  7073. "failed_code": -10,
  7074. "msg": res2.ErrMsg,
  7075. })
  7076. return
  7077. }
  7078. }
  7079. }
  7080. }
  7081. }
  7082. func (c *HisApiController) PsnUnPutOnRecord() {
  7083. id, _ := c.GetInt64("id")
  7084. //record_type, _ := c.GetInt64("type")
  7085. admin_user_id, _ := c.GetInt64("admin_user_id")
  7086. adminUser := c.GetAdminUserInfo()
  7087. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7088. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7089. var user_name string
  7090. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7091. if role.ID == 0 {
  7092. user_name = "xxx"
  7093. } else {
  7094. user_name = role.UserName
  7095. }
  7096. psn_record, _ := service.GetPsnRecordById(id)
  7097. if psn_record.ID == 0 {
  7098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7099. return
  7100. }
  7101. if config.IsOpen == 1 {
  7102. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  7103. var dat map[string]interface{}
  7104. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7105. fmt.Println(dat)
  7106. } else {
  7107. fmt.Println(err)
  7108. }
  7109. userJSONBytes, _ := json.Marshal(dat)
  7110. var res ResultFourteen
  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. psn_record.IsCancel = 2
  7118. service.CreatePsnRecord(&psn_record)
  7119. } else {
  7120. c.ServeSuccessJSON(map[string]interface{}{
  7121. "failed_code": -10,
  7122. "msg": res.ErrMsg,
  7123. })
  7124. return
  7125. }
  7126. }
  7127. }
  7128. func (c *HisApiController) PsnPutNCDSOnRecord() {
  7129. patient_id, _ := c.GetInt64("patient_id")
  7130. insutype_two := c.GetString("insutype")
  7131. psn_no := c.GetString("psn_no")
  7132. doctor_id, _ := c.GetInt64("doctor_id")
  7133. sick_id, _ := c.GetInt64("sick_id")
  7134. department_id, _ := c.GetInt64("department_id")
  7135. start_time := c.GetString("start_time")
  7136. end_time := c.GetString("end_time")
  7137. check_time := c.GetString("check_time")
  7138. adminUser := c.GetAdminUserInfo()
  7139. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7140. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7141. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7142. sick, _ := service.FindSickById(sick_id)
  7143. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7144. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7145. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7146. var res ResultTwo
  7147. var res10265 ResultTwo10265
  7148. if miConfig.Code == "H15049901371" {
  7149. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7150. utils.ErrorLog("解析失败:%v", err)
  7151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7152. return
  7153. }
  7154. res.ErrMsg = res10265.ErrMsg
  7155. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7156. res.Infcode = infocode
  7157. res.Output = res10265.Output
  7158. res.InfRefmsgid = res10265.InfRefmsgid
  7159. } else {
  7160. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7161. utils.ErrorLog("解析失败:%v", err)
  7162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7163. return
  7164. }
  7165. }
  7166. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7167. infoStr := string(Iinfos)
  7168. var rf []*ResultFive
  7169. json.Unmarshal([]byte(infoStr), &rf)
  7170. var insuplc_admdvs string
  7171. var insutype string
  7172. var is390 int = 0
  7173. var is310 int = 0
  7174. var insutypes []*ResultFive
  7175. for _, item := range rf {
  7176. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7177. insutypes = append(insutypes, item)
  7178. }
  7179. }
  7180. if len(insutypes) == 1 {
  7181. insutype = insutypes[0].Insutype
  7182. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7183. } else {
  7184. for _, i := range insutypes {
  7185. if i.Insutype == "390" {
  7186. is390 = 1
  7187. }
  7188. if i.Insutype == "310" {
  7189. is310 = 1
  7190. }
  7191. }
  7192. }
  7193. if is390 == 1 {
  7194. insutype = "390"
  7195. }
  7196. if is310 == 1 {
  7197. insutype = "310"
  7198. }
  7199. if len(insutypes) == 2 {
  7200. insutype = insutype_two
  7201. }
  7202. if len(insutypes) == 0 {
  7203. insutype = "310"
  7204. }
  7205. insutype = insutype_two
  7206. fmt.Println(insutype)
  7207. for _, item := range rf {
  7208. fmt.Println(item.Insutype)
  7209. fmt.Println(insutype)
  7210. if item.Insutype == insutype {
  7211. fmt.Println(item.Insutype)
  7212. fmt.Println(insutype)
  7213. insuplc_admdvs = item.InsuplcAdmdvs
  7214. }
  7215. }
  7216. fmt.Println(insuplc_admdvs)
  7217. if config.IsOpen == 1 {
  7218. 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)
  7219. var dat map[string]interface{}
  7220. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7221. fmt.Println(dat)
  7222. } else {
  7223. fmt.Println(err)
  7224. }
  7225. userJSONBytes, _ := json.Marshal(dat)
  7226. var res2 ResultThirteen
  7227. var res10265 ResultThirteen10265
  7228. if miConfig.Code == "H15049901371" {
  7229. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7230. utils.ErrorLog("解析失败:%v", err)
  7231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7232. return
  7233. }
  7234. res2.ErrMsg = res10265.ErrMsg
  7235. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7236. res2.Infcode = infocode
  7237. res2.Output = res10265.Output
  7238. res2.InfRefmsgid = res10265.InfRefmsgid
  7239. } else {
  7240. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7241. utils.ErrorLog("解析失败:%v", err)
  7242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7243. return
  7244. }
  7245. }
  7246. if res2.Infcode == 0 {
  7247. psnResult := &models.GdybPsnNcdsRecord{
  7248. UserOrgId: adminUser.CurrentOrgId,
  7249. PatientId: patient.ID,
  7250. PsnNo: psn_no,
  7251. DoctorId: doctor.AdminUserId,
  7252. DepartmentId: department_id,
  7253. SickType: sick_id,
  7254. Insutype: insutype,
  7255. Ctime: time.Now().Unix(),
  7256. Mtime: time.Now().Unix(),
  7257. Status: 1,
  7258. IsCancel: 1,
  7259. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7260. }
  7261. service.CreatePsnNCDSRecord(psnResult)
  7262. c.ServeSuccessJSON(map[string]interface{}{
  7263. "failed_code": 0,
  7264. "msg": "备案成功",
  7265. "result": psnResult,
  7266. })
  7267. } else {
  7268. c.ServeSuccessJSON(map[string]interface{}{
  7269. "failed_code": -10,
  7270. "msg": res2.ErrMsg,
  7271. })
  7272. return
  7273. }
  7274. }
  7275. }
  7276. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  7277. id, _ := c.GetInt64("id")
  7278. admin_user_id, _ := c.GetInt64("admin_user_id")
  7279. adminUser := c.GetAdminUserInfo()
  7280. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7281. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7282. //config, _ := service.Ge(adminUser.CurrentOrgId)
  7283. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  7284. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7285. //var user_name string
  7286. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7287. //if role.ID == 0 {
  7288. // user_name = "xxx"
  7289. //} else {
  7290. // user_name = role.UserName
  7291. //}
  7292. psn_record, _ := service.GetPsnNCDSRecordById(id)
  7293. if psn_record.ID == 0 {
  7294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7295. return
  7296. }
  7297. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7298. var res ResultTwo
  7299. var res10265 ResultTwo10265
  7300. if miConfig.Code == "H15049901371" {
  7301. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7302. utils.ErrorLog("解析失败:%v", err)
  7303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7304. return
  7305. }
  7306. res.ErrMsg = res10265.ErrMsg
  7307. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7308. res.Infcode = infocode
  7309. res.Output = res10265.Output
  7310. res.InfRefmsgid = res10265.InfRefmsgid
  7311. } else {
  7312. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7313. utils.ErrorLog("解析失败:%v", err)
  7314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7315. return
  7316. }
  7317. }
  7318. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7319. infoStr := string(Iinfos)
  7320. var rf []*ResultFive
  7321. json.Unmarshal([]byte(infoStr), &rf)
  7322. var insuplc_admdvs string
  7323. var insutype string
  7324. var is390 int = 0
  7325. var is310 int = 0
  7326. var insutypes []*ResultFive
  7327. for _, item := range rf {
  7328. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7329. insutypes = append(insutypes, item)
  7330. }
  7331. }
  7332. if len(insutypes) == 1 {
  7333. insutype = insutypes[0].Insutype
  7334. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7335. } else {
  7336. for _, i := range insutypes {
  7337. if i.Insutype == "390" {
  7338. is390 = 1
  7339. }
  7340. if i.Insutype == "310" {
  7341. is310 = 1
  7342. }
  7343. }
  7344. }
  7345. if is390 == 1 {
  7346. insutype = "390"
  7347. }
  7348. if is310 == 1 {
  7349. insutype = "310"
  7350. }
  7351. if len(insutypes) == 0 {
  7352. insutype = "310"
  7353. }
  7354. insutype = psn_record.Insutype
  7355. for _, item := range rf {
  7356. if item.Insutype == insutype {
  7357. insuplc_admdvs = item.InsuplcAdmdvs
  7358. }
  7359. }
  7360. if config.IsOpen == 1 {
  7361. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  7362. var dat map[string]interface{}
  7363. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7364. fmt.Println(dat)
  7365. } else {
  7366. fmt.Println(err)
  7367. }
  7368. userJSONBytes, _ := json.Marshal(dat)
  7369. var res ResultFourteen
  7370. var res10265 ResultFourteen10265
  7371. if miConfig.Code == "H15049901371" {
  7372. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7373. utils.ErrorLog("解析失败:%v", err)
  7374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7375. return
  7376. }
  7377. res.ErrMsg = res10265.ErrMsg
  7378. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7379. res.Infcode = infocode
  7380. res.Output = res10265.Output
  7381. res.InfRefmsgid = res10265.InfRefmsgid
  7382. } else {
  7383. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7384. utils.ErrorLog("解析失败:%v", err)
  7385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7386. return
  7387. }
  7388. }
  7389. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7390. // utils.ErrorLog("解析失败:%v", err)
  7391. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7392. // return
  7393. //}
  7394. if res.Infcode == 0 {
  7395. psn_record.IsCancel = 2
  7396. service.CreatePsnNCDSRecord(&psn_record)
  7397. c.ServeSuccessJSON(map[string]interface{}{
  7398. "failed_code": 0,
  7399. "msg": "撤销备案成功",
  7400. })
  7401. } else {
  7402. c.ServeSuccessJSON(map[string]interface{}{
  7403. "failed_code": -10,
  7404. "msg": res.ErrMsg,
  7405. })
  7406. return
  7407. }
  7408. }
  7409. }
  7410. func (c *HisApiController) TestTest() {
  7411. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  7412. fmt.Println(patient.Iinfo)
  7413. }
  7414. type CustomData struct {
  7415. MsgId string
  7416. PsnNo string
  7417. Info string
  7418. }
  7419. func (c *HisApiController) ReversalData() {
  7420. var customData []*CustomData
  7421. custom := &CustomData{
  7422. MsgId: "H44022900158202103301714472004",
  7423. PsnNo: "44020000001101329945",
  7424. Info: "2207",
  7425. }
  7426. customData = append(customData, custom)
  7427. custom1 := &CustomData{
  7428. MsgId: "H4402290015820210330172057803",
  7429. PsnNo: "44020000001101161813",
  7430. Info: "2207",
  7431. }
  7432. customData = append(customData, custom1)
  7433. custom2 := &CustomData{
  7434. MsgId: "H44022900158202103301705198813",
  7435. PsnNo: "44190000133097375417",
  7436. Info: "2207",
  7437. }
  7438. customData = append(customData, custom2)
  7439. custom3 := &CustomData{
  7440. MsgId: "H44022900158202103301715524756",
  7441. PsnNo: "44020000001100187221",
  7442. Info: "2207",
  7443. }
  7444. customData = append(customData, custom3)
  7445. custom4 := &CustomData{
  7446. MsgId: "H44022900158202103301730376224",
  7447. PsnNo: "44020000001101959155",
  7448. Info: "2207",
  7449. }
  7450. customData = append(customData, custom4)
  7451. custom5 := &CustomData{
  7452. MsgId: "H44022900158202103301748008725",
  7453. PsnNo: "44020000001104246641",
  7454. Info: "2207",
  7455. }
  7456. customData = append(customData, custom5)
  7457. custom6 := &CustomData{
  7458. MsgId: "H44022900158202103301718096755",
  7459. PsnNo: "44020000001102211860",
  7460. Info: "2207",
  7461. }
  7462. customData = append(customData, custom6)
  7463. custom7 := &CustomData{
  7464. MsgId: "H44022900158202103301736551640",
  7465. PsnNo: "44020000001102687718",
  7466. Info: "2207",
  7467. }
  7468. customData = append(customData, custom7)
  7469. custom8 := &CustomData{
  7470. MsgId: "H44022900158202103301743097676",
  7471. PsnNo: "44020000001102127785",
  7472. Info: "2207",
  7473. }
  7474. customData = append(customData, custom8)
  7475. custom9 := &CustomData{
  7476. MsgId: "H44022900158202103301712304203",
  7477. PsnNo: "44020000001101518097",
  7478. Info: "2207",
  7479. }
  7480. customData = append(customData, custom9)
  7481. custom10 := &CustomData{
  7482. MsgId: "H44022900158202103301738448785",
  7483. PsnNo: "44020000001100500813",
  7484. Info: "2207",
  7485. }
  7486. customData = append(customData, custom10)
  7487. custom11 := &CustomData{
  7488. MsgId: "H44022900158202103301732455843",
  7489. PsnNo: "44020000001102690557",
  7490. Info: "2207",
  7491. }
  7492. customData = append(customData, custom11)
  7493. custom12 := &CustomData{
  7494. MsgId: "H44022900158202103301745421708",
  7495. PsnNo: "44020000001102211928",
  7496. Info: "2207",
  7497. }
  7498. customData = append(customData, custom12)
  7499. custom1212 := &CustomData{
  7500. MsgId: "H440229001582021033017351627",
  7501. PsnNo: "44020000001102481733",
  7502. Info: "2207",
  7503. }
  7504. customData = append(customData, custom1212)
  7505. custom13 := &CustomData{
  7506. MsgId: "H44022900158202103301740327951",
  7507. PsnNo: "44020000001103174866",
  7508. Info: "2207",
  7509. }
  7510. customData = append(customData, custom13)
  7511. custom14 := &CustomData{
  7512. MsgId: "H4402290015820210330174922668",
  7513. PsnNo: "44020000001102927272",
  7514. Info: "2207",
  7515. }
  7516. customData = append(customData, custom14)
  7517. custom15 := &CustomData{
  7518. MsgId: "H44022900158202103301752362273",
  7519. PsnNo: "44020000001102942890",
  7520. Info: "2207",
  7521. }
  7522. customData = append(customData, custom15)
  7523. custom16 := &CustomData{
  7524. MsgId: "H44022900158202103301751082917",
  7525. PsnNo: "44020000001101662162",
  7526. Info: "2207",
  7527. }
  7528. customData = append(customData, custom16)
  7529. custom17 := &CustomData{
  7530. MsgId: "H44022900158202103301754147728",
  7531. PsnNo: "44020000000229014511",
  7532. Info: "2207",
  7533. }
  7534. customData = append(customData, custom17)
  7535. adminUser := c.GetAdminUserInfo()
  7536. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7537. for _, item := range customData {
  7538. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7539. fmt.Println(result)
  7540. }
  7541. }
  7542. func (c *HisApiController) ReversalOtherData() {
  7543. var customData []*CustomData
  7544. custom := &CustomData{
  7545. MsgId: "H44022900158202103301714472004",
  7546. PsnNo: "44020000001101329945",
  7547. Info: "2208",
  7548. }
  7549. customData = append(customData, custom)
  7550. custom1 := &CustomData{
  7551. MsgId: "H4402290015820210330172057803",
  7552. PsnNo: "44020000001101161813",
  7553. Info: "2208",
  7554. }
  7555. customData = append(customData, custom1)
  7556. custom2 := &CustomData{
  7557. MsgId: "H44022900158202103301705198813",
  7558. PsnNo: "44190000133097375417",
  7559. Info: "2208",
  7560. }
  7561. customData = append(customData, custom2)
  7562. custom3 := &CustomData{
  7563. MsgId: "H44022900158202103301715524756",
  7564. PsnNo: "44020000001100187221",
  7565. Info: "2208",
  7566. }
  7567. customData = append(customData, custom3)
  7568. custom4 := &CustomData{
  7569. MsgId: "H44022900158202103301730376224",
  7570. PsnNo: "44020000001101959155",
  7571. Info: "2208",
  7572. }
  7573. customData = append(customData, custom4)
  7574. custom5 := &CustomData{
  7575. MsgId: "H44022900158202103301748008725",
  7576. PsnNo: "44020000001104246641",
  7577. Info: "2208",
  7578. }
  7579. customData = append(customData, custom5)
  7580. custom6 := &CustomData{
  7581. MsgId: "H44022900158202103301718096755",
  7582. PsnNo: "44020000001102211860",
  7583. Info: "2208",
  7584. }
  7585. customData = append(customData, custom6)
  7586. custom7 := &CustomData{
  7587. MsgId: "H44022900158202103301736551640",
  7588. PsnNo: "44020000001102687718",
  7589. Info: "2208",
  7590. }
  7591. customData = append(customData, custom7)
  7592. custom8 := &CustomData{
  7593. MsgId: "H44022900158202103301743097676",
  7594. PsnNo: "44020000001102127785",
  7595. Info: "2208",
  7596. }
  7597. customData = append(customData, custom8)
  7598. custom9 := &CustomData{
  7599. MsgId: "H44022900158202103301712304203",
  7600. PsnNo: "44020000001101518097",
  7601. Info: "2208",
  7602. }
  7603. customData = append(customData, custom9)
  7604. custom10 := &CustomData{
  7605. MsgId: "H44022900158202103301738448785",
  7606. PsnNo: "44020000001100500813",
  7607. Info: "2208",
  7608. }
  7609. customData = append(customData, custom10)
  7610. custom11 := &CustomData{
  7611. MsgId: "H44022900158202103301732455843",
  7612. PsnNo: "44020000001102690557",
  7613. Info: "2208",
  7614. }
  7615. customData = append(customData, custom11)
  7616. custom12 := &CustomData{
  7617. MsgId: "H44022900158202103301745421708",
  7618. PsnNo: "44020000001102211928",
  7619. Info: "2208",
  7620. }
  7621. customData = append(customData, custom12)
  7622. custom1212 := &CustomData{
  7623. MsgId: "H440229001582021033017351627",
  7624. PsnNo: "44020000001102481733",
  7625. Info: "2208",
  7626. }
  7627. customData = append(customData, custom1212)
  7628. custom13 := &CustomData{
  7629. MsgId: "H44022900158202103301740327951",
  7630. PsnNo: "44020000001103174866",
  7631. Info: "2208",
  7632. }
  7633. customData = append(customData, custom13)
  7634. custom14 := &CustomData{
  7635. MsgId: "H4402290015820210330174922668",
  7636. PsnNo: "44020000001102927272",
  7637. Info: "2208",
  7638. }
  7639. customData = append(customData, custom14)
  7640. custom15 := &CustomData{
  7641. MsgId: "H44022900158202103301752362273",
  7642. PsnNo: "44020000001102942890",
  7643. Info: "2208",
  7644. }
  7645. customData = append(customData, custom15)
  7646. custom16 := &CustomData{
  7647. MsgId: "H44022900158202103301751082917",
  7648. PsnNo: "44020000001101662162",
  7649. Info: "2208",
  7650. }
  7651. customData = append(customData, custom16)
  7652. custom17 := &CustomData{
  7653. MsgId: "H44022900158202103301754147728",
  7654. PsnNo: "44020000000229014511",
  7655. Info: "2208",
  7656. }
  7657. customData = append(customData, custom17)
  7658. adminUser := c.GetAdminUserInfo()
  7659. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7660. for _, item := range customData {
  7661. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7662. fmt.Println(result)
  7663. }
  7664. }
  7665. func PathExists(path string) (bool, error) {
  7666. _, err := os.Stat(path)
  7667. if err == nil {
  7668. return true, nil
  7669. }
  7670. if os.IsNotExist(err) {
  7671. return false, nil
  7672. }
  7673. return false, err
  7674. }
  7675. //创建文件夹
  7676. func Mkdir(dir string) {
  7677. // 创建文件夹
  7678. exist, err := PathExists(dir)
  7679. if err != nil {
  7680. fmt.Println(err.Error())
  7681. } else {
  7682. if exist {
  7683. fmt.Println(dir + "文件夹已存在!")
  7684. } else {
  7685. // 文件夹名称,权限
  7686. err := os.Mkdir(dir, os.ModePerm)
  7687. if err != nil {
  7688. fmt.Println(dir+"文件夹创建失败:", err.Error())
  7689. } else {
  7690. fmt.Println(dir + "文件夹创建成功!")
  7691. }
  7692. }
  7693. }
  7694. }
  7695. //压缩文件
  7696. func Zip(srcFile string, destZip string) error {
  7697. zipfile, err := os.Create(destZip)
  7698. if err != nil {
  7699. return err
  7700. }
  7701. defer zipfile.Close()
  7702. archive := zip.NewWriter(zipfile)
  7703. defer archive.Close()
  7704. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  7705. if err != nil {
  7706. return err
  7707. }
  7708. header, err := zip.FileInfoHeader(info)
  7709. if err != nil {
  7710. return err
  7711. }
  7712. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  7713. // header.Name = path
  7714. if info.IsDir() {
  7715. header.Name += "/"
  7716. } else {
  7717. header.Method = zip.Deflate
  7718. }
  7719. writer, err := archive.CreateHeader(header)
  7720. if err != nil {
  7721. return err
  7722. }
  7723. if !info.IsDir() {
  7724. file, err := os.Open(path)
  7725. if err != nil {
  7726. return err
  7727. }
  7728. defer file.Close()
  7729. _, err = io.Copy(writer, file)
  7730. }
  7731. return err
  7732. })
  7733. return err
  7734. }
  7735. func ReadFile(filePath string) []byte {
  7736. f, err := os.Open(filePath)
  7737. if err != nil {
  7738. fmt.Println("read file fail", err)
  7739. return nil
  7740. }
  7741. defer f.Close()
  7742. fd, err := ioutil.ReadAll(f)
  7743. if err != nil {
  7744. fmt.Println("read to fd fail", err)
  7745. return nil
  7746. }
  7747. return fd
  7748. }
  7749. func RemoveRepeatedTeam(arr []*models.HisOrderInfo) (newArr []*models.HisOrderInfo) {
  7750. newArr = make([]*models.HisOrderInfo, 0)
  7751. for i := 0; i < len(arr); i++ {
  7752. repeat := false
  7753. for j := i + 1; j < len(arr); j++ {
  7754. if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
  7755. repeat = true
  7756. break
  7757. }
  7758. }
  7759. if !repeat {
  7760. newArr = append(newArr, arr[i])
  7761. }
  7762. }
  7763. return
  7764. }
  7765. func saveRegisterLog(result string) {
  7766. org_id, _ := beego.AppConfig.Int64("org_id")
  7767. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  7768. dir := miConfig.OrgName + "日志"
  7769. utils.Mkdir(dir)
  7770. month := time.Unix(1557042972, 0).Format("1")
  7771. year := time.Now().Format("2006")
  7772. month = time.Now().Format("01")
  7773. day := time.Now().Format("02")
  7774. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  7775. file_name := file + ".txt"
  7776. file_path := miConfig.OrgName + "日志" + "/" + file_name
  7777. exist, _ := utils.PathExists(file_path)
  7778. if exist { //存在
  7779. fmt.Println("存在")
  7780. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  7781. if err != nil {
  7782. fmt.Println("read fail")
  7783. }
  7784. content := "\r\n" + result
  7785. n, _ := f.Seek(0, 2)
  7786. _, err = f.WriteAt([]byte(content), n)
  7787. } else { //不存在
  7788. fmt.Println("文件不存在,创建文件")
  7789. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  7790. defer f.Close()
  7791. if err != nil {
  7792. } else {
  7793. _, err = f.Write([]byte("记录日志"))
  7794. }
  7795. }
  7796. }
  7797. func saveLog(result string, request string, infno string, desc string) {
  7798. org_id, _ := beego.AppConfig.Int64("org_id")
  7799. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  7800. dir := miConfig.OrgName + "日志"
  7801. utils.Mkdir(dir)
  7802. month := time.Unix(1557042972, 0).Format("1")
  7803. year := time.Now().Format("2006")
  7804. month = time.Now().Format("01")
  7805. day := time.Now().Format("02")
  7806. hour := time.Now().Format("15")
  7807. min := time.Now().Format("04")
  7808. sec := time.Now().Format("05")
  7809. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  7810. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  7811. file_name := file + ".txt"
  7812. file_path := miConfig.OrgName + "日志" + "/" + file_name
  7813. exist, _ := utils.PathExists(file_path)
  7814. if exist { //存在
  7815. fmt.Println("存在")
  7816. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  7817. if err != nil {
  7818. fmt.Println("read fail")
  7819. }
  7820. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  7821. n, _ := f.Seek(0, 2)
  7822. _, err = f.WriteAt([]byte(content), n)
  7823. } else { //不存在
  7824. fmt.Println("文件不存在,创建文件")
  7825. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  7826. defer f.Close()
  7827. if err != nil {
  7828. } else {
  7829. _, err = f.Write([]byte("记录日志"))
  7830. }
  7831. }
  7832. }
  7833. type Charset string
  7834. const (
  7835. UTF8 = Charset("UTF-8")
  7836. GB18030 = Charset("GB18030")
  7837. )
  7838. func ConvertToString(src string, srcCode string, tagCode string) string {
  7839. srcCoder := mahonia.NewDecoder(srcCode)
  7840. srcResult := srcCoder.ConvertString(src)
  7841. tagCoder := mahonia.NewDecoder(tagCode)
  7842. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  7843. result := string(cdata)
  7844. return result
  7845. }
  7846. //func (c *HisApiController)HandleCheckDetailAccount(){
  7847. // psn_no, _ := c.GetString("psn_no")
  7848. // psn_no, _ := c.GetString("psn_no")
  7849. // psn_no, _ := c.GetString("psn_no")
  7850. //
  7851. //
  7852. //
  7853. //}