his_api_controller.go 302KB

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