his_api_controller.go 397KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822
  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 + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  353. fmt.Println(api)
  354. } else {
  355. 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 +
  356. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  357. }
  358. resp, requestErr := http.Get(api)
  359. if requestErr != nil {
  360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  361. return
  362. }
  363. body, ioErr := ioutil.ReadAll(resp.Body)
  364. if ioErr != nil {
  365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  367. return
  368. }
  369. var respJSON map[string]interface{}
  370. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  373. return
  374. }
  375. var status string
  376. status = respJSON["data"].(map[string]interface{})["status"].(string)
  377. fmt.Println(respJSON["data"])
  378. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  379. //console.log()
  380. fmt.Println("type===")
  381. fmt.Println(card_type)
  382. var token string
  383. var res ResultTwo //1101结果
  384. var res10265 ResultTwo10265 //1101结果
  385. var card_info string //卡信息
  386. var busi_card_info string
  387. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  388. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  389. if status == "0" { //读卡成功
  390. if card_type == "1" {
  391. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  392. result, _ := json.Marshal(respJSON)
  393. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  394. utils.ErrorLog("解析失败:%v", err)
  395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  396. return
  397. }
  398. res.ErrMsg = res10265.ErrMsg
  399. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  400. res.Infcode = infocode
  401. res.Output = res10265.Output
  402. res.InfRefmsgid = res10265.InfRefmsgid
  403. } else {
  404. //var card_info string //卡信息
  405. //var busi_card_info string
  406. token = respJSON["data"].(map[string]interface{})["token"].(string)
  407. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  408. //fmt.Println(card_info)
  409. //fmt.Println(busi_card_info)
  410. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  411. result, _ := json.Marshal(respJSON)
  412. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  413. utils.ErrorLog("解析失败:%v", err)
  414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  415. return
  416. }
  417. res.ErrMsg = res10265.ErrMsg
  418. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  419. res.Infcode = infocode
  420. res.Output = res10265.Output
  421. res.InfRefmsgid = res10265.InfRefmsgid
  422. }
  423. if res.Infcode == 0 {
  424. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  425. if err == gorm.ErrRecordNotFound {
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  427. return
  428. } else if err != nil {
  429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  430. return
  431. } else {
  432. if card_type == "1" {
  433. bas := strings.Split(card_info, "|")
  434. basNumber := bas[2]
  435. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  436. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  437. infoStr := string(Iinfos)
  438. idetinfoStr := string(Idetinfos)
  439. psn := &models.HisPsn{
  440. PsnNo: res.Output.Baseinfo.PsnNo,
  441. Age: res.Output.Baseinfo.Age,
  442. PatientId: patient.ID,
  443. Certno: res.Output.Baseinfo.Certno,
  444. Brdy: res.Output.Baseinfo.Brdy,
  445. Gend: res.Output.Baseinfo.Gend,
  446. Naty: res.Output.Baseinfo.Naty,
  447. PsnCertType: res.Output.Baseinfo.PsnCertType,
  448. PsnName: res.Output.Baseinfo.PsnName,
  449. Idetinfo: idetinfoStr,
  450. Insuinfo: infoStr,
  451. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  452. CardInfo: card_info,
  453. VerifyNumber: busi_card_info,
  454. }
  455. service.CreateHisPsn(psn)
  456. c.ServeSuccessJSON(map[string]interface{}{
  457. "patient": patient,
  458. "number": basNumber,
  459. })
  460. } else {
  461. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  462. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  463. infoStr := string(Iinfos)
  464. idetinfoStr := string(Idetinfos)
  465. psn := &models.HisPsn{
  466. PsnNo: res.Output.Baseinfo.PsnNo,
  467. Age: res.Output.Baseinfo.Age,
  468. PatientId: patient.ID,
  469. Certno: res.Output.Baseinfo.Certno,
  470. Brdy: res.Output.Baseinfo.Brdy,
  471. Gend: res.Output.Baseinfo.Gend,
  472. Naty: res.Output.Baseinfo.Naty,
  473. PsnCertType: res.Output.Baseinfo.PsnCertType,
  474. PsnName: res.Output.Baseinfo.PsnName,
  475. Idetinfo: idetinfoStr,
  476. Insuinfo: infoStr,
  477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  478. CardInfo: card_info,
  479. VerifyNumber: token,
  480. }
  481. service.CreateHisPsn(psn)
  482. c.ServeSuccessJSON(map[string]interface{}{
  483. "patient": patient,
  484. "number": token,
  485. })
  486. }
  487. }
  488. } else {
  489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  490. return
  491. }
  492. } else { //读卡失败
  493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  494. return
  495. }
  496. } else {
  497. if initFlag == 0 {
  498. c.TestGetBasBaseInit()
  499. }
  500. basStr := c.GetBasBaseInfo()
  501. if len(basStr) == 0 {
  502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  503. return
  504. }
  505. fmt.Println(basStr)
  506. bas := strings.Split(basStr, "|")
  507. basNumber := bas[1]
  508. fmt.Println(basNumber)
  509. card_sn := bas[3]
  510. fmt.Println(card_sn)
  511. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  512. var dat map[string]interface{}
  513. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  514. fmt.Println(dat)
  515. } else {
  516. fmt.Println(err)
  517. }
  518. userJSONBytes, _ := json.Marshal(dat)
  519. var res ResultTwo
  520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  521. utils.ErrorLog("解析失败:%v", err)
  522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  523. return
  524. }
  525. if res.Infcode == 0 {
  526. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  527. if err == gorm.ErrRecordNotFound {
  528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  529. return
  530. } else if err != nil {
  531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  532. return
  533. } else {
  534. c.ServeSuccessJSON(map[string]interface{}{
  535. "patient": patient,
  536. "number": basNumber,
  537. })
  538. }
  539. } else {
  540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  541. return
  542. }
  543. break
  544. }
  545. case 2:
  546. SFZStr := c.GetSFZBaseInfo()
  547. id_card_str := strings.Split(SFZStr, "^")
  548. id_card_number := id_card_str[0]
  549. card_sn := ""
  550. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  551. var dat map[string]interface{}
  552. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  553. fmt.Println(dat)
  554. } else {
  555. fmt.Println(err)
  556. }
  557. userJSONBytes, _ := json.Marshal(dat)
  558. var res ResultTwo
  559. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  560. utils.ErrorLog("解析失败:%v", err)
  561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  562. return
  563. }
  564. if res.Infcode == 0 {
  565. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  566. if err == gorm.ErrRecordNotFound {
  567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  568. return
  569. } else if err != nil {
  570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  571. return
  572. } else {
  573. c.ServeSuccessJSON(map[string]interface{}{
  574. "patient": patient,
  575. "number": id_card_number,
  576. })
  577. }
  578. } else {
  579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  580. return
  581. }
  582. break
  583. case 3:
  584. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  585. var api string
  586. if miConfig.MdtrtareaAdmvs == "320921" {
  587. 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 +
  588. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  589. fmt.Println(api)
  590. } else {
  591. 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 +
  592. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  593. }
  594. resp, requestErr := http.Get(api)
  595. if requestErr != nil {
  596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  597. return
  598. }
  599. body, ioErr := ioutil.ReadAll(resp.Body)
  600. if ioErr != nil {
  601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  603. return
  604. }
  605. var respJSON map[string]interface{}
  606. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  609. return
  610. }
  611. var status string
  612. status = respJSON["data"].(map[string]interface{})["status"].(string)
  613. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  614. var token string
  615. var res ResultTwo //1101结果
  616. var res10265 ResultTwo10265 //1101结果
  617. var card_info string //卡信息
  618. var busi_card_info string
  619. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  620. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  621. if status == "0" { //读卡成功
  622. if card_type == "1" {
  623. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  624. result, _ := json.Marshal(respJSON)
  625. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  626. utils.ErrorLog("解析失败:%v", err)
  627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  628. return
  629. }
  630. res.ErrMsg = res10265.ErrMsg
  631. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  632. res.Infcode = infocode
  633. res.Output = res10265.Output
  634. res.InfRefmsgid = res10265.InfRefmsgid
  635. } else {
  636. //var card_info string //卡信息
  637. //var busi_card_info string
  638. token = respJSON["data"].(map[string]interface{})["token"].(string)
  639. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  640. //fmt.Println(card_info)
  641. //fmt.Println(busi_card_info)
  642. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  643. result, _ := json.Marshal(respJSON)
  644. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  645. utils.ErrorLog("解析失败:%v", err)
  646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  647. return
  648. }
  649. res.ErrMsg = res10265.ErrMsg
  650. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  651. res.Infcode = infocode
  652. res.Output = res10265.Output
  653. res.InfRefmsgid = res10265.InfRefmsgid
  654. }
  655. if res.Infcode == 0 {
  656. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  657. if err == gorm.ErrRecordNotFound {
  658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  659. return
  660. } else if err != nil {
  661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  662. return
  663. } else {
  664. if card_type == "1" {
  665. bas := strings.Split(card_info, "|")
  666. basNumber := bas[2]
  667. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  668. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  669. infoStr := string(Iinfos)
  670. idetinfoStr := string(Idetinfos)
  671. psn := &models.HisPsn{
  672. PsnNo: res.Output.Baseinfo.PsnNo,
  673. Age: res.Output.Baseinfo.Age,
  674. PatientId: patient.ID,
  675. Certno: res.Output.Baseinfo.Certno,
  676. Brdy: res.Output.Baseinfo.Brdy,
  677. Gend: res.Output.Baseinfo.Gend,
  678. Naty: res.Output.Baseinfo.Naty,
  679. PsnCertType: res.Output.Baseinfo.PsnCertType,
  680. PsnName: res.Output.Baseinfo.PsnName,
  681. Idetinfo: idetinfoStr,
  682. Insuinfo: infoStr,
  683. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  684. CardInfo: card_info,
  685. VerifyNumber: busi_card_info,
  686. }
  687. service.CreateHisPsn(psn)
  688. c.ServeSuccessJSON(map[string]interface{}{
  689. "patient": patient,
  690. "number": basNumber,
  691. })
  692. } else {
  693. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  694. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  695. infoStr := string(Iinfos)
  696. idetinfoStr := string(Idetinfos)
  697. psn := &models.HisPsn{
  698. PsnNo: res.Output.Baseinfo.PsnNo,
  699. Age: res.Output.Baseinfo.Age,
  700. PatientId: patient.ID,
  701. Certno: res.Output.Baseinfo.Certno,
  702. Brdy: res.Output.Baseinfo.Brdy,
  703. Gend: res.Output.Baseinfo.Gend,
  704. Naty: res.Output.Baseinfo.Naty,
  705. PsnCertType: res.Output.Baseinfo.PsnCertType,
  706. PsnName: res.Output.Baseinfo.PsnName,
  707. Idetinfo: idetinfoStr,
  708. Insuinfo: infoStr,
  709. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  710. CardInfo: card_info,
  711. VerifyNumber: token,
  712. }
  713. service.CreateHisPsn(psn)
  714. c.ServeSuccessJSON(map[string]interface{}{
  715. "patient": patient,
  716. "number": token,
  717. })
  718. }
  719. }
  720. } else {
  721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  722. return
  723. }
  724. } else { //读卡失败
  725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  726. return
  727. }
  728. }
  729. break
  730. }
  731. }
  732. var initFlag int64 = 0
  733. func (c *HisApiController) TestGetBasBaseInit() {
  734. DllDef := syscall.MustLoadDLL("SSCard.dll")
  735. Iinit := DllDef.MustFindProc("Init")
  736. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  737. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  738. if ret != 0 {
  739. fmt.Println("SSCard的报错原因:", err)
  740. fmt.Println("SSCard的运算结果为:", ret)
  741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  742. return
  743. }
  744. result := int(ret)
  745. fmt.Println("SSCard的运算结果为1:", result)
  746. initFlag = 1
  747. return
  748. }
  749. func (c *HisApiController) GetSFZBaseInfo() string {
  750. DllDef := syscall.MustLoadDLL("SSCard.dll")
  751. readCard := DllDef.MustFindProc("ReadSFZ")
  752. if readCard == nil {
  753. fmt.Println("readcard is nil")
  754. readCard = DllDef.MustFindProc("ReadSFZ")
  755. }
  756. str := make([]byte, 256)
  757. str1 := make([]byte, 256)
  758. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  759. fmt.Println(r)
  760. return string(str)
  761. }
  762. func (c *HisApiController) GetBasBaseInfo() string {
  763. DllDef := syscall.MustLoadDLL("SSCard.dll")
  764. readCard := DllDef.MustFindProc("ReadCardBas")
  765. if readCard == nil {
  766. fmt.Println("readcard is nil")
  767. readCard = DllDef.MustFindProc("ReadCardBas")
  768. }
  769. str := make([]byte, 1024)
  770. str1 := make([]byte, 1024)
  771. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  772. fmt.Println(string(str1))
  773. fmt.Println(string(str))
  774. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  775. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  776. if ret2 != 0 {
  777. return ""
  778. }
  779. return string(str)
  780. }
  781. type CustomFundPay struct {
  782. FundPayType string `json:"fund_pay_type"`
  783. FundPayamt float64 `json:"fund_payamt"`
  784. }
  785. func (c *HisApiController) GetSettleList() {
  786. order_id, _ := c.GetInt64("order_id")
  787. admin_user_id, _ := c.GetInt64("admin_user_id")
  788. order, _ := service.GetHisOrderByIDTwo(order_id)
  789. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  790. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  791. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  792. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  793. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  794. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  795. if order.ID == 0 {
  796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  797. return
  798. }
  799. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  800. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  801. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  802. fmt.Println(count)
  803. var zero string
  804. number := count + 1
  805. if number >= 1000 {
  806. zero = "0000" + strconv.FormatInt(number, 10)
  807. } else if number >= 10000 {
  808. zero = "000" + strconv.FormatInt(number, 10)
  809. } else if number >= 100000 {
  810. zero = "00" + strconv.FormatInt(number, 10)
  811. } else if number >= 1000000 {
  812. zero = "0" + strconv.FormatInt(number, 10)
  813. } else {
  814. zero = strconv.FormatInt(number, 10)
  815. }
  816. fmt.Println(zero)
  817. struct4101 := service.Struct4101{
  818. PsnNo: order.PsnNo,
  819. MdtrtId: order.MdtrtId,
  820. SetlId: order.SetlId,
  821. PsnName: order.PsnName,
  822. Gend: order.Gend,
  823. Brdy: his.Brdy,
  824. Age: his.Age,
  825. Naty: order.Naty,
  826. PatnCertType: "01",
  827. Certno: order.Certno,
  828. Prfs: "90",
  829. ConerName: roles[0].UserName,
  830. PatnRlts: "99",
  831. ConerAddr: miConfig.OrgName,
  832. ConerTel: admin.Mobile,
  833. HiType: order.Insutype,
  834. Insuplc: miConfig.InsuplcAdmdvs,
  835. MaindiagFlag: "1",
  836. BillCode: last_order.FaPiaoCode,
  837. BillNo: zero,
  838. BizSn: order.Number,
  839. PsnSelfPay: order.PsnPartAmt,
  840. PsnOwnPay: order.PsnPartAmt,
  841. AcctPay: order.AcctPay,
  842. PsnCashpay: order.PsnCashPay,
  843. HiPaymtd: "1",
  844. Hsorg: miConfig.InsuplcAdmdvs,
  845. HsorgOpter: miConfig.InsuplcAdmdvs,
  846. MedinsFillPsn: curRoles.UserName,
  847. MedinsFillDept: depart.Name,
  848. IptMedType: "2",
  849. }
  850. struct4101.SetlBegnDate = order.SetlTime
  851. struct4101.SetlEndDate = order.SetlTime
  852. time_arr := strings.Split(order.SetlTime, " ")
  853. struct4101.AdmTime = time_arr[0]
  854. struct4101.AdmEndTime = time_arr[0]
  855. var rf []CustomFundPay
  856. json.Unmarshal([]byte(order.SetlDetail), &rf)
  857. var tempFunPays []service.CustomStruct
  858. for _, item := range rf {
  859. var tempFunPay service.CustomStruct
  860. tempFunPay.FundPayamt = item.FundPayamt
  861. tempFunPay.FundPayType = item.FundPayType
  862. tempFunPays = append(tempFunPays, tempFunPay)
  863. }
  864. struct4101.CustomStruct = tempFunPays
  865. var tempDiaginfos []service.DiaginfoStructTwo
  866. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  867. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  868. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  869. var config []*models.HisXtDiagnoseConfig
  870. for _, item := range diagnosis_ids {
  871. id, _ := strconv.ParseInt(item, 10, 64)
  872. diagnosisConfig, _ := service.FindDiagnoseById(id)
  873. config = append(config, &diagnosisConfig)
  874. }
  875. for index, item := range config {
  876. if index == 0 {
  877. var tempDiaginfo service.DiaginfoStructTwo
  878. tempDiaginfo.DiagCode = item.CountryCode
  879. tempDiaginfo.DiagName = item.CountryContentName
  880. tempDiaginfo.DiagType = "1"
  881. tempDiaginfo.MaindiagFlag = "1"
  882. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  883. } else {
  884. var tempDiaginfo service.DiaginfoStructTwo
  885. tempDiaginfo.DiagCode = item.CountryCode
  886. tempDiaginfo.DiagName = item.CountryContentName
  887. tempDiaginfo.DiagType = "2"
  888. tempDiaginfo.MaindiagFlag = "0"
  889. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  890. }
  891. }
  892. struct4101.Diseinfo = tempDiaginfos
  893. sickConfigTwo, _ := service.FindSickById(his.SickType)
  894. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  895. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  896. tempOpspdiseinfo2.OprnOprtCode = ""
  897. tempOpspdiseinfo2.OprnOprtName = ""
  898. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  899. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  900. var iteminfo service.IteminfoStruct
  901. var bedCostTotal float64 = 0 //床位总费
  902. var bedCostSelfTotal float64 = 0 //床位自费
  903. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  904. var operationCostTotal float64 = 0 //手术费
  905. var operationCostSelfTotal float64 = 0 //手术费
  906. var operationCostPartSelfTotal float64 = 0 //手术费
  907. var otherCostTotal float64 = 0 //其他费用
  908. var otherCostSelfTotal float64 = 0 //其他费用
  909. var otherCostPartSelfTotal float64 = 0 //其他费用
  910. var materialCostTotal float64 = 0 //材料费
  911. var materialCostSelfTotal float64 = 0 //材料费
  912. var materialCostPartSelfTotal float64 = 0 //材料费
  913. var westernMedicineCostTotal float64 = 0 //西药费
  914. var westernMedicineCostSelfTotal float64 = 0 //西药费
  915. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  916. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  917. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  918. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  919. var checkCostTotal float64 = 0 //检查费
  920. var checkCostSelfTotal float64 = 0 //检查费
  921. var checkCostPartSelfTotal float64 = 0 //检查费
  922. var laboratoryCostTotal float64 = 0 //化验费
  923. var laboratoryCostSelfTotal float64 = 0 //化验费
  924. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  925. var treatCostTotal float64 = 0 //治疗费用
  926. var treatCostSelfTotal float64 = 0 //治疗费用
  927. var treatCostPartSelfTotal float64 = 0 //治疗费用
  928. decimal.DivisionPrecision = 2
  929. var bed_fulamt_ownpay_amt float64 = 0
  930. var operation_fulamt_ownpay_amt float64 = 0
  931. var other_fulamt_ownpay_amt float64 = 0
  932. var westernMedicine_fulamt_ownpay_amt float64 = 0
  933. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  934. var check_fulamt_ownpay_amt float64 = 0
  935. var material_fulamt_ownpay_amt float64 = 0
  936. var laboratory_fulamt_ownpay_amt float64 = 0
  937. var treat_fulamt_ownpay_amt float64 = 0
  938. var bed_claa_sunmfee float64 = 0
  939. var bed_clab_amt float64 = 0
  940. var bed_other_amt float64 = 0
  941. var operation_claa_sunmfee float64 = 0
  942. var operation_clab_amt float64 = 0
  943. var operation_other_amt float64 = 0
  944. var other_claa_sunmfee float64 = 0
  945. var other_clab_amt float64 = 0
  946. var other_other_amt float64 = 0
  947. var westernMedicine_claa_sunmfee float64 = 0
  948. var westernMedicine_clab_amt float64 = 0
  949. var westernMedicine_other_amt float64 = 0
  950. var chineseTraditional_claa_sunmfee float64 = 0
  951. var chineseTraditional_clab_amt float64 = 0
  952. var chineseTraditional_other_amt float64 = 0
  953. var check_claa_sunmfee float64 = 0
  954. var check_clab_amt float64 = 0
  955. var check_other_amt float64 = 0
  956. var material_claa_sunmfee float64 = 0
  957. var material_clab_amt float64 = 0
  958. var material_other_amt float64 = 0
  959. var laboratory_claa_sunmfee float64 = 0
  960. var laboratory_clab_amt float64 = 0
  961. var laboratory_other_amt float64 = 0
  962. var treat_claa_sunmfee float64 = 0
  963. var treat_clab_amt float64 = 0
  964. var treat_other_amt float64 = 0
  965. for _, item := range order.HisOrderInfo {
  966. if item.MedChrgitmType == "01" { //床位费
  967. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  968. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  969. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  970. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  971. if item.ChrgitmLv == "1" {
  972. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  973. }
  974. if item.ChrgitmLv == "2" {
  975. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  976. }
  977. if item.ChrgitmLv == "3" {
  978. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  979. }
  980. }
  981. if item.MedChrgitmType == "03" { //检查费
  982. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  983. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  984. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  985. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  986. if item.ChrgitmLv == "1" {
  987. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  988. }
  989. if item.ChrgitmLv == "2" {
  990. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  991. }
  992. if item.ChrgitmLv == "3" {
  993. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  994. }
  995. }
  996. if item.MedChrgitmType == "04" { //化验费
  997. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  998. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  999. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1000. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1001. if item.ChrgitmLv == "1" {
  1002. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1003. }
  1004. if item.ChrgitmLv == "2" {
  1005. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1006. }
  1007. if item.ChrgitmLv == "3" {
  1008. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1009. }
  1010. }
  1011. if item.MedChrgitmType == "05" { //治疗费
  1012. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1013. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1014. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1015. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1016. if item.ChrgitmLv == "1" {
  1017. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1018. }
  1019. if item.ChrgitmLv == "2" {
  1020. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1021. }
  1022. if item.ChrgitmLv == "3" {
  1023. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1024. }
  1025. }
  1026. if item.MedChrgitmType == "06" { //手术费
  1027. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1028. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1029. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1030. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1031. if item.ChrgitmLv == "1" {
  1032. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1033. }
  1034. if item.ChrgitmLv == "2" {
  1035. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1036. }
  1037. if item.ChrgitmLv == "3" {
  1038. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1039. }
  1040. }
  1041. if item.MedChrgitmType == "08" { //材料费
  1042. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1043. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1044. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1045. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1046. if item.ChrgitmLv == "1" {
  1047. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1048. }
  1049. if item.ChrgitmLv == "2" {
  1050. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1051. }
  1052. if item.ChrgitmLv == "3" {
  1053. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1054. }
  1055. }
  1056. if item.MedChrgitmType == "09" { //西药费
  1057. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1058. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1059. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1060. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1061. if item.ChrgitmLv == "1" {
  1062. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1063. }
  1064. if item.ChrgitmLv == "2" {
  1065. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1066. }
  1067. if item.ChrgitmLv == "3" {
  1068. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1069. }
  1070. }
  1071. if item.MedChrgitmType == "11" { //中成费
  1072. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1073. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1074. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1075. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1076. if item.ChrgitmLv == "1" {
  1077. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1078. }
  1079. if item.ChrgitmLv == "2" {
  1080. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1081. }
  1082. if item.ChrgitmLv == "3" {
  1083. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1084. }
  1085. }
  1086. if item.MedChrgitmType == "14" { //其他费
  1087. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1088. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1089. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1090. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1091. if item.ChrgitmLv == "1" {
  1092. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1093. }
  1094. if item.ChrgitmLv == "2" {
  1095. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1096. }
  1097. if item.ChrgitmLv == "3" {
  1098. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1099. }
  1100. }
  1101. }
  1102. var iteminfoStructs []service.IteminfoStruct
  1103. if bedCostTotal != 0 {
  1104. iteminfo.MedChrgitm = "01"
  1105. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1106. iteminfo.Amt = bedCostTotal
  1107. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1108. iteminfo.ClabAmt = bed_clab_amt
  1109. iteminfo.OthAmt = bed_other_amt
  1110. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1111. }
  1112. if checkCostTotal != 0 {
  1113. iteminfo.MedChrgitm = "03"
  1114. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1115. iteminfo.Amt = checkCostTotal
  1116. iteminfo.ClaaSumfee = check_claa_sunmfee
  1117. iteminfo.ClabAmt = check_clab_amt
  1118. iteminfo.OthAmt = check_other_amt
  1119. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1120. }
  1121. if laboratoryCostTotal != 0 {
  1122. iteminfo.MedChrgitm = "04"
  1123. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1124. iteminfo.Amt = laboratoryCostTotal
  1125. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1126. iteminfo.ClabAmt = laboratory_clab_amt
  1127. iteminfo.OthAmt = laboratory_other_amt
  1128. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1129. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1130. }
  1131. if treatCostTotal != 0 {
  1132. iteminfo.MedChrgitm = "05"
  1133. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1134. iteminfo.Amt = treatCostTotal
  1135. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1136. iteminfo.ClabAmt = treat_clab_amt
  1137. iteminfo.OthAmt = treat_other_amt
  1138. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1139. //(struct4101.IteminfoStruct, iteminfo)
  1140. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1141. }
  1142. if operationCostTotal != 0 {
  1143. iteminfo.MedChrgitm = "06"
  1144. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1145. iteminfo.Amt = operationCostTotal
  1146. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1147. iteminfo.ClabAmt = operation_clab_amt
  1148. iteminfo.OthAmt = operation_other_amt
  1149. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1150. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1151. }
  1152. if materialCostTotal != 0 {
  1153. iteminfo.MedChrgitm = "08"
  1154. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1155. iteminfo.Amt = materialCostTotal
  1156. iteminfo.ClaaSumfee = material_claa_sunmfee
  1157. iteminfo.ClabAmt = material_clab_amt
  1158. iteminfo.OthAmt = material_other_amt
  1159. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1160. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1161. }
  1162. if westernMedicineCostTotal != 0 {
  1163. iteminfo.MedChrgitm = "09"
  1164. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1165. iteminfo.Amt = westernMedicineCostTotal
  1166. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1167. iteminfo.ClabAmt = westernMedicine_clab_amt
  1168. iteminfo.OthAmt = westernMedicine_other_amt
  1169. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1170. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1171. }
  1172. if chineseTraditionalMedicineCostTotal != 0 {
  1173. iteminfo.MedChrgitm = "11"
  1174. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1175. iteminfo.Amt = westernMedicineCostTotal
  1176. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1177. iteminfo.ClabAmt = westernMedicine_clab_amt
  1178. iteminfo.OthAmt = westernMedicine_other_amt
  1179. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1180. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1181. }
  1182. if otherCostTotal != 0 {
  1183. iteminfo.MedChrgitm = "14"
  1184. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1185. iteminfo.Amt = otherCostTotal
  1186. iteminfo.ClaaSumfee = other_claa_sunmfee
  1187. iteminfo.ClabAmt = other_clab_amt
  1188. iteminfo.OthAmt = other_other_amt
  1189. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1190. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1191. }
  1192. struct4101.IteminfoStruct = iteminfoStructs
  1193. struct4101.Ntly = "中国"
  1194. struct4101.AdmCaty = "A03.06"
  1195. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1196. fmt.Println(result)
  1197. var dat map[string]interface{}
  1198. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1199. fmt.Println(dat)
  1200. } else {
  1201. fmt.Println(err)
  1202. }
  1203. userJSONBytes, _ := json.Marshal(dat)
  1204. var res ResultSeventeen
  1205. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1206. utils.ErrorLog("解析失败:%v", err)
  1207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1208. return
  1209. }
  1210. if res.Infcode != 0 {
  1211. c.ServeSuccessJSON(map[string]interface{}{
  1212. "failed_code": -10,
  1213. "msg": res.ErrMsg,
  1214. })
  1215. return
  1216. } else {
  1217. order.FaPiaoNumber = zero
  1218. order.FaPiaoCode = last_order.FaPiaoCode
  1219. service.UpdateOrder(order)
  1220. hisFundSettleListResult := &models.HisFundSettleListResult{
  1221. Number: res.Output.SetlListId,
  1222. Status: 1,
  1223. Ctime: time.Now().Unix(),
  1224. Mtime: time.Now().Unix(),
  1225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1226. IsUpload: 1,
  1227. OrderId: order_id,
  1228. }
  1229. service.CreateUploadRecord(hisFundSettleListResult)
  1230. c.ServeSuccessJSON(map[string]interface{}{
  1231. "msg": "上传成功",
  1232. "result": hisFundSettleListResult,
  1233. })
  1234. return
  1235. }
  1236. }
  1237. func (c *HisApiController) GetSettleListHospital() {
  1238. order_id, _ := c.GetInt64("order_id")
  1239. admin_user_id, _ := c.GetInt64("admin_user_id")
  1240. order, _ := service.GetHisOrderByIDTwo(order_id)
  1241. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1242. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1243. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1244. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1245. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1246. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1247. if order.ID == 0 {
  1248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1249. return
  1250. }
  1251. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1252. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1253. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1254. fmt.Println(count)
  1255. var zero string
  1256. number := count + 1
  1257. if number >= 1000 {
  1258. zero = "0000" + strconv.FormatInt(number, 10)
  1259. } else if number >= 10000 {
  1260. zero = "000" + strconv.FormatInt(number, 10)
  1261. } else if number >= 100000 {
  1262. zero = "00" + strconv.FormatInt(number, 10)
  1263. } else if number >= 1000000 {
  1264. zero = "0" + strconv.FormatInt(number, 10)
  1265. } else {
  1266. zero = strconv.FormatInt(number, 10)
  1267. }
  1268. fmt.Println(zero)
  1269. struct4101 := service.Struct4101{
  1270. PsnNo: order.PsnNo,
  1271. MdtrtId: order.MdtrtId,
  1272. SetlId: order.SetlId,
  1273. PsnName: order.PsnName,
  1274. Gend: order.Gend,
  1275. Brdy: his.Brdy,
  1276. Age: int64(order.Age),
  1277. Naty: order.Naty,
  1278. PatnCertType: "01",
  1279. Certno: order.Certno,
  1280. Prfs: "90",
  1281. ConerName: roles[0].UserName,
  1282. PatnRlts: "99",
  1283. ConerAddr: miConfig.OrgName,
  1284. ConerTel: admin.Mobile,
  1285. HiType: order.Insutype,
  1286. Insuplc: miConfig.InsuplcAdmdvs,
  1287. MaindiagFlag: "1",
  1288. BillCode: last_order.FaPiaoCode,
  1289. BillNo: zero,
  1290. BizSn: order.Number,
  1291. PsnSelfPay: order.PsnPartAmt,
  1292. PsnOwnPay: order.PsnPartAmt,
  1293. AcctPay: order.AcctPay,
  1294. PsnCashpay: order.PsnCashPay,
  1295. HiPaymtd: "1",
  1296. Hsorg: miConfig.InsuplcAdmdvs,
  1297. HsorgOpter: miConfig.InsuplcAdmdvs,
  1298. MedinsFillPsn: curRoles.UserName,
  1299. MedinsFillDept: depart.Name,
  1300. IptMedType: "2",
  1301. AdmTime: his.InHosptialTime,
  1302. AdmEndTime: his.OutHosptialTime,
  1303. }
  1304. struct4101.SetlBegnDate = order.SetlTime
  1305. struct4101.SetlEndDate = order.SetlTime
  1306. var rf []CustomFundPay
  1307. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1308. var tempFunPays []service.CustomStruct
  1309. for _, item := range rf {
  1310. var tempFunPay service.CustomStruct
  1311. tempFunPay.FundPayamt = item.FundPayamt
  1312. tempFunPay.FundPayType = item.FundPayType
  1313. tempFunPays = append(tempFunPays, tempFunPay)
  1314. }
  1315. struct4101.CustomStruct = tempFunPays
  1316. var tempDiaginfos []service.DiaginfoStructTwo
  1317. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1318. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1319. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1320. var config []*models.HisXtDiagnoseConfig
  1321. for _, item := range diagnosis_ids {
  1322. id, _ := strconv.ParseInt(item, 10, 64)
  1323. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1324. config = append(config, &diagnosisConfig)
  1325. }
  1326. for index, item := range config {
  1327. if index == 0 {
  1328. var tempDiaginfo service.DiaginfoStructTwo
  1329. tempDiaginfo.DiagCode = item.CountryCode
  1330. tempDiaginfo.DiagName = item.CountryContentName
  1331. tempDiaginfo.DiagType = "1"
  1332. tempDiaginfo.MaindiagFlag = "1"
  1333. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1334. } else {
  1335. var tempDiaginfo service.DiaginfoStructTwo
  1336. tempDiaginfo.DiagCode = item.CountryCode
  1337. tempDiaginfo.DiagName = item.CountryContentName
  1338. tempDiaginfo.DiagType = "2"
  1339. tempDiaginfo.MaindiagFlag = "0"
  1340. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1341. }
  1342. }
  1343. struct4101.Diseinfo = tempDiaginfos
  1344. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1345. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1346. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1347. tempOpspdiseinfo2.OprnOprtCode = ""
  1348. tempOpspdiseinfo2.OprnOprtName = ""
  1349. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1350. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1351. var iteminfo service.IteminfoStruct
  1352. var bedCostTotal float64 = 0 //床位总费
  1353. var bedCostSelfTotal float64 = 0 //床位自费
  1354. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1355. var operationCostTotal float64 = 0 //手术费
  1356. var operationCostSelfTotal float64 = 0 //手术费
  1357. var operationCostPartSelfTotal float64 = 0 //手术费
  1358. var otherCostTotal float64 = 0 //其他费用
  1359. var otherCostSelfTotal float64 = 0 //其他费用
  1360. var otherCostPartSelfTotal float64 = 0 //其他费用
  1361. var materialCostTotal float64 = 0 //材料费
  1362. var materialCostSelfTotal float64 = 0 //材料费
  1363. var materialCostPartSelfTotal float64 = 0 //材料费
  1364. var westernMedicineCostTotal float64 = 0 //西药费
  1365. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1366. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1367. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1368. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1369. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1370. var checkCostTotal float64 = 0 //检查费
  1371. var checkCostSelfTotal float64 = 0 //检查费
  1372. var checkCostPartSelfTotal float64 = 0 //检查费
  1373. var laboratoryCostTotal float64 = 0 //化验费
  1374. var laboratoryCostSelfTotal float64 = 0 //化验费
  1375. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1376. var treatCostTotal float64 = 0 //治疗费用
  1377. var treatCostSelfTotal float64 = 0 //治疗费用
  1378. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1379. decimal.DivisionPrecision = 2
  1380. var bed_fulamt_ownpay_amt float64 = 0
  1381. var operation_fulamt_ownpay_amt float64 = 0
  1382. var other_fulamt_ownpay_amt float64 = 0
  1383. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1384. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1385. var check_fulamt_ownpay_amt float64 = 0
  1386. var material_fulamt_ownpay_amt float64 = 0
  1387. var laboratory_fulamt_ownpay_amt float64 = 0
  1388. var treat_fulamt_ownpay_amt float64 = 0
  1389. var bed_claa_sunmfee float64 = 0
  1390. var bed_clab_amt float64 = 0
  1391. var bed_other_amt float64 = 0
  1392. var operation_claa_sunmfee float64 = 0
  1393. var operation_clab_amt float64 = 0
  1394. var operation_other_amt float64 = 0
  1395. var other_claa_sunmfee float64 = 0
  1396. var other_clab_amt float64 = 0
  1397. var other_other_amt float64 = 0
  1398. var westernMedicine_claa_sunmfee float64 = 0
  1399. var westernMedicine_clab_amt float64 = 0
  1400. var westernMedicine_other_amt float64 = 0
  1401. var chineseTraditional_claa_sunmfee float64 = 0
  1402. var chineseTraditional_clab_amt float64 = 0
  1403. var chineseTraditional_other_amt float64 = 0
  1404. var check_claa_sunmfee float64 = 0
  1405. var check_clab_amt float64 = 0
  1406. var check_other_amt float64 = 0
  1407. var material_claa_sunmfee float64 = 0
  1408. var material_clab_amt float64 = 0
  1409. var material_other_amt float64 = 0
  1410. var laboratory_claa_sunmfee float64 = 0
  1411. var laboratory_clab_amt float64 = 0
  1412. var laboratory_other_amt float64 = 0
  1413. var treat_claa_sunmfee float64 = 0
  1414. var treat_clab_amt float64 = 0
  1415. var treat_other_amt float64 = 0
  1416. for _, item := range order.HisOrderInfo {
  1417. if item.MedChrgitmType == "01" { //床位费
  1418. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1419. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1420. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1421. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1422. if item.ChrgitmLv == "1" {
  1423. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1424. }
  1425. if item.ChrgitmLv == "2" {
  1426. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1427. }
  1428. if item.ChrgitmLv == "3" {
  1429. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1430. }
  1431. }
  1432. if item.MedChrgitmType == "03" { //检查费
  1433. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1434. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1435. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1436. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1437. if item.ChrgitmLv == "1" {
  1438. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1439. }
  1440. if item.ChrgitmLv == "2" {
  1441. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1442. }
  1443. if item.ChrgitmLv == "3" {
  1444. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1445. }
  1446. }
  1447. if item.MedChrgitmType == "04" { //化验费
  1448. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1449. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1450. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1451. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1452. if item.ChrgitmLv == "1" {
  1453. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1454. }
  1455. if item.ChrgitmLv == "2" {
  1456. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1457. }
  1458. if item.ChrgitmLv == "3" {
  1459. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1460. }
  1461. }
  1462. if item.MedChrgitmType == "05" { //治疗费
  1463. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1464. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1465. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1466. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1467. if item.ChrgitmLv == "1" {
  1468. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1469. }
  1470. if item.ChrgitmLv == "2" {
  1471. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1472. }
  1473. if item.ChrgitmLv == "3" {
  1474. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1475. }
  1476. }
  1477. if item.MedChrgitmType == "06" { //手术费
  1478. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1479. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1480. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1481. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1482. if item.ChrgitmLv == "1" {
  1483. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1484. }
  1485. if item.ChrgitmLv == "2" {
  1486. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1487. }
  1488. if item.ChrgitmLv == "3" {
  1489. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1490. }
  1491. }
  1492. if item.MedChrgitmType == "08" { //材料费
  1493. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1494. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1495. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1496. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1497. if item.ChrgitmLv == "1" {
  1498. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1499. }
  1500. if item.ChrgitmLv == "2" {
  1501. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1502. }
  1503. if item.ChrgitmLv == "3" {
  1504. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1505. }
  1506. }
  1507. if item.MedChrgitmType == "09" { //西药费
  1508. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1509. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1510. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1511. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1512. if item.ChrgitmLv == "1" {
  1513. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1514. }
  1515. if item.ChrgitmLv == "2" {
  1516. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1517. }
  1518. if item.ChrgitmLv == "3" {
  1519. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1520. }
  1521. }
  1522. if item.MedChrgitmType == "11" { //中成费
  1523. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1524. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1525. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1526. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1527. if item.ChrgitmLv == "1" {
  1528. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1529. }
  1530. if item.ChrgitmLv == "2" {
  1531. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1532. }
  1533. if item.ChrgitmLv == "3" {
  1534. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1535. }
  1536. }
  1537. if item.MedChrgitmType == "14" { //其他费
  1538. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1539. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1540. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1541. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1542. if item.ChrgitmLv == "1" {
  1543. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1544. }
  1545. if item.ChrgitmLv == "2" {
  1546. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1547. }
  1548. if item.ChrgitmLv == "3" {
  1549. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1550. }
  1551. }
  1552. }
  1553. var iteminfoStructs []service.IteminfoStruct
  1554. if bedCostTotal != 0 {
  1555. iteminfo.MedChrgitm = "01"
  1556. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1557. iteminfo.Amt = bedCostTotal
  1558. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1559. iteminfo.ClabAmt = bed_clab_amt
  1560. iteminfo.OthAmt = bed_other_amt
  1561. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1562. }
  1563. if checkCostTotal != 0 {
  1564. iteminfo.MedChrgitm = "03"
  1565. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1566. iteminfo.Amt = checkCostTotal
  1567. iteminfo.ClaaSumfee = check_claa_sunmfee
  1568. iteminfo.ClabAmt = check_clab_amt
  1569. iteminfo.OthAmt = check_other_amt
  1570. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1571. }
  1572. if laboratoryCostTotal != 0 {
  1573. iteminfo.MedChrgitm = "04"
  1574. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1575. iteminfo.Amt = laboratoryCostTotal
  1576. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1577. iteminfo.ClabAmt = laboratory_clab_amt
  1578. iteminfo.OthAmt = laboratory_other_amt
  1579. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1580. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1581. }
  1582. if treatCostTotal != 0 {
  1583. iteminfo.MedChrgitm = "05"
  1584. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1585. iteminfo.Amt = treatCostTotal
  1586. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1587. iteminfo.ClabAmt = treat_clab_amt
  1588. iteminfo.OthAmt = treat_other_amt
  1589. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1590. //(struct4101.IteminfoStruct, iteminfo)
  1591. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1592. }
  1593. if operationCostTotal != 0 {
  1594. iteminfo.MedChrgitm = "06"
  1595. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1596. iteminfo.Amt = operationCostTotal
  1597. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1598. iteminfo.ClabAmt = operation_clab_amt
  1599. iteminfo.OthAmt = operation_other_amt
  1600. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1601. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1602. }
  1603. if materialCostTotal != 0 {
  1604. iteminfo.MedChrgitm = "08"
  1605. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1606. iteminfo.Amt = materialCostTotal
  1607. iteminfo.ClaaSumfee = material_claa_sunmfee
  1608. iteminfo.ClabAmt = material_clab_amt
  1609. iteminfo.OthAmt = material_other_amt
  1610. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1611. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1612. }
  1613. if westernMedicineCostTotal != 0 {
  1614. iteminfo.MedChrgitm = "09"
  1615. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1616. iteminfo.Amt = westernMedicineCostTotal
  1617. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1618. iteminfo.ClabAmt = westernMedicine_clab_amt
  1619. iteminfo.OthAmt = westernMedicine_other_amt
  1620. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1621. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1622. }
  1623. if chineseTraditionalMedicineCostTotal != 0 {
  1624. iteminfo.MedChrgitm = "11"
  1625. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1626. iteminfo.Amt = westernMedicineCostTotal
  1627. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1628. iteminfo.ClabAmt = westernMedicine_clab_amt
  1629. iteminfo.OthAmt = westernMedicine_other_amt
  1630. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1631. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1632. }
  1633. if otherCostTotal != 0 {
  1634. iteminfo.MedChrgitm = "14"
  1635. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1636. iteminfo.Amt = otherCostTotal
  1637. iteminfo.ClaaSumfee = other_claa_sunmfee
  1638. iteminfo.ClabAmt = other_clab_amt
  1639. iteminfo.OthAmt = other_other_amt
  1640. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1641. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1642. }
  1643. struct4101.IteminfoStruct = iteminfoStructs
  1644. struct4101.Ntly = "中国"
  1645. struct4101.AdmCaty = "A03.06"
  1646. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1647. fmt.Println(result)
  1648. var dat map[string]interface{}
  1649. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1650. fmt.Println(dat)
  1651. } else {
  1652. fmt.Println(err)
  1653. }
  1654. userJSONBytes, _ := json.Marshal(dat)
  1655. var res ResultSeventeen
  1656. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1657. utils.ErrorLog("解析失败:%v", err)
  1658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1659. return
  1660. }
  1661. if res.Infcode != 0 {
  1662. c.ServeSuccessJSON(map[string]interface{}{
  1663. "failed_code": -10,
  1664. "msg": res.ErrMsg,
  1665. })
  1666. return
  1667. } else {
  1668. order.FaPiaoNumber = zero
  1669. order.FaPiaoCode = last_order.FaPiaoCode
  1670. service.UpdateOrder(order)
  1671. hisFundSettleListResult := &models.HisFundSettleListResult{
  1672. Number: res.Output.SetlListId,
  1673. Status: 1,
  1674. Ctime: time.Now().Unix(),
  1675. Mtime: time.Now().Unix(),
  1676. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1677. IsUpload: 1,
  1678. OrderId: order_id,
  1679. }
  1680. service.CreateUploadRecord(hisFundSettleListResult)
  1681. c.ServeSuccessJSON(map[string]interface{}{
  1682. "msg": "上传成功",
  1683. "result": hisFundSettleListResult,
  1684. })
  1685. return
  1686. }
  1687. }
  1688. func (c *HisApiController) GetBatchSettleList() {
  1689. orders, _ := service.GetAllHisOrder(10106)
  1690. for _, item := range orders {
  1691. order_id := item.ID
  1692. order, _ := service.GetHisOrderByIDTwo(order_id)
  1693. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1694. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1695. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1696. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  1697. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1698. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1699. if order.ID == 0 {
  1700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1701. return
  1702. }
  1703. if his.BalanceAccountsType == 2 {
  1704. continue
  1705. }
  1706. struct4101 := service.Struct4101{
  1707. PsnNo: order.PsnNo,
  1708. MdtrtId: order.MdtrtId,
  1709. SetlId: order.SetlId,
  1710. PsnName: order.PsnName,
  1711. Gend: order.Gend,
  1712. Brdy: his.Brdy,
  1713. Age: his.Age,
  1714. Naty: order.Naty,
  1715. PatnCertType: "01",
  1716. Certno: order.Certno,
  1717. Prfs: "90",
  1718. ConerName: roles[0].UserName,
  1719. PatnRlts: "99",
  1720. ConerAddr: miConfig.OrgName,
  1721. ConerTel: admin.Mobile,
  1722. HiType: order.Insutype,
  1723. Insuplc: his.InsuplcAdmdvs,
  1724. MaindiagFlag: "1",
  1725. BillCode: order.FaPiaoCode,
  1726. BillNo: order.FaPiaoNumber,
  1727. BizSn: order.Number,
  1728. PsnSelfPay: order.PsnPartAmt,
  1729. PsnOwnPay: order.PsnPartAmt,
  1730. AcctPay: order.AcctPay,
  1731. PsnCashpay: order.PsnCashPay,
  1732. HiPaymtd: "1",
  1733. Hsorg: his.InsuplcAdmdvs,
  1734. HsorgOpter: his.InsuplcAdmdvs,
  1735. MedinsFillPsn: curRoles.UserName,
  1736. MedinsFillDept: depart.Name,
  1737. IptMedType: "2",
  1738. }
  1739. struct4101.SetlBegnDate = order.SetlTime
  1740. struct4101.SetlEndDate = order.SetlTime
  1741. //if order.SettleType == 1 {
  1742. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1743. // dateStr := t.Format("2006-01-02")
  1744. // struct4101.SetlBegnDate = dateStr
  1745. // struct4101.SetlEndDate = dateStr
  1746. //} else {
  1747. // t := time.Unix(int64(order.SettleStartTime), 0)
  1748. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1749. // dateStartStr := t.Format("2006-01-02")
  1750. // dateEndStr := t2.Format("2006-01-02")
  1751. // struct4101.SetlBegnDate = dateStartStr
  1752. // struct4101.SetlEndDate = dateEndStr
  1753. //}
  1754. var rf []CustomFundPay
  1755. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1756. var tempFunPays []service.CustomStruct
  1757. var tempFunPay610100 service.CustomStruct
  1758. for _, item := range rf {
  1759. if item.FundPayType == "610100" {
  1760. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1761. tempFunPay610100.FundPayType = item.FundPayType
  1762. } else {
  1763. var tempFunPay service.CustomStruct
  1764. tempFunPay.FundPayamt = item.FundPayamt
  1765. tempFunPay.FundPayType = item.FundPayType
  1766. tempFunPays = append(tempFunPays, tempFunPay)
  1767. }
  1768. }
  1769. tempFunPays = append(tempFunPays, tempFunPay610100)
  1770. struct4101.CustomStruct = tempFunPays
  1771. var tempDiaginfos []service.DiaginfoStructTwo
  1772. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1773. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1774. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1775. var config []*models.HisXtDiagnoseConfig
  1776. for _, item := range diagnosis_ids {
  1777. id, _ := strconv.ParseInt(item, 10, 64)
  1778. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1779. config = append(config, &diagnosisConfig)
  1780. }
  1781. for index, item := range config {
  1782. if index == 0 {
  1783. var tempDiaginfo service.DiaginfoStructTwo
  1784. tempDiaginfo.DiagCode = item.CountryCode
  1785. tempDiaginfo.DiagName = item.CountryContentName
  1786. tempDiaginfo.DiagType = "1"
  1787. tempDiaginfo.MaindiagFlag = "1"
  1788. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1789. } else {
  1790. var tempDiaginfo service.DiaginfoStructTwo
  1791. tempDiaginfo.DiagCode = item.CountryCode
  1792. tempDiaginfo.DiagName = item.CountryContentName
  1793. tempDiaginfo.DiagType = "2"
  1794. tempDiaginfo.MaindiagFlag = "0"
  1795. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1796. }
  1797. }
  1798. struct4101.Diseinfo = tempDiaginfos
  1799. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1800. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1801. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1802. tempOpspdiseinfo2.OprnOprtCode = ""
  1803. tempOpspdiseinfo2.OprnOprtName = ""
  1804. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1805. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1806. var iteminfo service.IteminfoStruct
  1807. var bedCostTotal float64 = 0 //床位总费
  1808. var bedCostSelfTotal float64 = 0 //床位自费
  1809. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1810. var examineCostTotal float64 = 0 //诊查总费
  1811. var examineCostSelfTotal float64 = 0 //诊查自费
  1812. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1813. var nursingCostTotal float64 = 0 //护理总费
  1814. var nursingCostSelfTotal float64 = 0 //护理自费
  1815. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1816. var chineseMedicineCostTotal float64 = 0 //中成药
  1817. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1818. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1819. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1820. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1821. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1822. var registerCostTotal float64 = 0 //一般诊疗费
  1823. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1824. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1825. var operationCostTotal float64 = 0 //手术费
  1826. var operationCostSelfTotal float64 = 0 //手术费
  1827. var operationCostPartSelfTotal float64 = 0 //手术费
  1828. var otherCostTotal float64 = 0 //其他费用
  1829. var otherCostSelfTotal float64 = 0 //其他费用
  1830. var otherCostPartSelfTotal float64 = 0 //其他费用
  1831. var materialCostTotal float64 = 0 //材料费
  1832. var materialCostSelfTotal float64 = 0 //材料费
  1833. var materialCostPartSelfTotal float64 = 0 //材料费
  1834. var westernMedicineCostTotal float64 = 0 //西药费
  1835. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1836. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1837. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1838. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1839. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1840. var checkCostTotal float64 = 0 //检查费
  1841. var checkCostSelfTotal float64 = 0 //检查费
  1842. var checkCostPartSelfTotal float64 = 0 //检查费
  1843. var laboratoryCostTotal float64 = 0 //化验费
  1844. var laboratoryCostSelfTotal float64 = 0 //化验费
  1845. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1846. var treatCostTotal float64 = 0 //治疗费用
  1847. var treatCostSelfTotal float64 = 0 //治疗费用
  1848. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1849. decimal.DivisionPrecision = 2
  1850. var bed_fulamt_ownpay_amt float64 = 0
  1851. var examine_fulamt_ownpay_amt float64 = 0
  1852. var nursing_fulamt_ownpay_amt float64 = 0
  1853. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1854. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1855. var register_fulamt_ownpay_amt float64 = 0
  1856. var operation_fulamt_ownpay_amt float64 = 0
  1857. var other_fulamt_ownpay_amt float64 = 0
  1858. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1859. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1860. var check_fulamt_ownpay_amt float64 = 0
  1861. var material_fulamt_ownpay_amt float64 = 0
  1862. var laboratory_fulamt_ownpay_amt float64 = 0
  1863. var treat_fulamt_ownpay_amt float64 = 0
  1864. var bed_claa_sunmfee float64 = 0
  1865. var bed_clab_amt float64 = 0
  1866. var bed_other_amt float64 = 0
  1867. var examine_claa_sunmfee float64 = 0
  1868. var examine_clab_amt float64 = 0
  1869. var examine_other_amt float64 = 0
  1870. var nursing_claa_sunmfee float64 = 0
  1871. var nursing_clab_amt float64 = 0
  1872. var nursing_other_amt float64 = 0
  1873. var chinese_medicine_claa_sunmfee float64 = 0
  1874. var chinese_medicine_clab_amt float64 = 0
  1875. var chinese_medicine_other_amt float64 = 0
  1876. var commonly_treatment_claa_sunmfee float64 = 0
  1877. var commonly_treatment_clab_amt float64 = 0
  1878. var commonly_treatment_other_amt float64 = 0
  1879. var operation_claa_sunmfee float64 = 0
  1880. var operation_clab_amt float64 = 0
  1881. var operation_other_amt float64 = 0
  1882. var other_claa_sunmfee float64 = 0
  1883. var other_clab_amt float64 = 0
  1884. var other_other_amt float64 = 0
  1885. var westernMedicine_claa_sunmfee float64 = 0
  1886. var westernMedicine_clab_amt float64 = 0
  1887. var westernMedicine_other_amt float64 = 0
  1888. var chineseTraditional_claa_sunmfee float64 = 0
  1889. var chineseTraditional_clab_amt float64 = 0
  1890. var chineseTraditional_other_amt float64 = 0
  1891. var check_claa_sunmfee float64 = 0
  1892. var check_clab_amt float64 = 0
  1893. var check_other_amt float64 = 0
  1894. var material_claa_sunmfee float64 = 0
  1895. var material_clab_amt float64 = 0
  1896. var material_other_amt float64 = 0
  1897. var laboratory_claa_sunmfee float64 = 0
  1898. var laboratory_clab_amt float64 = 0
  1899. var laboratory_other_amt float64 = 0
  1900. var treat_claa_sunmfee float64 = 0
  1901. var treat_clab_amt float64 = 0
  1902. var treat_other_amt float64 = 0
  1903. var register_claa_sunmfee float64 = 0
  1904. var register_clab_amt float64 = 0
  1905. var register_other_amt float64 = 0
  1906. for _, item := range order.HisOrderInfo {
  1907. if item.MedChrgitmType == "01" { //床位费
  1908. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1909. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1910. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1911. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1912. if item.ChrgitmLv == "1" {
  1913. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1914. }
  1915. if item.ChrgitmLv == "2" {
  1916. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1917. }
  1918. if item.ChrgitmLv == "3" {
  1919. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1920. }
  1921. }
  1922. if item.MedChrgitmType == "02" { //诊查
  1923. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1924. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1925. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1926. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1927. if item.ChrgitmLv == "1" {
  1928. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1929. }
  1930. if item.ChrgitmLv == "2" {
  1931. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1932. }
  1933. if item.ChrgitmLv == "3" {
  1934. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1935. }
  1936. }
  1937. if item.MedChrgitmType == "03" { //检查费
  1938. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1939. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1940. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1941. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1942. if item.ChrgitmLv == "1" {
  1943. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1944. }
  1945. if item.ChrgitmLv == "2" {
  1946. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1947. }
  1948. if item.ChrgitmLv == "3" {
  1949. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1950. }
  1951. }
  1952. if item.MedChrgitmType == "04" { //化验费
  1953. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1954. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1955. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1956. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1957. if item.ChrgitmLv == "1" {
  1958. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1959. }
  1960. if item.ChrgitmLv == "2" {
  1961. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1962. }
  1963. if item.ChrgitmLv == "3" {
  1964. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1965. }
  1966. }
  1967. if item.MedChrgitmType == "05" { //治疗费
  1968. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1969. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1970. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1971. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1972. if item.ChrgitmLv == "1" {
  1973. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1974. }
  1975. if item.ChrgitmLv == "2" {
  1976. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1977. }
  1978. if item.ChrgitmLv == "3" {
  1979. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1980. }
  1981. }
  1982. if item.MedChrgitmType == "06" { //手术费
  1983. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1984. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1985. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1986. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1987. if item.ChrgitmLv == "1" {
  1988. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1989. }
  1990. if item.ChrgitmLv == "2" {
  1991. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1992. }
  1993. if item.ChrgitmLv == "3" {
  1994. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1995. }
  1996. }
  1997. if item.MedChrgitmType == "07" { //手术费
  1998. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1999. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2000. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2001. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2002. if item.ChrgitmLv == "1" {
  2003. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2004. }
  2005. if item.ChrgitmLv == "2" {
  2006. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2007. }
  2008. if item.ChrgitmLv == "3" {
  2009. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2010. }
  2011. }
  2012. if item.MedChrgitmType == "08" { //材料费
  2013. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2014. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2015. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2016. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2017. if item.ChrgitmLv == "1" {
  2018. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2019. }
  2020. if item.ChrgitmLv == "2" {
  2021. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2022. }
  2023. if item.ChrgitmLv == "3" {
  2024. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2025. }
  2026. }
  2027. if item.MedChrgitmType == "09" { //西药费
  2028. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2029. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2030. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2031. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2032. if item.ChrgitmLv == "1" {
  2033. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2034. }
  2035. if item.ChrgitmLv == "2" {
  2036. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2037. }
  2038. if item.ChrgitmLv == "3" {
  2039. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2040. }
  2041. }
  2042. if item.MedChrgitmType == "10" { //中药饮片
  2043. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2044. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2045. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2046. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2047. if item.ChrgitmLv == "1" {
  2048. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2049. }
  2050. if item.ChrgitmLv == "2" {
  2051. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2052. }
  2053. if item.ChrgitmLv == "3" {
  2054. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2055. }
  2056. }
  2057. if item.MedChrgitmType == "11" { //中成费
  2058. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2059. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2060. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2061. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2062. if item.ChrgitmLv == "1" {
  2063. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2064. }
  2065. if item.ChrgitmLv == "2" {
  2066. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2067. }
  2068. if item.ChrgitmLv == "3" {
  2069. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2070. }
  2071. }
  2072. if item.MedChrgitmType == "12" { //中成费
  2073. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2074. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2075. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2076. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2077. if item.ChrgitmLv == "1" {
  2078. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2079. }
  2080. if item.ChrgitmLv == "2" {
  2081. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2082. }
  2083. if item.ChrgitmLv == "3" {
  2084. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2085. }
  2086. }
  2087. if item.MedChrgitmType == "13" { //中成费
  2088. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2089. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2090. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2091. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2092. if item.ChrgitmLv == "1" {
  2093. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2094. }
  2095. if item.ChrgitmLv == "2" {
  2096. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2097. }
  2098. if item.ChrgitmLv == "3" {
  2099. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2100. }
  2101. }
  2102. if item.MedChrgitmType == "14" { //其他费
  2103. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2104. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2105. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2106. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2107. if item.ChrgitmLv == "1" {
  2108. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2109. }
  2110. if item.ChrgitmLv == "2" {
  2111. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2112. }
  2113. if item.ChrgitmLv == "3" {
  2114. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2115. }
  2116. }
  2117. }
  2118. var iteminfoStructs []service.IteminfoStruct
  2119. if bedCostTotal != 0 {
  2120. iteminfo.MedChrgitm = "01"
  2121. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2122. iteminfo.Amt = bedCostTotal
  2123. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2124. iteminfo.ClabAmt = bed_clab_amt
  2125. iteminfo.OthAmt = bed_other_amt
  2126. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2127. }
  2128. if examineCostTotal != 0 {
  2129. iteminfo.MedChrgitm = "02"
  2130. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2131. iteminfo.Amt = examineCostTotal
  2132. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2133. iteminfo.ClabAmt = examine_clab_amt
  2134. iteminfo.OthAmt = examine_other_amt
  2135. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2136. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2137. }
  2138. if checkCostTotal != 0 {
  2139. iteminfo.MedChrgitm = "03"
  2140. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2141. iteminfo.Amt = checkCostTotal
  2142. iteminfo.ClaaSumfee = check_claa_sunmfee
  2143. iteminfo.ClabAmt = check_clab_amt
  2144. iteminfo.OthAmt = check_other_amt
  2145. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2146. }
  2147. if laboratoryCostTotal != 0 {
  2148. iteminfo.MedChrgitm = "04"
  2149. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2150. iteminfo.Amt = laboratoryCostTotal
  2151. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2152. iteminfo.ClabAmt = laboratory_clab_amt
  2153. iteminfo.OthAmt = laboratory_other_amt
  2154. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2155. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2156. }
  2157. if treatCostTotal != 0 {
  2158. iteminfo.MedChrgitm = "05"
  2159. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2160. iteminfo.Amt = treatCostTotal
  2161. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2162. iteminfo.ClabAmt = treat_clab_amt
  2163. iteminfo.OthAmt = treat_other_amt
  2164. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2165. //(struct4101.IteminfoStruct, iteminfo)
  2166. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2167. }
  2168. if operationCostTotal != 0 {
  2169. iteminfo.MedChrgitm = "06"
  2170. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2171. iteminfo.Amt = operationCostTotal
  2172. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2173. iteminfo.ClabAmt = operation_clab_amt
  2174. iteminfo.OthAmt = operation_other_amt
  2175. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2176. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2177. }
  2178. if nursingCostTotal != 0 {
  2179. iteminfo.MedChrgitm = "07"
  2180. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2181. iteminfo.Amt = nursingCostTotal
  2182. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2183. iteminfo.ClabAmt = nursing_clab_amt
  2184. iteminfo.OthAmt = nursing_other_amt
  2185. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2186. }
  2187. if materialCostTotal != 0 {
  2188. iteminfo.MedChrgitm = "08"
  2189. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2190. iteminfo.Amt = materialCostTotal
  2191. iteminfo.ClaaSumfee = material_claa_sunmfee
  2192. iteminfo.ClabAmt = material_clab_amt
  2193. iteminfo.OthAmt = material_other_amt
  2194. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2195. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2196. }
  2197. if westernMedicineCostTotal != 0 {
  2198. iteminfo.MedChrgitm = "09"
  2199. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2200. iteminfo.Amt = westernMedicineCostTotal
  2201. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2202. iteminfo.ClabAmt = westernMedicine_clab_amt
  2203. iteminfo.OthAmt = westernMedicine_other_amt
  2204. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2205. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2206. }
  2207. if chineseMedicineCostTotal != 0 {
  2208. iteminfo.MedChrgitm = "10"
  2209. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2210. iteminfo.Amt = chineseMedicineCostTotal
  2211. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2212. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2213. iteminfo.OthAmt = chinese_medicine_other_amt
  2214. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2215. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2216. }
  2217. if chineseTraditionalMedicineCostTotal != 0 {
  2218. iteminfo.MedChrgitm = "11"
  2219. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2220. iteminfo.Amt = westernMedicineCostTotal
  2221. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2222. iteminfo.ClabAmt = westernMedicine_clab_amt
  2223. iteminfo.OthAmt = westernMedicine_other_amt
  2224. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2225. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2226. }
  2227. if commonlyTreatmentCostTotal != 0 {
  2228. iteminfo.MedChrgitm = "12"
  2229. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2230. iteminfo.Amt = commonlyTreatmentCostTotal
  2231. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2232. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2233. iteminfo.OthAmt = commonly_treatment_other_amt
  2234. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2235. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2236. }
  2237. if registerCostTotal != 0 {
  2238. iteminfo.MedChrgitm = "13"
  2239. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2240. iteminfo.Amt = registerCostTotal
  2241. iteminfo.ClaaSumfee = register_claa_sunmfee
  2242. iteminfo.ClabAmt = register_clab_amt
  2243. iteminfo.OthAmt = register_other_amt
  2244. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2245. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2246. }
  2247. if otherCostTotal != 0 {
  2248. iteminfo.MedChrgitm = "14"
  2249. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2250. iteminfo.Amt = otherCostTotal
  2251. iteminfo.ClaaSumfee = other_claa_sunmfee
  2252. iteminfo.ClabAmt = other_clab_amt
  2253. iteminfo.OthAmt = other_other_amt
  2254. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2255. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2256. }
  2257. struct4101.IteminfoStruct = iteminfoStructs
  2258. struct4101.Ntly = "中国"
  2259. struct4101.AdmCaty = "A03.06"
  2260. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2261. fmt.Println(result)
  2262. var dat map[string]interface{}
  2263. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2264. fmt.Println(dat)
  2265. } else {
  2266. fmt.Println(err)
  2267. }
  2268. userJSONBytes, _ := json.Marshal(dat)
  2269. var res ResultSeventeen
  2270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2271. utils.ErrorLog("解析失败:%v", err)
  2272. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2273. adminUser := c.GetAdminUserInfo()
  2274. errlog := &models.HisOrderError{
  2275. UserOrgId: adminUser.CurrentOrgId,
  2276. Ctime: time.Now().Unix(),
  2277. Mtime: time.Now().Unix(),
  2278. ErrMsg: res.ErrMsg + "解析失败",
  2279. Status: 1,
  2280. PatientId: order_id,
  2281. Stage: 10106,
  2282. }
  2283. service.CreateErrMsgLog(errlog)
  2284. continue
  2285. }
  2286. if res.Infcode != 0 {
  2287. adminUser := c.GetAdminUserInfo()
  2288. errlog := &models.HisOrderError{
  2289. UserOrgId: adminUser.CurrentOrgId,
  2290. Ctime: time.Now().Unix(),
  2291. Mtime: time.Now().Unix(),
  2292. ErrMsg: res.ErrMsg,
  2293. Status: 1,
  2294. PatientId: order_id,
  2295. Stage: 10106,
  2296. }
  2297. service.CreateErrMsgLog(errlog)
  2298. continue
  2299. } else {
  2300. hisFundSettleListResult := &models.HisFundSettleListResult{
  2301. Number: res.Output.SetlListId,
  2302. Status: 1,
  2303. Ctime: time.Now().Unix(),
  2304. Mtime: time.Now().Unix(),
  2305. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2306. IsUpload: 1,
  2307. OrderId: order_id,
  2308. }
  2309. service.CreateUploadRecord(hisFundSettleListResult)
  2310. continue
  2311. }
  2312. }
  2313. }
  2314. func (c *HisApiController) GetOrgInfo() {
  2315. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2316. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2317. }
  2318. func (c *HisApiController) GetHisPatientInfo() {
  2319. medical_insurance_card := c.GetString("medical_insurance_card")
  2320. id_card_type, _ := c.GetInt64("id_card_type")
  2321. id_card := c.GetString("id_card")
  2322. adminInfo := c.GetAdminUserInfo()
  2323. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2324. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2325. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2326. IdCardNo := ""
  2327. if id_card_type == 1 {
  2328. IdCardNo = medical_insurance_card
  2329. } else if id_card_type == 2 {
  2330. IdCardNo = id_card
  2331. }
  2332. if config.IsOpen == 1 {
  2333. 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
  2334. resp, requestErr := http.Get(api)
  2335. if requestErr != nil {
  2336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2337. return
  2338. }
  2339. defer resp.Body.Close()
  2340. body, ioErr := ioutil.ReadAll(resp.Body)
  2341. if ioErr != nil {
  2342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2344. return
  2345. }
  2346. var respJSON map[string]interface{}
  2347. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2350. return
  2351. }
  2352. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2353. userJSONBytes, _ := json.Marshal(userJSON)
  2354. var res ResultTwo
  2355. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2356. utils.ErrorLog("解析失败:%v", err)
  2357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2358. return
  2359. }
  2360. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2361. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2362. infoStr := string(Iinfos)
  2363. idetinfoStr := string(Idetinfos)
  2364. if res.Infcode == 0 {
  2365. his := models.VMHisPatient{
  2366. Status: 1,
  2367. Ctime: time.Now().Unix(),
  2368. Mtime: time.Now().Unix(),
  2369. PsnNo: res.Output.Baseinfo.PsnNo,
  2370. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2371. Certno: res.Output.Baseinfo.Certno,
  2372. PsnName: res.Output.Baseinfo.PsnName,
  2373. Gend: res.Output.Baseinfo.Gend,
  2374. Naty: res.Output.Baseinfo.Naty,
  2375. Brdy: res.Output.Baseinfo.Brdy,
  2376. Age: res.Output.Baseinfo.Age,
  2377. Iinfo: infoStr,
  2378. Idetinfo: idetinfoStr,
  2379. UserOrgId: adminInfo.CurrentOrgId,
  2380. IsReturn: 1,
  2381. IdCardType: id_card_type,
  2382. }
  2383. c.ServeSuccessJSON(map[string]interface{}{
  2384. "info": his,
  2385. })
  2386. } else {
  2387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2388. return
  2389. }
  2390. }
  2391. }
  2392. //func GetBasBaseInfo() (jsonStr string, err error) {
  2393. //
  2394. // handle := syscall.NewLazyDLL("SSCard.dll")
  2395. // add := handle.NewProc("ReadCardBas")
  2396. // str := make([]byte, 1024)
  2397. // str1 := make([]byte, 1024)
  2398. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2399. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2400. //
  2401. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2402. //
  2403. // fmt.Println("> Add(4,5)的结果为:", ret)
  2404. // handle.Release()
  2405. //
  2406. // return "", nil
  2407. //
  2408. //}
  2409. //func GetQRBaseInfo() (jsonStr string, err error) {
  2410. // handle := syscall.LoadDLL("SSCard.dll")
  2411. // ReadCardBas := handle.FindProc("GetQRBase")
  2412. //
  2413. // str := make([]byte, 256)
  2414. // str1 := make([]byte, 256)
  2415. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2416. //
  2417. // fmt.Println(string(str))
  2418. // fmt.Println(r)
  2419. // return string(str), nil
  2420. //}
  2421. //func CardInit() int {
  2422. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2423. // add := DllTestDef.MustFindProc("Init")
  2424. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2425. // if err != nil {
  2426. // fmt.Println("SSCard的运算结果为:", ret)
  2427. // }
  2428. // result := int(ret)
  2429. // return result
  2430. //}
  2431. //func CardInit() int {
  2432. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2433. // if err != nil {
  2434. // fmt.Println("SSCard的运算结果为:", ret)
  2435. // }
  2436. // fmt.Println(err)
  2437. // result := int(ret)
  2438. // return result
  2439. //}
  2440. func IntPtr(n int) uintptr {
  2441. return uintptr(n)
  2442. }
  2443. func StrPtr(s string) uintptr {
  2444. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2445. }
  2446. type Result2001 struct {
  2447. Cainfo interface{} `json:"cainfo"`
  2448. ErrMsg string `json:"err_msg"`
  2449. InfRefmsgid string `json:"inf_refmsgid"`
  2450. Infcode int64 `json:"infcode"`
  2451. Output struct {
  2452. Trtinfo struct {
  2453. PsnNo string `json:"psn_no"`
  2454. TrtChkType string `json:"trt_chk_type"`
  2455. FundPayType string `json:"fund_pay_type"`
  2456. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2457. Begndate string `json:"begndate"`
  2458. Enddate string `json:"enddate"`
  2459. TrtChkRslt string `json:"trt_chk_rslt"`
  2460. } `json:"trtinfo"`
  2461. } `json:"output"`
  2462. RefmsgTime string `json:"refmsg_time"`
  2463. RespondTime string `json:"respond_time"`
  2464. Signtype interface{} `json:"signtype"`
  2465. WarnMsg interface{} `json:"warn_msg"`
  2466. }
  2467. type Result2001Org10265 struct {
  2468. Cainfo interface{} `json:"cainfo"`
  2469. ErrMsg string `json:"err_msg"`
  2470. InfRefmsgid string `json:"inf_refmsgid"`
  2471. Infcode string `json:"infcode"`
  2472. Output struct {
  2473. Trtinfo struct {
  2474. PsnNo string `json:"psn_no"`
  2475. TrtChkType string `json:"trt_chk_type"`
  2476. FundPayType string `json:"fund_pay_type"`
  2477. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2478. Begndate string `json:"begndate"`
  2479. Enddate string `json:"enddate"`
  2480. TrtChkRslt string `json:"trt_chk_rslt"`
  2481. } `json:"trtinfo"`
  2482. } `json:"output"`
  2483. RefmsgTime string `json:"refmsg_time"`
  2484. RespondTime string `json:"respond_time"`
  2485. Signtype interface{} `json:"signtype"`
  2486. WarnMsg interface{} `json:"warn_msg"`
  2487. }
  2488. type ResultTwo struct {
  2489. ErrMsg string `json:"err_msg"`
  2490. InfRefmsgid string `json:"inf_refmsgid"`
  2491. Infcode int64 `json:"infcode"`
  2492. Output struct {
  2493. Baseinfo struct {
  2494. Age float64 `json:"age"`
  2495. Brdy string `json:"brdy"`
  2496. Certno string `json:"certno"`
  2497. Gend string `json:"gend"`
  2498. Naty string `json:"naty"`
  2499. PsnCertType string `json:"psn_cert_type"`
  2500. PsnName string `json:"psn_name"`
  2501. PsnNo string `json:"psn_no"`
  2502. } `json:"baseinfo"`
  2503. Idetinfo []interface{} `json:"idetinfo"`
  2504. Iinfo []struct {
  2505. Balc float64 `json:"balc"`
  2506. CvlservFlag string `json:"cvlserv_flag"`
  2507. EmpName string `json:"emp_name"`
  2508. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2509. Insutype string `json:"insutype"`
  2510. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2511. PausInsuDate string `json:"paus_insu_date"`
  2512. PsnInsuDate string `json:"psn_insu_date"`
  2513. PsnInsuStas string `json:"psn_insu_stas"`
  2514. PsnType string `json:"psn_type"`
  2515. } `json:"insuinfo"`
  2516. } `json:"output"`
  2517. RefmsgTime string `json:"refmsg_time"`
  2518. RespondTime string `json:"respond_time"`
  2519. Signtype interface{} `json:"signtype"`
  2520. WarnInfo interface{} `json:"warn_info"`
  2521. }
  2522. type ResultTwo10265 struct {
  2523. ErrMsg string `json:"err_msg"`
  2524. InfRefmsgid string `json:"inf_refmsgid"`
  2525. Infcode string `json:"infcode"`
  2526. Output struct {
  2527. Baseinfo struct {
  2528. Age float64 `json:"age"`
  2529. Brdy string `json:"brdy"`
  2530. Certno string `json:"certno"`
  2531. Gend string `json:"gend"`
  2532. Naty string `json:"naty"`
  2533. PsnCertType string `json:"psn_cert_type"`
  2534. PsnName string `json:"psn_name"`
  2535. PsnNo string `json:"psn_no"`
  2536. } `json:"baseinfo"`
  2537. Idetinfo []interface{} `json:"idetinfo"`
  2538. Iinfo []struct {
  2539. Balc float64 `json:"balc"`
  2540. CvlservFlag string `json:"cvlserv_flag"`
  2541. EmpName string `json:"emp_name"`
  2542. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2543. Insutype string `json:"insutype"`
  2544. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2545. PausInsuDate string `json:"paus_insu_date"`
  2546. PsnInsuDate string `json:"psn_insu_date"`
  2547. PsnInsuStas string `json:"psn_insu_stas"`
  2548. PsnType string `json:"psn_type"`
  2549. } `json:"insuinfo"`
  2550. } `json:"output"`
  2551. RefmsgTime string `json:"refmsg_time"`
  2552. RespondTime string `json:"respond_time"`
  2553. Signtype interface{} `json:"signtype"`
  2554. WarnInfo interface{} `json:"warn_info"`
  2555. }
  2556. type ResultThree struct {
  2557. Cainfo interface{} `json:"cainfo"`
  2558. ErrMsg string `json:"err_msg"`
  2559. InfRefmsgid string `json:"inf_refmsgid"`
  2560. Infcode int64 `json:"infcode"`
  2561. Output struct {
  2562. Data struct {
  2563. IptOtpNo string `json:"ipt_otp_no"`
  2564. MdtrtID string `json:"mdtrt_id"`
  2565. PsnNo string `json:"psn_no"`
  2566. } `json:"data"`
  2567. } `json:"output"`
  2568. RefmsgTime string `json:"refmsg_time"`
  2569. RespondTime string `json:"respond_time"`
  2570. Signtype interface{} `json:"signtype"`
  2571. WarnMsg interface{} `json:"warn_msg"`
  2572. }
  2573. type ResultThree10265 struct {
  2574. Cainfo interface{} `json:"cainfo"`
  2575. ErrMsg string `json:"err_msg"`
  2576. InfRefmsgid string `json:"inf_refmsgid"`
  2577. Infcode string `json:"infcode"`
  2578. Output struct {
  2579. Data struct {
  2580. IptOtpNo string `json:"ipt_otp_no"`
  2581. MdtrtID string `json:"mdtrt_id"`
  2582. PsnNo string `json:"psn_no"`
  2583. } `json:"data"`
  2584. } `json:"output"`
  2585. RefmsgTime string `json:"refmsg_time"`
  2586. RespondTime string `json:"respond_time"`
  2587. Signtype interface{} `json:"signtype"`
  2588. WarnMsg interface{} `json:"warn_msg"`
  2589. }
  2590. type ResultFour struct {
  2591. Cainfo string `json:"cainfo"`
  2592. ErrMsg string `json:"err_msg"`
  2593. InfRefmsgid string `json:"inf_refmsgid"`
  2594. Infcode int64 `json:"infcode"`
  2595. Output struct {
  2596. Result []struct {
  2597. BasMednFlag string `json:"bas_medn_flag"`
  2598. ChldMedcFlag string `json:"chld_medc_flag"`
  2599. ChrgitmLv string `json:"chrgitm_lv"`
  2600. Cnt float64 `json:"cnt"`
  2601. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2602. DrtReimFlag string `json:"drt_reim_flag"`
  2603. FeedetlSn string `json:"feedetl_sn"`
  2604. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2605. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2606. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2607. ListSpItemFlag string `json:"list_sp_item_flag"`
  2608. LmtUsedFlag string `json:"lmt_used_flag"`
  2609. MedChrgitmType string `json:"med_chrgitm_type"`
  2610. Memo string `json:"memo"`
  2611. OverlmtAmt float64 `json:"overlmt_amt"`
  2612. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2613. Pric float64 `json:"pric"`
  2614. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2615. SelfpayProp float64 `json:"selfpay_prop"`
  2616. } `json:"result"`
  2617. } `json:"output"`
  2618. RefmsgTime string `json:"refmsg_time"`
  2619. RespondTime string `json:"respond_time"`
  2620. Signtype string `json:"signtype"`
  2621. WarnMsg string `json:"warn_msg"`
  2622. }
  2623. type ResultFour10265 struct {
  2624. Cainfo string `json:"cainfo"`
  2625. ErrMsg string `json:"err_msg"`
  2626. InfRefmsgid string `json:"inf_refmsgid"`
  2627. Infcode string `json:"infcode"`
  2628. Output struct {
  2629. Result []struct {
  2630. BasMednFlag string `json:"bas_medn_flag"`
  2631. ChldMedcFlag string `json:"chld_medc_flag"`
  2632. ChrgitmLv string `json:"chrgitm_lv"`
  2633. Cnt float64 `json:"cnt"`
  2634. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2635. DrtReimFlag string `json:"drt_reim_flag"`
  2636. FeedetlSn string `json:"feedetl_sn"`
  2637. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2638. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2639. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2640. ListSpItemFlag string `json:"list_sp_item_flag"`
  2641. LmtUsedFlag string `json:"lmt_used_flag"`
  2642. MedChrgitmType string `json:"med_chrgitm_type"`
  2643. Memo string `json:"memo"`
  2644. OverlmtAmt float64 `json:"overlmt_amt"`
  2645. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2646. Pric float64 `json:"pric"`
  2647. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2648. SelfpayProp float64 `json:"selfpay_prop"`
  2649. } `json:"result"`
  2650. } `json:"output"`
  2651. RefmsgTime string `json:"refmsg_time"`
  2652. RespondTime string `json:"respond_time"`
  2653. Signtype string `json:"signtype"`
  2654. WarnMsg string `json:"warn_msg"`
  2655. }
  2656. type ResultFive struct {
  2657. Balc float64 `json:"balc"`
  2658. CvlservFlag string `json:"cvlserv_flag"`
  2659. EmpName string `json:"emp_name"`
  2660. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2661. Insutype string `json:"insutype"`
  2662. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2663. PausInsuDate string `json:"paus_insu_date"`
  2664. PsnInsuDate string `json:"psn_insu_date"`
  2665. PsnInsuStas string `json:"psn_insu_stas"`
  2666. PsnType string `json:"psn_type"`
  2667. }
  2668. type ResultSix struct {
  2669. Cainfo interface{} `json:"cainfo"`
  2670. ErrMsg string `json:"err_msg"`
  2671. InfRefmsgid string `json:"inf_refmsgid"`
  2672. Infcode int64 `json:"infcode"`
  2673. Output struct {
  2674. } `json:"output"`
  2675. RefmsgTime string `json:"refmsg_time"`
  2676. RespondTime string `json:"respond_time"`
  2677. Signtype interface{} `json:"signtype"`
  2678. WarnMsg interface{} `json:"warn_msg"`
  2679. }
  2680. type ResultSix10265 struct {
  2681. Cainfo interface{} `json:"cainfo"`
  2682. ErrMsg string `json:"err_msg"`
  2683. InfRefmsgid string `json:"inf_refmsgid"`
  2684. Infcode string `json:"infcode"`
  2685. Output struct {
  2686. } `json:"output"`
  2687. RefmsgTime string `json:"refmsg_time"`
  2688. RespondTime string `json:"respond_time"`
  2689. Signtype interface{} `json:"signtype"`
  2690. WarnMsg interface{} `json:"warn_msg"`
  2691. }
  2692. type ResultSeven struct {
  2693. Cainfo string `json:"cainfo"`
  2694. ErrMsg string `json:"err_msg"`
  2695. InfRefmsgid string `json:"inf_refmsgid"`
  2696. Infcode int64 `json:"infcode"`
  2697. Output struct {
  2698. Setldetail []interface{} `json:"setldetail"`
  2699. Setlinfo struct {
  2700. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2701. AcctPay float64 `json:"acct_pay"`
  2702. ActPayDedc float64 `json:"act_pay_dedc"`
  2703. Age float64 `json:"age"`
  2704. Balc float64 `json:"balc"`
  2705. Brdy string `json:"brdy"`
  2706. Certno string `json:"certno"`
  2707. ClrOptins string `json:"clr_optins"`
  2708. ClrType string `json:"clr_type"`
  2709. ClrWay string `json:"clr_way"`
  2710. CvlservFlag string `json:"cvlserv_flag"`
  2711. CvlservPay float64 `json:"cvlserv_pay"`
  2712. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2713. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2714. Gend string `json:"gend"`
  2715. HifesPay float64 `json:"hifes_pay"`
  2716. HifmiPay float64 `json:"hifmi_pay"`
  2717. HifpPay float64 `json:"hifp_pay"`
  2718. HospPartAmt float64 `json:"hosp_part_amt"`
  2719. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2720. Insutype string `json:"insutype"`
  2721. MafPay float64 `json:"maf_pay"`
  2722. MdtrtCertType string `json:"mdtrt_cert_type"`
  2723. HifobPay float64 `json:"hifob_pay"`
  2724. MdtrtID string `json:"mdtrt_id"`
  2725. MedType string `json:"med_type"`
  2726. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2727. MedinsSetlID string `json:"medins_setl_id"`
  2728. Naty string `json:"naty"`
  2729. OthPay float64 `json:"oth_pay"`
  2730. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2731. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2732. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2733. PsnCashPay float64 `json:"psn_cash_pay"`
  2734. PsnCertType string `json:"psn_cert_type"`
  2735. PsnName string `json:"psn_name"`
  2736. PsnNo string `json:"psn_no"`
  2737. PsnPartAmt float64 `json:"psn_part_amt"`
  2738. PsnType string `json:"psn_type"`
  2739. SetlID string `json:"setl_id"`
  2740. SetlTime string `json:"setl_time"`
  2741. } `json:"setlinfo"`
  2742. } `json:"output"`
  2743. RefmsgTime string `json:"refmsg_time"`
  2744. RespondTime string `json:"respond_time"`
  2745. Signtype interface{} `json:"signtype"`
  2746. WarnMsg interface{} `json:"warn_msg"`
  2747. }
  2748. type ResultSeven10265 struct {
  2749. Cainfo string `json:"cainfo"`
  2750. ErrMsg string `json:"err_msg"`
  2751. InfRefmsgid string `json:"inf_refmsgid"`
  2752. Infcode string `json:"infcode"`
  2753. Output struct {
  2754. Setldetail []interface{} `json:"setldetail"`
  2755. Setlinfo struct {
  2756. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2757. AcctPay float64 `json:"acct_pay"`
  2758. ActPayDedc float64 `json:"act_pay_dedc"`
  2759. Age float64 `json:"age"`
  2760. Balc float64 `json:"balc"`
  2761. Brdy string `json:"brdy"`
  2762. Certno string `json:"certno"`
  2763. ClrOptins string `json:"clr_optins"`
  2764. ClrType string `json:"clr_type"`
  2765. ClrWay string `json:"clr_way"`
  2766. CvlservFlag string `json:"cvlserv_flag"`
  2767. CvlservPay float64 `json:"cvlserv_pay"`
  2768. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2769. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2770. Gend string `json:"gend"`
  2771. HifesPay float64 `json:"hifes_pay"`
  2772. HifmiPay float64 `json:"hifmi_pay"`
  2773. HifpPay float64 `json:"hifp_pay"`
  2774. HospPartAmt float64 `json:"hosp_part_amt"`
  2775. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2776. Insutype string `json:"insutype"`
  2777. MafPay float64 `json:"maf_pay"`
  2778. MdtrtCertType string `json:"mdtrt_cert_type"`
  2779. HifobPay float64 `json:"hifob_pay"`
  2780. MdtrtID string `json:"mdtrt_id"`
  2781. MedType string `json:"med_type"`
  2782. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2783. MedinsSetlID string `json:"medins_setl_id"`
  2784. Naty string `json:"naty"`
  2785. OthPay float64 `json:"oth_pay"`
  2786. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2787. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2788. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2789. PsnCashPay float64 `json:"psn_cash_pay"`
  2790. PsnCertType string `json:"psn_cert_type"`
  2791. PsnName string `json:"psn_name"`
  2792. PsnNo string `json:"psn_no"`
  2793. PsnPartAmt float64 `json:"psn_part_amt"`
  2794. PsnType string `json:"psn_type"`
  2795. SetlID string `json:"setl_id"`
  2796. SetlTime string `json:"setl_time"`
  2797. } `json:"setlinfo"`
  2798. } `json:"output"`
  2799. RefmsgTime string `json:"refmsg_time"`
  2800. RespondTime string `json:"respond_time"`
  2801. Signtype interface{} `json:"signtype"`
  2802. WarnMsg interface{} `json:"warn_msg"`
  2803. }
  2804. type ResultEight struct {
  2805. Cainfo string `json:"cainfo"`
  2806. ErrMsg string `json:"err_msg"`
  2807. InfRefmsgid string `json:"inf_refmsgid"`
  2808. Infcode int64 `json:"infcode"`
  2809. Output struct {
  2810. Stmtinfo struct {
  2811. SetlOptins string `json:"setl_optins"`
  2812. StmtRslt string `json:"stmt_rslt"`
  2813. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2814. } `json:"stmtinfo"`
  2815. } `json:"output"`
  2816. RefmsgTime string `json:"refmsg_time"`
  2817. RespondTime string `json:"respond_time"`
  2818. Signtype interface{} `json:"signtype"`
  2819. WarnMsg interface{} `json:"warn_msg"`
  2820. }
  2821. type ResultEightFor10188 struct {
  2822. Cainfo string `json:"cainfo"`
  2823. ErrMsg string `json:"err_msg"`
  2824. InfRefmsgid string `json:"inf_refmsgid"`
  2825. Infcode string `json:"infcode"`
  2826. Output struct {
  2827. Stmtinfo struct {
  2828. SetlOptins string `json:"setl_optins"`
  2829. StmtRslt string `json:"stmt_rslt"`
  2830. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2831. } `json:"stmtinfo"`
  2832. } `json:"output"`
  2833. RefmsgTime string `json:"refmsg_time"`
  2834. RespondTime string `json:"respond_time"`
  2835. Signtype interface{} `json:"signtype"`
  2836. WarnMsg interface{} `json:"warn_msg"`
  2837. }
  2838. type ResultNine struct {
  2839. Cainfo string `json:"cainfo"`
  2840. ErrMsg string `json:"err_msg"`
  2841. InfRefmsgid string `json:"inf_refmsgid"`
  2842. Infcode int64 `json:"infcode"`
  2843. Output struct {
  2844. FileQuryNo string `json:"file_qury_no"`
  2845. } `json:"output"`
  2846. RefmsgTime string `json:"refmsg_time"`
  2847. RespondTime string `json:"respond_time"`
  2848. Signtype interface{} `json:"signtype"`
  2849. WarnMsg interface{} `json:"warn_msg"`
  2850. }
  2851. type ResultTen struct {
  2852. Cainfo string `json:"cainfo"`
  2853. ErrMsg string `json:"err_msg"`
  2854. InfRefmsgid string `json:"inf_refmsgid"`
  2855. Infcode int64 `json:"infcode"`
  2856. Output struct {
  2857. DldEndtime string `json:"dld_endtime"`
  2858. FileQuryNo string `json:"file_qury_no"`
  2859. Filename string `json:"filename"`
  2860. } `json:"output"`
  2861. RefmsgTime string `json:"refmsg_time"`
  2862. RespondTime string `json:"respond_time"`
  2863. Signtype interface{} `json:"signtype"`
  2864. WarnMsg interface{} `json:"warn_msg"`
  2865. }
  2866. //type Autogenerated struct {
  2867. // Output struct {
  2868. // Setlinfo struct {
  2869. // SetlTime string `json:"setl_time"`
  2870. // CvlservPay float64 `json:"cvlserv_pay"`
  2871. // Year string `json:"year"`
  2872. // MedType string `json:"med_type"`
  2873. // PsnPay float64 `json:"psn_pay"`
  2874. // OpterID string `json:"opter_id"`
  2875. // Begndate string `json:"begndate"`
  2876. // FlxempeFlag string `json:"flxempe_flag"`
  2877. // HifmiPay float64 `json:"hifmi_pay"`
  2878. // PsnNo string `json:"psn_no"`
  2879. // ActPayDedc float64 `json:"act_pay_dedc"`
  2880. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2881. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2882. // ClrWay string `json:"clr_way"`
  2883. // OthPay float64 `json:"oth_pay"`
  2884. // Gend string `json:"gend"`
  2885. // MdtrtID string `json:"mdtrt_id"`
  2886. // AcctPay float64 `json:"acct_pay"`
  2887. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2888. // Insutype string `json:"insutype"`
  2889. // Invono interface{} `json:"invono"`
  2890. // Enddate string `json:"enddate"`
  2891. // CashPayamt float64 `json:"cash_payamt"`
  2892. // PsnType string `json:"psn_type"`
  2893. // FixmedinsName string `json:"fixmedins_name"`
  2894. // HifpPay float64 `json:"hifp_pay"`
  2895. // NewFlag interface{} `json:"new_flag"`
  2896. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2897. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2898. // PayLoc string `json:"pay_loc"`
  2899. // ClrType string `json:"clr_type"`
  2900. // RefdSetlFlag string `json:"refd_setl_flag"`
  2901. // CvlservFlag string `json:"cvlserv_flag"`
  2902. // EmpName string `json:"emp_name"`
  2903. // Brdy string `json:"brdy"`
  2904. // Naty string `json:"naty"`
  2905. // Certno string `json:"certno"`
  2906. // DiseCode string `json:"dise_code"`
  2907. // FixmedinsCode string `json:"fixmedins_code"`
  2908. // DedcHospLv string `json:"dedc_hosp_lv"`
  2909. // OpterName string `json:"opter_name"`
  2910. // Balc float64 `json:"balc"`
  2911. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2912. // PsnCertType string `json:"psn_cert_type"`
  2913. // HifobPay float64 `json:"hifob_pay"`
  2914. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2915. // HifesPay float64 `json:"hifes_pay"`
  2916. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2917. // OptTime string `json:"opt_time"`
  2918. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2919. // SetlID string `json:"setl_id"`
  2920. // MafPay float64 `json:"maf_pay"`
  2921. // PsnName string `json:"psn_name"`
  2922. // InsuOptins interface{} `json:"insu_optins"`
  2923. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2924. // ClrOptins string `json:"clr_optins"`
  2925. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2926. // DiseName string `json:"dise_name"`
  2927. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2928. // Age float64 `json:"age"`
  2929. // DtrtCertType string `json:"dtrt_cert_type"`
  2930. // HospLv string `json:"hosp_lv"`
  2931. // } `json:"setlinfo"`
  2932. // Setldetail []struct {
  2933. // FundPayType string `json:"fund_pay_type"`
  2934. // FundPayamt float64 `json:"fund_payamt"`
  2935. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2936. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2937. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2938. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2939. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2940. // } `json:"setldetail"`
  2941. // } `json:"output"`
  2942. // Infcode int `json:"infcode"`
  2943. // WarnMsg interface{} `json:"warn_msg"`
  2944. // Cainfo interface{} `json:"cainfo"`
  2945. // ErrMsg interface{} `json:"err_msg"`
  2946. // RefmsgTime string `json:"refmsg_time"`
  2947. // Signtype interface{} `json:"signtype"`
  2948. // RespondTime string `json:"respond_time"`
  2949. // InfRefmsgid string `json:"inf_refmsgid"`
  2950. //}
  2951. type ResultEleven struct {
  2952. Cainfo string `json:"cainfo"`
  2953. ErrMsg string `json:"err_msg"`
  2954. InfRefmsgid string `json:"inf_refmsgid"`
  2955. Infcode int64 `json:"infcode"`
  2956. Output struct {
  2957. Setlinfo struct {
  2958. SetlTime string `json:"setl_time"`
  2959. CvlservPay float64 `json:"cvlserv_pay"`
  2960. Year string `json:"year"`
  2961. MedType string `json:"med_type"`
  2962. PsnPay float64 `json:"psn_pay"`
  2963. OpterID string `json:"opter_id"`
  2964. Begndate string `json:"begndate"`
  2965. FlxempeFlag string `json:"flxempe_flag"`
  2966. HifmiPay float64 `json:"hifmi_pay"`
  2967. PsnNo string `json:"psn_no"`
  2968. ActPayDedc float64 `json:"act_pay_dedc"`
  2969. MedinsSetlID interface{} `json:"medins_setl_id"`
  2970. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2971. ClrWay string `json:"clr_way"`
  2972. OthPay float64 `json:"oth_pay"`
  2973. Gend string `json:"gend"`
  2974. MdtrtID string `json:"mdtrt_id"`
  2975. AcctPay float64 `json:"acct_pay"`
  2976. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2977. Insutype string `json:"insutype"`
  2978. Invono interface{} `json:"invono"`
  2979. Enddate string `json:"enddate"`
  2980. CashPayamt float64 `json:"cash_payamt"`
  2981. PsnType string `json:"psn_type"`
  2982. FixmedinsName string `json:"fixmedins_name"`
  2983. HifpPay float64 `json:"hifp_pay"`
  2984. NewFlag interface{} `json:"new_flag"`
  2985. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2986. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2987. PayLoc string `json:"pay_loc"`
  2988. ClrType string `json:"clr_type"`
  2989. RefdSetlFlag string `json:"refd_setl_flag"`
  2990. CvlservFlag string `json:"cvlserv_flag"`
  2991. EmpName string `json:"emp_name"`
  2992. Brdy string `json:"brdy"`
  2993. Naty string `json:"naty"`
  2994. Certno string `json:"certno"`
  2995. DiseCode string `json:"dise_code"`
  2996. FixmedinsCode string `json:"fixmedins_code"`
  2997. DedcHospLv string `json:"dedc_hosp_lv"`
  2998. OpterName string `json:"opter_name"`
  2999. Balc float64 `json:"balc"`
  3000. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3001. PsnCertType string `json:"psn_cert_type"`
  3002. HifobPay float64 `json:"hifob_pay"`
  3003. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3004. HifesPay float64 `json:"hifes_pay"`
  3005. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3006. OptTime string `json:"opt_time"`
  3007. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3008. SetlID string `json:"setl_id"`
  3009. MafPay float64 `json:"maf_pay"`
  3010. PsnName string `json:"psn_name"`
  3011. InsuOptins interface{} `json:"insu_optins"`
  3012. PrefFundPay interface{} `json:"pref_fund_pay"`
  3013. ClrOptins string `json:"clr_optins"`
  3014. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3015. DiseName string `json:"dise_name"`
  3016. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3017. Age float64 `json:"age"`
  3018. DtrtCertType string `json:"dtrt_cert_type"`
  3019. HospLv string `json:"hosp_lv"`
  3020. } `json:"setlinfo"`
  3021. } `json:"output"`
  3022. RefmsgTime string `json:"refmsg_time"`
  3023. RespondTime string `json:"respond_time"`
  3024. Signtype interface{} `json:"signtype"`
  3025. WarnMsg interface{} `json:"warn_msg"`
  3026. }
  3027. type ResultEleven10265 struct {
  3028. Cainfo string `json:"cainfo"`
  3029. ErrMsg string `json:"err_msg"`
  3030. InfRefmsgid string `json:"inf_refmsgid"`
  3031. Infcode string `json:"infcode"`
  3032. Output struct {
  3033. Setlinfo struct {
  3034. SetlTime string `json:"setl_time"`
  3035. CvlservPay float64 `json:"cvlserv_pay"`
  3036. Year string `json:"year"`
  3037. MedType string `json:"med_type"`
  3038. PsnPay float64 `json:"psn_pay"`
  3039. OpterID string `json:"opter_id"`
  3040. Begndate string `json:"begndate"`
  3041. FlxempeFlag string `json:"flxempe_flag"`
  3042. HifmiPay float64 `json:"hifmi_pay"`
  3043. PsnNo string `json:"psn_no"`
  3044. ActPayDedc float64 `json:"act_pay_dedc"`
  3045. MedinsSetlID interface{} `json:"medins_setl_id"`
  3046. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3047. ClrWay string `json:"clr_way"`
  3048. OthPay float64 `json:"oth_pay"`
  3049. Gend string `json:"gend"`
  3050. MdtrtID string `json:"mdtrt_id"`
  3051. AcctPay float64 `json:"acct_pay"`
  3052. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3053. Insutype string `json:"insutype"`
  3054. Invono interface{} `json:"invono"`
  3055. Enddate string `json:"enddate"`
  3056. CashPayamt float64 `json:"cash_payamt"`
  3057. PsnType string `json:"psn_type"`
  3058. FixmedinsName string `json:"fixmedins_name"`
  3059. HifpPay float64 `json:"hifp_pay"`
  3060. NewFlag interface{} `json:"new_flag"`
  3061. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3062. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3063. PayLoc string `json:"pay_loc"`
  3064. ClrType string `json:"clr_type"`
  3065. RefdSetlFlag string `json:"refd_setl_flag"`
  3066. CvlservFlag string `json:"cvlserv_flag"`
  3067. EmpName string `json:"emp_name"`
  3068. Brdy string `json:"brdy"`
  3069. Naty string `json:"naty"`
  3070. Certno string `json:"certno"`
  3071. DiseCode string `json:"dise_code"`
  3072. FixmedinsCode string `json:"fixmedins_code"`
  3073. DedcHospLv string `json:"dedc_hosp_lv"`
  3074. OpterName string `json:"opter_name"`
  3075. Balc float64 `json:"balc"`
  3076. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3077. PsnCertType string `json:"psn_cert_type"`
  3078. HifobPay float64 `json:"hifob_pay"`
  3079. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3080. HifesPay float64 `json:"hifes_pay"`
  3081. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3082. OptTime string `json:"opt_time"`
  3083. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3084. SetlID string `json:"setl_id"`
  3085. MafPay float64 `json:"maf_pay"`
  3086. PsnName string `json:"psn_name"`
  3087. InsuOptins interface{} `json:"insu_optins"`
  3088. PrefFundPay interface{} `json:"pref_fund_pay"`
  3089. ClrOptins string `json:"clr_optins"`
  3090. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3091. DiseName string `json:"dise_name"`
  3092. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3093. Age float64 `json:"age"`
  3094. DtrtCertType string `json:"dtrt_cert_type"`
  3095. HospLv string `json:"hosp_lv"`
  3096. } `json:"setlinfo"`
  3097. } `json:"output"`
  3098. RefmsgTime string `json:"refmsg_time"`
  3099. RespondTime string `json:"respond_time"`
  3100. Signtype interface{} `json:"signtype"`
  3101. WarnMsg interface{} `json:"warn_msg"`
  3102. }
  3103. type ResultTwelve struct {
  3104. Cainfo string `json:"cainfo"`
  3105. ErrMsg string `json:"err_msg"`
  3106. InfRefmsgid string `json:"inf_refmsgid"`
  3107. Infcode int64 `json:"infcode"`
  3108. Output struct {
  3109. MdtrtId string `json:"mdtrt_id"`
  3110. ChrgBchno string `json:"chrg_bchno"`
  3111. PsnNo string `json:"psn_no"`
  3112. } `json:"output"`
  3113. RefmsgTime string `json:"refmsg_time"`
  3114. RespondTime string `json:"respond_time"`
  3115. Signtype interface{} `json:"signtype"`
  3116. WarnMsg interface{} `json:"warn_msg"`
  3117. }
  3118. type ResultThirteen struct {
  3119. ErrMsg string `json:"err_msg"`
  3120. InfRefmsgid string `json:"inf_refmsgid"`
  3121. Infcode int64 `json:"infcode"`
  3122. Output struct {
  3123. Result struct {
  3124. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3125. } `json:"result"`
  3126. } `json:"output"`
  3127. RefmsgTime string `json:"refmsg_time"`
  3128. RespondTime string `json:"respond_time"`
  3129. Signtype interface{} `json:"signtype"`
  3130. WarnInfo interface{} `json:"warn_info"`
  3131. }
  3132. type ResultThirteen10265 struct {
  3133. ErrMsg string `json:"err_msg"`
  3134. InfRefmsgid string `json:"inf_refmsgid"`
  3135. Infcode string `json:"infcode"`
  3136. Output struct {
  3137. Result struct {
  3138. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3139. } `json:"result"`
  3140. } `json:"output"`
  3141. RefmsgTime string `json:"refmsg_time"`
  3142. RespondTime string `json:"respond_time"`
  3143. Signtype interface{} `json:"signtype"`
  3144. WarnInfo interface{} `json:"warn_info"`
  3145. }
  3146. type ResultFourteen struct {
  3147. ErrMsg string `json:"err_msg"`
  3148. InfRefmsgid string `json:"inf_refmsgid"`
  3149. Infcode int64 `json:"infcode"`
  3150. Output struct {
  3151. } `json:"output"`
  3152. RefmsgTime string `json:"refmsg_time"`
  3153. RespondTime string `json:"respond_time"`
  3154. Signtype interface{} `json:"signtype"`
  3155. WarnInfo interface{} `json:"warn_info"`
  3156. }
  3157. type ResultFourteen10265 struct {
  3158. ErrMsg string `json:"err_msg"`
  3159. InfRefmsgid string `json:"inf_refmsgid"`
  3160. Infcode string `json:"infcode"`
  3161. Output struct {
  3162. } `json:"output"`
  3163. RefmsgTime string `json:"refmsg_time"`
  3164. RespondTime string `json:"respond_time"`
  3165. Signtype interface{} `json:"signtype"`
  3166. WarnInfo interface{} `json:"warn_info"`
  3167. }
  3168. type ResultSixteen struct {
  3169. Cainfo string `json:"cainfo"`
  3170. ErrMsg string `json:"err_msg"`
  3171. InfRefmsgid string `json:"inf_refmsgid"`
  3172. Infcode int64 `json:"infcode"`
  3173. Output struct {
  3174. Setldetail []interface{} `json:"setldetail"`
  3175. Setlinfo struct {
  3176. MdtrtID string `json:"mdtrt_id"`
  3177. SetlID string `json:"setl_id"`
  3178. ClrOptins string `json:"clr_optins"`
  3179. SetlTime string `json:"setl_time"`
  3180. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3181. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3182. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3183. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3184. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3185. ActPayDedc float64 `json:"act_pay_dedc"`
  3186. HifpPay float64 `json:"hifp_pay"`
  3187. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3188. Lfpay float64 `json:"selfpay"`
  3189. CvlservPay float64 `json:"cvlserv_pay"`
  3190. HifesPay float64 `json:"hifes_pay"`
  3191. HifmiPay float64 `json:"hifmi_pay"`
  3192. HifobPay float64 `json:"hifob_pay"`
  3193. MafPay float64 `json:"maf_pay"`
  3194. OthPay float64 `json:"oth_pay"`
  3195. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3196. PsnPartAmt float64 `json:"psn_part_amt"`
  3197. AcctPay float64 `json:"acct_pay"`
  3198. Balc float64 `json:"balc"`
  3199. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3200. HospPartAmt float64 `json:"hosp_part_amt"`
  3201. MedinsSetlID string `json:"medins_setl_id"`
  3202. PdnCashPay string `json:"pdn_cash_pay"`
  3203. } `json:"setlinfo"`
  3204. } `json:"output"`
  3205. RefmsgTime string `json:"refmsg_time"`
  3206. RespondTime string `json:"respond_time"`
  3207. Signtype interface{} `json:"signtype"`
  3208. WarnMsg interface{} `json:"warn_msg"`
  3209. }
  3210. type ResultSixteen10265 struct {
  3211. Cainfo string `json:"cainfo"`
  3212. ErrMsg string `json:"err_msg"`
  3213. InfRefmsgid string `json:"inf_refmsgid"`
  3214. Infcode string `json:"infcode"`
  3215. Output struct {
  3216. Setldetail []interface{} `json:"setldetail"`
  3217. Setlinfo struct {
  3218. MdtrtID string `json:"mdtrt_id"`
  3219. SetlID string `json:"setl_id"`
  3220. ClrOptins string `json:"clr_optins"`
  3221. SetlTime string `json:"setl_time"`
  3222. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3223. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3224. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3225. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3226. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3227. ActPayDedc float64 `json:"act_pay_dedc"`
  3228. HifpPay float64 `json:"hifp_pay"`
  3229. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3230. Lfpay float64 `json:"selfpay"`
  3231. CvlservPay float64 `json:"cvlserv_pay"`
  3232. HifesPay float64 `json:"hifes_pay"`
  3233. HifmiPay float64 `json:"hifmi_pay"`
  3234. HifobPay float64 `json:"hifob_pay"`
  3235. MafPay float64 `json:"maf_pay"`
  3236. OthPay float64 `json:"oth_pay"`
  3237. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3238. PsnPartAmt float64 `json:"psn_part_amt"`
  3239. AcctPay float64 `json:"acct_pay"`
  3240. Balc float64 `json:"balc"`
  3241. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3242. HospPartAmt float64 `json:"hosp_part_amt"`
  3243. MedinsSetlID string `json:"medins_setl_id"`
  3244. PdnCashPay string `json:"pdn_cash_pay"`
  3245. } `json:"setlinfo"`
  3246. } `json:"output"`
  3247. RefmsgTime string `json:"refmsg_time"`
  3248. RespondTime string `json:"respond_time"`
  3249. Signtype interface{} `json:"signtype"`
  3250. WarnMsg interface{} `json:"warn_msg"`
  3251. }
  3252. type ResultSeventeen struct {
  3253. ErrMsg string `json:"err_msg"`
  3254. InfRefmsgid string `json:"inf_refmsgid"`
  3255. Infcode int64 `json:"infcode"`
  3256. Output struct {
  3257. SetlListId string `json:"setl_list_id"`
  3258. } `json:"output"`
  3259. RefmsgTime string `json:"refmsg_time"`
  3260. RespondTime string `json:"respond_time"`
  3261. Signtype string `json:"signtype"`
  3262. WarnInfo string `json:"warn_info"`
  3263. }
  3264. type Result90991 struct {
  3265. ErrMsg string `json:"err_msg"`
  3266. InfRefmsgid string `json:"inf_refmsgid"`
  3267. Infcode int64 `json:"infcode"`
  3268. Output struct {
  3269. Result struct {
  3270. PsnNo string `json:"psn_no"`
  3271. CardStat string `json:"card_stat"`
  3272. Certno string `json:"certno"`
  3273. PsnName string `json:"psn_name"`
  3274. CheckStat string `json:"check_stat"`
  3275. } `json:"result"`
  3276. } `json:"output"`
  3277. RefmsgTime string `json:"refmsg_time"`
  3278. RespondTime string `json:"respond_time"`
  3279. Signtype interface{} `json:"signtype"`
  3280. WarnInfo interface{} `json:"warn_info"`
  3281. }
  3282. type Result90100 struct {
  3283. ErrMsg string `json:"err_msg"`
  3284. InfRefmsgid string `json:"inf_refmsgid"`
  3285. Infcode int64 `json:"infcode"`
  3286. Output struct {
  3287. PoolareaNo string `json:"poolarea_no"`
  3288. PoolareaNoName string `json:"poolarea_no_name"`
  3289. Insutype string `json:"insutype"`
  3290. InsutypeName string `json:"insutype_name"`
  3291. ClctType string `json:"clct_type"`
  3292. ClctTypeName string `json:"clct_type_name"`
  3293. ClctFlag string `json:"clct_flag"`
  3294. ClctFlagName string `json:"clct_flag_name"`
  3295. AccrymBegn string `json:"accrym_begn"`
  3296. AccrymEnd string `json:"accrym_end"`
  3297. ClctTime string `json:"clct_time"`
  3298. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3299. } `json:"output"`
  3300. RefmsgTime string `json:"refmsg_time"`
  3301. RespondTime string `json:"respond_time"`
  3302. Signtype interface{} `json:"signtype"`
  3303. WarnInfo interface{} `json:"warn_info"`
  3304. }
  3305. type Custom struct {
  3306. DetItemFeeSumamt string
  3307. Cut string
  3308. FeedetlSn string
  3309. Price string
  3310. MedListCodg string
  3311. Type int64
  3312. AdviceId int64
  3313. ProjectId int64
  3314. ItemId int64
  3315. }
  3316. type Result5301 struct {
  3317. ErrMsg string `json:"err_msg"`
  3318. InfRefmsgid string `json:"inf_refmsgid"`
  3319. Infcode int64 `json:"infcode"`
  3320. Output struct {
  3321. Result []struct {
  3322. OpspDiseCode string `json:"opsp_dise_code"`
  3323. OpspDiseName string `json:"opsp_dise_name"`
  3324. Begndate string `json:"begndate"`
  3325. Enddate string `json:"enddate"`
  3326. } `json:"feedetail"`
  3327. } `json:"output"`
  3328. RefmsgTime string `json:"refmsg_time"`
  3329. RespondTime string `json:"respond_time"`
  3330. Signtype interface{} `json:"signtype"`
  3331. WarnInfo interface{} `json:"warn_info"`
  3332. }
  3333. type Result5301For10265 struct {
  3334. ErrMsg string `json:"err_msg"`
  3335. InfRefmsgid string `json:"inf_refmsgid"`
  3336. Infcode string `json:"infcode"`
  3337. Output struct {
  3338. Result []struct {
  3339. OpspDiseCode string `json:"opsp_dise_code"`
  3340. OpspDiseName string `json:"opsp_dise_name"`
  3341. Begndate string `json:"begndate"`
  3342. Enddate string `json:"enddate"`
  3343. } `json:"feedetail"`
  3344. } `json:"output"`
  3345. RefmsgTime string `json:"refmsg_time"`
  3346. RespondTime string `json:"respond_time"`
  3347. Signtype interface{} `json:"signtype"`
  3348. WarnInfo interface{} `json:"warn_info"`
  3349. }
  3350. //获取个人信息----挂号-----上传就诊信息
  3351. func (c *HisApiController) GetRegisterInfo() {
  3352. id, _ := c.GetInt64("id")
  3353. record_time := c.GetString("record_time")
  3354. settlementValue, _ := c.GetInt64("settlement_value")
  3355. medical_insurance_card := c.GetString("medical_insurance_card")
  3356. name := c.GetString("name")
  3357. id_card_type, _ := c.GetInt64("id_card_type")
  3358. certificates, _ := c.GetInt64("certificates")
  3359. medical_care, _ := c.GetInt64("medical_care")
  3360. birthday := c.GetString("birthday")
  3361. id_card := c.GetString("id_card")
  3362. register_type, _ := c.GetInt64("register")
  3363. doctor, _ := c.GetInt64("doctor")
  3364. department, _ := c.GetInt64("department")
  3365. gender, _ := c.GetInt64("sex")
  3366. registration_fee, _ := c.GetFloat("registration_fee")
  3367. medical_expenses, _ := c.GetFloat("medical_expenses")
  3368. social_type, _ := c.GetInt64("social_type")
  3369. med_type := c.GetString("social_type")
  3370. admin_user_id, _ := c.GetInt64("admin_user_id")
  3371. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3372. timeLayout := "2006-01-02"
  3373. loc, _ := time.LoadLocation("Local")
  3374. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3375. birthUnix := birthdays.Unix()
  3376. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3377. if err != nil {
  3378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3379. return
  3380. }
  3381. recordDateTime := theTime.Unix()
  3382. adminInfo := c.GetAdminUserInfo()
  3383. var patient service.Patients
  3384. if id == 0 {
  3385. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3386. } else {
  3387. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3388. }
  3389. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3390. if patientPrescription.ID == 0 {
  3391. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3392. }
  3393. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3394. if patient.ID == 0 {
  3395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3396. return
  3397. }
  3398. if len(patient.IdCardNo) == 0 {
  3399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3400. return
  3401. }
  3402. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3403. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3404. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3405. //就诊结算未完成,不能进行二次挂号
  3406. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3407. if len(his) >= 1 {
  3408. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3409. if len(his) >= 1 && order.ID == 0 {
  3410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3411. return
  3412. }
  3413. }
  3414. //var register_log string
  3415. if config.IsOpen == 1 {
  3416. var res ResultTwo
  3417. var res10265 ResultTwo10265
  3418. var PsnNo string
  3419. var PsnCertType string
  3420. var Certno string
  3421. var PsnName string
  3422. var Gend string
  3423. var Naty string
  3424. var Brdy string
  3425. var Age float64
  3426. var infoStr string
  3427. var idetinfoStr string
  3428. var infocode int64
  3429. var verify_number string
  3430. fmt.Println(verify_number)
  3431. if miConfig.MdtrtareaAdmvs == "421300" {
  3432. psn_info, _ := service.GetPsnByPatientId(id)
  3433. PsnNo = psn_info.PsnNo
  3434. PsnCertType = psn_info.PsnCertType
  3435. Certno = psn_info.Certno
  3436. PsnName = psn_info.PsnName
  3437. Gend = psn_info.Gend
  3438. Naty = psn_info.Naty
  3439. Brdy = psn_info.Brdy
  3440. Age = psn_info.Age
  3441. infoStr = psn_info.Insuinfo
  3442. idetinfoStr = psn_info.Idetinfo
  3443. infocode = 0
  3444. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3445. psn_info, _ := service.GetPsnByPatientId(id)
  3446. PsnNo = psn_info.PsnNo
  3447. PsnCertType = psn_info.PsnCertType
  3448. Certno = psn_info.Certno
  3449. PsnName = psn_info.PsnName
  3450. Gend = psn_info.Gend
  3451. Naty = psn_info.Naty
  3452. Brdy = psn_info.Brdy
  3453. Age = psn_info.Age
  3454. infoStr = psn_info.Insuinfo
  3455. idetinfoStr = psn_info.Idetinfo
  3456. infocode = 0
  3457. verify_number = psn_info.VerifyNumber
  3458. } else {
  3459. var result string
  3460. var requestLog string
  3461. if miConfig.UserOrgId == 10138 {
  3462. 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)
  3463. } else {
  3464. 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)
  3465. }
  3466. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3467. if miConfig.Code == "H15049901371" {
  3468. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3469. utils.ErrorLog("解析失败:%v", err)
  3470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3471. return
  3472. }
  3473. res.ErrMsg = res10265.ErrMsg
  3474. res.Output = res10265.Output
  3475. res.InfRefmsgid = res10265.InfRefmsgid
  3476. } else {
  3477. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3478. utils.ErrorLog("解析失败:%v", err)
  3479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3480. return
  3481. }
  3482. }
  3483. PsnNo = res.Output.Baseinfo.PsnNo
  3484. PsnCertType = res.Output.Baseinfo.PsnCertType
  3485. Certno = res.Output.Baseinfo.Certno
  3486. PsnName = res.Output.Baseinfo.PsnName
  3487. Gend = res.Output.Baseinfo.Gend
  3488. Naty = res.Output.Baseinfo.Naty
  3489. Brdy = res.Output.Baseinfo.Brdy
  3490. Age = res.Output.Baseinfo.Age
  3491. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3492. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3493. infoStr = string(Iinfos)
  3494. idetinfoStr = string(Idetinfos)
  3495. if miConfig.Code == "H15049901371" {
  3496. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3497. } else {
  3498. infocode = res.Infcode
  3499. }
  3500. }
  3501. if infocode == 0 {
  3502. his := models.VMHisPatient{
  3503. Name: name,
  3504. Gender: gender,
  3505. Birthday: birthUnix,
  3506. MedicalTreatmentType: medical_care,
  3507. IdType: certificates,
  3508. IdCardNo: id_card,
  3509. BalanceAccountsType: settlementValue,
  3510. SocialType: social_type,
  3511. MedicalInsuranceNumber: medical_insurance_card,
  3512. RegisterType: register_type,
  3513. RegisterCost: registration_fee,
  3514. TreatmentCost: medical_expenses,
  3515. Status: 1,
  3516. Ctime: time.Now().Unix(),
  3517. Mtime: time.Now().Unix(),
  3518. PsnNo: PsnNo,
  3519. PsnCertType: PsnCertType,
  3520. Certno: Certno,
  3521. PsnName: PsnName,
  3522. Gend: Gend,
  3523. Naty: Naty,
  3524. Brdy: Brdy,
  3525. Age: Age,
  3526. Iinfo: infoStr,
  3527. Idetinfo: idetinfoStr,
  3528. PatientId: patient.ID,
  3529. RecordDate: theTime.Unix(),
  3530. UserOrgId: adminInfo.CurrentOrgId,
  3531. AdminUserId: admin_user_id,
  3532. IsReturn: 1,
  3533. IdCardType: id_card_type,
  3534. Doctor: doctor,
  3535. Departments: department,
  3536. }
  3537. timestamp := time.Now().Unix()
  3538. tempTime := time.Unix(timestamp, 0)
  3539. timeFormat := tempTime.Format("20060102150405")
  3540. chrgBchno := rand.Intn(100000) + 10000
  3541. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3542. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3543. department, _ := service.GetDepartMentDetail(department)
  3544. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3545. IdCardNo := ""
  3546. if id_card_type == 1 {
  3547. // IdCardNo = medical_insurance_card
  3548. IdCardNo = patient.IdCardNo
  3549. } else {
  3550. IdCardNo = patient.IdCardNo
  3551. }
  3552. var rf []*ResultFive
  3553. json.Unmarshal([]byte(his.Iinfo), &rf)
  3554. var insutypes []*ResultFive
  3555. var insutype string
  3556. var insuplc_admdvs_temp string
  3557. var is390 int = 0
  3558. var is310 int = 0
  3559. for _, item := range rf {
  3560. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3561. insutypes = append(insutypes, item)
  3562. }
  3563. }
  3564. if len(insutypes) == 1 {
  3565. insutype = insutypes[0].Insutype
  3566. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3567. } else {
  3568. for _, i := range insutypes {
  3569. if i.Insutype == "390" {
  3570. is390 = 1
  3571. }
  3572. if i.Insutype == "310" {
  3573. is310 = 1
  3574. }
  3575. }
  3576. }
  3577. if is390 == 1 {
  3578. insutype = "390"
  3579. }
  3580. if is310 == 1 {
  3581. insutype = "310"
  3582. }
  3583. if len(insutypes) == 0 {
  3584. insutype = "310"
  3585. }
  3586. if len(insutypes) == 2 {
  3587. insutype = med_type
  3588. }
  3589. if len(med_type) > 0 {
  3590. insutype = med_type
  3591. }
  3592. //for _, item := range rf {
  3593. // if item.Insutype == insutype {
  3594. // insuplc_admdvs = item.InsuplcAdmdvs
  3595. // }
  3596. //}
  3597. var infocode int64
  3598. var resThree ResultThree
  3599. var resThree10265 ResultThree10265
  3600. if len(insuplc_admdvs) == 0 {
  3601. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3602. } else {
  3603. insuplc_admdvs_temp = insuplc_admdvs
  3604. }
  3605. if miConfig.MdtrtareaAdmvs == "421300" {
  3606. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3607. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3608. "&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
  3609. resp, requestErr := http.Get(api)
  3610. if requestErr != nil {
  3611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3612. return
  3613. }
  3614. body, ioErr := ioutil.ReadAll(resp.Body)
  3615. if ioErr != nil {
  3616. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3618. return
  3619. }
  3620. var respJSON map[string]interface{}
  3621. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3622. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3624. return
  3625. }
  3626. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3627. result, _ := json.Marshal(respJSON)
  3628. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3629. utils.ErrorLog("解析失败:%v", err)
  3630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3631. return
  3632. }
  3633. infocode = resThree.Infcode
  3634. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3635. psn_info, _ := service.GetPsnByPatientId(id)
  3636. bas := strings.Split(psn_info.CardInfo, "|")
  3637. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3638. var api string
  3639. if miConfig.MdtrtareaAdmvs == "320921" {
  3640. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3641. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3642. "&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
  3643. } else {
  3644. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3645. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3646. "&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
  3647. }
  3648. resp, requestErr := http.Get(api)
  3649. if requestErr != nil {
  3650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3651. return
  3652. }
  3653. body, ioErr := ioutil.ReadAll(resp.Body)
  3654. if ioErr != nil {
  3655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3657. return
  3658. }
  3659. var respJSON map[string]interface{}
  3660. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3663. return
  3664. }
  3665. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3666. result, _ := json.Marshal(respJSON)
  3667. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3668. utils.ErrorLog("解析失败:%v", err)
  3669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3670. return
  3671. }
  3672. resThree.ErrMsg = resThree10265.ErrMsg
  3673. resThree.Output = resThree10265.Output
  3674. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3675. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3676. } else {
  3677. 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)
  3678. saveLog(result, requestLog, "2201", "挂号")
  3679. if miConfig.Code == "H15049901371" {
  3680. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3681. utils.ErrorLog("解析失败:%v", err)
  3682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3683. return
  3684. }
  3685. resThree.ErrMsg = resThree10265.ErrMsg
  3686. resThree.Output = resThree10265.Output
  3687. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3688. } else {
  3689. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3690. utils.ErrorLog("解析失败:%v", err)
  3691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3692. return
  3693. }
  3694. }
  3695. if miConfig.Code == "H15049901371" {
  3696. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3697. } else {
  3698. infocode = resThree.Infcode
  3699. }
  3700. }
  3701. if infocode != 0 {
  3702. adminUser := c.GetAdminUserInfo()
  3703. errlog := &models.HisOrderError{
  3704. UserOrgId: adminUser.CurrentOrgId,
  3705. Ctime: time.Now().Unix(),
  3706. Mtime: time.Now().Unix(),
  3707. ErrMsg: resThree.ErrMsg,
  3708. Status: 1,
  3709. PatientId: id,
  3710. RecordTime: recordDateTime,
  3711. Stage: 2,
  3712. }
  3713. service.CreateErrMsgLog(errlog)
  3714. c.ServeSuccessJSON(map[string]interface{}{
  3715. "failed_code": -10,
  3716. "msg": resThree.ErrMsg,
  3717. })
  3718. return
  3719. }
  3720. his.Number = resThree.Output.Data.MdtrtID
  3721. his.PsnNo = resThree.Output.Data.PsnNo
  3722. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3723. his.IdCardNo = patient.IdCardNo
  3724. his.PhoneNumber = patient.Phone
  3725. his.UserOrgId = adminInfo.CurrentOrgId
  3726. his.Insutype = insutype
  3727. his.Ctime = time.Now().Unix()
  3728. his.Mtime = time.Now().Unix()
  3729. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3730. his.Status = 1
  3731. service.UpdateHisPatientStatus(&his)
  3732. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3733. c.ServeSuccessJSON(map[string]interface{}{
  3734. "his_info": his,
  3735. })
  3736. } else {
  3737. adminUser := c.GetAdminUserInfo()
  3738. errlog := &models.HisOrderError{
  3739. UserOrgId: adminUser.CurrentOrgId,
  3740. Ctime: time.Now().Unix(),
  3741. Mtime: time.Now().Unix(),
  3742. ErrMsg: res.ErrMsg,
  3743. Status: 1,
  3744. PatientId: id,
  3745. RecordTime: recordDateTime,
  3746. Stage: 1,
  3747. }
  3748. service.CreateErrMsgLog(errlog)
  3749. c.ServeSuccessJSON(map[string]interface{}{
  3750. "failed_code": -10,
  3751. "msg": res.ErrMsg,
  3752. })
  3753. return
  3754. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3755. }
  3756. }
  3757. }
  3758. //上传明细----预结算----确认订单
  3759. func (c *HisApiController) GetUploadInfo() {
  3760. id, _ := c.GetInt64("id")
  3761. record_time := c.GetString("record_time")
  3762. his_patient_id, _ := c.GetInt64("his_patient_id")
  3763. order_id, _ := c.GetInt64("order_id")
  3764. pay_way, _ := c.GetInt64("pay_way")
  3765. pay_price, _ := c.GetFloat("pay_price")
  3766. pay_card_no := c.GetString("pay_card_no")
  3767. discount_price, _ := c.GetFloat("discount_price")
  3768. preferential_price, _ := c.GetFloat("preferential_price")
  3769. reality_price, _ := c.GetFloat("reality_price")
  3770. found_price, _ := c.GetFloat("found_price")
  3771. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3772. private_price, _ := c.GetFloat("private_price")
  3773. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3774. admin_user_id, _ := c.GetInt64("admin_user_id")
  3775. fapiao_code := c.GetString("fapiao_code")
  3776. fapiao_number := c.GetString("fapiao_number")
  3777. diagnosis_id := c.GetString("diagnosis")
  3778. sick_type, _ := c.GetInt64("sick_type")
  3779. reg_type, _ := c.GetInt64("p_type")
  3780. begin_time := c.GetString("begin_time")
  3781. id_str := c.GetString("ids")
  3782. ids_arr := strings.Split(id_str, ",")
  3783. timeLayout := "2006-01-02"
  3784. loc, _ := time.LoadLocation("Local")
  3785. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3786. if err != nil {
  3787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3788. return
  3789. }
  3790. recordDateTime := theTime.Unix()
  3791. adminUser := c.GetAdminUserInfo()
  3792. var tempOrder models.HisOrder
  3793. tempOrder, _ = service.GetHisOrderByID(order_id)
  3794. var prescriptions []*models.HisPrescription
  3795. var start_time int64
  3796. var end_time int64
  3797. //if adminUser.CurrentOrgId == 10106{
  3798. // if len(fapiao_code) == 0{
  3799. // fapiao_code = "144072080589"
  3800. // }
  3801. // if len(fapiao_number) == 0{
  3802. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3803. // if order.ID == 0{
  3804. // fapiao_number = "00001520"
  3805. // }else{
  3806. // //fapiao_code = "00001520"
  3807. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3808. // var zero string
  3809. // if fpNumber >= 1000{
  3810. // zero = "0000" + strconv.Itoa(fpNumber)
  3811. // }else if fpNumber >= 10000{
  3812. // zero = "000" + strconv.Itoa(fpNumber)
  3813. // } else if fpNumber >= 100000{
  3814. // zero = "00" + strconv.Itoa(fpNumber)
  3815. // } else if fpNumber >= 1000000{
  3816. // zero = "0" + strconv.Itoa(fpNumber)
  3817. // }else {
  3818. // zero = strconv.Itoa(fpNumber)
  3819. // }
  3820. // fapiao_number = zero
  3821. // }
  3822. // }
  3823. //}
  3824. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3825. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3826. var patientPrescription models.HisPrescriptionInfo
  3827. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3828. if patientPrescription.ID == 0 {
  3829. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3830. }
  3831. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3832. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3833. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3834. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3835. var config []*models.HisXtDiagnoseConfig
  3836. for _, item := range diagnosis_ids {
  3837. id, _ := strconv.ParseInt(item, 10, 64)
  3838. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3839. config = append(config, &diagnosisConfig)
  3840. }
  3841. sickConfig, _ := service.FindSickById(sick_type)
  3842. //if tempOrder.ID == 0 {
  3843. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3844. //}
  3845. if tempOrder.ID == 0 {
  3846. var result string
  3847. var requestLog string
  3848. var res2 ResultSix
  3849. var ressix10265 ResultSix10265
  3850. if miConfig.MdtrtareaAdmvs == "421300" {
  3851. data := make(map[string]interface{})
  3852. client := &http.Client{}
  3853. data["psn_no"] = his.PsnNo
  3854. data["mdtrt_id"] = his.Number
  3855. data["doctor"] = roles.UserName
  3856. data["department"] = department.Name
  3857. data["org_name"] = miConfig.OrgName
  3858. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3859. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3860. data["fixmedins_code"] = miConfig.Code
  3861. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3862. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3863. data["secret_key"] = miConfig.SecretKey
  3864. data["sick_code"] = sickConfig.CountryCode
  3865. data["sick_name"] = sickConfig.ClassName
  3866. data["dept"] = strconv.FormatInt(department.ID, 10)
  3867. data["config"] = config
  3868. data["begin_time"] = begin_time
  3869. bytesData, _ := json.Marshal(data)
  3870. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3871. resp, _ := client.Do(req)
  3872. defer resp.Body.Close()
  3873. body, ioErr := ioutil.ReadAll(resp.Body)
  3874. if ioErr != nil {
  3875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3877. return
  3878. }
  3879. var respJSON map[string]interface{}
  3880. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3883. return
  3884. }
  3885. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3886. userJSONBytes, _ := json.Marshal(respJSON)
  3887. fmt.Println("log")
  3888. fmt.Println(string(userJSONBytes))
  3889. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3890. utils.ErrorLog("解析失败:%v", err)
  3891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3892. return
  3893. }
  3894. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3895. //江苏地区国家医保医疗类别
  3896. //职工透析:医疗类别选特殊情况门诊9933
  3897. //居民血透门慢: 医疗类别选门诊慢病1402
  3898. //var med_type string
  3899. //if his.Insutype == "310" {
  3900. // if reg_type == 14 {
  3901. // med_type = "9933"
  3902. // } else if reg_type == 11 {
  3903. // med_type = "11"
  3904. //
  3905. // }
  3906. //} else if his.Insutype == "390" {
  3907. // if reg_type == 14 {
  3908. // med_type = "1402"
  3909. // } else if reg_type == 11 {
  3910. // med_type = "11"
  3911. // }
  3912. //}
  3913. data := make(map[string]interface{})
  3914. client := &http.Client{}
  3915. data["psn_no"] = his.PsnNo
  3916. data["mdtrt_id"] = his.Number
  3917. data["doctor"] = roles.UserName
  3918. data["department"] = department.Name
  3919. data["org_name"] = miConfig.OrgName
  3920. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3921. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3922. data["fixmedins_code"] = miConfig.Code
  3923. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3924. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3925. data["secret_key"] = miConfig.SecretKey
  3926. data["sick_code"] = sickConfig.CountryCode
  3927. data["sick_name"] = sickConfig.ClassName
  3928. data["url"] = miConfig.Url
  3929. data["ak"] = miConfig.AccessKey
  3930. data["begin_time"] = begin_time
  3931. data["cainfo"] = miConfig.Cainfo
  3932. data["dept"] = strconv.FormatInt(department.ID, 10)
  3933. data["config"] = config
  3934. bytesData, _ := json.Marshal(data)
  3935. var req *http.Request
  3936. if miConfig.MdtrtareaAdmvs == "320921" {
  3937. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3938. //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 +
  3939. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  3940. } else {
  3941. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3942. }
  3943. resp, _ := client.Do(req)
  3944. defer resp.Body.Close()
  3945. body, ioErr := ioutil.ReadAll(resp.Body)
  3946. if ioErr != nil {
  3947. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3949. return
  3950. }
  3951. var respJSON map[string]interface{}
  3952. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3953. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3955. return
  3956. }
  3957. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3958. userJSONBytes, _ := json.Marshal(respJSON)
  3959. fmt.Println("log")
  3960. fmt.Println(string(userJSONBytes))
  3961. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3962. utils.ErrorLog("解析失败:%v", err)
  3963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3964. return
  3965. }
  3966. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3967. res2.Output = ressix10265.Output
  3968. res2.ErrMsg = ressix10265.ErrMsg
  3969. res2.Cainfo = ressix10265.Cainfo
  3970. res2.WarnMsg = ressix10265.WarnMsg
  3971. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3972. res2.Infcode = infocode
  3973. } else {
  3974. if miConfig.MdtrtareaAdmvs == "440781" { //
  3975. 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)
  3976. } else {
  3977. if miConfig.Code == "H15049901371" {
  3978. //赤峰地区国家医保医疗类别
  3979. //职工透析:医疗类别选特殊情况门诊990502
  3980. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3981. var med_type string
  3982. if his.Insutype == "390" {
  3983. if reg_type == 14 {
  3984. med_type = "9933"
  3985. } else if reg_type == 11 {
  3986. med_type = "11"
  3987. }
  3988. } else if his.Insutype == "310" {
  3989. if reg_type == 14 {
  3990. med_type = "990502"
  3991. } else if reg_type == 11 {
  3992. med_type = "11"
  3993. }
  3994. }
  3995. 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)
  3996. } else {
  3997. 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)
  3998. }
  3999. }
  4000. saveLog(result, requestLog, "2203", "上传就诊信息")
  4001. var respJSON2 map[string]interface{}
  4002. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4005. return
  4006. }
  4007. userJSONBytes2, _ := json.Marshal(respJSON2)
  4008. if miConfig.Code == "H15049901371" {
  4009. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4010. utils.ErrorLog("解析失败:%v", err)
  4011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4012. return
  4013. }
  4014. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4015. res2.Output = ressix10265.Output
  4016. res2.ErrMsg = ressix10265.ErrMsg
  4017. res2.Cainfo = ressix10265.Cainfo
  4018. res2.WarnMsg = ressix10265.WarnMsg
  4019. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4020. res2.Infcode = infocode
  4021. } else {
  4022. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4023. utils.ErrorLog("解析失败:%v", err)
  4024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4025. return
  4026. }
  4027. }
  4028. }
  4029. if res2.Infcode != 0 {
  4030. adminUser := c.GetAdminUserInfo()
  4031. errlog := &models.HisOrderError{
  4032. UserOrgId: adminUser.CurrentOrgId,
  4033. Ctime: time.Now().Unix(),
  4034. Mtime: time.Now().Unix(),
  4035. ErrMsg: res2.ErrMsg,
  4036. Status: 1,
  4037. PatientId: id,
  4038. RecordTime: recordDateTime,
  4039. Stage: 3,
  4040. }
  4041. service.CreateErrMsgLog(errlog)
  4042. c.ServeSuccessJSON(map[string]interface{}{
  4043. "failed_code": -10,
  4044. "msg": res2.ErrMsg,
  4045. })
  4046. return
  4047. } else {
  4048. his.Diagnosis = diagnosis_id
  4049. his.SickType = sickConfig.ID
  4050. var p_type int64
  4051. if reg_type == 1111 || reg_type == 1112 {
  4052. p_type = 11
  4053. }
  4054. his.PType = fmt.Sprintf("%d", p_type)
  4055. service.UpdateHisPatientThree(&his)
  4056. data := make(map[string]interface{})
  4057. if settle_accounts_type == 1 { //日结
  4058. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4059. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4060. } else {
  4061. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4062. }
  4063. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4064. data["pre"] = prescriptions
  4065. } else { //月结
  4066. start_time_str := c.GetString("start_time")
  4067. end_time_str := c.GetString("end_time")
  4068. timeLayout := "2006-01-02"
  4069. loc, _ := time.LoadLocation("Local")
  4070. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4071. if err != nil {
  4072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4073. return
  4074. }
  4075. recordStartTime := theStartTime.Unix()
  4076. start_time = recordStartTime
  4077. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4078. if err != nil {
  4079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4080. return
  4081. }
  4082. recordEndTime := theEndTime.Unix()
  4083. end_time = recordEndTime
  4084. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4085. data["pre"] = prescriptions
  4086. }
  4087. timestamp := time.Now().Unix()
  4088. tempTime := time.Unix(timestamp, 0)
  4089. timeFormat := tempTime.Format("20060102150405")
  4090. chrgBchno := rand.Intn(100000) + 10000
  4091. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4092. strconv.FormatInt(his.PatientId, 10)
  4093. client := &http.Client{}
  4094. data["psn_no"] = his.PsnNo
  4095. data["mdtrt_id"] = his.Number
  4096. data["chrg_bchno"] = chrg_bchno
  4097. data["org_name"] = miConfig.OrgName
  4098. data["doctor"] = roles.UserName
  4099. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4100. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4101. data["fixmedins_code"] = miConfig.Code
  4102. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4103. // data["dept_code"] = "15"
  4104. //} else {
  4105. data["dept_code"] = department.Number
  4106. //}
  4107. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4108. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4109. data["secret_key"] = miConfig.SecretKey
  4110. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4111. data["url"] = miConfig.Url
  4112. data["ak"] = miConfig.AccessKey
  4113. data["new_doctor_name"] = patientPrescription.Doctor
  4114. data["diag_code"] = sickConfig.CountryCode
  4115. data["cainfo"] = miConfig.Cainfo
  4116. var ids []int64
  4117. for _, item := range prescriptions {
  4118. ids = append(ids, item.ID)
  4119. }
  4120. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4121. if config.IsOpen == 1 { //对接了医保,走医保流程
  4122. var res ResultFour
  4123. var resFour10265 ResultFour10265
  4124. if miConfig.MdtrtareaAdmvs == "421300" {
  4125. bytesData, _ := json.Marshal(data)
  4126. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4127. resp, _ := client.Do(req)
  4128. defer resp.Body.Close()
  4129. body, ioErr := ioutil.ReadAll(resp.Body)
  4130. if ioErr != nil {
  4131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4133. return
  4134. }
  4135. var respJSON map[string]interface{}
  4136. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4139. return
  4140. }
  4141. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4142. userJSONBytes, _ := json.Marshal(respJSON)
  4143. fmt.Println("log")
  4144. fmt.Println(string(userJSONBytes))
  4145. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4146. utils.ErrorLog("解析失败:%v", err)
  4147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4148. return
  4149. }
  4150. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4151. bytesData, _ := json.Marshal(data)
  4152. var req *http.Request
  4153. if miConfig.MdtrtareaAdmvs == "320921" {
  4154. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4155. } else {
  4156. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4157. }
  4158. resp, _ := client.Do(req)
  4159. defer resp.Body.Close()
  4160. body, ioErr := ioutil.ReadAll(resp.Body)
  4161. if ioErr != nil {
  4162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4164. return
  4165. }
  4166. var respJSON map[string]interface{}
  4167. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4170. return
  4171. }
  4172. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4173. userJSONBytes, _ := json.Marshal(respJSON)
  4174. fmt.Println("log")
  4175. fmt.Println(string(userJSONBytes))
  4176. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4177. utils.ErrorLog("解析失败:%v", err)
  4178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4179. return
  4180. }
  4181. res.InfRefmsgid = resFour10265.InfRefmsgid
  4182. res.Output = resFour10265.Output
  4183. res.ErrMsg = resFour10265.ErrMsg
  4184. res.Cainfo = resFour10265.Cainfo
  4185. res.WarnMsg = resFour10265.WarnMsg
  4186. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4187. res.Infcode = infocode
  4188. } else {
  4189. if miConfig.Code == "H15049901371" {
  4190. 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)
  4191. var dat map[string]interface{}
  4192. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4193. fmt.Println(dat)
  4194. } else {
  4195. fmt.Println(err)
  4196. }
  4197. saveLog(result, request_log, "2204", "上传费用明细")
  4198. userJSONBytes, _ := json.Marshal(dat)
  4199. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4200. utils.ErrorLog("解析失败:%v", err)
  4201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4202. return
  4203. }
  4204. res.InfRefmsgid = resFour10265.InfRefmsgid
  4205. res.Output = resFour10265.Output
  4206. res.ErrMsg = resFour10265.ErrMsg
  4207. res.Cainfo = resFour10265.Cainfo
  4208. res.WarnMsg = resFour10265.WarnMsg
  4209. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4210. res.Infcode = infocode
  4211. } else {
  4212. 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)
  4213. var dat map[string]interface{}
  4214. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4215. fmt.Println(dat)
  4216. } else {
  4217. fmt.Println(err)
  4218. }
  4219. saveLog(result, request_log, "2204", "上传费用明细")
  4220. userJSONBytes, _ := json.Marshal(dat)
  4221. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4222. utils.ErrorLog("解析失败:%v", err)
  4223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4224. return
  4225. }
  4226. }
  4227. }
  4228. if res.Infcode == 0 {
  4229. order := &models.HisOrder{
  4230. UserOrgId: adminUser.CurrentOrgId,
  4231. HisPatientId: his.ID,
  4232. PatientId: his.PatientId,
  4233. SettleAccountsDate: recordDateTime,
  4234. MdtrtId: his.Number,
  4235. PsnNo: his.PsnNo,
  4236. MedType: strconv.FormatInt(reg_type, 10),
  4237. Ctime: time.Now().Unix(),
  4238. Mtime: time.Now().Unix(),
  4239. Status: 1,
  4240. Number: chrg_bchno,
  4241. Infcode: res.Infcode,
  4242. WarnMsg: res.WarnMsg,
  4243. Cainfo: res.Cainfo,
  4244. ErrMsg: res.ErrMsg,
  4245. RespondTime: res.RefmsgTime,
  4246. InfRefmsgid: res.InfRefmsgid,
  4247. OrderStatus: 1,
  4248. PayWay: pay_way,
  4249. PayPrice: pay_price,
  4250. PayCardNo: pay_card_no,
  4251. DiscountPrice: discount_price,
  4252. PreferentialPrice: preferential_price,
  4253. RealityPrice: reality_price,
  4254. FoundPrice: found_price,
  4255. MedicalInsurancePrice: medical_insurance_price,
  4256. PrivatePrice: private_price,
  4257. IsMedicineInsurance: 1,
  4258. SettleType: settle_accounts_type,
  4259. SettleStartTime: start_time,
  4260. SettleEndTime: end_time,
  4261. Creator: roles.AdminUserId,
  4262. Modify: roles.AdminUserId,
  4263. FaPiaoNumber: fapiao_number,
  4264. FaPiaoCode: fapiao_code,
  4265. PType: 2,
  4266. Diagnosis: diagnosis_id,
  4267. }
  4268. err = service.CreateOrder(order)
  4269. if err != nil {
  4270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4271. return
  4272. }
  4273. for _, item := range res.Output.Result {
  4274. temp := strings.Split(item.FeedetlSn, "-")
  4275. var advice_id int64 = 0
  4276. var project_id int64 = 0
  4277. var types int64 = 0
  4278. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4279. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4280. if temp[1] == "1" {
  4281. advice_id = id
  4282. project_id = 0
  4283. } else if temp[1] == "2" {
  4284. advice_id = 0
  4285. project_id = id
  4286. }
  4287. info := &models.HisOrderInfo{
  4288. OrderNumber: order.Number,
  4289. FeedetlSn: item.FeedetlSn,
  4290. UploadDate: time.Now().Unix(),
  4291. AdviceId: advice_id,
  4292. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4293. Cnt: item.Cnt,
  4294. Pric: float64(item.Pric),
  4295. PatientId: his.PatientId,
  4296. PricUplmtAmt: item.PricUplmtAmt,
  4297. SelfpayProp: item.SelfpayProp,
  4298. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4299. OverlmtAmt: item.OverlmtAmt,
  4300. PreselfpayAmt: item.PreselfpayAmt,
  4301. BasMednFlag: item.BasMednFlag,
  4302. MedChrgitmType: item.MedChrgitmType,
  4303. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4304. Status: 1,
  4305. Memo: item.Memo,
  4306. Mtime: time.Now().Unix(),
  4307. InscpScpAmt: item.InscpScpAmt,
  4308. DrtReimFlag: item.DrtReimFlag,
  4309. Ctime: time.Now().Unix(),
  4310. ListSpItemFlag: item.ListSpItemFlag,
  4311. ChldMedcFlag: item.ChldMedcFlag,
  4312. LmtUsedFlag: item.LmtUsedFlag,
  4313. ChrgitmLv: item.ChrgitmLv,
  4314. UserOrgId: adminUser.CurrentOrgId,
  4315. HisPatientId: his.ID,
  4316. OrderId: order.ID,
  4317. ProjectId: project_id,
  4318. Type: types,
  4319. }
  4320. service.CreateOrderInfo(info)
  4321. }
  4322. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4323. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4324. var total float64
  4325. for _, item := range prescriptions {
  4326. if item.Type == 1 { //药品
  4327. for _, subItem := range item.HisDoctorAdviceInfo {
  4328. total = total + (subItem.Price * subItem.PrescribingNumber)
  4329. }
  4330. }
  4331. if item.Type == 2 { //项目
  4332. for _, subItem := range item.HisPrescriptionProject {
  4333. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4334. total = total + (subItem.Price * cnt)
  4335. }
  4336. }
  4337. }
  4338. for _, item := range prescriptions {
  4339. for _, subItem := range item.HisAdditionalCharge {
  4340. total = total + (subItem.Price * float64(subItem.Count))
  4341. }
  4342. }
  4343. var allTotal string
  4344. if adminUser.CurrentOrgId == 9919 {
  4345. allTotal = fmt.Sprintf("%.4f", total)
  4346. } else {
  4347. allTotal = fmt.Sprintf("%.4f", total)
  4348. }
  4349. if res.Infcode == 0 {
  4350. var rf []*ResultFive
  4351. json.Unmarshal([]byte(his.Iinfo), &rf)
  4352. chrg_bchno := chrg_bchno
  4353. cert_no := his.Certno
  4354. var insutypes []string
  4355. var insutype string
  4356. var is390 int = 0
  4357. var is310 int = 0
  4358. for _, item := range rf {
  4359. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4360. insutypes = append(insutypes, item.Insutype)
  4361. }
  4362. }
  4363. if len(insutypes) == 1 {
  4364. insutype = insutypes[0]
  4365. } else {
  4366. for _, i := range insutypes {
  4367. if i == "390" {
  4368. is390 = 1
  4369. }
  4370. if i == "310" {
  4371. is310 = 1
  4372. }
  4373. }
  4374. }
  4375. if is390 == 1 {
  4376. insutype = "390"
  4377. }
  4378. if is310 == 1 {
  4379. insutype = "310"
  4380. }
  4381. if len(insutypes) == 0 {
  4382. insutype = "310"
  4383. }
  4384. if len(insutypes) == 2 {
  4385. insutype = strconv.FormatInt(his.SocialType, 10)
  4386. }
  4387. insutype = strconv.FormatInt(his.SocialType, 10)
  4388. //insutype = "390"
  4389. if his.IdCardType == 1 {
  4390. // cert_no = his.MedicalInsuranceNumber
  4391. cert_no = his.Certno
  4392. } else {
  4393. cert_no = his.Certno
  4394. }
  4395. var res ResultSeven
  4396. var resSeven10265 ResultSeven10265
  4397. var src_resquest string
  4398. var result2 string
  4399. var acct_used_flag string
  4400. fmt.Println("pay_way")
  4401. fmt.Println(pay_way)
  4402. fmt.Println("pay_way")
  4403. if pay_way == 4 {
  4404. acct_used_flag = "1"
  4405. } else {
  4406. acct_used_flag = "0"
  4407. }
  4408. if miConfig.MdtrtareaAdmvs == "421300" {
  4409. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4410. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4411. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4412. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4413. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4414. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4415. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4416. resp, requestErr := http.Get(api)
  4417. if requestErr != nil {
  4418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4419. return
  4420. }
  4421. body, ioErr := ioutil.ReadAll(resp.Body)
  4422. if ioErr != nil {
  4423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4425. return
  4426. }
  4427. var respJSON map[string]interface{}
  4428. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4431. return
  4432. }
  4433. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4434. result, _ := json.Marshal(respJSON)
  4435. if miConfig.Code == "H15049901371" {
  4436. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4437. utils.ErrorLog("解析失败:%v", err)
  4438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4439. return
  4440. }
  4441. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4442. res.Output = resSeven10265.Output
  4443. res.ErrMsg = resSeven10265.ErrMsg
  4444. res.Cainfo = resSeven10265.Cainfo
  4445. res.WarnMsg = resSeven10265.WarnMsg
  4446. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4447. res.Infcode = infocode
  4448. } else {
  4449. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4450. utils.ErrorLog("解析失败:%v", err)
  4451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4452. return
  4453. }
  4454. }
  4455. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4456. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4457. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4458. //psn_info, _ := service.GetPsnByPatientId(id)
  4459. bas := strings.Split(psn_info.CardInfo, "|")
  4460. if his.IdCardType == 1 {
  4461. cert_no = bas[2]
  4462. } else {
  4463. cert_no = bas[1]
  4464. }
  4465. //江苏地区国家医保医疗类别
  4466. //职工透析:医疗类别选特殊情况门诊9933
  4467. //居民血透门慢: 医疗类别选门诊慢病1402
  4468. //var med_type string
  4469. //if his.Insutype == "310" {
  4470. // if reg_type == 14 {
  4471. // med_type = "9933"
  4472. // } else if reg_type == 11 {
  4473. // med_type = "11"
  4474. //
  4475. // }
  4476. //} else if his.Insutype == "390" {
  4477. // if reg_type == 14 {
  4478. // med_type = "1402"
  4479. // } else if reg_type == 11 {
  4480. // med_type = "11"
  4481. // }
  4482. //}
  4483. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4484. var api string
  4485. if miConfig.MdtrtareaAdmvs == "320921" {
  4486. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4487. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4488. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4489. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4490. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4491. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4492. "&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
  4493. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4494. } else {
  4495. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4496. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4497. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4498. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4499. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4500. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4501. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4502. "&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
  4503. }
  4504. resp, requestErr := http.Get(api)
  4505. if requestErr != nil {
  4506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4507. return
  4508. }
  4509. body, ioErr := ioutil.ReadAll(resp.Body)
  4510. if ioErr != nil {
  4511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4513. return
  4514. }
  4515. var respJSON map[string]interface{}
  4516. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4519. return
  4520. }
  4521. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4522. result, _ := json.Marshal(respJSON)
  4523. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4524. utils.ErrorLog("解析失败:%v", err)
  4525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4526. return
  4527. }
  4528. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4529. res.Output = resSeven10265.Output
  4530. res.ErrMsg = resSeven10265.ErrMsg
  4531. res.Cainfo = resSeven10265.Cainfo
  4532. res.WarnMsg = resSeven10265.WarnMsg
  4533. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4534. res.Infcode = infocode
  4535. } else {
  4536. if miConfig.Code == "H15049901371" {
  4537. //赤峰地区国家医保医疗类别
  4538. //职工透析:医疗类别选特殊情况门诊990502
  4539. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4540. var med_type string
  4541. if his.Insutype == "390" {
  4542. if reg_type == 14 {
  4543. med_type = "9933"
  4544. } else if reg_type == 11 {
  4545. med_type = "11"
  4546. }
  4547. } else if his.Insutype == "310" {
  4548. if reg_type == 14 {
  4549. med_type = "990502"
  4550. } else if reg_type == 11 {
  4551. med_type = "11"
  4552. }
  4553. }
  4554. 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)
  4555. } else {
  4556. 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)
  4557. }
  4558. //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)
  4559. var dat map[string]interface{}
  4560. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4561. fmt.Println(dat)
  4562. } else {
  4563. fmt.Println(err)
  4564. }
  4565. saveLog(result2, src_resquest, "2207", "结算")
  4566. userJSONBytes, _ := json.Marshal(dat)
  4567. if miConfig.Code == "H15049901371" {
  4568. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4569. utils.ErrorLog("解析失败:%v", err)
  4570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4571. return
  4572. }
  4573. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4574. res.Output = resSeven10265.Output
  4575. res.ErrMsg = resSeven10265.ErrMsg
  4576. res.Cainfo = resSeven10265.Cainfo
  4577. res.WarnMsg = resSeven10265.WarnMsg
  4578. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4579. res.Infcode = infocode
  4580. } else {
  4581. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4582. utils.ErrorLog("解析失败:%v", err)
  4583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4584. return
  4585. }
  4586. }
  4587. }
  4588. if res.Infcode != 0 {
  4589. errlog := &models.HisOrderError{
  4590. UserOrgId: adminUser.CurrentOrgId,
  4591. Ctime: time.Now().Unix(),
  4592. Mtime: time.Now().Unix(),
  4593. Number: chrg_bchno,
  4594. ErrMsg: res.ErrMsg,
  4595. Status: 1,
  4596. PatientId: id,
  4597. RecordTime: recordDateTime,
  4598. Stage: 6,
  4599. }
  4600. service.CreateErrMsgLog(errlog)
  4601. c.ServeSuccessJSON(map[string]interface{}{
  4602. "failed_code": -10,
  4603. "msg": res.ErrMsg,
  4604. })
  4605. return
  4606. } else {
  4607. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4608. order.OrderStatus = 2
  4609. order.Status = 1
  4610. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4611. order.SetlId = res.Output.Setlinfo.SetlID
  4612. order.PsnNo = res.Output.Setlinfo.PsnNo
  4613. order.PsnName = res.Output.Setlinfo.PsnName
  4614. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4615. order.Certno = res.Output.Setlinfo.Certno
  4616. order.Gend = res.Output.Setlinfo.Gend
  4617. order.Naty = res.Output.Setlinfo.Naty
  4618. order.Age = res.Output.Setlinfo.Age
  4619. order.Insutype = res.Output.Setlinfo.Insutype
  4620. order.PsnType = res.Output.Setlinfo.PsnType
  4621. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4622. order.SetlTime = res.Output.Setlinfo.SetlTime
  4623. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4624. if res.Output.Setlinfo.MedType == "140101" {
  4625. order.MedType = "14"
  4626. } else {
  4627. order.MedType = res.Output.Setlinfo.MedType
  4628. }
  4629. if reg_type == 1112 {
  4630. order.MedType = "1112"
  4631. }
  4632. if reg_type == 1111 {
  4633. order.MedType = "1111"
  4634. }
  4635. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4636. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4637. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4638. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4639. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4640. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4641. order.HifpPay = res.Output.Setlinfo.HifpPay
  4642. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4643. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4644. order.HifesPay = res.Output.Setlinfo.HifesPay
  4645. order.HifobPay = res.Output.Setlinfo.HifobPay
  4646. order.MafPay = res.Output.Setlinfo.MafPay
  4647. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4648. order.OthPay = res.Output.Setlinfo.OthPay
  4649. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4650. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4651. order.AcctPay = res.Output.Setlinfo.AcctPay
  4652. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4653. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4654. order.Balc = res.Output.Setlinfo.Balc
  4655. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4656. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4657. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4658. order.ClrType = res.Output.Setlinfo.ClrType
  4659. order.ClrWay = res.Output.Setlinfo.ClrWay
  4660. order.Creator = order.Creator
  4661. order.Modify = roles.AdminUserId
  4662. order.RequestLog = src_resquest
  4663. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4664. detailStr := string(setlDetail)
  4665. order.SetlDetail = detailStr
  4666. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4667. err = service.UpDateOrder(order)
  4668. if err == nil {
  4669. c.ServeSuccessJSON(map[string]interface{}{
  4670. "msg": "结算成功",
  4671. })
  4672. } else {
  4673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4674. return
  4675. }
  4676. }
  4677. } else {
  4678. adminUser := c.GetAdminUserInfo()
  4679. errlog := &models.HisOrderError{
  4680. UserOrgId: adminUser.CurrentOrgId,
  4681. Ctime: time.Now().Unix(),
  4682. Mtime: time.Now().Unix(),
  4683. ErrMsg: res.ErrMsg,
  4684. Status: 1,
  4685. PatientId: id,
  4686. RecordTime: recordDateTime,
  4687. Stage: 4,
  4688. }
  4689. service.CreateErrMsgLog(errlog)
  4690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4691. return
  4692. }
  4693. } else {
  4694. adminUser := c.GetAdminUserInfo()
  4695. errlog := &models.HisOrderError{
  4696. UserOrgId: adminUser.CurrentOrgId,
  4697. Ctime: time.Now().Unix(),
  4698. Mtime: time.Now().Unix(),
  4699. ErrMsg: res.ErrMsg,
  4700. Status: 1,
  4701. PatientId: id,
  4702. RecordTime: recordDateTime,
  4703. Stage: 4,
  4704. }
  4705. service.CreateErrMsgLog(errlog)
  4706. c.ServeSuccessJSON(map[string]interface{}{
  4707. "failed_code": -10,
  4708. "msg": res.ErrMsg,
  4709. })
  4710. return
  4711. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4712. //return
  4713. }
  4714. }
  4715. }
  4716. } else if tempOrder.ID > 0 {
  4717. if tempOrder.IsPre == 1 {
  4718. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4719. var rf []*ResultFive
  4720. json.Unmarshal([]byte(his.Iinfo), &rf)
  4721. chrg_bchno := tempOrder.Number
  4722. cert_no := his.Certno
  4723. var insutypes []string
  4724. var insutype string
  4725. var is390 int = 0
  4726. var is310 int = 0
  4727. for _, item := range rf {
  4728. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4729. insutypes = append(insutypes, item.Insutype)
  4730. }
  4731. }
  4732. if len(insutypes) == 1 {
  4733. insutype = insutypes[0]
  4734. } else {
  4735. for _, i := range insutypes {
  4736. if i == "390" {
  4737. is390 = 1
  4738. }
  4739. if i == "310" {
  4740. is310 = 1
  4741. }
  4742. }
  4743. }
  4744. if is390 == 1 {
  4745. insutype = "390"
  4746. }
  4747. if is310 == 1 {
  4748. insutype = "310"
  4749. }
  4750. if len(insutypes) == 0 {
  4751. insutype = "310"
  4752. }
  4753. if len(insutypes) == 2 {
  4754. insutype = strconv.FormatInt(his.SocialType, 64)
  4755. }
  4756. //insutype = "390"
  4757. if his.IdCardType == 1 {
  4758. // cert_no = his.MedicalInsuranceNumber
  4759. cert_no = his.Certno
  4760. } else {
  4761. cert_no = his.Certno
  4762. }
  4763. var res ResultSeven
  4764. var resSeven10265 ResultSeven10265
  4765. var src_resquest string
  4766. var result2 string
  4767. var acct_used_flag string
  4768. fmt.Println("pay_way")
  4769. fmt.Println(pay_way)
  4770. fmt.Println("pay_way")
  4771. if pay_way == 4 {
  4772. acct_used_flag = "1"
  4773. } else {
  4774. acct_used_flag = "0"
  4775. }
  4776. if miConfig.MdtrtareaAdmvs == "421300" {
  4777. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4778. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4779. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4780. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4781. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4782. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4783. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4784. resp, requestErr := http.Get(api)
  4785. if requestErr != nil {
  4786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4787. return
  4788. }
  4789. body, ioErr := ioutil.ReadAll(resp.Body)
  4790. if ioErr != nil {
  4791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4793. return
  4794. }
  4795. var respJSON map[string]interface{}
  4796. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4799. return
  4800. }
  4801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4802. result, _ := json.Marshal(respJSON)
  4803. fmt.Println("log")
  4804. fmt.Println(string(result))
  4805. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4806. utils.ErrorLog("解析失败:%v", err)
  4807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4808. return
  4809. }
  4810. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4811. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4812. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4813. //psn_info, _ := service.GetPsnByPatientId(id)
  4814. bas := strings.Split(psn_info.CardInfo, "|")
  4815. if his.IdCardType == 1 {
  4816. cert_no = bas[2]
  4817. } else {
  4818. cert_no = bas[1]
  4819. }
  4820. //江苏地区国家医保医疗类别
  4821. //职工透析:医疗类别选特殊情况门诊9933
  4822. //居民血透门慢: 医疗类别选门诊慢病1402
  4823. //var med_type string
  4824. //if his.Insutype == "310" {
  4825. // if reg_type == 14 {
  4826. // med_type = "9933"
  4827. // } else if reg_type == 11 {
  4828. // med_type = "11"
  4829. //
  4830. // }
  4831. //} else if his.Insutype == "390" {
  4832. // if reg_type == 14 {
  4833. // med_type = "1402"
  4834. // } else if reg_type == 11 {
  4835. // med_type = "11"
  4836. // }
  4837. //}
  4838. var api string
  4839. if miConfig.MdtrtareaAdmvs == "320921" {
  4840. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4841. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4842. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4843. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4844. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4845. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4846. "&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
  4847. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4848. } else {
  4849. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4850. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4851. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4852. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4853. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4854. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4855. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4856. "&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
  4857. }
  4858. resp, requestErr := http.Get(api)
  4859. if requestErr != nil {
  4860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4861. return
  4862. }
  4863. body, ioErr := ioutil.ReadAll(resp.Body)
  4864. if ioErr != nil {
  4865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4867. return
  4868. }
  4869. var respJSON map[string]interface{}
  4870. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4873. return
  4874. }
  4875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4876. result, _ := json.Marshal(respJSON)
  4877. fmt.Println("log")
  4878. fmt.Println(string(result))
  4879. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4880. utils.ErrorLog("解析失败:%v", err)
  4881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4882. return
  4883. }
  4884. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4885. res.Output = resSeven10265.Output
  4886. res.ErrMsg = resSeven10265.ErrMsg
  4887. res.Cainfo = resSeven10265.Cainfo
  4888. res.WarnMsg = resSeven10265.WarnMsg
  4889. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4890. res.Infcode = infocode
  4891. } else {
  4892. var src_resquest string
  4893. if miConfig.Code == "H15049901371" {
  4894. //赤峰地区国家医保医疗类别
  4895. //职工透析:医疗类别选特殊情况门诊990502
  4896. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4897. var med_type string
  4898. if his.Insutype == "390" {
  4899. if reg_type == 14 {
  4900. med_type = "9933"
  4901. } else if reg_type == 11 {
  4902. med_type = "11"
  4903. }
  4904. } else if his.Insutype == "310" {
  4905. if reg_type == 14 {
  4906. med_type = "990502"
  4907. } else if reg_type == 11 {
  4908. med_type = "11"
  4909. }
  4910. }
  4911. 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)
  4912. } else {
  4913. 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)
  4914. }
  4915. var dat map[string]interface{}
  4916. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4917. fmt.Println(dat)
  4918. } else {
  4919. fmt.Println(err)
  4920. }
  4921. saveLog(result2, src_resquest, "2207", "结算")
  4922. userJSONBytes, _ := json.Marshal(dat)
  4923. if miConfig.Code == "H15049901371" {
  4924. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4925. utils.ErrorLog("解析失败:%v", err)
  4926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4927. return
  4928. }
  4929. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4930. res.Output = resSeven10265.Output
  4931. res.ErrMsg = resSeven10265.ErrMsg
  4932. res.Cainfo = resSeven10265.Cainfo
  4933. res.WarnMsg = resSeven10265.WarnMsg
  4934. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4935. res.Infcode = infocode
  4936. } else {
  4937. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4938. utils.ErrorLog("解析失败:%v", err)
  4939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4940. return
  4941. }
  4942. }
  4943. }
  4944. if res.Infcode != 0 {
  4945. errlog := &models.HisOrderError{
  4946. UserOrgId: adminUser.CurrentOrgId,
  4947. Ctime: time.Now().Unix(),
  4948. Mtime: time.Now().Unix(),
  4949. Number: chrg_bchno,
  4950. ErrMsg: res.ErrMsg,
  4951. Status: 1,
  4952. PatientId: id,
  4953. RecordTime: recordDateTime,
  4954. Stage: 6,
  4955. }
  4956. service.CreateErrMsgLog(errlog)
  4957. c.ServeSuccessJSON(map[string]interface{}{
  4958. "failed_code": -10,
  4959. "msg": res.ErrMsg,
  4960. })
  4961. return
  4962. } else {
  4963. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4964. order.OrderStatus = 2
  4965. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4966. order.SetlId = res.Output.Setlinfo.SetlID
  4967. order.PsnNo = res.Output.Setlinfo.PsnNo
  4968. order.PsnName = res.Output.Setlinfo.PsnName
  4969. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4970. order.Certno = res.Output.Setlinfo.Certno
  4971. order.Gend = res.Output.Setlinfo.Gend
  4972. order.Naty = res.Output.Setlinfo.Naty
  4973. order.Age = res.Output.Setlinfo.Age
  4974. order.Insutype = res.Output.Setlinfo.Insutype
  4975. order.PsnType = res.Output.Setlinfo.PsnType
  4976. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4977. order.SetlTime = res.Output.Setlinfo.SetlTime
  4978. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4979. //order.MedType = res.Output.Setlinfo.MedType
  4980. if reg_type == 1112 {
  4981. order.MedType = "1112"
  4982. }
  4983. if reg_type == 1111 {
  4984. order.MedType = "1111"
  4985. }
  4986. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4987. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4988. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4989. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4990. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4991. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4992. order.HifpPay = res.Output.Setlinfo.HifpPay
  4993. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4994. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4995. order.HifesPay = res.Output.Setlinfo.HifesPay
  4996. order.HifobPay = res.Output.Setlinfo.HifobPay
  4997. order.MafPay = res.Output.Setlinfo.MafPay
  4998. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4999. order.OthPay = res.Output.Setlinfo.OthPay
  5000. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5001. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5002. order.AcctPay = res.Output.Setlinfo.AcctPay
  5003. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5004. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5005. order.Balc = res.Output.Setlinfo.Balc
  5006. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5007. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5008. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5009. order.ClrWay = res.Output.Setlinfo.ClrWay
  5010. order.Creator = order.Creator
  5011. order.Modify = roles.AdminUserId
  5012. order.RequestLog = src_resquest
  5013. order.Diagnosis = diagnosis_id
  5014. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5015. detailStr := string(setlDetail)
  5016. order.SetlDetail = detailStr
  5017. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5018. err = service.UpDateOrder(order)
  5019. if err == nil {
  5020. c.ServeSuccessJSON(map[string]interface{}{
  5021. "msg": "结算成功",
  5022. })
  5023. } else {
  5024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5025. return
  5026. }
  5027. }
  5028. }
  5029. }
  5030. }
  5031. //func (c *HisApiController) GetPreUploadInfo() {
  5032. // id, _ := c.GetInt64("id")
  5033. // record_time := c.GetString("record_time")
  5034. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5035. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5036. //
  5037. // timeLayout := "2006-01-02"
  5038. // loc, _ := time.LoadLocation("Local")
  5039. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5040. // if err != nil {
  5041. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5042. // return
  5043. // }
  5044. // recordDateTime := theTime.Unix()
  5045. // adminUser := c.GetAdminUserInfo()
  5046. //
  5047. // var prescriptions []*models.HisPrescription
  5048. //
  5049. // var start_time int64
  5050. // var end_time int64
  5051. //
  5052. // data := make(map[string]interface{})
  5053. // if settle_accounts_type == 1 { //日结
  5054. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5055. // data["pre"] = prescriptions
  5056. //
  5057. // } else { //月结
  5058. // start_time_str := c.GetString("start_time")
  5059. // end_time_str := c.GetString("end_time")
  5060. // timeLayout := "2006-01-02"
  5061. // loc, _ := time.LoadLocation("Local")
  5062. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5063. // if err != nil {
  5064. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5065. // return
  5066. // }
  5067. // recordStartTime := theStartTime.Unix()
  5068. // start_time = recordStartTime
  5069. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5070. // if err != nil {
  5071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5072. // return
  5073. // }
  5074. // recordEndTime := theEndTime.Unix()
  5075. // end_time = recordEndTime
  5076. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5077. // data["pre"] = prescriptions
  5078. //
  5079. // }
  5080. //
  5081. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5082. //
  5083. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5084. // timestamp := time.Now().Unix()
  5085. // tempTime := time.Unix(timestamp, 0)
  5086. // timeFormat := tempTime.Format("20060102150405")
  5087. // chrgBchno := rand.Intn(100000) + 10000
  5088. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5089. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5090. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5091. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5092. // strconv.FormatInt(his.PatientId, 10)
  5093. // client := &http.Client{}
  5094. // data["psn_no"] = his.PsnNo
  5095. // data["mdtrt_id"] = his.Number
  5096. // data["chrg_bchno"] = chrg_bchno
  5097. // data["org_name"] = miConfig.OrgName
  5098. // data["doctor"] = roles.UserName
  5099. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5100. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5101. // data["fixmedins_code"] = miConfig.Code
  5102. // data["dept_code"] = department.Number
  5103. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5104. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5105. // data["secret_key"] = miConfig.SecretKey
  5106. // var ids []int64
  5107. //
  5108. // for _, item := range prescriptions {
  5109. // ids = append(ids, item.ID)
  5110. // }
  5111. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5112. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5113. // bytesData, _ := json.Marshal(data)
  5114. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5115. // resp, _ := client.Do(req)
  5116. // defer resp.Body.Close()
  5117. // body, ioErr := ioutil.ReadAll(resp.Body)
  5118. // if ioErr != nil {
  5119. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5121. // return
  5122. // }
  5123. // var respJSON map[string]interface{}
  5124. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5125. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5127. // return
  5128. // }
  5129. //
  5130. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5131. // userJSONBytes, _ := json.Marshal(respJSON)
  5132. // var res ResultFour
  5133. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5134. // utils.ErrorLog("解析失败:%v", err)
  5135. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5136. // return
  5137. // }
  5138. //
  5139. // if res.Infcode == 0 {
  5140. // order := &models.HisOrder{
  5141. // UserOrgId: adminUser.CurrentOrgId,
  5142. // HisPatientId: his.ID,
  5143. // PatientId: his.PatientId,
  5144. // SettleAccountsDate: recordDateTime,
  5145. // Ctime: time.Now().Unix(),
  5146. // Mtime: time.Now().Unix(),
  5147. // Status: 1,
  5148. // Number: chrg_bchno,
  5149. // Infcode: res.Infcode,
  5150. // WarnMsg: res.WarnMsg,
  5151. // Cainfo: res.Cainfo,
  5152. // ErrMsg: res.ErrMsg,
  5153. // RespondTime: res.RefmsgTime,
  5154. // InfRefmsgid: res.InfRefmsgid,
  5155. // OrderStatus: 1,
  5156. // IsMedicineInsurance: 1,
  5157. // SettleType: settle_accounts_type,
  5158. // SettleStartTime: start_time,
  5159. // SettleEndTime: end_time,
  5160. // Creator: roles.ID,
  5161. // Modify: roles.ID,
  5162. // PType: 2,
  5163. // }
  5164. // err = service.CreateOrder(order)
  5165. // if err != nil {
  5166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5167. // return
  5168. // }
  5169. //
  5170. // for _, item := range res.Output.Result {
  5171. // temp := strings.Split(item.FeedetlSn, "-")
  5172. // var advice_id int64 = 0
  5173. // var project_id int64 = 0
  5174. // var types int64 = 0
  5175. //
  5176. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5177. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5178. //
  5179. // if temp[1] == "1" {
  5180. // advice_id = id
  5181. // project_id = 0
  5182. // } else if temp[1] == "2" {
  5183. // advice_id = 0
  5184. // project_id = id
  5185. // }
  5186. //
  5187. // info := &models.HisOrderInfo{
  5188. // OrderNumber: order.Number,
  5189. // FeedetlSn: item.FeedetlSn,
  5190. // UploadDate: time.Now().Unix(),
  5191. // AdviceId: advice_id,
  5192. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5193. // Cnt: item.Cnt,
  5194. // Pric: float64(item.Pric),
  5195. // PatientId: his.PatientId,
  5196. // PricUplmtAmt: item.PricUplmtAmt,
  5197. // SelfpayProp: item.SelfpayProp,
  5198. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5199. // OverlmtAmt: item.OverlmtAmt,
  5200. // PreselfpayAmt: item.PreselfpayAmt,
  5201. // BasMednFlag: item.BasMednFlag,
  5202. // MedChrgitmType: item.MedChrgitmType,
  5203. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5204. // Status: 1,
  5205. // Memo: item.Memo,
  5206. // Mtime: time.Now().Unix(),
  5207. // InscpScpAmt: item.InscpScpAmt,
  5208. // DrtReimFlag: item.DrtReimFlag,
  5209. // Ctime: time.Now().Unix(),
  5210. // ListSpItemFlag: item.ListSpItemFlag,
  5211. // ChldMedcFlag: item.ChldMedcFlag,
  5212. // LmtUsedFlag: item.LmtUsedFlag,
  5213. // ChrgitmLv: item.ChrgitmLv,
  5214. // UserOrgId: adminUser.CurrentOrgId,
  5215. // HisPatientId: his.ID,
  5216. // OrderId: order.ID,
  5217. // ProjectId: project_id,
  5218. // Type: types,
  5219. // }
  5220. // service.CreateOrderInfo(info)
  5221. //
  5222. // }
  5223. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5224. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5225. //
  5226. // var total float64
  5227. // for _, item := range prescriptions {
  5228. // if item.Type == 1 { //药品
  5229. // for _, subItem := range item.HisDoctorAdviceInfo {
  5230. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5231. // }
  5232. // }
  5233. // if item.Type == 2 { //项目
  5234. // for _, subItem := range item.HisPrescriptionProject {
  5235. // total = total + (subItem.Price * float64(subItem.Count))
  5236. // }
  5237. // }
  5238. // }
  5239. //
  5240. // for _, item := range prescriptions {
  5241. // for _, subItem := range item.HisAdditionalCharge {
  5242. // total = total + (subItem.Price * float64(subItem.Count))
  5243. // }
  5244. // }
  5245. //
  5246. // allTotal := fmt.Sprintf("%.2f", total)
  5247. // if res.Infcode == 0 {
  5248. // var rf []*ResultFive
  5249. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5250. // psn_no := his.PsnNo
  5251. // mdtrt_id := his.Number
  5252. // chrg_bchno := chrg_bchno
  5253. // cert_no := his.Certno
  5254. // insutype := rf[0].Insutype
  5255. //
  5256. // if his.IdCardType == 1 {
  5257. // cert_no = his.MedicalInsuranceNumber
  5258. //
  5259. // } else {
  5260. //
  5261. // cert_no = his.Certno
  5262. //
  5263. // }
  5264. //
  5265. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5266. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5267. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5268. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5269. // resp, requestErr := http.Get(api)
  5270. // if requestErr != nil {
  5271. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5272. // return
  5273. // }
  5274. // defer resp.Body.Close()
  5275. // body, ioErr := ioutil.ReadAll(resp.Body)
  5276. // if ioErr != nil {
  5277. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5278. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5279. // return
  5280. // }
  5281. // var respJSON map[string]interface{}
  5282. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5283. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5284. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5285. // return
  5286. // }
  5287. // fmt.Println(respJSON)
  5288. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5289. // userJSONBytes, _ := json.Marshal(respJSON)
  5290. // var res ResultSeven
  5291. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5292. // utils.ErrorLog("解析失败:%v", err)
  5293. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5294. // return
  5295. // }
  5296. // if res.Infcode != 0 {
  5297. // errlog := &models.HisOrderError{
  5298. // UserOrgId: adminUser.CurrentOrgId,
  5299. // Ctime: time.Now().Unix(),
  5300. // Mtime: time.Now().Unix(),
  5301. // Number: chrg_bchno,
  5302. // ErrMsg: res.ErrMsg,
  5303. // Status: 1,
  5304. // PatientId: id,
  5305. // RecordTime: recordDateTime,
  5306. // Stage: 7,
  5307. // }
  5308. // service.CreateErrMsgLog(errlog)
  5309. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5310. // return
  5311. // } else {
  5312. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5313. // order.OrderStatus = 1
  5314. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5315. // order.SetlId = res.Output.Setlinfo.SetlID
  5316. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5317. // order.PsnName = res.Output.Setlinfo.PsnName
  5318. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5319. // order.Certno = res.Output.Setlinfo.Certno
  5320. // order.Gend = res.Output.Setlinfo.Gend
  5321. // order.Naty = res.Output.Setlinfo.Naty
  5322. // order.Age = res.Output.Setlinfo.Age
  5323. // order.Insutype = res.Output.Setlinfo.Insutype
  5324. // order.PsnType = res.Output.Setlinfo.PsnType
  5325. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5326. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5327. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5328. // order.MedType = res.Output.Setlinfo.MedType
  5329. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5330. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5331. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5332. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5333. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5334. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5335. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5336. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5337. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5338. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5339. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5340. // order.MafPay = res.Output.Setlinfo.MafPay
  5341. // order.OthPay = res.Output.Setlinfo.OthPay
  5342. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5343. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5344. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5345. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5346. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5347. // order.Balc = res.Output.Setlinfo.Balc
  5348. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5349. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5350. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5351. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5352. // order.Creator = order.Creator
  5353. // order.Modify = roles.ID
  5354. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5355. // detailStr := string(setlDetail)
  5356. // order.SetlDetail = detailStr
  5357. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5358. // err = service.UpDateOrder(order)
  5359. // if err == nil {
  5360. // c.ServeSuccessJSON(map[string]interface{}{
  5361. // "msg": "预结算成功",
  5362. // })
  5363. // } else {
  5364. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5365. // return
  5366. // }
  5367. // }
  5368. // } else {
  5369. // adminUser := c.GetAdminUserInfo()
  5370. // errlog := &models.HisOrderError{
  5371. // UserOrgId: adminUser.CurrentOrgId,
  5372. // Ctime: time.Now().Unix(),
  5373. // Mtime: time.Now().Unix(),
  5374. // ErrMsg: res.ErrMsg,
  5375. // Status: 1,
  5376. // PatientId: id,
  5377. // RecordTime: recordDateTime,
  5378. // Stage: 4,
  5379. // }
  5380. // service.CreateErrMsgLog(errlog)
  5381. //
  5382. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5383. // return
  5384. // }
  5385. // } else {
  5386. // adminUser := c.GetAdminUserInfo()
  5387. // errlog := &models.HisOrderError{
  5388. // UserOrgId: adminUser.CurrentOrgId,
  5389. // Ctime: time.Now().Unix(),
  5390. // Mtime: time.Now().Unix(),
  5391. // ErrMsg: res.ErrMsg,
  5392. // Status: 1,
  5393. // PatientId: id,
  5394. // RecordTime: recordDateTime,
  5395. // Stage: 4,
  5396. // }
  5397. // service.CreateErrMsgLog(errlog)
  5398. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5399. // return
  5400. // }
  5401. //
  5402. // } else {
  5403. // var total float64
  5404. // for _, item := range prescriptions {
  5405. // if item.Type == 1 { //药品
  5406. // for _, subItem := range item.HisDoctorAdviceInfo {
  5407. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5408. // }
  5409. // }
  5410. // if item.Type == 2 { //项目
  5411. // for _, subItem := range item.HisPrescriptionProject {
  5412. // total = total + (subItem.Price * float64(subItem.Count))
  5413. // }
  5414. // }
  5415. //
  5416. // for _, subItem := range item.HisAdditionalCharge {
  5417. // total = total + (subItem.Price * float64(subItem.Count))
  5418. // }
  5419. // }
  5420. //
  5421. // allTotal := fmt.Sprintf("%.2f", total)
  5422. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5423. // order := &models.HisOrder{
  5424. // UserOrgId: adminUser.CurrentOrgId,
  5425. // HisPatientId: his.ID,
  5426. // PatientId: id,
  5427. // SettleAccountsDate: recordDateTime,
  5428. // Ctime: time.Now().Unix(),
  5429. // Mtime: time.Now().Unix(),
  5430. // Status: 1,
  5431. // OrderStatus: 2,
  5432. // Number: chrg_bchno,
  5433. // MedfeeSumamt: totals,
  5434. // }
  5435. // err = service.CreateOrder(order)
  5436. // if err != nil {
  5437. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5438. // return
  5439. // }
  5440. //
  5441. // var customs []*Custom
  5442. // for _, item := range prescriptions {
  5443. //
  5444. // if item.Type == 1 { //药品
  5445. // for _, subItem := range item.HisDoctorAdviceInfo {
  5446. // cus := &Custom{
  5447. // AdviceId: subItem.ID,
  5448. // ProjectId: 0,
  5449. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5450. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5451. // FeedetlSn: subItem.FeedetlSn,
  5452. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5453. // MedListCodg: subItem.MedListCodg,
  5454. // Type: 1,
  5455. // }
  5456. // customs = append(customs, cus)
  5457. // }
  5458. // }
  5459. //
  5460. // if item.Type == 2 { //项目
  5461. // for _, subItem := range item.HisPrescriptionProject {
  5462. //
  5463. // cus := &Custom{
  5464. // AdviceId: 0,
  5465. // ProjectId: subItem.ID,
  5466. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5467. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5468. // FeedetlSn: subItem.FeedetlSn,
  5469. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5470. // MedListCodg: subItem.MedListCodg,
  5471. // Type: 2,
  5472. // }
  5473. //
  5474. // customs = append(customs, cus)
  5475. // }
  5476. // }
  5477. //
  5478. // for _, item := range item.HisAdditionalCharge {
  5479. // cus := &Custom{
  5480. // ItemId: item.ID,
  5481. // AdviceId: 0,
  5482. // ProjectId: 0,
  5483. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5484. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5485. // FeedetlSn: item.FeedetlSn,
  5486. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5487. // MedListCodg: item.XtHisAddtionConfig.Code,
  5488. // Type: 3,
  5489. // }
  5490. //
  5491. // customs = append(customs, cus)
  5492. // }
  5493. //
  5494. // }
  5495. //
  5496. // for _, item := range customs {
  5497. // var advice_id int64 = 0
  5498. // var project_id int64 = 0
  5499. // var item_id int64 = 0
  5500. //
  5501. // var types int64 = 0
  5502. //
  5503. // if item.Type == 1 {
  5504. // advice_id = item.AdviceId
  5505. // project_id = 0
  5506. // item_id = 0
  5507. // } else if item.Type == 2 {
  5508. // advice_id = 0
  5509. // item_id = 0
  5510. //
  5511. // project_id = item.ProjectId
  5512. // } else if item.Type == 3 {
  5513. // advice_id = 0
  5514. // item_id = item.ItemId
  5515. // project_id = 0
  5516. // }
  5517. //
  5518. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5519. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5520. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5521. //
  5522. // info := &models.HisOrderInfo{
  5523. // OrderNumber: order.Number,
  5524. // UploadDate: time.Now().Unix(),
  5525. // AdviceId: advice_id,
  5526. // DetItemFeeSumamt: detItemFeeSumamt,
  5527. // Cnt: cut,
  5528. // Pric: pric,
  5529. // PatientId: id,
  5530. // Status: 1,
  5531. // Mtime: time.Now().Unix(),
  5532. // Ctime: time.Now().Unix(),
  5533. // UserOrgId: adminUser.CurrentOrgId,
  5534. // HisPatientId: his.ID,
  5535. // OrderId: order.ID,
  5536. // ProjectId: project_id,
  5537. // Type: types,
  5538. // ItemId: item_id,
  5539. // }
  5540. // service.CreateOrderInfo(info)
  5541. // }
  5542. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5543. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5544. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5545. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5546. // if err == nil {
  5547. // c.ServeSuccessJSON(map[string]interface{}{
  5548. // "msg": "结算成功",
  5549. // })
  5550. // } else {
  5551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5552. // return
  5553. // }
  5554. // }
  5555. //}
  5556. //上传明细-预结算-
  5557. func (c *HisApiController) GetPreUploadInfo() {
  5558. id, _ := c.GetInt64("id")
  5559. record_time := c.GetString("record_time")
  5560. his_patient_id, _ := c.GetInt64("his_patient_id")
  5561. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5562. admin_user_id, _ := c.GetInt64("admin_user_id")
  5563. diagnosis_id := c.GetString("diagnosis")
  5564. sick_type, _ := c.GetInt64("sick_type")
  5565. reg_type, _ := c.GetInt64("p_type")
  5566. begin_time := c.GetString("begin_time")
  5567. id_str := c.GetString("ids")
  5568. ids_arr := strings.Split(id_str, ",")
  5569. timeLayout := "2006-01-02"
  5570. loc, _ := time.LoadLocation("Local")
  5571. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5572. if err != nil {
  5573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5574. return
  5575. }
  5576. recordDateTime := theTime.Unix()
  5577. adminUser := c.GetAdminUserInfo()
  5578. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5579. var config []*models.HisXtDiagnoseConfig
  5580. for _, item := range diagnosis_ids {
  5581. id, _ := strconv.ParseInt(item, 10, 64)
  5582. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5583. config = append(config, &diagnosisConfig)
  5584. }
  5585. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5586. sickConfig, _ := service.FindSickById(sick_type)
  5587. var prescriptions []*models.HisPrescription
  5588. var start_time int64
  5589. var end_time int64
  5590. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5591. fmt.Println(his_patient_id)
  5592. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5593. timestamp := time.Now().Unix()
  5594. tempTime := time.Unix(timestamp, 0)
  5595. timeFormat := tempTime.Format("20060102150405")
  5596. chrgBchno := rand.Intn(100000) + 10000
  5597. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5598. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5599. var patientPrescription models.HisPrescriptionInfo
  5600. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5601. if patientPrescription.ID == 0 {
  5602. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5603. }
  5604. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5605. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5606. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5607. strconv.FormatInt(his.PatientId, 10)
  5608. var res2 ResultSix
  5609. var resSix10265 ResultSix10265
  5610. var time_stamp string
  5611. if miConfig.MdtrtareaAdmvs == "421300" {
  5612. data := make(map[string]interface{})
  5613. client := &http.Client{}
  5614. data["psn_no"] = his.PsnNo
  5615. data["mdtrt_id"] = his.Number
  5616. data["doctor"] = roles.UserName
  5617. data["department"] = department.Name
  5618. data["org_name"] = miConfig.OrgName
  5619. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5620. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5621. data["fixmedins_code"] = miConfig.Code
  5622. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5623. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5624. data["secret_key"] = miConfig.SecretKey
  5625. data["sick_code"] = sickConfig.CountryCode
  5626. data["sick_name"] = sickConfig.ClassName
  5627. data["begin_time"] = begin_time
  5628. data["dept"] = strconv.FormatInt(department.ID, 10)
  5629. data["config"] = config
  5630. fmt.Println(data)
  5631. bytesData, _ := json.Marshal(data)
  5632. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5633. resp, _ := client.Do(req)
  5634. defer resp.Body.Close()
  5635. body, ioErr := ioutil.ReadAll(resp.Body)
  5636. if ioErr != nil {
  5637. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5639. return
  5640. }
  5641. var respJSON map[string]interface{}
  5642. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5645. return
  5646. }
  5647. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5648. userJSONBytes, _ := json.Marshal(respJSON)
  5649. fmt.Println("log")
  5650. fmt.Println(string(userJSONBytes))
  5651. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5652. utils.ErrorLog("解析失败:%v", err)
  5653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5654. return
  5655. }
  5656. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5657. //江苏地区国家医保医疗类别
  5658. //职工透析:医疗类别选特殊情况门诊9933
  5659. //居民血透门慢: 医疗类别选门诊慢病1402
  5660. //var med_type string
  5661. //if his.Insutype == "310" {
  5662. // if reg_type == 14 {
  5663. // med_type = "9933"
  5664. // } else if reg_type == 11 {
  5665. // med_type = "11"
  5666. //
  5667. // }
  5668. //} else if his.Insutype == "390" {
  5669. // if reg_type == 14 {
  5670. // med_type = "1402"
  5671. // } else if reg_type == 11 {
  5672. // med_type = "11"
  5673. // }
  5674. //}
  5675. data := make(map[string]interface{})
  5676. client := &http.Client{}
  5677. data["psn_no"] = his.PsnNo
  5678. data["mdtrt_id"] = his.Number
  5679. data["doctor"] = roles.UserName
  5680. data["department"] = department.Name
  5681. data["org_name"] = miConfig.OrgName
  5682. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5683. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5684. data["fixmedins_code"] = miConfig.Code
  5685. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5686. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5687. data["secret_key"] = miConfig.SecretKey
  5688. data["sick_code"] = sickConfig.CountryCode
  5689. data["sick_name"] = sickConfig.ClassName
  5690. data["begin_time"] = begin_time
  5691. data["dept"] = strconv.FormatInt(department.ID, 10)
  5692. data["config"] = config
  5693. data["url"] = miConfig.Url
  5694. data["ak"] = miConfig.AccessKey
  5695. data["cainfo"] = miConfig.Cainfo
  5696. bytesData, _ := json.Marshal(data)
  5697. var req *http.Request
  5698. if miConfig.MdtrtareaAdmvs == "320921" {
  5699. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5700. //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 +
  5701. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5702. } else {
  5703. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5704. }
  5705. resp, _ := client.Do(req)
  5706. defer resp.Body.Close()
  5707. body, ioErr := ioutil.ReadAll(resp.Body)
  5708. if ioErr != nil {
  5709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5711. return
  5712. }
  5713. var respJSON map[string]interface{}
  5714. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5717. return
  5718. }
  5719. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5720. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5721. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5722. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5723. userJSONBytes, _ := json.Marshal(respJSON)
  5724. fmt.Println("log")
  5725. fmt.Println(string(userJSONBytes))
  5726. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5727. utils.ErrorLog("解析失败:%v", err)
  5728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5729. return
  5730. }
  5731. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5732. res2.Output = resSix10265.Output
  5733. res2.ErrMsg = resSix10265.ErrMsg
  5734. res2.Cainfo = resSix10265.Cainfo
  5735. res2.WarnMsg = resSix10265.WarnMsg
  5736. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5737. res2.Infcode = infocode
  5738. } else {
  5739. var result string
  5740. var requestLog string
  5741. if miConfig.MdtrtareaAdmvs == "440781" { //
  5742. 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)
  5743. } else {
  5744. if miConfig.Code == "H15049901371" {
  5745. //赤峰地区国家医保医疗类别
  5746. //职工透析:医疗类别选特殊情况门诊990502
  5747. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5748. var med_type string
  5749. if his.Insutype == "390" {
  5750. if reg_type == 14 {
  5751. med_type = "9933"
  5752. } else if reg_type == 11 {
  5753. med_type = "11"
  5754. }
  5755. } else if his.Insutype == "310" {
  5756. if reg_type == 14 {
  5757. med_type = "990502"
  5758. } else if reg_type == 11 {
  5759. med_type = "11"
  5760. }
  5761. }
  5762. 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)
  5763. } else {
  5764. 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)
  5765. }
  5766. saveLog(result, requestLog, "2203", "上传就诊信息")
  5767. var respJSON2 map[string]interface{}
  5768. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5771. return
  5772. }
  5773. userJSONBytes2, _ := json.Marshal(respJSON2)
  5774. if miConfig.Code == "H15049901371" {
  5775. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5776. utils.ErrorLog("解析失败:%v", err)
  5777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5778. return
  5779. }
  5780. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5781. res2.Output = resSix10265.Output
  5782. res2.ErrMsg = resSix10265.ErrMsg
  5783. res2.Cainfo = resSix10265.Cainfo
  5784. res2.WarnMsg = resSix10265.WarnMsg
  5785. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5786. res2.Infcode = infocode
  5787. } else {
  5788. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5789. utils.ErrorLog("解析失败:%v", err)
  5790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5791. return
  5792. }
  5793. }
  5794. }
  5795. }
  5796. if res2.Infcode != 0 {
  5797. adminUser := c.GetAdminUserInfo()
  5798. errlog := &models.HisOrderError{
  5799. UserOrgId: adminUser.CurrentOrgId,
  5800. Ctime: time.Now().Unix(),
  5801. Mtime: time.Now().Unix(),
  5802. ErrMsg: res2.ErrMsg,
  5803. Status: 1,
  5804. PatientId: id,
  5805. RecordTime: recordDateTime,
  5806. Stage: 3,
  5807. }
  5808. service.CreateErrMsgLog(errlog)
  5809. c.ServeSuccessJSON(map[string]interface{}{
  5810. "failed_code": -10,
  5811. "msg": res2.ErrMsg,
  5812. })
  5813. return
  5814. } else {
  5815. his.Diagnosis = diagnosis_id
  5816. his.SickType = sickConfig.ID
  5817. his.PType = fmt.Sprintf("%d", reg_type)
  5818. service.UpdateHisPatientThree(&his)
  5819. data := make(map[string]interface{})
  5820. if settle_accounts_type == 1 { //日结
  5821. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5822. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5823. } else {
  5824. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5825. }
  5826. data["pre"] = prescriptions
  5827. } else { //月结
  5828. start_time_str := c.GetString("start_time")
  5829. end_time_str := c.GetString("end_time")
  5830. timeLayout := "2006-01-02"
  5831. loc, _ := time.LoadLocation("Local")
  5832. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5833. if err != nil {
  5834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5835. return
  5836. }
  5837. recordStartTime := theStartTime.Unix()
  5838. start_time = recordStartTime
  5839. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5840. if err != nil {
  5841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5842. return
  5843. }
  5844. recordEndTime := theEndTime.Unix()
  5845. end_time = recordEndTime
  5846. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5847. data["pre"] = prescriptions
  5848. }
  5849. client := &http.Client{}
  5850. data["psn_no"] = his.PsnNo
  5851. data["mdtrt_id"] = his.Number
  5852. data["chrg_bchno"] = chrg_bchno
  5853. data["org_name"] = miConfig.OrgName
  5854. data["doctor"] = roles.UserName
  5855. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5856. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5857. data["fixmedins_code"] = miConfig.Code
  5858. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5859. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5860. data["dept_code"] = "15"
  5861. } else {
  5862. data["dept_code"] = department.Number
  5863. }
  5864. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5865. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5866. data["secret_key"] = miConfig.SecretKey
  5867. data["url"] = miConfig.Url
  5868. data["ak"] = miConfig.AccessKey
  5869. data["new_doctor_name"] = patientPrescription.Doctor
  5870. data["diag_code"] = sickConfig.CountryCode
  5871. data["time_stamp"] = time_stamp
  5872. data["cainfo"] = miConfig.Cainfo
  5873. var ids []int64
  5874. for _, item := range prescriptions {
  5875. ids = append(ids, item.ID)
  5876. }
  5877. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5878. if config.IsOpen == 1 { //对接了医保,走医保流程
  5879. var res ResultFour
  5880. var resFour10265 ResultFour10265
  5881. if miConfig.MdtrtareaAdmvs == "421300" {
  5882. bytesData, _ := json.Marshal(data)
  5883. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5884. resp, _ := client.Do(req)
  5885. defer resp.Body.Close()
  5886. body, ioErr := ioutil.ReadAll(resp.Body)
  5887. if ioErr != nil {
  5888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5890. return
  5891. }
  5892. var respJSON map[string]interface{}
  5893. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5896. return
  5897. }
  5898. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5899. userJSONBytes, _ := json.Marshal(respJSON)
  5900. fmt.Println("log")
  5901. fmt.Println(string(userJSONBytes))
  5902. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5903. utils.ErrorLog("解析失败:%v", err)
  5904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5905. return
  5906. }
  5907. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5908. bytesData, _ := json.Marshal(data)
  5909. var req *http.Request
  5910. if miConfig.MdtrtareaAdmvs == "320921" {
  5911. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5912. } else {
  5913. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5914. }
  5915. resp, _ := client.Do(req)
  5916. defer resp.Body.Close()
  5917. body, ioErr := ioutil.ReadAll(resp.Body)
  5918. if ioErr != nil {
  5919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5921. return
  5922. }
  5923. var respJSON map[string]interface{}
  5924. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5927. return
  5928. }
  5929. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5930. userJSONBytes, _ := json.Marshal(respJSON)
  5931. fmt.Println("log")
  5932. fmt.Println(string(userJSONBytes))
  5933. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5934. utils.ErrorLog("解析失败:%v", err)
  5935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5936. return
  5937. }
  5938. res.InfRefmsgid = resFour10265.InfRefmsgid
  5939. res.Output = resFour10265.Output
  5940. res.ErrMsg = resFour10265.ErrMsg
  5941. res.Cainfo = resFour10265.Cainfo
  5942. res.WarnMsg = resFour10265.WarnMsg
  5943. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5944. res.Infcode = infocode
  5945. } else {
  5946. if miConfig.Code == "H15049901371" {
  5947. 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)
  5948. var dat map[string]interface{}
  5949. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5950. fmt.Println(dat)
  5951. } else {
  5952. fmt.Println(err)
  5953. }
  5954. saveLog(result, request_log, "2204", "上传费用明细")
  5955. userJSONBytes, _ := json.Marshal(dat)
  5956. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5957. utils.ErrorLog("解析失败:%v", err)
  5958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5959. return
  5960. }
  5961. res.InfRefmsgid = resFour10265.InfRefmsgid
  5962. res.Output = resFour10265.Output
  5963. res.ErrMsg = resFour10265.ErrMsg
  5964. res.Cainfo = resFour10265.Cainfo
  5965. res.WarnMsg = resFour10265.WarnMsg
  5966. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5967. res.Infcode = infocode
  5968. } else {
  5969. 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)
  5970. var dat map[string]interface{}
  5971. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5972. fmt.Println(dat)
  5973. } else {
  5974. fmt.Println(err)
  5975. }
  5976. saveLog(result, request_log, "2204", "上传费用明细")
  5977. userJSONBytes, _ := json.Marshal(dat)
  5978. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5979. utils.ErrorLog("解析失败:%v", err)
  5980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5981. return
  5982. }
  5983. }
  5984. }
  5985. if res.Infcode == 0 {
  5986. order := &models.HisOrder{
  5987. UserOrgId: adminUser.CurrentOrgId,
  5988. HisPatientId: his.ID,
  5989. PatientId: his.PatientId,
  5990. SettleAccountsDate: recordDateTime,
  5991. Ctime: time.Now().Unix(),
  5992. Mtime: time.Now().Unix(),
  5993. MdtrtId: his.Number,
  5994. PsnNo: his.PsnNo,
  5995. MedType: strconv.FormatInt(reg_type, 10),
  5996. Status: 1,
  5997. Number: chrg_bchno,
  5998. Infcode: res.Infcode,
  5999. WarnMsg: res.WarnMsg,
  6000. Cainfo: res.Cainfo,
  6001. ErrMsg: res.ErrMsg,
  6002. RespondTime: res.RefmsgTime,
  6003. InfRefmsgid: res.InfRefmsgid,
  6004. OrderStatus: 1,
  6005. IsMedicineInsurance: 1,
  6006. SettleType: settle_accounts_type,
  6007. SettleStartTime: start_time,
  6008. SettleEndTime: end_time,
  6009. Creator: roles.AdminUserId,
  6010. Modify: roles.AdminUserId,
  6011. PType: 2,
  6012. Diagnosis: diagnosis_id,
  6013. }
  6014. err = service.CreateOrder(order)
  6015. if err != nil {
  6016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6017. return
  6018. }
  6019. for _, item := range res.Output.Result {
  6020. temp := strings.Split(item.FeedetlSn, "-")
  6021. var advice_id int64 = 0
  6022. var project_id int64 = 0
  6023. var types int64 = 0
  6024. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6025. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6026. if temp[1] == "1" {
  6027. advice_id = id
  6028. project_id = 0
  6029. } else if temp[1] == "2" {
  6030. advice_id = 0
  6031. project_id = id
  6032. }
  6033. info := &models.HisOrderInfo{
  6034. OrderNumber: order.Number,
  6035. FeedetlSn: item.FeedetlSn,
  6036. UploadDate: time.Now().Unix(),
  6037. AdviceId: advice_id,
  6038. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6039. Cnt: item.Cnt,
  6040. Pric: float64(item.Pric),
  6041. PatientId: his.PatientId,
  6042. PricUplmtAmt: item.PricUplmtAmt,
  6043. SelfpayProp: item.SelfpayProp,
  6044. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6045. OverlmtAmt: item.OverlmtAmt,
  6046. PreselfpayAmt: item.PreselfpayAmt,
  6047. BasMednFlag: item.BasMednFlag,
  6048. MedChrgitmType: item.MedChrgitmType,
  6049. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6050. Status: 1,
  6051. Memo: item.Memo,
  6052. Mtime: time.Now().Unix(),
  6053. InscpScpAmt: item.InscpScpAmt,
  6054. DrtReimFlag: item.DrtReimFlag,
  6055. Ctime: time.Now().Unix(),
  6056. ListSpItemFlag: item.ListSpItemFlag,
  6057. ChldMedcFlag: item.ChldMedcFlag,
  6058. LmtUsedFlag: item.LmtUsedFlag,
  6059. ChrgitmLv: item.ChrgitmLv,
  6060. UserOrgId: adminUser.CurrentOrgId,
  6061. HisPatientId: his.ID,
  6062. OrderId: order.ID,
  6063. ProjectId: project_id,
  6064. Type: types,
  6065. }
  6066. service.CreateOrderInfo(info)
  6067. }
  6068. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6069. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6070. var total float64
  6071. for _, item := range prescriptions {
  6072. if item.Type == 1 { //药品
  6073. for _, subItem := range item.HisDoctorAdviceInfo {
  6074. total = total + (subItem.Price * subItem.PrescribingNumber)
  6075. }
  6076. }
  6077. if item.Type == 2 { //项目
  6078. for _, subItem := range item.HisPrescriptionProject {
  6079. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6080. total = total + (subItem.Price * cnt)
  6081. }
  6082. }
  6083. }
  6084. for _, item := range prescriptions {
  6085. for _, subItem := range item.HisAdditionalCharge {
  6086. total = total + (subItem.Price * float64(subItem.Count))
  6087. }
  6088. }
  6089. allTotal := fmt.Sprintf("%.4f", total)
  6090. if res.Infcode == 0 {
  6091. var rf []*ResultFive
  6092. json.Unmarshal([]byte(his.Iinfo), &rf)
  6093. chrg_bchno := chrg_bchno
  6094. cert_no := his.Certno
  6095. var insutypes []string
  6096. var insutype string
  6097. var is390 int = 0
  6098. var is310 int = 0
  6099. for _, item := range rf {
  6100. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6101. insutypes = append(insutypes, item.Insutype)
  6102. }
  6103. }
  6104. if len(insutypes) == 1 {
  6105. insutype = insutypes[0]
  6106. } else {
  6107. for _, i := range insutypes {
  6108. if i == "390" {
  6109. is390 = 1
  6110. }
  6111. if i == "310" {
  6112. is310 = 1
  6113. }
  6114. }
  6115. }
  6116. if is390 == 1 {
  6117. insutype = "390"
  6118. }
  6119. if is310 == 1 {
  6120. insutype = "310"
  6121. }
  6122. if len(insutypes) == 0 {
  6123. insutype = "310"
  6124. }
  6125. if len(insutypes) == 2 {
  6126. insutype = strconv.FormatInt(his.SocialType, 64)
  6127. }
  6128. //insutype = "390"
  6129. if his.IdCardType == 1 {
  6130. cert_no = his.MedicalInsuranceNumber
  6131. } else {
  6132. cert_no = his.Certno
  6133. }
  6134. var res ResultSeven
  6135. var resSeven10265 ResultSeven10265
  6136. if miConfig.MdtrtareaAdmvs == "421300" {
  6137. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6138. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6139. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6140. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6141. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6142. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6143. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6144. resp, requestErr := http.Get(api)
  6145. if requestErr != nil {
  6146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6147. return
  6148. }
  6149. body, ioErr := ioutil.ReadAll(resp.Body)
  6150. if ioErr != nil {
  6151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6153. return
  6154. }
  6155. var respJSON map[string]interface{}
  6156. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6159. return
  6160. }
  6161. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6162. result, _ := json.Marshal(respJSON)
  6163. fmt.Println("log")
  6164. fmt.Println(string(result))
  6165. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6166. utils.ErrorLog("解析失败:%v", err)
  6167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6168. return
  6169. }
  6170. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6171. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6172. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6173. bas := strings.Split(psn_info.CardInfo, "|")
  6174. if his.IdCardType == 1 {
  6175. cert_no = bas[2]
  6176. } else {
  6177. cert_no = bas[1]
  6178. }
  6179. //江苏地区国家医保医疗类别
  6180. //职工透析:医疗类别选特殊情况门诊9933
  6181. //居民血透门慢: 医疗类别选门诊慢病1402
  6182. //var med_type string
  6183. //if his.Insutype == "310" {
  6184. // if reg_type == 14 {
  6185. // med_type = "9933"
  6186. // } else if reg_type == 11 {
  6187. // med_type = "11"
  6188. //
  6189. // }
  6190. //} else if his.Insutype == "390" {
  6191. // if reg_type == 14 {
  6192. // med_type = "1402"
  6193. // } else if reg_type == 11 {
  6194. // med_type = "11"
  6195. // }
  6196. //}
  6197. var api string
  6198. if miConfig.MdtrtareaAdmvs == "320921" {
  6199. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6200. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6201. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6202. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6203. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6204. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6205. "&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
  6206. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6207. } else {
  6208. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6209. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6210. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6211. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6212. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6213. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6214. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6215. "&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
  6216. }
  6217. resp, requestErr := http.Get(api)
  6218. if requestErr != nil {
  6219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6220. return
  6221. }
  6222. body, ioErr := ioutil.ReadAll(resp.Body)
  6223. if ioErr != nil {
  6224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6226. return
  6227. }
  6228. var respJSON map[string]interface{}
  6229. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6232. return
  6233. }
  6234. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6235. result, _ := json.Marshal(respJSON)
  6236. fmt.Println("log")
  6237. fmt.Println(string(result))
  6238. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6239. utils.ErrorLog("解析失败:%v", err)
  6240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6241. return
  6242. }
  6243. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6244. res.Output = resSeven10265.Output
  6245. res.ErrMsg = resSeven10265.ErrMsg
  6246. res.Cainfo = resSeven10265.Cainfo
  6247. res.WarnMsg = resSeven10265.WarnMsg
  6248. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6249. res.Infcode = infocode
  6250. } else {
  6251. var result string
  6252. var request_log string
  6253. if miConfig.Code == "H15049901371" {
  6254. //赤峰地区国家医保医疗类别
  6255. //职工透析:医疗类别选特殊情况门诊990502
  6256. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6257. var med_type string
  6258. if his.Insutype == "390" {
  6259. if reg_type == 14 {
  6260. med_type = "9933"
  6261. } else if reg_type == 11 {
  6262. med_type = "11"
  6263. }
  6264. } else if his.Insutype == "310" {
  6265. if reg_type == 14 {
  6266. med_type = "990502"
  6267. } else if reg_type == 11 {
  6268. med_type = "11"
  6269. }
  6270. }
  6271. 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)
  6272. } else {
  6273. 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)
  6274. }
  6275. var dat map[string]interface{}
  6276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6277. fmt.Println(dat)
  6278. } else {
  6279. fmt.Println(err)
  6280. }
  6281. saveLog(result, request_log, "2206", "预结算")
  6282. //userJSONBytes, _ := json.Marshal(dat)
  6283. //
  6284. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6285. // utils.ErrorLog("解析失败:%v", err)
  6286. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6287. // return
  6288. //}
  6289. userJSONBytes, _ := json.Marshal(dat)
  6290. if miConfig.Code == "H15049901371" {
  6291. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6292. utils.ErrorLog("解析失败:%v", err)
  6293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6294. return
  6295. }
  6296. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6297. res.Output = resSeven10265.Output
  6298. res.ErrMsg = resSeven10265.ErrMsg
  6299. res.Cainfo = resSeven10265.Cainfo
  6300. res.WarnMsg = resSeven10265.WarnMsg
  6301. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6302. res.Infcode = infocode
  6303. } else {
  6304. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6305. utils.ErrorLog("解析失败:%v", err)
  6306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6307. return
  6308. }
  6309. }
  6310. }
  6311. if res.Infcode != 0 {
  6312. errlog := &models.HisOrderError{
  6313. UserOrgId: adminUser.CurrentOrgId,
  6314. Ctime: time.Now().Unix(),
  6315. Mtime: time.Now().Unix(),
  6316. Number: chrg_bchno,
  6317. ErrMsg: res.ErrMsg,
  6318. Status: 1,
  6319. PatientId: id,
  6320. RecordTime: recordDateTime,
  6321. Stage: 20,
  6322. }
  6323. service.CreateErrMsgLog(errlog)
  6324. c.ServeSuccessJSON(map[string]interface{}{
  6325. "failed_code": -10,
  6326. "msg": res.ErrMsg,
  6327. })
  6328. return
  6329. } else {
  6330. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6331. order.OrderStatus = 1
  6332. order.IsPre = 1
  6333. order.Status = 1
  6334. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6335. order.SetlId = res.Output.Setlinfo.SetlID
  6336. order.PsnNo = res.Output.Setlinfo.PsnNo
  6337. order.PsnName = res.Output.Setlinfo.PsnName
  6338. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6339. order.Certno = res.Output.Setlinfo.Certno
  6340. order.Gend = res.Output.Setlinfo.Gend
  6341. order.Naty = res.Output.Setlinfo.Naty
  6342. order.Age = res.Output.Setlinfo.Age
  6343. order.Insutype = res.Output.Setlinfo.Insutype
  6344. order.PsnType = res.Output.Setlinfo.PsnType
  6345. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6346. order.SetlTime = res.Output.Setlinfo.SetlTime
  6347. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6348. if res.Output.Setlinfo.MedType == "140101" {
  6349. order.MedType = "14"
  6350. } else {
  6351. order.MedType = res.Output.Setlinfo.MedType
  6352. }
  6353. if reg_type == 1112 {
  6354. order.MedType = "1112"
  6355. }
  6356. if reg_type == 1111 {
  6357. order.MedType = "1111"
  6358. }
  6359. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6360. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6361. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6362. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6363. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6364. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6365. order.HifpPay = res.Output.Setlinfo.HifpPay
  6366. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6367. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6368. order.HifesPay = res.Output.Setlinfo.HifesPay
  6369. order.HifobPay = res.Output.Setlinfo.HifobPay
  6370. order.MafPay = res.Output.Setlinfo.MafPay
  6371. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6372. order.OthPay = res.Output.Setlinfo.OthPay
  6373. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6374. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6375. order.AcctPay = res.Output.Setlinfo.AcctPay
  6376. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6377. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6378. order.Balc = res.Output.Setlinfo.Balc
  6379. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6380. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6381. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6382. order.ClrWay = res.Output.Setlinfo.ClrWay
  6383. order.Creator = order.Creator
  6384. order.Modify = roles.AdminUserId
  6385. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6386. detailStr := string(setlDetail)
  6387. order.SetlDetail = detailStr
  6388. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6389. err = service.UpDateOrder(order)
  6390. if err == nil {
  6391. c.ServeSuccessJSON(map[string]interface{}{
  6392. "msg": "预结算成功",
  6393. })
  6394. } else {
  6395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6396. return
  6397. }
  6398. }
  6399. } else {
  6400. adminUser := c.GetAdminUserInfo()
  6401. errlog := &models.HisOrderError{
  6402. UserOrgId: adminUser.CurrentOrgId,
  6403. Ctime: time.Now().Unix(),
  6404. Mtime: time.Now().Unix(),
  6405. ErrMsg: res.ErrMsg,
  6406. Status: 1,
  6407. PatientId: id,
  6408. RecordTime: recordDateTime,
  6409. Stage: 4,
  6410. }
  6411. service.CreateErrMsgLog(errlog)
  6412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6413. return
  6414. }
  6415. } else {
  6416. adminUser := c.GetAdminUserInfo()
  6417. errlog := &models.HisOrderError{
  6418. UserOrgId: adminUser.CurrentOrgId,
  6419. Ctime: time.Now().Unix(),
  6420. Mtime: time.Now().Unix(),
  6421. ErrMsg: res.ErrMsg,
  6422. Status: 1,
  6423. PatientId: id,
  6424. RecordTime: recordDateTime,
  6425. Stage: 4,
  6426. }
  6427. service.CreateErrMsgLog(errlog)
  6428. c.ServeSuccessJSON(map[string]interface{}{
  6429. "failed_code": -10,
  6430. "msg": res.ErrMsg,
  6431. })
  6432. return
  6433. }
  6434. }
  6435. }
  6436. }
  6437. //func (c *HisApiController) GetSettleInfo() {
  6438. // id, _ := c.GetInt64("id")
  6439. // order_id, _ := c.GetInt64("order_id")
  6440. //
  6441. // record_time := c.GetString("record_time")
  6442. // pay_way, _ := c.GetInt64("pay_way")
  6443. // pay_price, _ := c.GetFloat("pay_price")
  6444. // pay_card_no := c.GetString("pay_card_no")
  6445. // discount_price, _ := c.GetFloat("discount_price")
  6446. // preferential_price, _ := c.GetFloat("preferential_price")
  6447. // reality_price, _ := c.GetFloat("reality_price")
  6448. // found_price, _ := c.GetFloat("found_price")
  6449. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6450. // private_price, _ := c.GetFloat("private_price")
  6451. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6452. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6453. //
  6454. // timeLayout := "2006-01-02"
  6455. // loc, _ := time.LoadLocation("Local")
  6456. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6457. // if err != nil {
  6458. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6459. // return
  6460. // }
  6461. // recordDateTime := theTime.Unix()
  6462. // adminUser := c.GetAdminUserInfo()
  6463. //
  6464. // var prescriptions []*models.HisPrescription
  6465. //
  6466. // data := make(map[string]interface{})
  6467. // if settle_accounts_type == 1 { //日结
  6468. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6469. // data["pre"] = prescriptions
  6470. //
  6471. // } else { //月结
  6472. // start_time_str := c.GetString("start_time")
  6473. // end_time_str := c.GetString("end_time")
  6474. // timeLayout := "2006-01-02"
  6475. // loc, _ := time.LoadLocation("Local")
  6476. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6477. // if err != nil {
  6478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6479. // return
  6480. // }
  6481. // recordStartTime := theStartTime.Unix()
  6482. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6483. // if err != nil {
  6484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6485. // return
  6486. // }
  6487. // recordEndTime := theEndTime.Unix()
  6488. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6489. // data["pre"] = prescriptions
  6490. //
  6491. // }
  6492. //
  6493. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6494. //
  6495. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6496. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6497. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6498. // strconv.FormatInt(his.PatientId, 10)
  6499. //
  6500. // order_src, _ := service.GetHisOrderByID(order_id)
  6501. //
  6502. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6503. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6504. //
  6505. // var total float64
  6506. // for _, item := range prescriptions {
  6507. // if item.Type == 1 { //药品
  6508. // for _, subItem := range item.HisDoctorAdviceInfo {
  6509. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6510. // }
  6511. // }
  6512. // if item.Type == 2 { //项目
  6513. // for _, subItem := range item.HisPrescriptionProject {
  6514. // total = total + (subItem.Price * float64(subItem.Count))
  6515. // }
  6516. // }
  6517. // }
  6518. //
  6519. // for _, item := range prescriptions {
  6520. // for _, subItem := range item.HisAdditionalCharge {
  6521. // total = total + (subItem.Price * float64(subItem.Count))
  6522. // }
  6523. // }
  6524. //
  6525. // allTotal := fmt.Sprintf("%.2f", total)
  6526. // var rf []*ResultFive
  6527. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6528. // psn_no := order_src.PsnNo
  6529. // mdtrt_id := order_src.MdtrtId
  6530. // chrg_bchno := order_src.Number
  6531. // cert_no := order_src.Certno
  6532. // insutype := rf[0].Insutype
  6533. //
  6534. // if his.IdCardType == 1 {
  6535. // cert_no = his.MedicalInsuranceNumber
  6536. // } else {
  6537. // cert_no = his.Certno
  6538. // }
  6539. //
  6540. // 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)
  6541. // var dat map[string]interface{}
  6542. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6543. // fmt.Println(dat)
  6544. // } else {
  6545. // fmt.Println(err)
  6546. // }
  6547. //
  6548. // userJSONBytes, _ := json.Marshal(dat)
  6549. //
  6550. //
  6551. //
  6552. // var res ResultSeven
  6553. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6554. // utils.ErrorLog("解析失败:%v", err)
  6555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6556. // return
  6557. // }
  6558. // if res.Infcode == -1 {
  6559. // errlog := &models.HisOrderError{
  6560. // UserOrgId: adminUser.CurrentOrgId,
  6561. // Ctime: time.Now().Unix(),
  6562. // Mtime: time.Now().Unix(),
  6563. // Number: chrg_bchno,
  6564. // ErrMsg: res.ErrMsg,
  6565. // Status: 1,
  6566. // PatientId: id,
  6567. // RecordTime: recordDateTime,
  6568. // Stage: 6,
  6569. // }
  6570. // service.CreateErrMsgLog(errlog)
  6571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6572. // return
  6573. // } else {
  6574. // order_src.OrderStatus = 2
  6575. // order_src.PayWay = pay_way
  6576. // order_src.PayPrice = pay_price
  6577. // order_src.PayCardNo = pay_card_no
  6578. // order_src.DiscountPrice = discount_price
  6579. // order_src.PreferentialPrice = preferential_price
  6580. // order_src.RealityPrice = reality_price
  6581. // order_src.FoundPrice = found_price
  6582. // order_src.MedicalInsurancePrice = medical_insurance_price
  6583. // order_src.PrivatePrice = private_price
  6584. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6585. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6586. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6587. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6588. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6589. // order_src.Certno = res.Output.Setlinfo.Certno
  6590. // order_src.Gend = res.Output.Setlinfo.Gend
  6591. // order_src.Naty = res.Output.Setlinfo.Naty
  6592. // order_src.Age = res.Output.Setlinfo.Age
  6593. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6594. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6595. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6596. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6597. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6598. // order_src.MedType = res.Output.Setlinfo.MedType
  6599. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6600. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6601. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6602. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6603. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6604. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6605. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6606. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6607. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6608. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6609. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6610. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6611. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6612. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6613. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6614. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6615. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6616. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6617. // order_src.Balc = res.Output.Setlinfo.Balc
  6618. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6619. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6620. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6621. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6622. // order_src.Creator = order_src.Creator
  6623. // order_src.Modify = roles.ID
  6624. // order_src.RequestLog = src_resquest
  6625. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6626. // detailStr := string(setlDetail)
  6627. // order_src.SetlDetail = detailStr
  6628. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6629. // err = service.UpDateOrder(order_src)
  6630. //
  6631. // if err == nil {
  6632. // c.ServeSuccessJSON(map[string]interface{}{
  6633. // "msg": "结算成功",
  6634. // })
  6635. // } else {
  6636. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6637. // return
  6638. // }
  6639. // }
  6640. // }
  6641. //}
  6642. //退款
  6643. func (c *HisApiController) Refund() {
  6644. order_id, _ := c.GetInt64("order_id")
  6645. admin_user_id, _ := c.GetInt64("admin_user_id")
  6646. adminUser := c.GetAdminUserInfo()
  6647. var order models.HisOrder
  6648. order, _ = service.GetHisOrderByID(order_id)
  6649. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6650. if order.ID == 0 {
  6651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6652. return
  6653. }
  6654. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6655. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6656. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6657. if config.IsOpen == 1 { //对接了医保,走医保流程
  6658. var res ResultSixteen
  6659. var resSixteen10265 ResultSixteen10265
  6660. var src_resquest string
  6661. var result string
  6662. if miConfig.MdtrtareaAdmvs == "421300" {
  6663. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6664. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6665. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6666. resp3, requestErr3 := http.Get(api3)
  6667. if requestErr3 != nil {
  6668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6669. return
  6670. }
  6671. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6672. if ioErr3 != nil {
  6673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6675. return
  6676. }
  6677. var respJSON3 map[string]interface{}
  6678. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6681. return
  6682. }
  6683. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6684. userJSONBytes3, _ := json.Marshal(respJSON3)
  6685. fmt.Println("log")
  6686. fmt.Println(string(userJSONBytes3))
  6687. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6688. utils.ErrorLog("解析失败:%v", err)
  6689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6690. return
  6691. }
  6692. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6693. var api3 string
  6694. if miConfig.MdtrtareaAdmvs == "320921" {
  6695. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6696. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6697. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6698. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6699. } else {
  6700. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6701. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6702. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6703. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6704. }
  6705. resp3, requestErr3 := http.Get(api3)
  6706. if requestErr3 != nil {
  6707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6708. return
  6709. }
  6710. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6711. if ioErr3 != nil {
  6712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6714. return
  6715. }
  6716. var respJSON3 map[string]interface{}
  6717. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6720. return
  6721. }
  6722. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6723. userJSONBytes3, _ := json.Marshal(respJSON3)
  6724. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6725. utils.ErrorLog("解析失败:%v", err)
  6726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6727. return
  6728. }
  6729. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6730. res.Output = resSixteen10265.Output
  6731. res.ErrMsg = resSixteen10265.ErrMsg
  6732. res.Cainfo = resSixteen10265.Cainfo
  6733. res.WarnMsg = resSixteen10265.WarnMsg
  6734. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6735. res.Infcode = infocode
  6736. } else {
  6737. if miConfig.Code == "H15049901371" {
  6738. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6739. var dat map[string]interface{}
  6740. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6741. fmt.Println(dat)
  6742. } else {
  6743. fmt.Println(err)
  6744. }
  6745. saveLog(result, src_resquest, "2208", "退费")
  6746. userJSONBytes, _ := json.Marshal(dat)
  6747. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6748. utils.ErrorLog("解析失败:%v", err)
  6749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6750. return
  6751. }
  6752. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6753. res.Output = resSixteen10265.Output
  6754. res.ErrMsg = resSixteen10265.ErrMsg
  6755. res.Cainfo = resSixteen10265.Cainfo
  6756. res.WarnMsg = resSixteen10265.WarnMsg
  6757. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6758. res.Infcode = infocode
  6759. } else {
  6760. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6761. var dat map[string]interface{}
  6762. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6763. fmt.Println(dat)
  6764. } else {
  6765. fmt.Println(err)
  6766. }
  6767. saveLog(result, src_resquest, "2208", "退费")
  6768. userJSONBytes, _ := json.Marshal(dat)
  6769. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6770. utils.ErrorLog("解析失败:%v", err)
  6771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6772. return
  6773. }
  6774. }
  6775. }
  6776. if res.Infcode == 0 {
  6777. var res2 ResultSix
  6778. var resSix10265 ResultSix10265
  6779. if miConfig.MdtrtareaAdmvs == "421300" {
  6780. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6781. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6782. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6783. resp3, requestErr3 := http.Get(api3)
  6784. if requestErr3 != nil {
  6785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6786. return
  6787. }
  6788. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6789. if ioErr3 != nil {
  6790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6792. return
  6793. }
  6794. var respJSON3 map[string]interface{}
  6795. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6798. return
  6799. }
  6800. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6801. userJSONBytes3, _ := json.Marshal(respJSON3)
  6802. fmt.Println("log")
  6803. fmt.Println(string(userJSONBytes3))
  6804. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6805. utils.ErrorLog("解析失败:%v", err)
  6806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6807. return
  6808. }
  6809. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6810. var api3 string
  6811. if miConfig.MdtrtareaAdmvs == "320921" {
  6812. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6813. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6814. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6815. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6816. } else {
  6817. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6818. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6819. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6820. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6821. }
  6822. resp3, requestErr3 := http.Get(api3)
  6823. if requestErr3 != nil {
  6824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6825. return
  6826. }
  6827. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6828. if ioErr3 != nil {
  6829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6831. return
  6832. }
  6833. var respJSON3 map[string]interface{}
  6834. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6837. return
  6838. }
  6839. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6840. userJSONBytes3, _ := json.Marshal(respJSON3)
  6841. fmt.Println("log")
  6842. fmt.Println(string(userJSONBytes3))
  6843. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6844. utils.ErrorLog("解析失败:%v", err)
  6845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6846. return
  6847. }
  6848. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6849. res2.Output = resSix10265.Output
  6850. res2.ErrMsg = resSix10265.ErrMsg
  6851. res2.Cainfo = resSix10265.Cainfo
  6852. res2.WarnMsg = resSix10265.WarnMsg
  6853. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6854. res2.Infcode = infocode
  6855. } else {
  6856. if miConfig.Code == "H15049901371" {
  6857. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6858. var dat map[string]interface{}
  6859. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6860. fmt.Println(dat)
  6861. } else {
  6862. fmt.Println(err)
  6863. }
  6864. saveLog(result2, src_request, "2205", "撤销明细")
  6865. userJSONBytes, _ := json.Marshal(dat)
  6866. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6867. utils.ErrorLog("解析失败:%v", err)
  6868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6869. return
  6870. }
  6871. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6872. res2.Output = resSix10265.Output
  6873. res2.ErrMsg = resSix10265.ErrMsg
  6874. res2.Cainfo = resSix10265.Cainfo
  6875. res2.WarnMsg = resSix10265.WarnMsg
  6876. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6877. res2.Infcode = infocode
  6878. } else {
  6879. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6880. var dat map[string]interface{}
  6881. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6882. fmt.Println(dat)
  6883. } else {
  6884. fmt.Println(err)
  6885. }
  6886. saveLog(result2, src_request, "2205", "撤销明细")
  6887. userJSONBytes, _ := json.Marshal(dat)
  6888. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6889. utils.ErrorLog("解析失败:%v", err)
  6890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6891. return
  6892. }
  6893. }
  6894. }
  6895. if res2.Infcode == 0 {
  6896. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6897. if err == nil {
  6898. c.ServeSuccessJSON(map[string]interface{}{
  6899. "msg": "退费成功",
  6900. })
  6901. } else {
  6902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6903. return
  6904. }
  6905. } else {
  6906. c.ServeSuccessJSON(map[string]interface{}{
  6907. "code": -10,
  6908. "msg": res2.ErrMsg,
  6909. })
  6910. }
  6911. } else {
  6912. c.ServeSuccessJSON(map[string]interface{}{
  6913. "code": -10,
  6914. "msg": res.ErrMsg,
  6915. })
  6916. }
  6917. }
  6918. }
  6919. func (c *HisApiController) RefundNumber() {
  6920. record_time := c.GetString("record_time")
  6921. //patient_id, _ := c.GetInt64("patient_id")
  6922. admin_user_id, _ := c.GetInt64("admin_user_id")
  6923. his_patient_id, _ := c.GetInt64("id")
  6924. timeLayout := "2006-01-02"
  6925. loc, _ := time.LoadLocation("Local")
  6926. adminUser := c.GetAdminUserInfo()
  6927. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6928. fmt.Println(err)
  6929. if err != nil {
  6930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6931. return
  6932. }
  6933. recordDateTime := theTime.Unix()
  6934. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6935. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6936. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6937. //order, _ := service.GetHisOrderByID(order_id)
  6938. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6939. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6940. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6941. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6942. if count > 0 {
  6943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6944. return
  6945. }
  6946. if config.IsOpen == 1 { //对接了医保,走医保流程
  6947. var res2 ResultSix
  6948. var resSix10265 ResultSix10265
  6949. if miConfig.MdtrtareaAdmvs == "421300" {
  6950. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6951. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6952. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6953. resp3, requestErr3 := http.Get(api3)
  6954. if requestErr3 != nil {
  6955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6956. return
  6957. }
  6958. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6959. if ioErr3 != nil {
  6960. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6962. return
  6963. }
  6964. var respJSON3 map[string]interface{}
  6965. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6968. return
  6969. }
  6970. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6971. userJSONBytes3, _ := json.Marshal(respJSON3)
  6972. fmt.Println("log")
  6973. fmt.Println(string(userJSONBytes3))
  6974. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6975. utils.ErrorLog("解析失败:%v", err)
  6976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6977. return
  6978. }
  6979. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6980. var api3 string
  6981. if miConfig.MdtrtareaAdmvs == "320921" {
  6982. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6983. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6984. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6985. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6986. } else {
  6987. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6988. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6989. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6990. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6991. }
  6992. resp3, requestErr3 := http.Get(api3)
  6993. if requestErr3 != nil {
  6994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6995. return
  6996. }
  6997. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6998. if ioErr3 != nil {
  6999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7001. return
  7002. }
  7003. var respJSON3 map[string]interface{}
  7004. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7007. return
  7008. }
  7009. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7010. userJSONBytes3, _ := json.Marshal(respJSON3)
  7011. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7012. utils.ErrorLog("解析失败:%v", err)
  7013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7014. return
  7015. }
  7016. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7017. res2.Output = resSix10265.Output
  7018. res2.ErrMsg = resSix10265.ErrMsg
  7019. res2.Cainfo = resSix10265.Cainfo
  7020. res2.WarnMsg = resSix10265.WarnMsg
  7021. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7022. res2.Infcode = infocode
  7023. } else {
  7024. var api3 string
  7025. if miConfig.Code == "H15049901371" {
  7026. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7027. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7028. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7029. } else {
  7030. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7031. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7032. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7033. }
  7034. resp3, requestErr3 := http.Get(api3)
  7035. if requestErr3 != nil {
  7036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7037. return
  7038. }
  7039. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7040. if ioErr3 != nil {
  7041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7043. return
  7044. }
  7045. var respJSON3 map[string]interface{}
  7046. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7049. return
  7050. }
  7051. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7052. userJSONBytes3, _ := json.Marshal(respJSON3)
  7053. if miConfig.Code == "H15049901371" {
  7054. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7055. utils.ErrorLog("解析失败:%v", err)
  7056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7057. return
  7058. }
  7059. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7060. res2.Output = resSix10265.Output
  7061. res2.ErrMsg = resSix10265.ErrMsg
  7062. res2.Cainfo = resSix10265.Cainfo
  7063. res2.WarnMsg = resSix10265.WarnMsg
  7064. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7065. res2.Infcode = infocode
  7066. } else {
  7067. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7068. utils.ErrorLog("解析失败:%v", err)
  7069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7070. return
  7071. }
  7072. }
  7073. }
  7074. if res2.Infcode == 0 {
  7075. if err == nil {
  7076. c.ServeSuccessJSON(map[string]interface{}{
  7077. "msg": "退号成功",
  7078. })
  7079. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7080. } else {
  7081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7082. return
  7083. }
  7084. } else {
  7085. c.ServeSuccessJSON(map[string]interface{}{
  7086. "code": -10,
  7087. "msg": res2.ErrMsg,
  7088. })
  7089. }
  7090. } else {
  7091. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7092. //if err == nil {
  7093. // c.ServeSuccessJSON(map[string]interface{}{
  7094. // "msg": "退费成功",
  7095. // })
  7096. //} else {
  7097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7098. // return
  7099. //}
  7100. }
  7101. }
  7102. func (c *HisApiController) RefundDetail() {
  7103. order_id, _ := c.GetInt64("order_id")
  7104. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7105. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7106. number := c.GetString("number")
  7107. record_time := c.GetString("record_time")
  7108. patient_id, _ := c.GetInt64("patient_id")
  7109. //med_type, _ := c.GetInt64("med_type")
  7110. timeLayout := "2006-01-02"
  7111. loc, _ := time.LoadLocation("Local")
  7112. adminUser := c.GetAdminUserInfo()
  7113. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7114. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7115. fmt.Println(err)
  7116. if err != nil {
  7117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7118. return
  7119. }
  7120. recordDateTime := theTime.Unix()
  7121. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7122. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7123. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7124. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7125. var order models.HisOrder
  7126. order, _ = service.GetHisOrderByID(order_id)
  7127. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7128. if config.IsOpen == 1 { //对接了医保,走医保流程
  7129. var res2 ResultSix
  7130. if miConfig.MdtrtareaAdmvs == "421300" {
  7131. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7132. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7133. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7134. resp3, requestErr3 := http.Get(api3)
  7135. if requestErr3 != nil {
  7136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7137. return
  7138. }
  7139. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7140. if ioErr3 != nil {
  7141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7143. return
  7144. }
  7145. var respJSON3 map[string]interface{}
  7146. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7149. return
  7150. }
  7151. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7152. userJSONBytes3, _ := json.Marshal(respJSON3)
  7153. fmt.Println("log")
  7154. fmt.Println(string(userJSONBytes3))
  7155. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7156. utils.ErrorLog("解析失败:%v", err)
  7157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7158. return
  7159. }
  7160. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7161. if err == nil {
  7162. c.ServeSuccessJSON(map[string]interface{}{
  7163. "msg": "撤销明细成功",
  7164. })
  7165. return
  7166. } else {
  7167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7168. return
  7169. }
  7170. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7171. var resSix10265 ResultSix10265
  7172. var api3 string
  7173. if miConfig.MdtrtareaAdmvs == "320921" {
  7174. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7175. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7176. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7177. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7178. } else {
  7179. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7180. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7181. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7182. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7183. }
  7184. resp3, requestErr3 := http.Get(api3)
  7185. if requestErr3 != nil {
  7186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7187. return
  7188. }
  7189. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7190. if ioErr3 != nil {
  7191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7193. return
  7194. }
  7195. var respJSON3 map[string]interface{}
  7196. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7199. return
  7200. }
  7201. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7202. userJSONBytes3, _ := json.Marshal(respJSON3)
  7203. fmt.Println("log")
  7204. fmt.Println(string(userJSONBytes3))
  7205. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7206. utils.ErrorLog("解析失败:%v", err)
  7207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7208. return
  7209. }
  7210. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7211. res2.Output = resSix10265.Output
  7212. res2.ErrMsg = resSix10265.ErrMsg
  7213. res2.Cainfo = resSix10265.Cainfo
  7214. res2.WarnMsg = resSix10265.WarnMsg
  7215. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7216. res2.Infcode = infocode
  7217. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7218. if err == nil {
  7219. c.ServeSuccessJSON(map[string]interface{}{
  7220. "msg": "撤销明细成功",
  7221. })
  7222. return
  7223. } else {
  7224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7225. return
  7226. }
  7227. } else {
  7228. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7229. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7230. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7231. resp2, requestErr2 := http.Get(api2)
  7232. if requestErr2 != nil {
  7233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7234. return
  7235. }
  7236. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7237. if ioErr2 != nil {
  7238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7240. return
  7241. }
  7242. var respJSON2 map[string]interface{}
  7243. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7246. return
  7247. }
  7248. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7249. if err == nil {
  7250. c.ServeSuccessJSON(map[string]interface{}{
  7251. "msg": "撤销明细成功",
  7252. })
  7253. return
  7254. } else {
  7255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7256. return
  7257. }
  7258. }
  7259. } else {
  7260. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7261. if err == nil {
  7262. c.ServeSuccessJSON(map[string]interface{}{
  7263. "msg": "退费成功",
  7264. })
  7265. } else {
  7266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7267. return
  7268. }
  7269. }
  7270. }
  7271. //对账
  7272. func (c *HisApiController) GetCheckAccount() {
  7273. start_time := c.GetString("start_time")
  7274. end_time := c.GetString("end_time")
  7275. insutype := c.GetString("insutype")
  7276. clr_type := c.GetString("clr_type")
  7277. clr_org := c.GetString("clr_optins")
  7278. admin_user_id, _ := c.GetInt64("admin_user_id")
  7279. adminUser := c.GetAdminUserInfo()
  7280. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7281. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7282. if len(clr_org) == 0 {
  7283. clr_org = miConfig.MdtrtareaAdmvs
  7284. }
  7285. timeLayout := "2006-01-02"
  7286. loc, _ := time.LoadLocation("Local")
  7287. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7288. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7289. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7290. fixmedins_setl_cnt := int64(len(orders))
  7291. var medfee_sumamt float64
  7292. var acct_pay float64
  7293. var fund_pay_sumamt float64
  7294. for _, item := range orders {
  7295. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7296. acct_pay = acct_pay + item.AcctPay
  7297. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7298. }
  7299. var user_name string
  7300. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7301. if role.ID == 0 {
  7302. user_name = "xxx"
  7303. } else {
  7304. user_name = role.UserName
  7305. }
  7306. var res ResultEight
  7307. var res10188 ResultEightFor10188
  7308. if config.IsOpen == 1 {
  7309. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7310. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7311. "insutype=" + insutype +
  7312. "&clr_type=" + "11" +
  7313. "&setl_optins=" + clr_org +
  7314. "&stmt_begndate=" + start_time +
  7315. "&stm_enddate=" + end_time +
  7316. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7317. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7318. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7319. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7320. "&fixmedins_code=" + miConfig.Code +
  7321. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7322. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7323. "&secret_key=" + miConfig.SecretKey +
  7324. "&org_name=" + miConfig.OrgName +
  7325. "&doctor=" + user_name +
  7326. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7327. fmt.Println(api)
  7328. resp, requestErr := http.Get(api)
  7329. if requestErr != nil {
  7330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7331. return
  7332. }
  7333. body, ioErr := ioutil.ReadAll(resp.Body)
  7334. fmt.Println(body)
  7335. if ioErr != nil {
  7336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7338. return
  7339. }
  7340. var respJSON map[string]interface{}
  7341. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7344. return
  7345. }
  7346. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7347. userJSONBytes, _ := json.Marshal(respJSON)
  7348. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7349. utils.ErrorLog("解析失败:%v", err)
  7350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7351. return
  7352. }
  7353. res.InfRefmsgid = res10188.InfRefmsgid
  7354. res.Output = res10188.Output
  7355. res.ErrMsg = res10188.ErrMsg
  7356. res.Cainfo = res10188.Cainfo
  7357. res.WarnMsg = res10188.WarnMsg
  7358. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7359. res.Infcode = infocode
  7360. } else {
  7361. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7362. "insutype=" + insutype +
  7363. "&clr_type=" + clr_type +
  7364. "&setl_optins=" + clr_org +
  7365. "&stmt_begndate=" + start_time +
  7366. "&stm_enddate=" + end_time +
  7367. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7368. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7369. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7370. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7371. "&fixmedins_code=" + miConfig.Code +
  7372. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7373. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7374. "&secret_key=" + miConfig.SecretKey +
  7375. "&org_name=" + miConfig.OrgName +
  7376. "&doctor=" + user_name
  7377. fmt.Println(api)
  7378. resp, requestErr := http.Get(api)
  7379. if requestErr != nil {
  7380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7381. return
  7382. }
  7383. body, ioErr := ioutil.ReadAll(resp.Body)
  7384. fmt.Println(body)
  7385. if ioErr != nil {
  7386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7388. return
  7389. }
  7390. var respJSON map[string]interface{}
  7391. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7394. return
  7395. }
  7396. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7397. userJSONBytes, _ := json.Marshal(respJSON)
  7398. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7399. utils.ErrorLog("解析失败:%v", err)
  7400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7401. return
  7402. }
  7403. }
  7404. if res.Infcode == 0 {
  7405. if res.Output.Stmtinfo.StmtRslt == "0" {
  7406. micc := &models.MedicalInsuranceCostCompare{
  7407. StartTime: startime.Unix(),
  7408. EndTime: endtime.Unix(),
  7409. Insutype: insutype,
  7410. CheckType: 1,
  7411. Num: fixmedins_setl_cnt,
  7412. Mtime: time.Now().Unix(),
  7413. Status: 1,
  7414. UserOrgId: adminUser.CurrentOrgId,
  7415. CostTotal: medfee_sumamt,
  7416. FuncTotal: fund_pay_sumamt,
  7417. PsnPay: acct_pay,
  7418. Creator: admin_user_id,
  7419. Ctime: time.Now().Unix(),
  7420. ClrType: clr_type,
  7421. }
  7422. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7423. if err == nil {
  7424. c.ServeSuccessJSON(map[string]interface{}{
  7425. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7426. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7427. })
  7428. } else {
  7429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7430. }
  7431. } else {
  7432. c.ServeSuccessJSON(map[string]interface{}{
  7433. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7434. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7435. })
  7436. }
  7437. } else {
  7438. c.ServeSuccessJSON(map[string]interface{}{
  7439. "code": -10,
  7440. "msg": res.ErrMsg,
  7441. })
  7442. }
  7443. }
  7444. }
  7445. func (c *HisApiController) Check310() {
  7446. adminUser := c.GetAdminUserInfo()
  7447. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7448. var user_name string
  7449. user_name = "高慧裕"
  7450. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7451. "insutype=" + "310" +
  7452. "&clr_type=" + "" +
  7453. "&setl_optins=" + "441202" +
  7454. "&stmt_begndate=" + "2022-03-01" +
  7455. "&stm_enddate=" + "2022-03-31" +
  7456. "&medfee_sumamt=" + "194930.12" +
  7457. "&fund_pay_sumamt=" + "188741.46" +
  7458. "&acct_pay=" + "0" +
  7459. "&fixmedins_setl_cnt=" + "452" +
  7460. "&fixmedins_code=" + miConfig.Code +
  7461. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7462. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7463. "&secret_key=" + miConfig.SecretKey +
  7464. "&org_name=" + miConfig.OrgName +
  7465. "&doctor=" + user_name
  7466. fmt.Println(api)
  7467. resp, requestErr := http.Get(api)
  7468. if requestErr != nil {
  7469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7470. return
  7471. }
  7472. body, ioErr := ioutil.ReadAll(resp.Body)
  7473. fmt.Println(body)
  7474. if ioErr != nil {
  7475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7477. return
  7478. }
  7479. var respJSON map[string]interface{}
  7480. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7483. return
  7484. }
  7485. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7486. userJSONBytes, _ := json.Marshal(respJSON)
  7487. var res ResultEight
  7488. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7489. utils.ErrorLog("解析失败:%v", err)
  7490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7491. return
  7492. }
  7493. }
  7494. func (c *HisApiController) Check390() {
  7495. adminUser := c.GetAdminUserInfo()
  7496. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7497. var user_name string
  7498. user_name = "高慧裕"
  7499. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7500. "insutype=" + "390" +
  7501. "&clr_type=" + "" +
  7502. "&setl_optins=" + "441202" +
  7503. "&stmt_begndate=" + "2022-03-01" +
  7504. "&stm_enddate=" + "2022-03-31" +
  7505. "&medfee_sumamt=" + "1068448.89" +
  7506. "&fund_pay_sumamt=" + "1014677.62" +
  7507. "&acct_pay=" + "0" +
  7508. "&fixmedins_setl_cnt=" + "1950" +
  7509. "&fixmedins_code=" + miConfig.Code +
  7510. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7511. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7512. "&secret_key=" + miConfig.SecretKey +
  7513. "&org_name=" + miConfig.OrgName +
  7514. "&doctor=" + user_name
  7515. fmt.Println(api)
  7516. resp, requestErr := http.Get(api)
  7517. if requestErr != nil {
  7518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7519. return
  7520. }
  7521. body, ioErr := ioutil.ReadAll(resp.Body)
  7522. fmt.Println(body)
  7523. if ioErr != nil {
  7524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7526. return
  7527. }
  7528. var respJSON map[string]interface{}
  7529. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7532. return
  7533. }
  7534. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7535. userJSONBytes, _ := json.Marshal(respJSON)
  7536. var res ResultEight
  7537. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7538. utils.ErrorLog("解析失败:%v", err)
  7539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7540. return
  7541. }
  7542. }
  7543. //对账明细
  7544. func (c *HisApiController) GetCheckDetailAccount() {
  7545. start_time := c.GetString("start_time")
  7546. end_time := c.GetString("end_time")
  7547. admin_user_id, _ := c.GetInt64("admin_user_id")
  7548. adminUser := c.GetAdminUserInfo()
  7549. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7550. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7551. timeLayout := "2006-01-02"
  7552. loc, _ := time.LoadLocation("Local")
  7553. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7554. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7555. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7556. Mkdir(miConfig.OrgName)
  7557. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7558. file_name := file + ".txt"
  7559. zip_name := file + ".zip"
  7560. zip_path := miConfig.OrgName + "/" + zip_name
  7561. file_path := miConfig.OrgName + "/" + file_name
  7562. decimal.DivisionPrecision = 2
  7563. var medfee_sumamt float64
  7564. var psn_cash_pay float64
  7565. var fund_pay_sumamt float64
  7566. fixmedins_setl_cnt := int64(len(orders))
  7567. for _, item := range orders {
  7568. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7569. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7570. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7571. }
  7572. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7573. defer f.Close()
  7574. if err != nil {
  7575. fmt.Println(err.Error())
  7576. } else {
  7577. for _, item := range orders {
  7578. var refd_setl_flag string
  7579. if item.OrderStatus == 2 {
  7580. refd_setl_flag = "0"
  7581. var str string
  7582. str = item.SetlId + " " +
  7583. item.MdtrtId + " " +
  7584. item.PsnNo + " " +
  7585. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7586. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7587. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7588. _, err = f.Write([]byte(str))
  7589. }
  7590. if item.OrderStatus == 3 {
  7591. var str string
  7592. str = item.SetlId + " " +
  7593. item.MdtrtId + " " +
  7594. item.PsnNo + " " +
  7595. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7596. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7597. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7598. _, err = f.Write([]byte(str))
  7599. var str2 string
  7600. str2 = item.SetlId + " " +
  7601. item.MdtrtId + " " +
  7602. item.PsnNo + " " +
  7603. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7604. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7605. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7606. _, err = f.Write([]byte(str2))
  7607. }
  7608. }
  7609. }
  7610. Zip(file_path, zip_path)
  7611. fmt.Println(ReadFile(zip_path))
  7612. fmt.Println(string(ReadFile(zip_path)))
  7613. if config.IsOpen == 1 {
  7614. var user_name string
  7615. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7616. if role.ID == 0 {
  7617. user_name = "管理员"
  7618. } else {
  7619. user_name = role.UserName
  7620. }
  7621. baseParams := models.BaseParams{
  7622. SecretKey: miConfig.SecretKey,
  7623. FixmedinsCode: miConfig.Code,
  7624. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7625. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7626. OrgName: miConfig.OrgName,
  7627. Doctor: user_name,
  7628. }
  7629. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7630. var dat map[string]interface{}
  7631. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7632. fmt.Println(dat)
  7633. } else {
  7634. fmt.Println(err)
  7635. }
  7636. userJSONBytes, _ := json.Marshal(dat)
  7637. var res ResultNine
  7638. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7639. utils.ErrorLog("解析失败:%v", err)
  7640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7641. return
  7642. }
  7643. if res.Infcode == 0 {
  7644. fileNo := res.Output.FileQuryNo
  7645. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7646. "file_qury_no=" + fileNo +
  7647. "&setl_optins=" + "定点医保中心" +
  7648. "&stmt_begndate=" + start_time +
  7649. "&stm_enddate=" + end_time +
  7650. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7651. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7652. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7653. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7654. "&fixmedins_code=" + miConfig.Code +
  7655. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7656. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7657. "&secret_key=" + miConfig.SecretKey +
  7658. "&org_name=" + miConfig.OrgName +
  7659. "&doctor=" + user_name
  7660. resp, requestErr := http.Get(api)
  7661. if requestErr != nil {
  7662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7663. return
  7664. }
  7665. body, ioErr := ioutil.ReadAll(resp.Body)
  7666. if ioErr != nil {
  7667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7669. return
  7670. }
  7671. var respJSON map[string]interface{}
  7672. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7675. return
  7676. }
  7677. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7678. userJSONBytes, _ := json.Marshal(respJSON)
  7679. var res ResultTen
  7680. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7681. utils.ErrorLog("解析失败:%v", err)
  7682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7683. return
  7684. }
  7685. if res.Infcode == 0 {
  7686. service.Gdyb9102(baseParams, zip_name, fileNo)
  7687. micc := &models.MedicalInsuranceCostCompare{
  7688. StartTime: startime.Unix(),
  7689. EndTime: endtime.Unix(),
  7690. Insutype: "0",
  7691. CheckType: 2,
  7692. Num: fixmedins_setl_cnt,
  7693. Mtime: time.Now().Unix(),
  7694. Status: 1,
  7695. UserOrgId: adminUser.CurrentOrgId,
  7696. CostTotal: medfee_sumamt,
  7697. FuncTotal: fund_pay_sumamt,
  7698. PsnPay: psn_cash_pay,
  7699. Creator: admin_user_id,
  7700. Ctime: time.Now().Unix(),
  7701. }
  7702. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7703. c.ServeSuccessJSON(map[string]interface{}{
  7704. "msg": "明细对账成功",
  7705. })
  7706. }
  7707. } else {
  7708. }
  7709. }
  7710. }
  7711. type CustomOrderInfo struct {
  7712. Name string
  7713. Spec string
  7714. Unit string
  7715. Count float64
  7716. Price float64
  7717. Total float64
  7718. }
  7719. func (c *HisApiController) GetSettleAccounts() {
  7720. //id, _ := c.GetInt64("id")
  7721. //record_time := c.GetString("record_time")
  7722. order_id, _ := c.GetInt64("order_id")
  7723. admin_user_id, _ := c.GetInt64("admin_user_id")
  7724. //timeLayout := "2006-01-02"
  7725. //loc, _ := time.LoadLocation("Local")
  7726. //
  7727. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7728. //if err != nil {
  7729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7730. // return
  7731. //}
  7732. //recordDateTime := theTime.Unix()
  7733. adminUser := c.GetAdminUserInfo()
  7734. order, _ := service.GetHisOrderByID(order_id)
  7735. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7736. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7737. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7738. orderInfos = append(orderInfos, orderInfos_two...)
  7739. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7740. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7741. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7742. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7743. //var config []*models.HisXtDiagnoseConfig
  7744. var name string
  7745. for _, item := range diagnosis_ids {
  7746. id, _ := strconv.ParseInt(item, 10, 64)
  7747. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7748. if len(name) == 0 {
  7749. name = diagnosisConfig.ClassName
  7750. } else {
  7751. name = name + "," + diagnosisConfig.ClassName
  7752. }
  7753. }
  7754. var bedCostTotal float64 = 0 //床位总费
  7755. var bedCostSelfTotal float64 = 0 //床位自费
  7756. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7757. var operationCostTotal float64 = 0 //手术费
  7758. var operationCostSelfTotal float64 = 0 //手术费
  7759. var operationCostPartSelfTotal float64 = 0 //手术费
  7760. var otherCostTotal float64 = 0 //其他费用
  7761. var otherCostSelfTotal float64 = 0 //其他费用
  7762. var otherCostPartSelfTotal float64 = 0 //其他费用
  7763. var materialCostTotal float64 = 0 //材料费
  7764. var materialCostSelfTotal float64 = 0 //材料费
  7765. var materialCostPartSelfTotal float64 = 0 //材料费
  7766. var westernMedicineCostTotal float64 = 0 //西药费
  7767. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7768. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7769. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7770. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7771. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7772. var checkCostTotal float64 = 0 //检查费
  7773. var checkCostSelfTotal float64 = 0 //检查费
  7774. var checkCostPartSelfTotal float64 = 0 //检查费
  7775. var laboratoryCostTotal float64 = 0 //化验费
  7776. var laboratoryCostSelfTotal float64 = 0 //化验费
  7777. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7778. var treatCostTotal float64 = 0 //治疗费用
  7779. var treatCostSelfTotal float64 = 0 //治疗费用
  7780. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7781. decimal.DivisionPrecision = 2
  7782. for _, item := range orderInfos {
  7783. if item.MedChrgitmType == "01" { //床位费
  7784. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7785. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7786. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7787. }
  7788. if item.MedChrgitmType == "03" { //检查费
  7789. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7790. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7791. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7792. }
  7793. if item.MedChrgitmType == "04" { //化验费
  7794. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7795. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7796. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7797. }
  7798. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  7799. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7800. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7801. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7802. }
  7803. if item.MedChrgitmType == "06" { //手术费
  7804. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7805. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7806. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7807. }
  7808. if item.MedChrgitmType == "08" { //材料费
  7809. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7810. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7811. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7812. }
  7813. if item.MedChrgitmType == "09" { //西药费
  7814. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7815. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7816. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7817. }
  7818. if item.MedChrgitmType == "11" { //中成费
  7819. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7820. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7821. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7822. }
  7823. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  7824. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7825. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7826. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7827. }
  7828. }
  7829. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7830. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7831. var user_name string
  7832. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7833. if role.ID == 0 {
  7834. user_name = "管理员"
  7835. } else {
  7836. user_name = role.UserName
  7837. }
  7838. baseParams := models.BaseParams{
  7839. SecretKey: miConfig.SecretKey,
  7840. FixmedinsCode: miConfig.Code,
  7841. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7842. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7843. OrgName: miConfig.OrgName,
  7844. Doctor: user_name,
  7845. }
  7846. businessParams := models.BusinessParams{
  7847. PsnNo: order.PsnNo,
  7848. MdtrtId: order.MdtrtId,
  7849. SetlId: order.SetlId,
  7850. }
  7851. var res ResultEleven
  7852. var resEleven10265 ResultEleven10265
  7853. if config.IsOpen == 1 {
  7854. if miConfig.MdtrtareaAdmvs == "421300" {
  7855. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7856. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7857. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7858. resp, requestErr := http.Get(api)
  7859. if requestErr != nil {
  7860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7861. return
  7862. }
  7863. body, ioErr := ioutil.ReadAll(resp.Body)
  7864. if ioErr != nil {
  7865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7867. return
  7868. }
  7869. var respJSON map[string]interface{}
  7870. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7873. return
  7874. }
  7875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7876. result, _ := json.Marshal(respJSON)
  7877. fmt.Println("log")
  7878. fmt.Println(string(result))
  7879. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7880. utils.ErrorLog("解析失败:%v", err)
  7881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7882. return
  7883. }
  7884. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7885. var api string
  7886. if miConfig.MdtrtareaAdmvs == "320921" {
  7887. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7888. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7889. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7890. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7891. } else {
  7892. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7893. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7894. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7895. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7896. }
  7897. resp, requestErr := http.Get(api)
  7898. if requestErr != nil {
  7899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7900. return
  7901. }
  7902. body, ioErr := ioutil.ReadAll(resp.Body)
  7903. if ioErr != nil {
  7904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7906. return
  7907. }
  7908. var respJSON map[string]interface{}
  7909. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7912. return
  7913. }
  7914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7915. result, _ := json.Marshal(respJSON)
  7916. fmt.Println("log")
  7917. fmt.Println(string(result))
  7918. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7919. utils.ErrorLog("解析失败:%v", err)
  7920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7921. return
  7922. }
  7923. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7924. res.Output = resEleven10265.Output
  7925. res.ErrMsg = resEleven10265.ErrMsg
  7926. res.Cainfo = resEleven10265.Cainfo
  7927. res.WarnMsg = resEleven10265.WarnMsg
  7928. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7929. res.Infcode = infocode
  7930. } else {
  7931. //result2 := service.Gdyb1101()
  7932. result2 := service.Gdyb5204(baseParams, businessParams)
  7933. saveLog(result2, "", "5204", "查询")
  7934. result := service.Gdyb5203(baseParams, businessParams)
  7935. var dat map[string]interface{}
  7936. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7937. fmt.Println(dat)
  7938. } else {
  7939. fmt.Println(err)
  7940. }
  7941. userJSONBytes, _ := json.Marshal(dat)
  7942. if miConfig.Code == "H15049901371" {
  7943. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7944. utils.ErrorLog("解析失败:%v", err)
  7945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7946. return
  7947. }
  7948. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7949. res.Output = resEleven10265.Output
  7950. res.ErrMsg = resEleven10265.ErrMsg
  7951. res.Cainfo = resEleven10265.Cainfo
  7952. res.WarnMsg = resEleven10265.WarnMsg
  7953. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7954. res.Infcode = infocode
  7955. } else {
  7956. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7957. utils.ErrorLog("解析失败:%v", err)
  7958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7959. return
  7960. }
  7961. }
  7962. }
  7963. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7964. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7965. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7966. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7967. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7968. var doctor_name string
  7969. if roles.ID == 0 {
  7970. doctor_name = "管理员"
  7971. } else {
  7972. doctor_name = roles.UserName
  7973. }
  7974. yiliao_leibie := ""
  7975. switch order.MedType {
  7976. case "11":
  7977. yiliao_leibie = "普通门诊"
  7978. break
  7979. case "12":
  7980. yiliao_leibie = "门诊挂号"
  7981. break
  7982. case "13":
  7983. yiliao_leibie = "急诊"
  7984. break
  7985. case "14":
  7986. yiliao_leibie = "门诊特殊病"
  7987. break
  7988. case "15":
  7989. yiliao_leibie = "门诊统筹"
  7990. break
  7991. case "16":
  7992. yiliao_leibie = "门诊慢性病"
  7993. break
  7994. case "21":
  7995. yiliao_leibie = "普通住院"
  7996. break
  7997. }
  7998. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7999. if res.Infcode == 0 {
  8000. c.ServeSuccessJSON(map[string]interface{}{
  8001. "diagnosis": name,
  8002. "order_infos": orderInfos,
  8003. "number": order.MdtrtId,
  8004. "date": order.SettleAccountsDate,
  8005. "charge_admin": charge_admin,
  8006. "printor_admin": printor_admin,
  8007. "info": res.Output.Setlinfo,
  8008. "bedCostTotal": bedCostTotal,
  8009. "bedCostSelfTotal": bedCostSelfTotal,
  8010. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8011. "operationCostTotal": operationCostTotal,
  8012. "operationCostSelfTotal": operationCostSelfTotal,
  8013. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8014. "otherCostTotal": otherCostTotal,
  8015. "otherCostSelfTotal": otherCostSelfTotal,
  8016. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8017. "materialCostTotal": materialCostTotal,
  8018. "materialCostSelfTotal": materialCostSelfTotal,
  8019. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8020. "westernMedicineCostTotal": westernMedicineCostTotal,
  8021. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8022. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8023. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8024. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8025. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8026. "checkCostTotal": checkCostTotal,
  8027. "checkCostSelfTotal": checkCostSelfTotal,
  8028. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8029. "laboratoryCostTotal": laboratoryCostTotal,
  8030. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8031. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8032. "treatCostTotal": treatCostTotal,
  8033. "treatCostSelfTotal": treatCostSelfTotal,
  8034. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8035. "doctor_code": adminRole_two.DoctorCode,
  8036. "doctor_name": doctor_name,
  8037. "health_card_no": order.PsnNo,
  8038. "department": departments.Name,
  8039. "yiliao_leibie": yiliao_leibie,
  8040. "after_money": order.AccountPrice,
  8041. "patient": patient,
  8042. "org_name": miConfig.OrgName,
  8043. "org_code": miConfig.Code,
  8044. "order_number": order.Number,
  8045. "his_hospital": his_hospital,
  8046. "his": his,
  8047. //"check_order_info": cus_slice,
  8048. })
  8049. }
  8050. }
  8051. }
  8052. func (c *HisApiController) CheckTreatment() {
  8053. patient_id, _ := c.GetInt64("patient_id")
  8054. id_card_no := c.GetString("id_card_no")
  8055. insutype := c.GetString("insutype")
  8056. med_type := c.GetString("med_type")
  8057. admin_user_id, _ := c.GetInt64("admin_user_id")
  8058. adminUser := c.GetAdminUserInfo()
  8059. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8060. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8061. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8062. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8063. if miConfig.MdtrtareaAdmvs == "421300" {
  8064. var res ResultTwo
  8065. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8066. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8067. "&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)
  8068. resp, requestErr := http.Get(api)
  8069. if requestErr != nil {
  8070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8071. return
  8072. }
  8073. body, ioErr := ioutil.ReadAll(resp.Body)
  8074. if ioErr != nil {
  8075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8077. return
  8078. }
  8079. var respJSON map[string]interface{}
  8080. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8083. return
  8084. }
  8085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8086. result, _ := json.Marshal(respJSON)
  8087. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8088. utils.ErrorLog("解析失败:%v", err)
  8089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8090. return
  8091. }
  8092. if res.Infcode == 0 {
  8093. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8094. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8095. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8096. resp, requestErr := http.Get(api)
  8097. if requestErr != nil {
  8098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8099. return
  8100. }
  8101. body, ioErr := ioutil.ReadAll(resp.Body)
  8102. if ioErr != nil {
  8103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8105. return
  8106. }
  8107. var respJSON map[string]interface{}
  8108. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8111. return
  8112. }
  8113. var res Result2001
  8114. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8115. result2, _ := json.Marshal(respJSON)
  8116. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8117. utils.ErrorLog("解析失败:%v", err)
  8118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8119. return
  8120. }
  8121. if res.Infcode == 0 {
  8122. c.ServeSuccessJSON(map[string]interface{}{
  8123. "msg": res.Output.Trtinfo,
  8124. })
  8125. }
  8126. } else {
  8127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8128. return
  8129. }
  8130. } else {
  8131. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8132. var dat map[string]interface{}
  8133. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8134. fmt.Println(dat)
  8135. } else {
  8136. fmt.Println(err)
  8137. }
  8138. userJSONBytes, _ := json.Marshal(dat)
  8139. var res ResultTwo
  8140. var res10265 ResultTwo10265
  8141. if miConfig.Code == "H15049901371" {
  8142. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8143. utils.ErrorLog("解析失败:%v", err)
  8144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8145. return
  8146. }
  8147. res.ErrMsg = res10265.ErrMsg
  8148. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8149. res.Infcode = infocode
  8150. res.Output = res10265.Output
  8151. res.InfRefmsgid = res10265.InfRefmsgid
  8152. } else {
  8153. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8154. utils.ErrorLog("解析失败:%v", err)
  8155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8156. return
  8157. }
  8158. }
  8159. var user_name string
  8160. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8161. if role.ID == 0 {
  8162. user_name = "xxx"
  8163. } else {
  8164. user_name = role.UserName
  8165. }
  8166. baseParams := models.BaseParams{
  8167. SecretKey: miConfig.SecretKey,
  8168. FixmedinsCode: miConfig.Code,
  8169. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8170. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8171. OrgName: miConfig.OrgName,
  8172. Doctor: user_name,
  8173. }
  8174. if config.IsOpen == 1 {
  8175. if miConfig.Code == "H15049901371" {
  8176. if med_type == "14" {
  8177. if insutype == "390" {
  8178. med_type = "9933"
  8179. } else if insutype == "310" {
  8180. med_type = "990502"
  8181. }
  8182. } else if med_type == "11" {
  8183. med_type = "11"
  8184. }
  8185. }
  8186. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8187. var dat map[string]interface{}
  8188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8189. fmt.Println(dat)
  8190. } else {
  8191. fmt.Println(err)
  8192. }
  8193. var res Result2001
  8194. var res10265 Result2001Org10265
  8195. if miConfig.Code == "H15049901371" {
  8196. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8197. utils.ErrorLog("解析失败:%v", err)
  8198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8199. return
  8200. }
  8201. res.ErrMsg = res10265.ErrMsg
  8202. res.Output = res10265.Output
  8203. res.InfRefmsgid = res10265.InfRefmsgid
  8204. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8205. res.Infcode = infocode
  8206. } else {
  8207. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8208. utils.ErrorLog("解析失败:%v", err)
  8209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8210. return
  8211. }
  8212. }
  8213. if res.Infcode == 0 {
  8214. c.ServeSuccessJSON(map[string]interface{}{
  8215. "msg": res.Output.Trtinfo,
  8216. })
  8217. }
  8218. }
  8219. }
  8220. }
  8221. //func (c *HisApiController) PutRecord() {
  8222. // id, _ := c.GetInt64("id")
  8223. // record_time := c.GetString("record_time")
  8224. // timeLayout := "2006-01-02"
  8225. // loc, _ := time.LoadLocation("Local")
  8226. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8227. // if err != nil {
  8228. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8229. // return
  8230. // }
  8231. // recordDateTime := theTime.Unix()
  8232. //
  8233. // adminInfo := c.GetAdminUserInfo()
  8234. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8235. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8236. //
  8237. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8238. //
  8239. // fmt.Println(miConfig.SecretKey)
  8240. //
  8241. // if patient == nil {
  8242. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8243. // return
  8244. // }
  8245. // if len(patient.IdCardNo) == 0 {
  8246. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8247. // return
  8248. // }
  8249. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8250. // if config.IsOpen == 1 {
  8251. // 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
  8252. // resp, requestErr := http.Get(api)
  8253. // if requestErr != nil {
  8254. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8255. // return
  8256. // }
  8257. // defer resp.Body.Close()
  8258. // body, ioErr := ioutil.ReadAll(resp.Body)
  8259. // if ioErr != nil {
  8260. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8261. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8262. // return
  8263. // }
  8264. // var respJSON map[string]interface{}
  8265. //
  8266. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8267. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8268. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8269. // return
  8270. // }
  8271. //
  8272. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8273. // userJSONBytes, _ := json.Marshal(userJSON)
  8274. // var res ResultTwo
  8275. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8276. // utils.ErrorLog("解析失败:%v", err)
  8277. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8278. // return
  8279. // }
  8280. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8281. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8282. // infoStr := string(Iinfos)
  8283. // idetinfoStr := string(Idetinfos)
  8284. //
  8285. // if res.Infcode == 0 {
  8286. // his := models.VMHisPatient{
  8287. // Status: 1,
  8288. // Ctime: time.Now().Unix(),
  8289. // Mtime: time.Now().Unix(),
  8290. // PsnNo: res.Output.Baseinfo.PsnNo,
  8291. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8292. // Certno: res.Output.Baseinfo.Certno,
  8293. // PsnName: res.Output.Baseinfo.PsnName,
  8294. // Gend: res.Output.Baseinfo.Gend,
  8295. // Naty: res.Output.Baseinfo.Naty,
  8296. // Brdy: res.Output.Baseinfo.Brdy,
  8297. // Age: res.Output.Baseinfo.Age,
  8298. // Iinfo: infoStr,
  8299. // Idetinfo: idetinfoStr,
  8300. // PatientId: patient.ID,
  8301. // RecordDate: theTime.Unix(),
  8302. // UserOrgId: adminInfo.CurrentOrgId,
  8303. // AdminUserId: adminInfo.AdminUser.Id,
  8304. // IsReturn: 1,
  8305. // }
  8306. //
  8307. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8308. // //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")
  8309. // //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")
  8310. //
  8311. // //var dat map[string]interface{}
  8312. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8313. // // fmt.Println(dat)
  8314. // //} else {
  8315. // // fmt.Println(err)
  8316. // //}
  8317. //
  8318. // var dat2 map[string]interface{}
  8319. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8320. // fmt.Println(dat2)
  8321. // } else {
  8322. // fmt.Println(err)
  8323. // }
  8324. //
  8325. // } else {
  8326. // adminUser := c.GetAdminUserInfo()
  8327. // errlog := &models.HisOrderError{
  8328. // UserOrgId: adminUser.CurrentOrgId,
  8329. // Ctime: time.Now().Unix(),
  8330. // Mtime: time.Now().Unix(),
  8331. // ErrMsg: res.ErrMsg,
  8332. // Status: 1,
  8333. // PatientId: id,
  8334. // RecordTime: recordDateTime,
  8335. // Stage: 1,
  8336. // }
  8337. // service.CreateErrMsgLog(errlog)
  8338. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8339. // return
  8340. // }
  8341. // }
  8342. //
  8343. //}
  8344. //func (c *HisApiController) GetUploadDiag() {
  8345. // id, _ := c.GetInt64("id")
  8346. // record_time := c.GetString("record_time")
  8347. //
  8348. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8349. // sick_type, _ := c.GetInt64("sick_type")
  8350. // reg_type, _ := c.GetInt64("reg_type")
  8351. //
  8352. // timeLayout := "2006-01-02"
  8353. // loc, _ := time.LoadLocation("Local")
  8354. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8355. // if err != nil {
  8356. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8357. // return
  8358. // }
  8359. //
  8360. // var patientPrescription models.HisPrescriptionInfo
  8361. // recordDateTime := theTime.Unix()
  8362. // adminInfo := c.GetAdminUserInfo()
  8363. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8364. //
  8365. // if patientPrescription.ID == 0 {
  8366. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8367. // }
  8368. //
  8369. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8370. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8371. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8372. // sickConfig, _ := service.FindSickById(sick_type)
  8373. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8374. //
  8375. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8376. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8377. // "&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 +
  8378. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8379. // resp2, requestErr2 := http.Get(api2)
  8380. // if requestErr2 != nil {
  8381. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8382. // return
  8383. // }
  8384. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8385. // if ioErr2 != nil {
  8386. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8387. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8388. // return
  8389. // }
  8390. // var respJSON2 map[string]interface{}
  8391. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8392. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8394. // return
  8395. // }
  8396. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8397. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8398. //
  8399. // var res2 ResultSix
  8400. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8401. // utils.ErrorLog("解析失败:%v", err)
  8402. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8403. // return
  8404. // }
  8405. // if res2.Infcode != 0 {
  8406. // adminUser := c.GetAdminUserInfo()
  8407. // errlog := &models.HisOrderError{
  8408. // UserOrgId: adminUser.CurrentOrgId,
  8409. // Ctime: time.Now().Unix(),
  8410. // Mtime: time.Now().Unix(),
  8411. // ErrMsg: res2.ErrMsg,
  8412. // Status: 1,
  8413. // PatientId: id,
  8414. // RecordTime: recordDateTime,
  8415. // Stage: 3,
  8416. // }
  8417. // service.CreateErrMsgLog(errlog)
  8418. //
  8419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8420. // return
  8421. // }
  8422. //
  8423. // c.ServeSuccessJSON(map[string]interface{}{
  8424. // "msg": "上传成功",
  8425. // })
  8426. //
  8427. //}
  8428. type QueryResult struct {
  8429. ID int64
  8430. Name string
  8431. Code string
  8432. List_type_code string
  8433. }
  8434. func (c *HisApiController) GetCheckCode() {
  8435. ids_str := c.GetString("ids")
  8436. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8437. ids_arr := strings.Split(ids_str, ",")
  8438. var queryResult []QueryResult
  8439. ids := make([]int64, 0)
  8440. for _, item := range ids_arr {
  8441. id, _ := strconv.ParseInt(item, 10, 64)
  8442. ids = append(ids, id)
  8443. }
  8444. if record_type == 1 {
  8445. drugs, _ := service.GetBatchDrugList(ids)
  8446. for _, item := range drugs {
  8447. result := QueryResult{
  8448. ID: item.ID,
  8449. Name: item.DrugName,
  8450. Code: item.MedicalInsuranceNumber,
  8451. List_type_code: "101",
  8452. }
  8453. queryResult = append(queryResult, result)
  8454. }
  8455. } else if record_type == 2 {
  8456. goods, _ := service.GetBatchGoodInformationList(ids)
  8457. for _, item := range goods {
  8458. result := QueryResult{
  8459. ID: item.ID,
  8460. Name: item.GoodName,
  8461. Code: item.MedicalInsuranceNumber,
  8462. List_type_code: "301",
  8463. }
  8464. queryResult = append(queryResult, result)
  8465. }
  8466. } else if record_type == 3 {
  8467. projects, _ := service.GetBathchMyPorjecgList(ids)
  8468. for _, item := range projects {
  8469. result := QueryResult{
  8470. ID: item.ID,
  8471. Name: item.ProjectName,
  8472. Code: item.MedicalCode,
  8473. List_type_code: "201",
  8474. }
  8475. queryResult = append(queryResult, result)
  8476. }
  8477. }
  8478. admin_user_id, _ := c.GetInt64("admin_user_id")
  8479. adminUser := c.GetAdminUserInfo()
  8480. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8481. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8482. var user_name string
  8483. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8484. if role.ID == 0 {
  8485. user_name = "xxx"
  8486. } else {
  8487. user_name = role.UserName
  8488. }
  8489. baseParams := &models.BaseParams{
  8490. SecretKey: miConfig.SecretKey,
  8491. FixmedinsCode: miConfig.Code,
  8492. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8493. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8494. OrgName: miConfig.OrgName,
  8495. Doctor: user_name,
  8496. }
  8497. if config.IsOpen == 1 {
  8498. for _, item := range queryResult {
  8499. var result string
  8500. if record_type == 1 {
  8501. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8502. } else if record_type == 2 {
  8503. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8504. } else if record_type == 3 {
  8505. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8506. }
  8507. var dat map[string]interface{}
  8508. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8509. fmt.Println(dat)
  8510. } else {
  8511. fmt.Println(err)
  8512. }
  8513. userJSONBytes, _ := json.Marshal(dat)
  8514. var res ResultSix
  8515. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8516. utils.ErrorLog("解析失败:%v", err)
  8517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8518. return
  8519. }
  8520. if res.Infcode == 0 {
  8521. if record_type == 1 {
  8522. service.UpdateBaseDrugById(item.ID)
  8523. } else if record_type == 2 {
  8524. service.UpdateGoodInformaitonByDetail(item.ID)
  8525. } else if record_type == 3 {
  8526. service.UpdateProjectById(item.ID)
  8527. }
  8528. c.ServeSuccessJSON(map[string]interface{}{
  8529. "failed_code": 0,
  8530. "msg": "目录对照成功",
  8531. })
  8532. } else {
  8533. c.ServeSuccessJSON(map[string]interface{}{
  8534. "failed_code": -10,
  8535. "msg": res.ErrMsg,
  8536. })
  8537. }
  8538. }
  8539. }
  8540. }
  8541. func (c *HisApiController) UnCheckCode() {
  8542. ids_str := c.GetString("ids")
  8543. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8544. admin_user_id, _ := c.GetInt64("admin_user_id")
  8545. ids_arr := strings.Split(ids_str, ",")
  8546. var queryResult []QueryResult
  8547. ids := make([]int64, 0)
  8548. for _, item := range ids_arr {
  8549. id, _ := strconv.ParseInt(item, 10, 64)
  8550. ids = append(ids, id)
  8551. }
  8552. if record_type == 1 {
  8553. drugs, _ := service.GetBatchDrugList(ids)
  8554. for _, item := range drugs {
  8555. result := QueryResult{
  8556. ID: item.ID,
  8557. Name: item.DrugName,
  8558. Code: item.MedicalInsuranceNumber,
  8559. List_type_code: "101",
  8560. }
  8561. queryResult = append(queryResult, result)
  8562. }
  8563. } else if record_type == 2 {
  8564. goods, _ := service.GetBatchGoodInformationList(ids)
  8565. for _, item := range goods {
  8566. result := QueryResult{
  8567. ID: item.ID,
  8568. Name: item.GoodName,
  8569. Code: item.MedicalInsuranceNumber,
  8570. List_type_code: "301",
  8571. }
  8572. queryResult = append(queryResult, result)
  8573. }
  8574. } else if record_type == 3 {
  8575. projects, _ := service.GetBathchMyPorjecgList(ids)
  8576. for _, item := range projects {
  8577. result := QueryResult{
  8578. ID: item.ID,
  8579. Name: item.ProjectName,
  8580. Code: item.MedicalCode,
  8581. List_type_code: "201",
  8582. }
  8583. queryResult = append(queryResult, result)
  8584. }
  8585. }
  8586. adminUser := c.GetAdminUserInfo()
  8587. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8588. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8589. var user_name string
  8590. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8591. if role.ID == 0 {
  8592. user_name = "xxx"
  8593. } else {
  8594. user_name = role.UserName
  8595. }
  8596. baseParams := &models.BaseParams{
  8597. SecretKey: miConfig.SecretKey,
  8598. FixmedinsCode: miConfig.Code,
  8599. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8600. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8601. OrgName: miConfig.OrgName,
  8602. Doctor: user_name,
  8603. }
  8604. if config.IsOpen == 1 {
  8605. for _, item := range queryResult {
  8606. var result string
  8607. if record_type == 1 {
  8608. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8609. } else if record_type == 2 {
  8610. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8611. } else if record_type == 3 {
  8612. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8613. }
  8614. var dat2 map[string]interface{}
  8615. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8616. fmt.Println(dat2)
  8617. } else {
  8618. fmt.Println(err)
  8619. }
  8620. userJSONBytes, _ := json.Marshal(dat2)
  8621. var res ResultSix
  8622. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8623. utils.ErrorLog("解析失败:%v", err)
  8624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8625. return
  8626. }
  8627. if res.Infcode == 0 {
  8628. if record_type == 1 {
  8629. service.UpdateDrugByIdDetail(item.ID)
  8630. } else if record_type == 2 {
  8631. service.UpdateGoodInfoById(item.ID)
  8632. } else if record_type == 3 {
  8633. service.UpdateMyProjectById(item.ID)
  8634. }
  8635. c.ServeSuccessJSON(map[string]interface{}{
  8636. "failed_code": 0,
  8637. "msg": "撤销目录对照成功",
  8638. })
  8639. } else {
  8640. c.ServeSuccessJSON(map[string]interface{}{
  8641. "failed_code": -10,
  8642. "msg": res.ErrMsg,
  8643. })
  8644. }
  8645. }
  8646. }
  8647. }
  8648. func (c *HisApiController) GetPatientInfo() {
  8649. id_card_no := c.GetString("id_card_no")
  8650. admin_user_id, _ := c.GetInt64("admin_user_id")
  8651. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8652. if patient.ID == 0 {
  8653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8654. return
  8655. }
  8656. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8657. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8658. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8659. if config.IsOpen == 1 {
  8660. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8661. var dat map[string]interface{}
  8662. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8663. fmt.Println(dat)
  8664. } else {
  8665. fmt.Println(err)
  8666. }
  8667. userJSONBytes, _ := json.Marshal(dat)
  8668. var res ResultTwo
  8669. var res10265 ResultTwo10265
  8670. if miConfig.Code == "H15049901371" {
  8671. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8672. utils.ErrorLog("解析失败:%v", err)
  8673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8674. return
  8675. }
  8676. res.ErrMsg = res10265.ErrMsg
  8677. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8678. res.Infcode = infocode
  8679. res.Output = res10265.Output
  8680. res.InfRefmsgid = res10265.InfRefmsgid
  8681. } else {
  8682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8683. utils.ErrorLog("解析失败:%v", err)
  8684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8685. return
  8686. }
  8687. }
  8688. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8689. // utils.ErrorLog("解析失败:%v", err)
  8690. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8691. // return
  8692. //}
  8693. if res.Infcode != 0 {
  8694. c.ServeSuccessJSON(map[string]interface{}{
  8695. "failed_code": -10,
  8696. "msg": res.ErrMsg,
  8697. })
  8698. } else {
  8699. c.ServeSuccessJSON(map[string]interface{}{
  8700. "failed_code": 0,
  8701. "info": res,
  8702. })
  8703. }
  8704. }
  8705. }
  8706. func (c *HisApiController) PsnPutOnRecord() {
  8707. record_type, _ := c.GetInt64("type")
  8708. patient_id, _ := c.GetInt64("patient_id")
  8709. admin_user_id, _ := c.GetInt64("admin_user_id")
  8710. start_time := c.GetString("start_time")
  8711. end_time := c.GetString("end_time")
  8712. adminUser := c.GetAdminUserInfo()
  8713. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8714. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8715. var patients []*models.Patients
  8716. if record_type == 1 { //全部备案
  8717. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8718. patients = append(patients, patient...)
  8719. } else { //单个备案
  8720. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8721. patients = append(patients, patient)
  8722. }
  8723. var user_name string
  8724. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8725. if role.ID == 0 {
  8726. user_name = "xxx"
  8727. } else {
  8728. user_name = role.UserName
  8729. }
  8730. if config.IsOpen == 1 {
  8731. for _, item := range patients {
  8732. 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
  8733. resp, requestErr := http.Get(api)
  8734. if requestErr != nil {
  8735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8736. return
  8737. }
  8738. defer resp.Body.Close()
  8739. body, ioErr := ioutil.ReadAll(resp.Body)
  8740. if ioErr != nil {
  8741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8743. return
  8744. }
  8745. var respJSON map[string]interface{}
  8746. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8749. return
  8750. }
  8751. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8752. userJSONBytes, _ := json.Marshal(userJSON)
  8753. var res ResultTwo
  8754. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8755. utils.ErrorLog("解析失败:%v", err)
  8756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8757. return
  8758. }
  8759. if res.Infcode == 0 {
  8760. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8761. var dat map[string]interface{}
  8762. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8763. fmt.Println(dat)
  8764. } else {
  8765. fmt.Println(err)
  8766. }
  8767. userJSONBytes, _ := json.Marshal(dat)
  8768. var res2 ResultThirteen
  8769. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8770. utils.ErrorLog("解析失败:%v", err)
  8771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8772. return
  8773. }
  8774. if res2.Infcode == 0 {
  8775. psnResult := &models.GdybPsnRecord{
  8776. UserOrgId: adminUser.CurrentOrgId,
  8777. PatientId: item.ID,
  8778. PsnNo: res.Output.Baseinfo.PsnNo,
  8779. Ctime: time.Now().Unix(),
  8780. Mtime: time.Now().Unix(),
  8781. Status: 1,
  8782. IsCancel: 1,
  8783. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8784. }
  8785. service.CreatePsnRecord(psnResult)
  8786. } else {
  8787. c.ServeSuccessJSON(map[string]interface{}{
  8788. "failed_code": -10,
  8789. "msg": res2.ErrMsg,
  8790. })
  8791. return
  8792. }
  8793. }
  8794. }
  8795. }
  8796. }
  8797. func (c *HisApiController) PsnUnPutOnRecord() {
  8798. id, _ := c.GetInt64("id")
  8799. //record_type, _ := c.GetInt64("type")
  8800. admin_user_id, _ := c.GetInt64("admin_user_id")
  8801. adminUser := c.GetAdminUserInfo()
  8802. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8803. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8804. var user_name string
  8805. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8806. if role.ID == 0 {
  8807. user_name = "xxx"
  8808. } else {
  8809. user_name = role.UserName
  8810. }
  8811. psn_record, _ := service.GetPsnRecordById(id)
  8812. if psn_record.ID == 0 {
  8813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8814. return
  8815. }
  8816. if config.IsOpen == 1 {
  8817. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8818. var dat map[string]interface{}
  8819. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8820. fmt.Println(dat)
  8821. } else {
  8822. fmt.Println(err)
  8823. }
  8824. userJSONBytes, _ := json.Marshal(dat)
  8825. var res ResultFourteen
  8826. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8827. utils.ErrorLog("解析失败:%v", err)
  8828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8829. return
  8830. }
  8831. if res.Infcode == 0 {
  8832. psn_record.IsCancel = 2
  8833. service.CreatePsnRecord(&psn_record)
  8834. } else {
  8835. c.ServeSuccessJSON(map[string]interface{}{
  8836. "failed_code": -10,
  8837. "msg": res.ErrMsg,
  8838. })
  8839. return
  8840. }
  8841. }
  8842. }
  8843. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8844. patient_id, _ := c.GetInt64("patient_id")
  8845. insutype_two := c.GetString("insutype")
  8846. psn_no := c.GetString("psn_no")
  8847. doctor_id, _ := c.GetInt64("doctor_id")
  8848. sick_id, _ := c.GetInt64("sick_id")
  8849. department_id, _ := c.GetInt64("department_id")
  8850. start_time := c.GetString("start_time")
  8851. end_time := c.GetString("end_time")
  8852. check_time := c.GetString("check_time")
  8853. adminUser := c.GetAdminUserInfo()
  8854. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8855. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8856. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8857. sick, _ := service.FindSickById(sick_id)
  8858. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8859. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8860. var res ResultTwo
  8861. var res10265 ResultTwo10265
  8862. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8863. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8864. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8865. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8866. "&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
  8867. resp, requestErr := http.Get(api)
  8868. if requestErr != nil {
  8869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8870. return
  8871. }
  8872. body, ioErr := ioutil.ReadAll(resp.Body)
  8873. if ioErr != nil {
  8874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8876. return
  8877. }
  8878. var respJSON map[string]interface{}
  8879. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8882. return
  8883. }
  8884. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8885. result, _ := json.Marshal(respJSON)
  8886. fmt.Println("log")
  8887. fmt.Println(string(result))
  8888. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8889. utils.ErrorLog("解析失败:%v", err)
  8890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8891. return
  8892. }
  8893. res.ErrMsg = res10265.ErrMsg
  8894. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8895. res.Infcode = infocode
  8896. res.Output = res10265.Output
  8897. res.InfRefmsgid = res10265.InfRefmsgid
  8898. } else {
  8899. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8900. if miConfig.Code == "H15049901371" {
  8901. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8902. utils.ErrorLog("解析失败:%v", err)
  8903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8904. return
  8905. }
  8906. res.ErrMsg = res10265.ErrMsg
  8907. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8908. res.Infcode = infocode
  8909. res.Output = res10265.Output
  8910. res.InfRefmsgid = res10265.InfRefmsgid
  8911. } else {
  8912. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8913. utils.ErrorLog("解析失败:%v", err)
  8914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8915. return
  8916. }
  8917. }
  8918. }
  8919. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8920. infoStr := string(Iinfos)
  8921. var rf []*ResultFive
  8922. json.Unmarshal([]byte(infoStr), &rf)
  8923. var insuplc_admdvs string
  8924. var insutype string
  8925. var is390 int = 0
  8926. var is310 int = 0
  8927. var insutypes []*ResultFive
  8928. for _, item := range rf {
  8929. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8930. insutypes = append(insutypes, item)
  8931. }
  8932. }
  8933. if len(insutypes) == 1 {
  8934. insutype = insutypes[0].Insutype
  8935. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8936. } else {
  8937. for _, i := range insutypes {
  8938. if i.Insutype == "390" {
  8939. is390 = 1
  8940. }
  8941. if i.Insutype == "310" {
  8942. is310 = 1
  8943. }
  8944. }
  8945. }
  8946. if is390 == 1 {
  8947. insutype = "390"
  8948. }
  8949. if is310 == 1 {
  8950. insutype = "310"
  8951. }
  8952. if len(insutypes) == 2 {
  8953. insutype = insutype_two
  8954. }
  8955. if len(insutypes) == 0 {
  8956. insutype = "310"
  8957. }
  8958. insutype = insutype_two
  8959. fmt.Println(insutype)
  8960. for _, item := range rf {
  8961. fmt.Println(item.Insutype)
  8962. fmt.Println(insutype)
  8963. if item.Insutype == insutype {
  8964. fmt.Println(item.Insutype)
  8965. fmt.Println(insutype)
  8966. insuplc_admdvs = item.InsuplcAdmdvs
  8967. }
  8968. }
  8969. fmt.Println(insuplc_admdvs)
  8970. var res2 ResultThirteen
  8971. var res10265_2 ResultThirteen10265
  8972. if config.IsOpen == 1 {
  8973. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8974. } else {
  8975. 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)
  8976. var dat map[string]interface{}
  8977. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8978. fmt.Println(dat)
  8979. } else {
  8980. fmt.Println(err)
  8981. }
  8982. userJSONBytes, _ := json.Marshal(dat)
  8983. if miConfig.Code == "H15049901371" {
  8984. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8985. utils.ErrorLog("解析失败:%v", err)
  8986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8987. return
  8988. }
  8989. res2.ErrMsg = res10265_2.ErrMsg
  8990. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8991. res2.Infcode = infocode
  8992. res2.Output = res10265_2.Output
  8993. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8994. } else {
  8995. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8996. utils.ErrorLog("解析失败:%v", err)
  8997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8998. return
  8999. }
  9000. }
  9001. }
  9002. if res2.Infcode == 0 {
  9003. psnResult := &models.GdybPsnNcdsRecord{
  9004. UserOrgId: adminUser.CurrentOrgId,
  9005. PatientId: patient.ID,
  9006. PsnNo: psn_no,
  9007. DoctorId: doctor.AdminUserId,
  9008. DepartmentId: department_id,
  9009. SickType: sick_id,
  9010. Insutype: insutype,
  9011. Ctime: time.Now().Unix(),
  9012. Mtime: time.Now().Unix(),
  9013. Status: 1,
  9014. IsCancel: 1,
  9015. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9016. }
  9017. service.CreatePsnNCDSRecord(psnResult)
  9018. c.ServeSuccessJSON(map[string]interface{}{
  9019. "failed_code": 0,
  9020. "msg": "备案成功",
  9021. "result": psnResult,
  9022. })
  9023. } else {
  9024. c.ServeSuccessJSON(map[string]interface{}{
  9025. "failed_code": -10,
  9026. "msg": res2.ErrMsg,
  9027. })
  9028. return
  9029. }
  9030. }
  9031. }
  9032. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9033. id, _ := c.GetInt64("id")
  9034. admin_user_id, _ := c.GetInt64("admin_user_id")
  9035. adminUser := c.GetAdminUserInfo()
  9036. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9037. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9038. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9039. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9040. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9041. //var user_name string
  9042. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9043. //if role.ID == 0 {
  9044. // user_name = "xxx"
  9045. //} else {
  9046. // user_name = role.UserName
  9047. //}
  9048. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9049. if psn_record.ID == 0 {
  9050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9051. return
  9052. }
  9053. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9054. var res ResultTwo
  9055. var res10265 ResultTwo10265
  9056. if miConfig.Code == "H15049901371" {
  9057. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9058. utils.ErrorLog("解析失败:%v", err)
  9059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9060. return
  9061. }
  9062. res.ErrMsg = res10265.ErrMsg
  9063. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9064. res.Infcode = infocode
  9065. res.Output = res10265.Output
  9066. res.InfRefmsgid = res10265.InfRefmsgid
  9067. } else {
  9068. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9069. utils.ErrorLog("解析失败:%v", err)
  9070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9071. return
  9072. }
  9073. }
  9074. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9075. infoStr := string(Iinfos)
  9076. var rf []*ResultFive
  9077. json.Unmarshal([]byte(infoStr), &rf)
  9078. var insuplc_admdvs string
  9079. var insutype string
  9080. var is390 int = 0
  9081. var is310 int = 0
  9082. var insutypes []*ResultFive
  9083. for _, item := range rf {
  9084. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9085. insutypes = append(insutypes, item)
  9086. }
  9087. }
  9088. if len(insutypes) == 1 {
  9089. insutype = insutypes[0].Insutype
  9090. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9091. } else {
  9092. for _, i := range insutypes {
  9093. if i.Insutype == "390" {
  9094. is390 = 1
  9095. }
  9096. if i.Insutype == "310" {
  9097. is310 = 1
  9098. }
  9099. }
  9100. }
  9101. if is390 == 1 {
  9102. insutype = "390"
  9103. }
  9104. if is310 == 1 {
  9105. insutype = "310"
  9106. }
  9107. if len(insutypes) == 0 {
  9108. insutype = "310"
  9109. }
  9110. insutype = psn_record.Insutype
  9111. for _, item := range rf {
  9112. if item.Insutype == insutype {
  9113. insuplc_admdvs = item.InsuplcAdmdvs
  9114. }
  9115. }
  9116. if config.IsOpen == 1 {
  9117. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9118. var dat map[string]interface{}
  9119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9120. fmt.Println(dat)
  9121. } else {
  9122. fmt.Println(err)
  9123. }
  9124. userJSONBytes, _ := json.Marshal(dat)
  9125. var res ResultFourteen
  9126. var res10265 ResultFourteen10265
  9127. if miConfig.Code == "H15049901371" {
  9128. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9129. utils.ErrorLog("解析失败:%v", err)
  9130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9131. return
  9132. }
  9133. res.ErrMsg = res10265.ErrMsg
  9134. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9135. res.Infcode = infocode
  9136. res.Output = res10265.Output
  9137. res.InfRefmsgid = res10265.InfRefmsgid
  9138. } else {
  9139. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9140. utils.ErrorLog("解析失败:%v", err)
  9141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9142. return
  9143. }
  9144. }
  9145. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9146. // utils.ErrorLog("解析失败:%v", err)
  9147. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9148. // return
  9149. //}
  9150. if res.Infcode == 0 {
  9151. psn_record.IsCancel = 2
  9152. service.CreatePsnNCDSRecord(&psn_record)
  9153. c.ServeSuccessJSON(map[string]interface{}{
  9154. "failed_code": 0,
  9155. "msg": "撤销备案成功",
  9156. })
  9157. } else {
  9158. c.ServeSuccessJSON(map[string]interface{}{
  9159. "failed_code": -10,
  9160. "msg": res.ErrMsg,
  9161. })
  9162. return
  9163. }
  9164. }
  9165. }
  9166. func (c *HisApiController) TestTest() {
  9167. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9168. fmt.Println(patient.Iinfo)
  9169. }
  9170. type CustomData struct {
  9171. MsgId string
  9172. PsnNo string
  9173. Info string
  9174. }
  9175. func (c *HisApiController) ReversalData() {
  9176. var customData []*CustomData
  9177. custom := &CustomData{
  9178. MsgId: "H44022900158202103301714472004",
  9179. PsnNo: "44020000001101329945",
  9180. Info: "2207",
  9181. }
  9182. customData = append(customData, custom)
  9183. custom1 := &CustomData{
  9184. MsgId: "H4402290015820210330172057803",
  9185. PsnNo: "44020000001101161813",
  9186. Info: "2207",
  9187. }
  9188. customData = append(customData, custom1)
  9189. custom2 := &CustomData{
  9190. MsgId: "H44022900158202103301705198813",
  9191. PsnNo: "44190000133097375417",
  9192. Info: "2207",
  9193. }
  9194. customData = append(customData, custom2)
  9195. custom3 := &CustomData{
  9196. MsgId: "H44022900158202103301715524756",
  9197. PsnNo: "44020000001100187221",
  9198. Info: "2207",
  9199. }
  9200. customData = append(customData, custom3)
  9201. custom4 := &CustomData{
  9202. MsgId: "H44022900158202103301730376224",
  9203. PsnNo: "44020000001101959155",
  9204. Info: "2207",
  9205. }
  9206. customData = append(customData, custom4)
  9207. custom5 := &CustomData{
  9208. MsgId: "H44022900158202103301748008725",
  9209. PsnNo: "44020000001104246641",
  9210. Info: "2207",
  9211. }
  9212. customData = append(customData, custom5)
  9213. custom6 := &CustomData{
  9214. MsgId: "H44022900158202103301718096755",
  9215. PsnNo: "44020000001102211860",
  9216. Info: "2207",
  9217. }
  9218. customData = append(customData, custom6)
  9219. custom7 := &CustomData{
  9220. MsgId: "H44022900158202103301736551640",
  9221. PsnNo: "44020000001102687718",
  9222. Info: "2207",
  9223. }
  9224. customData = append(customData, custom7)
  9225. custom8 := &CustomData{
  9226. MsgId: "H44022900158202103301743097676",
  9227. PsnNo: "44020000001102127785",
  9228. Info: "2207",
  9229. }
  9230. customData = append(customData, custom8)
  9231. custom9 := &CustomData{
  9232. MsgId: "H44022900158202103301712304203",
  9233. PsnNo: "44020000001101518097",
  9234. Info: "2207",
  9235. }
  9236. customData = append(customData, custom9)
  9237. custom10 := &CustomData{
  9238. MsgId: "H44022900158202103301738448785",
  9239. PsnNo: "44020000001100500813",
  9240. Info: "2207",
  9241. }
  9242. customData = append(customData, custom10)
  9243. custom11 := &CustomData{
  9244. MsgId: "H44022900158202103301732455843",
  9245. PsnNo: "44020000001102690557",
  9246. Info: "2207",
  9247. }
  9248. customData = append(customData, custom11)
  9249. custom12 := &CustomData{
  9250. MsgId: "H44022900158202103301745421708",
  9251. PsnNo: "44020000001102211928",
  9252. Info: "2207",
  9253. }
  9254. customData = append(customData, custom12)
  9255. custom1212 := &CustomData{
  9256. MsgId: "H440229001582021033017351627",
  9257. PsnNo: "44020000001102481733",
  9258. Info: "2207",
  9259. }
  9260. customData = append(customData, custom1212)
  9261. custom13 := &CustomData{
  9262. MsgId: "H44022900158202103301740327951",
  9263. PsnNo: "44020000001103174866",
  9264. Info: "2207",
  9265. }
  9266. customData = append(customData, custom13)
  9267. custom14 := &CustomData{
  9268. MsgId: "H4402290015820210330174922668",
  9269. PsnNo: "44020000001102927272",
  9270. Info: "2207",
  9271. }
  9272. customData = append(customData, custom14)
  9273. custom15 := &CustomData{
  9274. MsgId: "H44022900158202103301752362273",
  9275. PsnNo: "44020000001102942890",
  9276. Info: "2207",
  9277. }
  9278. customData = append(customData, custom15)
  9279. custom16 := &CustomData{
  9280. MsgId: "H44022900158202103301751082917",
  9281. PsnNo: "44020000001101662162",
  9282. Info: "2207",
  9283. }
  9284. customData = append(customData, custom16)
  9285. custom17 := &CustomData{
  9286. MsgId: "H44022900158202103301754147728",
  9287. PsnNo: "44020000000229014511",
  9288. Info: "2207",
  9289. }
  9290. customData = append(customData, custom17)
  9291. adminUser := c.GetAdminUserInfo()
  9292. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9293. for _, item := range customData {
  9294. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9295. fmt.Println(result)
  9296. }
  9297. }
  9298. func (c *HisApiController) GetAllopatry() {
  9299. year := c.GetString("year")
  9300. month := c.GetString("month")
  9301. admin_user_id, _ := c.GetInt64("admin_user_id")
  9302. adminUser := c.GetAdminUserInfo()
  9303. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9304. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9305. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9306. var dat map[string]interface{}
  9307. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9308. fmt.Println(dat)
  9309. } else {
  9310. fmt.Println(err)
  9311. }
  9312. userJSONBytes, _ := json.Marshal(dat)
  9313. var res models.Result9001
  9314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9315. utils.ErrorLog("解析失败:%v", err)
  9316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9317. return
  9318. }
  9319. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9320. var dat2 map[string]interface{}
  9321. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9322. fmt.Println(dat)
  9323. } else {
  9324. fmt.Println(err)
  9325. }
  9326. userJSONBytes2, _ := json.Marshal(dat2)
  9327. var res2 models.Result3260
  9328. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9329. utils.ErrorLog("解析失败:%v", err)
  9330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9331. return
  9332. }
  9333. if res2.Infcode == 0 {
  9334. c.ServeSuccessJSON(map[string]interface{}{
  9335. "list": res2.Output.Data,
  9336. })
  9337. return
  9338. } else {
  9339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9340. return
  9341. }
  9342. }
  9343. func (c *HisApiController) ComfirmAllopatry() {
  9344. year := c.GetString("year")
  9345. month := c.GetString("month")
  9346. admin_user_id, _ := c.GetInt64("admin_user_id")
  9347. adminUser := c.GetAdminUserInfo()
  9348. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9349. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9350. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9351. var dat map[string]interface{}
  9352. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9353. fmt.Println(dat)
  9354. } else {
  9355. fmt.Println(err)
  9356. }
  9357. userJSONBytes, _ := json.Marshal(dat)
  9358. var res models.Result9001
  9359. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9360. utils.ErrorLog("解析失败:%v", err)
  9361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9362. return
  9363. }
  9364. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9365. var dat2 map[string]interface{}
  9366. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9367. fmt.Println(dat)
  9368. } else {
  9369. fmt.Println(err)
  9370. }
  9371. userJSONBytes2, _ := json.Marshal(dat2)
  9372. var res2 models.Result3260
  9373. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9374. utils.ErrorLog("解析失败:%v", err)
  9375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9376. return
  9377. }
  9378. if res2.Infcode == 0 {
  9379. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9380. var dat map[string]interface{}
  9381. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9382. fmt.Println(dat)
  9383. } else {
  9384. fmt.Println(err)
  9385. }
  9386. userJSONBytes, _ := json.Marshal(dat)
  9387. var res3 models.Result3261
  9388. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9389. utils.ErrorLog("解析失败:%v", err)
  9390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9391. return
  9392. }
  9393. if res3.Infcode == 0 {
  9394. record := &models.HisYidiClearRecord{
  9395. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9396. Ctime: time.Now().Unix(),
  9397. Mtime: time.Now().Unix(),
  9398. Status: 1,
  9399. MsgId: msgId,
  9400. }
  9401. service.SaveClearRecord(record)
  9402. c.ServeSuccessJSON(map[string]interface{}{
  9403. "msg": "提取成功",
  9404. })
  9405. }
  9406. }
  9407. }
  9408. func (c *HisApiController) RefundAllopatry() {
  9409. year := c.GetString("year")
  9410. month := c.GetString("month")
  9411. id, _ := c.GetInt64("id")
  9412. admin_user_id, _ := c.GetInt64("admin_user_id")
  9413. adminUser := c.GetAdminUserInfo()
  9414. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9415. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9416. record, _ := service.GetClearRecordById(id)
  9417. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9418. var dat map[string]interface{}
  9419. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9420. fmt.Println(dat)
  9421. } else {
  9422. fmt.Println(err)
  9423. }
  9424. userJSONBytes, _ := json.Marshal(dat)
  9425. var empty ResultFourteen
  9426. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9427. utils.ErrorLog("解析失败:%v", err)
  9428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9429. return
  9430. }
  9431. if empty.Infcode == 0 {
  9432. c.ServeSuccessJSON(map[string]interface{}{
  9433. "msg": "撤销成功",
  9434. })
  9435. return
  9436. }
  9437. }
  9438. func (c *HisApiController) ReversalOtherData() {
  9439. var customData []*CustomData
  9440. custom := &CustomData{
  9441. MsgId: "H44022900158202103301714472004",
  9442. PsnNo: "44020000001101329945",
  9443. Info: "2208",
  9444. }
  9445. customData = append(customData, custom)
  9446. custom1 := &CustomData{
  9447. MsgId: "H4402290015820210330172057803",
  9448. PsnNo: "44020000001101161813",
  9449. Info: "2208",
  9450. }
  9451. customData = append(customData, custom1)
  9452. custom2 := &CustomData{
  9453. MsgId: "H44022900158202103301705198813",
  9454. PsnNo: "44190000133097375417",
  9455. Info: "2208",
  9456. }
  9457. customData = append(customData, custom2)
  9458. custom3 := &CustomData{
  9459. MsgId: "H44022900158202103301715524756",
  9460. PsnNo: "44020000001100187221",
  9461. Info: "2208",
  9462. }
  9463. customData = append(customData, custom3)
  9464. custom4 := &CustomData{
  9465. MsgId: "H44022900158202103301730376224",
  9466. PsnNo: "44020000001101959155",
  9467. Info: "2208",
  9468. }
  9469. customData = append(customData, custom4)
  9470. custom5 := &CustomData{
  9471. MsgId: "H44022900158202103301748008725",
  9472. PsnNo: "44020000001104246641",
  9473. Info: "2208",
  9474. }
  9475. customData = append(customData, custom5)
  9476. custom6 := &CustomData{
  9477. MsgId: "H44022900158202103301718096755",
  9478. PsnNo: "44020000001102211860",
  9479. Info: "2208",
  9480. }
  9481. customData = append(customData, custom6)
  9482. custom7 := &CustomData{
  9483. MsgId: "H44022900158202103301736551640",
  9484. PsnNo: "44020000001102687718",
  9485. Info: "2208",
  9486. }
  9487. customData = append(customData, custom7)
  9488. custom8 := &CustomData{
  9489. MsgId: "H44022900158202103301743097676",
  9490. PsnNo: "44020000001102127785",
  9491. Info: "2208",
  9492. }
  9493. customData = append(customData, custom8)
  9494. custom9 := &CustomData{
  9495. MsgId: "H44022900158202103301712304203",
  9496. PsnNo: "44020000001101518097",
  9497. Info: "2208",
  9498. }
  9499. customData = append(customData, custom9)
  9500. custom10 := &CustomData{
  9501. MsgId: "H44022900158202103301738448785",
  9502. PsnNo: "44020000001100500813",
  9503. Info: "2208",
  9504. }
  9505. customData = append(customData, custom10)
  9506. custom11 := &CustomData{
  9507. MsgId: "H44022900158202103301732455843",
  9508. PsnNo: "44020000001102690557",
  9509. Info: "2208",
  9510. }
  9511. customData = append(customData, custom11)
  9512. custom12 := &CustomData{
  9513. MsgId: "H44022900158202103301745421708",
  9514. PsnNo: "44020000001102211928",
  9515. Info: "2208",
  9516. }
  9517. customData = append(customData, custom12)
  9518. custom1212 := &CustomData{
  9519. MsgId: "H440229001582021033017351627",
  9520. PsnNo: "44020000001102481733",
  9521. Info: "2208",
  9522. }
  9523. customData = append(customData, custom1212)
  9524. custom13 := &CustomData{
  9525. MsgId: "H44022900158202103301740327951",
  9526. PsnNo: "44020000001103174866",
  9527. Info: "2208",
  9528. }
  9529. customData = append(customData, custom13)
  9530. custom14 := &CustomData{
  9531. MsgId: "H4402290015820210330174922668",
  9532. PsnNo: "44020000001102927272",
  9533. Info: "2208",
  9534. }
  9535. customData = append(customData, custom14)
  9536. custom15 := &CustomData{
  9537. MsgId: "H44022900158202103301752362273",
  9538. PsnNo: "44020000001102942890",
  9539. Info: "2208",
  9540. }
  9541. customData = append(customData, custom15)
  9542. custom16 := &CustomData{
  9543. MsgId: "H44022900158202103301751082917",
  9544. PsnNo: "44020000001101662162",
  9545. Info: "2208",
  9546. }
  9547. customData = append(customData, custom16)
  9548. custom17 := &CustomData{
  9549. MsgId: "H44022900158202103301754147728",
  9550. PsnNo: "44020000000229014511",
  9551. Info: "2208",
  9552. }
  9553. customData = append(customData, custom17)
  9554. adminUser := c.GetAdminUserInfo()
  9555. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9556. for _, item := range customData {
  9557. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9558. fmt.Println(result)
  9559. }
  9560. }
  9561. func PathExists(path string) (bool, error) {
  9562. _, err := os.Stat(path)
  9563. if err == nil {
  9564. return true, nil
  9565. }
  9566. if os.IsNotExist(err) {
  9567. return false, nil
  9568. }
  9569. return false, err
  9570. }
  9571. //创建文件夹
  9572. func Mkdir(dir string) {
  9573. // 创建文件夹
  9574. exist, err := PathExists(dir)
  9575. if err != nil {
  9576. fmt.Println(err.Error())
  9577. } else {
  9578. if exist {
  9579. fmt.Println(dir + "文件夹已存在!")
  9580. } else {
  9581. // 文件夹名称,权限
  9582. err := os.Mkdir(dir, os.ModePerm)
  9583. if err != nil {
  9584. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9585. } else {
  9586. fmt.Println(dir + "文件夹创建成功!")
  9587. }
  9588. }
  9589. }
  9590. }
  9591. //压缩文件
  9592. func Zip(srcFile string, destZip string) error {
  9593. zipfile, err := os.Create(destZip)
  9594. if err != nil {
  9595. return err
  9596. }
  9597. defer zipfile.Close()
  9598. archive := zip.NewWriter(zipfile)
  9599. defer archive.Close()
  9600. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9601. if err != nil {
  9602. return err
  9603. }
  9604. header, err := zip.FileInfoHeader(info)
  9605. if err != nil {
  9606. return err
  9607. }
  9608. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9609. // header.Name = path
  9610. if info.IsDir() {
  9611. header.Name += "/"
  9612. } else {
  9613. header.Method = zip.Deflate
  9614. }
  9615. writer, err := archive.CreateHeader(header)
  9616. if err != nil {
  9617. return err
  9618. }
  9619. if !info.IsDir() {
  9620. file, err := os.Open(path)
  9621. if err != nil {
  9622. return err
  9623. }
  9624. defer file.Close()
  9625. _, err = io.Copy(writer, file)
  9626. }
  9627. return err
  9628. })
  9629. return err
  9630. }
  9631. func ReadFile(filePath string) []byte {
  9632. f, err := os.Open(filePath)
  9633. if err != nil {
  9634. fmt.Println("read file fail", err)
  9635. return nil
  9636. }
  9637. defer f.Close()
  9638. fd, err := ioutil.ReadAll(f)
  9639. if err != nil {
  9640. fmt.Println("read to fd fail", err)
  9641. return nil
  9642. }
  9643. return fd
  9644. }
  9645. func saveLog(result string, request string, infno string, desc string) {
  9646. org_id, _ := beego.AppConfig.Int64("org_id")
  9647. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9648. dir := miConfig.OrgName + "日志"
  9649. utils.Mkdir(dir)
  9650. month := time.Unix(1557042972, 0).Format("1")
  9651. year := time.Now().Format("2006")
  9652. month = time.Now().Format("01")
  9653. day := time.Now().Format("02")
  9654. hour := time.Now().Format("15")
  9655. min := time.Now().Format("04")
  9656. sec := time.Now().Format("05")
  9657. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9658. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9659. file_name := file + ".txt"
  9660. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9661. exist, _ := utils.PathExists(file_path)
  9662. if exist { //存在
  9663. fmt.Println("存在")
  9664. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9665. if err != nil {
  9666. fmt.Println("read fail")
  9667. }
  9668. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9669. n, _ := f.Seek(0, 2)
  9670. _, err = f.WriteAt([]byte(content), n)
  9671. } else { //不存在
  9672. fmt.Println("文件不存在,创建文件")
  9673. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9674. defer f.Close()
  9675. if err != nil {
  9676. } else {
  9677. _, err = f.Write([]byte("记录日志"))
  9678. }
  9679. }
  9680. }
  9681. type Charset string
  9682. const (
  9683. UTF8 = Charset("UTF-8")
  9684. GB18030 = Charset("GB18030")
  9685. )
  9686. func ConvertToString(src string, srcCode string, tagCode string) string {
  9687. srcCoder := mahonia.NewDecoder(srcCode)
  9688. srcResult := srcCoder.ConvertString(src)
  9689. tagCoder := mahonia.NewDecoder(tagCode)
  9690. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9691. result := string(cdata)
  9692. return result
  9693. }