his_api_controller.go 355KB

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