his_api_controller.go 352KB

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