his_api_controller.go 381KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. }
  73. func (c *HisApiController) GetPsnNcdsInfo() {
  74. admin_user_id, _ := c.GetInt64("admin_user_id")
  75. patient_id, _ := c.GetInt64("patient_id")
  76. id, _ := c.GetInt64("id")
  77. adminUser := c.GetAdminUserInfo()
  78. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  79. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  80. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  81. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  82. psn_record, _ := service.GetPsnNCDSRecordById(id)
  83. //
  84. //if psn_record.ID == 0 {
  85. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  86. // return
  87. //}
  88. var res Result5301
  89. var res10265 Result5301For10265
  90. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  91. psn_info, _ := service.GetPsnByPatientId(patient_id)
  92. var api string
  93. if miConfig.MdtrtareaAdmvs == "320921" {
  94. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  95. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  96. } else {
  97. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  98. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  99. }
  100. resp, requestErr := http.Get(api)
  101. if requestErr != nil {
  102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  103. return
  104. }
  105. body, ioErr := ioutil.ReadAll(resp.Body)
  106. if ioErr != nil {
  107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  109. return
  110. }
  111. var respJSON map[string]interface{}
  112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  115. return
  116. }
  117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  118. result, _ := json.Marshal(respJSON)
  119. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  120. utils.ErrorLog("解析失败:%v", err)
  121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  122. return
  123. }
  124. res.ErrMsg = res10265.ErrMsg
  125. res.Output = res10265.Output
  126. res.InfRefmsgid = res10265.InfRefmsgid
  127. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  128. res.Infcode = infocode
  129. } else {
  130. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  131. var dat map[string]interface{}
  132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  133. fmt.Println(dat)
  134. } else {
  135. fmt.Println(err)
  136. }
  137. userJSONBytes, _ := json.Marshal(dat)
  138. if miConfig.Code == "H15049901371" {
  139. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  140. utils.ErrorLog("解析失败:%v", err)
  141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  142. return
  143. }
  144. res.InfRefmsgid = res10265.InfRefmsgid
  145. res.Output = res10265.Output
  146. res.ErrMsg = res10265.ErrMsg
  147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  148. res.Infcode = infocode
  149. } else {
  150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  151. utils.ErrorLog("解析失败:%v", err)
  152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  153. return
  154. }
  155. }
  156. }
  157. if res.Infcode == 0 {
  158. c.ServeSuccessJSON(map[string]interface{}{
  159. "result": res.Output.Result,
  160. })
  161. }
  162. }
  163. func (c *HisApiController) CheckInsutype() {
  164. his_patient_id, _ := c.GetInt64("his_patient_id")
  165. admin_user_id, _ := c.GetInt64("admin_user_id")
  166. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  167. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  168. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  169. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  170. var dat map[string]interface{}
  171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  172. fmt.Println(dat)
  173. } else {
  174. fmt.Println(err)
  175. }
  176. userJSONBytes, _ := json.Marshal(dat)
  177. var res Result90100
  178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  179. utils.ErrorLog("解析失败:%v", err)
  180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  181. return
  182. }
  183. if res.Infcode != 0 {
  184. c.ServeSuccessJSON(map[string]interface{}{
  185. "failed_code": -10,
  186. "msg": res.ErrMsg,
  187. })
  188. return
  189. } else {
  190. fmt.Println(res)
  191. }
  192. }
  193. func (c *HisApiController) CheckCardPWD() {
  194. card_pwd := c.GetString("card_pwd")
  195. his_patient_id, _ := c.GetInt64("his_patient_id")
  196. admin_user_id, _ := c.GetInt64("admin_user_id")
  197. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  198. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  199. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  200. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  201. var dat map[string]interface{}
  202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  203. fmt.Println(dat)
  204. } else {
  205. fmt.Println(err)
  206. }
  207. userJSONBytes, _ := json.Marshal(dat)
  208. var res Result90991
  209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  210. utils.ErrorLog("解析失败:%v", err)
  211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  212. return
  213. }
  214. if res.Infcode != 0 {
  215. c.ServeSuccessJSON(map[string]interface{}{
  216. "failed_code": -10,
  217. "msg": res.ErrMsg,
  218. })
  219. return
  220. } else {
  221. if res.Output.Result.CheckStat == "0" {
  222. var msg string
  223. switch res.Output.Result.CardStat {
  224. case "00":
  225. msg = "未激活"
  226. break
  227. case "10":
  228. msg = "激活"
  229. break
  230. case "20":
  231. msg = "窗口挂失"
  232. break
  233. case "21":
  234. msg = "电话挂失"
  235. break
  236. case "22":
  237. msg = "单位网上申报挂失"
  238. break
  239. case "23":
  240. msg = "保健办挂失"
  241. break
  242. case "24":
  243. msg = "个人网上挂失"
  244. break
  245. case "25":
  246. msg = "网上服务大厅挂失"
  247. break
  248. case "30":
  249. msg = "注销"
  250. break
  251. case "40":
  252. msg = "回收"
  253. break
  254. case "99":
  255. msg = "制卡中(无效卡)"
  256. break
  257. }
  258. c.ServeSuccessJSON(map[string]interface{}{
  259. "failed_code": -10,
  260. "msg": msg,
  261. })
  262. return
  263. } else {
  264. c.ServeSuccessJSON(map[string]interface{}{
  265. "msg": "校验成功",
  266. })
  267. return
  268. }
  269. }
  270. }
  271. func (c *HisApiController) ReadCard() {
  272. id_card_type, _ := c.GetInt64("id_card_type")
  273. admin_user_id, _ := c.GetInt64("admin_user_id")
  274. certificates, _ := c.GetInt64("certificates")
  275. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  276. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  278. switch id_card_type {
  279. case 1:
  280. if miConfig.MdtrtareaAdmvs == "421300" {
  281. var res ResultTwo
  282. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  283. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  284. "&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)
  285. resp, requestErr := http.Get(api)
  286. if requestErr != nil {
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. body, ioErr := ioutil.ReadAll(resp.Body)
  291. if ioErr != nil {
  292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  294. return
  295. }
  296. var respJSON map[string]interface{}
  297. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  300. return
  301. }
  302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  303. result, _ := json.Marshal(respJSON)
  304. fmt.Println("log")
  305. fmt.Println(string(result))
  306. if err := json.Unmarshal([]byte(result), &res); err != nil {
  307. utils.ErrorLog("解析失败:%v", err)
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. if res.Infcode == 0 {
  312. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  313. if err == gorm.ErrRecordNotFound {
  314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  315. return
  316. } else if err != nil {
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  318. return
  319. } else {
  320. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  321. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  322. infoStr := string(Iinfos)
  323. idetinfoStr := string(Idetinfos)
  324. psn := &models.HisPsn{
  325. PsnNo: res.Output.Baseinfo.PsnNo,
  326. Age: res.Output.Baseinfo.Age,
  327. PatientId: patient.ID,
  328. Certno: res.Output.Baseinfo.Certno,
  329. Brdy: res.Output.Baseinfo.Brdy,
  330. Gend: res.Output.Baseinfo.Gend,
  331. Naty: res.Output.Baseinfo.Naty,
  332. PsnCertType: res.Output.Baseinfo.PsnCertType,
  333. PsnName: res.Output.Baseinfo.PsnName,
  334. Idetinfo: idetinfoStr,
  335. Insuinfo: infoStr,
  336. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  337. }
  338. service.CreateHisPsn(psn)
  339. c.ServeSuccessJSON(map[string]interface{}{
  340. "patient": patient,
  341. "number": res.Output.Baseinfo.Certno,
  342. })
  343. }
  344. } else {
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  346. return
  347. }
  348. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  349. var api string
  350. if miConfig.MdtrtareaAdmvs == "320921" {
  351. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  352. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  353. } else {
  354. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  355. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  356. }
  357. resp, requestErr := http.Get(api)
  358. if requestErr != nil {
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. body, ioErr := ioutil.ReadAll(resp.Body)
  363. if ioErr != nil {
  364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  366. return
  367. }
  368. var respJSON map[string]interface{}
  369. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  372. return
  373. }
  374. var status string
  375. status = respJSON["data"].(map[string]interface{})["status"].(string)
  376. if status == "0" { //读卡成功
  377. var card_info string //卡信息
  378. var busi_card_info string
  379. var res ResultTwo //1101结果
  380. var res10265 ResultTwo10265 //1101结果
  381. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  382. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  383. fmt.Println(card_info)
  384. fmt.Println(busi_card_info)
  385. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  386. result, _ := json.Marshal(respJSON)
  387. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  388. utils.ErrorLog("解析失败:%v", err)
  389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  390. return
  391. }
  392. res.ErrMsg = res10265.ErrMsg
  393. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  394. res.Infcode = infocode
  395. res.Output = res10265.Output
  396. res.InfRefmsgid = res10265.InfRefmsgid
  397. if res.Infcode == 0 {
  398. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  399. if err == gorm.ErrRecordNotFound {
  400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  401. return
  402. } else if err != nil {
  403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  404. return
  405. } else {
  406. bas := strings.Split(card_info, "|")
  407. basNumber := bas[2]
  408. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  409. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  410. infoStr := string(Iinfos)
  411. idetinfoStr := string(Idetinfos)
  412. psn := &models.HisPsn{
  413. PsnNo: res.Output.Baseinfo.PsnNo,
  414. Age: res.Output.Baseinfo.Age,
  415. PatientId: patient.ID,
  416. Certno: res.Output.Baseinfo.Certno,
  417. Brdy: res.Output.Baseinfo.Brdy,
  418. Gend: res.Output.Baseinfo.Gend,
  419. Naty: res.Output.Baseinfo.Naty,
  420. PsnCertType: res.Output.Baseinfo.PsnCertType,
  421. PsnName: res.Output.Baseinfo.PsnName,
  422. Idetinfo: idetinfoStr,
  423. Insuinfo: infoStr,
  424. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  425. CardInfo: card_info,
  426. VerifyNumber: busi_card_info,
  427. }
  428. service.CreateHisPsn(psn)
  429. c.ServeSuccessJSON(map[string]interface{}{
  430. "patient": patient,
  431. "number": basNumber,
  432. })
  433. }
  434. } else {
  435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  436. return
  437. }
  438. } else { //读卡失败
  439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  440. return
  441. }
  442. } else {
  443. if initFlag == 0 {
  444. c.TestGetBasBaseInit()
  445. }
  446. basStr := c.GetBasBaseInfo()
  447. if len(basStr) == 0 {
  448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  449. return
  450. }
  451. fmt.Println(basStr)
  452. bas := strings.Split(basStr, "|")
  453. basNumber := bas[1]
  454. fmt.Println(basNumber)
  455. card_sn := bas[3]
  456. fmt.Println(card_sn)
  457. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  458. var dat map[string]interface{}
  459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  460. fmt.Println(dat)
  461. } else {
  462. fmt.Println(err)
  463. }
  464. userJSONBytes, _ := json.Marshal(dat)
  465. var res ResultTwo
  466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  467. utils.ErrorLog("解析失败:%v", err)
  468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  469. return
  470. }
  471. if res.Infcode == 0 {
  472. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  473. if err == gorm.ErrRecordNotFound {
  474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  475. return
  476. } else if err != nil {
  477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  478. return
  479. } else {
  480. c.ServeSuccessJSON(map[string]interface{}{
  481. "patient": patient,
  482. "number": basNumber,
  483. })
  484. }
  485. } else {
  486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  487. return
  488. }
  489. break
  490. }
  491. case 2:
  492. SFZStr := c.GetSFZBaseInfo()
  493. id_card_str := strings.Split(SFZStr, "^")
  494. id_card_number := id_card_str[0]
  495. card_sn := ""
  496. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  497. var dat map[string]interface{}
  498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  499. fmt.Println(dat)
  500. } else {
  501. fmt.Println(err)
  502. }
  503. userJSONBytes, _ := json.Marshal(dat)
  504. var res ResultTwo
  505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  506. utils.ErrorLog("解析失败:%v", err)
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  508. return
  509. }
  510. if res.Infcode == 0 {
  511. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  512. if err == gorm.ErrRecordNotFound {
  513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  514. return
  515. } else if err != nil {
  516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  517. return
  518. } else {
  519. c.ServeSuccessJSON(map[string]interface{}{
  520. "patient": patient,
  521. "number": id_card_number,
  522. })
  523. }
  524. } else {
  525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  526. return
  527. }
  528. break
  529. case 3:
  530. break
  531. }
  532. }
  533. var initFlag int64 = 0
  534. func (c *HisApiController) TestGetBasBaseInit() {
  535. DllDef := syscall.MustLoadDLL("SSCard.dll")
  536. Iinit := DllDef.MustFindProc("Init")
  537. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  538. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  539. if ret != 0 {
  540. fmt.Println("SSCard的报错原因:", err)
  541. fmt.Println("SSCard的运算结果为:", ret)
  542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  543. return
  544. }
  545. result := int(ret)
  546. fmt.Println("SSCard的运算结果为1:", result)
  547. initFlag = 1
  548. return
  549. }
  550. func (c *HisApiController) GetSFZBaseInfo() string {
  551. DllDef := syscall.MustLoadDLL("SSCard.dll")
  552. readCard := DllDef.MustFindProc("ReadSFZ")
  553. if readCard == nil {
  554. fmt.Println("readcard is nil")
  555. readCard = DllDef.MustFindProc("ReadSFZ")
  556. }
  557. str := make([]byte, 256)
  558. str1 := make([]byte, 256)
  559. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  560. fmt.Println(r)
  561. return string(str)
  562. }
  563. func (c *HisApiController) GetBasBaseInfo() string {
  564. DllDef := syscall.MustLoadDLL("SSCard.dll")
  565. readCard := DllDef.MustFindProc("ReadCardBas")
  566. if readCard == nil {
  567. fmt.Println("readcard is nil")
  568. readCard = DllDef.MustFindProc("ReadCardBas")
  569. }
  570. str := make([]byte, 1024)
  571. str1 := make([]byte, 1024)
  572. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  573. fmt.Println(string(str1))
  574. fmt.Println(string(str))
  575. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  576. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  577. if ret2 != 0 {
  578. return ""
  579. }
  580. return string(str)
  581. }
  582. type CustomFundPay struct {
  583. FundPayType string `json:"fund_pay_type"`
  584. FundPayamt float64 `json:"fund_payamt"`
  585. }
  586. func (c *HisApiController) GetSettleList() {
  587. order_id, _ := c.GetInt64("order_id")
  588. admin_user_id, _ := c.GetInt64("admin_user_id")
  589. order, _ := service.GetHisOrderByIDTwo(order_id)
  590. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  591. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  592. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  593. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  594. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  595. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  596. if order.ID == 0 {
  597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  598. return
  599. }
  600. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  601. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  602. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  603. fmt.Println(count)
  604. var zero string
  605. number := count + 1
  606. if number >= 1000 {
  607. zero = "0000" + strconv.FormatInt(number, 10)
  608. } else if number >= 10000 {
  609. zero = "000" + strconv.FormatInt(number, 10)
  610. } else if number >= 100000 {
  611. zero = "00" + strconv.FormatInt(number, 10)
  612. } else if number >= 1000000 {
  613. zero = "0" + strconv.FormatInt(number, 10)
  614. } else {
  615. zero = strconv.FormatInt(number, 10)
  616. }
  617. fmt.Println(zero)
  618. struct4101 := service.Struct4101{
  619. PsnNo: order.PsnNo,
  620. MdtrtId: order.MdtrtId,
  621. SetlId: order.SetlId,
  622. PsnName: order.PsnName,
  623. Gend: order.Gend,
  624. Brdy: his.Brdy,
  625. Age: his.Age,
  626. Naty: order.Naty,
  627. PatnCertType: "01",
  628. Certno: order.Certno,
  629. Prfs: "90",
  630. ConerName: roles[0].UserName,
  631. PatnRlts: "99",
  632. ConerAddr: miConfig.OrgName,
  633. ConerTel: admin.Mobile,
  634. HiType: order.Insutype,
  635. Insuplc: miConfig.InsuplcAdmdvs,
  636. MaindiagFlag: "1",
  637. BillCode: last_order.FaPiaoCode,
  638. BillNo: zero,
  639. BizSn: order.Number,
  640. PsnSelfPay: order.PsnPartAmt,
  641. PsnOwnPay: order.PsnPartAmt,
  642. AcctPay: order.AcctPay,
  643. PsnCashpay: order.PsnCashPay,
  644. HiPaymtd: "1",
  645. Hsorg: miConfig.InsuplcAdmdvs,
  646. HsorgOpter: miConfig.InsuplcAdmdvs,
  647. MedinsFillPsn: curRoles.UserName,
  648. MedinsFillDept: depart.Name,
  649. IptMedType: "2",
  650. }
  651. struct4101.SetlBegnDate = order.SetlTime
  652. struct4101.SetlEndDate = order.SetlTime
  653. time_arr := strings.Split(order.SetlTime, " ")
  654. struct4101.AdmTime = time_arr[0]
  655. struct4101.AdmEndTime = time_arr[0]
  656. var rf []CustomFundPay
  657. json.Unmarshal([]byte(order.SetlDetail), &rf)
  658. var tempFunPays []service.CustomStruct
  659. for _, item := range rf {
  660. var tempFunPay service.CustomStruct
  661. tempFunPay.FundPayamt = item.FundPayamt
  662. tempFunPay.FundPayType = item.FundPayType
  663. tempFunPays = append(tempFunPays, tempFunPay)
  664. }
  665. struct4101.CustomStruct = tempFunPays
  666. var tempDiaginfos []service.DiaginfoStructTwo
  667. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  668. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  669. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  670. var config []*models.HisXtDiagnoseConfig
  671. for _, item := range diagnosis_ids {
  672. id, _ := strconv.ParseInt(item, 10, 64)
  673. diagnosisConfig, _ := service.FindDiagnoseById(id)
  674. config = append(config, &diagnosisConfig)
  675. }
  676. for index, item := range config {
  677. if index == 0 {
  678. var tempDiaginfo service.DiaginfoStructTwo
  679. tempDiaginfo.DiagCode = item.CountryCode
  680. tempDiaginfo.DiagName = item.CountryContentName
  681. tempDiaginfo.DiagType = "1"
  682. tempDiaginfo.MaindiagFlag = "1"
  683. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  684. } else {
  685. var tempDiaginfo service.DiaginfoStructTwo
  686. tempDiaginfo.DiagCode = item.CountryCode
  687. tempDiaginfo.DiagName = item.CountryContentName
  688. tempDiaginfo.DiagType = "2"
  689. tempDiaginfo.MaindiagFlag = "0"
  690. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  691. }
  692. }
  693. sickConfigTwo, _ := service.FindSickById(his.SickType)
  694. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  695. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  696. tempOpspdiseinfo2.OprnOprtCode = ""
  697. tempOpspdiseinfo2.OprnOprtName = ""
  698. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  699. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  700. var iteminfo service.IteminfoStruct
  701. var bedCostTotal float64 = 0 //床位总费
  702. var bedCostSelfTotal float64 = 0 //床位自费
  703. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  704. var operationCostTotal float64 = 0 //手术费
  705. var operationCostSelfTotal float64 = 0 //手术费
  706. var operationCostPartSelfTotal float64 = 0 //手术费
  707. var otherCostTotal float64 = 0 //其他费用
  708. var otherCostSelfTotal float64 = 0 //其他费用
  709. var otherCostPartSelfTotal float64 = 0 //其他费用
  710. var materialCostTotal float64 = 0 //材料费
  711. var materialCostSelfTotal float64 = 0 //材料费
  712. var materialCostPartSelfTotal float64 = 0 //材料费
  713. var westernMedicineCostTotal float64 = 0 //西药费
  714. var westernMedicineCostSelfTotal float64 = 0 //西药费
  715. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  716. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  717. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  718. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  719. var checkCostTotal float64 = 0 //检查费
  720. var checkCostSelfTotal float64 = 0 //检查费
  721. var checkCostPartSelfTotal float64 = 0 //检查费
  722. var laboratoryCostTotal float64 = 0 //化验费
  723. var laboratoryCostSelfTotal float64 = 0 //化验费
  724. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  725. var treatCostTotal float64 = 0 //治疗费用
  726. var treatCostSelfTotal float64 = 0 //治疗费用
  727. var treatCostPartSelfTotal float64 = 0 //治疗费用
  728. decimal.DivisionPrecision = 2
  729. var bed_fulamt_ownpay_amt float64 = 0
  730. var operation_fulamt_ownpay_amt float64 = 0
  731. var other_fulamt_ownpay_amt float64 = 0
  732. var westernMedicine_fulamt_ownpay_amt float64 = 0
  733. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  734. var check_fulamt_ownpay_amt float64 = 0
  735. var material_fulamt_ownpay_amt float64 = 0
  736. var laboratory_fulamt_ownpay_amt float64 = 0
  737. var treat_fulamt_ownpay_amt float64 = 0
  738. var bed_claa_sunmfee float64 = 0
  739. var bed_clab_amt float64 = 0
  740. var bed_other_amt float64 = 0
  741. var operation_claa_sunmfee float64 = 0
  742. var operation_clab_amt float64 = 0
  743. var operation_other_amt float64 = 0
  744. var other_claa_sunmfee float64 = 0
  745. var other_clab_amt float64 = 0
  746. var other_other_amt float64 = 0
  747. var westernMedicine_claa_sunmfee float64 = 0
  748. var westernMedicine_clab_amt float64 = 0
  749. var westernMedicine_other_amt float64 = 0
  750. var chineseTraditional_claa_sunmfee float64 = 0
  751. var chineseTraditional_clab_amt float64 = 0
  752. var chineseTraditional_other_amt float64 = 0
  753. var check_claa_sunmfee float64 = 0
  754. var check_clab_amt float64 = 0
  755. var check_other_amt float64 = 0
  756. var material_claa_sunmfee float64 = 0
  757. var material_clab_amt float64 = 0
  758. var material_other_amt float64 = 0
  759. var laboratory_claa_sunmfee float64 = 0
  760. var laboratory_clab_amt float64 = 0
  761. var laboratory_other_amt float64 = 0
  762. var treat_claa_sunmfee float64 = 0
  763. var treat_clab_amt float64 = 0
  764. var treat_other_amt float64 = 0
  765. for _, item := range order.HisOrderInfo {
  766. if item.MedChrgitmType == "01" { //床位费
  767. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  768. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  769. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  770. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  771. if item.ChrgitmLv == "1" {
  772. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  773. }
  774. if item.ChrgitmLv == "2" {
  775. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  776. }
  777. if item.ChrgitmLv == "3" {
  778. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  779. }
  780. }
  781. if item.MedChrgitmType == "03" { //检查费
  782. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  783. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  784. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  785. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  786. if item.ChrgitmLv == "1" {
  787. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  788. }
  789. if item.ChrgitmLv == "2" {
  790. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  791. }
  792. if item.ChrgitmLv == "3" {
  793. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  794. }
  795. }
  796. if item.MedChrgitmType == "04" { //化验费
  797. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  798. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  799. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  800. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  801. if item.ChrgitmLv == "1" {
  802. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  803. }
  804. if item.ChrgitmLv == "2" {
  805. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  806. }
  807. if item.ChrgitmLv == "3" {
  808. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  809. }
  810. }
  811. if item.MedChrgitmType == "05" { //治疗费
  812. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  813. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  814. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  815. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  816. if item.ChrgitmLv == "1" {
  817. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  818. }
  819. if item.ChrgitmLv == "2" {
  820. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  821. }
  822. if item.ChrgitmLv == "3" {
  823. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  824. }
  825. }
  826. if item.MedChrgitmType == "06" { //手术费
  827. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  828. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  829. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  830. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  831. if item.ChrgitmLv == "1" {
  832. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  833. }
  834. if item.ChrgitmLv == "2" {
  835. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  836. }
  837. if item.ChrgitmLv == "3" {
  838. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  839. }
  840. }
  841. if item.MedChrgitmType == "08" { //材料费
  842. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  843. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  844. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  845. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  846. if item.ChrgitmLv == "1" {
  847. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  848. }
  849. if item.ChrgitmLv == "2" {
  850. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  851. }
  852. if item.ChrgitmLv == "3" {
  853. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  854. }
  855. }
  856. if item.MedChrgitmType == "09" { //西药费
  857. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  858. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  859. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  860. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  861. if item.ChrgitmLv == "1" {
  862. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  863. }
  864. if item.ChrgitmLv == "2" {
  865. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  866. }
  867. if item.ChrgitmLv == "3" {
  868. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  869. }
  870. }
  871. if item.MedChrgitmType == "11" { //中成费
  872. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  873. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  874. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  875. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  876. if item.ChrgitmLv == "1" {
  877. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  878. }
  879. if item.ChrgitmLv == "2" {
  880. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  881. }
  882. if item.ChrgitmLv == "3" {
  883. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  884. }
  885. }
  886. if item.MedChrgitmType == "14" { //其他费
  887. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  888. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  889. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  890. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  891. if item.ChrgitmLv == "1" {
  892. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  893. }
  894. if item.ChrgitmLv == "2" {
  895. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  896. }
  897. if item.ChrgitmLv == "3" {
  898. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  899. }
  900. }
  901. }
  902. var iteminfoStructs []service.IteminfoStruct
  903. if bedCostTotal != 0 {
  904. iteminfo.MedChrgitm = "01"
  905. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  906. iteminfo.Amt = bedCostTotal
  907. iteminfo.ClaaSumfee = bed_claa_sunmfee
  908. iteminfo.ClabAmt = bed_clab_amt
  909. iteminfo.OthAmt = bed_other_amt
  910. iteminfoStructs = append(iteminfoStructs, iteminfo)
  911. }
  912. if checkCostTotal != 0 {
  913. iteminfo.MedChrgitm = "03"
  914. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  915. iteminfo.Amt = checkCostTotal
  916. iteminfo.ClaaSumfee = check_claa_sunmfee
  917. iteminfo.ClabAmt = check_clab_amt
  918. iteminfo.OthAmt = check_other_amt
  919. iteminfoStructs = append(iteminfoStructs, iteminfo)
  920. }
  921. if laboratoryCostTotal != 0 {
  922. iteminfo.MedChrgitm = "04"
  923. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  924. iteminfo.Amt = laboratoryCostTotal
  925. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  926. iteminfo.ClabAmt = laboratory_clab_amt
  927. iteminfo.OthAmt = laboratory_other_amt
  928. iteminfoStructs = append(iteminfoStructs, iteminfo)
  929. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  930. }
  931. if treatCostTotal != 0 {
  932. iteminfo.MedChrgitm = "05"
  933. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  934. iteminfo.Amt = treatCostTotal
  935. iteminfo.ClaaSumfee = treat_claa_sunmfee
  936. iteminfo.ClabAmt = treat_clab_amt
  937. iteminfo.OthAmt = treat_other_amt
  938. iteminfoStructs = append(iteminfoStructs, iteminfo)
  939. //(struct4101.IteminfoStruct, iteminfo)
  940. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  941. }
  942. if operationCostTotal != 0 {
  943. iteminfo.MedChrgitm = "06"
  944. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  945. iteminfo.Amt = operationCostTotal
  946. iteminfo.ClaaSumfee = operation_claa_sunmfee
  947. iteminfo.ClabAmt = operation_clab_amt
  948. iteminfo.OthAmt = operation_other_amt
  949. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  950. iteminfoStructs = append(iteminfoStructs, iteminfo)
  951. }
  952. if materialCostTotal != 0 {
  953. iteminfo.MedChrgitm = "08"
  954. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  955. iteminfo.Amt = materialCostTotal
  956. iteminfo.ClaaSumfee = material_claa_sunmfee
  957. iteminfo.ClabAmt = material_clab_amt
  958. iteminfo.OthAmt = material_other_amt
  959. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  960. iteminfoStructs = append(iteminfoStructs, iteminfo)
  961. }
  962. if westernMedicineCostTotal != 0 {
  963. iteminfo.MedChrgitm = "09"
  964. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  965. iteminfo.Amt = westernMedicineCostTotal
  966. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  967. iteminfo.ClabAmt = westernMedicine_clab_amt
  968. iteminfo.OthAmt = westernMedicine_other_amt
  969. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  970. iteminfoStructs = append(iteminfoStructs, iteminfo)
  971. }
  972. if chineseTraditionalMedicineCostTotal != 0 {
  973. iteminfo.MedChrgitm = "11"
  974. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  975. iteminfo.Amt = westernMedicineCostTotal
  976. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  977. iteminfo.ClabAmt = westernMedicine_clab_amt
  978. iteminfo.OthAmt = westernMedicine_other_amt
  979. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  980. iteminfoStructs = append(iteminfoStructs, iteminfo)
  981. }
  982. if otherCostTotal != 0 {
  983. iteminfo.MedChrgitm = "14"
  984. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  985. iteminfo.Amt = otherCostTotal
  986. iteminfo.ClaaSumfee = other_claa_sunmfee
  987. iteminfo.ClabAmt = other_clab_amt
  988. iteminfo.OthAmt = other_other_amt
  989. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  990. iteminfoStructs = append(iteminfoStructs, iteminfo)
  991. }
  992. struct4101.IteminfoStruct = iteminfoStructs
  993. struct4101.Ntly = "中国"
  994. struct4101.AdmCaty = "A03.06"
  995. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  996. fmt.Println(result)
  997. var dat map[string]interface{}
  998. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  999. fmt.Println(dat)
  1000. } else {
  1001. fmt.Println(err)
  1002. }
  1003. userJSONBytes, _ := json.Marshal(dat)
  1004. var res ResultSeventeen
  1005. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1006. utils.ErrorLog("解析失败:%v", err)
  1007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1008. return
  1009. }
  1010. if res.Infcode != 0 {
  1011. c.ServeSuccessJSON(map[string]interface{}{
  1012. "failed_code": -10,
  1013. "msg": res.ErrMsg,
  1014. })
  1015. return
  1016. } else {
  1017. order.FaPiaoNumber = zero
  1018. order.FaPiaoCode = last_order.FaPiaoCode
  1019. service.UpdateOrder(order)
  1020. hisFundSettleListResult := &models.HisFundSettleListResult{
  1021. Number: res.Output.SetlListId,
  1022. Status: 1,
  1023. Ctime: time.Now().Unix(),
  1024. Mtime: time.Now().Unix(),
  1025. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1026. IsUpload: 1,
  1027. OrderId: order_id,
  1028. }
  1029. service.CreateUploadRecord(hisFundSettleListResult)
  1030. c.ServeSuccessJSON(map[string]interface{}{
  1031. "msg": "上传成功",
  1032. "result": hisFundSettleListResult,
  1033. })
  1034. return
  1035. }
  1036. }
  1037. func (c *HisApiController) GetSettleListHospital() {
  1038. order_id, _ := c.GetInt64("order_id")
  1039. admin_user_id, _ := c.GetInt64("admin_user_id")
  1040. order, _ := service.GetHisOrderByIDTwo(order_id)
  1041. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1042. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1043. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1044. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1045. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1046. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1047. if order.ID == 0 {
  1048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1049. return
  1050. }
  1051. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1052. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1053. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1054. fmt.Println(count)
  1055. var zero string
  1056. number := count + 1
  1057. if number >= 1000 {
  1058. zero = "0000" + strconv.FormatInt(number, 10)
  1059. } else if number >= 10000 {
  1060. zero = "000" + strconv.FormatInt(number, 10)
  1061. } else if number >= 100000 {
  1062. zero = "00" + strconv.FormatInt(number, 10)
  1063. } else if number >= 1000000 {
  1064. zero = "0" + strconv.FormatInt(number, 10)
  1065. } else {
  1066. zero = strconv.FormatInt(number, 10)
  1067. }
  1068. fmt.Println(zero)
  1069. struct4101 := service.Struct4101{
  1070. PsnNo: order.PsnNo,
  1071. MdtrtId: order.MdtrtId,
  1072. SetlId: order.SetlId,
  1073. PsnName: order.PsnName,
  1074. Gend: order.Gend,
  1075. Brdy: his.Brdy,
  1076. Age: int64(order.Age),
  1077. Naty: order.Naty,
  1078. PatnCertType: "01",
  1079. Certno: order.Certno,
  1080. Prfs: "90",
  1081. ConerName: roles[0].UserName,
  1082. PatnRlts: "99",
  1083. ConerAddr: miConfig.OrgName,
  1084. ConerTel: admin.Mobile,
  1085. HiType: order.Insutype,
  1086. Insuplc: miConfig.InsuplcAdmdvs,
  1087. MaindiagFlag: "1",
  1088. BillCode: last_order.FaPiaoCode,
  1089. BillNo: zero,
  1090. BizSn: order.Number,
  1091. PsnSelfPay: order.PsnPartAmt,
  1092. PsnOwnPay: order.PsnPartAmt,
  1093. AcctPay: order.AcctPay,
  1094. PsnCashpay: order.PsnCashPay,
  1095. HiPaymtd: "1",
  1096. Hsorg: miConfig.InsuplcAdmdvs,
  1097. HsorgOpter: miConfig.InsuplcAdmdvs,
  1098. MedinsFillPsn: curRoles.UserName,
  1099. MedinsFillDept: depart.Name,
  1100. IptMedType: "2",
  1101. }
  1102. struct4101.SetlBegnDate = order.SetlTime
  1103. struct4101.SetlEndDate = order.SetlTime
  1104. var rf []CustomFundPay
  1105. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1106. var tempFunPays []service.CustomStruct
  1107. for _, item := range rf {
  1108. var tempFunPay service.CustomStruct
  1109. tempFunPay.FundPayamt = item.FundPayamt
  1110. tempFunPay.FundPayType = item.FundPayType
  1111. tempFunPays = append(tempFunPays, tempFunPay)
  1112. }
  1113. struct4101.CustomStruct = tempFunPays
  1114. var tempDiaginfos []service.DiaginfoStructTwo
  1115. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1116. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1117. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1118. var config []*models.HisXtDiagnoseConfig
  1119. for _, item := range diagnosis_ids {
  1120. id, _ := strconv.ParseInt(item, 10, 64)
  1121. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1122. config = append(config, &diagnosisConfig)
  1123. }
  1124. for index, item := range config {
  1125. if index == 0 {
  1126. var tempDiaginfo service.DiaginfoStructTwo
  1127. tempDiaginfo.DiagCode = item.CountryCode
  1128. tempDiaginfo.DiagName = item.CountryContentName
  1129. tempDiaginfo.DiagType = "1"
  1130. tempDiaginfo.MaindiagFlag = "1"
  1131. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1132. } else {
  1133. var tempDiaginfo service.DiaginfoStructTwo
  1134. tempDiaginfo.DiagCode = item.CountryCode
  1135. tempDiaginfo.DiagName = item.CountryContentName
  1136. tempDiaginfo.DiagType = "2"
  1137. tempDiaginfo.MaindiagFlag = "0"
  1138. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1139. }
  1140. }
  1141. struct4101.Diseinfo = tempDiaginfos
  1142. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1143. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1144. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1145. tempOpspdiseinfo2.OprnOprtCode = ""
  1146. tempOpspdiseinfo2.OprnOprtName = ""
  1147. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1148. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1149. var iteminfo service.IteminfoStruct
  1150. var bedCostTotal float64 = 0 //床位总费
  1151. var bedCostSelfTotal float64 = 0 //床位自费
  1152. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1153. var operationCostTotal float64 = 0 //手术费
  1154. var operationCostSelfTotal float64 = 0 //手术费
  1155. var operationCostPartSelfTotal float64 = 0 //手术费
  1156. var otherCostTotal float64 = 0 //其他费用
  1157. var otherCostSelfTotal float64 = 0 //其他费用
  1158. var otherCostPartSelfTotal float64 = 0 //其他费用
  1159. var materialCostTotal float64 = 0 //材料费
  1160. var materialCostSelfTotal float64 = 0 //材料费
  1161. var materialCostPartSelfTotal float64 = 0 //材料费
  1162. var westernMedicineCostTotal float64 = 0 //西药费
  1163. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1164. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1165. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1166. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1167. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1168. var checkCostTotal float64 = 0 //检查费
  1169. var checkCostSelfTotal float64 = 0 //检查费
  1170. var checkCostPartSelfTotal float64 = 0 //检查费
  1171. var laboratoryCostTotal float64 = 0 //化验费
  1172. var laboratoryCostSelfTotal float64 = 0 //化验费
  1173. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1174. var treatCostTotal float64 = 0 //治疗费用
  1175. var treatCostSelfTotal float64 = 0 //治疗费用
  1176. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1177. decimal.DivisionPrecision = 2
  1178. var bed_fulamt_ownpay_amt float64 = 0
  1179. var operation_fulamt_ownpay_amt float64 = 0
  1180. var other_fulamt_ownpay_amt float64 = 0
  1181. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1182. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1183. var check_fulamt_ownpay_amt float64 = 0
  1184. var material_fulamt_ownpay_amt float64 = 0
  1185. var laboratory_fulamt_ownpay_amt float64 = 0
  1186. var treat_fulamt_ownpay_amt float64 = 0
  1187. var bed_claa_sunmfee float64 = 0
  1188. var bed_clab_amt float64 = 0
  1189. var bed_other_amt float64 = 0
  1190. var operation_claa_sunmfee float64 = 0
  1191. var operation_clab_amt float64 = 0
  1192. var operation_other_amt float64 = 0
  1193. var other_claa_sunmfee float64 = 0
  1194. var other_clab_amt float64 = 0
  1195. var other_other_amt float64 = 0
  1196. var westernMedicine_claa_sunmfee float64 = 0
  1197. var westernMedicine_clab_amt float64 = 0
  1198. var westernMedicine_other_amt float64 = 0
  1199. var chineseTraditional_claa_sunmfee float64 = 0
  1200. var chineseTraditional_clab_amt float64 = 0
  1201. var chineseTraditional_other_amt float64 = 0
  1202. var check_claa_sunmfee float64 = 0
  1203. var check_clab_amt float64 = 0
  1204. var check_other_amt float64 = 0
  1205. var material_claa_sunmfee float64 = 0
  1206. var material_clab_amt float64 = 0
  1207. var material_other_amt float64 = 0
  1208. var laboratory_claa_sunmfee float64 = 0
  1209. var laboratory_clab_amt float64 = 0
  1210. var laboratory_other_amt float64 = 0
  1211. var treat_claa_sunmfee float64 = 0
  1212. var treat_clab_amt float64 = 0
  1213. var treat_other_amt float64 = 0
  1214. for _, item := range order.HisOrderInfo {
  1215. if item.MedChrgitmType == "01" { //床位费
  1216. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1217. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1218. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1219. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1220. if item.ChrgitmLv == "1" {
  1221. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1222. }
  1223. if item.ChrgitmLv == "2" {
  1224. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1225. }
  1226. if item.ChrgitmLv == "3" {
  1227. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1228. }
  1229. }
  1230. if item.MedChrgitmType == "03" { //检查费
  1231. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1232. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1233. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1234. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1235. if item.ChrgitmLv == "1" {
  1236. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1237. }
  1238. if item.ChrgitmLv == "2" {
  1239. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1240. }
  1241. if item.ChrgitmLv == "3" {
  1242. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1243. }
  1244. }
  1245. if item.MedChrgitmType == "04" { //化验费
  1246. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1247. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1248. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1249. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1250. if item.ChrgitmLv == "1" {
  1251. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1252. }
  1253. if item.ChrgitmLv == "2" {
  1254. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1255. }
  1256. if item.ChrgitmLv == "3" {
  1257. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1258. }
  1259. }
  1260. if item.MedChrgitmType == "05" { //治疗费
  1261. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1262. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1263. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1264. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1265. if item.ChrgitmLv == "1" {
  1266. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1267. }
  1268. if item.ChrgitmLv == "2" {
  1269. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1270. }
  1271. if item.ChrgitmLv == "3" {
  1272. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1273. }
  1274. }
  1275. if item.MedChrgitmType == "06" { //手术费
  1276. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1277. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1278. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1279. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1280. if item.ChrgitmLv == "1" {
  1281. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1282. }
  1283. if item.ChrgitmLv == "2" {
  1284. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1285. }
  1286. if item.ChrgitmLv == "3" {
  1287. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1288. }
  1289. }
  1290. if item.MedChrgitmType == "08" { //材料费
  1291. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1292. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1293. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1294. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1295. if item.ChrgitmLv == "1" {
  1296. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1297. }
  1298. if item.ChrgitmLv == "2" {
  1299. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1300. }
  1301. if item.ChrgitmLv == "3" {
  1302. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1303. }
  1304. }
  1305. if item.MedChrgitmType == "09" { //西药费
  1306. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1307. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1308. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1309. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1310. if item.ChrgitmLv == "1" {
  1311. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1312. }
  1313. if item.ChrgitmLv == "2" {
  1314. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1315. }
  1316. if item.ChrgitmLv == "3" {
  1317. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1318. }
  1319. }
  1320. if item.MedChrgitmType == "11" { //中成费
  1321. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1322. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1323. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1324. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1325. if item.ChrgitmLv == "1" {
  1326. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1327. }
  1328. if item.ChrgitmLv == "2" {
  1329. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1330. }
  1331. if item.ChrgitmLv == "3" {
  1332. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1333. }
  1334. }
  1335. if item.MedChrgitmType == "14" { //其他费
  1336. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1337. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1338. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1339. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1340. if item.ChrgitmLv == "1" {
  1341. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1342. }
  1343. if item.ChrgitmLv == "2" {
  1344. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1345. }
  1346. if item.ChrgitmLv == "3" {
  1347. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1348. }
  1349. }
  1350. }
  1351. var iteminfoStructs []service.IteminfoStruct
  1352. if bedCostTotal != 0 {
  1353. iteminfo.MedChrgitm = "01"
  1354. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1355. iteminfo.Amt = bedCostTotal
  1356. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1357. iteminfo.ClabAmt = bed_clab_amt
  1358. iteminfo.OthAmt = bed_other_amt
  1359. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1360. }
  1361. if checkCostTotal != 0 {
  1362. iteminfo.MedChrgitm = "03"
  1363. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1364. iteminfo.Amt = checkCostTotal
  1365. iteminfo.ClaaSumfee = check_claa_sunmfee
  1366. iteminfo.ClabAmt = check_clab_amt
  1367. iteminfo.OthAmt = check_other_amt
  1368. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1369. }
  1370. if laboratoryCostTotal != 0 {
  1371. iteminfo.MedChrgitm = "04"
  1372. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1373. iteminfo.Amt = laboratoryCostTotal
  1374. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1375. iteminfo.ClabAmt = laboratory_clab_amt
  1376. iteminfo.OthAmt = laboratory_other_amt
  1377. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1378. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1379. }
  1380. if treatCostTotal != 0 {
  1381. iteminfo.MedChrgitm = "05"
  1382. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1383. iteminfo.Amt = treatCostTotal
  1384. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1385. iteminfo.ClabAmt = treat_clab_amt
  1386. iteminfo.OthAmt = treat_other_amt
  1387. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1388. //(struct4101.IteminfoStruct, iteminfo)
  1389. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1390. }
  1391. if operationCostTotal != 0 {
  1392. iteminfo.MedChrgitm = "06"
  1393. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1394. iteminfo.Amt = operationCostTotal
  1395. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1396. iteminfo.ClabAmt = operation_clab_amt
  1397. iteminfo.OthAmt = operation_other_amt
  1398. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1399. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1400. }
  1401. if materialCostTotal != 0 {
  1402. iteminfo.MedChrgitm = "08"
  1403. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1404. iteminfo.Amt = materialCostTotal
  1405. iteminfo.ClaaSumfee = material_claa_sunmfee
  1406. iteminfo.ClabAmt = material_clab_amt
  1407. iteminfo.OthAmt = material_other_amt
  1408. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1409. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1410. }
  1411. if westernMedicineCostTotal != 0 {
  1412. iteminfo.MedChrgitm = "09"
  1413. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1414. iteminfo.Amt = westernMedicineCostTotal
  1415. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1416. iteminfo.ClabAmt = westernMedicine_clab_amt
  1417. iteminfo.OthAmt = westernMedicine_other_amt
  1418. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1419. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1420. }
  1421. if chineseTraditionalMedicineCostTotal != 0 {
  1422. iteminfo.MedChrgitm = "11"
  1423. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1424. iteminfo.Amt = westernMedicineCostTotal
  1425. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1426. iteminfo.ClabAmt = westernMedicine_clab_amt
  1427. iteminfo.OthAmt = westernMedicine_other_amt
  1428. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1429. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1430. }
  1431. if otherCostTotal != 0 {
  1432. iteminfo.MedChrgitm = "14"
  1433. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1434. iteminfo.Amt = otherCostTotal
  1435. iteminfo.ClaaSumfee = other_claa_sunmfee
  1436. iteminfo.ClabAmt = other_clab_amt
  1437. iteminfo.OthAmt = other_other_amt
  1438. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1439. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1440. }
  1441. struct4101.IteminfoStruct = iteminfoStructs
  1442. struct4101.Ntly = "中国"
  1443. struct4101.AdmCaty = "A03.06"
  1444. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1445. fmt.Println(result)
  1446. var dat map[string]interface{}
  1447. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1448. fmt.Println(dat)
  1449. } else {
  1450. fmt.Println(err)
  1451. }
  1452. userJSONBytes, _ := json.Marshal(dat)
  1453. var res ResultSeventeen
  1454. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1455. utils.ErrorLog("解析失败:%v", err)
  1456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1457. return
  1458. }
  1459. if res.Infcode != 0 {
  1460. c.ServeSuccessJSON(map[string]interface{}{
  1461. "failed_code": -10,
  1462. "msg": res.ErrMsg,
  1463. })
  1464. return
  1465. } else {
  1466. order.FaPiaoNumber = zero
  1467. order.FaPiaoCode = last_order.FaPiaoCode
  1468. service.UpdateOrder(order)
  1469. hisFundSettleListResult := &models.HisFundSettleListResult{
  1470. Number: res.Output.SetlListId,
  1471. Status: 1,
  1472. Ctime: time.Now().Unix(),
  1473. Mtime: time.Now().Unix(),
  1474. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1475. IsUpload: 1,
  1476. OrderId: order_id,
  1477. }
  1478. service.CreateUploadRecord(hisFundSettleListResult)
  1479. c.ServeSuccessJSON(map[string]interface{}{
  1480. "msg": "上传成功",
  1481. "result": hisFundSettleListResult,
  1482. })
  1483. return
  1484. }
  1485. }
  1486. func (c *HisApiController) GetBatchSettleList() {
  1487. org_id, _ := beego.AppConfig.Int64("org_id")
  1488. //stage, _ := c.GetInt64("stage")
  1489. orders, _ := service.GetAllHisOrder(org_id)
  1490. for _, item := range orders {
  1491. order_id := item.ID
  1492. order, _ := service.GetHisOrderByIDTwo(order_id)
  1493. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1494. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1495. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1496. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2185)
  1497. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1498. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1499. if order.ID == 0 {
  1500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1501. return
  1502. }
  1503. if his.BalanceAccountsType == 2 {
  1504. continue
  1505. }
  1506. struct4101 := service.Struct4101{
  1507. PsnNo: order.PsnNo,
  1508. MdtrtId: order.MdtrtId,
  1509. SetlId: order.SetlId,
  1510. PsnName: order.PsnName,
  1511. Gend: order.Gend,
  1512. Brdy: his.Brdy,
  1513. Age: his.Age,
  1514. Naty: order.Naty,
  1515. PatnCertType: "01",
  1516. Certno: order.Certno,
  1517. Prfs: "90",
  1518. ConerName: roles[0].UserName,
  1519. PatnRlts: "99",
  1520. ConerAddr: miConfig.OrgName,
  1521. ConerTel: admin.Mobile,
  1522. HiType: order.Insutype,
  1523. Insuplc: his.InsuplcAdmdvs,
  1524. MaindiagFlag: "1",
  1525. BillCode: order.FaPiaoCode,
  1526. BillNo: order.FaPiaoNumber,
  1527. BizSn: order.Number,
  1528. PsnSelfPay: order.PsnPartAmt,
  1529. PsnOwnPay: order.PsnPartAmt,
  1530. AcctPay: order.AcctPay,
  1531. PsnCashpay: order.PsnCashPay,
  1532. HiPaymtd: "1",
  1533. Hsorg: his.InsuplcAdmdvs,
  1534. HsorgOpter: his.InsuplcAdmdvs,
  1535. MedinsFillPsn: curRoles.UserName,
  1536. MedinsFillDept: depart.Name,
  1537. IptMedType: "2",
  1538. }
  1539. struct4101.SetlBegnDate = order.SetlTime
  1540. struct4101.SetlEndDate = order.SetlTime
  1541. //if order.SettleType == 1 {
  1542. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1543. // dateStr := t.Format("2006-01-02")
  1544. // struct4101.SetlBegnDate = dateStr
  1545. // struct4101.SetlEndDate = dateStr
  1546. //} else {
  1547. // t := time.Unix(int64(order.SettleStartTime), 0)
  1548. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1549. // dateStartStr := t.Format("2006-01-02")
  1550. // dateEndStr := t2.Format("2006-01-02")
  1551. // struct4101.SetlBegnDate = dateStartStr
  1552. // struct4101.SetlEndDate = dateEndStr
  1553. //}
  1554. var rf []CustomFundPay
  1555. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1556. var tempFunPays []service.CustomStruct
  1557. var tempFunPay610100 service.CustomStruct
  1558. for _, item := range rf {
  1559. if item.FundPayType == "610100" {
  1560. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1561. tempFunPay610100.FundPayType = item.FundPayType
  1562. } else {
  1563. var tempFunPay service.CustomStruct
  1564. tempFunPay.FundPayamt = item.FundPayamt
  1565. tempFunPay.FundPayType = item.FundPayType
  1566. tempFunPays = append(tempFunPays, tempFunPay)
  1567. }
  1568. }
  1569. tempFunPays = append(tempFunPays, tempFunPay610100)
  1570. struct4101.CustomStruct = tempFunPays
  1571. var tempDiaginfos []service.DiaginfoStructTwo
  1572. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1573. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1574. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1575. var config []*models.HisXtDiagnoseConfig
  1576. for _, item := range diagnosis_ids {
  1577. id, _ := strconv.ParseInt(item, 10, 64)
  1578. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1579. config = append(config, &diagnosisConfig)
  1580. }
  1581. for index, item := range config {
  1582. if index == 0 {
  1583. var tempDiaginfo service.DiaginfoStructTwo
  1584. tempDiaginfo.DiagCode = item.CountryCode
  1585. tempDiaginfo.DiagName = item.CountryContentName
  1586. tempDiaginfo.DiagType = "1"
  1587. tempDiaginfo.MaindiagFlag = "1"
  1588. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1589. } else {
  1590. var tempDiaginfo service.DiaginfoStructTwo
  1591. tempDiaginfo.DiagCode = item.CountryCode
  1592. tempDiaginfo.DiagName = item.CountryContentName
  1593. tempDiaginfo.DiagType = "2"
  1594. tempDiaginfo.MaindiagFlag = "0"
  1595. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1596. }
  1597. }
  1598. struct4101.Diseinfo = tempDiaginfos
  1599. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1600. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1601. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1602. tempOpspdiseinfo2.OprnOprtCode = ""
  1603. tempOpspdiseinfo2.OprnOprtName = ""
  1604. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1605. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1606. var iteminfo service.IteminfoStruct
  1607. var bedCostTotal float64 = 0 //床位总费
  1608. var bedCostSelfTotal float64 = 0 //床位自费
  1609. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1610. var examineCostTotal float64 = 0 //诊查总费
  1611. var examineCostSelfTotal float64 = 0 //诊查自费
  1612. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1613. var nursingCostTotal float64 = 0 //护理总费
  1614. var nursingCostSelfTotal float64 = 0 //护理自费
  1615. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1616. var chineseMedicineCostTotal float64 = 0 //中成药
  1617. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1618. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1619. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1620. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1621. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1622. var registerCostTotal float64 = 0 //一般诊疗费
  1623. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1624. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1625. var operationCostTotal float64 = 0 //手术费
  1626. var operationCostSelfTotal float64 = 0 //手术费
  1627. var operationCostPartSelfTotal float64 = 0 //手术费
  1628. var otherCostTotal float64 = 0 //其他费用
  1629. var otherCostSelfTotal float64 = 0 //其他费用
  1630. var otherCostPartSelfTotal float64 = 0 //其他费用
  1631. var materialCostTotal float64 = 0 //材料费
  1632. var materialCostSelfTotal float64 = 0 //材料费
  1633. var materialCostPartSelfTotal float64 = 0 //材料费
  1634. var westernMedicineCostTotal float64 = 0 //西药费
  1635. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1636. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1637. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1638. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1639. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1640. var checkCostTotal float64 = 0 //检查费
  1641. var checkCostSelfTotal float64 = 0 //检查费
  1642. var checkCostPartSelfTotal float64 = 0 //检查费
  1643. var laboratoryCostTotal float64 = 0 //化验费
  1644. var laboratoryCostSelfTotal float64 = 0 //化验费
  1645. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1646. var treatCostTotal float64 = 0 //治疗费用
  1647. var treatCostSelfTotal float64 = 0 //治疗费用
  1648. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1649. decimal.DivisionPrecision = 2
  1650. var bed_fulamt_ownpay_amt float64 = 0
  1651. var examine_fulamt_ownpay_amt float64 = 0
  1652. var nursing_fulamt_ownpay_amt float64 = 0
  1653. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1654. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1655. var register_fulamt_ownpay_amt float64 = 0
  1656. var operation_fulamt_ownpay_amt float64 = 0
  1657. var other_fulamt_ownpay_amt float64 = 0
  1658. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1659. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1660. var check_fulamt_ownpay_amt float64 = 0
  1661. var material_fulamt_ownpay_amt float64 = 0
  1662. var laboratory_fulamt_ownpay_amt float64 = 0
  1663. var treat_fulamt_ownpay_amt float64 = 0
  1664. var bed_claa_sunmfee float64 = 0
  1665. var bed_clab_amt float64 = 0
  1666. var bed_other_amt float64 = 0
  1667. var examine_claa_sunmfee float64 = 0
  1668. var examine_clab_amt float64 = 0
  1669. var examine_other_amt float64 = 0
  1670. var nursing_claa_sunmfee float64 = 0
  1671. var nursing_clab_amt float64 = 0
  1672. var nursing_other_amt float64 = 0
  1673. var chinese_medicine_claa_sunmfee float64 = 0
  1674. var chinese_medicine_clab_amt float64 = 0
  1675. var chinese_medicine_other_amt float64 = 0
  1676. var commonly_treatment_claa_sunmfee float64 = 0
  1677. var commonly_treatment_clab_amt float64 = 0
  1678. var commonly_treatment_other_amt float64 = 0
  1679. var operation_claa_sunmfee float64 = 0
  1680. var operation_clab_amt float64 = 0
  1681. var operation_other_amt float64 = 0
  1682. var other_claa_sunmfee float64 = 0
  1683. var other_clab_amt float64 = 0
  1684. var other_other_amt float64 = 0
  1685. var westernMedicine_claa_sunmfee float64 = 0
  1686. var westernMedicine_clab_amt float64 = 0
  1687. var westernMedicine_other_amt float64 = 0
  1688. var chineseTraditional_claa_sunmfee float64 = 0
  1689. var chineseTraditional_clab_amt float64 = 0
  1690. var chineseTraditional_other_amt float64 = 0
  1691. var check_claa_sunmfee float64 = 0
  1692. var check_clab_amt float64 = 0
  1693. var check_other_amt float64 = 0
  1694. var material_claa_sunmfee float64 = 0
  1695. var material_clab_amt float64 = 0
  1696. var material_other_amt float64 = 0
  1697. var laboratory_claa_sunmfee float64 = 0
  1698. var laboratory_clab_amt float64 = 0
  1699. var laboratory_other_amt float64 = 0
  1700. var treat_claa_sunmfee float64 = 0
  1701. var treat_clab_amt float64 = 0
  1702. var treat_other_amt float64 = 0
  1703. var register_claa_sunmfee float64 = 0
  1704. var register_clab_amt float64 = 0
  1705. var register_other_amt float64 = 0
  1706. for _, item := range order.HisOrderInfo {
  1707. if item.MedChrgitmType == "01" { //床位费
  1708. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1709. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1710. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1711. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1712. if item.ChrgitmLv == "1" {
  1713. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1714. }
  1715. if item.ChrgitmLv == "2" {
  1716. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1717. }
  1718. if item.ChrgitmLv == "3" {
  1719. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1720. }
  1721. }
  1722. if item.MedChrgitmType == "02" { //诊查
  1723. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1724. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1725. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1726. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1727. if item.ChrgitmLv == "1" {
  1728. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1729. }
  1730. if item.ChrgitmLv == "2" {
  1731. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1732. }
  1733. if item.ChrgitmLv == "3" {
  1734. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1735. }
  1736. }
  1737. if item.MedChrgitmType == "03" { //检查费
  1738. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1739. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1740. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1741. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1742. if item.ChrgitmLv == "1" {
  1743. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1744. }
  1745. if item.ChrgitmLv == "2" {
  1746. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1747. }
  1748. if item.ChrgitmLv == "3" {
  1749. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1750. }
  1751. }
  1752. if item.MedChrgitmType == "04" { //化验费
  1753. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1754. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1755. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1756. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1757. if item.ChrgitmLv == "1" {
  1758. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1759. }
  1760. if item.ChrgitmLv == "2" {
  1761. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1762. }
  1763. if item.ChrgitmLv == "3" {
  1764. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1765. }
  1766. }
  1767. if item.MedChrgitmType == "05" { //治疗费
  1768. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1769. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1770. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1771. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1772. if item.ChrgitmLv == "1" {
  1773. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1774. }
  1775. if item.ChrgitmLv == "2" {
  1776. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1777. }
  1778. if item.ChrgitmLv == "3" {
  1779. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1780. }
  1781. }
  1782. if item.MedChrgitmType == "06" { //手术费
  1783. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1784. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1785. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1786. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1787. if item.ChrgitmLv == "1" {
  1788. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1789. }
  1790. if item.ChrgitmLv == "2" {
  1791. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1792. }
  1793. if item.ChrgitmLv == "3" {
  1794. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1795. }
  1796. }
  1797. if item.MedChrgitmType == "07" { //手术费
  1798. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1799. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1800. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1801. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1802. if item.ChrgitmLv == "1" {
  1803. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1804. }
  1805. if item.ChrgitmLv == "2" {
  1806. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1807. }
  1808. if item.ChrgitmLv == "3" {
  1809. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1810. }
  1811. }
  1812. if item.MedChrgitmType == "08" { //材料费
  1813. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1814. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1815. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1816. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1817. if item.ChrgitmLv == "1" {
  1818. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1819. }
  1820. if item.ChrgitmLv == "2" {
  1821. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1822. }
  1823. if item.ChrgitmLv == "3" {
  1824. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1825. }
  1826. }
  1827. if item.MedChrgitmType == "09" { //西药费
  1828. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1829. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1830. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1831. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1832. if item.ChrgitmLv == "1" {
  1833. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1834. }
  1835. if item.ChrgitmLv == "2" {
  1836. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1837. }
  1838. if item.ChrgitmLv == "3" {
  1839. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1840. }
  1841. }
  1842. if item.MedChrgitmType == "10" { //中药饮片
  1843. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1844. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1845. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1846. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1847. if item.ChrgitmLv == "1" {
  1848. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1849. }
  1850. if item.ChrgitmLv == "2" {
  1851. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1852. }
  1853. if item.ChrgitmLv == "3" {
  1854. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1855. }
  1856. }
  1857. if item.MedChrgitmType == "11" { //中成费
  1858. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1859. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1860. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1861. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1862. if item.ChrgitmLv == "1" {
  1863. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1864. }
  1865. if item.ChrgitmLv == "2" {
  1866. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1867. }
  1868. if item.ChrgitmLv == "3" {
  1869. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1870. }
  1871. }
  1872. if item.MedChrgitmType == "12" { //中成费
  1873. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1874. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1875. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1876. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1877. if item.ChrgitmLv == "1" {
  1878. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1879. }
  1880. if item.ChrgitmLv == "2" {
  1881. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1882. }
  1883. if item.ChrgitmLv == "3" {
  1884. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1885. }
  1886. }
  1887. if item.MedChrgitmType == "13" { //中成费
  1888. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1889. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1890. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1891. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1892. if item.ChrgitmLv == "1" {
  1893. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1894. }
  1895. if item.ChrgitmLv == "2" {
  1896. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1897. }
  1898. if item.ChrgitmLv == "3" {
  1899. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1900. }
  1901. }
  1902. if item.MedChrgitmType == "14" { //其他费
  1903. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1904. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1905. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1906. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1907. if item.ChrgitmLv == "1" {
  1908. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1909. }
  1910. if item.ChrgitmLv == "2" {
  1911. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1912. }
  1913. if item.ChrgitmLv == "3" {
  1914. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1915. }
  1916. }
  1917. }
  1918. var iteminfoStructs []service.IteminfoStruct
  1919. if bedCostTotal != 0 {
  1920. iteminfo.MedChrgitm = "01"
  1921. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1922. iteminfo.Amt = bedCostTotal
  1923. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1924. iteminfo.ClabAmt = bed_clab_amt
  1925. iteminfo.OthAmt = bed_other_amt
  1926. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1927. }
  1928. if examineCostTotal != 0 {
  1929. iteminfo.MedChrgitm = "02"
  1930. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1931. iteminfo.Amt = examineCostTotal
  1932. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1933. iteminfo.ClabAmt = examine_clab_amt
  1934. iteminfo.OthAmt = examine_other_amt
  1935. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1936. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1937. }
  1938. if checkCostTotal != 0 {
  1939. iteminfo.MedChrgitm = "03"
  1940. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1941. iteminfo.Amt = checkCostTotal
  1942. iteminfo.ClaaSumfee = check_claa_sunmfee
  1943. iteminfo.ClabAmt = check_clab_amt
  1944. iteminfo.OthAmt = check_other_amt
  1945. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1946. }
  1947. if laboratoryCostTotal != 0 {
  1948. iteminfo.MedChrgitm = "04"
  1949. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1950. iteminfo.Amt = laboratoryCostTotal
  1951. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1952. iteminfo.ClabAmt = laboratory_clab_amt
  1953. iteminfo.OthAmt = laboratory_other_amt
  1954. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1955. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1956. }
  1957. if treatCostTotal != 0 {
  1958. iteminfo.MedChrgitm = "05"
  1959. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1960. iteminfo.Amt = treatCostTotal
  1961. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1962. iteminfo.ClabAmt = treat_clab_amt
  1963. iteminfo.OthAmt = treat_other_amt
  1964. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1965. //(struct4101.IteminfoStruct, iteminfo)
  1966. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1967. }
  1968. if operationCostTotal != 0 {
  1969. iteminfo.MedChrgitm = "06"
  1970. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1971. iteminfo.Amt = operationCostTotal
  1972. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1973. iteminfo.ClabAmt = operation_clab_amt
  1974. iteminfo.OthAmt = operation_other_amt
  1975. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1976. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1977. }
  1978. if nursingCostTotal != 0 {
  1979. iteminfo.MedChrgitm = "07"
  1980. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  1981. iteminfo.Amt = nursingCostTotal
  1982. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  1983. iteminfo.ClabAmt = nursing_clab_amt
  1984. iteminfo.OthAmt = nursing_other_amt
  1985. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1986. }
  1987. if materialCostTotal != 0 {
  1988. iteminfo.MedChrgitm = "08"
  1989. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1990. iteminfo.Amt = materialCostTotal
  1991. iteminfo.ClaaSumfee = material_claa_sunmfee
  1992. iteminfo.ClabAmt = material_clab_amt
  1993. iteminfo.OthAmt = material_other_amt
  1994. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1995. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1996. }
  1997. if westernMedicineCostTotal != 0 {
  1998. iteminfo.MedChrgitm = "09"
  1999. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2000. iteminfo.Amt = westernMedicineCostTotal
  2001. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2002. iteminfo.ClabAmt = westernMedicine_clab_amt
  2003. iteminfo.OthAmt = westernMedicine_other_amt
  2004. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2005. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2006. }
  2007. if chineseMedicineCostTotal != 0 {
  2008. iteminfo.MedChrgitm = "10"
  2009. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2010. iteminfo.Amt = chineseMedicineCostTotal
  2011. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2012. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2013. iteminfo.OthAmt = chinese_medicine_other_amt
  2014. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2015. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2016. }
  2017. if chineseTraditionalMedicineCostTotal != 0 {
  2018. iteminfo.MedChrgitm = "11"
  2019. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2020. iteminfo.Amt = westernMedicineCostTotal
  2021. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2022. iteminfo.ClabAmt = westernMedicine_clab_amt
  2023. iteminfo.OthAmt = westernMedicine_other_amt
  2024. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2025. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2026. }
  2027. if commonlyTreatmentCostTotal != 0 {
  2028. iteminfo.MedChrgitm = "12"
  2029. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2030. iteminfo.Amt = commonlyTreatmentCostTotal
  2031. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2032. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2033. iteminfo.OthAmt = commonly_treatment_other_amt
  2034. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2035. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2036. }
  2037. if registerCostTotal != 0 {
  2038. iteminfo.MedChrgitm = "13"
  2039. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2040. iteminfo.Amt = registerCostTotal
  2041. iteminfo.ClaaSumfee = register_claa_sunmfee
  2042. iteminfo.ClabAmt = register_clab_amt
  2043. iteminfo.OthAmt = register_other_amt
  2044. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2045. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2046. }
  2047. if otherCostTotal != 0 {
  2048. iteminfo.MedChrgitm = "14"
  2049. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2050. iteminfo.Amt = otherCostTotal
  2051. iteminfo.ClaaSumfee = other_claa_sunmfee
  2052. iteminfo.ClabAmt = other_clab_amt
  2053. iteminfo.OthAmt = other_other_amt
  2054. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2055. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2056. }
  2057. struct4101.IteminfoStruct = iteminfoStructs
  2058. struct4101.Ntly = "中国"
  2059. struct4101.AdmCaty = "A03.06"
  2060. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, org_id)
  2061. fmt.Println(result)
  2062. var dat map[string]interface{}
  2063. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2064. fmt.Println(dat)
  2065. } else {
  2066. fmt.Println(err)
  2067. }
  2068. userJSONBytes, _ := json.Marshal(dat)
  2069. var res ResultSeventeen
  2070. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2071. utils.ErrorLog("解析失败:%v", err)
  2072. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2073. adminUser := c.GetAdminUserInfo()
  2074. errlog := &models.HisOrderError{
  2075. UserOrgId: adminUser.CurrentOrgId,
  2076. Ctime: time.Now().Unix(),
  2077. Mtime: time.Now().Unix(),
  2078. ErrMsg: res.ErrMsg + "解析失败",
  2079. Status: 1,
  2080. PatientId: order_id,
  2081. Stage: 1000,
  2082. }
  2083. service.CreateErrMsgLog(errlog)
  2084. continue
  2085. }
  2086. if res.Infcode != 0 {
  2087. adminUser := c.GetAdminUserInfo()
  2088. errlog := &models.HisOrderError{
  2089. UserOrgId: adminUser.CurrentOrgId,
  2090. Ctime: time.Now().Unix(),
  2091. Mtime: time.Now().Unix(),
  2092. ErrMsg: res.ErrMsg,
  2093. Status: 1,
  2094. PatientId: order_id,
  2095. Stage: 1000,
  2096. }
  2097. service.CreateErrMsgLog(errlog)
  2098. continue
  2099. } else {
  2100. hisFundSettleListResult := &models.HisFundSettleListResult{
  2101. Number: res.Output.SetlListId,
  2102. Status: 1,
  2103. Ctime: time.Now().Unix(),
  2104. Mtime: time.Now().Unix(),
  2105. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2106. IsUpload: 1,
  2107. OrderId: order_id,
  2108. }
  2109. service.CreateUploadRecord(hisFundSettleListResult)
  2110. continue
  2111. }
  2112. }
  2113. }
  2114. func (c *HisApiController) GetOrgInfo() {
  2115. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2116. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2117. }
  2118. func (c *HisApiController) GetHisPatientInfo() {
  2119. medical_insurance_card := c.GetString("medical_insurance_card")
  2120. id_card_type, _ := c.GetInt64("id_card_type")
  2121. id_card := c.GetString("id_card")
  2122. adminInfo := c.GetAdminUserInfo()
  2123. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2124. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2125. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2126. IdCardNo := ""
  2127. if id_card_type == 1 {
  2128. IdCardNo = medical_insurance_card
  2129. } else if id_card_type == 2 {
  2130. IdCardNo = id_card
  2131. }
  2132. if config.IsOpen == 1 {
  2133. 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
  2134. resp, requestErr := http.Get(api)
  2135. if requestErr != nil {
  2136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2137. return
  2138. }
  2139. defer resp.Body.Close()
  2140. body, ioErr := ioutil.ReadAll(resp.Body)
  2141. if ioErr != nil {
  2142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2144. return
  2145. }
  2146. var respJSON map[string]interface{}
  2147. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2150. return
  2151. }
  2152. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2153. userJSONBytes, _ := json.Marshal(userJSON)
  2154. var res ResultTwo
  2155. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2156. utils.ErrorLog("解析失败:%v", err)
  2157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2158. return
  2159. }
  2160. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2161. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2162. infoStr := string(Iinfos)
  2163. idetinfoStr := string(Idetinfos)
  2164. if res.Infcode == 0 {
  2165. his := models.VMHisPatient{
  2166. Status: 1,
  2167. Ctime: time.Now().Unix(),
  2168. Mtime: time.Now().Unix(),
  2169. PsnNo: res.Output.Baseinfo.PsnNo,
  2170. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2171. Certno: res.Output.Baseinfo.Certno,
  2172. PsnName: res.Output.Baseinfo.PsnName,
  2173. Gend: res.Output.Baseinfo.Gend,
  2174. Naty: res.Output.Baseinfo.Naty,
  2175. Brdy: res.Output.Baseinfo.Brdy,
  2176. Age: res.Output.Baseinfo.Age,
  2177. Iinfo: infoStr,
  2178. Idetinfo: idetinfoStr,
  2179. UserOrgId: adminInfo.CurrentOrgId,
  2180. IsReturn: 1,
  2181. IdCardType: id_card_type,
  2182. }
  2183. c.ServeSuccessJSON(map[string]interface{}{
  2184. "info": his,
  2185. })
  2186. } else {
  2187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2188. return
  2189. }
  2190. }
  2191. }
  2192. //func GetBasBaseInfo() (jsonStr string, err error) {
  2193. //
  2194. // handle := syscall.NewLazyDLL("SSCard.dll")
  2195. // add := handle.NewProc("ReadCardBas")
  2196. // str := make([]byte, 1024)
  2197. // str1 := make([]byte, 1024)
  2198. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2199. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2200. //
  2201. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2202. //
  2203. // fmt.Println("> Add(4,5)的结果为:", ret)
  2204. // handle.Release()
  2205. //
  2206. // return "", nil
  2207. //
  2208. //}
  2209. //func GetQRBaseInfo() (jsonStr string, err error) {
  2210. // handle := syscall.LoadDLL("SSCard.dll")
  2211. // ReadCardBas := handle.FindProc("GetQRBase")
  2212. //
  2213. // str := make([]byte, 256)
  2214. // str1 := make([]byte, 256)
  2215. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2216. //
  2217. // fmt.Println(string(str))
  2218. // fmt.Println(r)
  2219. // return string(str), nil
  2220. //}
  2221. //func CardInit() int {
  2222. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2223. // add := DllTestDef.MustFindProc("Init")
  2224. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2225. // if err != nil {
  2226. // fmt.Println("SSCard的运算结果为:", ret)
  2227. // }
  2228. // result := int(ret)
  2229. // return result
  2230. //}
  2231. //func CardInit() int {
  2232. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2233. // if err != nil {
  2234. // fmt.Println("SSCard的运算结果为:", ret)
  2235. // }
  2236. // fmt.Println(err)
  2237. // result := int(ret)
  2238. // return result
  2239. //}
  2240. func IntPtr(n int) uintptr {
  2241. return uintptr(n)
  2242. }
  2243. func StrPtr(s string) uintptr {
  2244. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2245. }
  2246. type Result2001 struct {
  2247. Cainfo interface{} `json:"cainfo"`
  2248. ErrMsg string `json:"err_msg"`
  2249. InfRefmsgid string `json:"inf_refmsgid"`
  2250. Infcode int64 `json:"infcode"`
  2251. Output struct {
  2252. Trtinfo struct {
  2253. PsnNo string `json:"psn_no"`
  2254. TrtChkType string `json:"trt_chk_type"`
  2255. FundPayType string `json:"fund_pay_type"`
  2256. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2257. Begndate string `json:"begndate"`
  2258. Enddate string `json:"enddate"`
  2259. TrtChkRslt string `json:"trt_chk_rslt"`
  2260. } `json:"trtinfo"`
  2261. } `json:"output"`
  2262. RefmsgTime string `json:"refmsg_time"`
  2263. RespondTime string `json:"respond_time"`
  2264. Signtype interface{} `json:"signtype"`
  2265. WarnMsg interface{} `json:"warn_msg"`
  2266. }
  2267. type Result2001Org10265 struct {
  2268. Cainfo interface{} `json:"cainfo"`
  2269. ErrMsg string `json:"err_msg"`
  2270. InfRefmsgid string `json:"inf_refmsgid"`
  2271. Infcode string `json:"infcode"`
  2272. Output struct {
  2273. Trtinfo struct {
  2274. PsnNo string `json:"psn_no"`
  2275. TrtChkType string `json:"trt_chk_type"`
  2276. FundPayType string `json:"fund_pay_type"`
  2277. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2278. Begndate string `json:"begndate"`
  2279. Enddate string `json:"enddate"`
  2280. TrtChkRslt string `json:"trt_chk_rslt"`
  2281. } `json:"trtinfo"`
  2282. } `json:"output"`
  2283. RefmsgTime string `json:"refmsg_time"`
  2284. RespondTime string `json:"respond_time"`
  2285. Signtype interface{} `json:"signtype"`
  2286. WarnMsg interface{} `json:"warn_msg"`
  2287. }
  2288. type ResultTwo struct {
  2289. ErrMsg string `json:"err_msg"`
  2290. InfRefmsgid string `json:"inf_refmsgid"`
  2291. Infcode int64 `json:"infcode"`
  2292. Output struct {
  2293. Baseinfo struct {
  2294. Age float64 `json:"age"`
  2295. Brdy string `json:"brdy"`
  2296. Certno string `json:"certno"`
  2297. Gend string `json:"gend"`
  2298. Naty string `json:"naty"`
  2299. PsnCertType string `json:"psn_cert_type"`
  2300. PsnName string `json:"psn_name"`
  2301. PsnNo string `json:"psn_no"`
  2302. } `json:"baseinfo"`
  2303. Idetinfo []interface{} `json:"idetinfo"`
  2304. Iinfo []struct {
  2305. Balc float64 `json:"balc"`
  2306. CvlservFlag string `json:"cvlserv_flag"`
  2307. EmpName string `json:"emp_name"`
  2308. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2309. Insutype string `json:"insutype"`
  2310. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2311. PausInsuDate string `json:"paus_insu_date"`
  2312. PsnInsuDate string `json:"psn_insu_date"`
  2313. PsnInsuStas string `json:"psn_insu_stas"`
  2314. PsnType string `json:"psn_type"`
  2315. } `json:"insuinfo"`
  2316. } `json:"output"`
  2317. RefmsgTime string `json:"refmsg_time"`
  2318. RespondTime string `json:"respond_time"`
  2319. Signtype interface{} `json:"signtype"`
  2320. WarnInfo interface{} `json:"warn_info"`
  2321. }
  2322. type ResultTwo10265 struct {
  2323. ErrMsg string `json:"err_msg"`
  2324. InfRefmsgid string `json:"inf_refmsgid"`
  2325. Infcode string `json:"infcode"`
  2326. Output struct {
  2327. Baseinfo struct {
  2328. Age float64 `json:"age"`
  2329. Brdy string `json:"brdy"`
  2330. Certno string `json:"certno"`
  2331. Gend string `json:"gend"`
  2332. Naty string `json:"naty"`
  2333. PsnCertType string `json:"psn_cert_type"`
  2334. PsnName string `json:"psn_name"`
  2335. PsnNo string `json:"psn_no"`
  2336. } `json:"baseinfo"`
  2337. Idetinfo []interface{} `json:"idetinfo"`
  2338. Iinfo []struct {
  2339. Balc float64 `json:"balc"`
  2340. CvlservFlag string `json:"cvlserv_flag"`
  2341. EmpName string `json:"emp_name"`
  2342. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2343. Insutype string `json:"insutype"`
  2344. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2345. PausInsuDate string `json:"paus_insu_date"`
  2346. PsnInsuDate string `json:"psn_insu_date"`
  2347. PsnInsuStas string `json:"psn_insu_stas"`
  2348. PsnType string `json:"psn_type"`
  2349. } `json:"insuinfo"`
  2350. } `json:"output"`
  2351. RefmsgTime string `json:"refmsg_time"`
  2352. RespondTime string `json:"respond_time"`
  2353. Signtype interface{} `json:"signtype"`
  2354. WarnInfo interface{} `json:"warn_info"`
  2355. }
  2356. type ResultThree struct {
  2357. Cainfo interface{} `json:"cainfo"`
  2358. ErrMsg string `json:"err_msg"`
  2359. InfRefmsgid string `json:"inf_refmsgid"`
  2360. Infcode int64 `json:"infcode"`
  2361. Output struct {
  2362. Data struct {
  2363. IptOtpNo string `json:"ipt_otp_no"`
  2364. MdtrtID string `json:"mdtrt_id"`
  2365. PsnNo string `json:"psn_no"`
  2366. } `json:"data"`
  2367. } `json:"output"`
  2368. RefmsgTime string `json:"refmsg_time"`
  2369. RespondTime string `json:"respond_time"`
  2370. Signtype interface{} `json:"signtype"`
  2371. WarnMsg interface{} `json:"warn_msg"`
  2372. }
  2373. type ResultThree10265 struct {
  2374. Cainfo interface{} `json:"cainfo"`
  2375. ErrMsg string `json:"err_msg"`
  2376. InfRefmsgid string `json:"inf_refmsgid"`
  2377. Infcode string `json:"infcode"`
  2378. Output struct {
  2379. Data struct {
  2380. IptOtpNo string `json:"ipt_otp_no"`
  2381. MdtrtID string `json:"mdtrt_id"`
  2382. PsnNo string `json:"psn_no"`
  2383. } `json:"data"`
  2384. } `json:"output"`
  2385. RefmsgTime string `json:"refmsg_time"`
  2386. RespondTime string `json:"respond_time"`
  2387. Signtype interface{} `json:"signtype"`
  2388. WarnMsg interface{} `json:"warn_msg"`
  2389. }
  2390. type ResultFour struct {
  2391. Cainfo string `json:"cainfo"`
  2392. ErrMsg string `json:"err_msg"`
  2393. InfRefmsgid string `json:"inf_refmsgid"`
  2394. Infcode int64 `json:"infcode"`
  2395. Output struct {
  2396. Result []struct {
  2397. BasMednFlag string `json:"bas_medn_flag"`
  2398. ChldMedcFlag string `json:"chld_medc_flag"`
  2399. ChrgitmLv string `json:"chrgitm_lv"`
  2400. Cnt float64 `json:"cnt"`
  2401. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2402. DrtReimFlag string `json:"drt_reim_flag"`
  2403. FeedetlSn string `json:"feedetl_sn"`
  2404. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2405. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2406. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2407. ListSpItemFlag string `json:"list_sp_item_flag"`
  2408. LmtUsedFlag string `json:"lmt_used_flag"`
  2409. MedChrgitmType string `json:"med_chrgitm_type"`
  2410. Memo string `json:"memo"`
  2411. OverlmtAmt float64 `json:"overlmt_amt"`
  2412. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2413. Pric float64 `json:"pric"`
  2414. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2415. SelfpayProp float64 `json:"selfpay_prop"`
  2416. } `json:"result"`
  2417. } `json:"output"`
  2418. RefmsgTime string `json:"refmsg_time"`
  2419. RespondTime string `json:"respond_time"`
  2420. Signtype string `json:"signtype"`
  2421. WarnMsg string `json:"warn_msg"`
  2422. }
  2423. type ResultFour10265 struct {
  2424. Cainfo string `json:"cainfo"`
  2425. ErrMsg string `json:"err_msg"`
  2426. InfRefmsgid string `json:"inf_refmsgid"`
  2427. Infcode string `json:"infcode"`
  2428. Output struct {
  2429. Result []struct {
  2430. BasMednFlag string `json:"bas_medn_flag"`
  2431. ChldMedcFlag string `json:"chld_medc_flag"`
  2432. ChrgitmLv string `json:"chrgitm_lv"`
  2433. Cnt float64 `json:"cnt"`
  2434. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2435. DrtReimFlag string `json:"drt_reim_flag"`
  2436. FeedetlSn string `json:"feedetl_sn"`
  2437. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2438. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2439. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2440. ListSpItemFlag string `json:"list_sp_item_flag"`
  2441. LmtUsedFlag string `json:"lmt_used_flag"`
  2442. MedChrgitmType string `json:"med_chrgitm_type"`
  2443. Memo string `json:"memo"`
  2444. OverlmtAmt float64 `json:"overlmt_amt"`
  2445. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2446. Pric float64 `json:"pric"`
  2447. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2448. SelfpayProp float64 `json:"selfpay_prop"`
  2449. } `json:"result"`
  2450. } `json:"output"`
  2451. RefmsgTime string `json:"refmsg_time"`
  2452. RespondTime string `json:"respond_time"`
  2453. Signtype string `json:"signtype"`
  2454. WarnMsg string `json:"warn_msg"`
  2455. }
  2456. type ResultFive struct {
  2457. Balc float64 `json:"balc"`
  2458. CvlservFlag string `json:"cvlserv_flag"`
  2459. EmpName string `json:"emp_name"`
  2460. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2461. Insutype string `json:"insutype"`
  2462. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2463. PausInsuDate string `json:"paus_insu_date"`
  2464. PsnInsuDate string `json:"psn_insu_date"`
  2465. PsnInsuStas string `json:"psn_insu_stas"`
  2466. PsnType string `json:"psn_type"`
  2467. }
  2468. type ResultSix struct {
  2469. Cainfo interface{} `json:"cainfo"`
  2470. ErrMsg string `json:"err_msg"`
  2471. InfRefmsgid string `json:"inf_refmsgid"`
  2472. Infcode int64 `json:"infcode"`
  2473. Output struct {
  2474. } `json:"output"`
  2475. RefmsgTime string `json:"refmsg_time"`
  2476. RespondTime string `json:"respond_time"`
  2477. Signtype interface{} `json:"signtype"`
  2478. WarnMsg interface{} `json:"warn_msg"`
  2479. }
  2480. type ResultSix10265 struct {
  2481. Cainfo interface{} `json:"cainfo"`
  2482. ErrMsg string `json:"err_msg"`
  2483. InfRefmsgid string `json:"inf_refmsgid"`
  2484. Infcode string `json:"infcode"`
  2485. Output struct {
  2486. } `json:"output"`
  2487. RefmsgTime string `json:"refmsg_time"`
  2488. RespondTime string `json:"respond_time"`
  2489. Signtype interface{} `json:"signtype"`
  2490. WarnMsg interface{} `json:"warn_msg"`
  2491. }
  2492. type ResultSeven struct {
  2493. Cainfo string `json:"cainfo"`
  2494. ErrMsg string `json:"err_msg"`
  2495. InfRefmsgid string `json:"inf_refmsgid"`
  2496. Infcode int64 `json:"infcode"`
  2497. Output struct {
  2498. Setldetail []interface{} `json:"setldetail"`
  2499. Setlinfo struct {
  2500. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2501. AcctPay float64 `json:"acct_pay"`
  2502. ActPayDedc float64 `json:"act_pay_dedc"`
  2503. Age float64 `json:"age"`
  2504. Balc float64 `json:"balc"`
  2505. Brdy string `json:"brdy"`
  2506. Certno string `json:"certno"`
  2507. ClrOptins string `json:"clr_optins"`
  2508. ClrType string `json:"clr_type"`
  2509. ClrWay string `json:"clr_way"`
  2510. CvlservFlag string `json:"cvlserv_flag"`
  2511. CvlservPay float64 `json:"cvlserv_pay"`
  2512. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2513. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2514. Gend string `json:"gend"`
  2515. HifesPay float64 `json:"hifes_pay"`
  2516. HifmiPay float64 `json:"hifmi_pay"`
  2517. HifpPay float64 `json:"hifp_pay"`
  2518. HospPartAmt float64 `json:"hosp_part_amt"`
  2519. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2520. Insutype string `json:"insutype"`
  2521. MafPay float64 `json:"maf_pay"`
  2522. MdtrtCertType string `json:"mdtrt_cert_type"`
  2523. HifobPay float64 `json:"hifob_pay"`
  2524. MdtrtID string `json:"mdtrt_id"`
  2525. MedType string `json:"med_type"`
  2526. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2527. MedinsSetlID string `json:"medins_setl_id"`
  2528. Naty string `json:"naty"`
  2529. OthPay float64 `json:"oth_pay"`
  2530. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2531. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2532. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2533. PsnCashPay float64 `json:"psn_cash_pay"`
  2534. PsnCertType string `json:"psn_cert_type"`
  2535. PsnName string `json:"psn_name"`
  2536. PsnNo string `json:"psn_no"`
  2537. PsnPartAmt float64 `json:"psn_part_amt"`
  2538. PsnType string `json:"psn_type"`
  2539. SetlID string `json:"setl_id"`
  2540. SetlTime string `json:"setl_time"`
  2541. } `json:"setlinfo"`
  2542. } `json:"output"`
  2543. RefmsgTime string `json:"refmsg_time"`
  2544. RespondTime string `json:"respond_time"`
  2545. Signtype interface{} `json:"signtype"`
  2546. WarnMsg interface{} `json:"warn_msg"`
  2547. }
  2548. type ResultSeven10265 struct {
  2549. Cainfo string `json:"cainfo"`
  2550. ErrMsg string `json:"err_msg"`
  2551. InfRefmsgid string `json:"inf_refmsgid"`
  2552. Infcode string `json:"infcode"`
  2553. Output struct {
  2554. Setldetail []interface{} `json:"setldetail"`
  2555. Setlinfo struct {
  2556. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2557. AcctPay float64 `json:"acct_pay"`
  2558. ActPayDedc float64 `json:"act_pay_dedc"`
  2559. Age float64 `json:"age"`
  2560. Balc float64 `json:"balc"`
  2561. Brdy string `json:"brdy"`
  2562. Certno string `json:"certno"`
  2563. ClrOptins string `json:"clr_optins"`
  2564. ClrType string `json:"clr_type"`
  2565. ClrWay string `json:"clr_way"`
  2566. CvlservFlag string `json:"cvlserv_flag"`
  2567. CvlservPay float64 `json:"cvlserv_pay"`
  2568. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2569. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2570. Gend string `json:"gend"`
  2571. HifesPay float64 `json:"hifes_pay"`
  2572. HifmiPay float64 `json:"hifmi_pay"`
  2573. HifpPay float64 `json:"hifp_pay"`
  2574. HospPartAmt float64 `json:"hosp_part_amt"`
  2575. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2576. Insutype string `json:"insutype"`
  2577. MafPay float64 `json:"maf_pay"`
  2578. MdtrtCertType string `json:"mdtrt_cert_type"`
  2579. HifobPay float64 `json:"hifob_pay"`
  2580. MdtrtID string `json:"mdtrt_id"`
  2581. MedType string `json:"med_type"`
  2582. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2583. MedinsSetlID string `json:"medins_setl_id"`
  2584. Naty string `json:"naty"`
  2585. OthPay float64 `json:"oth_pay"`
  2586. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2587. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2588. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2589. PsnCashPay float64 `json:"psn_cash_pay"`
  2590. PsnCertType string `json:"psn_cert_type"`
  2591. PsnName string `json:"psn_name"`
  2592. PsnNo string `json:"psn_no"`
  2593. PsnPartAmt float64 `json:"psn_part_amt"`
  2594. PsnType string `json:"psn_type"`
  2595. SetlID string `json:"setl_id"`
  2596. SetlTime string `json:"setl_time"`
  2597. } `json:"setlinfo"`
  2598. } `json:"output"`
  2599. RefmsgTime string `json:"refmsg_time"`
  2600. RespondTime string `json:"respond_time"`
  2601. Signtype interface{} `json:"signtype"`
  2602. WarnMsg interface{} `json:"warn_msg"`
  2603. }
  2604. type ResultEight struct {
  2605. Cainfo string `json:"cainfo"`
  2606. ErrMsg string `json:"err_msg"`
  2607. InfRefmsgid string `json:"inf_refmsgid"`
  2608. Infcode int64 `json:"infcode"`
  2609. Output struct {
  2610. Stmtinfo struct {
  2611. SetlOptins string `json:"setl_optins"`
  2612. StmtRslt string `json:"stmt_rslt"`
  2613. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2614. } `json:"stmtinfo"`
  2615. } `json:"output"`
  2616. RefmsgTime string `json:"refmsg_time"`
  2617. RespondTime string `json:"respond_time"`
  2618. Signtype interface{} `json:"signtype"`
  2619. WarnMsg interface{} `json:"warn_msg"`
  2620. }
  2621. type ResultEightFor10188 struct {
  2622. Cainfo string `json:"cainfo"`
  2623. ErrMsg string `json:"err_msg"`
  2624. InfRefmsgid string `json:"inf_refmsgid"`
  2625. Infcode string `json:"infcode"`
  2626. Output struct {
  2627. Stmtinfo struct {
  2628. SetlOptins string `json:"setl_optins"`
  2629. StmtRslt string `json:"stmt_rslt"`
  2630. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2631. } `json:"stmtinfo"`
  2632. } `json:"output"`
  2633. RefmsgTime string `json:"refmsg_time"`
  2634. RespondTime string `json:"respond_time"`
  2635. Signtype interface{} `json:"signtype"`
  2636. WarnMsg interface{} `json:"warn_msg"`
  2637. }
  2638. type ResultNine struct {
  2639. Cainfo string `json:"cainfo"`
  2640. ErrMsg string `json:"err_msg"`
  2641. InfRefmsgid string `json:"inf_refmsgid"`
  2642. Infcode int64 `json:"infcode"`
  2643. Output struct {
  2644. FileQuryNo string `json:"file_qury_no"`
  2645. } `json:"output"`
  2646. RefmsgTime string `json:"refmsg_time"`
  2647. RespondTime string `json:"respond_time"`
  2648. Signtype interface{} `json:"signtype"`
  2649. WarnMsg interface{} `json:"warn_msg"`
  2650. }
  2651. type ResultTen struct {
  2652. Cainfo string `json:"cainfo"`
  2653. ErrMsg string `json:"err_msg"`
  2654. InfRefmsgid string `json:"inf_refmsgid"`
  2655. Infcode int64 `json:"infcode"`
  2656. Output struct {
  2657. DldEndtime string `json:"dld_endtime"`
  2658. FileQuryNo string `json:"file_qury_no"`
  2659. Filename string `json:"filename"`
  2660. } `json:"output"`
  2661. RefmsgTime string `json:"refmsg_time"`
  2662. RespondTime string `json:"respond_time"`
  2663. Signtype interface{} `json:"signtype"`
  2664. WarnMsg interface{} `json:"warn_msg"`
  2665. }
  2666. //type Autogenerated struct {
  2667. // Output struct {
  2668. // Setlinfo struct {
  2669. // SetlTime string `json:"setl_time"`
  2670. // CvlservPay float64 `json:"cvlserv_pay"`
  2671. // Year string `json:"year"`
  2672. // MedType string `json:"med_type"`
  2673. // PsnPay float64 `json:"psn_pay"`
  2674. // OpterID string `json:"opter_id"`
  2675. // Begndate string `json:"begndate"`
  2676. // FlxempeFlag string `json:"flxempe_flag"`
  2677. // HifmiPay float64 `json:"hifmi_pay"`
  2678. // PsnNo string `json:"psn_no"`
  2679. // ActPayDedc float64 `json:"act_pay_dedc"`
  2680. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2681. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2682. // ClrWay string `json:"clr_way"`
  2683. // OthPay float64 `json:"oth_pay"`
  2684. // Gend string `json:"gend"`
  2685. // MdtrtID string `json:"mdtrt_id"`
  2686. // AcctPay float64 `json:"acct_pay"`
  2687. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2688. // Insutype string `json:"insutype"`
  2689. // Invono interface{} `json:"invono"`
  2690. // Enddate string `json:"enddate"`
  2691. // CashPayamt float64 `json:"cash_payamt"`
  2692. // PsnType string `json:"psn_type"`
  2693. // FixmedinsName string `json:"fixmedins_name"`
  2694. // HifpPay float64 `json:"hifp_pay"`
  2695. // NewFlag interface{} `json:"new_flag"`
  2696. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2697. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2698. // PayLoc string `json:"pay_loc"`
  2699. // ClrType string `json:"clr_type"`
  2700. // RefdSetlFlag string `json:"refd_setl_flag"`
  2701. // CvlservFlag string `json:"cvlserv_flag"`
  2702. // EmpName string `json:"emp_name"`
  2703. // Brdy string `json:"brdy"`
  2704. // Naty string `json:"naty"`
  2705. // Certno string `json:"certno"`
  2706. // DiseCode string `json:"dise_code"`
  2707. // FixmedinsCode string `json:"fixmedins_code"`
  2708. // DedcHospLv string `json:"dedc_hosp_lv"`
  2709. // OpterName string `json:"opter_name"`
  2710. // Balc float64 `json:"balc"`
  2711. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2712. // PsnCertType string `json:"psn_cert_type"`
  2713. // HifobPay float64 `json:"hifob_pay"`
  2714. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2715. // HifesPay float64 `json:"hifes_pay"`
  2716. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2717. // OptTime string `json:"opt_time"`
  2718. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2719. // SetlID string `json:"setl_id"`
  2720. // MafPay float64 `json:"maf_pay"`
  2721. // PsnName string `json:"psn_name"`
  2722. // InsuOptins interface{} `json:"insu_optins"`
  2723. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2724. // ClrOptins string `json:"clr_optins"`
  2725. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2726. // DiseName string `json:"dise_name"`
  2727. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2728. // Age float64 `json:"age"`
  2729. // DtrtCertType string `json:"dtrt_cert_type"`
  2730. // HospLv string `json:"hosp_lv"`
  2731. // } `json:"setlinfo"`
  2732. // Setldetail []struct {
  2733. // FundPayType string `json:"fund_pay_type"`
  2734. // FundPayamt float64 `json:"fund_payamt"`
  2735. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2736. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2737. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2738. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2739. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2740. // } `json:"setldetail"`
  2741. // } `json:"output"`
  2742. // Infcode int `json:"infcode"`
  2743. // WarnMsg interface{} `json:"warn_msg"`
  2744. // Cainfo interface{} `json:"cainfo"`
  2745. // ErrMsg interface{} `json:"err_msg"`
  2746. // RefmsgTime string `json:"refmsg_time"`
  2747. // Signtype interface{} `json:"signtype"`
  2748. // RespondTime string `json:"respond_time"`
  2749. // InfRefmsgid string `json:"inf_refmsgid"`
  2750. //}
  2751. type ResultEleven struct {
  2752. Cainfo string `json:"cainfo"`
  2753. ErrMsg string `json:"err_msg"`
  2754. InfRefmsgid string `json:"inf_refmsgid"`
  2755. Infcode int64 `json:"infcode"`
  2756. Output struct {
  2757. Setlinfo struct {
  2758. SetlTime string `json:"setl_time"`
  2759. CvlservPay float64 `json:"cvlserv_pay"`
  2760. Year string `json:"year"`
  2761. MedType string `json:"med_type"`
  2762. PsnPay float64 `json:"psn_pay"`
  2763. OpterID string `json:"opter_id"`
  2764. Begndate string `json:"begndate"`
  2765. FlxempeFlag string `json:"flxempe_flag"`
  2766. HifmiPay float64 `json:"hifmi_pay"`
  2767. PsnNo string `json:"psn_no"`
  2768. ActPayDedc float64 `json:"act_pay_dedc"`
  2769. MedinsSetlID interface{} `json:"medins_setl_id"`
  2770. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2771. ClrWay string `json:"clr_way"`
  2772. OthPay float64 `json:"oth_pay"`
  2773. Gend string `json:"gend"`
  2774. MdtrtID string `json:"mdtrt_id"`
  2775. AcctPay float64 `json:"acct_pay"`
  2776. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2777. Insutype string `json:"insutype"`
  2778. Invono interface{} `json:"invono"`
  2779. Enddate string `json:"enddate"`
  2780. CashPayamt float64 `json:"cash_payamt"`
  2781. PsnType string `json:"psn_type"`
  2782. FixmedinsName string `json:"fixmedins_name"`
  2783. HifpPay float64 `json:"hifp_pay"`
  2784. NewFlag interface{} `json:"new_flag"`
  2785. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2786. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2787. PayLoc string `json:"pay_loc"`
  2788. ClrType string `json:"clr_type"`
  2789. RefdSetlFlag string `json:"refd_setl_flag"`
  2790. CvlservFlag string `json:"cvlserv_flag"`
  2791. EmpName string `json:"emp_name"`
  2792. Brdy string `json:"brdy"`
  2793. Naty string `json:"naty"`
  2794. Certno string `json:"certno"`
  2795. DiseCode string `json:"dise_code"`
  2796. FixmedinsCode string `json:"fixmedins_code"`
  2797. DedcHospLv string `json:"dedc_hosp_lv"`
  2798. OpterName string `json:"opter_name"`
  2799. Balc float64 `json:"balc"`
  2800. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2801. PsnCertType string `json:"psn_cert_type"`
  2802. HifobPay float64 `json:"hifob_pay"`
  2803. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2804. HifesPay float64 `json:"hifes_pay"`
  2805. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2806. OptTime string `json:"opt_time"`
  2807. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2808. SetlID string `json:"setl_id"`
  2809. MafPay float64 `json:"maf_pay"`
  2810. PsnName string `json:"psn_name"`
  2811. InsuOptins interface{} `json:"insu_optins"`
  2812. PrefFundPay interface{} `json:"pref_fund_pay"`
  2813. ClrOptins string `json:"clr_optins"`
  2814. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2815. DiseName string `json:"dise_name"`
  2816. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2817. Age float64 `json:"age"`
  2818. DtrtCertType string `json:"dtrt_cert_type"`
  2819. HospLv string `json:"hosp_lv"`
  2820. } `json:"setlinfo"`
  2821. } `json:"output"`
  2822. RefmsgTime string `json:"refmsg_time"`
  2823. RespondTime string `json:"respond_time"`
  2824. Signtype interface{} `json:"signtype"`
  2825. WarnMsg interface{} `json:"warn_msg"`
  2826. }
  2827. type ResultEleven10265 struct {
  2828. Cainfo string `json:"cainfo"`
  2829. ErrMsg string `json:"err_msg"`
  2830. InfRefmsgid string `json:"inf_refmsgid"`
  2831. Infcode string `json:"infcode"`
  2832. Output struct {
  2833. Setlinfo struct {
  2834. SetlTime string `json:"setl_time"`
  2835. CvlservPay float64 `json:"cvlserv_pay"`
  2836. Year string `json:"year"`
  2837. MedType string `json:"med_type"`
  2838. PsnPay float64 `json:"psn_pay"`
  2839. OpterID string `json:"opter_id"`
  2840. Begndate string `json:"begndate"`
  2841. FlxempeFlag string `json:"flxempe_flag"`
  2842. HifmiPay float64 `json:"hifmi_pay"`
  2843. PsnNo string `json:"psn_no"`
  2844. ActPayDedc float64 `json:"act_pay_dedc"`
  2845. MedinsSetlID interface{} `json:"medins_setl_id"`
  2846. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2847. ClrWay string `json:"clr_way"`
  2848. OthPay float64 `json:"oth_pay"`
  2849. Gend string `json:"gend"`
  2850. MdtrtID string `json:"mdtrt_id"`
  2851. AcctPay float64 `json:"acct_pay"`
  2852. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2853. Insutype string `json:"insutype"`
  2854. Invono interface{} `json:"invono"`
  2855. Enddate string `json:"enddate"`
  2856. CashPayamt float64 `json:"cash_payamt"`
  2857. PsnType string `json:"psn_type"`
  2858. FixmedinsName string `json:"fixmedins_name"`
  2859. HifpPay float64 `json:"hifp_pay"`
  2860. NewFlag interface{} `json:"new_flag"`
  2861. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2862. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2863. PayLoc string `json:"pay_loc"`
  2864. ClrType string `json:"clr_type"`
  2865. RefdSetlFlag string `json:"refd_setl_flag"`
  2866. CvlservFlag string `json:"cvlserv_flag"`
  2867. EmpName string `json:"emp_name"`
  2868. Brdy string `json:"brdy"`
  2869. Naty string `json:"naty"`
  2870. Certno string `json:"certno"`
  2871. DiseCode string `json:"dise_code"`
  2872. FixmedinsCode string `json:"fixmedins_code"`
  2873. DedcHospLv string `json:"dedc_hosp_lv"`
  2874. OpterName string `json:"opter_name"`
  2875. Balc float64 `json:"balc"`
  2876. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2877. PsnCertType string `json:"psn_cert_type"`
  2878. HifobPay float64 `json:"hifob_pay"`
  2879. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2880. HifesPay float64 `json:"hifes_pay"`
  2881. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2882. OptTime string `json:"opt_time"`
  2883. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2884. SetlID string `json:"setl_id"`
  2885. MafPay float64 `json:"maf_pay"`
  2886. PsnName string `json:"psn_name"`
  2887. InsuOptins interface{} `json:"insu_optins"`
  2888. PrefFundPay interface{} `json:"pref_fund_pay"`
  2889. ClrOptins string `json:"clr_optins"`
  2890. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2891. DiseName string `json:"dise_name"`
  2892. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2893. Age float64 `json:"age"`
  2894. DtrtCertType string `json:"dtrt_cert_type"`
  2895. HospLv string `json:"hosp_lv"`
  2896. } `json:"setlinfo"`
  2897. } `json:"output"`
  2898. RefmsgTime string `json:"refmsg_time"`
  2899. RespondTime string `json:"respond_time"`
  2900. Signtype interface{} `json:"signtype"`
  2901. WarnMsg interface{} `json:"warn_msg"`
  2902. }
  2903. type ResultTwelve struct {
  2904. Cainfo string `json:"cainfo"`
  2905. ErrMsg string `json:"err_msg"`
  2906. InfRefmsgid string `json:"inf_refmsgid"`
  2907. Infcode int64 `json:"infcode"`
  2908. Output struct {
  2909. MdtrtId string `json:"mdtrt_id"`
  2910. ChrgBchno string `json:"chrg_bchno"`
  2911. PsnNo string `json:"psn_no"`
  2912. } `json:"output"`
  2913. RefmsgTime string `json:"refmsg_time"`
  2914. RespondTime string `json:"respond_time"`
  2915. Signtype interface{} `json:"signtype"`
  2916. WarnMsg interface{} `json:"warn_msg"`
  2917. }
  2918. type ResultThirteen struct {
  2919. ErrMsg string `json:"err_msg"`
  2920. InfRefmsgid string `json:"inf_refmsgid"`
  2921. Infcode int64 `json:"infcode"`
  2922. Output struct {
  2923. Result struct {
  2924. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2925. } `json:"result"`
  2926. } `json:"output"`
  2927. RefmsgTime string `json:"refmsg_time"`
  2928. RespondTime string `json:"respond_time"`
  2929. Signtype interface{} `json:"signtype"`
  2930. WarnInfo interface{} `json:"warn_info"`
  2931. }
  2932. type ResultThirteen10265 struct {
  2933. ErrMsg string `json:"err_msg"`
  2934. InfRefmsgid string `json:"inf_refmsgid"`
  2935. Infcode string `json:"infcode"`
  2936. Output struct {
  2937. Result struct {
  2938. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2939. } `json:"result"`
  2940. } `json:"output"`
  2941. RefmsgTime string `json:"refmsg_time"`
  2942. RespondTime string `json:"respond_time"`
  2943. Signtype interface{} `json:"signtype"`
  2944. WarnInfo interface{} `json:"warn_info"`
  2945. }
  2946. type ResultFourteen struct {
  2947. ErrMsg string `json:"err_msg"`
  2948. InfRefmsgid string `json:"inf_refmsgid"`
  2949. Infcode int64 `json:"infcode"`
  2950. Output struct {
  2951. } `json:"output"`
  2952. RefmsgTime string `json:"refmsg_time"`
  2953. RespondTime string `json:"respond_time"`
  2954. Signtype interface{} `json:"signtype"`
  2955. WarnInfo interface{} `json:"warn_info"`
  2956. }
  2957. type ResultFourteen10265 struct {
  2958. ErrMsg string `json:"err_msg"`
  2959. InfRefmsgid string `json:"inf_refmsgid"`
  2960. Infcode string `json:"infcode"`
  2961. Output struct {
  2962. } `json:"output"`
  2963. RefmsgTime string `json:"refmsg_time"`
  2964. RespondTime string `json:"respond_time"`
  2965. Signtype interface{} `json:"signtype"`
  2966. WarnInfo interface{} `json:"warn_info"`
  2967. }
  2968. type ResultSixteen struct {
  2969. Cainfo string `json:"cainfo"`
  2970. ErrMsg string `json:"err_msg"`
  2971. InfRefmsgid string `json:"inf_refmsgid"`
  2972. Infcode int64 `json:"infcode"`
  2973. Output struct {
  2974. Setldetail []interface{} `json:"setldetail"`
  2975. Setlinfo struct {
  2976. MdtrtID string `json:"mdtrt_id"`
  2977. SetlID string `json:"setl_id"`
  2978. ClrOptins string `json:"clr_optins"`
  2979. SetlTime string `json:"setl_time"`
  2980. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2981. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2982. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2983. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2984. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2985. ActPayDedc float64 `json:"act_pay_dedc"`
  2986. HifpPay float64 `json:"hifp_pay"`
  2987. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2988. Lfpay float64 `json:"selfpay"`
  2989. CvlservPay float64 `json:"cvlserv_pay"`
  2990. HifesPay float64 `json:"hifes_pay"`
  2991. HifmiPay float64 `json:"hifmi_pay"`
  2992. HifobPay float64 `json:"hifob_pay"`
  2993. MafPay float64 `json:"maf_pay"`
  2994. OthPay float64 `json:"oth_pay"`
  2995. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2996. PsnPartAmt float64 `json:"psn_part_amt"`
  2997. AcctPay float64 `json:"acct_pay"`
  2998. Balc float64 `json:"balc"`
  2999. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3000. HospPartAmt float64 `json:"hosp_part_amt"`
  3001. MedinsSetlID string `json:"medins_setl_id"`
  3002. PdnCashPay string `json:"pdn_cash_pay"`
  3003. } `json:"setlinfo"`
  3004. } `json:"output"`
  3005. RefmsgTime string `json:"refmsg_time"`
  3006. RespondTime string `json:"respond_time"`
  3007. Signtype interface{} `json:"signtype"`
  3008. WarnMsg interface{} `json:"warn_msg"`
  3009. }
  3010. type ResultSixteen10265 struct {
  3011. Cainfo string `json:"cainfo"`
  3012. ErrMsg string `json:"err_msg"`
  3013. InfRefmsgid string `json:"inf_refmsgid"`
  3014. Infcode string `json:"infcode"`
  3015. Output struct {
  3016. Setldetail []interface{} `json:"setldetail"`
  3017. Setlinfo struct {
  3018. MdtrtID string `json:"mdtrt_id"`
  3019. SetlID string `json:"setl_id"`
  3020. ClrOptins string `json:"clr_optins"`
  3021. SetlTime string `json:"setl_time"`
  3022. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3023. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3024. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3025. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3026. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3027. ActPayDedc float64 `json:"act_pay_dedc"`
  3028. HifpPay float64 `json:"hifp_pay"`
  3029. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3030. Lfpay float64 `json:"selfpay"`
  3031. CvlservPay float64 `json:"cvlserv_pay"`
  3032. HifesPay float64 `json:"hifes_pay"`
  3033. HifmiPay float64 `json:"hifmi_pay"`
  3034. HifobPay float64 `json:"hifob_pay"`
  3035. MafPay float64 `json:"maf_pay"`
  3036. OthPay float64 `json:"oth_pay"`
  3037. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3038. PsnPartAmt float64 `json:"psn_part_amt"`
  3039. AcctPay float64 `json:"acct_pay"`
  3040. Balc float64 `json:"balc"`
  3041. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3042. HospPartAmt float64 `json:"hosp_part_amt"`
  3043. MedinsSetlID string `json:"medins_setl_id"`
  3044. PdnCashPay string `json:"pdn_cash_pay"`
  3045. } `json:"setlinfo"`
  3046. } `json:"output"`
  3047. RefmsgTime string `json:"refmsg_time"`
  3048. RespondTime string `json:"respond_time"`
  3049. Signtype interface{} `json:"signtype"`
  3050. WarnMsg interface{} `json:"warn_msg"`
  3051. }
  3052. type ResultSeventeen struct {
  3053. ErrMsg string `json:"err_msg"`
  3054. InfRefmsgid string `json:"inf_refmsgid"`
  3055. Infcode int64 `json:"infcode"`
  3056. Output struct {
  3057. SetlListId string `json:"setl_list_id"`
  3058. } `json:"output"`
  3059. RefmsgTime string `json:"refmsg_time"`
  3060. RespondTime string `json:"respond_time"`
  3061. Signtype string `json:"signtype"`
  3062. WarnInfo string `json:"warn_info"`
  3063. }
  3064. type Result90991 struct {
  3065. ErrMsg string `json:"err_msg"`
  3066. InfRefmsgid string `json:"inf_refmsgid"`
  3067. Infcode int64 `json:"infcode"`
  3068. Output struct {
  3069. Result struct {
  3070. PsnNo string `json:"psn_no"`
  3071. CardStat string `json:"card_stat"`
  3072. Certno string `json:"certno"`
  3073. PsnName string `json:"psn_name"`
  3074. CheckStat string `json:"check_stat"`
  3075. } `json:"result"`
  3076. } `json:"output"`
  3077. RefmsgTime string `json:"refmsg_time"`
  3078. RespondTime string `json:"respond_time"`
  3079. Signtype interface{} `json:"signtype"`
  3080. WarnInfo interface{} `json:"warn_info"`
  3081. }
  3082. type Result90100 struct {
  3083. ErrMsg string `json:"err_msg"`
  3084. InfRefmsgid string `json:"inf_refmsgid"`
  3085. Infcode int64 `json:"infcode"`
  3086. Output struct {
  3087. PoolareaNo string `json:"poolarea_no"`
  3088. PoolareaNoName string `json:"poolarea_no_name"`
  3089. Insutype string `json:"insutype"`
  3090. InsutypeName string `json:"insutype_name"`
  3091. ClctType string `json:"clct_type"`
  3092. ClctTypeName string `json:"clct_type_name"`
  3093. ClctFlag string `json:"clct_flag"`
  3094. ClctFlagName string `json:"clct_flag_name"`
  3095. AccrymBegn string `json:"accrym_begn"`
  3096. AccrymEnd string `json:"accrym_end"`
  3097. ClctTime string `json:"clct_time"`
  3098. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3099. } `json:"output"`
  3100. RefmsgTime string `json:"refmsg_time"`
  3101. RespondTime string `json:"respond_time"`
  3102. Signtype interface{} `json:"signtype"`
  3103. WarnInfo interface{} `json:"warn_info"`
  3104. }
  3105. type Custom struct {
  3106. DetItemFeeSumamt string
  3107. Cut string
  3108. FeedetlSn string
  3109. Price string
  3110. MedListCodg string
  3111. Type int64
  3112. AdviceId int64
  3113. ProjectId int64
  3114. ItemId int64
  3115. }
  3116. type Result5301 struct {
  3117. ErrMsg string `json:"err_msg"`
  3118. InfRefmsgid string `json:"inf_refmsgid"`
  3119. Infcode int64 `json:"infcode"`
  3120. Output struct {
  3121. Result []struct {
  3122. OpspDiseCode string `json:"opsp_dise_code"`
  3123. OpspDiseName string `json:"opsp_dise_name"`
  3124. Begndate string `json:"begndate"`
  3125. Enddate string `json:"enddate"`
  3126. } `json:"feedetail"`
  3127. } `json:"output"`
  3128. RefmsgTime string `json:"refmsg_time"`
  3129. RespondTime string `json:"respond_time"`
  3130. Signtype interface{} `json:"signtype"`
  3131. WarnInfo interface{} `json:"warn_info"`
  3132. }
  3133. type Result5301For10265 struct {
  3134. ErrMsg string `json:"err_msg"`
  3135. InfRefmsgid string `json:"inf_refmsgid"`
  3136. Infcode string `json:"infcode"`
  3137. Output struct {
  3138. Result []struct {
  3139. OpspDiseCode string `json:"opsp_dise_code"`
  3140. OpspDiseName string `json:"opsp_dise_name"`
  3141. Begndate string `json:"begndate"`
  3142. Enddate string `json:"enddate"`
  3143. } `json:"feedetail"`
  3144. } `json:"output"`
  3145. RefmsgTime string `json:"refmsg_time"`
  3146. RespondTime string `json:"respond_time"`
  3147. Signtype interface{} `json:"signtype"`
  3148. WarnInfo interface{} `json:"warn_info"`
  3149. }
  3150. //获取个人信息----挂号-----上传就诊信息
  3151. func (c *HisApiController) GetRegisterInfo() {
  3152. id, _ := c.GetInt64("id")
  3153. record_time := c.GetString("record_time")
  3154. settlementValue, _ := c.GetInt64("settlement_value")
  3155. medical_insurance_card := c.GetString("medical_insurance_card")
  3156. name := c.GetString("name")
  3157. id_card_type, _ := c.GetInt64("id_card_type")
  3158. certificates, _ := c.GetInt64("certificates")
  3159. medical_care, _ := c.GetInt64("medical_care")
  3160. birthday := c.GetString("birthday")
  3161. id_card := c.GetString("id_card")
  3162. register_type, _ := c.GetInt64("register")
  3163. doctor, _ := c.GetInt64("doctor")
  3164. department, _ := c.GetInt64("department")
  3165. gender, _ := c.GetInt64("sex")
  3166. registration_fee, _ := c.GetFloat("registration_fee")
  3167. medical_expenses, _ := c.GetFloat("medical_expenses")
  3168. social_type, _ := c.GetInt64("social_type")
  3169. med_type := c.GetString("social_type")
  3170. admin_user_id, _ := c.GetInt64("admin_user_id")
  3171. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3172. timeLayout := "2006-01-02"
  3173. loc, _ := time.LoadLocation("Local")
  3174. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3175. birthUnix := birthdays.Unix()
  3176. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3177. if err != nil {
  3178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3179. return
  3180. }
  3181. recordDateTime := theTime.Unix()
  3182. adminInfo := c.GetAdminUserInfo()
  3183. var patient service.Patients
  3184. if id == 0 {
  3185. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3186. } else {
  3187. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3188. }
  3189. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3190. if patientPrescription.ID == 0 {
  3191. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3192. }
  3193. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3194. if patient.ID == 0 {
  3195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3196. return
  3197. }
  3198. if len(patient.IdCardNo) == 0 {
  3199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3200. return
  3201. }
  3202. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3203. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3204. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3205. //就诊结算未完成,不能进行二次挂号
  3206. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3207. if len(his) >= 1 {
  3208. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3209. if len(his) >= 1 && order.ID == 0 {
  3210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3211. return
  3212. }
  3213. }
  3214. //var register_log string
  3215. if config.IsOpen == 1 {
  3216. var res ResultTwo
  3217. var res10265 ResultTwo10265
  3218. var PsnNo string
  3219. var PsnCertType string
  3220. var Certno string
  3221. var PsnName string
  3222. var Gend string
  3223. var Naty string
  3224. var Brdy string
  3225. var Age float64
  3226. var infoStr string
  3227. var idetinfoStr string
  3228. var infocode int64
  3229. var verify_number string
  3230. fmt.Println(verify_number)
  3231. if miConfig.MdtrtareaAdmvs == "421300" {
  3232. psn_info, _ := service.GetPsnByPatientId(id)
  3233. PsnNo = psn_info.PsnNo
  3234. PsnCertType = psn_info.PsnCertType
  3235. Certno = psn_info.Certno
  3236. PsnName = psn_info.PsnName
  3237. Gend = psn_info.Gend
  3238. Naty = psn_info.Naty
  3239. Brdy = psn_info.Brdy
  3240. Age = psn_info.Age
  3241. infoStr = psn_info.Insuinfo
  3242. idetinfoStr = psn_info.Idetinfo
  3243. infocode = 0
  3244. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3245. psn_info, _ := service.GetPsnByPatientId(id)
  3246. PsnNo = psn_info.PsnNo
  3247. PsnCertType = psn_info.PsnCertType
  3248. Certno = psn_info.Certno
  3249. PsnName = psn_info.PsnName
  3250. Gend = psn_info.Gend
  3251. Naty = psn_info.Naty
  3252. Brdy = psn_info.Brdy
  3253. Age = psn_info.Age
  3254. infoStr = psn_info.Insuinfo
  3255. idetinfoStr = psn_info.Idetinfo
  3256. infocode = 0
  3257. verify_number = psn_info.VerifyNumber
  3258. } else {
  3259. var result string
  3260. var requestLog string
  3261. if miConfig.UserOrgId == 10138 {
  3262. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  3263. } else {
  3264. 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)
  3265. }
  3266. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3267. if miConfig.Code == "H15049901371" {
  3268. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3269. utils.ErrorLog("解析失败:%v", err)
  3270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3271. return
  3272. }
  3273. res.ErrMsg = res10265.ErrMsg
  3274. res.Output = res10265.Output
  3275. res.InfRefmsgid = res10265.InfRefmsgid
  3276. } else {
  3277. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3278. utils.ErrorLog("解析失败:%v", err)
  3279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3280. return
  3281. }
  3282. }
  3283. PsnNo = res.Output.Baseinfo.PsnNo
  3284. PsnCertType = res.Output.Baseinfo.PsnCertType
  3285. Certno = res.Output.Baseinfo.Certno
  3286. PsnName = res.Output.Baseinfo.PsnName
  3287. Gend = res.Output.Baseinfo.Gend
  3288. Naty = res.Output.Baseinfo.Naty
  3289. Brdy = res.Output.Baseinfo.Brdy
  3290. Age = res.Output.Baseinfo.Age
  3291. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3292. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3293. infoStr = string(Iinfos)
  3294. idetinfoStr = string(Idetinfos)
  3295. if miConfig.Code == "H15049901371" {
  3296. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3297. } else {
  3298. infocode = res.Infcode
  3299. }
  3300. }
  3301. if infocode == 0 {
  3302. his := models.VMHisPatient{
  3303. Name: name,
  3304. Gender: gender,
  3305. Birthday: birthUnix,
  3306. MedicalTreatmentType: medical_care,
  3307. IdType: certificates,
  3308. IdCardNo: id_card,
  3309. BalanceAccountsType: settlementValue,
  3310. SocialType: social_type,
  3311. MedicalInsuranceNumber: medical_insurance_card,
  3312. RegisterType: register_type,
  3313. RegisterCost: registration_fee,
  3314. TreatmentCost: medical_expenses,
  3315. Status: 1,
  3316. Ctime: time.Now().Unix(),
  3317. Mtime: time.Now().Unix(),
  3318. PsnNo: PsnNo,
  3319. PsnCertType: PsnCertType,
  3320. Certno: Certno,
  3321. PsnName: PsnName,
  3322. Gend: Gend,
  3323. Naty: Naty,
  3324. Brdy: Brdy,
  3325. Age: Age,
  3326. Iinfo: infoStr,
  3327. Idetinfo: idetinfoStr,
  3328. PatientId: patient.ID,
  3329. RecordDate: theTime.Unix(),
  3330. UserOrgId: adminInfo.CurrentOrgId,
  3331. AdminUserId: admin_user_id,
  3332. IsReturn: 1,
  3333. IdCardType: id_card_type,
  3334. Doctor: doctor,
  3335. Departments: department,
  3336. }
  3337. timestamp := time.Now().Unix()
  3338. tempTime := time.Unix(timestamp, 0)
  3339. timeFormat := tempTime.Format("20060102150405")
  3340. chrgBchno := rand.Intn(100000) + 10000
  3341. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3342. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3343. department, _ := service.GetDepartMentDetail(department)
  3344. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3345. IdCardNo := ""
  3346. if id_card_type == 1 {
  3347. // IdCardNo = medical_insurance_card
  3348. IdCardNo = patient.IdCardNo
  3349. } else {
  3350. IdCardNo = patient.IdCardNo
  3351. }
  3352. var rf []*ResultFive
  3353. json.Unmarshal([]byte(his.Iinfo), &rf)
  3354. var insutypes []*ResultFive
  3355. var insutype string
  3356. var insuplc_admdvs_temp string
  3357. var is390 int = 0
  3358. var is310 int = 0
  3359. for _, item := range rf {
  3360. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3361. insutypes = append(insutypes, item)
  3362. }
  3363. }
  3364. if len(insutypes) == 1 {
  3365. insutype = insutypes[0].Insutype
  3366. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3367. } else {
  3368. for _, i := range insutypes {
  3369. if i.Insutype == "390" {
  3370. is390 = 1
  3371. }
  3372. if i.Insutype == "310" {
  3373. is310 = 1
  3374. }
  3375. }
  3376. }
  3377. if is390 == 1 {
  3378. insutype = "390"
  3379. }
  3380. if is310 == 1 {
  3381. insutype = "310"
  3382. }
  3383. if len(insutypes) == 0 {
  3384. insutype = "310"
  3385. }
  3386. if len(insutypes) == 2 {
  3387. insutype = med_type
  3388. }
  3389. if len(med_type) > 0 {
  3390. insutype = med_type
  3391. }
  3392. //for _, item := range rf {
  3393. // if item.Insutype == insutype {
  3394. // insuplc_admdvs = item.InsuplcAdmdvs
  3395. // }
  3396. //}
  3397. var infocode int64
  3398. var resThree ResultThree
  3399. var resThree10265 ResultThree10265
  3400. if len(insuplc_admdvs) == 0 {
  3401. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3402. } else {
  3403. insuplc_admdvs_temp = insuplc_admdvs
  3404. }
  3405. if miConfig.MdtrtareaAdmvs == "421300" {
  3406. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3407. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3408. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&doctor_name=" + doctor_info.UserName
  3409. resp, requestErr := http.Get(api)
  3410. if requestErr != nil {
  3411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3412. return
  3413. }
  3414. body, ioErr := ioutil.ReadAll(resp.Body)
  3415. if ioErr != nil {
  3416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3418. return
  3419. }
  3420. var respJSON map[string]interface{}
  3421. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3422. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3424. return
  3425. }
  3426. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3427. result, _ := json.Marshal(respJSON)
  3428. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3429. utils.ErrorLog("解析失败:%v", err)
  3430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3431. return
  3432. }
  3433. infocode = resThree.Infcode
  3434. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3435. psn_info, _ := service.GetPsnByPatientId(id)
  3436. bas := strings.Split(psn_info.CardInfo, "|")
  3437. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3438. var api string
  3439. if miConfig.MdtrtareaAdmvs == "320921" {
  3440. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3441. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3442. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3443. } else {
  3444. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3445. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3446. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3447. }
  3448. resp, requestErr := http.Get(api)
  3449. if requestErr != nil {
  3450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3451. return
  3452. }
  3453. body, ioErr := ioutil.ReadAll(resp.Body)
  3454. if ioErr != nil {
  3455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3457. return
  3458. }
  3459. var respJSON map[string]interface{}
  3460. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3463. return
  3464. }
  3465. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3466. result, _ := json.Marshal(respJSON)
  3467. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3468. utils.ErrorLog("解析失败:%v", err)
  3469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3470. return
  3471. }
  3472. resThree.ErrMsg = resThree10265.ErrMsg
  3473. resThree.Output = resThree10265.Output
  3474. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3475. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3476. } else {
  3477. result, requestLog := service.Gdyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  3478. saveLog(result, requestLog, "2201", "挂号")
  3479. if miConfig.Code == "H15049901371" {
  3480. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3481. utils.ErrorLog("解析失败:%v", err)
  3482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3483. return
  3484. }
  3485. resThree.ErrMsg = resThree10265.ErrMsg
  3486. resThree.Output = resThree10265.Output
  3487. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3488. } else {
  3489. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3490. utils.ErrorLog("解析失败:%v", err)
  3491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3492. return
  3493. }
  3494. }
  3495. if miConfig.Code == "H15049901371" {
  3496. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3497. } else {
  3498. infocode = resThree.Infcode
  3499. }
  3500. }
  3501. if infocode != 0 {
  3502. adminUser := c.GetAdminUserInfo()
  3503. errlog := &models.HisOrderError{
  3504. UserOrgId: adminUser.CurrentOrgId,
  3505. Ctime: time.Now().Unix(),
  3506. Mtime: time.Now().Unix(),
  3507. ErrMsg: resThree.ErrMsg,
  3508. Status: 1,
  3509. PatientId: id,
  3510. RecordTime: recordDateTime,
  3511. Stage: 2,
  3512. }
  3513. service.CreateErrMsgLog(errlog)
  3514. c.ServeSuccessJSON(map[string]interface{}{
  3515. "failed_code": -10,
  3516. "msg": resThree.ErrMsg,
  3517. })
  3518. return
  3519. }
  3520. his.Number = resThree.Output.Data.MdtrtID
  3521. his.PsnNo = resThree.Output.Data.PsnNo
  3522. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3523. his.IdCardNo = patient.IdCardNo
  3524. his.PhoneNumber = patient.Phone
  3525. his.UserOrgId = adminInfo.CurrentOrgId
  3526. his.Insutype = insutype
  3527. his.Ctime = time.Now().Unix()
  3528. his.Mtime = time.Now().Unix()
  3529. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3530. his.Status = 1
  3531. service.UpdateHisPatientStatus(&his)
  3532. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3533. c.ServeSuccessJSON(map[string]interface{}{
  3534. "his_info": his,
  3535. })
  3536. } else {
  3537. adminUser := c.GetAdminUserInfo()
  3538. errlog := &models.HisOrderError{
  3539. UserOrgId: adminUser.CurrentOrgId,
  3540. Ctime: time.Now().Unix(),
  3541. Mtime: time.Now().Unix(),
  3542. ErrMsg: res.ErrMsg,
  3543. Status: 1,
  3544. PatientId: id,
  3545. RecordTime: recordDateTime,
  3546. Stage: 1,
  3547. }
  3548. service.CreateErrMsgLog(errlog)
  3549. c.ServeSuccessJSON(map[string]interface{}{
  3550. "failed_code": -10,
  3551. "msg": res.ErrMsg,
  3552. })
  3553. return
  3554. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3555. }
  3556. }
  3557. }
  3558. //上传明细----预结算----确认订单
  3559. func (c *HisApiController) GetUploadInfo() {
  3560. id, _ := c.GetInt64("id")
  3561. record_time := c.GetString("record_time")
  3562. his_patient_id, _ := c.GetInt64("his_patient_id")
  3563. order_id, _ := c.GetInt64("order_id")
  3564. pay_way, _ := c.GetInt64("pay_way")
  3565. pay_price, _ := c.GetFloat("pay_price")
  3566. pay_card_no := c.GetString("pay_card_no")
  3567. discount_price, _ := c.GetFloat("discount_price")
  3568. preferential_price, _ := c.GetFloat("preferential_price")
  3569. reality_price, _ := c.GetFloat("reality_price")
  3570. found_price, _ := c.GetFloat("found_price")
  3571. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3572. private_price, _ := c.GetFloat("private_price")
  3573. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3574. admin_user_id, _ := c.GetInt64("admin_user_id")
  3575. fapiao_code := c.GetString("fapiao_code")
  3576. fapiao_number := c.GetString("fapiao_number")
  3577. diagnosis_id := c.GetString("diagnosis")
  3578. sick_type, _ := c.GetInt64("sick_type")
  3579. reg_type, _ := c.GetInt64("p_type")
  3580. begin_time := c.GetString("begin_time")
  3581. id_str := c.GetString("ids")
  3582. ids_arr := strings.Split(id_str, ",")
  3583. timeLayout := "2006-01-02"
  3584. loc, _ := time.LoadLocation("Local")
  3585. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3586. if err != nil {
  3587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3588. return
  3589. }
  3590. recordDateTime := theTime.Unix()
  3591. adminUser := c.GetAdminUserInfo()
  3592. var tempOrder models.HisOrder
  3593. tempOrder, _ = service.GetHisOrderByID(order_id)
  3594. var prescriptions []*models.HisPrescription
  3595. var start_time int64
  3596. var end_time int64
  3597. //if adminUser.CurrentOrgId == 10106{
  3598. // if len(fapiao_code) == 0{
  3599. // fapiao_code = "144072080589"
  3600. // }
  3601. // if len(fapiao_number) == 0{
  3602. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3603. // if order.ID == 0{
  3604. // fapiao_number = "00001520"
  3605. // }else{
  3606. // //fapiao_code = "00001520"
  3607. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3608. // var zero string
  3609. // if fpNumber >= 1000{
  3610. // zero = "0000" + strconv.Itoa(fpNumber)
  3611. // }else if fpNumber >= 10000{
  3612. // zero = "000" + strconv.Itoa(fpNumber)
  3613. // } else if fpNumber >= 100000{
  3614. // zero = "00" + strconv.Itoa(fpNumber)
  3615. // } else if fpNumber >= 1000000{
  3616. // zero = "0" + strconv.Itoa(fpNumber)
  3617. // }else {
  3618. // zero = strconv.Itoa(fpNumber)
  3619. // }
  3620. // fapiao_number = zero
  3621. // }
  3622. // }
  3623. //}
  3624. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3625. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3626. var patientPrescription models.HisPrescriptionInfo
  3627. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3628. if patientPrescription.ID == 0 {
  3629. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3630. }
  3631. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3632. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3633. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3634. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3635. var config []*models.HisXtDiagnoseConfig
  3636. for _, item := range diagnosis_ids {
  3637. id, _ := strconv.ParseInt(item, 10, 64)
  3638. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3639. config = append(config, &diagnosisConfig)
  3640. }
  3641. sickConfig, _ := service.FindSickById(sick_type)
  3642. //if tempOrder.ID == 0 {
  3643. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3644. //}
  3645. if tempOrder.ID == 0 {
  3646. var result string
  3647. var requestLog string
  3648. var res2 ResultSix
  3649. var ressix10265 ResultSix10265
  3650. if miConfig.MdtrtareaAdmvs == "421300" {
  3651. data := make(map[string]interface{})
  3652. client := &http.Client{}
  3653. data["psn_no"] = his.PsnNo
  3654. data["mdtrt_id"] = his.Number
  3655. data["doctor"] = roles.UserName
  3656. data["department"] = department.Name
  3657. data["org_name"] = miConfig.OrgName
  3658. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3659. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3660. data["fixmedins_code"] = miConfig.Code
  3661. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3662. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3663. data["secret_key"] = miConfig.SecretKey
  3664. data["sick_code"] = sickConfig.CountryCode
  3665. data["sick_name"] = sickConfig.ClassName
  3666. data["dept"] = strconv.FormatInt(department.ID, 10)
  3667. data["config"] = config
  3668. data["begin_time"] = begin_time
  3669. bytesData, _ := json.Marshal(data)
  3670. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3671. resp, _ := client.Do(req)
  3672. defer resp.Body.Close()
  3673. body, ioErr := ioutil.ReadAll(resp.Body)
  3674. if ioErr != nil {
  3675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3677. return
  3678. }
  3679. var respJSON map[string]interface{}
  3680. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3683. return
  3684. }
  3685. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3686. userJSONBytes, _ := json.Marshal(respJSON)
  3687. fmt.Println("log")
  3688. fmt.Println(string(userJSONBytes))
  3689. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3690. utils.ErrorLog("解析失败:%v", err)
  3691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3692. return
  3693. }
  3694. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3695. //江苏地区国家医保医疗类别
  3696. //职工透析:医疗类别选特殊情况门诊9933
  3697. //居民血透门慢: 医疗类别选门诊慢病1402
  3698. //var med_type string
  3699. //if his.Insutype == "310" {
  3700. // if reg_type == 14 {
  3701. // med_type = "9933"
  3702. // } else if reg_type == 11 {
  3703. // med_type = "11"
  3704. //
  3705. // }
  3706. //} else if his.Insutype == "390" {
  3707. // if reg_type == 14 {
  3708. // med_type = "1402"
  3709. // } else if reg_type == 11 {
  3710. // med_type = "11"
  3711. // }
  3712. //}
  3713. data := make(map[string]interface{})
  3714. client := &http.Client{}
  3715. data["psn_no"] = his.PsnNo
  3716. data["mdtrt_id"] = his.Number
  3717. data["doctor"] = roles.UserName
  3718. data["department"] = department.Name
  3719. data["org_name"] = miConfig.OrgName
  3720. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3721. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3722. data["fixmedins_code"] = miConfig.Code
  3723. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3724. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3725. data["secret_key"] = miConfig.SecretKey
  3726. data["sick_code"] = sickConfig.CountryCode
  3727. data["sick_name"] = sickConfig.ClassName
  3728. data["url"] = miConfig.Url
  3729. data["ak"] = miConfig.AccessKey
  3730. data["begin_time"] = begin_time
  3731. data["cainfo"] = miConfig.Cainfo
  3732. data["dept"] = strconv.FormatInt(department.ID, 10)
  3733. data["config"] = config
  3734. bytesData, _ := json.Marshal(data)
  3735. var req *http.Request
  3736. if miConfig.MdtrtareaAdmvs == "320921" {
  3737. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3738. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3739. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  3740. } else {
  3741. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3742. }
  3743. resp, _ := client.Do(req)
  3744. defer resp.Body.Close()
  3745. body, ioErr := ioutil.ReadAll(resp.Body)
  3746. if ioErr != nil {
  3747. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3749. return
  3750. }
  3751. var respJSON map[string]interface{}
  3752. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3755. return
  3756. }
  3757. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3758. userJSONBytes, _ := json.Marshal(respJSON)
  3759. fmt.Println("log")
  3760. fmt.Println(string(userJSONBytes))
  3761. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3762. utils.ErrorLog("解析失败:%v", err)
  3763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3764. return
  3765. }
  3766. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3767. res2.Output = ressix10265.Output
  3768. res2.ErrMsg = ressix10265.ErrMsg
  3769. res2.Cainfo = ressix10265.Cainfo
  3770. res2.WarnMsg = ressix10265.WarnMsg
  3771. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3772. res2.Infcode = infocode
  3773. } else {
  3774. if miConfig.MdtrtareaAdmvs == "440781" { //
  3775. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3776. } else {
  3777. if miConfig.Code == "H15049901371" {
  3778. //赤峰地区国家医保医疗类别
  3779. //职工透析:医疗类别选特殊情况门诊990502
  3780. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3781. var med_type string
  3782. if his.Insutype == "390" {
  3783. if reg_type == 14 {
  3784. med_type = "9933"
  3785. } else if reg_type == 11 {
  3786. med_type = "11"
  3787. }
  3788. } else if his.Insutype == "310" {
  3789. if reg_type == 14 {
  3790. med_type = "990502"
  3791. } else if reg_type == 11 {
  3792. med_type = "11"
  3793. }
  3794. }
  3795. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3796. } else {
  3797. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3798. }
  3799. }
  3800. saveLog(result, requestLog, "2203", "上传就诊信息")
  3801. var respJSON2 map[string]interface{}
  3802. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3805. return
  3806. }
  3807. userJSONBytes2, _ := json.Marshal(respJSON2)
  3808. if miConfig.Code == "H15049901371" {
  3809. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3810. utils.ErrorLog("解析失败:%v", err)
  3811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3812. return
  3813. }
  3814. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3815. res2.Output = ressix10265.Output
  3816. res2.ErrMsg = ressix10265.ErrMsg
  3817. res2.Cainfo = ressix10265.Cainfo
  3818. res2.WarnMsg = ressix10265.WarnMsg
  3819. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3820. res2.Infcode = infocode
  3821. } else {
  3822. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3823. utils.ErrorLog("解析失败:%v", err)
  3824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3825. return
  3826. }
  3827. }
  3828. }
  3829. if res2.Infcode != 0 {
  3830. adminUser := c.GetAdminUserInfo()
  3831. errlog := &models.HisOrderError{
  3832. UserOrgId: adminUser.CurrentOrgId,
  3833. Ctime: time.Now().Unix(),
  3834. Mtime: time.Now().Unix(),
  3835. ErrMsg: res2.ErrMsg,
  3836. Status: 1,
  3837. PatientId: id,
  3838. RecordTime: recordDateTime,
  3839. Stage: 3,
  3840. }
  3841. service.CreateErrMsgLog(errlog)
  3842. c.ServeSuccessJSON(map[string]interface{}{
  3843. "failed_code": -10,
  3844. "msg": res2.ErrMsg,
  3845. })
  3846. return
  3847. } else {
  3848. his.Diagnosis = diagnosis_id
  3849. his.SickType = sickConfig.ID
  3850. var p_type int64
  3851. if reg_type == 1111 || reg_type == 1112 {
  3852. p_type = 11
  3853. }
  3854. his.PType = fmt.Sprintf("%d", p_type)
  3855. service.UpdateHisPatientThree(&his)
  3856. data := make(map[string]interface{})
  3857. if settle_accounts_type == 1 { //日结
  3858. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3859. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3860. } else {
  3861. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3862. }
  3863. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3864. data["pre"] = prescriptions
  3865. } else { //月结
  3866. start_time_str := c.GetString("start_time")
  3867. end_time_str := c.GetString("end_time")
  3868. timeLayout := "2006-01-02"
  3869. loc, _ := time.LoadLocation("Local")
  3870. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3871. if err != nil {
  3872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3873. return
  3874. }
  3875. recordStartTime := theStartTime.Unix()
  3876. start_time = recordStartTime
  3877. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3878. if err != nil {
  3879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3880. return
  3881. }
  3882. recordEndTime := theEndTime.Unix()
  3883. end_time = recordEndTime
  3884. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3885. data["pre"] = prescriptions
  3886. }
  3887. timestamp := time.Now().Unix()
  3888. tempTime := time.Unix(timestamp, 0)
  3889. timeFormat := tempTime.Format("20060102150405")
  3890. chrgBchno := rand.Intn(100000) + 10000
  3891. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3892. strconv.FormatInt(his.PatientId, 10)
  3893. client := &http.Client{}
  3894. data["psn_no"] = his.PsnNo
  3895. data["mdtrt_id"] = his.Number
  3896. data["chrg_bchno"] = chrg_bchno
  3897. data["org_name"] = miConfig.OrgName
  3898. data["doctor"] = roles.UserName
  3899. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3900. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3901. data["fixmedins_code"] = miConfig.Code
  3902. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3903. // data["dept_code"] = "15"
  3904. //} else {
  3905. data["dept_code"] = department.Number
  3906. //}
  3907. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3908. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3909. data["secret_key"] = miConfig.SecretKey
  3910. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3911. data["url"] = miConfig.Url
  3912. data["ak"] = miConfig.AccessKey
  3913. data["new_doctor_name"] = patientPrescription.Doctor
  3914. data["diag_code"] = sickConfig.CountryCode
  3915. data["cainfo"] = miConfig.Cainfo
  3916. var ids []int64
  3917. for _, item := range prescriptions {
  3918. ids = append(ids, item.ID)
  3919. }
  3920. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3921. if config.IsOpen == 1 { //对接了医保,走医保流程
  3922. var res ResultFour
  3923. var resFour10265 ResultFour10265
  3924. if miConfig.MdtrtareaAdmvs == "421300" {
  3925. bytesData, _ := json.Marshal(data)
  3926. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3927. resp, _ := client.Do(req)
  3928. defer resp.Body.Close()
  3929. body, ioErr := ioutil.ReadAll(resp.Body)
  3930. if ioErr != nil {
  3931. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3933. return
  3934. }
  3935. var respJSON map[string]interface{}
  3936. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3939. return
  3940. }
  3941. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3942. userJSONBytes, _ := json.Marshal(respJSON)
  3943. fmt.Println("log")
  3944. fmt.Println(string(userJSONBytes))
  3945. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3946. utils.ErrorLog("解析失败:%v", err)
  3947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3948. return
  3949. }
  3950. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3951. bytesData, _ := json.Marshal(data)
  3952. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3953. resp, _ := client.Do(req)
  3954. defer resp.Body.Close()
  3955. body, ioErr := ioutil.ReadAll(resp.Body)
  3956. if ioErr != nil {
  3957. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3959. return
  3960. }
  3961. var respJSON map[string]interface{}
  3962. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3965. return
  3966. }
  3967. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3968. userJSONBytes, _ := json.Marshal(respJSON)
  3969. fmt.Println("log")
  3970. fmt.Println(string(userJSONBytes))
  3971. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3972. utils.ErrorLog("解析失败:%v", err)
  3973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3974. return
  3975. }
  3976. res.InfRefmsgid = resFour10265.InfRefmsgid
  3977. res.Output = resFour10265.Output
  3978. res.ErrMsg = resFour10265.ErrMsg
  3979. res.Cainfo = resFour10265.Cainfo
  3980. res.WarnMsg = resFour10265.WarnMsg
  3981. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3982. res.Infcode = infocode
  3983. } else {
  3984. if miConfig.Code == "H15049901371" {
  3985. 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)
  3986. var dat map[string]interface{}
  3987. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3988. fmt.Println(dat)
  3989. } else {
  3990. fmt.Println(err)
  3991. }
  3992. saveLog(result, request_log, "2204", "上传费用明细")
  3993. userJSONBytes, _ := json.Marshal(dat)
  3994. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3995. utils.ErrorLog("解析失败:%v", err)
  3996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3997. return
  3998. }
  3999. res.InfRefmsgid = resFour10265.InfRefmsgid
  4000. res.Output = resFour10265.Output
  4001. res.ErrMsg = resFour10265.ErrMsg
  4002. res.Cainfo = resFour10265.Cainfo
  4003. res.WarnMsg = resFour10265.WarnMsg
  4004. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4005. res.Infcode = infocode
  4006. } else {
  4007. 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)
  4008. var dat map[string]interface{}
  4009. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4010. fmt.Println(dat)
  4011. } else {
  4012. fmt.Println(err)
  4013. }
  4014. saveLog(result, request_log, "2204", "上传费用明细")
  4015. userJSONBytes, _ := json.Marshal(dat)
  4016. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4017. utils.ErrorLog("解析失败:%v", err)
  4018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4019. return
  4020. }
  4021. }
  4022. }
  4023. if res.Infcode == 0 {
  4024. order := &models.HisOrder{
  4025. UserOrgId: adminUser.CurrentOrgId,
  4026. HisPatientId: his.ID,
  4027. PatientId: his.PatientId,
  4028. SettleAccountsDate: recordDateTime,
  4029. MdtrtId: his.Number,
  4030. PsnNo: his.PsnNo,
  4031. MedType: strconv.FormatInt(reg_type, 10),
  4032. Ctime: time.Now().Unix(),
  4033. Mtime: time.Now().Unix(),
  4034. Status: 1,
  4035. Number: chrg_bchno,
  4036. Infcode: res.Infcode,
  4037. WarnMsg: res.WarnMsg,
  4038. Cainfo: res.Cainfo,
  4039. ErrMsg: res.ErrMsg,
  4040. RespondTime: res.RefmsgTime,
  4041. InfRefmsgid: res.InfRefmsgid,
  4042. OrderStatus: 1,
  4043. PayWay: pay_way,
  4044. PayPrice: pay_price,
  4045. PayCardNo: pay_card_no,
  4046. DiscountPrice: discount_price,
  4047. PreferentialPrice: preferential_price,
  4048. RealityPrice: reality_price,
  4049. FoundPrice: found_price,
  4050. MedicalInsurancePrice: medical_insurance_price,
  4051. PrivatePrice: private_price,
  4052. IsMedicineInsurance: 1,
  4053. SettleType: settle_accounts_type,
  4054. SettleStartTime: start_time,
  4055. SettleEndTime: end_time,
  4056. Creator: roles.AdminUserId,
  4057. Modify: roles.AdminUserId,
  4058. FaPiaoNumber: fapiao_number,
  4059. FaPiaoCode: fapiao_code,
  4060. PType: 2,
  4061. Diagnosis: diagnosis_id,
  4062. }
  4063. err = service.CreateOrder(order)
  4064. if err != nil {
  4065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4066. return
  4067. }
  4068. for _, item := range res.Output.Result {
  4069. temp := strings.Split(item.FeedetlSn, "-")
  4070. var advice_id int64 = 0
  4071. var project_id int64 = 0
  4072. var types int64 = 0
  4073. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4074. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4075. if temp[1] == "1" {
  4076. advice_id = id
  4077. project_id = 0
  4078. } else if temp[1] == "2" {
  4079. advice_id = 0
  4080. project_id = id
  4081. }
  4082. info := &models.HisOrderInfo{
  4083. OrderNumber: order.Number,
  4084. FeedetlSn: item.FeedetlSn,
  4085. UploadDate: time.Now().Unix(),
  4086. AdviceId: advice_id,
  4087. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4088. Cnt: item.Cnt,
  4089. Pric: float64(item.Pric),
  4090. PatientId: his.PatientId,
  4091. PricUplmtAmt: item.PricUplmtAmt,
  4092. SelfpayProp: item.SelfpayProp,
  4093. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4094. OverlmtAmt: item.OverlmtAmt,
  4095. PreselfpayAmt: item.PreselfpayAmt,
  4096. BasMednFlag: item.BasMednFlag,
  4097. MedChrgitmType: item.MedChrgitmType,
  4098. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4099. Status: 1,
  4100. Memo: item.Memo,
  4101. Mtime: time.Now().Unix(),
  4102. InscpScpAmt: item.InscpScpAmt,
  4103. DrtReimFlag: item.DrtReimFlag,
  4104. Ctime: time.Now().Unix(),
  4105. ListSpItemFlag: item.ListSpItemFlag,
  4106. ChldMedcFlag: item.ChldMedcFlag,
  4107. LmtUsedFlag: item.LmtUsedFlag,
  4108. ChrgitmLv: item.ChrgitmLv,
  4109. UserOrgId: adminUser.CurrentOrgId,
  4110. HisPatientId: his.ID,
  4111. OrderId: order.ID,
  4112. ProjectId: project_id,
  4113. Type: types,
  4114. }
  4115. service.CreateOrderInfo(info)
  4116. }
  4117. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4118. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4119. var total float64
  4120. for _, item := range prescriptions {
  4121. if item.Type == 1 { //药品
  4122. for _, subItem := range item.HisDoctorAdviceInfo {
  4123. total = total + (subItem.Price * subItem.PrescribingNumber)
  4124. }
  4125. }
  4126. if item.Type == 2 { //项目
  4127. for _, subItem := range item.HisPrescriptionProject {
  4128. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4129. total = total + (subItem.Price * cnt)
  4130. }
  4131. }
  4132. }
  4133. for _, item := range prescriptions {
  4134. for _, subItem := range item.HisAdditionalCharge {
  4135. total = total + (subItem.Price * float64(subItem.Count))
  4136. }
  4137. }
  4138. var allTotal string
  4139. if adminUser.CurrentOrgId == 9919 {
  4140. allTotal = fmt.Sprintf("%.4f", total)
  4141. } else {
  4142. allTotal = fmt.Sprintf("%.4f", total)
  4143. }
  4144. if res.Infcode == 0 {
  4145. var rf []*ResultFive
  4146. json.Unmarshal([]byte(his.Iinfo), &rf)
  4147. chrg_bchno := chrg_bchno
  4148. cert_no := his.Certno
  4149. var insutypes []string
  4150. var insutype string
  4151. var is390 int = 0
  4152. var is310 int = 0
  4153. for _, item := range rf {
  4154. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4155. insutypes = append(insutypes, item.Insutype)
  4156. }
  4157. }
  4158. if len(insutypes) == 1 {
  4159. insutype = insutypes[0]
  4160. } else {
  4161. for _, i := range insutypes {
  4162. if i == "390" {
  4163. is390 = 1
  4164. }
  4165. if i == "310" {
  4166. is310 = 1
  4167. }
  4168. }
  4169. }
  4170. if is390 == 1 {
  4171. insutype = "390"
  4172. }
  4173. if is310 == 1 {
  4174. insutype = "310"
  4175. }
  4176. if len(insutypes) == 0 {
  4177. insutype = "310"
  4178. }
  4179. if len(insutypes) == 2 {
  4180. insutype = strconv.FormatInt(his.SocialType, 10)
  4181. }
  4182. insutype = strconv.FormatInt(his.SocialType, 10)
  4183. //insutype = "390"
  4184. if his.IdCardType == 1 {
  4185. // cert_no = his.MedicalInsuranceNumber
  4186. cert_no = his.Certno
  4187. } else {
  4188. cert_no = his.Certno
  4189. }
  4190. var res ResultSeven
  4191. var resSeven10265 ResultSeven10265
  4192. var src_resquest string
  4193. var result2 string
  4194. var acct_used_flag string
  4195. fmt.Println("pay_way")
  4196. fmt.Println(pay_way)
  4197. fmt.Println("pay_way")
  4198. if pay_way == 4 {
  4199. acct_used_flag = "1"
  4200. } else {
  4201. acct_used_flag = "0"
  4202. }
  4203. if miConfig.MdtrtareaAdmvs == "421300" {
  4204. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4205. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4206. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4207. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4208. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4209. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4210. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4211. resp, requestErr := http.Get(api)
  4212. if requestErr != nil {
  4213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4214. return
  4215. }
  4216. body, ioErr := ioutil.ReadAll(resp.Body)
  4217. if ioErr != nil {
  4218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4220. return
  4221. }
  4222. var respJSON map[string]interface{}
  4223. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4226. return
  4227. }
  4228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4229. result, _ := json.Marshal(respJSON)
  4230. if miConfig.Code == "H15049901371" {
  4231. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4232. utils.ErrorLog("解析失败:%v", err)
  4233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4234. return
  4235. }
  4236. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4237. res.Output = resSeven10265.Output
  4238. res.ErrMsg = resSeven10265.ErrMsg
  4239. res.Cainfo = resSeven10265.Cainfo
  4240. res.WarnMsg = resSeven10265.WarnMsg
  4241. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4242. res.Infcode = infocode
  4243. } else {
  4244. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4245. utils.ErrorLog("解析失败:%v", err)
  4246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4247. return
  4248. }
  4249. }
  4250. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4251. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4252. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4253. //psn_info, _ := service.GetPsnByPatientId(id)
  4254. bas := strings.Split(psn_info.CardInfo, "|")
  4255. if his.IdCardType == 1 {
  4256. cert_no = bas[2]
  4257. } else {
  4258. cert_no = bas[1]
  4259. }
  4260. //江苏地区国家医保医疗类别
  4261. //职工透析:医疗类别选特殊情况门诊9933
  4262. //居民血透门慢: 医疗类别选门诊慢病1402
  4263. //var med_type string
  4264. //if his.Insutype == "310" {
  4265. // if reg_type == 14 {
  4266. // med_type = "9933"
  4267. // } else if reg_type == 11 {
  4268. // med_type = "11"
  4269. //
  4270. // }
  4271. //} else if his.Insutype == "390" {
  4272. // if reg_type == 14 {
  4273. // med_type = "1402"
  4274. // } else if reg_type == 11 {
  4275. // med_type = "11"
  4276. // }
  4277. //}
  4278. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4279. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4280. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4281. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4282. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4283. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4284. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4285. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4286. resp, requestErr := http.Get(api)
  4287. if requestErr != nil {
  4288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4289. return
  4290. }
  4291. body, ioErr := ioutil.ReadAll(resp.Body)
  4292. if ioErr != nil {
  4293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4295. return
  4296. }
  4297. var respJSON map[string]interface{}
  4298. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4301. return
  4302. }
  4303. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4304. result, _ := json.Marshal(respJSON)
  4305. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4306. utils.ErrorLog("解析失败:%v", err)
  4307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4308. return
  4309. }
  4310. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4311. res.Output = resSeven10265.Output
  4312. res.ErrMsg = resSeven10265.ErrMsg
  4313. res.Cainfo = resSeven10265.Cainfo
  4314. res.WarnMsg = resSeven10265.WarnMsg
  4315. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4316. res.Infcode = infocode
  4317. } else {
  4318. if miConfig.Code == "H15049901371" {
  4319. //赤峰地区国家医保医疗类别
  4320. //职工透析:医疗类别选特殊情况门诊990502
  4321. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4322. var med_type string
  4323. if his.Insutype == "390" {
  4324. if reg_type == 14 {
  4325. med_type = "9933"
  4326. } else if reg_type == 11 {
  4327. med_type = "11"
  4328. }
  4329. } else if his.Insutype == "310" {
  4330. if reg_type == 14 {
  4331. med_type = "990502"
  4332. } else if reg_type == 11 {
  4333. med_type = "11"
  4334. }
  4335. }
  4336. 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)
  4337. } else {
  4338. 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)
  4339. }
  4340. //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)
  4341. var dat map[string]interface{}
  4342. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4343. fmt.Println(dat)
  4344. } else {
  4345. fmt.Println(err)
  4346. }
  4347. saveLog(result2, src_resquest, "2207", "结算")
  4348. userJSONBytes, _ := json.Marshal(dat)
  4349. if miConfig.Code == "H15049901371" {
  4350. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4351. utils.ErrorLog("解析失败:%v", err)
  4352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4353. return
  4354. }
  4355. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4356. res.Output = resSeven10265.Output
  4357. res.ErrMsg = resSeven10265.ErrMsg
  4358. res.Cainfo = resSeven10265.Cainfo
  4359. res.WarnMsg = resSeven10265.WarnMsg
  4360. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4361. res.Infcode = infocode
  4362. } else {
  4363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4364. utils.ErrorLog("解析失败:%v", err)
  4365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4366. return
  4367. }
  4368. }
  4369. }
  4370. if res.Infcode != 0 {
  4371. errlog := &models.HisOrderError{
  4372. UserOrgId: adminUser.CurrentOrgId,
  4373. Ctime: time.Now().Unix(),
  4374. Mtime: time.Now().Unix(),
  4375. Number: chrg_bchno,
  4376. ErrMsg: res.ErrMsg,
  4377. Status: 1,
  4378. PatientId: id,
  4379. RecordTime: recordDateTime,
  4380. Stage: 6,
  4381. }
  4382. service.CreateErrMsgLog(errlog)
  4383. c.ServeSuccessJSON(map[string]interface{}{
  4384. "failed_code": -10,
  4385. "msg": res.ErrMsg,
  4386. })
  4387. return
  4388. } else {
  4389. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4390. order.OrderStatus = 2
  4391. order.Status = 1
  4392. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4393. order.SetlId = res.Output.Setlinfo.SetlID
  4394. order.PsnNo = res.Output.Setlinfo.PsnNo
  4395. order.PsnName = res.Output.Setlinfo.PsnName
  4396. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4397. order.Certno = res.Output.Setlinfo.Certno
  4398. order.Gend = res.Output.Setlinfo.Gend
  4399. order.Naty = res.Output.Setlinfo.Naty
  4400. order.Age = res.Output.Setlinfo.Age
  4401. order.Insutype = res.Output.Setlinfo.Insutype
  4402. order.PsnType = res.Output.Setlinfo.PsnType
  4403. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4404. order.SetlTime = res.Output.Setlinfo.SetlTime
  4405. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4406. if res.Output.Setlinfo.MedType == "140101" {
  4407. order.MedType = "14"
  4408. } else {
  4409. order.MedType = res.Output.Setlinfo.MedType
  4410. }
  4411. if reg_type == 1112 {
  4412. order.MedType = "1112"
  4413. }
  4414. if reg_type == 1111 {
  4415. order.MedType = "1111"
  4416. }
  4417. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4418. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4419. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4420. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4421. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4422. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4423. order.HifpPay = res.Output.Setlinfo.HifpPay
  4424. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4425. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4426. order.HifesPay = res.Output.Setlinfo.HifesPay
  4427. order.HifobPay = res.Output.Setlinfo.HifobPay
  4428. order.MafPay = res.Output.Setlinfo.MafPay
  4429. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4430. order.OthPay = res.Output.Setlinfo.OthPay
  4431. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4432. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4433. order.AcctPay = res.Output.Setlinfo.AcctPay
  4434. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4435. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4436. order.Balc = res.Output.Setlinfo.Balc
  4437. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4438. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4439. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4440. order.ClrType = res.Output.Setlinfo.ClrType
  4441. order.ClrWay = res.Output.Setlinfo.ClrWay
  4442. order.Creator = order.Creator
  4443. order.Modify = roles.AdminUserId
  4444. order.RequestLog = src_resquest
  4445. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4446. detailStr := string(setlDetail)
  4447. order.SetlDetail = detailStr
  4448. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4449. err = service.UpDateOrder(order)
  4450. if err == nil {
  4451. c.ServeSuccessJSON(map[string]interface{}{
  4452. "msg": "结算成功",
  4453. })
  4454. } else {
  4455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4456. return
  4457. }
  4458. }
  4459. } else {
  4460. adminUser := c.GetAdminUserInfo()
  4461. errlog := &models.HisOrderError{
  4462. UserOrgId: adminUser.CurrentOrgId,
  4463. Ctime: time.Now().Unix(),
  4464. Mtime: time.Now().Unix(),
  4465. ErrMsg: res.ErrMsg,
  4466. Status: 1,
  4467. PatientId: id,
  4468. RecordTime: recordDateTime,
  4469. Stage: 4,
  4470. }
  4471. service.CreateErrMsgLog(errlog)
  4472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4473. return
  4474. }
  4475. } else {
  4476. adminUser := c.GetAdminUserInfo()
  4477. errlog := &models.HisOrderError{
  4478. UserOrgId: adminUser.CurrentOrgId,
  4479. Ctime: time.Now().Unix(),
  4480. Mtime: time.Now().Unix(),
  4481. ErrMsg: res.ErrMsg,
  4482. Status: 1,
  4483. PatientId: id,
  4484. RecordTime: recordDateTime,
  4485. Stage: 4,
  4486. }
  4487. service.CreateErrMsgLog(errlog)
  4488. c.ServeSuccessJSON(map[string]interface{}{
  4489. "failed_code": -10,
  4490. "msg": res.ErrMsg,
  4491. })
  4492. return
  4493. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4494. //return
  4495. }
  4496. }
  4497. }
  4498. } else if tempOrder.ID > 0 {
  4499. if tempOrder.IsPre == 1 {
  4500. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4501. var rf []*ResultFive
  4502. json.Unmarshal([]byte(his.Iinfo), &rf)
  4503. chrg_bchno := tempOrder.Number
  4504. cert_no := his.Certno
  4505. var insutypes []string
  4506. var insutype string
  4507. var is390 int = 0
  4508. var is310 int = 0
  4509. for _, item := range rf {
  4510. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4511. insutypes = append(insutypes, item.Insutype)
  4512. }
  4513. }
  4514. if len(insutypes) == 1 {
  4515. insutype = insutypes[0]
  4516. } else {
  4517. for _, i := range insutypes {
  4518. if i == "390" {
  4519. is390 = 1
  4520. }
  4521. if i == "310" {
  4522. is310 = 1
  4523. }
  4524. }
  4525. }
  4526. if is390 == 1 {
  4527. insutype = "390"
  4528. }
  4529. if is310 == 1 {
  4530. insutype = "310"
  4531. }
  4532. if len(insutypes) == 0 {
  4533. insutype = "310"
  4534. }
  4535. if len(insutypes) == 2 {
  4536. insutype = strconv.FormatInt(his.SocialType, 64)
  4537. }
  4538. //insutype = "390"
  4539. if his.IdCardType == 1 {
  4540. // cert_no = his.MedicalInsuranceNumber
  4541. cert_no = his.Certno
  4542. } else {
  4543. cert_no = his.Certno
  4544. }
  4545. var res ResultSeven
  4546. var resSeven10265 ResultSeven10265
  4547. var src_resquest string
  4548. var result2 string
  4549. var acct_used_flag string
  4550. fmt.Println("pay_way")
  4551. fmt.Println(pay_way)
  4552. fmt.Println("pay_way")
  4553. if pay_way == 4 {
  4554. acct_used_flag = "1"
  4555. } else {
  4556. acct_used_flag = "0"
  4557. }
  4558. if miConfig.MdtrtareaAdmvs == "421300" {
  4559. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4560. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4561. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4562. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4563. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4564. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4565. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4566. resp, requestErr := http.Get(api)
  4567. if requestErr != nil {
  4568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4569. return
  4570. }
  4571. body, ioErr := ioutil.ReadAll(resp.Body)
  4572. if ioErr != nil {
  4573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4575. return
  4576. }
  4577. var respJSON map[string]interface{}
  4578. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4581. return
  4582. }
  4583. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4584. result, _ := json.Marshal(respJSON)
  4585. fmt.Println("log")
  4586. fmt.Println(string(result))
  4587. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4588. utils.ErrorLog("解析失败:%v", err)
  4589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4590. return
  4591. }
  4592. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4593. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4594. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4595. //psn_info, _ := service.GetPsnByPatientId(id)
  4596. bas := strings.Split(psn_info.CardInfo, "|")
  4597. if his.IdCardType == 1 {
  4598. cert_no = bas[2]
  4599. } else {
  4600. cert_no = bas[1]
  4601. }
  4602. //江苏地区国家医保医疗类别
  4603. //职工透析:医疗类别选特殊情况门诊9933
  4604. //居民血透门慢: 医疗类别选门诊慢病1402
  4605. //var med_type string
  4606. //if his.Insutype == "310" {
  4607. // if reg_type == 14 {
  4608. // med_type = "9933"
  4609. // } else if reg_type == 11 {
  4610. // med_type = "11"
  4611. //
  4612. // }
  4613. //} else if his.Insutype == "390" {
  4614. // if reg_type == 14 {
  4615. // med_type = "1402"
  4616. // } else if reg_type == 11 {
  4617. // med_type = "11"
  4618. // }
  4619. //}
  4620. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4621. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4622. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4623. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4624. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4625. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4626. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4627. resp, requestErr := http.Get(api)
  4628. if requestErr != nil {
  4629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4630. return
  4631. }
  4632. body, ioErr := ioutil.ReadAll(resp.Body)
  4633. if ioErr != nil {
  4634. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4636. return
  4637. }
  4638. var respJSON map[string]interface{}
  4639. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4642. return
  4643. }
  4644. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4645. result, _ := json.Marshal(respJSON)
  4646. fmt.Println("log")
  4647. fmt.Println(string(result))
  4648. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4649. utils.ErrorLog("解析失败:%v", err)
  4650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4651. return
  4652. }
  4653. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4654. res.Output = resSeven10265.Output
  4655. res.ErrMsg = resSeven10265.ErrMsg
  4656. res.Cainfo = resSeven10265.Cainfo
  4657. res.WarnMsg = resSeven10265.WarnMsg
  4658. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4659. res.Infcode = infocode
  4660. } else {
  4661. var src_resquest string
  4662. if miConfig.Code == "H15049901371" {
  4663. //赤峰地区国家医保医疗类别
  4664. //职工透析:医疗类别选特殊情况门诊990502
  4665. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4666. var med_type string
  4667. if his.Insutype == "390" {
  4668. if reg_type == 14 {
  4669. med_type = "9933"
  4670. } else if reg_type == 11 {
  4671. med_type = "11"
  4672. }
  4673. } else if his.Insutype == "310" {
  4674. if reg_type == 14 {
  4675. med_type = "990502"
  4676. } else if reg_type == 11 {
  4677. med_type = "11"
  4678. }
  4679. }
  4680. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4681. } else {
  4682. 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)
  4683. }
  4684. var dat map[string]interface{}
  4685. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4686. fmt.Println(dat)
  4687. } else {
  4688. fmt.Println(err)
  4689. }
  4690. saveLog(result2, src_resquest, "2207", "结算")
  4691. userJSONBytes, _ := json.Marshal(dat)
  4692. if miConfig.Code == "H15049901371" {
  4693. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4694. utils.ErrorLog("解析失败:%v", err)
  4695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4696. return
  4697. }
  4698. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4699. res.Output = resSeven10265.Output
  4700. res.ErrMsg = resSeven10265.ErrMsg
  4701. res.Cainfo = resSeven10265.Cainfo
  4702. res.WarnMsg = resSeven10265.WarnMsg
  4703. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4704. res.Infcode = infocode
  4705. } else {
  4706. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4707. utils.ErrorLog("解析失败:%v", err)
  4708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4709. return
  4710. }
  4711. }
  4712. }
  4713. if res.Infcode != 0 {
  4714. errlog := &models.HisOrderError{
  4715. UserOrgId: adminUser.CurrentOrgId,
  4716. Ctime: time.Now().Unix(),
  4717. Mtime: time.Now().Unix(),
  4718. Number: chrg_bchno,
  4719. ErrMsg: res.ErrMsg,
  4720. Status: 1,
  4721. PatientId: id,
  4722. RecordTime: recordDateTime,
  4723. Stage: 6,
  4724. }
  4725. service.CreateErrMsgLog(errlog)
  4726. c.ServeSuccessJSON(map[string]interface{}{
  4727. "failed_code": -10,
  4728. "msg": res.ErrMsg,
  4729. })
  4730. return
  4731. } else {
  4732. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4733. order.OrderStatus = 2
  4734. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4735. order.SetlId = res.Output.Setlinfo.SetlID
  4736. order.PsnNo = res.Output.Setlinfo.PsnNo
  4737. order.PsnName = res.Output.Setlinfo.PsnName
  4738. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4739. order.Certno = res.Output.Setlinfo.Certno
  4740. order.Gend = res.Output.Setlinfo.Gend
  4741. order.Naty = res.Output.Setlinfo.Naty
  4742. order.Age = res.Output.Setlinfo.Age
  4743. order.Insutype = res.Output.Setlinfo.Insutype
  4744. order.PsnType = res.Output.Setlinfo.PsnType
  4745. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4746. order.SetlTime = res.Output.Setlinfo.SetlTime
  4747. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4748. //order.MedType = res.Output.Setlinfo.MedType
  4749. if reg_type == 1112 {
  4750. order.MedType = "1112"
  4751. }
  4752. if reg_type == 1111 {
  4753. order.MedType = "1111"
  4754. }
  4755. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4756. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4757. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4758. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4759. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4760. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4761. order.HifpPay = res.Output.Setlinfo.HifpPay
  4762. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4763. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4764. order.HifesPay = res.Output.Setlinfo.HifesPay
  4765. order.HifobPay = res.Output.Setlinfo.HifobPay
  4766. order.MafPay = res.Output.Setlinfo.MafPay
  4767. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4768. order.OthPay = res.Output.Setlinfo.OthPay
  4769. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4770. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4771. order.AcctPay = res.Output.Setlinfo.AcctPay
  4772. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4773. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4774. order.Balc = res.Output.Setlinfo.Balc
  4775. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4776. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4777. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4778. order.ClrWay = res.Output.Setlinfo.ClrWay
  4779. order.Creator = order.Creator
  4780. order.Modify = roles.AdminUserId
  4781. order.RequestLog = src_resquest
  4782. order.Diagnosis = diagnosis_id
  4783. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4784. detailStr := string(setlDetail)
  4785. order.SetlDetail = detailStr
  4786. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4787. err = service.UpDateOrder(order)
  4788. if err == nil {
  4789. c.ServeSuccessJSON(map[string]interface{}{
  4790. "msg": "结算成功",
  4791. })
  4792. } else {
  4793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4794. return
  4795. }
  4796. }
  4797. }
  4798. }
  4799. }
  4800. //func (c *HisApiController) GetPreUploadInfo() {
  4801. // id, _ := c.GetInt64("id")
  4802. // record_time := c.GetString("record_time")
  4803. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4804. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4805. //
  4806. // timeLayout := "2006-01-02"
  4807. // loc, _ := time.LoadLocation("Local")
  4808. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4809. // if err != nil {
  4810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4811. // return
  4812. // }
  4813. // recordDateTime := theTime.Unix()
  4814. // adminUser := c.GetAdminUserInfo()
  4815. //
  4816. // var prescriptions []*models.HisPrescription
  4817. //
  4818. // var start_time int64
  4819. // var end_time int64
  4820. //
  4821. // data := make(map[string]interface{})
  4822. // if settle_accounts_type == 1 { //日结
  4823. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4824. // data["pre"] = prescriptions
  4825. //
  4826. // } else { //月结
  4827. // start_time_str := c.GetString("start_time")
  4828. // end_time_str := c.GetString("end_time")
  4829. // timeLayout := "2006-01-02"
  4830. // loc, _ := time.LoadLocation("Local")
  4831. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4832. // if err != nil {
  4833. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4834. // return
  4835. // }
  4836. // recordStartTime := theStartTime.Unix()
  4837. // start_time = recordStartTime
  4838. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4839. // if err != nil {
  4840. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4841. // return
  4842. // }
  4843. // recordEndTime := theEndTime.Unix()
  4844. // end_time = recordEndTime
  4845. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4846. // data["pre"] = prescriptions
  4847. //
  4848. // }
  4849. //
  4850. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4851. //
  4852. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4853. // timestamp := time.Now().Unix()
  4854. // tempTime := time.Unix(timestamp, 0)
  4855. // timeFormat := tempTime.Format("20060102150405")
  4856. // chrgBchno := rand.Intn(100000) + 10000
  4857. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4858. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4859. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4860. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4861. // strconv.FormatInt(his.PatientId, 10)
  4862. // client := &http.Client{}
  4863. // data["psn_no"] = his.PsnNo
  4864. // data["mdtrt_id"] = his.Number
  4865. // data["chrg_bchno"] = chrg_bchno
  4866. // data["org_name"] = miConfig.OrgName
  4867. // data["doctor"] = roles.UserName
  4868. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4869. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4870. // data["fixmedins_code"] = miConfig.Code
  4871. // data["dept_code"] = department.Number
  4872. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4873. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4874. // data["secret_key"] = miConfig.SecretKey
  4875. // var ids []int64
  4876. //
  4877. // for _, item := range prescriptions {
  4878. // ids = append(ids, item.ID)
  4879. // }
  4880. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4881. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4882. // bytesData, _ := json.Marshal(data)
  4883. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4884. // resp, _ := client.Do(req)
  4885. // defer resp.Body.Close()
  4886. // body, ioErr := ioutil.ReadAll(resp.Body)
  4887. // if ioErr != nil {
  4888. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4889. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4890. // return
  4891. // }
  4892. // var respJSON map[string]interface{}
  4893. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4894. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4895. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4896. // return
  4897. // }
  4898. //
  4899. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4900. // userJSONBytes, _ := json.Marshal(respJSON)
  4901. // var res ResultFour
  4902. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4903. // utils.ErrorLog("解析失败:%v", err)
  4904. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4905. // return
  4906. // }
  4907. //
  4908. // if res.Infcode == 0 {
  4909. // order := &models.HisOrder{
  4910. // UserOrgId: adminUser.CurrentOrgId,
  4911. // HisPatientId: his.ID,
  4912. // PatientId: his.PatientId,
  4913. // SettleAccountsDate: recordDateTime,
  4914. // Ctime: time.Now().Unix(),
  4915. // Mtime: time.Now().Unix(),
  4916. // Status: 1,
  4917. // Number: chrg_bchno,
  4918. // Infcode: res.Infcode,
  4919. // WarnMsg: res.WarnMsg,
  4920. // Cainfo: res.Cainfo,
  4921. // ErrMsg: res.ErrMsg,
  4922. // RespondTime: res.RefmsgTime,
  4923. // InfRefmsgid: res.InfRefmsgid,
  4924. // OrderStatus: 1,
  4925. // IsMedicineInsurance: 1,
  4926. // SettleType: settle_accounts_type,
  4927. // SettleStartTime: start_time,
  4928. // SettleEndTime: end_time,
  4929. // Creator: roles.ID,
  4930. // Modify: roles.ID,
  4931. // PType: 2,
  4932. // }
  4933. // err = service.CreateOrder(order)
  4934. // if err != nil {
  4935. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4936. // return
  4937. // }
  4938. //
  4939. // for _, item := range res.Output.Result {
  4940. // temp := strings.Split(item.FeedetlSn, "-")
  4941. // var advice_id int64 = 0
  4942. // var project_id int64 = 0
  4943. // var types int64 = 0
  4944. //
  4945. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4946. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4947. //
  4948. // if temp[1] == "1" {
  4949. // advice_id = id
  4950. // project_id = 0
  4951. // } else if temp[1] == "2" {
  4952. // advice_id = 0
  4953. // project_id = id
  4954. // }
  4955. //
  4956. // info := &models.HisOrderInfo{
  4957. // OrderNumber: order.Number,
  4958. // FeedetlSn: item.FeedetlSn,
  4959. // UploadDate: time.Now().Unix(),
  4960. // AdviceId: advice_id,
  4961. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4962. // Cnt: item.Cnt,
  4963. // Pric: float64(item.Pric),
  4964. // PatientId: his.PatientId,
  4965. // PricUplmtAmt: item.PricUplmtAmt,
  4966. // SelfpayProp: item.SelfpayProp,
  4967. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4968. // OverlmtAmt: item.OverlmtAmt,
  4969. // PreselfpayAmt: item.PreselfpayAmt,
  4970. // BasMednFlag: item.BasMednFlag,
  4971. // MedChrgitmType: item.MedChrgitmType,
  4972. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4973. // Status: 1,
  4974. // Memo: item.Memo,
  4975. // Mtime: time.Now().Unix(),
  4976. // InscpScpAmt: item.InscpScpAmt,
  4977. // DrtReimFlag: item.DrtReimFlag,
  4978. // Ctime: time.Now().Unix(),
  4979. // ListSpItemFlag: item.ListSpItemFlag,
  4980. // ChldMedcFlag: item.ChldMedcFlag,
  4981. // LmtUsedFlag: item.LmtUsedFlag,
  4982. // ChrgitmLv: item.ChrgitmLv,
  4983. // UserOrgId: adminUser.CurrentOrgId,
  4984. // HisPatientId: his.ID,
  4985. // OrderId: order.ID,
  4986. // ProjectId: project_id,
  4987. // Type: types,
  4988. // }
  4989. // service.CreateOrderInfo(info)
  4990. //
  4991. // }
  4992. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4993. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4994. //
  4995. // var total float64
  4996. // for _, item := range prescriptions {
  4997. // if item.Type == 1 { //药品
  4998. // for _, subItem := range item.HisDoctorAdviceInfo {
  4999. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5000. // }
  5001. // }
  5002. // if item.Type == 2 { //项目
  5003. // for _, subItem := range item.HisPrescriptionProject {
  5004. // total = total + (subItem.Price * float64(subItem.Count))
  5005. // }
  5006. // }
  5007. // }
  5008. //
  5009. // for _, item := range prescriptions {
  5010. // for _, subItem := range item.HisAdditionalCharge {
  5011. // total = total + (subItem.Price * float64(subItem.Count))
  5012. // }
  5013. // }
  5014. //
  5015. // allTotal := fmt.Sprintf("%.2f", total)
  5016. // if res.Infcode == 0 {
  5017. // var rf []*ResultFive
  5018. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5019. // psn_no := his.PsnNo
  5020. // mdtrt_id := his.Number
  5021. // chrg_bchno := chrg_bchno
  5022. // cert_no := his.Certno
  5023. // insutype := rf[0].Insutype
  5024. //
  5025. // if his.IdCardType == 1 {
  5026. // cert_no = his.MedicalInsuranceNumber
  5027. //
  5028. // } else {
  5029. //
  5030. // cert_no = his.Certno
  5031. //
  5032. // }
  5033. //
  5034. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5035. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5036. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5037. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5038. // resp, requestErr := http.Get(api)
  5039. // if requestErr != nil {
  5040. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5041. // return
  5042. // }
  5043. // defer resp.Body.Close()
  5044. // body, ioErr := ioutil.ReadAll(resp.Body)
  5045. // if ioErr != nil {
  5046. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5047. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5048. // return
  5049. // }
  5050. // var respJSON map[string]interface{}
  5051. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5052. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5053. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5054. // return
  5055. // }
  5056. // fmt.Println(respJSON)
  5057. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5058. // userJSONBytes, _ := json.Marshal(respJSON)
  5059. // var res ResultSeven
  5060. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5061. // utils.ErrorLog("解析失败:%v", err)
  5062. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5063. // return
  5064. // }
  5065. // if res.Infcode != 0 {
  5066. // errlog := &models.HisOrderError{
  5067. // UserOrgId: adminUser.CurrentOrgId,
  5068. // Ctime: time.Now().Unix(),
  5069. // Mtime: time.Now().Unix(),
  5070. // Number: chrg_bchno,
  5071. // ErrMsg: res.ErrMsg,
  5072. // Status: 1,
  5073. // PatientId: id,
  5074. // RecordTime: recordDateTime,
  5075. // Stage: 7,
  5076. // }
  5077. // service.CreateErrMsgLog(errlog)
  5078. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5079. // return
  5080. // } else {
  5081. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5082. // order.OrderStatus = 1
  5083. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5084. // order.SetlId = res.Output.Setlinfo.SetlID
  5085. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5086. // order.PsnName = res.Output.Setlinfo.PsnName
  5087. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5088. // order.Certno = res.Output.Setlinfo.Certno
  5089. // order.Gend = res.Output.Setlinfo.Gend
  5090. // order.Naty = res.Output.Setlinfo.Naty
  5091. // order.Age = res.Output.Setlinfo.Age
  5092. // order.Insutype = res.Output.Setlinfo.Insutype
  5093. // order.PsnType = res.Output.Setlinfo.PsnType
  5094. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5095. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5096. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5097. // order.MedType = res.Output.Setlinfo.MedType
  5098. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5099. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5100. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5101. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5102. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5103. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5104. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5105. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5106. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5107. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5108. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5109. // order.MafPay = res.Output.Setlinfo.MafPay
  5110. // order.OthPay = res.Output.Setlinfo.OthPay
  5111. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5112. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5113. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5114. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5115. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5116. // order.Balc = res.Output.Setlinfo.Balc
  5117. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5118. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5119. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5120. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5121. // order.Creator = order.Creator
  5122. // order.Modify = roles.ID
  5123. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5124. // detailStr := string(setlDetail)
  5125. // order.SetlDetail = detailStr
  5126. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5127. // err = service.UpDateOrder(order)
  5128. // if err == nil {
  5129. // c.ServeSuccessJSON(map[string]interface{}{
  5130. // "msg": "预结算成功",
  5131. // })
  5132. // } else {
  5133. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5134. // return
  5135. // }
  5136. // }
  5137. // } else {
  5138. // adminUser := c.GetAdminUserInfo()
  5139. // errlog := &models.HisOrderError{
  5140. // UserOrgId: adminUser.CurrentOrgId,
  5141. // Ctime: time.Now().Unix(),
  5142. // Mtime: time.Now().Unix(),
  5143. // ErrMsg: res.ErrMsg,
  5144. // Status: 1,
  5145. // PatientId: id,
  5146. // RecordTime: recordDateTime,
  5147. // Stage: 4,
  5148. // }
  5149. // service.CreateErrMsgLog(errlog)
  5150. //
  5151. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5152. // return
  5153. // }
  5154. // } else {
  5155. // adminUser := c.GetAdminUserInfo()
  5156. // errlog := &models.HisOrderError{
  5157. // UserOrgId: adminUser.CurrentOrgId,
  5158. // Ctime: time.Now().Unix(),
  5159. // Mtime: time.Now().Unix(),
  5160. // ErrMsg: res.ErrMsg,
  5161. // Status: 1,
  5162. // PatientId: id,
  5163. // RecordTime: recordDateTime,
  5164. // Stage: 4,
  5165. // }
  5166. // service.CreateErrMsgLog(errlog)
  5167. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5168. // return
  5169. // }
  5170. //
  5171. // } else {
  5172. // var total float64
  5173. // for _, item := range prescriptions {
  5174. // if item.Type == 1 { //药品
  5175. // for _, subItem := range item.HisDoctorAdviceInfo {
  5176. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5177. // }
  5178. // }
  5179. // if item.Type == 2 { //项目
  5180. // for _, subItem := range item.HisPrescriptionProject {
  5181. // total = total + (subItem.Price * float64(subItem.Count))
  5182. // }
  5183. // }
  5184. //
  5185. // for _, subItem := range item.HisAdditionalCharge {
  5186. // total = total + (subItem.Price * float64(subItem.Count))
  5187. // }
  5188. // }
  5189. //
  5190. // allTotal := fmt.Sprintf("%.2f", total)
  5191. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5192. // order := &models.HisOrder{
  5193. // UserOrgId: adminUser.CurrentOrgId,
  5194. // HisPatientId: his.ID,
  5195. // PatientId: id,
  5196. // SettleAccountsDate: recordDateTime,
  5197. // Ctime: time.Now().Unix(),
  5198. // Mtime: time.Now().Unix(),
  5199. // Status: 1,
  5200. // OrderStatus: 2,
  5201. // Number: chrg_bchno,
  5202. // MedfeeSumamt: totals,
  5203. // }
  5204. // err = service.CreateOrder(order)
  5205. // if err != nil {
  5206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5207. // return
  5208. // }
  5209. //
  5210. // var customs []*Custom
  5211. // for _, item := range prescriptions {
  5212. //
  5213. // if item.Type == 1 { //药品
  5214. // for _, subItem := range item.HisDoctorAdviceInfo {
  5215. // cus := &Custom{
  5216. // AdviceId: subItem.ID,
  5217. // ProjectId: 0,
  5218. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5219. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5220. // FeedetlSn: subItem.FeedetlSn,
  5221. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5222. // MedListCodg: subItem.MedListCodg,
  5223. // Type: 1,
  5224. // }
  5225. // customs = append(customs, cus)
  5226. // }
  5227. // }
  5228. //
  5229. // if item.Type == 2 { //项目
  5230. // for _, subItem := range item.HisPrescriptionProject {
  5231. //
  5232. // cus := &Custom{
  5233. // AdviceId: 0,
  5234. // ProjectId: subItem.ID,
  5235. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5236. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5237. // FeedetlSn: subItem.FeedetlSn,
  5238. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5239. // MedListCodg: subItem.MedListCodg,
  5240. // Type: 2,
  5241. // }
  5242. //
  5243. // customs = append(customs, cus)
  5244. // }
  5245. // }
  5246. //
  5247. // for _, item := range item.HisAdditionalCharge {
  5248. // cus := &Custom{
  5249. // ItemId: item.ID,
  5250. // AdviceId: 0,
  5251. // ProjectId: 0,
  5252. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5253. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5254. // FeedetlSn: item.FeedetlSn,
  5255. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5256. // MedListCodg: item.XtHisAddtionConfig.Code,
  5257. // Type: 3,
  5258. // }
  5259. //
  5260. // customs = append(customs, cus)
  5261. // }
  5262. //
  5263. // }
  5264. //
  5265. // for _, item := range customs {
  5266. // var advice_id int64 = 0
  5267. // var project_id int64 = 0
  5268. // var item_id int64 = 0
  5269. //
  5270. // var types int64 = 0
  5271. //
  5272. // if item.Type == 1 {
  5273. // advice_id = item.AdviceId
  5274. // project_id = 0
  5275. // item_id = 0
  5276. // } else if item.Type == 2 {
  5277. // advice_id = 0
  5278. // item_id = 0
  5279. //
  5280. // project_id = item.ProjectId
  5281. // } else if item.Type == 3 {
  5282. // advice_id = 0
  5283. // item_id = item.ItemId
  5284. // project_id = 0
  5285. // }
  5286. //
  5287. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5288. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5289. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5290. //
  5291. // info := &models.HisOrderInfo{
  5292. // OrderNumber: order.Number,
  5293. // UploadDate: time.Now().Unix(),
  5294. // AdviceId: advice_id,
  5295. // DetItemFeeSumamt: detItemFeeSumamt,
  5296. // Cnt: cut,
  5297. // Pric: pric,
  5298. // PatientId: id,
  5299. // Status: 1,
  5300. // Mtime: time.Now().Unix(),
  5301. // Ctime: time.Now().Unix(),
  5302. // UserOrgId: adminUser.CurrentOrgId,
  5303. // HisPatientId: his.ID,
  5304. // OrderId: order.ID,
  5305. // ProjectId: project_id,
  5306. // Type: types,
  5307. // ItemId: item_id,
  5308. // }
  5309. // service.CreateOrderInfo(info)
  5310. // }
  5311. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5312. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5313. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5314. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5315. // if err == nil {
  5316. // c.ServeSuccessJSON(map[string]interface{}{
  5317. // "msg": "结算成功",
  5318. // })
  5319. // } else {
  5320. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5321. // return
  5322. // }
  5323. // }
  5324. //}
  5325. //上传明细-预结算-
  5326. func (c *HisApiController) GetPreUploadInfo() {
  5327. id, _ := c.GetInt64("id")
  5328. record_time := c.GetString("record_time")
  5329. his_patient_id, _ := c.GetInt64("his_patient_id")
  5330. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5331. admin_user_id, _ := c.GetInt64("admin_user_id")
  5332. diagnosis_id := c.GetString("diagnosis")
  5333. sick_type, _ := c.GetInt64("sick_type")
  5334. reg_type, _ := c.GetInt64("p_type")
  5335. begin_time := c.GetString("begin_time")
  5336. id_str := c.GetString("ids")
  5337. ids_arr := strings.Split(id_str, ",")
  5338. timeLayout := "2006-01-02"
  5339. loc, _ := time.LoadLocation("Local")
  5340. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5341. if err != nil {
  5342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5343. return
  5344. }
  5345. recordDateTime := theTime.Unix()
  5346. adminUser := c.GetAdminUserInfo()
  5347. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5348. var config []*models.HisXtDiagnoseConfig
  5349. for _, item := range diagnosis_ids {
  5350. id, _ := strconv.ParseInt(item, 10, 64)
  5351. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5352. config = append(config, &diagnosisConfig)
  5353. }
  5354. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5355. sickConfig, _ := service.FindSickById(sick_type)
  5356. var prescriptions []*models.HisPrescription
  5357. var start_time int64
  5358. var end_time int64
  5359. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5360. fmt.Println(his_patient_id)
  5361. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5362. timestamp := time.Now().Unix()
  5363. tempTime := time.Unix(timestamp, 0)
  5364. timeFormat := tempTime.Format("20060102150405")
  5365. chrgBchno := rand.Intn(100000) + 10000
  5366. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5367. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5368. var patientPrescription models.HisPrescriptionInfo
  5369. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5370. if patientPrescription.ID == 0 {
  5371. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5372. }
  5373. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5374. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5375. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5376. strconv.FormatInt(his.PatientId, 10)
  5377. var res2 ResultSix
  5378. var resSix10265 ResultSix10265
  5379. var time_stamp string
  5380. if miConfig.MdtrtareaAdmvs == "421300" {
  5381. data := make(map[string]interface{})
  5382. client := &http.Client{}
  5383. data["psn_no"] = his.PsnNo
  5384. data["mdtrt_id"] = his.Number
  5385. data["doctor"] = roles.UserName
  5386. data["department"] = department.Name
  5387. data["org_name"] = miConfig.OrgName
  5388. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5389. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5390. data["fixmedins_code"] = miConfig.Code
  5391. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5392. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5393. data["secret_key"] = miConfig.SecretKey
  5394. data["sick_code"] = sickConfig.CountryCode
  5395. data["sick_name"] = sickConfig.ClassName
  5396. data["begin_time"] = begin_time
  5397. data["dept"] = strconv.FormatInt(department.ID, 10)
  5398. data["config"] = config
  5399. fmt.Println(data)
  5400. bytesData, _ := json.Marshal(data)
  5401. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5402. resp, _ := client.Do(req)
  5403. defer resp.Body.Close()
  5404. body, ioErr := ioutil.ReadAll(resp.Body)
  5405. if ioErr != nil {
  5406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5408. return
  5409. }
  5410. var respJSON map[string]interface{}
  5411. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5414. return
  5415. }
  5416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5417. userJSONBytes, _ := json.Marshal(respJSON)
  5418. fmt.Println("log")
  5419. fmt.Println(string(userJSONBytes))
  5420. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5421. utils.ErrorLog("解析失败:%v", err)
  5422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5423. return
  5424. }
  5425. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5426. //江苏地区国家医保医疗类别
  5427. //职工透析:医疗类别选特殊情况门诊9933
  5428. //居民血透门慢: 医疗类别选门诊慢病1402
  5429. //var med_type string
  5430. //if his.Insutype == "310" {
  5431. // if reg_type == 14 {
  5432. // med_type = "9933"
  5433. // } else if reg_type == 11 {
  5434. // med_type = "11"
  5435. //
  5436. // }
  5437. //} else if his.Insutype == "390" {
  5438. // if reg_type == 14 {
  5439. // med_type = "1402"
  5440. // } else if reg_type == 11 {
  5441. // med_type = "11"
  5442. // }
  5443. //}
  5444. data := make(map[string]interface{})
  5445. client := &http.Client{}
  5446. data["psn_no"] = his.PsnNo
  5447. data["mdtrt_id"] = his.Number
  5448. data["doctor"] = roles.UserName
  5449. data["department"] = department.Name
  5450. data["org_name"] = miConfig.OrgName
  5451. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5452. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5453. data["fixmedins_code"] = miConfig.Code
  5454. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5455. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5456. data["secret_key"] = miConfig.SecretKey
  5457. data["sick_code"] = sickConfig.CountryCode
  5458. data["sick_name"] = sickConfig.ClassName
  5459. data["begin_time"] = begin_time
  5460. data["dept"] = strconv.FormatInt(department.ID, 10)
  5461. data["config"] = config
  5462. data["url"] = miConfig.Url
  5463. data["ak"] = miConfig.AccessKey
  5464. data["cainfo"] = miConfig.Cainfo
  5465. bytesData, _ := json.Marshal(data)
  5466. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5467. resp, _ := client.Do(req)
  5468. defer resp.Body.Close()
  5469. body, ioErr := ioutil.ReadAll(resp.Body)
  5470. if ioErr != nil {
  5471. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5473. return
  5474. }
  5475. var respJSON map[string]interface{}
  5476. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5479. return
  5480. }
  5481. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5482. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5483. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5484. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5485. userJSONBytes, _ := json.Marshal(respJSON)
  5486. fmt.Println("log")
  5487. fmt.Println(string(userJSONBytes))
  5488. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5489. utils.ErrorLog("解析失败:%v", err)
  5490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5491. return
  5492. }
  5493. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5494. res2.Output = resSix10265.Output
  5495. res2.ErrMsg = resSix10265.ErrMsg
  5496. res2.Cainfo = resSix10265.Cainfo
  5497. res2.WarnMsg = resSix10265.WarnMsg
  5498. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5499. res2.Infcode = infocode
  5500. } else {
  5501. var result string
  5502. var requestLog string
  5503. if miConfig.MdtrtareaAdmvs == "440781" { //
  5504. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5505. } else {
  5506. if miConfig.Code == "H15049901371" {
  5507. //赤峰地区国家医保医疗类别
  5508. //职工透析:医疗类别选特殊情况门诊990502
  5509. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5510. var med_type string
  5511. if his.Insutype == "390" {
  5512. if reg_type == 14 {
  5513. med_type = "9933"
  5514. } else if reg_type == 11 {
  5515. med_type = "11"
  5516. }
  5517. } else if his.Insutype == "310" {
  5518. if reg_type == 14 {
  5519. med_type = "990502"
  5520. } else if reg_type == 11 {
  5521. med_type = "11"
  5522. }
  5523. }
  5524. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5525. } else {
  5526. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5527. }
  5528. saveLog(result, requestLog, "2203", "上传就诊信息")
  5529. var respJSON2 map[string]interface{}
  5530. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5533. return
  5534. }
  5535. userJSONBytes2, _ := json.Marshal(respJSON2)
  5536. if miConfig.Code == "H15049901371" {
  5537. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5538. utils.ErrorLog("解析失败:%v", err)
  5539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5540. return
  5541. }
  5542. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5543. res2.Output = resSix10265.Output
  5544. res2.ErrMsg = resSix10265.ErrMsg
  5545. res2.Cainfo = resSix10265.Cainfo
  5546. res2.WarnMsg = resSix10265.WarnMsg
  5547. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5548. res2.Infcode = infocode
  5549. } else {
  5550. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5551. utils.ErrorLog("解析失败:%v", err)
  5552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5553. return
  5554. }
  5555. }
  5556. }
  5557. }
  5558. if res2.Infcode != 0 {
  5559. adminUser := c.GetAdminUserInfo()
  5560. errlog := &models.HisOrderError{
  5561. UserOrgId: adminUser.CurrentOrgId,
  5562. Ctime: time.Now().Unix(),
  5563. Mtime: time.Now().Unix(),
  5564. ErrMsg: res2.ErrMsg,
  5565. Status: 1,
  5566. PatientId: id,
  5567. RecordTime: recordDateTime,
  5568. Stage: 3,
  5569. }
  5570. service.CreateErrMsgLog(errlog)
  5571. c.ServeSuccessJSON(map[string]interface{}{
  5572. "failed_code": -10,
  5573. "msg": res2.ErrMsg,
  5574. })
  5575. return
  5576. } else {
  5577. his.Diagnosis = diagnosis_id
  5578. his.SickType = sickConfig.ID
  5579. his.PType = fmt.Sprintf("%d", reg_type)
  5580. service.UpdateHisPatientThree(&his)
  5581. data := make(map[string]interface{})
  5582. if settle_accounts_type == 1 { //日结
  5583. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5584. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5585. } else {
  5586. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5587. }
  5588. data["pre"] = prescriptions
  5589. } else { //月结
  5590. start_time_str := c.GetString("start_time")
  5591. end_time_str := c.GetString("end_time")
  5592. timeLayout := "2006-01-02"
  5593. loc, _ := time.LoadLocation("Local")
  5594. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5595. if err != nil {
  5596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5597. return
  5598. }
  5599. recordStartTime := theStartTime.Unix()
  5600. start_time = recordStartTime
  5601. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5602. if err != nil {
  5603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5604. return
  5605. }
  5606. recordEndTime := theEndTime.Unix()
  5607. end_time = recordEndTime
  5608. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5609. data["pre"] = prescriptions
  5610. }
  5611. client := &http.Client{}
  5612. data["psn_no"] = his.PsnNo
  5613. data["mdtrt_id"] = his.Number
  5614. data["chrg_bchno"] = chrg_bchno
  5615. data["org_name"] = miConfig.OrgName
  5616. data["doctor"] = roles.UserName
  5617. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5618. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5619. data["fixmedins_code"] = miConfig.Code
  5620. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5621. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5622. data["dept_code"] = "15"
  5623. } else {
  5624. data["dept_code"] = department.Number
  5625. }
  5626. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5627. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5628. data["secret_key"] = miConfig.SecretKey
  5629. data["url"] = miConfig.Url
  5630. data["ak"] = miConfig.AccessKey
  5631. data["new_doctor_name"] = patientPrescription.Doctor
  5632. data["diag_code"] = sickConfig.CountryCode
  5633. data["time_stamp"] = time_stamp
  5634. data["cainfo"] = miConfig.Cainfo
  5635. var ids []int64
  5636. for _, item := range prescriptions {
  5637. ids = append(ids, item.ID)
  5638. }
  5639. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5640. if config.IsOpen == 1 { //对接了医保,走医保流程
  5641. var res ResultFour
  5642. var resFour10265 ResultFour10265
  5643. if miConfig.MdtrtareaAdmvs == "421300" {
  5644. bytesData, _ := json.Marshal(data)
  5645. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5646. resp, _ := client.Do(req)
  5647. defer resp.Body.Close()
  5648. body, ioErr := ioutil.ReadAll(resp.Body)
  5649. if ioErr != nil {
  5650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5652. return
  5653. }
  5654. var respJSON map[string]interface{}
  5655. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5658. return
  5659. }
  5660. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5661. userJSONBytes, _ := json.Marshal(respJSON)
  5662. fmt.Println("log")
  5663. fmt.Println(string(userJSONBytes))
  5664. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5665. utils.ErrorLog("解析失败:%v", err)
  5666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5667. return
  5668. }
  5669. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5670. bytesData, _ := json.Marshal(data)
  5671. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5672. resp, _ := client.Do(req)
  5673. defer resp.Body.Close()
  5674. body, ioErr := ioutil.ReadAll(resp.Body)
  5675. if ioErr != nil {
  5676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5678. return
  5679. }
  5680. var respJSON map[string]interface{}
  5681. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5684. return
  5685. }
  5686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5687. userJSONBytes, _ := json.Marshal(respJSON)
  5688. fmt.Println("log")
  5689. fmt.Println(string(userJSONBytes))
  5690. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5691. utils.ErrorLog("解析失败:%v", err)
  5692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5693. return
  5694. }
  5695. res.InfRefmsgid = resFour10265.InfRefmsgid
  5696. res.Output = resFour10265.Output
  5697. res.ErrMsg = resFour10265.ErrMsg
  5698. res.Cainfo = resFour10265.Cainfo
  5699. res.WarnMsg = resFour10265.WarnMsg
  5700. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5701. res.Infcode = infocode
  5702. } else {
  5703. if miConfig.Code == "H15049901371" {
  5704. 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)
  5705. var dat map[string]interface{}
  5706. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5707. fmt.Println(dat)
  5708. } else {
  5709. fmt.Println(err)
  5710. }
  5711. saveLog(result, request_log, "2204", "上传费用明细")
  5712. userJSONBytes, _ := json.Marshal(dat)
  5713. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5714. utils.ErrorLog("解析失败:%v", err)
  5715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5716. return
  5717. }
  5718. res.InfRefmsgid = resFour10265.InfRefmsgid
  5719. res.Output = resFour10265.Output
  5720. res.ErrMsg = resFour10265.ErrMsg
  5721. res.Cainfo = resFour10265.Cainfo
  5722. res.WarnMsg = resFour10265.WarnMsg
  5723. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5724. res.Infcode = infocode
  5725. } else {
  5726. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  5727. var dat map[string]interface{}
  5728. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5729. fmt.Println(dat)
  5730. } else {
  5731. fmt.Println(err)
  5732. }
  5733. saveLog(result, request_log, "2204", "上传费用明细")
  5734. userJSONBytes, _ := json.Marshal(dat)
  5735. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5736. utils.ErrorLog("解析失败:%v", err)
  5737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5738. return
  5739. }
  5740. }
  5741. }
  5742. if res.Infcode == 0 {
  5743. order := &models.HisOrder{
  5744. UserOrgId: adminUser.CurrentOrgId,
  5745. HisPatientId: his.ID,
  5746. PatientId: his.PatientId,
  5747. SettleAccountsDate: recordDateTime,
  5748. Ctime: time.Now().Unix(),
  5749. Mtime: time.Now().Unix(),
  5750. MdtrtId: his.Number,
  5751. PsnNo: his.PsnNo,
  5752. MedType: strconv.FormatInt(reg_type, 10),
  5753. Status: 1,
  5754. Number: chrg_bchno,
  5755. Infcode: res.Infcode,
  5756. WarnMsg: res.WarnMsg,
  5757. Cainfo: res.Cainfo,
  5758. ErrMsg: res.ErrMsg,
  5759. RespondTime: res.RefmsgTime,
  5760. InfRefmsgid: res.InfRefmsgid,
  5761. OrderStatus: 1,
  5762. IsMedicineInsurance: 1,
  5763. SettleType: settle_accounts_type,
  5764. SettleStartTime: start_time,
  5765. SettleEndTime: end_time,
  5766. Creator: roles.AdminUserId,
  5767. Modify: roles.AdminUserId,
  5768. PType: 2,
  5769. Diagnosis: diagnosis_id,
  5770. }
  5771. err = service.CreateOrder(order)
  5772. if err != nil {
  5773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5774. return
  5775. }
  5776. for _, item := range res.Output.Result {
  5777. temp := strings.Split(item.FeedetlSn, "-")
  5778. var advice_id int64 = 0
  5779. var project_id int64 = 0
  5780. var types int64 = 0
  5781. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5782. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5783. if temp[1] == "1" {
  5784. advice_id = id
  5785. project_id = 0
  5786. } else if temp[1] == "2" {
  5787. advice_id = 0
  5788. project_id = id
  5789. }
  5790. info := &models.HisOrderInfo{
  5791. OrderNumber: order.Number,
  5792. FeedetlSn: item.FeedetlSn,
  5793. UploadDate: time.Now().Unix(),
  5794. AdviceId: advice_id,
  5795. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5796. Cnt: item.Cnt,
  5797. Pric: float64(item.Pric),
  5798. PatientId: his.PatientId,
  5799. PricUplmtAmt: item.PricUplmtAmt,
  5800. SelfpayProp: item.SelfpayProp,
  5801. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5802. OverlmtAmt: item.OverlmtAmt,
  5803. PreselfpayAmt: item.PreselfpayAmt,
  5804. BasMednFlag: item.BasMednFlag,
  5805. MedChrgitmType: item.MedChrgitmType,
  5806. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5807. Status: 1,
  5808. Memo: item.Memo,
  5809. Mtime: time.Now().Unix(),
  5810. InscpScpAmt: item.InscpScpAmt,
  5811. DrtReimFlag: item.DrtReimFlag,
  5812. Ctime: time.Now().Unix(),
  5813. ListSpItemFlag: item.ListSpItemFlag,
  5814. ChldMedcFlag: item.ChldMedcFlag,
  5815. LmtUsedFlag: item.LmtUsedFlag,
  5816. ChrgitmLv: item.ChrgitmLv,
  5817. UserOrgId: adminUser.CurrentOrgId,
  5818. HisPatientId: his.ID,
  5819. OrderId: order.ID,
  5820. ProjectId: project_id,
  5821. Type: types,
  5822. }
  5823. service.CreateOrderInfo(info)
  5824. }
  5825. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5826. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5827. var total float64
  5828. for _, item := range prescriptions {
  5829. if item.Type == 1 { //药品
  5830. for _, subItem := range item.HisDoctorAdviceInfo {
  5831. total = total + (subItem.Price * subItem.PrescribingNumber)
  5832. }
  5833. }
  5834. if item.Type == 2 { //项目
  5835. for _, subItem := range item.HisPrescriptionProject {
  5836. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5837. total = total + (subItem.Price * cnt)
  5838. }
  5839. }
  5840. }
  5841. for _, item := range prescriptions {
  5842. for _, subItem := range item.HisAdditionalCharge {
  5843. total = total + (subItem.Price * float64(subItem.Count))
  5844. }
  5845. }
  5846. allTotal := fmt.Sprintf("%.4f", total)
  5847. if res.Infcode == 0 {
  5848. var rf []*ResultFive
  5849. json.Unmarshal([]byte(his.Iinfo), &rf)
  5850. chrg_bchno := chrg_bchno
  5851. cert_no := his.Certno
  5852. var insutypes []string
  5853. var insutype string
  5854. var is390 int = 0
  5855. var is310 int = 0
  5856. for _, item := range rf {
  5857. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5858. insutypes = append(insutypes, item.Insutype)
  5859. }
  5860. }
  5861. if len(insutypes) == 1 {
  5862. insutype = insutypes[0]
  5863. } else {
  5864. for _, i := range insutypes {
  5865. if i == "390" {
  5866. is390 = 1
  5867. }
  5868. if i == "310" {
  5869. is310 = 1
  5870. }
  5871. }
  5872. }
  5873. if is390 == 1 {
  5874. insutype = "390"
  5875. }
  5876. if is310 == 1 {
  5877. insutype = "310"
  5878. }
  5879. if len(insutypes) == 0 {
  5880. insutype = "310"
  5881. }
  5882. if len(insutypes) == 2 {
  5883. insutype = strconv.FormatInt(his.SocialType, 64)
  5884. }
  5885. //insutype = "390"
  5886. if his.IdCardType == 1 {
  5887. cert_no = his.MedicalInsuranceNumber
  5888. } else {
  5889. cert_no = his.Certno
  5890. }
  5891. var res ResultSeven
  5892. var resSeven10265 ResultSeven10265
  5893. if miConfig.MdtrtareaAdmvs == "421300" {
  5894. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5895. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5896. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5897. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5898. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5899. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5900. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5901. resp, requestErr := http.Get(api)
  5902. if requestErr != nil {
  5903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5904. return
  5905. }
  5906. body, ioErr := ioutil.ReadAll(resp.Body)
  5907. if ioErr != nil {
  5908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5910. return
  5911. }
  5912. var respJSON map[string]interface{}
  5913. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5916. return
  5917. }
  5918. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5919. result, _ := json.Marshal(respJSON)
  5920. fmt.Println("log")
  5921. fmt.Println(string(result))
  5922. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5923. utils.ErrorLog("解析失败:%v", err)
  5924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5925. return
  5926. }
  5927. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5928. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5929. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5930. bas := strings.Split(psn_info.CardInfo, "|")
  5931. if his.IdCardType == 1 {
  5932. cert_no = bas[2]
  5933. } else {
  5934. cert_no = bas[1]
  5935. }
  5936. //江苏地区国家医保医疗类别
  5937. //职工透析:医疗类别选特殊情况门诊9933
  5938. //居民血透门慢: 医疗类别选门诊慢病1402
  5939. //var med_type string
  5940. //if his.Insutype == "310" {
  5941. // if reg_type == 14 {
  5942. // med_type = "9933"
  5943. // } else if reg_type == 11 {
  5944. // med_type = "11"
  5945. //
  5946. // }
  5947. //} else if his.Insutype == "390" {
  5948. // if reg_type == 14 {
  5949. // med_type = "1402"
  5950. // } else if reg_type == 11 {
  5951. // med_type = "11"
  5952. // }
  5953. //}
  5954. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5955. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5956. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5957. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5958. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5959. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5960. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5961. resp, requestErr := http.Get(api)
  5962. if requestErr != nil {
  5963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5964. return
  5965. }
  5966. body, ioErr := ioutil.ReadAll(resp.Body)
  5967. if ioErr != nil {
  5968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5970. return
  5971. }
  5972. var respJSON map[string]interface{}
  5973. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5976. return
  5977. }
  5978. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5979. result, _ := json.Marshal(respJSON)
  5980. fmt.Println("log")
  5981. fmt.Println(string(result))
  5982. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5983. utils.ErrorLog("解析失败:%v", err)
  5984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5985. return
  5986. }
  5987. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5988. res.Output = resSeven10265.Output
  5989. res.ErrMsg = resSeven10265.ErrMsg
  5990. res.Cainfo = resSeven10265.Cainfo
  5991. res.WarnMsg = resSeven10265.WarnMsg
  5992. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5993. res.Infcode = infocode
  5994. } else {
  5995. var result string
  5996. var request_log string
  5997. if miConfig.Code == "H15049901371" {
  5998. //赤峰地区国家医保医疗类别
  5999. //职工透析:医疗类别选特殊情况门诊990502
  6000. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6001. var med_type string
  6002. if his.Insutype == "390" {
  6003. if reg_type == 14 {
  6004. med_type = "9933"
  6005. } else if reg_type == 11 {
  6006. med_type = "11"
  6007. }
  6008. } else if his.Insutype == "310" {
  6009. if reg_type == 14 {
  6010. med_type = "990502"
  6011. } else if reg_type == 11 {
  6012. med_type = "11"
  6013. }
  6014. }
  6015. 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)
  6016. } else {
  6017. 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)
  6018. }
  6019. var dat map[string]interface{}
  6020. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6021. fmt.Println(dat)
  6022. } else {
  6023. fmt.Println(err)
  6024. }
  6025. saveLog(result, request_log, "2206", "预结算")
  6026. //userJSONBytes, _ := json.Marshal(dat)
  6027. //
  6028. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6029. // utils.ErrorLog("解析失败:%v", err)
  6030. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6031. // return
  6032. //}
  6033. userJSONBytes, _ := json.Marshal(dat)
  6034. if miConfig.Code == "H15049901371" {
  6035. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6036. utils.ErrorLog("解析失败:%v", err)
  6037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6038. return
  6039. }
  6040. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6041. res.Output = resSeven10265.Output
  6042. res.ErrMsg = resSeven10265.ErrMsg
  6043. res.Cainfo = resSeven10265.Cainfo
  6044. res.WarnMsg = resSeven10265.WarnMsg
  6045. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6046. res.Infcode = infocode
  6047. } else {
  6048. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6049. utils.ErrorLog("解析失败:%v", err)
  6050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6051. return
  6052. }
  6053. }
  6054. }
  6055. if res.Infcode != 0 {
  6056. errlog := &models.HisOrderError{
  6057. UserOrgId: adminUser.CurrentOrgId,
  6058. Ctime: time.Now().Unix(),
  6059. Mtime: time.Now().Unix(),
  6060. Number: chrg_bchno,
  6061. ErrMsg: res.ErrMsg,
  6062. Status: 1,
  6063. PatientId: id,
  6064. RecordTime: recordDateTime,
  6065. Stage: 20,
  6066. }
  6067. service.CreateErrMsgLog(errlog)
  6068. c.ServeSuccessJSON(map[string]interface{}{
  6069. "failed_code": -10,
  6070. "msg": res.ErrMsg,
  6071. })
  6072. return
  6073. } else {
  6074. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6075. order.OrderStatus = 1
  6076. order.IsPre = 1
  6077. order.Status = 1
  6078. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6079. order.SetlId = res.Output.Setlinfo.SetlID
  6080. order.PsnNo = res.Output.Setlinfo.PsnNo
  6081. order.PsnName = res.Output.Setlinfo.PsnName
  6082. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6083. order.Certno = res.Output.Setlinfo.Certno
  6084. order.Gend = res.Output.Setlinfo.Gend
  6085. order.Naty = res.Output.Setlinfo.Naty
  6086. order.Age = res.Output.Setlinfo.Age
  6087. order.Insutype = res.Output.Setlinfo.Insutype
  6088. order.PsnType = res.Output.Setlinfo.PsnType
  6089. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6090. order.SetlTime = res.Output.Setlinfo.SetlTime
  6091. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6092. if res.Output.Setlinfo.MedType == "140101" {
  6093. order.MedType = "14"
  6094. } else {
  6095. order.MedType = res.Output.Setlinfo.MedType
  6096. }
  6097. if reg_type == 1112 {
  6098. order.MedType = "1112"
  6099. }
  6100. if reg_type == 1111 {
  6101. order.MedType = "1111"
  6102. }
  6103. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6104. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6105. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6106. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6107. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6108. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6109. order.HifpPay = res.Output.Setlinfo.HifpPay
  6110. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6111. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6112. order.HifesPay = res.Output.Setlinfo.HifesPay
  6113. order.HifobPay = res.Output.Setlinfo.HifobPay
  6114. order.MafPay = res.Output.Setlinfo.MafPay
  6115. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6116. order.OthPay = res.Output.Setlinfo.OthPay
  6117. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6118. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6119. order.AcctPay = res.Output.Setlinfo.AcctPay
  6120. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6121. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6122. order.Balc = res.Output.Setlinfo.Balc
  6123. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6124. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6125. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6126. order.ClrWay = res.Output.Setlinfo.ClrWay
  6127. order.Creator = order.Creator
  6128. order.Modify = roles.AdminUserId
  6129. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6130. detailStr := string(setlDetail)
  6131. order.SetlDetail = detailStr
  6132. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6133. err = service.UpDateOrder(order)
  6134. if err == nil {
  6135. c.ServeSuccessJSON(map[string]interface{}{
  6136. "msg": "预结算成功",
  6137. })
  6138. } else {
  6139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6140. return
  6141. }
  6142. }
  6143. } else {
  6144. adminUser := c.GetAdminUserInfo()
  6145. errlog := &models.HisOrderError{
  6146. UserOrgId: adminUser.CurrentOrgId,
  6147. Ctime: time.Now().Unix(),
  6148. Mtime: time.Now().Unix(),
  6149. ErrMsg: res.ErrMsg,
  6150. Status: 1,
  6151. PatientId: id,
  6152. RecordTime: recordDateTime,
  6153. Stage: 4,
  6154. }
  6155. service.CreateErrMsgLog(errlog)
  6156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6157. return
  6158. }
  6159. } else {
  6160. adminUser := c.GetAdminUserInfo()
  6161. errlog := &models.HisOrderError{
  6162. UserOrgId: adminUser.CurrentOrgId,
  6163. Ctime: time.Now().Unix(),
  6164. Mtime: time.Now().Unix(),
  6165. ErrMsg: res.ErrMsg,
  6166. Status: 1,
  6167. PatientId: id,
  6168. RecordTime: recordDateTime,
  6169. Stage: 4,
  6170. }
  6171. service.CreateErrMsgLog(errlog)
  6172. c.ServeSuccessJSON(map[string]interface{}{
  6173. "failed_code": -10,
  6174. "msg": res.ErrMsg,
  6175. })
  6176. return
  6177. }
  6178. }
  6179. }
  6180. }
  6181. //func (c *HisApiController) GetSettleInfo() {
  6182. // id, _ := c.GetInt64("id")
  6183. // order_id, _ := c.GetInt64("order_id")
  6184. //
  6185. // record_time := c.GetString("record_time")
  6186. // pay_way, _ := c.GetInt64("pay_way")
  6187. // pay_price, _ := c.GetFloat("pay_price")
  6188. // pay_card_no := c.GetString("pay_card_no")
  6189. // discount_price, _ := c.GetFloat("discount_price")
  6190. // preferential_price, _ := c.GetFloat("preferential_price")
  6191. // reality_price, _ := c.GetFloat("reality_price")
  6192. // found_price, _ := c.GetFloat("found_price")
  6193. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6194. // private_price, _ := c.GetFloat("private_price")
  6195. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6196. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6197. //
  6198. // timeLayout := "2006-01-02"
  6199. // loc, _ := time.LoadLocation("Local")
  6200. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6201. // if err != nil {
  6202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6203. // return
  6204. // }
  6205. // recordDateTime := theTime.Unix()
  6206. // adminUser := c.GetAdminUserInfo()
  6207. //
  6208. // var prescriptions []*models.HisPrescription
  6209. //
  6210. // data := make(map[string]interface{})
  6211. // if settle_accounts_type == 1 { //日结
  6212. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6213. // data["pre"] = prescriptions
  6214. //
  6215. // } else { //月结
  6216. // start_time_str := c.GetString("start_time")
  6217. // end_time_str := c.GetString("end_time")
  6218. // timeLayout := "2006-01-02"
  6219. // loc, _ := time.LoadLocation("Local")
  6220. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6221. // if err != nil {
  6222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6223. // return
  6224. // }
  6225. // recordStartTime := theStartTime.Unix()
  6226. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6227. // if err != nil {
  6228. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6229. // return
  6230. // }
  6231. // recordEndTime := theEndTime.Unix()
  6232. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6233. // data["pre"] = prescriptions
  6234. //
  6235. // }
  6236. //
  6237. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6238. //
  6239. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6240. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6241. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6242. // strconv.FormatInt(his.PatientId, 10)
  6243. //
  6244. // order_src, _ := service.GetHisOrderByID(order_id)
  6245. //
  6246. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6247. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6248. //
  6249. // var total float64
  6250. // for _, item := range prescriptions {
  6251. // if item.Type == 1 { //药品
  6252. // for _, subItem := range item.HisDoctorAdviceInfo {
  6253. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6254. // }
  6255. // }
  6256. // if item.Type == 2 { //项目
  6257. // for _, subItem := range item.HisPrescriptionProject {
  6258. // total = total + (subItem.Price * float64(subItem.Count))
  6259. // }
  6260. // }
  6261. // }
  6262. //
  6263. // for _, item := range prescriptions {
  6264. // for _, subItem := range item.HisAdditionalCharge {
  6265. // total = total + (subItem.Price * float64(subItem.Count))
  6266. // }
  6267. // }
  6268. //
  6269. // allTotal := fmt.Sprintf("%.2f", total)
  6270. // var rf []*ResultFive
  6271. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6272. // psn_no := order_src.PsnNo
  6273. // mdtrt_id := order_src.MdtrtId
  6274. // chrg_bchno := order_src.Number
  6275. // cert_no := order_src.Certno
  6276. // insutype := rf[0].Insutype
  6277. //
  6278. // if his.IdCardType == 1 {
  6279. // cert_no = his.MedicalInsuranceNumber
  6280. // } else {
  6281. // cert_no = his.Certno
  6282. // }
  6283. //
  6284. // 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)
  6285. // var dat map[string]interface{}
  6286. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6287. // fmt.Println(dat)
  6288. // } else {
  6289. // fmt.Println(err)
  6290. // }
  6291. //
  6292. // userJSONBytes, _ := json.Marshal(dat)
  6293. //
  6294. //
  6295. //
  6296. // var res ResultSeven
  6297. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6298. // utils.ErrorLog("解析失败:%v", err)
  6299. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6300. // return
  6301. // }
  6302. // if res.Infcode == -1 {
  6303. // errlog := &models.HisOrderError{
  6304. // UserOrgId: adminUser.CurrentOrgId,
  6305. // Ctime: time.Now().Unix(),
  6306. // Mtime: time.Now().Unix(),
  6307. // Number: chrg_bchno,
  6308. // ErrMsg: res.ErrMsg,
  6309. // Status: 1,
  6310. // PatientId: id,
  6311. // RecordTime: recordDateTime,
  6312. // Stage: 6,
  6313. // }
  6314. // service.CreateErrMsgLog(errlog)
  6315. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6316. // return
  6317. // } else {
  6318. // order_src.OrderStatus = 2
  6319. // order_src.PayWay = pay_way
  6320. // order_src.PayPrice = pay_price
  6321. // order_src.PayCardNo = pay_card_no
  6322. // order_src.DiscountPrice = discount_price
  6323. // order_src.PreferentialPrice = preferential_price
  6324. // order_src.RealityPrice = reality_price
  6325. // order_src.FoundPrice = found_price
  6326. // order_src.MedicalInsurancePrice = medical_insurance_price
  6327. // order_src.PrivatePrice = private_price
  6328. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6329. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6330. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6331. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6332. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6333. // order_src.Certno = res.Output.Setlinfo.Certno
  6334. // order_src.Gend = res.Output.Setlinfo.Gend
  6335. // order_src.Naty = res.Output.Setlinfo.Naty
  6336. // order_src.Age = res.Output.Setlinfo.Age
  6337. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6338. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6339. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6340. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6341. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6342. // order_src.MedType = res.Output.Setlinfo.MedType
  6343. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6344. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6345. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6346. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6347. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6348. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6349. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6350. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6351. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6352. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6353. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6354. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6355. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6356. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6357. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6358. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6359. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6360. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6361. // order_src.Balc = res.Output.Setlinfo.Balc
  6362. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6363. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6364. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6365. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6366. // order_src.Creator = order_src.Creator
  6367. // order_src.Modify = roles.ID
  6368. // order_src.RequestLog = src_resquest
  6369. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6370. // detailStr := string(setlDetail)
  6371. // order_src.SetlDetail = detailStr
  6372. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6373. // err = service.UpDateOrder(order_src)
  6374. //
  6375. // if err == nil {
  6376. // c.ServeSuccessJSON(map[string]interface{}{
  6377. // "msg": "结算成功",
  6378. // })
  6379. // } else {
  6380. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6381. // return
  6382. // }
  6383. // }
  6384. // }
  6385. //}
  6386. //退款
  6387. func (c *HisApiController) Refund() {
  6388. order_id, _ := c.GetInt64("order_id")
  6389. admin_user_id, _ := c.GetInt64("admin_user_id")
  6390. adminUser := c.GetAdminUserInfo()
  6391. var order models.HisOrder
  6392. order, _ = service.GetHisOrderByID(order_id)
  6393. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6394. if order.ID == 0 {
  6395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6396. return
  6397. }
  6398. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6399. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6400. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6401. if config.IsOpen == 1 { //对接了医保,走医保流程
  6402. var res ResultSixteen
  6403. var resSixteen10265 ResultSixteen10265
  6404. var src_resquest string
  6405. var result string
  6406. if miConfig.MdtrtareaAdmvs == "421300" {
  6407. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6408. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6409. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6410. resp3, requestErr3 := http.Get(api3)
  6411. if requestErr3 != nil {
  6412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6413. return
  6414. }
  6415. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6416. if ioErr3 != nil {
  6417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6419. return
  6420. }
  6421. var respJSON3 map[string]interface{}
  6422. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6425. return
  6426. }
  6427. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6428. userJSONBytes3, _ := json.Marshal(respJSON3)
  6429. fmt.Println("log")
  6430. fmt.Println(string(userJSONBytes3))
  6431. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6432. utils.ErrorLog("解析失败:%v", err)
  6433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6434. return
  6435. }
  6436. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6437. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6438. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6439. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6440. resp3, requestErr3 := http.Get(api3)
  6441. if requestErr3 != nil {
  6442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6443. return
  6444. }
  6445. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6446. if ioErr3 != nil {
  6447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6449. return
  6450. }
  6451. var respJSON3 map[string]interface{}
  6452. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6455. return
  6456. }
  6457. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6458. userJSONBytes3, _ := json.Marshal(respJSON3)
  6459. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6460. utils.ErrorLog("解析失败:%v", err)
  6461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6462. return
  6463. }
  6464. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6465. res.Output = resSixteen10265.Output
  6466. res.ErrMsg = resSixteen10265.ErrMsg
  6467. res.Cainfo = resSixteen10265.Cainfo
  6468. res.WarnMsg = resSixteen10265.WarnMsg
  6469. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6470. res.Infcode = infocode
  6471. } else {
  6472. if miConfig.Code == "H15049901371" {
  6473. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6474. var dat map[string]interface{}
  6475. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6476. fmt.Println(dat)
  6477. } else {
  6478. fmt.Println(err)
  6479. }
  6480. saveLog(result, src_resquest, "2208", "退费")
  6481. userJSONBytes, _ := json.Marshal(dat)
  6482. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6483. utils.ErrorLog("解析失败:%v", err)
  6484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6485. return
  6486. }
  6487. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6488. res.Output = resSixteen10265.Output
  6489. res.ErrMsg = resSixteen10265.ErrMsg
  6490. res.Cainfo = resSixteen10265.Cainfo
  6491. res.WarnMsg = resSixteen10265.WarnMsg
  6492. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6493. res.Infcode = infocode
  6494. } else {
  6495. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6496. var dat map[string]interface{}
  6497. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6498. fmt.Println(dat)
  6499. } else {
  6500. fmt.Println(err)
  6501. }
  6502. saveLog(result, src_resquest, "2208", "退费")
  6503. userJSONBytes, _ := json.Marshal(dat)
  6504. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6505. utils.ErrorLog("解析失败:%v", err)
  6506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6507. return
  6508. }
  6509. }
  6510. }
  6511. if res.Infcode == 0 {
  6512. var res2 ResultSix
  6513. var resSix10265 ResultSix10265
  6514. if miConfig.MdtrtareaAdmvs == "421300" {
  6515. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6516. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6517. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6518. resp3, requestErr3 := http.Get(api3)
  6519. if requestErr3 != nil {
  6520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6521. return
  6522. }
  6523. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6524. if ioErr3 != nil {
  6525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6527. return
  6528. }
  6529. var respJSON3 map[string]interface{}
  6530. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6533. return
  6534. }
  6535. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6536. userJSONBytes3, _ := json.Marshal(respJSON3)
  6537. fmt.Println("log")
  6538. fmt.Println(string(userJSONBytes3))
  6539. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6540. utils.ErrorLog("解析失败:%v", err)
  6541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6542. return
  6543. }
  6544. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6545. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6546. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6547. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6548. resp3, requestErr3 := http.Get(api3)
  6549. if requestErr3 != nil {
  6550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6551. return
  6552. }
  6553. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6554. if ioErr3 != nil {
  6555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6557. return
  6558. }
  6559. var respJSON3 map[string]interface{}
  6560. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6563. return
  6564. }
  6565. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6566. userJSONBytes3, _ := json.Marshal(respJSON3)
  6567. fmt.Println("log")
  6568. fmt.Println(string(userJSONBytes3))
  6569. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6570. utils.ErrorLog("解析失败:%v", err)
  6571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6572. return
  6573. }
  6574. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6575. res2.Output = resSix10265.Output
  6576. res2.ErrMsg = resSix10265.ErrMsg
  6577. res2.Cainfo = resSix10265.Cainfo
  6578. res2.WarnMsg = resSix10265.WarnMsg
  6579. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6580. res2.Infcode = infocode
  6581. } else {
  6582. if miConfig.Code == "H15049901371" {
  6583. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6584. var dat map[string]interface{}
  6585. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6586. fmt.Println(dat)
  6587. } else {
  6588. fmt.Println(err)
  6589. }
  6590. saveLog(result2, src_request, "2205", "撤销明细")
  6591. userJSONBytes, _ := json.Marshal(dat)
  6592. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6593. utils.ErrorLog("解析失败:%v", err)
  6594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6595. return
  6596. }
  6597. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6598. res2.Output = resSix10265.Output
  6599. res2.ErrMsg = resSix10265.ErrMsg
  6600. res2.Cainfo = resSix10265.Cainfo
  6601. res2.WarnMsg = resSix10265.WarnMsg
  6602. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6603. res2.Infcode = infocode
  6604. } else {
  6605. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6606. var dat map[string]interface{}
  6607. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6608. fmt.Println(dat)
  6609. } else {
  6610. fmt.Println(err)
  6611. }
  6612. saveLog(result2, src_request, "2205", "撤销明细")
  6613. userJSONBytes, _ := json.Marshal(dat)
  6614. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6615. utils.ErrorLog("解析失败:%v", err)
  6616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6617. return
  6618. }
  6619. }
  6620. }
  6621. if res2.Infcode == 0 {
  6622. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6623. if err == nil {
  6624. c.ServeSuccessJSON(map[string]interface{}{
  6625. "msg": "退费成功",
  6626. })
  6627. } else {
  6628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6629. return
  6630. }
  6631. } else {
  6632. c.ServeSuccessJSON(map[string]interface{}{
  6633. "code": -10,
  6634. "msg": res2.ErrMsg,
  6635. })
  6636. }
  6637. } else {
  6638. c.ServeSuccessJSON(map[string]interface{}{
  6639. "code": -10,
  6640. "msg": res.ErrMsg,
  6641. })
  6642. }
  6643. }
  6644. }
  6645. func (c *HisApiController) RefundNumber() {
  6646. record_time := c.GetString("record_time")
  6647. //patient_id, _ := c.GetInt64("patient_id")
  6648. admin_user_id, _ := c.GetInt64("admin_user_id")
  6649. his_patient_id, _ := c.GetInt64("id")
  6650. timeLayout := "2006-01-02"
  6651. loc, _ := time.LoadLocation("Local")
  6652. adminUser := c.GetAdminUserInfo()
  6653. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6654. fmt.Println(err)
  6655. if err != nil {
  6656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6657. return
  6658. }
  6659. recordDateTime := theTime.Unix()
  6660. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6661. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6662. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6663. //order, _ := service.GetHisOrderByID(order_id)
  6664. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6665. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6666. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6667. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6668. if count > 0 {
  6669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6670. return
  6671. }
  6672. if config.IsOpen == 1 { //对接了医保,走医保流程
  6673. var res2 ResultSix
  6674. var resSix10265 ResultSix10265
  6675. if miConfig.MdtrtareaAdmvs == "421300" {
  6676. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6677. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6678. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6679. resp3, requestErr3 := http.Get(api3)
  6680. if requestErr3 != nil {
  6681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6682. return
  6683. }
  6684. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6685. if ioErr3 != nil {
  6686. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6688. return
  6689. }
  6690. var respJSON3 map[string]interface{}
  6691. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6692. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6694. return
  6695. }
  6696. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6697. userJSONBytes3, _ := json.Marshal(respJSON3)
  6698. fmt.Println("log")
  6699. fmt.Println(string(userJSONBytes3))
  6700. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6701. utils.ErrorLog("解析失败:%v", err)
  6702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6703. return
  6704. }
  6705. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6706. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6707. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6708. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6709. resp3, requestErr3 := http.Get(api3)
  6710. if requestErr3 != nil {
  6711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6712. return
  6713. }
  6714. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6715. if ioErr3 != nil {
  6716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6718. return
  6719. }
  6720. var respJSON3 map[string]interface{}
  6721. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6724. return
  6725. }
  6726. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6727. userJSONBytes3, _ := json.Marshal(respJSON3)
  6728. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6729. utils.ErrorLog("解析失败:%v", err)
  6730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6731. return
  6732. }
  6733. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6734. res2.Output = resSix10265.Output
  6735. res2.ErrMsg = resSix10265.ErrMsg
  6736. res2.Cainfo = resSix10265.Cainfo
  6737. res2.WarnMsg = resSix10265.WarnMsg
  6738. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6739. res2.Infcode = infocode
  6740. } else {
  6741. var api3 string
  6742. if miConfig.Code == "H15049901371" {
  6743. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6744. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6745. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6746. } else {
  6747. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6748. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6749. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6750. }
  6751. resp3, requestErr3 := http.Get(api3)
  6752. if requestErr3 != nil {
  6753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6754. return
  6755. }
  6756. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6757. if ioErr3 != nil {
  6758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6760. return
  6761. }
  6762. var respJSON3 map[string]interface{}
  6763. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6766. return
  6767. }
  6768. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6769. userJSONBytes3, _ := json.Marshal(respJSON3)
  6770. if miConfig.Code == "H15049901371" {
  6771. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6772. utils.ErrorLog("解析失败:%v", err)
  6773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6774. return
  6775. }
  6776. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6777. res2.Output = resSix10265.Output
  6778. res2.ErrMsg = resSix10265.ErrMsg
  6779. res2.Cainfo = resSix10265.Cainfo
  6780. res2.WarnMsg = resSix10265.WarnMsg
  6781. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6782. res2.Infcode = infocode
  6783. } else {
  6784. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6785. utils.ErrorLog("解析失败:%v", err)
  6786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6787. return
  6788. }
  6789. }
  6790. }
  6791. if res2.Infcode == 0 {
  6792. if err == nil {
  6793. c.ServeSuccessJSON(map[string]interface{}{
  6794. "msg": "退号成功",
  6795. })
  6796. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6797. } else {
  6798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6799. return
  6800. }
  6801. } else {
  6802. c.ServeSuccessJSON(map[string]interface{}{
  6803. "code": -10,
  6804. "msg": res2.ErrMsg,
  6805. })
  6806. }
  6807. } else {
  6808. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6809. //if err == nil {
  6810. // c.ServeSuccessJSON(map[string]interface{}{
  6811. // "msg": "退费成功",
  6812. // })
  6813. //} else {
  6814. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6815. // return
  6816. //}
  6817. }
  6818. }
  6819. func (c *HisApiController) RefundDetail() {
  6820. order_id, _ := c.GetInt64("order_id")
  6821. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6822. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6823. number := c.GetString("number")
  6824. record_time := c.GetString("record_time")
  6825. patient_id, _ := c.GetInt64("patient_id")
  6826. timeLayout := "2006-01-02"
  6827. loc, _ := time.LoadLocation("Local")
  6828. adminUser := c.GetAdminUserInfo()
  6829. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6830. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6831. fmt.Println(err)
  6832. if err != nil {
  6833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6834. return
  6835. }
  6836. recordDateTime := theTime.Unix()
  6837. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6838. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6839. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6840. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6841. var order models.HisOrder
  6842. order, _ = service.GetHisOrderByID(order_id)
  6843. if order.ID == 0 {
  6844. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6845. }
  6846. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6847. if config.IsOpen == 1 { //对接了医保,走医保流程
  6848. var res2 ResultSix
  6849. if miConfig.MdtrtareaAdmvs == "421300" {
  6850. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6851. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6852. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6853. resp3, requestErr3 := http.Get(api3)
  6854. if requestErr3 != nil {
  6855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6856. return
  6857. }
  6858. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6859. if ioErr3 != nil {
  6860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6862. return
  6863. }
  6864. var respJSON3 map[string]interface{}
  6865. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6868. return
  6869. }
  6870. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6871. userJSONBytes3, _ := json.Marshal(respJSON3)
  6872. fmt.Println("log")
  6873. fmt.Println(string(userJSONBytes3))
  6874. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6875. utils.ErrorLog("解析失败:%v", err)
  6876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6877. return
  6878. }
  6879. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6880. if err == nil {
  6881. c.ServeSuccessJSON(map[string]interface{}{
  6882. "msg": "撤销明细成功",
  6883. })
  6884. return
  6885. } else {
  6886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6887. return
  6888. }
  6889. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6890. var resSix10265 ResultSix10265
  6891. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6892. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6893. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6894. resp3, requestErr3 := http.Get(api3)
  6895. if requestErr3 != nil {
  6896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6897. return
  6898. }
  6899. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6900. if ioErr3 != nil {
  6901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6903. return
  6904. }
  6905. var respJSON3 map[string]interface{}
  6906. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6909. return
  6910. }
  6911. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6912. userJSONBytes3, _ := json.Marshal(respJSON3)
  6913. fmt.Println("log")
  6914. fmt.Println(string(userJSONBytes3))
  6915. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6916. utils.ErrorLog("解析失败:%v", err)
  6917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6918. return
  6919. }
  6920. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6921. res2.Output = resSix10265.Output
  6922. res2.ErrMsg = resSix10265.ErrMsg
  6923. res2.Cainfo = resSix10265.Cainfo
  6924. res2.WarnMsg = resSix10265.WarnMsg
  6925. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6926. res2.Infcode = infocode
  6927. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6928. if err == nil {
  6929. c.ServeSuccessJSON(map[string]interface{}{
  6930. "msg": "撤销明细成功",
  6931. })
  6932. return
  6933. } else {
  6934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6935. return
  6936. }
  6937. } else {
  6938. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6939. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6940. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6941. resp2, requestErr2 := http.Get(api2)
  6942. if requestErr2 != nil {
  6943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6944. return
  6945. }
  6946. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6947. if ioErr2 != nil {
  6948. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6950. return
  6951. }
  6952. var respJSON2 map[string]interface{}
  6953. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6956. return
  6957. }
  6958. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6959. if err == nil {
  6960. c.ServeSuccessJSON(map[string]interface{}{
  6961. "msg": "撤销明细成功",
  6962. })
  6963. return
  6964. } else {
  6965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6966. return
  6967. }
  6968. }
  6969. } else {
  6970. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6971. if err == nil {
  6972. c.ServeSuccessJSON(map[string]interface{}{
  6973. "msg": "退费成功",
  6974. })
  6975. } else {
  6976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6977. return
  6978. }
  6979. }
  6980. }
  6981. //对账
  6982. func (c *HisApiController) GetCheckAccount() {
  6983. start_time := c.GetString("start_time")
  6984. end_time := c.GetString("end_time")
  6985. insutype := c.GetString("insutype")
  6986. clr_type := c.GetString("clr_type")
  6987. clr_org := c.GetString("clr_optins")
  6988. admin_user_id, _ := c.GetInt64("admin_user_id")
  6989. adminUser := c.GetAdminUserInfo()
  6990. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6991. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6992. if len(clr_org) == 0 {
  6993. clr_org = miConfig.MdtrtareaAdmvs
  6994. }
  6995. timeLayout := "2006-01-02"
  6996. loc, _ := time.LoadLocation("Local")
  6997. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6998. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6999. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7000. fixmedins_setl_cnt := int64(len(orders))
  7001. var medfee_sumamt float64
  7002. var acct_pay float64
  7003. var fund_pay_sumamt float64
  7004. for _, item := range orders {
  7005. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7006. acct_pay = acct_pay + item.AcctPay
  7007. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7008. }
  7009. var user_name string
  7010. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7011. if role.ID == 0 {
  7012. user_name = "xxx"
  7013. } else {
  7014. user_name = role.UserName
  7015. }
  7016. var res ResultEight
  7017. var res10188 ResultEightFor10188
  7018. if config.IsOpen == 1 {
  7019. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7020. api := "http://192.168.3.111:9532/" + "jsyb/3201" +
  7021. "insutype=" + insutype +
  7022. "&clr_type=" + clr_type +
  7023. "&setl_optins=" + clr_org +
  7024. "&stmt_begndate=" + start_time +
  7025. "&stm_enddate=" + end_time +
  7026. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7027. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7028. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7029. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7030. "&fixmedins_code=" + miConfig.Code +
  7031. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7032. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7033. "&secret_key=" + miConfig.SecretKey +
  7034. "&org_name=" + miConfig.OrgName +
  7035. "&doctor=" + user_name +
  7036. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7037. fmt.Println(api)
  7038. resp, requestErr := http.Get(api)
  7039. if requestErr != nil {
  7040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7041. return
  7042. }
  7043. body, ioErr := ioutil.ReadAll(resp.Body)
  7044. fmt.Println(body)
  7045. if ioErr != nil {
  7046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7048. return
  7049. }
  7050. var respJSON map[string]interface{}
  7051. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7054. return
  7055. }
  7056. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7057. userJSONBytes, _ := json.Marshal(respJSON)
  7058. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7059. utils.ErrorLog("解析失败:%v", err)
  7060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7061. return
  7062. }
  7063. res.InfRefmsgid = res10188.InfRefmsgid
  7064. res.Output = res10188.Output
  7065. res.ErrMsg = res10188.ErrMsg
  7066. res.Cainfo = res10188.Cainfo
  7067. res.WarnMsg = res10188.WarnMsg
  7068. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7069. res.Infcode = infocode
  7070. } else {
  7071. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7072. "insutype=" + insutype +
  7073. "&clr_type=" + clr_type +
  7074. "&setl_optins=" + clr_org +
  7075. "&stmt_begndate=" + start_time +
  7076. "&stm_enddate=" + end_time +
  7077. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7078. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7079. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7080. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7081. "&fixmedins_code=" + miConfig.Code +
  7082. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7083. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7084. "&secret_key=" + miConfig.SecretKey +
  7085. "&org_name=" + miConfig.OrgName +
  7086. "&doctor=" + user_name
  7087. fmt.Println(api)
  7088. resp, requestErr := http.Get(api)
  7089. if requestErr != nil {
  7090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7091. return
  7092. }
  7093. body, ioErr := ioutil.ReadAll(resp.Body)
  7094. fmt.Println(body)
  7095. if ioErr != nil {
  7096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7098. return
  7099. }
  7100. var respJSON map[string]interface{}
  7101. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7104. return
  7105. }
  7106. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7107. userJSONBytes, _ := json.Marshal(respJSON)
  7108. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7109. utils.ErrorLog("解析失败:%v", err)
  7110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7111. return
  7112. }
  7113. }
  7114. if res.Infcode == 0 {
  7115. if res.Output.Stmtinfo.StmtRslt == "0" {
  7116. micc := &models.MedicalInsuranceCostCompare{
  7117. StartTime: startime.Unix(),
  7118. EndTime: endtime.Unix(),
  7119. Insutype: insutype,
  7120. CheckType: 1,
  7121. Num: fixmedins_setl_cnt,
  7122. Mtime: time.Now().Unix(),
  7123. Status: 1,
  7124. UserOrgId: adminUser.CurrentOrgId,
  7125. CostTotal: medfee_sumamt,
  7126. FuncTotal: fund_pay_sumamt,
  7127. PsnPay: acct_pay,
  7128. Creator: admin_user_id,
  7129. Ctime: time.Now().Unix(),
  7130. }
  7131. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7132. if err == nil {
  7133. c.ServeSuccessJSON(map[string]interface{}{
  7134. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7135. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7136. })
  7137. } else {
  7138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7139. }
  7140. } else {
  7141. c.ServeSuccessJSON(map[string]interface{}{
  7142. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7143. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7144. })
  7145. }
  7146. } else {
  7147. c.ServeSuccessJSON(map[string]interface{}{
  7148. "code": -10,
  7149. "msg": res.ErrMsg,
  7150. })
  7151. }
  7152. }
  7153. }
  7154. func (c *HisApiController) Check310() {
  7155. adminUser := c.GetAdminUserInfo()
  7156. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7157. var user_name string
  7158. user_name = "高慧裕"
  7159. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7160. "insutype=" + "310" +
  7161. "&clr_type=" + "11" +
  7162. "&setl_optins=" + "441202" +
  7163. "&stmt_begndate=" + "2022-03-01" +
  7164. "&stm_enddate=" + "2022-03-31" +
  7165. "&medfee_sumamt=" + "194930.12" +
  7166. "&fund_pay_sumamt=" + "188741.46" +
  7167. "&acct_pay=" + "0" +
  7168. "&fixmedins_setl_cnt=" + "452" +
  7169. "&fixmedins_code=" + miConfig.Code +
  7170. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7171. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7172. "&secret_key=" + miConfig.SecretKey +
  7173. "&org_name=" + miConfig.OrgName +
  7174. "&doctor=" + user_name
  7175. fmt.Println(api)
  7176. resp, requestErr := http.Get(api)
  7177. if requestErr != nil {
  7178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7179. return
  7180. }
  7181. body, ioErr := ioutil.ReadAll(resp.Body)
  7182. fmt.Println(body)
  7183. if ioErr != nil {
  7184. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7186. return
  7187. }
  7188. var respJSON map[string]interface{}
  7189. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7192. return
  7193. }
  7194. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7195. userJSONBytes, _ := json.Marshal(respJSON)
  7196. var res ResultEight
  7197. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7198. utils.ErrorLog("解析失败:%v", err)
  7199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7200. return
  7201. }
  7202. }
  7203. func (c *HisApiController) Check390() {
  7204. adminUser := c.GetAdminUserInfo()
  7205. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7206. var user_name string
  7207. user_name = "高慧裕"
  7208. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7209. "insutype=" + "390" +
  7210. "&clr_type=" + "11" +
  7211. "&setl_optins=" + "441202" +
  7212. "&stmt_begndate=" + "2022-03-01" +
  7213. "&stm_enddate=" + "2022-03-31" +
  7214. "&medfee_sumamt=" + "1068448.89" +
  7215. "&fund_pay_sumamt=" + "1014677.62" +
  7216. "&acct_pay=" + "0" +
  7217. "&fixmedins_setl_cnt=" + "1950" +
  7218. "&fixmedins_code=" + miConfig.Code +
  7219. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7220. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7221. "&secret_key=" + miConfig.SecretKey +
  7222. "&org_name=" + miConfig.OrgName +
  7223. "&doctor=" + user_name
  7224. fmt.Println(api)
  7225. resp, requestErr := http.Get(api)
  7226. if requestErr != nil {
  7227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7228. return
  7229. }
  7230. body, ioErr := ioutil.ReadAll(resp.Body)
  7231. fmt.Println(body)
  7232. if ioErr != nil {
  7233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7235. return
  7236. }
  7237. var respJSON map[string]interface{}
  7238. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7241. return
  7242. }
  7243. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7244. userJSONBytes, _ := json.Marshal(respJSON)
  7245. var res ResultEight
  7246. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7247. utils.ErrorLog("解析失败:%v", err)
  7248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7249. return
  7250. }
  7251. }
  7252. //对账明细
  7253. func (c *HisApiController) GetCheckDetailAccount() {
  7254. start_time := c.GetString("start_time")
  7255. end_time := c.GetString("end_time")
  7256. admin_user_id, _ := c.GetInt64("admin_user_id")
  7257. adminUser := c.GetAdminUserInfo()
  7258. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7259. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7260. timeLayout := "2006-01-02"
  7261. loc, _ := time.LoadLocation("Local")
  7262. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7263. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7264. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7265. Mkdir(miConfig.OrgName)
  7266. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7267. file_name := file + ".txt"
  7268. zip_name := file + ".zip"
  7269. zip_path := miConfig.OrgName + "/" + zip_name
  7270. file_path := miConfig.OrgName + "/" + file_name
  7271. decimal.DivisionPrecision = 2
  7272. var medfee_sumamt float64
  7273. var psn_cash_pay float64
  7274. var fund_pay_sumamt float64
  7275. fixmedins_setl_cnt := int64(len(orders))
  7276. for _, item := range orders {
  7277. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7278. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7279. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7280. }
  7281. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7282. defer f.Close()
  7283. if err != nil {
  7284. fmt.Println(err.Error())
  7285. } else {
  7286. for _, item := range orders {
  7287. var refd_setl_flag string
  7288. if item.OrderStatus == 2 {
  7289. refd_setl_flag = "0"
  7290. var str string
  7291. str = item.SetlId + " " +
  7292. item.MdtrtId + " " +
  7293. item.PsnNo + " " +
  7294. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7295. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7296. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7297. _, err = f.Write([]byte(str))
  7298. }
  7299. if item.OrderStatus == 3 {
  7300. var str string
  7301. str = item.SetlId + " " +
  7302. item.MdtrtId + " " +
  7303. item.PsnNo + " " +
  7304. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7305. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7306. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7307. _, err = f.Write([]byte(str))
  7308. var str2 string
  7309. str2 = item.SetlId + " " +
  7310. item.MdtrtId + " " +
  7311. item.PsnNo + " " +
  7312. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7313. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7314. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7315. _, err = f.Write([]byte(str2))
  7316. }
  7317. }
  7318. }
  7319. Zip(file_path, zip_path)
  7320. fmt.Println(ReadFile(zip_path))
  7321. fmt.Println(string(ReadFile(zip_path)))
  7322. if config.IsOpen == 1 {
  7323. var user_name string
  7324. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7325. if role.ID == 0 {
  7326. user_name = "管理员"
  7327. } else {
  7328. user_name = role.UserName
  7329. }
  7330. baseParams := models.BaseParams{
  7331. SecretKey: miConfig.SecretKey,
  7332. FixmedinsCode: miConfig.Code,
  7333. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7334. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7335. OrgName: miConfig.OrgName,
  7336. Doctor: user_name,
  7337. }
  7338. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7339. var dat map[string]interface{}
  7340. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7341. fmt.Println(dat)
  7342. } else {
  7343. fmt.Println(err)
  7344. }
  7345. userJSONBytes, _ := json.Marshal(dat)
  7346. var res ResultNine
  7347. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7348. utils.ErrorLog("解析失败:%v", err)
  7349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7350. return
  7351. }
  7352. if res.Infcode == 0 {
  7353. fileNo := res.Output.FileQuryNo
  7354. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7355. "file_qury_no=" + fileNo +
  7356. "&setl_optins=" + "定点医保中心" +
  7357. "&stmt_begndate=" + start_time +
  7358. "&stm_enddate=" + end_time +
  7359. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7360. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7361. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7362. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7363. "&fixmedins_code=" + miConfig.Code +
  7364. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7365. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7366. "&secret_key=" + miConfig.SecretKey +
  7367. "&org_name=" + miConfig.OrgName +
  7368. "&doctor=" + user_name
  7369. resp, requestErr := http.Get(api)
  7370. if requestErr != nil {
  7371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7372. return
  7373. }
  7374. body, ioErr := ioutil.ReadAll(resp.Body)
  7375. if ioErr != nil {
  7376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7378. return
  7379. }
  7380. var respJSON map[string]interface{}
  7381. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7384. return
  7385. }
  7386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7387. userJSONBytes, _ := json.Marshal(respJSON)
  7388. var res ResultTen
  7389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7390. utils.ErrorLog("解析失败:%v", err)
  7391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7392. return
  7393. }
  7394. if res.Infcode == 0 {
  7395. service.Gdyb9102(baseParams, zip_name, fileNo)
  7396. micc := &models.MedicalInsuranceCostCompare{
  7397. StartTime: startime.Unix(),
  7398. EndTime: endtime.Unix(),
  7399. Insutype: "0",
  7400. CheckType: 2,
  7401. Num: fixmedins_setl_cnt,
  7402. Mtime: time.Now().Unix(),
  7403. Status: 1,
  7404. UserOrgId: adminUser.CurrentOrgId,
  7405. CostTotal: medfee_sumamt,
  7406. FuncTotal: fund_pay_sumamt,
  7407. PsnPay: psn_cash_pay,
  7408. Creator: admin_user_id,
  7409. Ctime: time.Now().Unix(),
  7410. }
  7411. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7412. c.ServeSuccessJSON(map[string]interface{}{
  7413. "msg": "明细对账成功",
  7414. })
  7415. }
  7416. } else {
  7417. }
  7418. }
  7419. }
  7420. type CustomOrderInfo struct {
  7421. Name string
  7422. Spec string
  7423. Unit string
  7424. Count float64
  7425. Price float64
  7426. Total float64
  7427. }
  7428. func (c *HisApiController) GetSettleAccounts() {
  7429. //id, _ := c.GetInt64("id")
  7430. //record_time := c.GetString("record_time")
  7431. order_id, _ := c.GetInt64("order_id")
  7432. admin_user_id, _ := c.GetInt64("admin_user_id")
  7433. //timeLayout := "2006-01-02"
  7434. //loc, _ := time.LoadLocation("Local")
  7435. //
  7436. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7437. //if err != nil {
  7438. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7439. // return
  7440. //}
  7441. //recordDateTime := theTime.Unix()
  7442. adminUser := c.GetAdminUserInfo()
  7443. order, _ := service.GetHisOrderByID(order_id)
  7444. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7445. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7446. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7447. orderInfos = append(orderInfos, orderInfos_two...)
  7448. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7449. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7450. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7451. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7452. //var config []*models.HisXtDiagnoseConfig
  7453. var name string
  7454. for _, item := range diagnosis_ids {
  7455. id, _ := strconv.ParseInt(item, 10, 64)
  7456. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7457. if len(name) == 0 {
  7458. name = diagnosisConfig.ClassName
  7459. } else {
  7460. name = name + "," + diagnosisConfig.ClassName
  7461. }
  7462. }
  7463. var bedCostTotal float64 = 0 //床位总费
  7464. var bedCostSelfTotal float64 = 0 //床位自费
  7465. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7466. var operationCostTotal float64 = 0 //手术费
  7467. var operationCostSelfTotal float64 = 0 //手术费
  7468. var operationCostPartSelfTotal float64 = 0 //手术费
  7469. var otherCostTotal float64 = 0 //其他费用
  7470. var otherCostSelfTotal float64 = 0 //其他费用
  7471. var otherCostPartSelfTotal float64 = 0 //其他费用
  7472. var materialCostTotal float64 = 0 //材料费
  7473. var materialCostSelfTotal float64 = 0 //材料费
  7474. var materialCostPartSelfTotal float64 = 0 //材料费
  7475. var westernMedicineCostTotal float64 = 0 //西药费
  7476. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7477. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7478. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7479. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7480. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7481. var checkCostTotal float64 = 0 //检查费
  7482. var checkCostSelfTotal float64 = 0 //检查费
  7483. var checkCostPartSelfTotal float64 = 0 //检查费
  7484. var laboratoryCostTotal float64 = 0 //化验费
  7485. var laboratoryCostSelfTotal float64 = 0 //化验费
  7486. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7487. var treatCostTotal float64 = 0 //治疗费用
  7488. var treatCostSelfTotal float64 = 0 //治疗费用
  7489. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7490. decimal.DivisionPrecision = 2
  7491. for _, item := range orderInfos {
  7492. if item.MedChrgitmType == "01" { //床位费
  7493. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7494. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7495. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7496. }
  7497. if item.MedChrgitmType == "03" { //检查费
  7498. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7499. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7500. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7501. }
  7502. if item.MedChrgitmType == "04" { //化验费
  7503. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7504. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7505. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7506. }
  7507. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  7508. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7509. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7510. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7511. }
  7512. if item.MedChrgitmType == "06" { //手术费
  7513. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7514. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7515. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7516. }
  7517. if item.MedChrgitmType == "08" { //材料费
  7518. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7519. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7520. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7521. }
  7522. if item.MedChrgitmType == "09" { //西药费
  7523. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7524. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7525. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7526. }
  7527. if item.MedChrgitmType == "11" { //中成费
  7528. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7529. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7530. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7531. }
  7532. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  7533. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7534. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7535. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7536. }
  7537. }
  7538. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7539. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7540. var user_name string
  7541. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7542. if role.ID == 0 {
  7543. user_name = "管理员"
  7544. } else {
  7545. user_name = role.UserName
  7546. }
  7547. baseParams := models.BaseParams{
  7548. SecretKey: miConfig.SecretKey,
  7549. FixmedinsCode: miConfig.Code,
  7550. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7551. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7552. OrgName: miConfig.OrgName,
  7553. Doctor: user_name,
  7554. }
  7555. businessParams := models.BusinessParams{
  7556. PsnNo: order.PsnNo,
  7557. MdtrtId: order.MdtrtId,
  7558. SetlId: order.SetlId,
  7559. }
  7560. var res ResultEleven
  7561. var resEleven10265 ResultEleven10265
  7562. if config.IsOpen == 1 {
  7563. if miConfig.MdtrtareaAdmvs == "421300" {
  7564. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7565. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7566. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7567. resp, requestErr := http.Get(api)
  7568. if requestErr != nil {
  7569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7570. return
  7571. }
  7572. body, ioErr := ioutil.ReadAll(resp.Body)
  7573. if ioErr != nil {
  7574. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7576. return
  7577. }
  7578. var respJSON map[string]interface{}
  7579. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7580. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7582. return
  7583. }
  7584. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7585. result, _ := json.Marshal(respJSON)
  7586. fmt.Println("log")
  7587. fmt.Println(string(result))
  7588. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7589. utils.ErrorLog("解析失败:%v", err)
  7590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7591. return
  7592. }
  7593. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7594. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7595. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7596. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7597. resp, requestErr := http.Get(api)
  7598. if requestErr != nil {
  7599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7600. return
  7601. }
  7602. body, ioErr := ioutil.ReadAll(resp.Body)
  7603. if ioErr != nil {
  7604. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7606. return
  7607. }
  7608. var respJSON map[string]interface{}
  7609. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7612. return
  7613. }
  7614. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7615. result, _ := json.Marshal(respJSON)
  7616. fmt.Println("log")
  7617. fmt.Println(string(result))
  7618. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7619. utils.ErrorLog("解析失败:%v", err)
  7620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7621. return
  7622. }
  7623. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7624. res.Output = resEleven10265.Output
  7625. res.ErrMsg = resEleven10265.ErrMsg
  7626. res.Cainfo = resEleven10265.Cainfo
  7627. res.WarnMsg = resEleven10265.WarnMsg
  7628. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7629. res.Infcode = infocode
  7630. } else {
  7631. result2 := service.Gdyb5204(baseParams, businessParams)
  7632. saveLog(result2, "", "5204", "查询")
  7633. result := service.Gdyb5203(baseParams, businessParams)
  7634. var dat map[string]interface{}
  7635. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7636. fmt.Println(dat)
  7637. } else {
  7638. fmt.Println(err)
  7639. }
  7640. userJSONBytes, _ := json.Marshal(dat)
  7641. if miConfig.Code == "H15049901371" {
  7642. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7643. utils.ErrorLog("解析失败:%v", err)
  7644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7645. return
  7646. }
  7647. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7648. res.Output = resEleven10265.Output
  7649. res.ErrMsg = resEleven10265.ErrMsg
  7650. res.Cainfo = resEleven10265.Cainfo
  7651. res.WarnMsg = resEleven10265.WarnMsg
  7652. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7653. res.Infcode = infocode
  7654. } else {
  7655. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7656. utils.ErrorLog("解析失败:%v", err)
  7657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7658. return
  7659. }
  7660. }
  7661. }
  7662. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7663. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7664. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7665. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7666. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7667. var doctor_name string
  7668. if roles.ID == 0 {
  7669. doctor_name = "管理员"
  7670. } else {
  7671. doctor_name = roles.UserName
  7672. }
  7673. yiliao_leibie := ""
  7674. switch order.MedType {
  7675. case "11":
  7676. yiliao_leibie = "普通门诊"
  7677. break
  7678. case "12":
  7679. yiliao_leibie = "门诊挂号"
  7680. break
  7681. case "13":
  7682. yiliao_leibie = "急诊"
  7683. break
  7684. case "14":
  7685. yiliao_leibie = "门诊特殊病"
  7686. break
  7687. case "15":
  7688. yiliao_leibie = "门诊统筹"
  7689. break
  7690. case "16":
  7691. yiliao_leibie = "门诊慢性病"
  7692. break
  7693. case "21":
  7694. yiliao_leibie = "普通住院"
  7695. break
  7696. }
  7697. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7698. if res.Infcode == 0 {
  7699. c.ServeSuccessJSON(map[string]interface{}{
  7700. "diagnosis": name,
  7701. "order_infos": orderInfos,
  7702. "number": order.MdtrtId,
  7703. "date": order.SettleAccountsDate,
  7704. "charge_admin": charge_admin,
  7705. "printor_admin": printor_admin,
  7706. "info": res.Output.Setlinfo,
  7707. "bedCostTotal": bedCostTotal,
  7708. "bedCostSelfTotal": bedCostSelfTotal,
  7709. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  7710. "operationCostTotal": operationCostTotal,
  7711. "operationCostSelfTotal": operationCostSelfTotal,
  7712. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  7713. "otherCostTotal": otherCostTotal,
  7714. "otherCostSelfTotal": otherCostSelfTotal,
  7715. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  7716. "materialCostTotal": materialCostTotal,
  7717. "materialCostSelfTotal": materialCostSelfTotal,
  7718. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  7719. "westernMedicineCostTotal": westernMedicineCostTotal,
  7720. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  7721. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  7722. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  7723. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  7724. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  7725. "checkCostTotal": checkCostTotal,
  7726. "checkCostSelfTotal": checkCostSelfTotal,
  7727. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  7728. "laboratoryCostTotal": laboratoryCostTotal,
  7729. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  7730. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  7731. "treatCostTotal": treatCostTotal,
  7732. "treatCostSelfTotal": treatCostSelfTotal,
  7733. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  7734. "doctor_code": adminRole_two.DoctorCode,
  7735. "doctor_name": doctor_name,
  7736. "health_card_no": order.PsnNo,
  7737. "department": departments.Name,
  7738. "yiliao_leibie": yiliao_leibie,
  7739. "after_money": order.AccountPrice,
  7740. "patient": patient,
  7741. "org_name": miConfig.OrgName,
  7742. "org_code": miConfig.Code,
  7743. "order_number": order.Number,
  7744. //"his": his_hospital,
  7745. //"check_order_info": cus_slice,
  7746. })
  7747. }
  7748. }
  7749. }
  7750. func (c *HisApiController) CheckTreatment() {
  7751. patient_id, _ := c.GetInt64("patient_id")
  7752. id_card_no := c.GetString("id_card_no")
  7753. insutype := c.GetString("insutype")
  7754. med_type := c.GetString("med_type")
  7755. admin_user_id, _ := c.GetInt64("admin_user_id")
  7756. adminUser := c.GetAdminUserInfo()
  7757. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7758. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7759. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7760. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7761. if miConfig.MdtrtareaAdmvs == "421300" {
  7762. var res ResultTwo
  7763. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7764. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7765. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(2, 10)
  7766. resp, requestErr := http.Get(api)
  7767. if requestErr != nil {
  7768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7769. return
  7770. }
  7771. body, ioErr := ioutil.ReadAll(resp.Body)
  7772. if ioErr != nil {
  7773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7775. return
  7776. }
  7777. var respJSON map[string]interface{}
  7778. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7781. return
  7782. }
  7783. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7784. result, _ := json.Marshal(respJSON)
  7785. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7786. utils.ErrorLog("解析失败:%v", err)
  7787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7788. return
  7789. }
  7790. if res.Infcode == 0 {
  7791. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7792. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7793. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7794. resp, requestErr := http.Get(api)
  7795. if requestErr != nil {
  7796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7797. return
  7798. }
  7799. body, ioErr := ioutil.ReadAll(resp.Body)
  7800. if ioErr != nil {
  7801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7803. return
  7804. }
  7805. var respJSON map[string]interface{}
  7806. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7809. return
  7810. }
  7811. var res Result2001
  7812. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7813. result2, _ := json.Marshal(respJSON)
  7814. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7815. utils.ErrorLog("解析失败:%v", err)
  7816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7817. return
  7818. }
  7819. if res.Infcode == 0 {
  7820. c.ServeSuccessJSON(map[string]interface{}{
  7821. "msg": res.Output.Trtinfo,
  7822. })
  7823. }
  7824. } else {
  7825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7826. return
  7827. }
  7828. } else {
  7829. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7830. var dat map[string]interface{}
  7831. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7832. fmt.Println(dat)
  7833. } else {
  7834. fmt.Println(err)
  7835. }
  7836. userJSONBytes, _ := json.Marshal(dat)
  7837. var res ResultTwo
  7838. var res10265 ResultTwo10265
  7839. if miConfig.Code == "H15049901371" {
  7840. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7841. utils.ErrorLog("解析失败:%v", err)
  7842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7843. return
  7844. }
  7845. res.ErrMsg = res10265.ErrMsg
  7846. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7847. res.Infcode = infocode
  7848. res.Output = res10265.Output
  7849. res.InfRefmsgid = res10265.InfRefmsgid
  7850. } else {
  7851. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7852. utils.ErrorLog("解析失败:%v", err)
  7853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7854. return
  7855. }
  7856. }
  7857. var user_name string
  7858. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7859. if role.ID == 0 {
  7860. user_name = "xxx"
  7861. } else {
  7862. user_name = role.UserName
  7863. }
  7864. baseParams := models.BaseParams{
  7865. SecretKey: miConfig.SecretKey,
  7866. FixmedinsCode: miConfig.Code,
  7867. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7868. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7869. OrgName: miConfig.OrgName,
  7870. Doctor: user_name,
  7871. }
  7872. if config.IsOpen == 1 {
  7873. if miConfig.Code == "H15049901371" {
  7874. if med_type == "14" {
  7875. if insutype == "390" {
  7876. med_type = "9933"
  7877. } else if insutype == "310" {
  7878. med_type = "990502"
  7879. }
  7880. } else if med_type == "11" {
  7881. med_type = "11"
  7882. }
  7883. }
  7884. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7885. var dat map[string]interface{}
  7886. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7887. fmt.Println(dat)
  7888. } else {
  7889. fmt.Println(err)
  7890. }
  7891. var res Result2001
  7892. var res10265 Result2001Org10265
  7893. if miConfig.Code == "H15049901371" {
  7894. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7895. utils.ErrorLog("解析失败:%v", err)
  7896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7897. return
  7898. }
  7899. res.ErrMsg = res10265.ErrMsg
  7900. res.Output = res10265.Output
  7901. res.InfRefmsgid = res10265.InfRefmsgid
  7902. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7903. res.Infcode = infocode
  7904. } else {
  7905. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7906. utils.ErrorLog("解析失败:%v", err)
  7907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7908. return
  7909. }
  7910. }
  7911. if res.Infcode == 0 {
  7912. c.ServeSuccessJSON(map[string]interface{}{
  7913. "msg": res.Output.Trtinfo,
  7914. })
  7915. }
  7916. }
  7917. }
  7918. }
  7919. //func (c *HisApiController) PutRecord() {
  7920. // id, _ := c.GetInt64("id")
  7921. // record_time := c.GetString("record_time")
  7922. // timeLayout := "2006-01-02"
  7923. // loc, _ := time.LoadLocation("Local")
  7924. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7925. // if err != nil {
  7926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7927. // return
  7928. // }
  7929. // recordDateTime := theTime.Unix()
  7930. //
  7931. // adminInfo := c.GetAdminUserInfo()
  7932. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7933. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7934. //
  7935. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7936. //
  7937. // fmt.Println(miConfig.SecretKey)
  7938. //
  7939. // if patient == nil {
  7940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7941. // return
  7942. // }
  7943. // if len(patient.IdCardNo) == 0 {
  7944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7945. // return
  7946. // }
  7947. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7948. // if config.IsOpen == 1 {
  7949. // 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
  7950. // resp, requestErr := http.Get(api)
  7951. // if requestErr != nil {
  7952. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7953. // return
  7954. // }
  7955. // defer resp.Body.Close()
  7956. // body, ioErr := ioutil.ReadAll(resp.Body)
  7957. // if ioErr != nil {
  7958. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7959. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7960. // return
  7961. // }
  7962. // var respJSON map[string]interface{}
  7963. //
  7964. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7965. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7966. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7967. // return
  7968. // }
  7969. //
  7970. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7971. // userJSONBytes, _ := json.Marshal(userJSON)
  7972. // var res ResultTwo
  7973. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7974. // utils.ErrorLog("解析失败:%v", err)
  7975. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7976. // return
  7977. // }
  7978. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7979. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7980. // infoStr := string(Iinfos)
  7981. // idetinfoStr := string(Idetinfos)
  7982. //
  7983. // if res.Infcode == 0 {
  7984. // his := models.VMHisPatient{
  7985. // Status: 1,
  7986. // Ctime: time.Now().Unix(),
  7987. // Mtime: time.Now().Unix(),
  7988. // PsnNo: res.Output.Baseinfo.PsnNo,
  7989. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7990. // Certno: res.Output.Baseinfo.Certno,
  7991. // PsnName: res.Output.Baseinfo.PsnName,
  7992. // Gend: res.Output.Baseinfo.Gend,
  7993. // Naty: res.Output.Baseinfo.Naty,
  7994. // Brdy: res.Output.Baseinfo.Brdy,
  7995. // Age: res.Output.Baseinfo.Age,
  7996. // Iinfo: infoStr,
  7997. // Idetinfo: idetinfoStr,
  7998. // PatientId: patient.ID,
  7999. // RecordDate: theTime.Unix(),
  8000. // UserOrgId: adminInfo.CurrentOrgId,
  8001. // AdminUserId: adminInfo.AdminUser.Id,
  8002. // IsReturn: 1,
  8003. // }
  8004. //
  8005. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8006. // //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")
  8007. // //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")
  8008. //
  8009. // //var dat map[string]interface{}
  8010. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8011. // // fmt.Println(dat)
  8012. // //} else {
  8013. // // fmt.Println(err)
  8014. // //}
  8015. //
  8016. // var dat2 map[string]interface{}
  8017. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8018. // fmt.Println(dat2)
  8019. // } else {
  8020. // fmt.Println(err)
  8021. // }
  8022. //
  8023. // } else {
  8024. // adminUser := c.GetAdminUserInfo()
  8025. // errlog := &models.HisOrderError{
  8026. // UserOrgId: adminUser.CurrentOrgId,
  8027. // Ctime: time.Now().Unix(),
  8028. // Mtime: time.Now().Unix(),
  8029. // ErrMsg: res.ErrMsg,
  8030. // Status: 1,
  8031. // PatientId: id,
  8032. // RecordTime: recordDateTime,
  8033. // Stage: 1,
  8034. // }
  8035. // service.CreateErrMsgLog(errlog)
  8036. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8037. // return
  8038. // }
  8039. // }
  8040. //
  8041. //}
  8042. //func (c *HisApiController) GetUploadDiag() {
  8043. // id, _ := c.GetInt64("id")
  8044. // record_time := c.GetString("record_time")
  8045. //
  8046. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8047. // sick_type, _ := c.GetInt64("sick_type")
  8048. // reg_type, _ := c.GetInt64("reg_type")
  8049. //
  8050. // timeLayout := "2006-01-02"
  8051. // loc, _ := time.LoadLocation("Local")
  8052. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8053. // if err != nil {
  8054. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8055. // return
  8056. // }
  8057. //
  8058. // var patientPrescription models.HisPrescriptionInfo
  8059. // recordDateTime := theTime.Unix()
  8060. // adminInfo := c.GetAdminUserInfo()
  8061. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8062. //
  8063. // if patientPrescription.ID == 0 {
  8064. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8065. // }
  8066. //
  8067. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8068. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8069. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8070. // sickConfig, _ := service.FindSickById(sick_type)
  8071. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8072. //
  8073. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8074. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8075. // "&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 +
  8076. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8077. // resp2, requestErr2 := http.Get(api2)
  8078. // if requestErr2 != nil {
  8079. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8080. // return
  8081. // }
  8082. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8083. // if ioErr2 != nil {
  8084. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8085. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8086. // return
  8087. // }
  8088. // var respJSON2 map[string]interface{}
  8089. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8090. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8091. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8092. // return
  8093. // }
  8094. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8095. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8096. //
  8097. // var res2 ResultSix
  8098. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8099. // utils.ErrorLog("解析失败:%v", err)
  8100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8101. // return
  8102. // }
  8103. // if res2.Infcode != 0 {
  8104. // adminUser := c.GetAdminUserInfo()
  8105. // errlog := &models.HisOrderError{
  8106. // UserOrgId: adminUser.CurrentOrgId,
  8107. // Ctime: time.Now().Unix(),
  8108. // Mtime: time.Now().Unix(),
  8109. // ErrMsg: res2.ErrMsg,
  8110. // Status: 1,
  8111. // PatientId: id,
  8112. // RecordTime: recordDateTime,
  8113. // Stage: 3,
  8114. // }
  8115. // service.CreateErrMsgLog(errlog)
  8116. //
  8117. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8118. // return
  8119. // }
  8120. //
  8121. // c.ServeSuccessJSON(map[string]interface{}{
  8122. // "msg": "上传成功",
  8123. // })
  8124. //
  8125. //}
  8126. type QueryResult struct {
  8127. ID int64
  8128. Name string
  8129. Code string
  8130. List_type_code string
  8131. }
  8132. func (c *HisApiController) GetCheckCode() {
  8133. ids_str := c.GetString("ids")
  8134. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8135. ids_arr := strings.Split(ids_str, ",")
  8136. var queryResult []QueryResult
  8137. ids := make([]int64, 0)
  8138. for _, item := range ids_arr {
  8139. id, _ := strconv.ParseInt(item, 10, 64)
  8140. ids = append(ids, id)
  8141. }
  8142. if record_type == 1 {
  8143. drugs, _ := service.GetBatchDrugList(ids)
  8144. for _, item := range drugs {
  8145. result := QueryResult{
  8146. ID: item.ID,
  8147. Name: item.DrugName,
  8148. Code: item.MedicalInsuranceNumber,
  8149. List_type_code: "101",
  8150. }
  8151. queryResult = append(queryResult, result)
  8152. }
  8153. } else if record_type == 2 {
  8154. goods, _ := service.GetBatchGoodInformationList(ids)
  8155. for _, item := range goods {
  8156. result := QueryResult{
  8157. ID: item.ID,
  8158. Name: item.GoodName,
  8159. Code: item.MedicalInsuranceNumber,
  8160. List_type_code: "301",
  8161. }
  8162. queryResult = append(queryResult, result)
  8163. }
  8164. } else if record_type == 3 {
  8165. projects, _ := service.GetBathchMyPorjecgList(ids)
  8166. for _, item := range projects {
  8167. result := QueryResult{
  8168. ID: item.ID,
  8169. Name: item.ProjectName,
  8170. Code: item.MedicalCode,
  8171. List_type_code: "201",
  8172. }
  8173. queryResult = append(queryResult, result)
  8174. }
  8175. }
  8176. admin_user_id, _ := c.GetInt64("admin_user_id")
  8177. adminUser := c.GetAdminUserInfo()
  8178. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8179. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8180. var user_name string
  8181. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8182. if role.ID == 0 {
  8183. user_name = "xxx"
  8184. } else {
  8185. user_name = role.UserName
  8186. }
  8187. baseParams := &models.BaseParams{
  8188. SecretKey: miConfig.SecretKey,
  8189. FixmedinsCode: miConfig.Code,
  8190. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8191. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8192. OrgName: miConfig.OrgName,
  8193. Doctor: user_name,
  8194. }
  8195. if config.IsOpen == 1 {
  8196. for _, item := range queryResult {
  8197. var result string
  8198. if record_type == 1 {
  8199. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8200. } else if record_type == 2 {
  8201. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8202. } else if record_type == 3 {
  8203. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8204. }
  8205. var dat map[string]interface{}
  8206. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8207. fmt.Println(dat)
  8208. } else {
  8209. fmt.Println(err)
  8210. }
  8211. userJSONBytes, _ := json.Marshal(dat)
  8212. var res ResultSix
  8213. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8214. utils.ErrorLog("解析失败:%v", err)
  8215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8216. return
  8217. }
  8218. if res.Infcode == 0 {
  8219. if record_type == 1 {
  8220. service.UpdateBaseDrugById(item.ID)
  8221. } else if record_type == 2 {
  8222. service.UpdateGoodInformaitonByDetail(item.ID)
  8223. } else if record_type == 3 {
  8224. service.UpdateProjectById(item.ID)
  8225. }
  8226. c.ServeSuccessJSON(map[string]interface{}{
  8227. "failed_code": 0,
  8228. "msg": "目录对照成功",
  8229. })
  8230. } else {
  8231. c.ServeSuccessJSON(map[string]interface{}{
  8232. "failed_code": -10,
  8233. "msg": res.ErrMsg,
  8234. })
  8235. }
  8236. }
  8237. }
  8238. }
  8239. func (c *HisApiController) UnCheckCode() {
  8240. ids_str := c.GetString("ids")
  8241. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8242. admin_user_id, _ := c.GetInt64("admin_user_id")
  8243. ids_arr := strings.Split(ids_str, ",")
  8244. var queryResult []QueryResult
  8245. ids := make([]int64, 0)
  8246. for _, item := range ids_arr {
  8247. id, _ := strconv.ParseInt(item, 10, 64)
  8248. ids = append(ids, id)
  8249. }
  8250. if record_type == 1 {
  8251. drugs, _ := service.GetBatchDrugList(ids)
  8252. for _, item := range drugs {
  8253. result := QueryResult{
  8254. ID: item.ID,
  8255. Name: item.DrugName,
  8256. Code: item.MedicalInsuranceNumber,
  8257. List_type_code: "101",
  8258. }
  8259. queryResult = append(queryResult, result)
  8260. }
  8261. } else if record_type == 2 {
  8262. goods, _ := service.GetBatchGoodInformationList(ids)
  8263. for _, item := range goods {
  8264. result := QueryResult{
  8265. ID: item.ID,
  8266. Name: item.GoodName,
  8267. Code: item.MedicalInsuranceNumber,
  8268. List_type_code: "301",
  8269. }
  8270. queryResult = append(queryResult, result)
  8271. }
  8272. } else if record_type == 3 {
  8273. projects, _ := service.GetBathchMyPorjecgList(ids)
  8274. for _, item := range projects {
  8275. result := QueryResult{
  8276. ID: item.ID,
  8277. Name: item.ProjectName,
  8278. Code: item.MedicalCode,
  8279. List_type_code: "201",
  8280. }
  8281. queryResult = append(queryResult, result)
  8282. }
  8283. }
  8284. adminUser := c.GetAdminUserInfo()
  8285. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8286. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8287. var user_name string
  8288. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8289. if role.ID == 0 {
  8290. user_name = "xxx"
  8291. } else {
  8292. user_name = role.UserName
  8293. }
  8294. baseParams := &models.BaseParams{
  8295. SecretKey: miConfig.SecretKey,
  8296. FixmedinsCode: miConfig.Code,
  8297. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8298. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8299. OrgName: miConfig.OrgName,
  8300. Doctor: user_name,
  8301. }
  8302. if config.IsOpen == 1 {
  8303. for _, item := range queryResult {
  8304. var result string
  8305. if record_type == 1 {
  8306. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8307. } else if record_type == 2 {
  8308. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8309. } else if record_type == 3 {
  8310. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8311. }
  8312. var dat2 map[string]interface{}
  8313. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8314. fmt.Println(dat2)
  8315. } else {
  8316. fmt.Println(err)
  8317. }
  8318. userJSONBytes, _ := json.Marshal(dat2)
  8319. var res ResultSix
  8320. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8321. utils.ErrorLog("解析失败:%v", err)
  8322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8323. return
  8324. }
  8325. if res.Infcode == 0 {
  8326. if record_type == 1 {
  8327. service.UpdateDrugByIdDetail(item.ID)
  8328. } else if record_type == 2 {
  8329. service.UpdateGoodInfoById(item.ID)
  8330. } else if record_type == 3 {
  8331. service.UpdateMyProjectById(item.ID)
  8332. }
  8333. c.ServeSuccessJSON(map[string]interface{}{
  8334. "failed_code": 0,
  8335. "msg": "撤销目录对照成功",
  8336. })
  8337. } else {
  8338. c.ServeSuccessJSON(map[string]interface{}{
  8339. "failed_code": -10,
  8340. "msg": res.ErrMsg,
  8341. })
  8342. }
  8343. }
  8344. }
  8345. }
  8346. func (c *HisApiController) GetPatientInfo() {
  8347. id_card_no := c.GetString("id_card_no")
  8348. admin_user_id, _ := c.GetInt64("admin_user_id")
  8349. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8350. if patient.ID == 0 {
  8351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8352. return
  8353. }
  8354. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8355. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8356. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8357. if config.IsOpen == 1 {
  8358. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8359. var dat map[string]interface{}
  8360. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8361. fmt.Println(dat)
  8362. } else {
  8363. fmt.Println(err)
  8364. }
  8365. userJSONBytes, _ := json.Marshal(dat)
  8366. var res ResultTwo
  8367. var res10265 ResultTwo10265
  8368. if miConfig.Code == "H15049901371" {
  8369. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8370. utils.ErrorLog("解析失败:%v", err)
  8371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8372. return
  8373. }
  8374. res.ErrMsg = res10265.ErrMsg
  8375. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8376. res.Infcode = infocode
  8377. res.Output = res10265.Output
  8378. res.InfRefmsgid = res10265.InfRefmsgid
  8379. } else {
  8380. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8381. utils.ErrorLog("解析失败:%v", err)
  8382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8383. return
  8384. }
  8385. }
  8386. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8387. // utils.ErrorLog("解析失败:%v", err)
  8388. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8389. // return
  8390. //}
  8391. if res.Infcode != 0 {
  8392. c.ServeSuccessJSON(map[string]interface{}{
  8393. "failed_code": -10,
  8394. "msg": res.ErrMsg,
  8395. })
  8396. } else {
  8397. c.ServeSuccessJSON(map[string]interface{}{
  8398. "failed_code": 0,
  8399. "info": res,
  8400. })
  8401. }
  8402. }
  8403. }
  8404. func (c *HisApiController) PsnPutOnRecord() {
  8405. record_type, _ := c.GetInt64("type")
  8406. patient_id, _ := c.GetInt64("patient_id")
  8407. admin_user_id, _ := c.GetInt64("admin_user_id")
  8408. start_time := c.GetString("start_time")
  8409. end_time := c.GetString("end_time")
  8410. adminUser := c.GetAdminUserInfo()
  8411. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8412. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8413. var patients []*models.Patients
  8414. if record_type == 1 { //全部备案
  8415. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8416. patients = append(patients, patient...)
  8417. } else { //单个备案
  8418. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8419. patients = append(patients, patient)
  8420. }
  8421. var user_name string
  8422. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8423. if role.ID == 0 {
  8424. user_name = "xxx"
  8425. } else {
  8426. user_name = role.UserName
  8427. }
  8428. if config.IsOpen == 1 {
  8429. for _, item := range patients {
  8430. 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
  8431. resp, requestErr := http.Get(api)
  8432. if requestErr != nil {
  8433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8434. return
  8435. }
  8436. defer resp.Body.Close()
  8437. body, ioErr := ioutil.ReadAll(resp.Body)
  8438. if ioErr != nil {
  8439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8441. return
  8442. }
  8443. var respJSON map[string]interface{}
  8444. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8447. return
  8448. }
  8449. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8450. userJSONBytes, _ := json.Marshal(userJSON)
  8451. var res ResultTwo
  8452. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8453. utils.ErrorLog("解析失败:%v", err)
  8454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8455. return
  8456. }
  8457. if res.Infcode == 0 {
  8458. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8459. var dat map[string]interface{}
  8460. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8461. fmt.Println(dat)
  8462. } else {
  8463. fmt.Println(err)
  8464. }
  8465. userJSONBytes, _ := json.Marshal(dat)
  8466. var res2 ResultThirteen
  8467. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8468. utils.ErrorLog("解析失败:%v", err)
  8469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8470. return
  8471. }
  8472. if res2.Infcode == 0 {
  8473. psnResult := &models.GdybPsnRecord{
  8474. UserOrgId: adminUser.CurrentOrgId,
  8475. PatientId: item.ID,
  8476. PsnNo: res.Output.Baseinfo.PsnNo,
  8477. Ctime: time.Now().Unix(),
  8478. Mtime: time.Now().Unix(),
  8479. Status: 1,
  8480. IsCancel: 1,
  8481. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8482. }
  8483. service.CreatePsnRecord(psnResult)
  8484. } else {
  8485. c.ServeSuccessJSON(map[string]interface{}{
  8486. "failed_code": -10,
  8487. "msg": res2.ErrMsg,
  8488. })
  8489. return
  8490. }
  8491. }
  8492. }
  8493. }
  8494. }
  8495. func (c *HisApiController) PsnUnPutOnRecord() {
  8496. id, _ := c.GetInt64("id")
  8497. //record_type, _ := c.GetInt64("type")
  8498. admin_user_id, _ := c.GetInt64("admin_user_id")
  8499. adminUser := c.GetAdminUserInfo()
  8500. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8501. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8502. var user_name string
  8503. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8504. if role.ID == 0 {
  8505. user_name = "xxx"
  8506. } else {
  8507. user_name = role.UserName
  8508. }
  8509. psn_record, _ := service.GetPsnRecordById(id)
  8510. if psn_record.ID == 0 {
  8511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8512. return
  8513. }
  8514. if config.IsOpen == 1 {
  8515. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8516. var dat map[string]interface{}
  8517. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8518. fmt.Println(dat)
  8519. } else {
  8520. fmt.Println(err)
  8521. }
  8522. userJSONBytes, _ := json.Marshal(dat)
  8523. var res ResultFourteen
  8524. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8525. utils.ErrorLog("解析失败:%v", err)
  8526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8527. return
  8528. }
  8529. if res.Infcode == 0 {
  8530. psn_record.IsCancel = 2
  8531. service.CreatePsnRecord(&psn_record)
  8532. } else {
  8533. c.ServeSuccessJSON(map[string]interface{}{
  8534. "failed_code": -10,
  8535. "msg": res.ErrMsg,
  8536. })
  8537. return
  8538. }
  8539. }
  8540. }
  8541. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8542. patient_id, _ := c.GetInt64("patient_id")
  8543. insutype_two := c.GetString("insutype")
  8544. psn_no := c.GetString("psn_no")
  8545. doctor_id, _ := c.GetInt64("doctor_id")
  8546. sick_id, _ := c.GetInt64("sick_id")
  8547. department_id, _ := c.GetInt64("department_id")
  8548. start_time := c.GetString("start_time")
  8549. end_time := c.GetString("end_time")
  8550. check_time := c.GetString("check_time")
  8551. adminUser := c.GetAdminUserInfo()
  8552. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8553. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8554. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8555. sick, _ := service.FindSickById(sick_id)
  8556. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8557. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8558. var res ResultTwo
  8559. var res10265 ResultTwo10265
  8560. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8561. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8562. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8563. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8564. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(3, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  8565. resp, requestErr := http.Get(api)
  8566. if requestErr != nil {
  8567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8568. return
  8569. }
  8570. body, ioErr := ioutil.ReadAll(resp.Body)
  8571. if ioErr != nil {
  8572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8574. return
  8575. }
  8576. var respJSON map[string]interface{}
  8577. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8580. return
  8581. }
  8582. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8583. result, _ := json.Marshal(respJSON)
  8584. fmt.Println("log")
  8585. fmt.Println(string(result))
  8586. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8587. utils.ErrorLog("解析失败:%v", err)
  8588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8589. return
  8590. }
  8591. res.ErrMsg = res10265.ErrMsg
  8592. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8593. res.Infcode = infocode
  8594. res.Output = res10265.Output
  8595. res.InfRefmsgid = res10265.InfRefmsgid
  8596. } else {
  8597. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8598. if miConfig.Code == "H15049901371" {
  8599. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8600. utils.ErrorLog("解析失败:%v", err)
  8601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8602. return
  8603. }
  8604. res.ErrMsg = res10265.ErrMsg
  8605. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8606. res.Infcode = infocode
  8607. res.Output = res10265.Output
  8608. res.InfRefmsgid = res10265.InfRefmsgid
  8609. } else {
  8610. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8611. utils.ErrorLog("解析失败:%v", err)
  8612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8613. return
  8614. }
  8615. }
  8616. }
  8617. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8618. infoStr := string(Iinfos)
  8619. var rf []*ResultFive
  8620. json.Unmarshal([]byte(infoStr), &rf)
  8621. var insuplc_admdvs string
  8622. var insutype string
  8623. var is390 int = 0
  8624. var is310 int = 0
  8625. var insutypes []*ResultFive
  8626. for _, item := range rf {
  8627. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8628. insutypes = append(insutypes, item)
  8629. }
  8630. }
  8631. if len(insutypes) == 1 {
  8632. insutype = insutypes[0].Insutype
  8633. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8634. } else {
  8635. for _, i := range insutypes {
  8636. if i.Insutype == "390" {
  8637. is390 = 1
  8638. }
  8639. if i.Insutype == "310" {
  8640. is310 = 1
  8641. }
  8642. }
  8643. }
  8644. if is390 == 1 {
  8645. insutype = "390"
  8646. }
  8647. if is310 == 1 {
  8648. insutype = "310"
  8649. }
  8650. if len(insutypes) == 2 {
  8651. insutype = insutype_two
  8652. }
  8653. if len(insutypes) == 0 {
  8654. insutype = "310"
  8655. }
  8656. insutype = insutype_two
  8657. fmt.Println(insutype)
  8658. for _, item := range rf {
  8659. fmt.Println(item.Insutype)
  8660. fmt.Println(insutype)
  8661. if item.Insutype == insutype {
  8662. fmt.Println(item.Insutype)
  8663. fmt.Println(insutype)
  8664. insuplc_admdvs = item.InsuplcAdmdvs
  8665. }
  8666. }
  8667. fmt.Println(insuplc_admdvs)
  8668. var res2 ResultThirteen
  8669. var res10265_2 ResultThirteen10265
  8670. if config.IsOpen == 1 {
  8671. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8672. } else {
  8673. 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)
  8674. var dat map[string]interface{}
  8675. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8676. fmt.Println(dat)
  8677. } else {
  8678. fmt.Println(err)
  8679. }
  8680. userJSONBytes, _ := json.Marshal(dat)
  8681. if miConfig.Code == "H15049901371" {
  8682. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8683. utils.ErrorLog("解析失败:%v", err)
  8684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8685. return
  8686. }
  8687. res2.ErrMsg = res10265_2.ErrMsg
  8688. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8689. res2.Infcode = infocode
  8690. res2.Output = res10265_2.Output
  8691. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8692. } else {
  8693. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8694. utils.ErrorLog("解析失败:%v", err)
  8695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8696. return
  8697. }
  8698. }
  8699. }
  8700. if res2.Infcode == 0 {
  8701. psnResult := &models.GdybPsnNcdsRecord{
  8702. UserOrgId: adminUser.CurrentOrgId,
  8703. PatientId: patient.ID,
  8704. PsnNo: psn_no,
  8705. DoctorId: doctor.AdminUserId,
  8706. DepartmentId: department_id,
  8707. SickType: sick_id,
  8708. Insutype: insutype,
  8709. Ctime: time.Now().Unix(),
  8710. Mtime: time.Now().Unix(),
  8711. Status: 1,
  8712. IsCancel: 1,
  8713. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8714. }
  8715. service.CreatePsnNCDSRecord(psnResult)
  8716. c.ServeSuccessJSON(map[string]interface{}{
  8717. "failed_code": 0,
  8718. "msg": "备案成功",
  8719. "result": psnResult,
  8720. })
  8721. } else {
  8722. c.ServeSuccessJSON(map[string]interface{}{
  8723. "failed_code": -10,
  8724. "msg": res2.ErrMsg,
  8725. })
  8726. return
  8727. }
  8728. }
  8729. }
  8730. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  8731. id, _ := c.GetInt64("id")
  8732. admin_user_id, _ := c.GetInt64("admin_user_id")
  8733. adminUser := c.GetAdminUserInfo()
  8734. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8735. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8736. //config, _ := service.Ge(adminUser.CurrentOrgId)
  8737. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  8738. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8739. //var user_name string
  8740. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8741. //if role.ID == 0 {
  8742. // user_name = "xxx"
  8743. //} else {
  8744. // user_name = role.UserName
  8745. //}
  8746. psn_record, _ := service.GetPsnNCDSRecordById(id)
  8747. if psn_record.ID == 0 {
  8748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8749. return
  8750. }
  8751. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8752. var res ResultTwo
  8753. var res10265 ResultTwo10265
  8754. if miConfig.Code == "H15049901371" {
  8755. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8756. utils.ErrorLog("解析失败:%v", err)
  8757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8758. return
  8759. }
  8760. res.ErrMsg = res10265.ErrMsg
  8761. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8762. res.Infcode = infocode
  8763. res.Output = res10265.Output
  8764. res.InfRefmsgid = res10265.InfRefmsgid
  8765. } else {
  8766. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8767. utils.ErrorLog("解析失败:%v", err)
  8768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8769. return
  8770. }
  8771. }
  8772. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8773. infoStr := string(Iinfos)
  8774. var rf []*ResultFive
  8775. json.Unmarshal([]byte(infoStr), &rf)
  8776. var insuplc_admdvs string
  8777. var insutype string
  8778. var is390 int = 0
  8779. var is310 int = 0
  8780. var insutypes []*ResultFive
  8781. for _, item := range rf {
  8782. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8783. insutypes = append(insutypes, item)
  8784. }
  8785. }
  8786. if len(insutypes) == 1 {
  8787. insutype = insutypes[0].Insutype
  8788. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8789. } else {
  8790. for _, i := range insutypes {
  8791. if i.Insutype == "390" {
  8792. is390 = 1
  8793. }
  8794. if i.Insutype == "310" {
  8795. is310 = 1
  8796. }
  8797. }
  8798. }
  8799. if is390 == 1 {
  8800. insutype = "390"
  8801. }
  8802. if is310 == 1 {
  8803. insutype = "310"
  8804. }
  8805. if len(insutypes) == 0 {
  8806. insutype = "310"
  8807. }
  8808. insutype = psn_record.Insutype
  8809. for _, item := range rf {
  8810. if item.Insutype == insutype {
  8811. insuplc_admdvs = item.InsuplcAdmdvs
  8812. }
  8813. }
  8814. if config.IsOpen == 1 {
  8815. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8816. var dat map[string]interface{}
  8817. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8818. fmt.Println(dat)
  8819. } else {
  8820. fmt.Println(err)
  8821. }
  8822. userJSONBytes, _ := json.Marshal(dat)
  8823. var res ResultFourteen
  8824. var res10265 ResultFourteen10265
  8825. if miConfig.Code == "H15049901371" {
  8826. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8827. utils.ErrorLog("解析失败:%v", err)
  8828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8829. return
  8830. }
  8831. res.ErrMsg = res10265.ErrMsg
  8832. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8833. res.Infcode = infocode
  8834. res.Output = res10265.Output
  8835. res.InfRefmsgid = res10265.InfRefmsgid
  8836. } else {
  8837. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8838. utils.ErrorLog("解析失败:%v", err)
  8839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8840. return
  8841. }
  8842. }
  8843. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8844. // utils.ErrorLog("解析失败:%v", err)
  8845. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8846. // return
  8847. //}
  8848. if res.Infcode == 0 {
  8849. psn_record.IsCancel = 2
  8850. service.CreatePsnNCDSRecord(&psn_record)
  8851. c.ServeSuccessJSON(map[string]interface{}{
  8852. "failed_code": 0,
  8853. "msg": "撤销备案成功",
  8854. })
  8855. } else {
  8856. c.ServeSuccessJSON(map[string]interface{}{
  8857. "failed_code": -10,
  8858. "msg": res.ErrMsg,
  8859. })
  8860. return
  8861. }
  8862. }
  8863. }
  8864. func (c *HisApiController) TestTest() {
  8865. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8866. fmt.Println(patient.Iinfo)
  8867. }
  8868. type CustomData struct {
  8869. MsgId string
  8870. PsnNo string
  8871. Info string
  8872. }
  8873. func (c *HisApiController) ReversalData() {
  8874. var customData []*CustomData
  8875. custom := &CustomData{
  8876. MsgId: "H44022900158202103301714472004",
  8877. PsnNo: "44020000001101329945",
  8878. Info: "2207",
  8879. }
  8880. customData = append(customData, custom)
  8881. custom1 := &CustomData{
  8882. MsgId: "H4402290015820210330172057803",
  8883. PsnNo: "44020000001101161813",
  8884. Info: "2207",
  8885. }
  8886. customData = append(customData, custom1)
  8887. custom2 := &CustomData{
  8888. MsgId: "H44022900158202103301705198813",
  8889. PsnNo: "44190000133097375417",
  8890. Info: "2207",
  8891. }
  8892. customData = append(customData, custom2)
  8893. custom3 := &CustomData{
  8894. MsgId: "H44022900158202103301715524756",
  8895. PsnNo: "44020000001100187221",
  8896. Info: "2207",
  8897. }
  8898. customData = append(customData, custom3)
  8899. custom4 := &CustomData{
  8900. MsgId: "H44022900158202103301730376224",
  8901. PsnNo: "44020000001101959155",
  8902. Info: "2207",
  8903. }
  8904. customData = append(customData, custom4)
  8905. custom5 := &CustomData{
  8906. MsgId: "H44022900158202103301748008725",
  8907. PsnNo: "44020000001104246641",
  8908. Info: "2207",
  8909. }
  8910. customData = append(customData, custom5)
  8911. custom6 := &CustomData{
  8912. MsgId: "H44022900158202103301718096755",
  8913. PsnNo: "44020000001102211860",
  8914. Info: "2207",
  8915. }
  8916. customData = append(customData, custom6)
  8917. custom7 := &CustomData{
  8918. MsgId: "H44022900158202103301736551640",
  8919. PsnNo: "44020000001102687718",
  8920. Info: "2207",
  8921. }
  8922. customData = append(customData, custom7)
  8923. custom8 := &CustomData{
  8924. MsgId: "H44022900158202103301743097676",
  8925. PsnNo: "44020000001102127785",
  8926. Info: "2207",
  8927. }
  8928. customData = append(customData, custom8)
  8929. custom9 := &CustomData{
  8930. MsgId: "H44022900158202103301712304203",
  8931. PsnNo: "44020000001101518097",
  8932. Info: "2207",
  8933. }
  8934. customData = append(customData, custom9)
  8935. custom10 := &CustomData{
  8936. MsgId: "H44022900158202103301738448785",
  8937. PsnNo: "44020000001100500813",
  8938. Info: "2207",
  8939. }
  8940. customData = append(customData, custom10)
  8941. custom11 := &CustomData{
  8942. MsgId: "H44022900158202103301732455843",
  8943. PsnNo: "44020000001102690557",
  8944. Info: "2207",
  8945. }
  8946. customData = append(customData, custom11)
  8947. custom12 := &CustomData{
  8948. MsgId: "H44022900158202103301745421708",
  8949. PsnNo: "44020000001102211928",
  8950. Info: "2207",
  8951. }
  8952. customData = append(customData, custom12)
  8953. custom1212 := &CustomData{
  8954. MsgId: "H440229001582021033017351627",
  8955. PsnNo: "44020000001102481733",
  8956. Info: "2207",
  8957. }
  8958. customData = append(customData, custom1212)
  8959. custom13 := &CustomData{
  8960. MsgId: "H44022900158202103301740327951",
  8961. PsnNo: "44020000001103174866",
  8962. Info: "2207",
  8963. }
  8964. customData = append(customData, custom13)
  8965. custom14 := &CustomData{
  8966. MsgId: "H4402290015820210330174922668",
  8967. PsnNo: "44020000001102927272",
  8968. Info: "2207",
  8969. }
  8970. customData = append(customData, custom14)
  8971. custom15 := &CustomData{
  8972. MsgId: "H44022900158202103301752362273",
  8973. PsnNo: "44020000001102942890",
  8974. Info: "2207",
  8975. }
  8976. customData = append(customData, custom15)
  8977. custom16 := &CustomData{
  8978. MsgId: "H44022900158202103301751082917",
  8979. PsnNo: "44020000001101662162",
  8980. Info: "2207",
  8981. }
  8982. customData = append(customData, custom16)
  8983. custom17 := &CustomData{
  8984. MsgId: "H44022900158202103301754147728",
  8985. PsnNo: "44020000000229014511",
  8986. Info: "2207",
  8987. }
  8988. customData = append(customData, custom17)
  8989. adminUser := c.GetAdminUserInfo()
  8990. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8991. for _, item := range customData {
  8992. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8993. fmt.Println(result)
  8994. }
  8995. }
  8996. func (c *HisApiController) GetAllopatry() {
  8997. year := c.GetString("year")
  8998. month := c.GetString("month")
  8999. admin_user_id, _ := c.GetInt64("admin_user_id")
  9000. adminUser := c.GetAdminUserInfo()
  9001. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9002. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9003. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9004. var dat map[string]interface{}
  9005. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9006. fmt.Println(dat)
  9007. } else {
  9008. fmt.Println(err)
  9009. }
  9010. userJSONBytes, _ := json.Marshal(dat)
  9011. var res models.Result9001
  9012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9013. utils.ErrorLog("解析失败:%v", err)
  9014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9015. return
  9016. }
  9017. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9018. var dat2 map[string]interface{}
  9019. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9020. fmt.Println(dat)
  9021. } else {
  9022. fmt.Println(err)
  9023. }
  9024. userJSONBytes2, _ := json.Marshal(dat2)
  9025. var res2 models.Result3260
  9026. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9027. utils.ErrorLog("解析失败:%v", err)
  9028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9029. return
  9030. }
  9031. if res2.Infcode == 0 {
  9032. c.ServeSuccessJSON(map[string]interface{}{
  9033. "list": res2.Output.Data,
  9034. })
  9035. return
  9036. } else {
  9037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9038. return
  9039. }
  9040. }
  9041. func (c *HisApiController) ComfirmAllopatry() {
  9042. year := c.GetString("year")
  9043. month := c.GetString("month")
  9044. admin_user_id, _ := c.GetInt64("admin_user_id")
  9045. adminUser := c.GetAdminUserInfo()
  9046. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9047. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9048. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9049. var dat map[string]interface{}
  9050. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9051. fmt.Println(dat)
  9052. } else {
  9053. fmt.Println(err)
  9054. }
  9055. userJSONBytes, _ := json.Marshal(dat)
  9056. var res models.Result9001
  9057. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9058. utils.ErrorLog("解析失败:%v", err)
  9059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9060. return
  9061. }
  9062. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9063. var dat2 map[string]interface{}
  9064. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9065. fmt.Println(dat)
  9066. } else {
  9067. fmt.Println(err)
  9068. }
  9069. userJSONBytes2, _ := json.Marshal(dat2)
  9070. var res2 models.Result3260
  9071. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9072. utils.ErrorLog("解析失败:%v", err)
  9073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9074. return
  9075. }
  9076. if res2.Infcode == 0 {
  9077. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9078. var dat map[string]interface{}
  9079. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9080. fmt.Println(dat)
  9081. } else {
  9082. fmt.Println(err)
  9083. }
  9084. userJSONBytes, _ := json.Marshal(dat)
  9085. var res3 models.Result3261
  9086. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9087. utils.ErrorLog("解析失败:%v", err)
  9088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9089. return
  9090. }
  9091. if res3.Infcode == 0 {
  9092. record := &models.HisYidiClearRecord{
  9093. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9094. Ctime: time.Now().Unix(),
  9095. Mtime: time.Now().Unix(),
  9096. Status: 1,
  9097. MsgId: msgId,
  9098. }
  9099. service.SaveClearRecord(record)
  9100. c.ServeSuccessJSON(map[string]interface{}{
  9101. "msg": "提取成功",
  9102. })
  9103. }
  9104. }
  9105. }
  9106. func (c *HisApiController) RefundAllopatry() {
  9107. year := c.GetString("year")
  9108. month := c.GetString("month")
  9109. id, _ := c.GetInt64("id")
  9110. admin_user_id, _ := c.GetInt64("admin_user_id")
  9111. adminUser := c.GetAdminUserInfo()
  9112. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9113. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9114. record, _ := service.GetClearRecordById(id)
  9115. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9116. var dat map[string]interface{}
  9117. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9118. fmt.Println(dat)
  9119. } else {
  9120. fmt.Println(err)
  9121. }
  9122. userJSONBytes, _ := json.Marshal(dat)
  9123. var empty ResultFourteen
  9124. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9125. utils.ErrorLog("解析失败:%v", err)
  9126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9127. return
  9128. }
  9129. if empty.Infcode == 0 {
  9130. c.ServeSuccessJSON(map[string]interface{}{
  9131. "msg": "撤销成功",
  9132. })
  9133. return
  9134. }
  9135. }
  9136. func (c *HisApiController) ReversalOtherData() {
  9137. var customData []*CustomData
  9138. custom := &CustomData{
  9139. MsgId: "H44022900158202103301714472004",
  9140. PsnNo: "44020000001101329945",
  9141. Info: "2208",
  9142. }
  9143. customData = append(customData, custom)
  9144. custom1 := &CustomData{
  9145. MsgId: "H4402290015820210330172057803",
  9146. PsnNo: "44020000001101161813",
  9147. Info: "2208",
  9148. }
  9149. customData = append(customData, custom1)
  9150. custom2 := &CustomData{
  9151. MsgId: "H44022900158202103301705198813",
  9152. PsnNo: "44190000133097375417",
  9153. Info: "2208",
  9154. }
  9155. customData = append(customData, custom2)
  9156. custom3 := &CustomData{
  9157. MsgId: "H44022900158202103301715524756",
  9158. PsnNo: "44020000001100187221",
  9159. Info: "2208",
  9160. }
  9161. customData = append(customData, custom3)
  9162. custom4 := &CustomData{
  9163. MsgId: "H44022900158202103301730376224",
  9164. PsnNo: "44020000001101959155",
  9165. Info: "2208",
  9166. }
  9167. customData = append(customData, custom4)
  9168. custom5 := &CustomData{
  9169. MsgId: "H44022900158202103301748008725",
  9170. PsnNo: "44020000001104246641",
  9171. Info: "2208",
  9172. }
  9173. customData = append(customData, custom5)
  9174. custom6 := &CustomData{
  9175. MsgId: "H44022900158202103301718096755",
  9176. PsnNo: "44020000001102211860",
  9177. Info: "2208",
  9178. }
  9179. customData = append(customData, custom6)
  9180. custom7 := &CustomData{
  9181. MsgId: "H44022900158202103301736551640",
  9182. PsnNo: "44020000001102687718",
  9183. Info: "2208",
  9184. }
  9185. customData = append(customData, custom7)
  9186. custom8 := &CustomData{
  9187. MsgId: "H44022900158202103301743097676",
  9188. PsnNo: "44020000001102127785",
  9189. Info: "2208",
  9190. }
  9191. customData = append(customData, custom8)
  9192. custom9 := &CustomData{
  9193. MsgId: "H44022900158202103301712304203",
  9194. PsnNo: "44020000001101518097",
  9195. Info: "2208",
  9196. }
  9197. customData = append(customData, custom9)
  9198. custom10 := &CustomData{
  9199. MsgId: "H44022900158202103301738448785",
  9200. PsnNo: "44020000001100500813",
  9201. Info: "2208",
  9202. }
  9203. customData = append(customData, custom10)
  9204. custom11 := &CustomData{
  9205. MsgId: "H44022900158202103301732455843",
  9206. PsnNo: "44020000001102690557",
  9207. Info: "2208",
  9208. }
  9209. customData = append(customData, custom11)
  9210. custom12 := &CustomData{
  9211. MsgId: "H44022900158202103301745421708",
  9212. PsnNo: "44020000001102211928",
  9213. Info: "2208",
  9214. }
  9215. customData = append(customData, custom12)
  9216. custom1212 := &CustomData{
  9217. MsgId: "H440229001582021033017351627",
  9218. PsnNo: "44020000001102481733",
  9219. Info: "2208",
  9220. }
  9221. customData = append(customData, custom1212)
  9222. custom13 := &CustomData{
  9223. MsgId: "H44022900158202103301740327951",
  9224. PsnNo: "44020000001103174866",
  9225. Info: "2208",
  9226. }
  9227. customData = append(customData, custom13)
  9228. custom14 := &CustomData{
  9229. MsgId: "H4402290015820210330174922668",
  9230. PsnNo: "44020000001102927272",
  9231. Info: "2208",
  9232. }
  9233. customData = append(customData, custom14)
  9234. custom15 := &CustomData{
  9235. MsgId: "H44022900158202103301752362273",
  9236. PsnNo: "44020000001102942890",
  9237. Info: "2208",
  9238. }
  9239. customData = append(customData, custom15)
  9240. custom16 := &CustomData{
  9241. MsgId: "H44022900158202103301751082917",
  9242. PsnNo: "44020000001101662162",
  9243. Info: "2208",
  9244. }
  9245. customData = append(customData, custom16)
  9246. custom17 := &CustomData{
  9247. MsgId: "H44022900158202103301754147728",
  9248. PsnNo: "44020000000229014511",
  9249. Info: "2208",
  9250. }
  9251. customData = append(customData, custom17)
  9252. adminUser := c.GetAdminUserInfo()
  9253. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9254. for _, item := range customData {
  9255. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9256. fmt.Println(result)
  9257. }
  9258. }
  9259. func PathExists(path string) (bool, error) {
  9260. _, err := os.Stat(path)
  9261. if err == nil {
  9262. return true, nil
  9263. }
  9264. if os.IsNotExist(err) {
  9265. return false, nil
  9266. }
  9267. return false, err
  9268. }
  9269. //创建文件夹
  9270. func Mkdir(dir string) {
  9271. // 创建文件夹
  9272. exist, err := PathExists(dir)
  9273. if err != nil {
  9274. fmt.Println(err.Error())
  9275. } else {
  9276. if exist {
  9277. fmt.Println(dir + "文件夹已存在!")
  9278. } else {
  9279. // 文件夹名称,权限
  9280. err := os.Mkdir(dir, os.ModePerm)
  9281. if err != nil {
  9282. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9283. } else {
  9284. fmt.Println(dir + "文件夹创建成功!")
  9285. }
  9286. }
  9287. }
  9288. }
  9289. //压缩文件
  9290. func Zip(srcFile string, destZip string) error {
  9291. zipfile, err := os.Create(destZip)
  9292. if err != nil {
  9293. return err
  9294. }
  9295. defer zipfile.Close()
  9296. archive := zip.NewWriter(zipfile)
  9297. defer archive.Close()
  9298. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9299. if err != nil {
  9300. return err
  9301. }
  9302. header, err := zip.FileInfoHeader(info)
  9303. if err != nil {
  9304. return err
  9305. }
  9306. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9307. // header.Name = path
  9308. if info.IsDir() {
  9309. header.Name += "/"
  9310. } else {
  9311. header.Method = zip.Deflate
  9312. }
  9313. writer, err := archive.CreateHeader(header)
  9314. if err != nil {
  9315. return err
  9316. }
  9317. if !info.IsDir() {
  9318. file, err := os.Open(path)
  9319. if err != nil {
  9320. return err
  9321. }
  9322. defer file.Close()
  9323. _, err = io.Copy(writer, file)
  9324. }
  9325. return err
  9326. })
  9327. return err
  9328. }
  9329. func ReadFile(filePath string) []byte {
  9330. f, err := os.Open(filePath)
  9331. if err != nil {
  9332. fmt.Println("read file fail", err)
  9333. return nil
  9334. }
  9335. defer f.Close()
  9336. fd, err := ioutil.ReadAll(f)
  9337. if err != nil {
  9338. fmt.Println("read to fd fail", err)
  9339. return nil
  9340. }
  9341. return fd
  9342. }
  9343. func saveLog(result string, request string, infno string, desc string) {
  9344. org_id, _ := beego.AppConfig.Int64("org_id")
  9345. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9346. dir := miConfig.OrgName + "日志"
  9347. utils.Mkdir(dir)
  9348. month := time.Unix(1557042972, 0).Format("1")
  9349. year := time.Now().Format("2006")
  9350. month = time.Now().Format("01")
  9351. day := time.Now().Format("02")
  9352. hour := time.Now().Format("15")
  9353. min := time.Now().Format("04")
  9354. sec := time.Now().Format("05")
  9355. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9356. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9357. file_name := file + ".txt"
  9358. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9359. exist, _ := utils.PathExists(file_path)
  9360. if exist { //存在
  9361. fmt.Println("存在")
  9362. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9363. if err != nil {
  9364. fmt.Println("read fail")
  9365. }
  9366. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9367. n, _ := f.Seek(0, 2)
  9368. _, err = f.WriteAt([]byte(content), n)
  9369. } else { //不存在
  9370. fmt.Println("文件不存在,创建文件")
  9371. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9372. defer f.Close()
  9373. if err != nil {
  9374. } else {
  9375. _, err = f.Write([]byte("记录日志"))
  9376. }
  9377. }
  9378. }
  9379. type Charset string
  9380. const (
  9381. UTF8 = Charset("UTF-8")
  9382. GB18030 = Charset("GB18030")
  9383. )
  9384. func ConvertToString(src string, srcCode string, tagCode string) string {
  9385. srcCoder := mahonia.NewDecoder(srcCode)
  9386. srcResult := srcCoder.ConvertString(src)
  9387. tagCoder := mahonia.NewDecoder(tagCode)
  9388. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9389. result := string(cdata)
  9390. return result
  9391. }