his_api_controller.go 355KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854
  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. 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)
  2780. saveLog(result, requestLog, "1101", "人员基本信息获取")
  2781. if miConfig.Code == "H15049901371" {
  2782. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2783. utils.ErrorLog("解析失败:%v", err)
  2784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2785. return
  2786. }
  2787. res.ErrMsg = res10265.ErrMsg
  2788. res.Output = res10265.Output
  2789. res.InfRefmsgid = res10265.InfRefmsgid
  2790. } else {
  2791. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2792. utils.ErrorLog("解析失败:%v", err)
  2793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2794. return
  2795. }
  2796. }
  2797. PsnNo = res.Output.Baseinfo.PsnNo
  2798. PsnCertType = res.Output.Baseinfo.PsnCertType
  2799. Certno = res.Output.Baseinfo.Certno
  2800. PsnName = res.Output.Baseinfo.PsnName
  2801. Gend = res.Output.Baseinfo.Gend
  2802. Naty = res.Output.Baseinfo.Naty
  2803. Brdy = res.Output.Baseinfo.Brdy
  2804. Age = res.Output.Baseinfo.Age
  2805. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2806. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2807. infoStr = string(Iinfos)
  2808. idetinfoStr = string(Idetinfos)
  2809. if miConfig.Code == "H15049901371" {
  2810. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  2811. } else {
  2812. infocode = res.Infcode
  2813. }
  2814. }
  2815. if infocode == 0 {
  2816. his := models.VMHisPatient{
  2817. Name: name,
  2818. Gender: gender,
  2819. Birthday: birthUnix,
  2820. MedicalTreatmentType: medical_care,
  2821. IdType: certificates,
  2822. IdCardNo: id_card,
  2823. BalanceAccountsType: settlementValue,
  2824. SocialType: social_type,
  2825. MedicalInsuranceNumber: medical_insurance_card,
  2826. RegisterType: register_type,
  2827. RegisterCost: registration_fee,
  2828. TreatmentCost: medical_expenses,
  2829. Status: 1,
  2830. Ctime: time.Now().Unix(),
  2831. Mtime: time.Now().Unix(),
  2832. PsnNo: PsnNo,
  2833. PsnCertType: PsnCertType,
  2834. Certno: Certno,
  2835. PsnName: PsnName,
  2836. Gend: Gend,
  2837. Naty: Naty,
  2838. Brdy: Brdy,
  2839. Age: Age,
  2840. Iinfo: infoStr,
  2841. Idetinfo: idetinfoStr,
  2842. PatientId: patient.ID,
  2843. RecordDate: theTime.Unix(),
  2844. UserOrgId: adminInfo.CurrentOrgId,
  2845. AdminUserId: admin_user_id,
  2846. IsReturn: 1,
  2847. IdCardType: id_card_type,
  2848. Doctor: doctor,
  2849. Departments: department,
  2850. }
  2851. timestamp := time.Now().Unix()
  2852. tempTime := time.Unix(timestamp, 0)
  2853. timeFormat := tempTime.Format("20060102150405")
  2854. chrgBchno := rand.Intn(100000) + 10000
  2855. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2856. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  2857. department, _ := service.GetDepartMentDetail(department)
  2858. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  2859. IdCardNo := ""
  2860. if id_card_type == 1 {
  2861. // IdCardNo = medical_insurance_card
  2862. IdCardNo = patient.IdCardNo
  2863. } else {
  2864. IdCardNo = patient.IdCardNo
  2865. }
  2866. var rf []*ResultFive
  2867. json.Unmarshal([]byte(his.Iinfo), &rf)
  2868. var insutypes []*ResultFive
  2869. var insutype string
  2870. var insuplc_admdvs_temp string
  2871. var is390 int = 0
  2872. var is310 int = 0
  2873. for _, item := range rf {
  2874. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2875. insutypes = append(insutypes, item)
  2876. }
  2877. }
  2878. if len(insutypes) == 1 {
  2879. insutype = insutypes[0].Insutype
  2880. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2881. } else {
  2882. for _, i := range insutypes {
  2883. if i.Insutype == "390" {
  2884. is390 = 1
  2885. }
  2886. if i.Insutype == "310" {
  2887. is310 = 1
  2888. }
  2889. }
  2890. }
  2891. if is390 == 1 {
  2892. insutype = "390"
  2893. }
  2894. if is310 == 1 {
  2895. insutype = "310"
  2896. }
  2897. if len(insutypes) == 0 {
  2898. insutype = "310"
  2899. }
  2900. if len(insutypes) == 2 {
  2901. insutype = med_type
  2902. }
  2903. if len(med_type) > 0 {
  2904. insutype = med_type
  2905. }
  2906. //for _, item := range rf {
  2907. // if item.Insutype == insutype {
  2908. // insuplc_admdvs = item.InsuplcAdmdvs
  2909. // }
  2910. //}
  2911. var infocode int64
  2912. var resThree ResultThree
  2913. var resThree10265 ResultThree10265
  2914. if len(insuplc_admdvs) == 0 {
  2915. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  2916. } else {
  2917. insuplc_admdvs_temp = insuplc_admdvs
  2918. }
  2919. if miConfig.MdtrtareaAdmvs == "421300" {
  2920. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  2921. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2922. "&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
  2923. resp, requestErr := http.Get(api)
  2924. if requestErr != nil {
  2925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2926. return
  2927. }
  2928. body, ioErr := ioutil.ReadAll(resp.Body)
  2929. if ioErr != nil {
  2930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2932. return
  2933. }
  2934. var respJSON map[string]interface{}
  2935. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2938. return
  2939. }
  2940. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2941. result, _ := json.Marshal(respJSON)
  2942. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2943. utils.ErrorLog("解析失败:%v", err)
  2944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2945. return
  2946. }
  2947. infocode = resThree.Infcode
  2948. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2949. psn_info, _ := service.GetPsnByPatientId(id)
  2950. bas := strings.Split(psn_info.CardInfo, "|")
  2951. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  2952. api := "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  2953. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2954. "&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
  2955. resp, requestErr := http.Get(api)
  2956. if requestErr != nil {
  2957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2958. return
  2959. }
  2960. body, ioErr := ioutil.ReadAll(resp.Body)
  2961. if ioErr != nil {
  2962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2964. return
  2965. }
  2966. var respJSON map[string]interface{}
  2967. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2970. return
  2971. }
  2972. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2973. result, _ := json.Marshal(respJSON)
  2974. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  2975. utils.ErrorLog("解析失败:%v", err)
  2976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2977. return
  2978. }
  2979. resThree.ErrMsg = resThree10265.ErrMsg
  2980. resThree.Output = resThree10265.Output
  2981. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  2982. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  2983. } else {
  2984. 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)
  2985. saveLog(result, requestLog, "2201", "挂号")
  2986. if miConfig.Code == "H15049901371" {
  2987. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  2988. utils.ErrorLog("解析失败:%v", err)
  2989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2990. return
  2991. }
  2992. resThree.ErrMsg = resThree10265.ErrMsg
  2993. resThree.Output = resThree10265.Output
  2994. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  2995. } else {
  2996. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2997. utils.ErrorLog("解析失败:%v", err)
  2998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2999. return
  3000. }
  3001. }
  3002. if miConfig.Code == "H15049901371" {
  3003. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3004. } else {
  3005. infocode = resThree.Infcode
  3006. }
  3007. }
  3008. if infocode != 0 {
  3009. adminUser := c.GetAdminUserInfo()
  3010. errlog := &models.HisOrderError{
  3011. UserOrgId: adminUser.CurrentOrgId,
  3012. Ctime: time.Now().Unix(),
  3013. Mtime: time.Now().Unix(),
  3014. ErrMsg: resThree.ErrMsg,
  3015. Status: 1,
  3016. PatientId: id,
  3017. RecordTime: recordDateTime,
  3018. Stage: 2,
  3019. }
  3020. service.CreateErrMsgLog(errlog)
  3021. c.ServeSuccessJSON(map[string]interface{}{
  3022. "failed_code": -10,
  3023. "msg": resThree.ErrMsg,
  3024. })
  3025. return
  3026. }
  3027. his.Number = resThree.Output.Data.MdtrtID
  3028. his.PsnNo = resThree.Output.Data.PsnNo
  3029. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3030. his.IdCardNo = patient.IdCardNo
  3031. his.PhoneNumber = patient.Phone
  3032. his.UserOrgId = adminInfo.CurrentOrgId
  3033. his.Insutype = insutype
  3034. his.Ctime = time.Now().Unix()
  3035. his.Mtime = time.Now().Unix()
  3036. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3037. his.Status = 1
  3038. service.UpdateHisPatientStatus(&his)
  3039. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3040. c.ServeSuccessJSON(map[string]interface{}{
  3041. "his_info": his,
  3042. })
  3043. } else {
  3044. adminUser := c.GetAdminUserInfo()
  3045. errlog := &models.HisOrderError{
  3046. UserOrgId: adminUser.CurrentOrgId,
  3047. Ctime: time.Now().Unix(),
  3048. Mtime: time.Now().Unix(),
  3049. ErrMsg: res.ErrMsg,
  3050. Status: 1,
  3051. PatientId: id,
  3052. RecordTime: recordDateTime,
  3053. Stage: 1,
  3054. }
  3055. service.CreateErrMsgLog(errlog)
  3056. c.ServeSuccessJSON(map[string]interface{}{
  3057. "failed_code": -10,
  3058. "msg": res.ErrMsg,
  3059. })
  3060. return
  3061. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3062. }
  3063. }
  3064. }
  3065. //上传明细----预结算----确认订单
  3066. func (c *HisApiController) GetUploadInfo() {
  3067. id, _ := c.GetInt64("id")
  3068. record_time := c.GetString("record_time")
  3069. his_patient_id, _ := c.GetInt64("his_patient_id")
  3070. order_id, _ := c.GetInt64("order_id")
  3071. pay_way, _ := c.GetInt64("pay_way")
  3072. pay_price, _ := c.GetFloat("pay_price")
  3073. pay_card_no := c.GetString("pay_card_no")
  3074. discount_price, _ := c.GetFloat("discount_price")
  3075. preferential_price, _ := c.GetFloat("preferential_price")
  3076. reality_price, _ := c.GetFloat("reality_price")
  3077. found_price, _ := c.GetFloat("found_price")
  3078. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3079. private_price, _ := c.GetFloat("private_price")
  3080. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3081. admin_user_id, _ := c.GetInt64("admin_user_id")
  3082. fapiao_code := c.GetString("fapiao_code")
  3083. fapiao_number := c.GetString("fapiao_number")
  3084. diagnosis_id := c.GetString("diagnosis")
  3085. sick_type, _ := c.GetInt64("sick_type")
  3086. reg_type, _ := c.GetInt64("p_type")
  3087. begin_time := c.GetString("begin_time")
  3088. id_str := c.GetString("ids")
  3089. ids_arr := strings.Split(id_str, ",")
  3090. timeLayout := "2006-01-02"
  3091. loc, _ := time.LoadLocation("Local")
  3092. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3093. if err != nil {
  3094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3095. return
  3096. }
  3097. recordDateTime := theTime.Unix()
  3098. adminUser := c.GetAdminUserInfo()
  3099. var tempOrder models.HisOrder
  3100. tempOrder, _ = service.GetHisOrderByID(order_id)
  3101. var prescriptions []*models.HisPrescription
  3102. var start_time int64
  3103. var end_time int64
  3104. //if adminUser.CurrentOrgId == 10106{
  3105. // if len(fapiao_code) == 0{
  3106. // fapiao_code = "144072080589"
  3107. // }
  3108. // if len(fapiao_number) == 0{
  3109. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3110. // if order.ID == 0{
  3111. // fapiao_number = "00001520"
  3112. // }else{
  3113. // //fapiao_code = "00001520"
  3114. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3115. // var zero string
  3116. // if fpNumber >= 1000{
  3117. // zero = "0000" + strconv.Itoa(fpNumber)
  3118. // }else if fpNumber >= 10000{
  3119. // zero = "000" + strconv.Itoa(fpNumber)
  3120. // } else if fpNumber >= 100000{
  3121. // zero = "00" + strconv.Itoa(fpNumber)
  3122. // } else if fpNumber >= 1000000{
  3123. // zero = "0" + strconv.Itoa(fpNumber)
  3124. // }else {
  3125. // zero = strconv.Itoa(fpNumber)
  3126. // }
  3127. // fapiao_number = zero
  3128. // }
  3129. // }
  3130. //}
  3131. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3132. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3133. var patientPrescription models.HisPrescriptionInfo
  3134. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3135. if patientPrescription.ID == 0 {
  3136. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3137. }
  3138. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3139. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3140. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3141. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3142. var config []*models.HisXtDiagnoseConfig
  3143. for _, item := range diagnosis_ids {
  3144. id, _ := strconv.ParseInt(item, 10, 64)
  3145. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3146. config = append(config, &diagnosisConfig)
  3147. }
  3148. sickConfig, _ := service.FindSickById(sick_type)
  3149. if tempOrder.ID == 0 {
  3150. tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3151. }
  3152. if tempOrder.ID == 0 {
  3153. var result string
  3154. var requestLog string
  3155. var res2 ResultSix
  3156. var ressix10265 ResultSix10265
  3157. if miConfig.MdtrtareaAdmvs == "421300" {
  3158. data := make(map[string]interface{})
  3159. client := &http.Client{}
  3160. data["psn_no"] = his.PsnNo
  3161. data["mdtrt_id"] = his.Number
  3162. data["doctor"] = roles.UserName
  3163. data["department"] = department.Name
  3164. data["org_name"] = miConfig.OrgName
  3165. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3166. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3167. data["fixmedins_code"] = miConfig.Code
  3168. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3169. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3170. data["secret_key"] = miConfig.SecretKey
  3171. data["sick_code"] = sickConfig.CountryCode
  3172. data["sick_name"] = sickConfig.ClassName
  3173. data["dept"] = strconv.FormatInt(department.ID, 10)
  3174. data["config"] = config
  3175. data["begin_time"] = begin_time
  3176. bytesData, _ := json.Marshal(data)
  3177. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3178. resp, _ := client.Do(req)
  3179. defer resp.Body.Close()
  3180. body, ioErr := ioutil.ReadAll(resp.Body)
  3181. if ioErr != nil {
  3182. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3184. return
  3185. }
  3186. var respJSON map[string]interface{}
  3187. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3190. return
  3191. }
  3192. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3193. userJSONBytes, _ := json.Marshal(respJSON)
  3194. fmt.Println("log")
  3195. fmt.Println(string(userJSONBytes))
  3196. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3197. utils.ErrorLog("解析失败:%v", err)
  3198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3199. return
  3200. }
  3201. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3202. //江苏地区国家医保医疗类别
  3203. //职工透析:医疗类别选特殊情况门诊9933
  3204. //居民血透门慢: 医疗类别选门诊慢病1402
  3205. //var med_type string
  3206. //if his.Insutype == "310" {
  3207. // if reg_type == 14 {
  3208. // med_type = "9933"
  3209. // } else if reg_type == 11 {
  3210. // med_type = "11"
  3211. //
  3212. // }
  3213. //} else if his.Insutype == "390" {
  3214. // if reg_type == 14 {
  3215. // med_type = "1402"
  3216. // } else if reg_type == 11 {
  3217. // med_type = "11"
  3218. // }
  3219. //}
  3220. data := make(map[string]interface{})
  3221. client := &http.Client{}
  3222. data["psn_no"] = his.PsnNo
  3223. data["mdtrt_id"] = his.Number
  3224. data["doctor"] = roles.UserName
  3225. data["department"] = department.Name
  3226. data["org_name"] = miConfig.OrgName
  3227. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3228. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3229. data["fixmedins_code"] = miConfig.Code
  3230. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3231. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3232. data["secret_key"] = miConfig.SecretKey
  3233. data["sick_code"] = sickConfig.CountryCode
  3234. data["sick_name"] = sickConfig.ClassName
  3235. data["url"] = miConfig.Url
  3236. data["ak"] = miConfig.AccessKey
  3237. data["begin_time"] = begin_time
  3238. data["cainfo"] = miConfig.Cainfo
  3239. data["dept"] = strconv.FormatInt(department.ID, 10)
  3240. data["config"] = config
  3241. bytesData, _ := json.Marshal(data)
  3242. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3243. resp, _ := client.Do(req)
  3244. defer resp.Body.Close()
  3245. body, ioErr := ioutil.ReadAll(resp.Body)
  3246. if ioErr != nil {
  3247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3249. return
  3250. }
  3251. var respJSON map[string]interface{}
  3252. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3255. return
  3256. }
  3257. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3258. userJSONBytes, _ := json.Marshal(respJSON)
  3259. fmt.Println("log")
  3260. fmt.Println(string(userJSONBytes))
  3261. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3262. utils.ErrorLog("解析失败:%v", err)
  3263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3264. return
  3265. }
  3266. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3267. res2.Output = ressix10265.Output
  3268. res2.ErrMsg = ressix10265.ErrMsg
  3269. res2.Cainfo = ressix10265.Cainfo
  3270. res2.WarnMsg = ressix10265.WarnMsg
  3271. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3272. res2.Infcode = infocode
  3273. } else {
  3274. if miConfig.MdtrtareaAdmvs == "440781" { //
  3275. 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)
  3276. } else {
  3277. if miConfig.Code == "H15049901371" {
  3278. //赤峰地区国家医保医疗类别
  3279. //职工透析:医疗类别选特殊情况门诊990502
  3280. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3281. var med_type string
  3282. if his.Insutype == "390" {
  3283. if reg_type == 14 {
  3284. med_type = "9933"
  3285. } else if reg_type == 11 {
  3286. med_type = "11"
  3287. }
  3288. } else if his.Insutype == "310" {
  3289. if reg_type == 14 {
  3290. med_type = "990502"
  3291. } else if reg_type == 11 {
  3292. med_type = "11"
  3293. }
  3294. }
  3295. 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)
  3296. } else {
  3297. 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)
  3298. }
  3299. }
  3300. saveLog(result, requestLog, "2203", "上传就诊信息")
  3301. var respJSON2 map[string]interface{}
  3302. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3305. return
  3306. }
  3307. userJSONBytes2, _ := json.Marshal(respJSON2)
  3308. if miConfig.Code == "H15049901371" {
  3309. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3310. utils.ErrorLog("解析失败:%v", err)
  3311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3312. return
  3313. }
  3314. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3315. res2.Output = ressix10265.Output
  3316. res2.ErrMsg = ressix10265.ErrMsg
  3317. res2.Cainfo = ressix10265.Cainfo
  3318. res2.WarnMsg = ressix10265.WarnMsg
  3319. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3320. res2.Infcode = infocode
  3321. } else {
  3322. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3323. utils.ErrorLog("解析失败:%v", err)
  3324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3325. return
  3326. }
  3327. }
  3328. }
  3329. if res2.Infcode != 0 {
  3330. adminUser := c.GetAdminUserInfo()
  3331. errlog := &models.HisOrderError{
  3332. UserOrgId: adminUser.CurrentOrgId,
  3333. Ctime: time.Now().Unix(),
  3334. Mtime: time.Now().Unix(),
  3335. ErrMsg: res2.ErrMsg,
  3336. Status: 1,
  3337. PatientId: id,
  3338. RecordTime: recordDateTime,
  3339. Stage: 3,
  3340. }
  3341. service.CreateErrMsgLog(errlog)
  3342. c.ServeSuccessJSON(map[string]interface{}{
  3343. "failed_code": -10,
  3344. "msg": res2.ErrMsg,
  3345. })
  3346. return
  3347. } else {
  3348. his.Diagnosis = diagnosis_id
  3349. his.SickType = sickConfig.ID
  3350. var p_type int64
  3351. if reg_type == 1111 || reg_type == 1112 {
  3352. p_type = 11
  3353. }
  3354. his.PType = fmt.Sprintf("%d", p_type)
  3355. service.UpdateHisPatientThree(&his)
  3356. data := make(map[string]interface{})
  3357. if settle_accounts_type == 1 { //日结
  3358. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3359. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3360. } else {
  3361. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3362. }
  3363. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3364. data["pre"] = prescriptions
  3365. } else { //月结
  3366. start_time_str := c.GetString("start_time")
  3367. end_time_str := c.GetString("end_time")
  3368. timeLayout := "2006-01-02"
  3369. loc, _ := time.LoadLocation("Local")
  3370. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3371. if err != nil {
  3372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3373. return
  3374. }
  3375. recordStartTime := theStartTime.Unix()
  3376. start_time = recordStartTime
  3377. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3378. if err != nil {
  3379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3380. return
  3381. }
  3382. recordEndTime := theEndTime.Unix()
  3383. end_time = recordEndTime
  3384. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3385. data["pre"] = prescriptions
  3386. }
  3387. timestamp := time.Now().Unix()
  3388. tempTime := time.Unix(timestamp, 0)
  3389. timeFormat := tempTime.Format("20060102150405")
  3390. chrgBchno := rand.Intn(100000) + 10000
  3391. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3392. strconv.FormatInt(his.PatientId, 10)
  3393. client := &http.Client{}
  3394. data["psn_no"] = his.PsnNo
  3395. data["mdtrt_id"] = his.Number
  3396. data["chrg_bchno"] = chrg_bchno
  3397. data["org_name"] = miConfig.OrgName
  3398. data["doctor"] = roles.UserName
  3399. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3400. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3401. data["fixmedins_code"] = miConfig.Code
  3402. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3403. // data["dept_code"] = "15"
  3404. //} else {
  3405. data["dept_code"] = department.Number
  3406. //}
  3407. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3408. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3409. data["secret_key"] = miConfig.SecretKey
  3410. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3411. data["url"] = miConfig.Url
  3412. data["ak"] = miConfig.AccessKey
  3413. data["new_doctor_name"] = patientPrescription.Doctor
  3414. data["diag_code"] = sickConfig.CountryCode
  3415. data["cainfo"] = miConfig.Cainfo
  3416. var ids []int64
  3417. for _, item := range prescriptions {
  3418. ids = append(ids, item.ID)
  3419. }
  3420. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3421. if config.IsOpen == 1 { //对接了医保,走医保流程
  3422. var res ResultFour
  3423. var resFour10265 ResultFour10265
  3424. if miConfig.MdtrtareaAdmvs == "421300" {
  3425. bytesData, _ := json.Marshal(data)
  3426. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3427. resp, _ := client.Do(req)
  3428. defer resp.Body.Close()
  3429. body, ioErr := ioutil.ReadAll(resp.Body)
  3430. if ioErr != nil {
  3431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3433. return
  3434. }
  3435. var respJSON map[string]interface{}
  3436. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3439. return
  3440. }
  3441. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3442. userJSONBytes, _ := json.Marshal(respJSON)
  3443. fmt.Println("log")
  3444. fmt.Println(string(userJSONBytes))
  3445. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3446. utils.ErrorLog("解析失败:%v", err)
  3447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3448. return
  3449. }
  3450. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3451. bytesData, _ := json.Marshal(data)
  3452. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3453. resp, _ := client.Do(req)
  3454. defer resp.Body.Close()
  3455. body, ioErr := ioutil.ReadAll(resp.Body)
  3456. if ioErr != nil {
  3457. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3459. return
  3460. }
  3461. var respJSON map[string]interface{}
  3462. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3463. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3465. return
  3466. }
  3467. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3468. userJSONBytes, _ := json.Marshal(respJSON)
  3469. fmt.Println("log")
  3470. fmt.Println(string(userJSONBytes))
  3471. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3472. utils.ErrorLog("解析失败:%v", err)
  3473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3474. return
  3475. }
  3476. res.InfRefmsgid = resFour10265.InfRefmsgid
  3477. res.Output = resFour10265.Output
  3478. res.ErrMsg = resFour10265.ErrMsg
  3479. res.Cainfo = resFour10265.Cainfo
  3480. res.WarnMsg = resFour10265.WarnMsg
  3481. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3482. res.Infcode = infocode
  3483. } else {
  3484. if miConfig.Code == "H15049901371" {
  3485. 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)
  3486. var dat map[string]interface{}
  3487. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3488. fmt.Println(dat)
  3489. } else {
  3490. fmt.Println(err)
  3491. }
  3492. saveLog(result, request_log, "2204", "上传费用明细")
  3493. userJSONBytes, _ := json.Marshal(dat)
  3494. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3495. utils.ErrorLog("解析失败:%v", err)
  3496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3497. return
  3498. }
  3499. res.InfRefmsgid = resFour10265.InfRefmsgid
  3500. res.Output = resFour10265.Output
  3501. res.ErrMsg = resFour10265.ErrMsg
  3502. res.Cainfo = resFour10265.Cainfo
  3503. res.WarnMsg = resFour10265.WarnMsg
  3504. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3505. res.Infcode = infocode
  3506. } else {
  3507. 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)
  3508. var dat map[string]interface{}
  3509. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3510. fmt.Println(dat)
  3511. } else {
  3512. fmt.Println(err)
  3513. }
  3514. saveLog(result, request_log, "2204", "上传费用明细")
  3515. userJSONBytes, _ := json.Marshal(dat)
  3516. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3517. utils.ErrorLog("解析失败:%v", err)
  3518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3519. return
  3520. }
  3521. }
  3522. }
  3523. if res.Infcode == 0 {
  3524. order := &models.HisOrder{
  3525. UserOrgId: adminUser.CurrentOrgId,
  3526. HisPatientId: his.ID,
  3527. PatientId: his.PatientId,
  3528. SettleAccountsDate: recordDateTime,
  3529. MdtrtId: his.Number,
  3530. PsnNo: his.PsnNo,
  3531. MedType: strconv.FormatInt(reg_type, 10),
  3532. Ctime: time.Now().Unix(),
  3533. Mtime: time.Now().Unix(),
  3534. Status: 1,
  3535. Number: chrg_bchno,
  3536. Infcode: res.Infcode,
  3537. WarnMsg: res.WarnMsg,
  3538. Cainfo: res.Cainfo,
  3539. ErrMsg: res.ErrMsg,
  3540. RespondTime: res.RefmsgTime,
  3541. InfRefmsgid: res.InfRefmsgid,
  3542. OrderStatus: 1,
  3543. PayWay: pay_way,
  3544. PayPrice: pay_price,
  3545. PayCardNo: pay_card_no,
  3546. DiscountPrice: discount_price,
  3547. PreferentialPrice: preferential_price,
  3548. RealityPrice: reality_price,
  3549. FoundPrice: found_price,
  3550. MedicalInsurancePrice: medical_insurance_price,
  3551. PrivatePrice: private_price,
  3552. IsMedicineInsurance: 1,
  3553. SettleType: settle_accounts_type,
  3554. SettleStartTime: start_time,
  3555. SettleEndTime: end_time,
  3556. Creator: roles.AdminUserId,
  3557. Modify: roles.AdminUserId,
  3558. FaPiaoNumber: fapiao_number,
  3559. FaPiaoCode: fapiao_code,
  3560. PType: 2,
  3561. Diagnosis: diagnosis_id,
  3562. }
  3563. err = service.CreateOrder(order)
  3564. if err != nil {
  3565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3566. return
  3567. }
  3568. for _, item := range res.Output.Result {
  3569. temp := strings.Split(item.FeedetlSn, "-")
  3570. var advice_id int64 = 0
  3571. var project_id int64 = 0
  3572. var types int64 = 0
  3573. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3574. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3575. if temp[1] == "1" {
  3576. advice_id = id
  3577. project_id = 0
  3578. } else if temp[1] == "2" {
  3579. advice_id = 0
  3580. project_id = id
  3581. }
  3582. info := &models.HisOrderInfo{
  3583. OrderNumber: order.Number,
  3584. FeedetlSn: item.FeedetlSn,
  3585. UploadDate: time.Now().Unix(),
  3586. AdviceId: advice_id,
  3587. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3588. Cnt: item.Cnt,
  3589. Pric: float64(item.Pric),
  3590. PatientId: his.PatientId,
  3591. PricUplmtAmt: item.PricUplmtAmt,
  3592. SelfpayProp: item.SelfpayProp,
  3593. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3594. OverlmtAmt: item.OverlmtAmt,
  3595. PreselfpayAmt: item.PreselfpayAmt,
  3596. BasMednFlag: item.BasMednFlag,
  3597. MedChrgitmType: item.MedChrgitmType,
  3598. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3599. Status: 1,
  3600. Memo: item.Memo,
  3601. Mtime: time.Now().Unix(),
  3602. InscpScpAmt: item.InscpScpAmt,
  3603. DrtReimFlag: item.DrtReimFlag,
  3604. Ctime: time.Now().Unix(),
  3605. ListSpItemFlag: item.ListSpItemFlag,
  3606. ChldMedcFlag: item.ChldMedcFlag,
  3607. LmtUsedFlag: item.LmtUsedFlag,
  3608. ChrgitmLv: item.ChrgitmLv,
  3609. UserOrgId: adminUser.CurrentOrgId,
  3610. HisPatientId: his.ID,
  3611. OrderId: order.ID,
  3612. ProjectId: project_id,
  3613. Type: types,
  3614. }
  3615. service.CreateOrderInfo(info)
  3616. }
  3617. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3618. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3619. var total float64
  3620. for _, item := range prescriptions {
  3621. if item.Type == 1 { //药品
  3622. for _, subItem := range item.HisDoctorAdviceInfo {
  3623. total = total + (subItem.Price * subItem.PrescribingNumber)
  3624. }
  3625. }
  3626. if item.Type == 2 { //项目
  3627. for _, subItem := range item.HisPrescriptionProject {
  3628. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3629. total = total + (subItem.Price * cnt)
  3630. }
  3631. }
  3632. }
  3633. for _, item := range prescriptions {
  3634. for _, subItem := range item.HisAdditionalCharge {
  3635. total = total + (subItem.Price * float64(subItem.Count))
  3636. }
  3637. }
  3638. var allTotal string
  3639. if adminUser.CurrentOrgId == 9919 {
  3640. allTotal = fmt.Sprintf("%.4f", total)
  3641. } else {
  3642. allTotal = fmt.Sprintf("%.4f", total)
  3643. }
  3644. if res.Infcode == 0 {
  3645. var rf []*ResultFive
  3646. json.Unmarshal([]byte(his.Iinfo), &rf)
  3647. chrg_bchno := chrg_bchno
  3648. cert_no := his.Certno
  3649. var insutypes []string
  3650. var insutype string
  3651. var is390 int = 0
  3652. var is310 int = 0
  3653. for _, item := range rf {
  3654. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3655. insutypes = append(insutypes, item.Insutype)
  3656. }
  3657. }
  3658. if len(insutypes) == 1 {
  3659. insutype = insutypes[0]
  3660. } else {
  3661. for _, i := range insutypes {
  3662. if i == "390" {
  3663. is390 = 1
  3664. }
  3665. if i == "310" {
  3666. is310 = 1
  3667. }
  3668. }
  3669. }
  3670. if is390 == 1 {
  3671. insutype = "390"
  3672. }
  3673. if is310 == 1 {
  3674. insutype = "310"
  3675. }
  3676. if len(insutypes) == 0 {
  3677. insutype = "310"
  3678. }
  3679. if len(insutypes) == 2 {
  3680. insutype = strconv.FormatInt(his.SocialType, 10)
  3681. }
  3682. insutype = strconv.FormatInt(his.SocialType, 10)
  3683. //insutype = "390"
  3684. if his.IdCardType == 1 {
  3685. // cert_no = his.MedicalInsuranceNumber
  3686. cert_no = his.Certno
  3687. } else {
  3688. cert_no = his.Certno
  3689. }
  3690. var res ResultSeven
  3691. var resSeven10265 ResultSeven10265
  3692. var src_resquest string
  3693. var result2 string
  3694. var acct_used_flag string
  3695. fmt.Println("pay_way")
  3696. fmt.Println(pay_way)
  3697. fmt.Println("pay_way")
  3698. if pay_way == 4 {
  3699. acct_used_flag = "1"
  3700. } else {
  3701. acct_used_flag = "0"
  3702. }
  3703. if miConfig.MdtrtareaAdmvs == "421300" {
  3704. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3705. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3706. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3707. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3708. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3709. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3710. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3711. resp, requestErr := http.Get(api)
  3712. if requestErr != nil {
  3713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3714. return
  3715. }
  3716. body, ioErr := ioutil.ReadAll(resp.Body)
  3717. if ioErr != nil {
  3718. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3720. return
  3721. }
  3722. var respJSON map[string]interface{}
  3723. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3726. return
  3727. }
  3728. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3729. result, _ := json.Marshal(respJSON)
  3730. if miConfig.Code == "H15049901371" {
  3731. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3732. utils.ErrorLog("解析失败:%v", err)
  3733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3734. return
  3735. }
  3736. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3737. res.Output = resSeven10265.Output
  3738. res.ErrMsg = resSeven10265.ErrMsg
  3739. res.Cainfo = resSeven10265.Cainfo
  3740. res.WarnMsg = resSeven10265.WarnMsg
  3741. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3742. res.Infcode = infocode
  3743. } else {
  3744. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3745. utils.ErrorLog("解析失败:%v", err)
  3746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3747. return
  3748. }
  3749. }
  3750. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3751. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  3752. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3753. //psn_info, _ := service.GetPsnByPatientId(id)
  3754. bas := strings.Split(psn_info.CardInfo, "|")
  3755. if his.IdCardType == 1 {
  3756. cert_no = bas[2]
  3757. } else {
  3758. cert_no = bas[1]
  3759. }
  3760. //江苏地区国家医保医疗类别
  3761. //职工透析:医疗类别选特殊情况门诊9933
  3762. //居民血透门慢: 医疗类别选门诊慢病1402
  3763. //var med_type string
  3764. //if his.Insutype == "310" {
  3765. // if reg_type == 14 {
  3766. // med_type = "9933"
  3767. // } else if reg_type == 11 {
  3768. // med_type = "11"
  3769. //
  3770. // }
  3771. //} else if his.Insutype == "390" {
  3772. // if reg_type == 14 {
  3773. // med_type = "1402"
  3774. // } else if reg_type == 11 {
  3775. // med_type = "11"
  3776. // }
  3777. //}
  3778. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3779. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3780. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3781. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3782. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3783. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3784. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3785. "&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
  3786. resp, requestErr := http.Get(api)
  3787. if requestErr != nil {
  3788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3789. return
  3790. }
  3791. body, ioErr := ioutil.ReadAll(resp.Body)
  3792. if ioErr != nil {
  3793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3795. return
  3796. }
  3797. var respJSON map[string]interface{}
  3798. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3801. return
  3802. }
  3803. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3804. result, _ := json.Marshal(respJSON)
  3805. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3806. utils.ErrorLog("解析失败:%v", err)
  3807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3808. return
  3809. }
  3810. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3811. res.Output = resSeven10265.Output
  3812. res.ErrMsg = resSeven10265.ErrMsg
  3813. res.Cainfo = resSeven10265.Cainfo
  3814. res.WarnMsg = resSeven10265.WarnMsg
  3815. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3816. res.Infcode = infocode
  3817. } else {
  3818. if miConfig.Code == "H15049901371" {
  3819. //赤峰地区国家医保医疗类别
  3820. //职工透析:医疗类别选特殊情况门诊990502
  3821. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3822. var med_type string
  3823. if his.Insutype == "390" {
  3824. if reg_type == 14 {
  3825. med_type = "9933"
  3826. } else if reg_type == 11 {
  3827. med_type = "11"
  3828. }
  3829. } else if his.Insutype == "310" {
  3830. if reg_type == 14 {
  3831. med_type = "990502"
  3832. } else if reg_type == 11 {
  3833. med_type = "11"
  3834. }
  3835. }
  3836. 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)
  3837. } else {
  3838. 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)
  3839. }
  3840. //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)
  3841. var dat map[string]interface{}
  3842. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3843. fmt.Println(dat)
  3844. } else {
  3845. fmt.Println(err)
  3846. }
  3847. saveLog(result2, src_resquest, "2207", "结算")
  3848. userJSONBytes, _ := json.Marshal(dat)
  3849. if miConfig.Code == "H15049901371" {
  3850. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3851. utils.ErrorLog("解析失败:%v", err)
  3852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3853. return
  3854. }
  3855. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3856. res.Output = resSeven10265.Output
  3857. res.ErrMsg = resSeven10265.ErrMsg
  3858. res.Cainfo = resSeven10265.Cainfo
  3859. res.WarnMsg = resSeven10265.WarnMsg
  3860. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3861. res.Infcode = infocode
  3862. } else {
  3863. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3864. utils.ErrorLog("解析失败:%v", err)
  3865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3866. return
  3867. }
  3868. }
  3869. }
  3870. if res.Infcode != 0 {
  3871. errlog := &models.HisOrderError{
  3872. UserOrgId: adminUser.CurrentOrgId,
  3873. Ctime: time.Now().Unix(),
  3874. Mtime: time.Now().Unix(),
  3875. Number: chrg_bchno,
  3876. ErrMsg: res.ErrMsg,
  3877. Status: 1,
  3878. PatientId: id,
  3879. RecordTime: recordDateTime,
  3880. Stage: 6,
  3881. }
  3882. service.CreateErrMsgLog(errlog)
  3883. c.ServeSuccessJSON(map[string]interface{}{
  3884. "failed_code": -10,
  3885. "msg": res.ErrMsg,
  3886. })
  3887. return
  3888. } else {
  3889. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3890. order.OrderStatus = 2
  3891. order.Status = 1
  3892. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3893. order.SetlId = res.Output.Setlinfo.SetlID
  3894. order.PsnNo = res.Output.Setlinfo.PsnNo
  3895. order.PsnName = res.Output.Setlinfo.PsnName
  3896. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3897. order.Certno = res.Output.Setlinfo.Certno
  3898. order.Gend = res.Output.Setlinfo.Gend
  3899. order.Naty = res.Output.Setlinfo.Naty
  3900. order.Age = res.Output.Setlinfo.Age
  3901. order.Insutype = res.Output.Setlinfo.Insutype
  3902. order.PsnType = res.Output.Setlinfo.PsnType
  3903. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3904. order.SetlTime = res.Output.Setlinfo.SetlTime
  3905. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3906. if res.Output.Setlinfo.MedType == "140101" {
  3907. order.MedType = "14"
  3908. } else {
  3909. order.MedType = res.Output.Setlinfo.MedType
  3910. }
  3911. if reg_type == 1112 {
  3912. order.MedType = "1112"
  3913. }
  3914. if reg_type == 1111 {
  3915. order.MedType = "1111"
  3916. }
  3917. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3918. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3919. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3920. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3921. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3922. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3923. order.HifpPay = res.Output.Setlinfo.HifpPay
  3924. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3925. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3926. order.HifesPay = res.Output.Setlinfo.HifesPay
  3927. order.HifobPay = res.Output.Setlinfo.HifobPay
  3928. order.MafPay = res.Output.Setlinfo.MafPay
  3929. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3930. order.OthPay = res.Output.Setlinfo.OthPay
  3931. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3932. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3933. order.AcctPay = res.Output.Setlinfo.AcctPay
  3934. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3935. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3936. order.Balc = res.Output.Setlinfo.Balc
  3937. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3938. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3939. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3940. order.ClrType = res.Output.Setlinfo.ClrType
  3941. order.ClrWay = res.Output.Setlinfo.ClrWay
  3942. order.Creator = order.Creator
  3943. order.Modify = roles.AdminUserId
  3944. order.RequestLog = src_resquest
  3945. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3946. detailStr := string(setlDetail)
  3947. order.SetlDetail = detailStr
  3948. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3949. err = service.UpDateOrder(order)
  3950. if err == nil {
  3951. c.ServeSuccessJSON(map[string]interface{}{
  3952. "msg": "结算成功",
  3953. })
  3954. } else {
  3955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3956. return
  3957. }
  3958. }
  3959. } else {
  3960. adminUser := c.GetAdminUserInfo()
  3961. errlog := &models.HisOrderError{
  3962. UserOrgId: adminUser.CurrentOrgId,
  3963. Ctime: time.Now().Unix(),
  3964. Mtime: time.Now().Unix(),
  3965. ErrMsg: res.ErrMsg,
  3966. Status: 1,
  3967. PatientId: id,
  3968. RecordTime: recordDateTime,
  3969. Stage: 4,
  3970. }
  3971. service.CreateErrMsgLog(errlog)
  3972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3973. return
  3974. }
  3975. } else {
  3976. adminUser := c.GetAdminUserInfo()
  3977. errlog := &models.HisOrderError{
  3978. UserOrgId: adminUser.CurrentOrgId,
  3979. Ctime: time.Now().Unix(),
  3980. Mtime: time.Now().Unix(),
  3981. ErrMsg: res.ErrMsg,
  3982. Status: 1,
  3983. PatientId: id,
  3984. RecordTime: recordDateTime,
  3985. Stage: 4,
  3986. }
  3987. service.CreateErrMsgLog(errlog)
  3988. c.ServeSuccessJSON(map[string]interface{}{
  3989. "failed_code": -10,
  3990. "msg": res.ErrMsg,
  3991. })
  3992. return
  3993. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3994. //return
  3995. }
  3996. }
  3997. }
  3998. } else if tempOrder.ID > 0 {
  3999. if tempOrder.IsPre == 1 {
  4000. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4001. var rf []*ResultFive
  4002. json.Unmarshal([]byte(his.Iinfo), &rf)
  4003. chrg_bchno := tempOrder.Number
  4004. cert_no := his.Certno
  4005. var insutypes []string
  4006. var insutype string
  4007. var is390 int = 0
  4008. var is310 int = 0
  4009. for _, item := range rf {
  4010. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4011. insutypes = append(insutypes, item.Insutype)
  4012. }
  4013. }
  4014. if len(insutypes) == 1 {
  4015. insutype = insutypes[0]
  4016. } else {
  4017. for _, i := range insutypes {
  4018. if i == "390" {
  4019. is390 = 1
  4020. }
  4021. if i == "310" {
  4022. is310 = 1
  4023. }
  4024. }
  4025. }
  4026. if is390 == 1 {
  4027. insutype = "390"
  4028. }
  4029. if is310 == 1 {
  4030. insutype = "310"
  4031. }
  4032. if len(insutypes) == 0 {
  4033. insutype = "310"
  4034. }
  4035. if len(insutypes) == 2 {
  4036. insutype = strconv.FormatInt(his.SocialType, 64)
  4037. }
  4038. //insutype = "390"
  4039. if his.IdCardType == 1 {
  4040. // cert_no = his.MedicalInsuranceNumber
  4041. cert_no = his.Certno
  4042. } else {
  4043. cert_no = his.Certno
  4044. }
  4045. var res ResultSeven
  4046. var resSeven10265 ResultSeven10265
  4047. var src_resquest string
  4048. var result2 string
  4049. var acct_used_flag string
  4050. fmt.Println("pay_way")
  4051. fmt.Println(pay_way)
  4052. fmt.Println("pay_way")
  4053. if pay_way == 4 {
  4054. acct_used_flag = "1"
  4055. } else {
  4056. acct_used_flag = "0"
  4057. }
  4058. if miConfig.MdtrtareaAdmvs == "421300" {
  4059. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4060. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4061. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4062. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4063. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4064. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4065. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4066. resp, requestErr := http.Get(api)
  4067. if requestErr != nil {
  4068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4069. return
  4070. }
  4071. body, ioErr := ioutil.ReadAll(resp.Body)
  4072. if ioErr != nil {
  4073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4075. return
  4076. }
  4077. var respJSON map[string]interface{}
  4078. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4081. return
  4082. }
  4083. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4084. result, _ := json.Marshal(respJSON)
  4085. fmt.Println("log")
  4086. fmt.Println(string(result))
  4087. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4088. utils.ErrorLog("解析失败:%v", err)
  4089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4090. return
  4091. }
  4092. } else if miConfig.MdtrtareaAdmvs == "320921" {
  4093. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4094. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4095. //psn_info, _ := service.GetPsnByPatientId(id)
  4096. bas := strings.Split(psn_info.CardInfo, "|")
  4097. if his.IdCardType == 1 {
  4098. cert_no = bas[2]
  4099. } else {
  4100. cert_no = bas[1]
  4101. }
  4102. //江苏地区国家医保医疗类别
  4103. //职工透析:医疗类别选特殊情况门诊9933
  4104. //居民血透门慢: 医疗类别选门诊慢病1402
  4105. //var med_type string
  4106. //if his.Insutype == "310" {
  4107. // if reg_type == 14 {
  4108. // med_type = "9933"
  4109. // } else if reg_type == 11 {
  4110. // med_type = "11"
  4111. //
  4112. // }
  4113. //} else if his.Insutype == "390" {
  4114. // if reg_type == 14 {
  4115. // med_type = "1402"
  4116. // } else if reg_type == 11 {
  4117. // med_type = "11"
  4118. // }
  4119. //}
  4120. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4121. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4122. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4123. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4124. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4125. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4126. "&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
  4127. resp, requestErr := http.Get(api)
  4128. if requestErr != nil {
  4129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4130. return
  4131. }
  4132. body, ioErr := ioutil.ReadAll(resp.Body)
  4133. if ioErr != nil {
  4134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4136. return
  4137. }
  4138. var respJSON map[string]interface{}
  4139. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4142. return
  4143. }
  4144. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4145. result, _ := json.Marshal(respJSON)
  4146. fmt.Println("log")
  4147. fmt.Println(string(result))
  4148. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4149. utils.ErrorLog("解析失败:%v", err)
  4150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4151. return
  4152. }
  4153. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4154. res.Output = resSeven10265.Output
  4155. res.ErrMsg = resSeven10265.ErrMsg
  4156. res.Cainfo = resSeven10265.Cainfo
  4157. res.WarnMsg = resSeven10265.WarnMsg
  4158. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4159. res.Infcode = infocode
  4160. } else {
  4161. var src_resquest string
  4162. if miConfig.Code == "H15049901371" {
  4163. //赤峰地区国家医保医疗类别
  4164. //职工透析:医疗类别选特殊情况门诊990502
  4165. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4166. var med_type string
  4167. if his.Insutype == "390" {
  4168. if reg_type == 14 {
  4169. med_type = "9933"
  4170. } else if reg_type == 11 {
  4171. med_type = "11"
  4172. }
  4173. } else if his.Insutype == "310" {
  4174. if reg_type == 14 {
  4175. med_type = "990502"
  4176. } else if reg_type == 11 {
  4177. med_type = "11"
  4178. }
  4179. }
  4180. 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)
  4181. } else {
  4182. 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)
  4183. }
  4184. var dat map[string]interface{}
  4185. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4186. fmt.Println(dat)
  4187. } else {
  4188. fmt.Println(err)
  4189. }
  4190. saveLog(result2, src_resquest, "2207", "结算")
  4191. userJSONBytes, _ := json.Marshal(dat)
  4192. if miConfig.Code == "H15049901371" {
  4193. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4194. utils.ErrorLog("解析失败:%v", err)
  4195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4196. return
  4197. }
  4198. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4199. res.Output = resSeven10265.Output
  4200. res.ErrMsg = resSeven10265.ErrMsg
  4201. res.Cainfo = resSeven10265.Cainfo
  4202. res.WarnMsg = resSeven10265.WarnMsg
  4203. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4204. res.Infcode = infocode
  4205. } else {
  4206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4207. utils.ErrorLog("解析失败:%v", err)
  4208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4209. return
  4210. }
  4211. }
  4212. }
  4213. if res.Infcode != 0 {
  4214. errlog := &models.HisOrderError{
  4215. UserOrgId: adminUser.CurrentOrgId,
  4216. Ctime: time.Now().Unix(),
  4217. Mtime: time.Now().Unix(),
  4218. Number: chrg_bchno,
  4219. ErrMsg: res.ErrMsg,
  4220. Status: 1,
  4221. PatientId: id,
  4222. RecordTime: recordDateTime,
  4223. Stage: 6,
  4224. }
  4225. service.CreateErrMsgLog(errlog)
  4226. c.ServeSuccessJSON(map[string]interface{}{
  4227. "failed_code": -10,
  4228. "msg": res.ErrMsg,
  4229. })
  4230. return
  4231. } else {
  4232. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4233. order.OrderStatus = 2
  4234. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4235. order.SetlId = res.Output.Setlinfo.SetlID
  4236. order.PsnNo = res.Output.Setlinfo.PsnNo
  4237. order.PsnName = res.Output.Setlinfo.PsnName
  4238. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4239. order.Certno = res.Output.Setlinfo.Certno
  4240. order.Gend = res.Output.Setlinfo.Gend
  4241. order.Naty = res.Output.Setlinfo.Naty
  4242. order.Age = res.Output.Setlinfo.Age
  4243. order.Insutype = res.Output.Setlinfo.Insutype
  4244. order.PsnType = res.Output.Setlinfo.PsnType
  4245. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4246. order.SetlTime = res.Output.Setlinfo.SetlTime
  4247. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4248. //order.MedType = res.Output.Setlinfo.MedType
  4249. if reg_type == 1112 {
  4250. order.MedType = "1112"
  4251. }
  4252. if reg_type == 1111 {
  4253. order.MedType = "1111"
  4254. }
  4255. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4256. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4257. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4258. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4259. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4260. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4261. order.HifpPay = res.Output.Setlinfo.HifpPay
  4262. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4263. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4264. order.HifesPay = res.Output.Setlinfo.HifesPay
  4265. order.HifobPay = res.Output.Setlinfo.HifobPay
  4266. order.MafPay = res.Output.Setlinfo.MafPay
  4267. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4268. order.OthPay = res.Output.Setlinfo.OthPay
  4269. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4270. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4271. order.AcctPay = res.Output.Setlinfo.AcctPay
  4272. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4273. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4274. order.Balc = res.Output.Setlinfo.Balc
  4275. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4276. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4277. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4278. order.ClrWay = res.Output.Setlinfo.ClrWay
  4279. order.Creator = order.Creator
  4280. order.Modify = roles.AdminUserId
  4281. order.RequestLog = src_resquest
  4282. order.Diagnosis = diagnosis_id
  4283. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4284. detailStr := string(setlDetail)
  4285. order.SetlDetail = detailStr
  4286. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4287. err = service.UpDateOrder(order)
  4288. if err == nil {
  4289. c.ServeSuccessJSON(map[string]interface{}{
  4290. "msg": "结算成功",
  4291. })
  4292. } else {
  4293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4294. return
  4295. }
  4296. }
  4297. }
  4298. }
  4299. }
  4300. //func (c *HisApiController) GetPreUploadInfo() {
  4301. // id, _ := c.GetInt64("id")
  4302. // record_time := c.GetString("record_time")
  4303. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4304. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4305. //
  4306. // timeLayout := "2006-01-02"
  4307. // loc, _ := time.LoadLocation("Local")
  4308. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4309. // if err != nil {
  4310. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4311. // return
  4312. // }
  4313. // recordDateTime := theTime.Unix()
  4314. // adminUser := c.GetAdminUserInfo()
  4315. //
  4316. // var prescriptions []*models.HisPrescription
  4317. //
  4318. // var start_time int64
  4319. // var end_time int64
  4320. //
  4321. // data := make(map[string]interface{})
  4322. // if settle_accounts_type == 1 { //日结
  4323. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4324. // data["pre"] = prescriptions
  4325. //
  4326. // } else { //月结
  4327. // start_time_str := c.GetString("start_time")
  4328. // end_time_str := c.GetString("end_time")
  4329. // timeLayout := "2006-01-02"
  4330. // loc, _ := time.LoadLocation("Local")
  4331. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4332. // if err != nil {
  4333. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4334. // return
  4335. // }
  4336. // recordStartTime := theStartTime.Unix()
  4337. // start_time = recordStartTime
  4338. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4339. // if err != nil {
  4340. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4341. // return
  4342. // }
  4343. // recordEndTime := theEndTime.Unix()
  4344. // end_time = recordEndTime
  4345. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4346. // data["pre"] = prescriptions
  4347. //
  4348. // }
  4349. //
  4350. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4351. //
  4352. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4353. // timestamp := time.Now().Unix()
  4354. // tempTime := time.Unix(timestamp, 0)
  4355. // timeFormat := tempTime.Format("20060102150405")
  4356. // chrgBchno := rand.Intn(100000) + 10000
  4357. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4358. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4359. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4360. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4361. // strconv.FormatInt(his.PatientId, 10)
  4362. // client := &http.Client{}
  4363. // data["psn_no"] = his.PsnNo
  4364. // data["mdtrt_id"] = his.Number
  4365. // data["chrg_bchno"] = chrg_bchno
  4366. // data["org_name"] = miConfig.OrgName
  4367. // data["doctor"] = roles.UserName
  4368. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4369. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4370. // data["fixmedins_code"] = miConfig.Code
  4371. // data["dept_code"] = department.Number
  4372. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4373. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4374. // data["secret_key"] = miConfig.SecretKey
  4375. // var ids []int64
  4376. //
  4377. // for _, item := range prescriptions {
  4378. // ids = append(ids, item.ID)
  4379. // }
  4380. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4381. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4382. // bytesData, _ := json.Marshal(data)
  4383. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4384. // resp, _ := client.Do(req)
  4385. // defer resp.Body.Close()
  4386. // body, ioErr := ioutil.ReadAll(resp.Body)
  4387. // if ioErr != nil {
  4388. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4390. // return
  4391. // }
  4392. // var respJSON map[string]interface{}
  4393. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4394. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4396. // return
  4397. // }
  4398. //
  4399. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4400. // userJSONBytes, _ := json.Marshal(respJSON)
  4401. // var res ResultFour
  4402. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4403. // utils.ErrorLog("解析失败:%v", err)
  4404. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4405. // return
  4406. // }
  4407. //
  4408. // if res.Infcode == 0 {
  4409. // order := &models.HisOrder{
  4410. // UserOrgId: adminUser.CurrentOrgId,
  4411. // HisPatientId: his.ID,
  4412. // PatientId: his.PatientId,
  4413. // SettleAccountsDate: recordDateTime,
  4414. // Ctime: time.Now().Unix(),
  4415. // Mtime: time.Now().Unix(),
  4416. // Status: 1,
  4417. // Number: chrg_bchno,
  4418. // Infcode: res.Infcode,
  4419. // WarnMsg: res.WarnMsg,
  4420. // Cainfo: res.Cainfo,
  4421. // ErrMsg: res.ErrMsg,
  4422. // RespondTime: res.RefmsgTime,
  4423. // InfRefmsgid: res.InfRefmsgid,
  4424. // OrderStatus: 1,
  4425. // IsMedicineInsurance: 1,
  4426. // SettleType: settle_accounts_type,
  4427. // SettleStartTime: start_time,
  4428. // SettleEndTime: end_time,
  4429. // Creator: roles.ID,
  4430. // Modify: roles.ID,
  4431. // PType: 2,
  4432. // }
  4433. // err = service.CreateOrder(order)
  4434. // if err != nil {
  4435. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4436. // return
  4437. // }
  4438. //
  4439. // for _, item := range res.Output.Result {
  4440. // temp := strings.Split(item.FeedetlSn, "-")
  4441. // var advice_id int64 = 0
  4442. // var project_id int64 = 0
  4443. // var types int64 = 0
  4444. //
  4445. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4446. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4447. //
  4448. // if temp[1] == "1" {
  4449. // advice_id = id
  4450. // project_id = 0
  4451. // } else if temp[1] == "2" {
  4452. // advice_id = 0
  4453. // project_id = id
  4454. // }
  4455. //
  4456. // info := &models.HisOrderInfo{
  4457. // OrderNumber: order.Number,
  4458. // FeedetlSn: item.FeedetlSn,
  4459. // UploadDate: time.Now().Unix(),
  4460. // AdviceId: advice_id,
  4461. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4462. // Cnt: item.Cnt,
  4463. // Pric: float64(item.Pric),
  4464. // PatientId: his.PatientId,
  4465. // PricUplmtAmt: item.PricUplmtAmt,
  4466. // SelfpayProp: item.SelfpayProp,
  4467. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4468. // OverlmtAmt: item.OverlmtAmt,
  4469. // PreselfpayAmt: item.PreselfpayAmt,
  4470. // BasMednFlag: item.BasMednFlag,
  4471. // MedChrgitmType: item.MedChrgitmType,
  4472. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4473. // Status: 1,
  4474. // Memo: item.Memo,
  4475. // Mtime: time.Now().Unix(),
  4476. // InscpScpAmt: item.InscpScpAmt,
  4477. // DrtReimFlag: item.DrtReimFlag,
  4478. // Ctime: time.Now().Unix(),
  4479. // ListSpItemFlag: item.ListSpItemFlag,
  4480. // ChldMedcFlag: item.ChldMedcFlag,
  4481. // LmtUsedFlag: item.LmtUsedFlag,
  4482. // ChrgitmLv: item.ChrgitmLv,
  4483. // UserOrgId: adminUser.CurrentOrgId,
  4484. // HisPatientId: his.ID,
  4485. // OrderId: order.ID,
  4486. // ProjectId: project_id,
  4487. // Type: types,
  4488. // }
  4489. // service.CreateOrderInfo(info)
  4490. //
  4491. // }
  4492. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4493. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4494. //
  4495. // var total float64
  4496. // for _, item := range prescriptions {
  4497. // if item.Type == 1 { //药品
  4498. // for _, subItem := range item.HisDoctorAdviceInfo {
  4499. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4500. // }
  4501. // }
  4502. // if item.Type == 2 { //项目
  4503. // for _, subItem := range item.HisPrescriptionProject {
  4504. // total = total + (subItem.Price * float64(subItem.Count))
  4505. // }
  4506. // }
  4507. // }
  4508. //
  4509. // for _, item := range prescriptions {
  4510. // for _, subItem := range item.HisAdditionalCharge {
  4511. // total = total + (subItem.Price * float64(subItem.Count))
  4512. // }
  4513. // }
  4514. //
  4515. // allTotal := fmt.Sprintf("%.2f", total)
  4516. // if res.Infcode == 0 {
  4517. // var rf []*ResultFive
  4518. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4519. // psn_no := his.PsnNo
  4520. // mdtrt_id := his.Number
  4521. // chrg_bchno := chrg_bchno
  4522. // cert_no := his.Certno
  4523. // insutype := rf[0].Insutype
  4524. //
  4525. // if his.IdCardType == 1 {
  4526. // cert_no = his.MedicalInsuranceNumber
  4527. //
  4528. // } else {
  4529. //
  4530. // cert_no = his.Certno
  4531. //
  4532. // }
  4533. //
  4534. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  4535. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  4536. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  4537. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  4538. // resp, requestErr := http.Get(api)
  4539. // if requestErr != nil {
  4540. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4541. // return
  4542. // }
  4543. // defer resp.Body.Close()
  4544. // body, ioErr := ioutil.ReadAll(resp.Body)
  4545. // if ioErr != nil {
  4546. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4548. // return
  4549. // }
  4550. // var respJSON map[string]interface{}
  4551. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4552. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4553. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4554. // return
  4555. // }
  4556. // fmt.Println(respJSON)
  4557. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4558. // userJSONBytes, _ := json.Marshal(respJSON)
  4559. // var res ResultSeven
  4560. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4561. // utils.ErrorLog("解析失败:%v", err)
  4562. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4563. // return
  4564. // }
  4565. // if res.Infcode != 0 {
  4566. // errlog := &models.HisOrderError{
  4567. // UserOrgId: adminUser.CurrentOrgId,
  4568. // Ctime: time.Now().Unix(),
  4569. // Mtime: time.Now().Unix(),
  4570. // Number: chrg_bchno,
  4571. // ErrMsg: res.ErrMsg,
  4572. // Status: 1,
  4573. // PatientId: id,
  4574. // RecordTime: recordDateTime,
  4575. // Stage: 7,
  4576. // }
  4577. // service.CreateErrMsgLog(errlog)
  4578. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4579. // return
  4580. // } else {
  4581. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4582. // order.OrderStatus = 1
  4583. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4584. // order.SetlId = res.Output.Setlinfo.SetlID
  4585. // order.PsnNo = res.Output.Setlinfo.PsnNo
  4586. // order.PsnName = res.Output.Setlinfo.PsnName
  4587. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4588. // order.Certno = res.Output.Setlinfo.Certno
  4589. // order.Gend = res.Output.Setlinfo.Gend
  4590. // order.Naty = res.Output.Setlinfo.Naty
  4591. // order.Age = res.Output.Setlinfo.Age
  4592. // order.Insutype = res.Output.Setlinfo.Insutype
  4593. // order.PsnType = res.Output.Setlinfo.PsnType
  4594. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4595. // order.SetlTime = res.Output.Setlinfo.SetlTime
  4596. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4597. // order.MedType = res.Output.Setlinfo.MedType
  4598. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4599. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4600. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4601. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4602. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4603. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4604. // order.HifpPay = res.Output.Setlinfo.HifpPay
  4605. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4606. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4607. // order.HifesPay = res.Output.Setlinfo.HifesPay
  4608. // order.HifobPay = res.Output.Setlinfo.HifobPay
  4609. // order.MafPay = res.Output.Setlinfo.MafPay
  4610. // order.OthPay = res.Output.Setlinfo.OthPay
  4611. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4612. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4613. // order.AcctPay = res.Output.Setlinfo.AcctPay
  4614. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4615. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4616. // order.Balc = res.Output.Setlinfo.Balc
  4617. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4618. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4619. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4620. // order.ClrWay = res.Output.Setlinfo.ClrWay
  4621. // order.Creator = order.Creator
  4622. // order.Modify = roles.ID
  4623. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4624. // detailStr := string(setlDetail)
  4625. // order.SetlDetail = detailStr
  4626. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4627. // err = service.UpDateOrder(order)
  4628. // if err == nil {
  4629. // c.ServeSuccessJSON(map[string]interface{}{
  4630. // "msg": "预结算成功",
  4631. // })
  4632. // } else {
  4633. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4634. // return
  4635. // }
  4636. // }
  4637. // } else {
  4638. // adminUser := c.GetAdminUserInfo()
  4639. // errlog := &models.HisOrderError{
  4640. // UserOrgId: adminUser.CurrentOrgId,
  4641. // Ctime: time.Now().Unix(),
  4642. // Mtime: time.Now().Unix(),
  4643. // ErrMsg: res.ErrMsg,
  4644. // Status: 1,
  4645. // PatientId: id,
  4646. // RecordTime: recordDateTime,
  4647. // Stage: 4,
  4648. // }
  4649. // service.CreateErrMsgLog(errlog)
  4650. //
  4651. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4652. // return
  4653. // }
  4654. // } else {
  4655. // adminUser := c.GetAdminUserInfo()
  4656. // errlog := &models.HisOrderError{
  4657. // UserOrgId: adminUser.CurrentOrgId,
  4658. // Ctime: time.Now().Unix(),
  4659. // Mtime: time.Now().Unix(),
  4660. // ErrMsg: res.ErrMsg,
  4661. // Status: 1,
  4662. // PatientId: id,
  4663. // RecordTime: recordDateTime,
  4664. // Stage: 4,
  4665. // }
  4666. // service.CreateErrMsgLog(errlog)
  4667. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4668. // return
  4669. // }
  4670. //
  4671. // } else {
  4672. // var total float64
  4673. // for _, item := range prescriptions {
  4674. // if item.Type == 1 { //药品
  4675. // for _, subItem := range item.HisDoctorAdviceInfo {
  4676. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4677. // }
  4678. // }
  4679. // if item.Type == 2 { //项目
  4680. // for _, subItem := range item.HisPrescriptionProject {
  4681. // total = total + (subItem.Price * float64(subItem.Count))
  4682. // }
  4683. // }
  4684. //
  4685. // for _, subItem := range item.HisAdditionalCharge {
  4686. // total = total + (subItem.Price * float64(subItem.Count))
  4687. // }
  4688. // }
  4689. //
  4690. // allTotal := fmt.Sprintf("%.2f", total)
  4691. // totals, _ := strconv.ParseFloat(allTotal, 64)
  4692. // order := &models.HisOrder{
  4693. // UserOrgId: adminUser.CurrentOrgId,
  4694. // HisPatientId: his.ID,
  4695. // PatientId: id,
  4696. // SettleAccountsDate: recordDateTime,
  4697. // Ctime: time.Now().Unix(),
  4698. // Mtime: time.Now().Unix(),
  4699. // Status: 1,
  4700. // OrderStatus: 2,
  4701. // Number: chrg_bchno,
  4702. // MedfeeSumamt: totals,
  4703. // }
  4704. // err = service.CreateOrder(order)
  4705. // if err != nil {
  4706. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4707. // return
  4708. // }
  4709. //
  4710. // var customs []*Custom
  4711. // for _, item := range prescriptions {
  4712. //
  4713. // if item.Type == 1 { //药品
  4714. // for _, subItem := range item.HisDoctorAdviceInfo {
  4715. // cus := &Custom{
  4716. // AdviceId: subItem.ID,
  4717. // ProjectId: 0,
  4718. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  4719. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  4720. // FeedetlSn: subItem.FeedetlSn,
  4721. // Price: fmt.Sprintf("%.2f", subItem.Price),
  4722. // MedListCodg: subItem.MedListCodg,
  4723. // Type: 1,
  4724. // }
  4725. // customs = append(customs, cus)
  4726. // }
  4727. // }
  4728. //
  4729. // if item.Type == 2 { //项目
  4730. // for _, subItem := range item.HisPrescriptionProject {
  4731. //
  4732. // cus := &Custom{
  4733. // AdviceId: 0,
  4734. // ProjectId: subItem.ID,
  4735. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  4736. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  4737. // FeedetlSn: subItem.FeedetlSn,
  4738. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  4739. // MedListCodg: subItem.MedListCodg,
  4740. // Type: 2,
  4741. // }
  4742. //
  4743. // customs = append(customs, cus)
  4744. // }
  4745. // }
  4746. //
  4747. // for _, item := range item.HisAdditionalCharge {
  4748. // cus := &Custom{
  4749. // ItemId: item.ID,
  4750. // AdviceId: 0,
  4751. // ProjectId: 0,
  4752. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  4753. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  4754. // FeedetlSn: item.FeedetlSn,
  4755. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  4756. // MedListCodg: item.XtHisAddtionConfig.Code,
  4757. // Type: 3,
  4758. // }
  4759. //
  4760. // customs = append(customs, cus)
  4761. // }
  4762. //
  4763. // }
  4764. //
  4765. // for _, item := range customs {
  4766. // var advice_id int64 = 0
  4767. // var project_id int64 = 0
  4768. // var item_id int64 = 0
  4769. //
  4770. // var types int64 = 0
  4771. //
  4772. // if item.Type == 1 {
  4773. // advice_id = item.AdviceId
  4774. // project_id = 0
  4775. // item_id = 0
  4776. // } else if item.Type == 2 {
  4777. // advice_id = 0
  4778. // item_id = 0
  4779. //
  4780. // project_id = item.ProjectId
  4781. // } else if item.Type == 3 {
  4782. // advice_id = 0
  4783. // item_id = item.ItemId
  4784. // project_id = 0
  4785. // }
  4786. //
  4787. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  4788. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  4789. // pric, _ := strconv.ParseFloat(item.Price, 32)
  4790. //
  4791. // info := &models.HisOrderInfo{
  4792. // OrderNumber: order.Number,
  4793. // UploadDate: time.Now().Unix(),
  4794. // AdviceId: advice_id,
  4795. // DetItemFeeSumamt: detItemFeeSumamt,
  4796. // Cnt: cut,
  4797. // Pric: pric,
  4798. // PatientId: id,
  4799. // Status: 1,
  4800. // Mtime: time.Now().Unix(),
  4801. // Ctime: time.Now().Unix(),
  4802. // UserOrgId: adminUser.CurrentOrgId,
  4803. // HisPatientId: his.ID,
  4804. // OrderId: order.ID,
  4805. // ProjectId: project_id,
  4806. // Type: types,
  4807. // ItemId: item_id,
  4808. // }
  4809. // service.CreateOrderInfo(info)
  4810. // }
  4811. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4812. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4813. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  4814. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4815. // if err == nil {
  4816. // c.ServeSuccessJSON(map[string]interface{}{
  4817. // "msg": "结算成功",
  4818. // })
  4819. // } else {
  4820. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4821. // return
  4822. // }
  4823. // }
  4824. //}
  4825. //上传明细-预结算-
  4826. func (c *HisApiController) GetPreUploadInfo() {
  4827. id, _ := c.GetInt64("id")
  4828. record_time := c.GetString("record_time")
  4829. his_patient_id, _ := c.GetInt64("his_patient_id")
  4830. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4831. admin_user_id, _ := c.GetInt64("admin_user_id")
  4832. diagnosis_id := c.GetString("diagnosis")
  4833. sick_type, _ := c.GetInt64("sick_type")
  4834. reg_type, _ := c.GetInt64("p_type")
  4835. begin_time := c.GetString("begin_time")
  4836. id_str := c.GetString("ids")
  4837. ids_arr := strings.Split(id_str, ",")
  4838. timeLayout := "2006-01-02"
  4839. loc, _ := time.LoadLocation("Local")
  4840. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4841. if err != nil {
  4842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4843. return
  4844. }
  4845. recordDateTime := theTime.Unix()
  4846. adminUser := c.GetAdminUserInfo()
  4847. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4848. var config []*models.HisXtDiagnoseConfig
  4849. for _, item := range diagnosis_ids {
  4850. id, _ := strconv.ParseInt(item, 10, 64)
  4851. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4852. config = append(config, &diagnosisConfig)
  4853. }
  4854. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4855. sickConfig, _ := service.FindSickById(sick_type)
  4856. var prescriptions []*models.HisPrescription
  4857. var start_time int64
  4858. var end_time int64
  4859. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4860. fmt.Println(his_patient_id)
  4861. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4862. timestamp := time.Now().Unix()
  4863. tempTime := time.Unix(timestamp, 0)
  4864. timeFormat := tempTime.Format("20060102150405")
  4865. chrgBchno := rand.Intn(100000) + 10000
  4866. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4867. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4868. var patientPrescription models.HisPrescriptionInfo
  4869. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4870. if patientPrescription.ID == 0 {
  4871. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4872. }
  4873. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4874. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4875. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4876. strconv.FormatInt(his.PatientId, 10)
  4877. var res2 ResultSix
  4878. var resSix10265 ResultSix10265
  4879. var time_stamp string
  4880. if miConfig.MdtrtareaAdmvs == "421300" {
  4881. data := make(map[string]interface{})
  4882. client := &http.Client{}
  4883. data["psn_no"] = his.PsnNo
  4884. data["mdtrt_id"] = his.Number
  4885. data["doctor"] = roles.UserName
  4886. data["department"] = department.Name
  4887. data["org_name"] = miConfig.OrgName
  4888. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4889. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4890. data["fixmedins_code"] = miConfig.Code
  4891. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4892. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4893. data["secret_key"] = miConfig.SecretKey
  4894. data["sick_code"] = sickConfig.CountryCode
  4895. data["sick_name"] = sickConfig.ClassName
  4896. data["begin_time"] = begin_time
  4897. data["dept"] = strconv.FormatInt(department.ID, 10)
  4898. data["config"] = config
  4899. fmt.Println(data)
  4900. bytesData, _ := json.Marshal(data)
  4901. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4902. resp, _ := client.Do(req)
  4903. defer resp.Body.Close()
  4904. body, ioErr := ioutil.ReadAll(resp.Body)
  4905. if ioErr != nil {
  4906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4908. return
  4909. }
  4910. var respJSON map[string]interface{}
  4911. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4914. return
  4915. }
  4916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4917. userJSONBytes, _ := json.Marshal(respJSON)
  4918. fmt.Println("log")
  4919. fmt.Println(string(userJSONBytes))
  4920. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4921. utils.ErrorLog("解析失败:%v", err)
  4922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4923. return
  4924. }
  4925. } else if miConfig.MdtrtareaAdmvs == "320921" {
  4926. //江苏地区国家医保医疗类别
  4927. //职工透析:医疗类别选特殊情况门诊9933
  4928. //居民血透门慢: 医疗类别选门诊慢病1402
  4929. //var med_type string
  4930. //if his.Insutype == "310" {
  4931. // if reg_type == 14 {
  4932. // med_type = "9933"
  4933. // } else if reg_type == 11 {
  4934. // med_type = "11"
  4935. //
  4936. // }
  4937. //} else if his.Insutype == "390" {
  4938. // if reg_type == 14 {
  4939. // med_type = "1402"
  4940. // } else if reg_type == 11 {
  4941. // med_type = "11"
  4942. // }
  4943. //}
  4944. data := make(map[string]interface{})
  4945. client := &http.Client{}
  4946. data["psn_no"] = his.PsnNo
  4947. data["mdtrt_id"] = his.Number
  4948. data["doctor"] = roles.UserName
  4949. data["department"] = department.Name
  4950. data["org_name"] = miConfig.OrgName
  4951. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4952. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4953. data["fixmedins_code"] = miConfig.Code
  4954. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4955. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4956. data["secret_key"] = miConfig.SecretKey
  4957. data["sick_code"] = sickConfig.CountryCode
  4958. data["sick_name"] = sickConfig.ClassName
  4959. data["begin_time"] = begin_time
  4960. data["dept"] = strconv.FormatInt(department.ID, 10)
  4961. data["config"] = config
  4962. data["url"] = miConfig.Url
  4963. data["ak"] = miConfig.AccessKey
  4964. data["cainfo"] = miConfig.Cainfo
  4965. bytesData, _ := json.Marshal(data)
  4966. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4967. resp, _ := client.Do(req)
  4968. defer resp.Body.Close()
  4969. body, ioErr := ioutil.ReadAll(resp.Body)
  4970. if ioErr != nil {
  4971. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4973. return
  4974. }
  4975. var respJSON map[string]interface{}
  4976. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4977. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4979. return
  4980. }
  4981. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  4982. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  4983. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  4984. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4985. userJSONBytes, _ := json.Marshal(respJSON)
  4986. fmt.Println("log")
  4987. fmt.Println(string(userJSONBytes))
  4988. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  4989. utils.ErrorLog("解析失败:%v", err)
  4990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4991. return
  4992. }
  4993. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4994. res2.Output = resSix10265.Output
  4995. res2.ErrMsg = resSix10265.ErrMsg
  4996. res2.Cainfo = resSix10265.Cainfo
  4997. res2.WarnMsg = resSix10265.WarnMsg
  4998. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  4999. res2.Infcode = infocode
  5000. } else {
  5001. var result string
  5002. var requestLog string
  5003. if miConfig.MdtrtareaAdmvs == "440781" { //
  5004. 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)
  5005. } else {
  5006. if miConfig.Code == "H15049901371" {
  5007. //赤峰地区国家医保医疗类别
  5008. //职工透析:医疗类别选特殊情况门诊990502
  5009. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5010. var med_type string
  5011. if his.Insutype == "390" {
  5012. if reg_type == 14 {
  5013. med_type = "9933"
  5014. } else if reg_type == 11 {
  5015. med_type = "11"
  5016. }
  5017. } else if his.Insutype == "310" {
  5018. if reg_type == 14 {
  5019. med_type = "990502"
  5020. } else if reg_type == 11 {
  5021. med_type = "11"
  5022. }
  5023. }
  5024. 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)
  5025. } else {
  5026. 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)
  5027. }
  5028. saveLog(result, requestLog, "2203", "上传就诊信息")
  5029. var respJSON2 map[string]interface{}
  5030. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5033. return
  5034. }
  5035. userJSONBytes2, _ := json.Marshal(respJSON2)
  5036. if miConfig.Code == "H15049901371" {
  5037. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5038. utils.ErrorLog("解析失败:%v", err)
  5039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5040. return
  5041. }
  5042. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5043. res2.Output = resSix10265.Output
  5044. res2.ErrMsg = resSix10265.ErrMsg
  5045. res2.Cainfo = resSix10265.Cainfo
  5046. res2.WarnMsg = resSix10265.WarnMsg
  5047. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5048. res2.Infcode = infocode
  5049. } else {
  5050. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5051. utils.ErrorLog("解析失败:%v", err)
  5052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5053. return
  5054. }
  5055. }
  5056. }
  5057. }
  5058. if res2.Infcode != 0 {
  5059. adminUser := c.GetAdminUserInfo()
  5060. errlog := &models.HisOrderError{
  5061. UserOrgId: adminUser.CurrentOrgId,
  5062. Ctime: time.Now().Unix(),
  5063. Mtime: time.Now().Unix(),
  5064. ErrMsg: res2.ErrMsg,
  5065. Status: 1,
  5066. PatientId: id,
  5067. RecordTime: recordDateTime,
  5068. Stage: 3,
  5069. }
  5070. service.CreateErrMsgLog(errlog)
  5071. c.ServeSuccessJSON(map[string]interface{}{
  5072. "failed_code": -10,
  5073. "msg": res2.ErrMsg,
  5074. })
  5075. return
  5076. } else {
  5077. his.Diagnosis = diagnosis_id
  5078. his.SickType = sickConfig.ID
  5079. his.PType = fmt.Sprintf("%d", reg_type)
  5080. service.UpdateHisPatientThree(&his)
  5081. data := make(map[string]interface{})
  5082. if settle_accounts_type == 1 { //日结
  5083. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5084. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5085. } else {
  5086. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5087. }
  5088. data["pre"] = prescriptions
  5089. } else { //月结
  5090. start_time_str := c.GetString("start_time")
  5091. end_time_str := c.GetString("end_time")
  5092. timeLayout := "2006-01-02"
  5093. loc, _ := time.LoadLocation("Local")
  5094. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5095. if err != nil {
  5096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5097. return
  5098. }
  5099. recordStartTime := theStartTime.Unix()
  5100. start_time = recordStartTime
  5101. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5102. if err != nil {
  5103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5104. return
  5105. }
  5106. recordEndTime := theEndTime.Unix()
  5107. end_time = recordEndTime
  5108. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5109. data["pre"] = prescriptions
  5110. }
  5111. client := &http.Client{}
  5112. data["psn_no"] = his.PsnNo
  5113. data["mdtrt_id"] = his.Number
  5114. data["chrg_bchno"] = chrg_bchno
  5115. data["org_name"] = miConfig.OrgName
  5116. data["doctor"] = roles.UserName
  5117. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5118. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5119. data["fixmedins_code"] = miConfig.Code
  5120. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5121. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5122. data["dept_code"] = "15"
  5123. } else {
  5124. data["dept_code"] = department.Number
  5125. }
  5126. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5127. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5128. data["secret_key"] = miConfig.SecretKey
  5129. data["url"] = miConfig.Url
  5130. data["ak"] = miConfig.AccessKey
  5131. data["new_doctor_name"] = patientPrescription.Doctor
  5132. data["diag_code"] = sickConfig.CountryCode
  5133. data["time_stamp"] = time_stamp
  5134. data["cainfo"] = miConfig.Cainfo
  5135. var ids []int64
  5136. for _, item := range prescriptions {
  5137. ids = append(ids, item.ID)
  5138. }
  5139. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5140. if config.IsOpen == 1 { //对接了医保,走医保流程
  5141. var res ResultFour
  5142. var resFour10265 ResultFour10265
  5143. if miConfig.MdtrtareaAdmvs == "421300" {
  5144. bytesData, _ := json.Marshal(data)
  5145. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5146. resp, _ := client.Do(req)
  5147. defer resp.Body.Close()
  5148. body, ioErr := ioutil.ReadAll(resp.Body)
  5149. if ioErr != nil {
  5150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5152. return
  5153. }
  5154. var respJSON map[string]interface{}
  5155. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5158. return
  5159. }
  5160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5161. userJSONBytes, _ := json.Marshal(respJSON)
  5162. fmt.Println("log")
  5163. fmt.Println(string(userJSONBytes))
  5164. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5165. utils.ErrorLog("解析失败:%v", err)
  5166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5167. return
  5168. }
  5169. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5170. bytesData, _ := json.Marshal(data)
  5171. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5172. resp, _ := client.Do(req)
  5173. defer resp.Body.Close()
  5174. body, ioErr := ioutil.ReadAll(resp.Body)
  5175. if ioErr != nil {
  5176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5178. return
  5179. }
  5180. var respJSON map[string]interface{}
  5181. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5184. return
  5185. }
  5186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5187. userJSONBytes, _ := json.Marshal(respJSON)
  5188. fmt.Println("log")
  5189. fmt.Println(string(userJSONBytes))
  5190. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5191. utils.ErrorLog("解析失败:%v", err)
  5192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5193. return
  5194. }
  5195. res.InfRefmsgid = resFour10265.InfRefmsgid
  5196. res.Output = resFour10265.Output
  5197. res.ErrMsg = resFour10265.ErrMsg
  5198. res.Cainfo = resFour10265.Cainfo
  5199. res.WarnMsg = resFour10265.WarnMsg
  5200. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5201. res.Infcode = infocode
  5202. } else {
  5203. if miConfig.Code == "H15049901371" {
  5204. 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)
  5205. var dat map[string]interface{}
  5206. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5207. fmt.Println(dat)
  5208. } else {
  5209. fmt.Println(err)
  5210. }
  5211. saveLog(result, request_log, "2204", "上传费用明细")
  5212. userJSONBytes, _ := json.Marshal(dat)
  5213. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5214. utils.ErrorLog("解析失败:%v", err)
  5215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5216. return
  5217. }
  5218. res.InfRefmsgid = resFour10265.InfRefmsgid
  5219. res.Output = resFour10265.Output
  5220. res.ErrMsg = resFour10265.ErrMsg
  5221. res.Cainfo = resFour10265.Cainfo
  5222. res.WarnMsg = resFour10265.WarnMsg
  5223. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5224. res.Infcode = infocode
  5225. } else {
  5226. 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)
  5227. var dat map[string]interface{}
  5228. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5229. fmt.Println(dat)
  5230. } else {
  5231. fmt.Println(err)
  5232. }
  5233. saveLog(result, request_log, "2204", "上传费用明细")
  5234. userJSONBytes, _ := json.Marshal(dat)
  5235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5236. utils.ErrorLog("解析失败:%v", err)
  5237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5238. return
  5239. }
  5240. }
  5241. }
  5242. if res.Infcode == 0 {
  5243. order := &models.HisOrder{
  5244. UserOrgId: adminUser.CurrentOrgId,
  5245. HisPatientId: his.ID,
  5246. PatientId: his.PatientId,
  5247. SettleAccountsDate: recordDateTime,
  5248. Ctime: time.Now().Unix(),
  5249. Mtime: time.Now().Unix(),
  5250. MdtrtId: his.Number,
  5251. PsnNo: his.PsnNo,
  5252. MedType: strconv.FormatInt(reg_type, 10),
  5253. Status: 1,
  5254. Number: chrg_bchno,
  5255. Infcode: res.Infcode,
  5256. WarnMsg: res.WarnMsg,
  5257. Cainfo: res.Cainfo,
  5258. ErrMsg: res.ErrMsg,
  5259. RespondTime: res.RefmsgTime,
  5260. InfRefmsgid: res.InfRefmsgid,
  5261. OrderStatus: 1,
  5262. IsMedicineInsurance: 1,
  5263. SettleType: settle_accounts_type,
  5264. SettleStartTime: start_time,
  5265. SettleEndTime: end_time,
  5266. Creator: roles.AdminUserId,
  5267. Modify: roles.AdminUserId,
  5268. PType: 2,
  5269. Diagnosis: diagnosis_id,
  5270. }
  5271. err = service.CreateOrder(order)
  5272. if err != nil {
  5273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5274. return
  5275. }
  5276. for _, item := range res.Output.Result {
  5277. temp := strings.Split(item.FeedetlSn, "-")
  5278. var advice_id int64 = 0
  5279. var project_id int64 = 0
  5280. var types int64 = 0
  5281. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5282. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5283. if temp[1] == "1" {
  5284. advice_id = id
  5285. project_id = 0
  5286. } else if temp[1] == "2" {
  5287. advice_id = 0
  5288. project_id = id
  5289. }
  5290. info := &models.HisOrderInfo{
  5291. OrderNumber: order.Number,
  5292. FeedetlSn: item.FeedetlSn,
  5293. UploadDate: time.Now().Unix(),
  5294. AdviceId: advice_id,
  5295. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5296. Cnt: item.Cnt,
  5297. Pric: float64(item.Pric),
  5298. PatientId: his.PatientId,
  5299. PricUplmtAmt: item.PricUplmtAmt,
  5300. SelfpayProp: item.SelfpayProp,
  5301. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5302. OverlmtAmt: item.OverlmtAmt,
  5303. PreselfpayAmt: item.PreselfpayAmt,
  5304. BasMednFlag: item.BasMednFlag,
  5305. MedChrgitmType: item.MedChrgitmType,
  5306. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5307. Status: 1,
  5308. Memo: item.Memo,
  5309. Mtime: time.Now().Unix(),
  5310. InscpScpAmt: item.InscpScpAmt,
  5311. DrtReimFlag: item.DrtReimFlag,
  5312. Ctime: time.Now().Unix(),
  5313. ListSpItemFlag: item.ListSpItemFlag,
  5314. ChldMedcFlag: item.ChldMedcFlag,
  5315. LmtUsedFlag: item.LmtUsedFlag,
  5316. ChrgitmLv: item.ChrgitmLv,
  5317. UserOrgId: adminUser.CurrentOrgId,
  5318. HisPatientId: his.ID,
  5319. OrderId: order.ID,
  5320. ProjectId: project_id,
  5321. Type: types,
  5322. }
  5323. service.CreateOrderInfo(info)
  5324. }
  5325. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5326. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5327. var total float64
  5328. for _, item := range prescriptions {
  5329. if item.Type == 1 { //药品
  5330. for _, subItem := range item.HisDoctorAdviceInfo {
  5331. total = total + (subItem.Price * subItem.PrescribingNumber)
  5332. }
  5333. }
  5334. if item.Type == 2 { //项目
  5335. for _, subItem := range item.HisPrescriptionProject {
  5336. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5337. total = total + (subItem.Price * cnt)
  5338. }
  5339. }
  5340. }
  5341. for _, item := range prescriptions {
  5342. for _, subItem := range item.HisAdditionalCharge {
  5343. total = total + (subItem.Price * float64(subItem.Count))
  5344. }
  5345. }
  5346. allTotal := fmt.Sprintf("%.4f", total)
  5347. if res.Infcode == 0 {
  5348. var rf []*ResultFive
  5349. json.Unmarshal([]byte(his.Iinfo), &rf)
  5350. chrg_bchno := chrg_bchno
  5351. cert_no := his.Certno
  5352. var insutypes []string
  5353. var insutype string
  5354. var is390 int = 0
  5355. var is310 int = 0
  5356. for _, item := range rf {
  5357. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5358. insutypes = append(insutypes, item.Insutype)
  5359. }
  5360. }
  5361. if len(insutypes) == 1 {
  5362. insutype = insutypes[0]
  5363. } else {
  5364. for _, i := range insutypes {
  5365. if i == "390" {
  5366. is390 = 1
  5367. }
  5368. if i == "310" {
  5369. is310 = 1
  5370. }
  5371. }
  5372. }
  5373. if is390 == 1 {
  5374. insutype = "390"
  5375. }
  5376. if is310 == 1 {
  5377. insutype = "310"
  5378. }
  5379. if len(insutypes) == 0 {
  5380. insutype = "310"
  5381. }
  5382. if len(insutypes) == 2 {
  5383. insutype = strconv.FormatInt(his.SocialType, 64)
  5384. }
  5385. //insutype = "390"
  5386. if his.IdCardType == 1 {
  5387. cert_no = his.MedicalInsuranceNumber
  5388. } else {
  5389. cert_no = his.Certno
  5390. }
  5391. var res ResultSeven
  5392. var resSeven10265 ResultSeven10265
  5393. if miConfig.MdtrtareaAdmvs == "421300" {
  5394. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5395. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5396. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5397. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5398. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5399. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5400. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5401. resp, requestErr := http.Get(api)
  5402. if requestErr != nil {
  5403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5404. return
  5405. }
  5406. body, ioErr := ioutil.ReadAll(resp.Body)
  5407. if ioErr != nil {
  5408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5410. return
  5411. }
  5412. var respJSON map[string]interface{}
  5413. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5416. return
  5417. }
  5418. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5419. result, _ := json.Marshal(respJSON)
  5420. fmt.Println("log")
  5421. fmt.Println(string(result))
  5422. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5423. utils.ErrorLog("解析失败:%v", err)
  5424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5425. return
  5426. }
  5427. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5428. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5429. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5430. bas := strings.Split(psn_info.CardInfo, "|")
  5431. if his.IdCardType == 1 {
  5432. cert_no = bas[2]
  5433. } else {
  5434. cert_no = bas[1]
  5435. }
  5436. //江苏地区国家医保医疗类别
  5437. //职工透析:医疗类别选特殊情况门诊9933
  5438. //居民血透门慢: 医疗类别选门诊慢病1402
  5439. //var med_type string
  5440. //if his.Insutype == "310" {
  5441. // if reg_type == 14 {
  5442. // med_type = "9933"
  5443. // } else if reg_type == 11 {
  5444. // med_type = "11"
  5445. //
  5446. // }
  5447. //} else if his.Insutype == "390" {
  5448. // if reg_type == 14 {
  5449. // med_type = "1402"
  5450. // } else if reg_type == 11 {
  5451. // med_type = "11"
  5452. // }
  5453. //}
  5454. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5455. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5456. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5457. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5458. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5459. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5460. "&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
  5461. resp, requestErr := http.Get(api)
  5462. if requestErr != nil {
  5463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5464. return
  5465. }
  5466. body, ioErr := ioutil.ReadAll(resp.Body)
  5467. if ioErr != nil {
  5468. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5470. return
  5471. }
  5472. var respJSON map[string]interface{}
  5473. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5476. return
  5477. }
  5478. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5479. result, _ := json.Marshal(respJSON)
  5480. fmt.Println("log")
  5481. fmt.Println(string(result))
  5482. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5483. utils.ErrorLog("解析失败:%v", err)
  5484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5485. return
  5486. }
  5487. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5488. res.Output = resSeven10265.Output
  5489. res.ErrMsg = resSeven10265.ErrMsg
  5490. res.Cainfo = resSeven10265.Cainfo
  5491. res.WarnMsg = resSeven10265.WarnMsg
  5492. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5493. res.Infcode = infocode
  5494. } else {
  5495. var result string
  5496. var request_log string
  5497. if miConfig.Code == "H15049901371" {
  5498. //赤峰地区国家医保医疗类别
  5499. //职工透析:医疗类别选特殊情况门诊990502
  5500. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5501. var med_type string
  5502. if his.Insutype == "390" {
  5503. if reg_type == 14 {
  5504. med_type = "9933"
  5505. } else if reg_type == 11 {
  5506. med_type = "11"
  5507. }
  5508. } else if his.Insutype == "310" {
  5509. if reg_type == 14 {
  5510. med_type = "990502"
  5511. } else if reg_type == 11 {
  5512. med_type = "11"
  5513. }
  5514. }
  5515. 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)
  5516. } else {
  5517. 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)
  5518. }
  5519. var dat map[string]interface{}
  5520. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5521. fmt.Println(dat)
  5522. } else {
  5523. fmt.Println(err)
  5524. }
  5525. saveLog(result, request_log, "2206", "预结算")
  5526. //userJSONBytes, _ := json.Marshal(dat)
  5527. //
  5528. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5529. // utils.ErrorLog("解析失败:%v", err)
  5530. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5531. // return
  5532. //}
  5533. userJSONBytes, _ := json.Marshal(dat)
  5534. if miConfig.Code == "H15049901371" {
  5535. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5536. utils.ErrorLog("解析失败:%v", err)
  5537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5538. return
  5539. }
  5540. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5541. res.Output = resSeven10265.Output
  5542. res.ErrMsg = resSeven10265.ErrMsg
  5543. res.Cainfo = resSeven10265.Cainfo
  5544. res.WarnMsg = resSeven10265.WarnMsg
  5545. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5546. res.Infcode = infocode
  5547. } else {
  5548. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5549. utils.ErrorLog("解析失败:%v", err)
  5550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5551. return
  5552. }
  5553. }
  5554. }
  5555. if res.Infcode != 0 {
  5556. errlog := &models.HisOrderError{
  5557. UserOrgId: adminUser.CurrentOrgId,
  5558. Ctime: time.Now().Unix(),
  5559. Mtime: time.Now().Unix(),
  5560. Number: chrg_bchno,
  5561. ErrMsg: res.ErrMsg,
  5562. Status: 1,
  5563. PatientId: id,
  5564. RecordTime: recordDateTime,
  5565. Stage: 20,
  5566. }
  5567. service.CreateErrMsgLog(errlog)
  5568. c.ServeSuccessJSON(map[string]interface{}{
  5569. "failed_code": -10,
  5570. "msg": res.ErrMsg,
  5571. })
  5572. return
  5573. } else {
  5574. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5575. order.OrderStatus = 1
  5576. order.IsPre = 1
  5577. order.Status = 1
  5578. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5579. order.SetlId = res.Output.Setlinfo.SetlID
  5580. order.PsnNo = res.Output.Setlinfo.PsnNo
  5581. order.PsnName = res.Output.Setlinfo.PsnName
  5582. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5583. order.Certno = res.Output.Setlinfo.Certno
  5584. order.Gend = res.Output.Setlinfo.Gend
  5585. order.Naty = res.Output.Setlinfo.Naty
  5586. order.Age = res.Output.Setlinfo.Age
  5587. order.Insutype = res.Output.Setlinfo.Insutype
  5588. order.PsnType = res.Output.Setlinfo.PsnType
  5589. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5590. order.SetlTime = res.Output.Setlinfo.SetlTime
  5591. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5592. if res.Output.Setlinfo.MedType == "140101" {
  5593. order.MedType = "14"
  5594. } else {
  5595. order.MedType = res.Output.Setlinfo.MedType
  5596. }
  5597. if reg_type == 1112 {
  5598. order.MedType = "1112"
  5599. }
  5600. if reg_type == 1111 {
  5601. order.MedType = "1111"
  5602. }
  5603. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5604. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5605. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5606. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5607. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5608. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5609. order.HifpPay = res.Output.Setlinfo.HifpPay
  5610. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5611. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5612. order.HifesPay = res.Output.Setlinfo.HifesPay
  5613. order.HifobPay = res.Output.Setlinfo.HifobPay
  5614. order.MafPay = res.Output.Setlinfo.MafPay
  5615. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5616. order.OthPay = res.Output.Setlinfo.OthPay
  5617. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5618. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5619. order.AcctPay = res.Output.Setlinfo.AcctPay
  5620. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5621. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5622. order.Balc = res.Output.Setlinfo.Balc
  5623. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5624. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5625. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5626. order.ClrWay = res.Output.Setlinfo.ClrWay
  5627. order.Creator = order.Creator
  5628. order.Modify = roles.AdminUserId
  5629. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5630. detailStr := string(setlDetail)
  5631. order.SetlDetail = detailStr
  5632. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5633. err = service.UpDateOrder(order)
  5634. if err == nil {
  5635. c.ServeSuccessJSON(map[string]interface{}{
  5636. "msg": "预结算成功",
  5637. })
  5638. } else {
  5639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5640. return
  5641. }
  5642. }
  5643. } else {
  5644. adminUser := c.GetAdminUserInfo()
  5645. errlog := &models.HisOrderError{
  5646. UserOrgId: adminUser.CurrentOrgId,
  5647. Ctime: time.Now().Unix(),
  5648. Mtime: time.Now().Unix(),
  5649. ErrMsg: res.ErrMsg,
  5650. Status: 1,
  5651. PatientId: id,
  5652. RecordTime: recordDateTime,
  5653. Stage: 4,
  5654. }
  5655. service.CreateErrMsgLog(errlog)
  5656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5657. return
  5658. }
  5659. } else {
  5660. adminUser := c.GetAdminUserInfo()
  5661. errlog := &models.HisOrderError{
  5662. UserOrgId: adminUser.CurrentOrgId,
  5663. Ctime: time.Now().Unix(),
  5664. Mtime: time.Now().Unix(),
  5665. ErrMsg: res.ErrMsg,
  5666. Status: 1,
  5667. PatientId: id,
  5668. RecordTime: recordDateTime,
  5669. Stage: 4,
  5670. }
  5671. service.CreateErrMsgLog(errlog)
  5672. c.ServeSuccessJSON(map[string]interface{}{
  5673. "failed_code": -10,
  5674. "msg": res.ErrMsg,
  5675. })
  5676. return
  5677. }
  5678. }
  5679. }
  5680. }
  5681. //func (c *HisApiController) GetSettleInfo() {
  5682. // id, _ := c.GetInt64("id")
  5683. // order_id, _ := c.GetInt64("order_id")
  5684. //
  5685. // record_time := c.GetString("record_time")
  5686. // pay_way, _ := c.GetInt64("pay_way")
  5687. // pay_price, _ := c.GetFloat("pay_price")
  5688. // pay_card_no := c.GetString("pay_card_no")
  5689. // discount_price, _ := c.GetFloat("discount_price")
  5690. // preferential_price, _ := c.GetFloat("preferential_price")
  5691. // reality_price, _ := c.GetFloat("reality_price")
  5692. // found_price, _ := c.GetFloat("found_price")
  5693. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5694. // private_price, _ := c.GetFloat("private_price")
  5695. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5696. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5697. //
  5698. // timeLayout := "2006-01-02"
  5699. // loc, _ := time.LoadLocation("Local")
  5700. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5701. // if err != nil {
  5702. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5703. // return
  5704. // }
  5705. // recordDateTime := theTime.Unix()
  5706. // adminUser := c.GetAdminUserInfo()
  5707. //
  5708. // var prescriptions []*models.HisPrescription
  5709. //
  5710. // data := make(map[string]interface{})
  5711. // if settle_accounts_type == 1 { //日结
  5712. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5713. // data["pre"] = prescriptions
  5714. //
  5715. // } else { //月结
  5716. // start_time_str := c.GetString("start_time")
  5717. // end_time_str := c.GetString("end_time")
  5718. // timeLayout := "2006-01-02"
  5719. // loc, _ := time.LoadLocation("Local")
  5720. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5721. // if err != nil {
  5722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5723. // return
  5724. // }
  5725. // recordStartTime := theStartTime.Unix()
  5726. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5727. // if err != nil {
  5728. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5729. // return
  5730. // }
  5731. // recordEndTime := theEndTime.Unix()
  5732. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5733. // data["pre"] = prescriptions
  5734. //
  5735. // }
  5736. //
  5737. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5738. //
  5739. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5740. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5741. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5742. // strconv.FormatInt(his.PatientId, 10)
  5743. //
  5744. // order_src, _ := service.GetHisOrderByID(order_id)
  5745. //
  5746. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5747. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5748. //
  5749. // var total float64
  5750. // for _, item := range prescriptions {
  5751. // if item.Type == 1 { //药品
  5752. // for _, subItem := range item.HisDoctorAdviceInfo {
  5753. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5754. // }
  5755. // }
  5756. // if item.Type == 2 { //项目
  5757. // for _, subItem := range item.HisPrescriptionProject {
  5758. // total = total + (subItem.Price * float64(subItem.Count))
  5759. // }
  5760. // }
  5761. // }
  5762. //
  5763. // for _, item := range prescriptions {
  5764. // for _, subItem := range item.HisAdditionalCharge {
  5765. // total = total + (subItem.Price * float64(subItem.Count))
  5766. // }
  5767. // }
  5768. //
  5769. // allTotal := fmt.Sprintf("%.2f", total)
  5770. // var rf []*ResultFive
  5771. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5772. // psn_no := order_src.PsnNo
  5773. // mdtrt_id := order_src.MdtrtId
  5774. // chrg_bchno := order_src.Number
  5775. // cert_no := order_src.Certno
  5776. // insutype := rf[0].Insutype
  5777. //
  5778. // if his.IdCardType == 1 {
  5779. // cert_no = his.MedicalInsuranceNumber
  5780. // } else {
  5781. // cert_no = his.Certno
  5782. // }
  5783. //
  5784. // 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)
  5785. // var dat map[string]interface{}
  5786. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5787. // fmt.Println(dat)
  5788. // } else {
  5789. // fmt.Println(err)
  5790. // }
  5791. //
  5792. // userJSONBytes, _ := json.Marshal(dat)
  5793. //
  5794. //
  5795. //
  5796. // var res ResultSeven
  5797. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5798. // utils.ErrorLog("解析失败:%v", err)
  5799. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5800. // return
  5801. // }
  5802. // if res.Infcode == -1 {
  5803. // errlog := &models.HisOrderError{
  5804. // UserOrgId: adminUser.CurrentOrgId,
  5805. // Ctime: time.Now().Unix(),
  5806. // Mtime: time.Now().Unix(),
  5807. // Number: chrg_bchno,
  5808. // ErrMsg: res.ErrMsg,
  5809. // Status: 1,
  5810. // PatientId: id,
  5811. // RecordTime: recordDateTime,
  5812. // Stage: 6,
  5813. // }
  5814. // service.CreateErrMsgLog(errlog)
  5815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5816. // return
  5817. // } else {
  5818. // order_src.OrderStatus = 2
  5819. // order_src.PayWay = pay_way
  5820. // order_src.PayPrice = pay_price
  5821. // order_src.PayCardNo = pay_card_no
  5822. // order_src.DiscountPrice = discount_price
  5823. // order_src.PreferentialPrice = preferential_price
  5824. // order_src.RealityPrice = reality_price
  5825. // order_src.FoundPrice = found_price
  5826. // order_src.MedicalInsurancePrice = medical_insurance_price
  5827. // order_src.PrivatePrice = private_price
  5828. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  5829. // order_src.SetlId = res.Output.Setlinfo.SetlID
  5830. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  5831. // order_src.PsnName = res.Output.Setlinfo.PsnName
  5832. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  5833. // order_src.Certno = res.Output.Setlinfo.Certno
  5834. // order_src.Gend = res.Output.Setlinfo.Gend
  5835. // order_src.Naty = res.Output.Setlinfo.Naty
  5836. // order_src.Age = res.Output.Setlinfo.Age
  5837. // order_src.Insutype = res.Output.Setlinfo.Insutype
  5838. // order_src.PsnType = res.Output.Setlinfo.PsnType
  5839. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5840. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  5841. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5842. // order_src.MedType = res.Output.Setlinfo.MedType
  5843. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5844. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5845. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5846. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5847. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5848. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5849. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  5850. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  5851. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5852. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  5853. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  5854. // order_src.MafPay = res.Output.Setlinfo.MafPay
  5855. // order_src.OthPay = res.Output.Setlinfo.OthPay
  5856. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5857. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5858. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  5859. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5860. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5861. // order_src.Balc = res.Output.Setlinfo.Balc
  5862. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5863. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5864. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  5865. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  5866. // order_src.Creator = order_src.Creator
  5867. // order_src.Modify = roles.ID
  5868. // order_src.RequestLog = src_resquest
  5869. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5870. // detailStr := string(setlDetail)
  5871. // order_src.SetlDetail = detailStr
  5872. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5873. // err = service.UpDateOrder(order_src)
  5874. //
  5875. // if err == nil {
  5876. // c.ServeSuccessJSON(map[string]interface{}{
  5877. // "msg": "结算成功",
  5878. // })
  5879. // } else {
  5880. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5881. // return
  5882. // }
  5883. // }
  5884. // }
  5885. //}
  5886. //退款
  5887. func (c *HisApiController) Refund() {
  5888. order_id, _ := c.GetInt64("order_id")
  5889. admin_user_id, _ := c.GetInt64("admin_user_id")
  5890. adminUser := c.GetAdminUserInfo()
  5891. var order models.HisOrder
  5892. order, _ = service.GetHisOrderByID(order_id)
  5893. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5894. if order.ID == 0 {
  5895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5896. return
  5897. }
  5898. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5899. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5900. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5901. if config.IsOpen == 1 { //对接了医保,走医保流程
  5902. var res ResultSixteen
  5903. var resSixteen10265 ResultSixteen10265
  5904. var src_resquest string
  5905. var result string
  5906. if miConfig.MdtrtareaAdmvs == "421300" {
  5907. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  5908. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5909. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5910. resp3, requestErr3 := http.Get(api3)
  5911. if requestErr3 != nil {
  5912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5913. return
  5914. }
  5915. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5916. if ioErr3 != nil {
  5917. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5919. return
  5920. }
  5921. var respJSON3 map[string]interface{}
  5922. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5925. return
  5926. }
  5927. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5928. userJSONBytes3, _ := json.Marshal(respJSON3)
  5929. fmt.Println("log")
  5930. fmt.Println(string(userJSONBytes3))
  5931. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5932. utils.ErrorLog("解析失败:%v", err)
  5933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5934. return
  5935. }
  5936. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5937. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  5938. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5939. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5940. resp3, requestErr3 := http.Get(api3)
  5941. if requestErr3 != nil {
  5942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5943. return
  5944. }
  5945. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5946. if ioErr3 != nil {
  5947. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5949. return
  5950. }
  5951. var respJSON3 map[string]interface{}
  5952. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5953. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5955. return
  5956. }
  5957. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5958. userJSONBytes3, _ := json.Marshal(respJSON3)
  5959. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  5960. utils.ErrorLog("解析失败:%v", err)
  5961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5962. return
  5963. }
  5964. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5965. res.Output = resSixteen10265.Output
  5966. res.ErrMsg = resSixteen10265.ErrMsg
  5967. res.Cainfo = resSixteen10265.Cainfo
  5968. res.WarnMsg = resSixteen10265.WarnMsg
  5969. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5970. res.Infcode = infocode
  5971. } else {
  5972. if miConfig.Code == "H15049901371" {
  5973. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5974. var dat map[string]interface{}
  5975. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5976. fmt.Println(dat)
  5977. } else {
  5978. fmt.Println(err)
  5979. }
  5980. saveLog(result, src_resquest, "2208", "退费")
  5981. userJSONBytes, _ := json.Marshal(dat)
  5982. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  5983. utils.ErrorLog("解析失败:%v", err)
  5984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5985. return
  5986. }
  5987. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5988. res.Output = resSixteen10265.Output
  5989. res.ErrMsg = resSixteen10265.ErrMsg
  5990. res.Cainfo = resSixteen10265.Cainfo
  5991. res.WarnMsg = resSixteen10265.WarnMsg
  5992. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5993. res.Infcode = infocode
  5994. } else {
  5995. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5996. var dat map[string]interface{}
  5997. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5998. fmt.Println(dat)
  5999. } else {
  6000. fmt.Println(err)
  6001. }
  6002. saveLog(result, src_resquest, "2208", "退费")
  6003. userJSONBytes, _ := json.Marshal(dat)
  6004. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6005. utils.ErrorLog("解析失败:%v", err)
  6006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6007. return
  6008. }
  6009. }
  6010. }
  6011. if res.Infcode == 0 {
  6012. var res2 ResultSix
  6013. var resSix10265 ResultSix10265
  6014. if miConfig.MdtrtareaAdmvs == "421300" {
  6015. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6016. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6017. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6018. resp3, requestErr3 := http.Get(api3)
  6019. if requestErr3 != nil {
  6020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6021. return
  6022. }
  6023. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6024. if ioErr3 != nil {
  6025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6027. return
  6028. }
  6029. var respJSON3 map[string]interface{}
  6030. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6033. return
  6034. }
  6035. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6036. userJSONBytes3, _ := json.Marshal(respJSON3)
  6037. fmt.Println("log")
  6038. fmt.Println(string(userJSONBytes3))
  6039. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6040. utils.ErrorLog("解析失败:%v", err)
  6041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6042. return
  6043. }
  6044. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6045. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6046. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6047. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6048. resp3, requestErr3 := http.Get(api3)
  6049. if requestErr3 != nil {
  6050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6051. return
  6052. }
  6053. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6054. if ioErr3 != nil {
  6055. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6057. return
  6058. }
  6059. var respJSON3 map[string]interface{}
  6060. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6061. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6063. return
  6064. }
  6065. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6066. userJSONBytes3, _ := json.Marshal(respJSON3)
  6067. fmt.Println("log")
  6068. fmt.Println(string(userJSONBytes3))
  6069. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6070. utils.ErrorLog("解析失败:%v", err)
  6071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6072. return
  6073. }
  6074. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6075. res2.Output = resSix10265.Output
  6076. res2.ErrMsg = resSix10265.ErrMsg
  6077. res2.Cainfo = resSix10265.Cainfo
  6078. res2.WarnMsg = resSix10265.WarnMsg
  6079. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6080. res2.Infcode = infocode
  6081. } else {
  6082. if miConfig.Code == "H15049901371" {
  6083. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6084. var dat map[string]interface{}
  6085. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6086. fmt.Println(dat)
  6087. } else {
  6088. fmt.Println(err)
  6089. }
  6090. saveLog(result2, src_request, "2205", "撤销明细")
  6091. userJSONBytes, _ := json.Marshal(dat)
  6092. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6093. utils.ErrorLog("解析失败:%v", err)
  6094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6095. return
  6096. }
  6097. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6098. res2.Output = resSix10265.Output
  6099. res2.ErrMsg = resSix10265.ErrMsg
  6100. res2.Cainfo = resSix10265.Cainfo
  6101. res2.WarnMsg = resSix10265.WarnMsg
  6102. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6103. res2.Infcode = infocode
  6104. } else {
  6105. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6106. var dat map[string]interface{}
  6107. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6108. fmt.Println(dat)
  6109. } else {
  6110. fmt.Println(err)
  6111. }
  6112. saveLog(result2, src_request, "2205", "撤销明细")
  6113. userJSONBytes, _ := json.Marshal(dat)
  6114. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6115. utils.ErrorLog("解析失败:%v", err)
  6116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6117. return
  6118. }
  6119. }
  6120. }
  6121. if res2.Infcode == 0 {
  6122. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6123. if err == nil {
  6124. c.ServeSuccessJSON(map[string]interface{}{
  6125. "msg": "退费成功",
  6126. })
  6127. } else {
  6128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6129. return
  6130. }
  6131. } else {
  6132. c.ServeSuccessJSON(map[string]interface{}{
  6133. "code": -10,
  6134. "msg": res2.ErrMsg,
  6135. })
  6136. }
  6137. } else {
  6138. c.ServeSuccessJSON(map[string]interface{}{
  6139. "code": -10,
  6140. "msg": res.ErrMsg,
  6141. })
  6142. }
  6143. }
  6144. }
  6145. func (c *HisApiController) RefundNumber() {
  6146. record_time := c.GetString("record_time")
  6147. //patient_id, _ := c.GetInt64("patient_id")
  6148. admin_user_id, _ := c.GetInt64("admin_user_id")
  6149. his_patient_id, _ := c.GetInt64("id")
  6150. timeLayout := "2006-01-02"
  6151. loc, _ := time.LoadLocation("Local")
  6152. adminUser := c.GetAdminUserInfo()
  6153. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6154. fmt.Println(err)
  6155. if err != nil {
  6156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6157. return
  6158. }
  6159. recordDateTime := theTime.Unix()
  6160. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6161. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6162. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6163. //order, _ := service.GetHisOrderByID(order_id)
  6164. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6165. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6166. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6167. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6168. if count > 0 {
  6169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6170. return
  6171. }
  6172. if config.IsOpen == 1 { //对接了医保,走医保流程
  6173. var res2 ResultSix
  6174. var resSix10265 ResultSix10265
  6175. if miConfig.MdtrtareaAdmvs == "421300" {
  6176. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6177. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6178. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6179. resp3, requestErr3 := http.Get(api3)
  6180. if requestErr3 != nil {
  6181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6182. return
  6183. }
  6184. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6185. if ioErr3 != nil {
  6186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6188. return
  6189. }
  6190. var respJSON3 map[string]interface{}
  6191. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6194. return
  6195. }
  6196. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6197. userJSONBytes3, _ := json.Marshal(respJSON3)
  6198. fmt.Println("log")
  6199. fmt.Println(string(userJSONBytes3))
  6200. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6201. utils.ErrorLog("解析失败:%v", err)
  6202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6203. return
  6204. }
  6205. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6206. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6207. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6208. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6209. resp3, requestErr3 := http.Get(api3)
  6210. if requestErr3 != nil {
  6211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6212. return
  6213. }
  6214. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6215. if ioErr3 != nil {
  6216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6218. return
  6219. }
  6220. var respJSON3 map[string]interface{}
  6221. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6224. return
  6225. }
  6226. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6227. userJSONBytes3, _ := json.Marshal(respJSON3)
  6228. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6229. utils.ErrorLog("解析失败:%v", err)
  6230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6231. return
  6232. }
  6233. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6234. res2.Output = resSix10265.Output
  6235. res2.ErrMsg = resSix10265.ErrMsg
  6236. res2.Cainfo = resSix10265.Cainfo
  6237. res2.WarnMsg = resSix10265.WarnMsg
  6238. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6239. res2.Infcode = infocode
  6240. } else {
  6241. var api3 string
  6242. if miConfig.Code == "H15049901371" {
  6243. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6244. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6245. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6246. } else {
  6247. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6248. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6249. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6250. }
  6251. resp3, requestErr3 := http.Get(api3)
  6252. if requestErr3 != nil {
  6253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6254. return
  6255. }
  6256. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6257. if ioErr3 != nil {
  6258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6260. return
  6261. }
  6262. var respJSON3 map[string]interface{}
  6263. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6266. return
  6267. }
  6268. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6269. userJSONBytes3, _ := json.Marshal(respJSON3)
  6270. if miConfig.Code == "H15049901371" {
  6271. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6272. utils.ErrorLog("解析失败:%v", err)
  6273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6274. return
  6275. }
  6276. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6277. res2.Output = resSix10265.Output
  6278. res2.ErrMsg = resSix10265.ErrMsg
  6279. res2.Cainfo = resSix10265.Cainfo
  6280. res2.WarnMsg = resSix10265.WarnMsg
  6281. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6282. res2.Infcode = infocode
  6283. } else {
  6284. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6285. utils.ErrorLog("解析失败:%v", err)
  6286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6287. return
  6288. }
  6289. }
  6290. }
  6291. if res2.Infcode == 0 {
  6292. if err == nil {
  6293. c.ServeSuccessJSON(map[string]interface{}{
  6294. "msg": "退号成功",
  6295. })
  6296. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6297. } else {
  6298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6299. return
  6300. }
  6301. } else {
  6302. c.ServeSuccessJSON(map[string]interface{}{
  6303. "code": -10,
  6304. "msg": res2.ErrMsg,
  6305. })
  6306. }
  6307. } else {
  6308. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6309. //if err == nil {
  6310. // c.ServeSuccessJSON(map[string]interface{}{
  6311. // "msg": "退费成功",
  6312. // })
  6313. //} else {
  6314. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6315. // return
  6316. //}
  6317. }
  6318. }
  6319. func (c *HisApiController) RefundDetail() {
  6320. order_id, _ := c.GetInt64("order_id")
  6321. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6322. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6323. number := c.GetString("number")
  6324. record_time := c.GetString("record_time")
  6325. patient_id, _ := c.GetInt64("patient_id")
  6326. timeLayout := "2006-01-02"
  6327. loc, _ := time.LoadLocation("Local")
  6328. adminUser := c.GetAdminUserInfo()
  6329. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6330. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6331. fmt.Println(err)
  6332. if err != nil {
  6333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6334. return
  6335. }
  6336. recordDateTime := theTime.Unix()
  6337. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6338. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6339. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6340. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6341. var order models.HisOrder
  6342. order, _ = service.GetHisOrderByID(order_id)
  6343. if order.ID == 0 {
  6344. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6345. }
  6346. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6347. if config.IsOpen == 1 { //对接了医保,走医保流程
  6348. var res2 ResultSix
  6349. if miConfig.MdtrtareaAdmvs == "421300" {
  6350. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6351. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6352. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6353. resp3, requestErr3 := http.Get(api3)
  6354. if requestErr3 != nil {
  6355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6356. return
  6357. }
  6358. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6359. if ioErr3 != nil {
  6360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6362. return
  6363. }
  6364. var respJSON3 map[string]interface{}
  6365. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6368. return
  6369. }
  6370. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6371. userJSONBytes3, _ := json.Marshal(respJSON3)
  6372. fmt.Println("log")
  6373. fmt.Println(string(userJSONBytes3))
  6374. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6375. utils.ErrorLog("解析失败:%v", err)
  6376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6377. return
  6378. }
  6379. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6380. if err == nil {
  6381. c.ServeSuccessJSON(map[string]interface{}{
  6382. "msg": "撤销明细成功",
  6383. })
  6384. return
  6385. } else {
  6386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6387. return
  6388. }
  6389. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6390. var resSix10265 ResultSix10265
  6391. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6392. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6393. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6394. resp3, requestErr3 := http.Get(api3)
  6395. if requestErr3 != nil {
  6396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6397. return
  6398. }
  6399. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6400. if ioErr3 != nil {
  6401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6403. return
  6404. }
  6405. var respJSON3 map[string]interface{}
  6406. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6409. return
  6410. }
  6411. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6412. userJSONBytes3, _ := json.Marshal(respJSON3)
  6413. fmt.Println("log")
  6414. fmt.Println(string(userJSONBytes3))
  6415. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6416. utils.ErrorLog("解析失败:%v", err)
  6417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6418. return
  6419. }
  6420. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6421. res2.Output = resSix10265.Output
  6422. res2.ErrMsg = resSix10265.ErrMsg
  6423. res2.Cainfo = resSix10265.Cainfo
  6424. res2.WarnMsg = resSix10265.WarnMsg
  6425. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6426. res2.Infcode = infocode
  6427. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6428. if err == nil {
  6429. c.ServeSuccessJSON(map[string]interface{}{
  6430. "msg": "撤销明细成功",
  6431. })
  6432. return
  6433. } else {
  6434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6435. return
  6436. }
  6437. } else {
  6438. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6439. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6440. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6441. resp2, requestErr2 := http.Get(api2)
  6442. if requestErr2 != nil {
  6443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6444. return
  6445. }
  6446. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6447. if ioErr2 != nil {
  6448. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6450. return
  6451. }
  6452. var respJSON2 map[string]interface{}
  6453. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6456. return
  6457. }
  6458. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6459. if err == nil {
  6460. c.ServeSuccessJSON(map[string]interface{}{
  6461. "msg": "撤销明细成功",
  6462. })
  6463. return
  6464. } else {
  6465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6466. return
  6467. }
  6468. }
  6469. } else {
  6470. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6471. if err == nil {
  6472. c.ServeSuccessJSON(map[string]interface{}{
  6473. "msg": "退费成功",
  6474. })
  6475. } else {
  6476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6477. return
  6478. }
  6479. }
  6480. }
  6481. //对账
  6482. func (c *HisApiController) GetCheckAccount() {
  6483. start_time := c.GetString("start_time")
  6484. end_time := c.GetString("end_time")
  6485. insutype := c.GetString("insutype")
  6486. clr_type := c.GetString("clr_type")
  6487. clr_org := c.GetString("clr_optins")
  6488. admin_user_id, _ := c.GetInt64("admin_user_id")
  6489. adminUser := c.GetAdminUserInfo()
  6490. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6491. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6492. if len(clr_org) == 0 {
  6493. clr_org = miConfig.MdtrtareaAdmvs
  6494. }
  6495. timeLayout := "2006-01-02"
  6496. loc, _ := time.LoadLocation("Local")
  6497. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6498. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6499. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6500. fixmedins_setl_cnt := int64(len(orders))
  6501. var medfee_sumamt float64
  6502. var acct_pay float64
  6503. var fund_pay_sumamt float64
  6504. for _, item := range orders {
  6505. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6506. acct_pay = acct_pay + item.AcctPay
  6507. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6508. }
  6509. var user_name string
  6510. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6511. if role.ID == 0 {
  6512. user_name = "xxx"
  6513. } else {
  6514. user_name = role.UserName
  6515. }
  6516. var res ResultEight
  6517. var res10188 ResultEightFor10188
  6518. if config.IsOpen == 1 {
  6519. if miConfig.MdtrtareaAdmvs == "320921" {
  6520. api := "http://192.168.3.111:9532/" + "jsyb/3201" +
  6521. "insutype=" + insutype +
  6522. "&clr_type=" + clr_type +
  6523. "&setl_optins=" + clr_org +
  6524. "&stmt_begndate=" + start_time +
  6525. "&stm_enddate=" + end_time +
  6526. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6527. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6528. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  6529. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6530. "&fixmedins_code=" + miConfig.Code +
  6531. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6532. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6533. "&secret_key=" + miConfig.SecretKey +
  6534. "&org_name=" + miConfig.OrgName +
  6535. "&doctor=" + user_name +
  6536. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6537. fmt.Println(api)
  6538. resp, requestErr := http.Get(api)
  6539. if requestErr != nil {
  6540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6541. return
  6542. }
  6543. body, ioErr := ioutil.ReadAll(resp.Body)
  6544. fmt.Println(body)
  6545. if ioErr != nil {
  6546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6548. return
  6549. }
  6550. var respJSON map[string]interface{}
  6551. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6554. return
  6555. }
  6556. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6557. userJSONBytes, _ := json.Marshal(respJSON)
  6558. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6559. utils.ErrorLog("解析失败:%v", err)
  6560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6561. return
  6562. }
  6563. res.InfRefmsgid = res10188.InfRefmsgid
  6564. res.Output = res10188.Output
  6565. res.ErrMsg = res10188.ErrMsg
  6566. res.Cainfo = res10188.Cainfo
  6567. res.WarnMsg = res10188.WarnMsg
  6568. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  6569. res.Infcode = infocode
  6570. } else {
  6571. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6572. "insutype=" + insutype +
  6573. "&clr_type=" + clr_type +
  6574. "&setl_optins=" + clr_org +
  6575. "&stmt_begndate=" + start_time +
  6576. "&stm_enddate=" + end_time +
  6577. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6578. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6579. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  6580. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6581. "&fixmedins_code=" + miConfig.Code +
  6582. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6583. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6584. "&secret_key=" + miConfig.SecretKey +
  6585. "&org_name=" + miConfig.OrgName +
  6586. "&doctor=" + user_name
  6587. fmt.Println(api)
  6588. resp, requestErr := http.Get(api)
  6589. if requestErr != nil {
  6590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6591. return
  6592. }
  6593. body, ioErr := ioutil.ReadAll(resp.Body)
  6594. fmt.Println(body)
  6595. if ioErr != nil {
  6596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6598. return
  6599. }
  6600. var respJSON map[string]interface{}
  6601. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6604. return
  6605. }
  6606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6607. userJSONBytes, _ := json.Marshal(respJSON)
  6608. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6609. utils.ErrorLog("解析失败:%v", err)
  6610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6611. return
  6612. }
  6613. }
  6614. if res.Infcode == 0 {
  6615. if res.Output.Stmtinfo.StmtRslt == "0" {
  6616. micc := &models.MedicalInsuranceCostCompare{
  6617. StartTime: startime.Unix(),
  6618. EndTime: endtime.Unix(),
  6619. Insutype: insutype,
  6620. CheckType: 1,
  6621. Num: fixmedins_setl_cnt,
  6622. Mtime: time.Now().Unix(),
  6623. Status: 1,
  6624. UserOrgId: adminUser.CurrentOrgId,
  6625. CostTotal: medfee_sumamt,
  6626. FuncTotal: fund_pay_sumamt,
  6627. PsnPay: acct_pay,
  6628. Creator: admin_user_id,
  6629. Ctime: time.Now().Unix(),
  6630. }
  6631. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  6632. if err == nil {
  6633. c.ServeSuccessJSON(map[string]interface{}{
  6634. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6635. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6636. })
  6637. } else {
  6638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6639. }
  6640. } else {
  6641. c.ServeSuccessJSON(map[string]interface{}{
  6642. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6643. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6644. })
  6645. }
  6646. } else {
  6647. c.ServeSuccessJSON(map[string]interface{}{
  6648. "code": -10,
  6649. "msg": res.ErrMsg,
  6650. })
  6651. }
  6652. }
  6653. }
  6654. func (c *HisApiController) Check310() {
  6655. adminUser := c.GetAdminUserInfo()
  6656. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6657. var user_name string
  6658. user_name = "高慧裕"
  6659. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6660. "insutype=" + "310" +
  6661. "&clr_type=" + "11" +
  6662. "&setl_optins=" + "441202" +
  6663. "&stmt_begndate=" + "2022-02-01" +
  6664. "&stm_enddate=" + "2022-02-28" +
  6665. "&medfee_sumamt=" + "155812.88" +
  6666. "&fund_pay_sumamt=" + "151026.15" +
  6667. "&acct_pay=" + "0" +
  6668. "&fixmedins_setl_cnt=" + "73" +
  6669. "&fixmedins_code=" + miConfig.Code +
  6670. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6671. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6672. "&secret_key=" + miConfig.SecretKey +
  6673. "&org_name=" + miConfig.OrgName +
  6674. "&doctor=" + user_name
  6675. fmt.Println(api)
  6676. resp, requestErr := http.Get(api)
  6677. if requestErr != nil {
  6678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6679. return
  6680. }
  6681. body, ioErr := ioutil.ReadAll(resp.Body)
  6682. fmt.Println(body)
  6683. if ioErr != nil {
  6684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6686. return
  6687. }
  6688. var respJSON map[string]interface{}
  6689. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6692. return
  6693. }
  6694. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6695. userJSONBytes, _ := json.Marshal(respJSON)
  6696. var res ResultEight
  6697. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6698. utils.ErrorLog("解析失败:%v", err)
  6699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6700. return
  6701. }
  6702. }
  6703. func (c *HisApiController) Check390() {
  6704. adminUser := c.GetAdminUserInfo()
  6705. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6706. var user_name string
  6707. user_name = "高慧裕"
  6708. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6709. "insutype=" + "390" +
  6710. "&clr_type=" + "11" +
  6711. "&setl_optins=" + "441202" +
  6712. "&stmt_begndate=" + "2022-02-01" +
  6713. "&stm_enddate=" + "2022-02-28" +
  6714. "&medfee_sumamt=" + "933920.08" +
  6715. "&fund_pay_sumamt=" + "887153.34" +
  6716. "&acct_pay=" + "0" +
  6717. "&fixmedins_setl_cnt=" + "396" +
  6718. "&fixmedins_code=" + miConfig.Code +
  6719. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6720. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6721. "&secret_key=" + miConfig.SecretKey +
  6722. "&org_name=" + miConfig.OrgName +
  6723. "&doctor=" + user_name
  6724. fmt.Println(api)
  6725. resp, requestErr := http.Get(api)
  6726. if requestErr != nil {
  6727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6728. return
  6729. }
  6730. body, ioErr := ioutil.ReadAll(resp.Body)
  6731. fmt.Println(body)
  6732. if ioErr != nil {
  6733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6735. return
  6736. }
  6737. var respJSON map[string]interface{}
  6738. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6741. return
  6742. }
  6743. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6744. userJSONBytes, _ := json.Marshal(respJSON)
  6745. var res ResultEight
  6746. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6747. utils.ErrorLog("解析失败:%v", err)
  6748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6749. return
  6750. }
  6751. }
  6752. //对账明细
  6753. func (c *HisApiController) GetCheckDetailAccount() {
  6754. start_time := c.GetString("start_time")
  6755. end_time := c.GetString("end_time")
  6756. admin_user_id, _ := c.GetInt64("admin_user_id")
  6757. adminUser := c.GetAdminUserInfo()
  6758. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6759. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6760. timeLayout := "2006-01-02"
  6761. loc, _ := time.LoadLocation("Local")
  6762. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6763. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6764. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  6765. Mkdir(miConfig.OrgName)
  6766. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  6767. file_name := file + ".txt"
  6768. zip_name := file + ".zip"
  6769. zip_path := miConfig.OrgName + "/" + zip_name
  6770. file_path := miConfig.OrgName + "/" + file_name
  6771. decimal.DivisionPrecision = 2
  6772. var medfee_sumamt float64
  6773. var psn_cash_pay float64
  6774. var fund_pay_sumamt float64
  6775. fixmedins_setl_cnt := int64(len(orders))
  6776. for _, item := range orders {
  6777. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6778. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  6779. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6780. }
  6781. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  6782. defer f.Close()
  6783. if err != nil {
  6784. fmt.Println(err.Error())
  6785. } else {
  6786. for _, item := range orders {
  6787. var refd_setl_flag string
  6788. if item.OrderStatus == 2 {
  6789. refd_setl_flag = "0"
  6790. var str string
  6791. str = item.SetlId + " " +
  6792. item.MdtrtId + " " +
  6793. item.PsnNo + " " +
  6794. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6795. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6796. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  6797. _, err = f.Write([]byte(str))
  6798. }
  6799. if item.OrderStatus == 3 {
  6800. var str string
  6801. str = item.SetlId + " " +
  6802. item.MdtrtId + " " +
  6803. item.PsnNo + " " +
  6804. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6805. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6806. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  6807. _, err = f.Write([]byte(str))
  6808. var str2 string
  6809. str2 = item.SetlId + " " +
  6810. item.MdtrtId + " " +
  6811. item.PsnNo + " " +
  6812. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  6813. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  6814. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  6815. _, err = f.Write([]byte(str2))
  6816. }
  6817. }
  6818. }
  6819. Zip(file_path, zip_path)
  6820. fmt.Println(ReadFile(zip_path))
  6821. fmt.Println(string(ReadFile(zip_path)))
  6822. if config.IsOpen == 1 {
  6823. var user_name string
  6824. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6825. if role.ID == 0 {
  6826. user_name = "管理员"
  6827. } else {
  6828. user_name = role.UserName
  6829. }
  6830. baseParams := models.BaseParams{
  6831. SecretKey: miConfig.SecretKey,
  6832. FixmedinsCode: miConfig.Code,
  6833. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6834. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6835. OrgName: miConfig.OrgName,
  6836. Doctor: user_name,
  6837. }
  6838. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  6839. var dat map[string]interface{}
  6840. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6841. fmt.Println(dat)
  6842. } else {
  6843. fmt.Println(err)
  6844. }
  6845. userJSONBytes, _ := json.Marshal(dat)
  6846. var res ResultNine
  6847. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6848. utils.ErrorLog("解析失败:%v", err)
  6849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6850. return
  6851. }
  6852. if res.Infcode == 0 {
  6853. fileNo := res.Output.FileQuryNo
  6854. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  6855. "file_qury_no=" + fileNo +
  6856. "&setl_optins=" + "定点医保中心" +
  6857. "&stmt_begndate=" + start_time +
  6858. "&stm_enddate=" + end_time +
  6859. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6860. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6861. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  6862. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6863. "&fixmedins_code=" + miConfig.Code +
  6864. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6865. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6866. "&secret_key=" + miConfig.SecretKey +
  6867. "&org_name=" + miConfig.OrgName +
  6868. "&doctor=" + user_name
  6869. resp, requestErr := http.Get(api)
  6870. if requestErr != nil {
  6871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6872. return
  6873. }
  6874. body, ioErr := ioutil.ReadAll(resp.Body)
  6875. if ioErr != nil {
  6876. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6878. return
  6879. }
  6880. var respJSON map[string]interface{}
  6881. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6884. return
  6885. }
  6886. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6887. userJSONBytes, _ := json.Marshal(respJSON)
  6888. var res ResultTen
  6889. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6890. utils.ErrorLog("解析失败:%v", err)
  6891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6892. return
  6893. }
  6894. if res.Infcode == 0 {
  6895. service.Gdyb9102(baseParams, zip_name, fileNo)
  6896. micc := &models.MedicalInsuranceCostCompare{
  6897. StartTime: startime.Unix(),
  6898. EndTime: endtime.Unix(),
  6899. Insutype: "0",
  6900. CheckType: 2,
  6901. Num: fixmedins_setl_cnt,
  6902. Mtime: time.Now().Unix(),
  6903. Status: 1,
  6904. UserOrgId: adminUser.CurrentOrgId,
  6905. CostTotal: medfee_sumamt,
  6906. FuncTotal: fund_pay_sumamt,
  6907. PsnPay: psn_cash_pay,
  6908. Creator: admin_user_id,
  6909. Ctime: time.Now().Unix(),
  6910. }
  6911. service.CreateMedicalInsuranceCostCompareRecord(micc)
  6912. c.ServeSuccessJSON(map[string]interface{}{
  6913. "msg": "明细对账成功",
  6914. })
  6915. }
  6916. } else {
  6917. }
  6918. }
  6919. }
  6920. type CustomOrderInfo struct {
  6921. Name string
  6922. Spec string
  6923. Unit string
  6924. Count float64
  6925. Price float64
  6926. Total float64
  6927. }
  6928. func (c *HisApiController) GetSettleAccounts() {
  6929. //id, _ := c.GetInt64("id")
  6930. //record_time := c.GetString("record_time")
  6931. order_id, _ := c.GetInt64("order_id")
  6932. admin_user_id, _ := c.GetInt64("admin_user_id")
  6933. //timeLayout := "2006-01-02"
  6934. //loc, _ := time.LoadLocation("Local")
  6935. //
  6936. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6937. //if err != nil {
  6938. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6939. // return
  6940. //}
  6941. //recordDateTime := theTime.Unix()
  6942. adminUser := c.GetAdminUserInfo()
  6943. order, _ := service.GetHisOrderByID(order_id)
  6944. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6945. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  6946. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  6947. orderInfos = append(orderInfos, orderInfos_two...)
  6948. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  6949. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6950. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  6951. //var config []*models.HisXtDiagnoseConfig
  6952. var name string
  6953. for _, item := range diagnosis_ids {
  6954. id, _ := strconv.ParseInt(item, 10, 64)
  6955. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6956. if len(name) == 0 {
  6957. name = diagnosisConfig.ClassName
  6958. } else {
  6959. name = name + "," + diagnosisConfig.ClassName
  6960. }
  6961. }
  6962. var bedCostTotal float64 = 0 //床位总费
  6963. var bedCostSelfTotal float64 = 0 //床位自费
  6964. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6965. var operationCostTotal float64 = 0 //手术费
  6966. var operationCostSelfTotal float64 = 0 //手术费
  6967. var operationCostPartSelfTotal float64 = 0 //手术费
  6968. var otherCostTotal float64 = 0 //其他费用
  6969. var otherCostSelfTotal float64 = 0 //其他费用
  6970. var otherCostPartSelfTotal float64 = 0 //其他费用
  6971. var materialCostTotal float64 = 0 //材料费
  6972. var materialCostSelfTotal float64 = 0 //材料费
  6973. var materialCostPartSelfTotal float64 = 0 //材料费
  6974. var westernMedicineCostTotal float64 = 0 //西药费
  6975. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6976. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6977. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6978. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6979. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6980. var checkCostTotal float64 = 0 //检查费
  6981. var checkCostSelfTotal float64 = 0 //检查费
  6982. var checkCostPartSelfTotal float64 = 0 //检查费
  6983. var laboratoryCostTotal float64 = 0 //化验费
  6984. var laboratoryCostSelfTotal float64 = 0 //化验费
  6985. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6986. var treatCostTotal float64 = 0 //治疗费用
  6987. var treatCostSelfTotal float64 = 0 //治疗费用
  6988. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6989. decimal.DivisionPrecision = 2
  6990. for _, item := range orderInfos {
  6991. if item.MedChrgitmType == "01" { //床位费
  6992. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6993. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6994. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6995. }
  6996. if item.MedChrgitmType == "03" { //检查费
  6997. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6998. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6999. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7000. }
  7001. if item.MedChrgitmType == "04" { //化验费
  7002. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7003. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7004. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7005. }
  7006. if item.MedChrgitmType == "05" { //治疗费
  7007. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7008. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7009. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7010. }
  7011. if item.MedChrgitmType == "06" { //手术费
  7012. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7013. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7014. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7015. }
  7016. if item.MedChrgitmType == "08" { //材料费
  7017. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7018. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7019. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7020. }
  7021. if item.MedChrgitmType == "09" { //西药费
  7022. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7023. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7024. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7025. }
  7026. if item.MedChrgitmType == "11" { //中成费
  7027. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7028. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7029. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7030. }
  7031. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  7032. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7033. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7034. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7035. }
  7036. }
  7037. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7038. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7039. var user_name string
  7040. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7041. if role.ID == 0 {
  7042. user_name = "管理员"
  7043. } else {
  7044. user_name = role.UserName
  7045. }
  7046. baseParams := models.BaseParams{
  7047. SecretKey: miConfig.SecretKey,
  7048. FixmedinsCode: miConfig.Code,
  7049. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7050. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7051. OrgName: miConfig.OrgName,
  7052. Doctor: user_name,
  7053. }
  7054. businessParams := models.BusinessParams{
  7055. PsnNo: order.PsnNo,
  7056. MdtrtId: order.MdtrtId,
  7057. SetlId: order.SetlId,
  7058. }
  7059. var res ResultEleven
  7060. var resEleven10265 ResultEleven10265
  7061. if config.IsOpen == 1 {
  7062. if miConfig.MdtrtareaAdmvs == "421300" {
  7063. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7064. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7065. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7066. resp, requestErr := http.Get(api)
  7067. if requestErr != nil {
  7068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7069. return
  7070. }
  7071. body, ioErr := ioutil.ReadAll(resp.Body)
  7072. if ioErr != nil {
  7073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7075. return
  7076. }
  7077. var respJSON map[string]interface{}
  7078. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7081. return
  7082. }
  7083. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7084. result, _ := json.Marshal(respJSON)
  7085. fmt.Println("log")
  7086. fmt.Println(string(result))
  7087. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7088. utils.ErrorLog("解析失败:%v", err)
  7089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7090. return
  7091. }
  7092. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7093. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7094. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7095. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7096. resp, requestErr := http.Get(api)
  7097. if requestErr != nil {
  7098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7099. return
  7100. }
  7101. body, ioErr := ioutil.ReadAll(resp.Body)
  7102. if ioErr != nil {
  7103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7105. return
  7106. }
  7107. var respJSON map[string]interface{}
  7108. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7111. return
  7112. }
  7113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7114. result, _ := json.Marshal(respJSON)
  7115. fmt.Println("log")
  7116. fmt.Println(string(result))
  7117. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7118. utils.ErrorLog("解析失败:%v", err)
  7119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7120. return
  7121. }
  7122. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7123. res.Output = resEleven10265.Output
  7124. res.ErrMsg = resEleven10265.ErrMsg
  7125. res.Cainfo = resEleven10265.Cainfo
  7126. res.WarnMsg = resEleven10265.WarnMsg
  7127. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7128. res.Infcode = infocode
  7129. } else {
  7130. result2 := service.Gdyb5204(baseParams, businessParams)
  7131. saveLog(result2, "", "5204", "查询")
  7132. result := service.Gdyb5203(baseParams, businessParams)
  7133. var dat map[string]interface{}
  7134. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7135. fmt.Println(dat)
  7136. } else {
  7137. fmt.Println(err)
  7138. }
  7139. userJSONBytes, _ := json.Marshal(dat)
  7140. if miConfig.Code == "H15049901371" {
  7141. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7142. utils.ErrorLog("解析失败:%v", err)
  7143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7144. return
  7145. }
  7146. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7147. res.Output = resEleven10265.Output
  7148. res.ErrMsg = resEleven10265.ErrMsg
  7149. res.Cainfo = resEleven10265.Cainfo
  7150. res.WarnMsg = resEleven10265.WarnMsg
  7151. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7152. res.Infcode = infocode
  7153. } else {
  7154. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7155. utils.ErrorLog("解析失败:%v", err)
  7156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7157. return
  7158. }
  7159. }
  7160. }
  7161. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7162. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7163. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7164. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7165. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7166. var doctor_name string
  7167. if roles.ID == 0 {
  7168. doctor_name = "管理员"
  7169. } else {
  7170. doctor_name = roles.UserName
  7171. }
  7172. yiliao_leibie := ""
  7173. switch order.MedType {
  7174. case "11":
  7175. yiliao_leibie = "普通门诊"
  7176. break
  7177. case "12":
  7178. yiliao_leibie = "门诊挂号"
  7179. break
  7180. case "13":
  7181. yiliao_leibie = "急诊"
  7182. break
  7183. case "14":
  7184. yiliao_leibie = "门诊特殊病"
  7185. break
  7186. case "15":
  7187. yiliao_leibie = "门诊统筹"
  7188. break
  7189. case "16":
  7190. yiliao_leibie = "门诊慢性病"
  7191. break
  7192. case "21":
  7193. yiliao_leibie = "普通住院"
  7194. break
  7195. }
  7196. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7197. if res.Infcode == 0 {
  7198. c.ServeSuccessJSON(map[string]interface{}{
  7199. "diagnosis": name,
  7200. "order_infos": orderInfos,
  7201. "number": order.MdtrtId,
  7202. "date": order.SettleAccountsDate,
  7203. "charge_admin": charge_admin,
  7204. "printor_admin": printor_admin,
  7205. "info": res.Output.Setlinfo,
  7206. "bedCostTotal": bedCostTotal,
  7207. "bedCostSelfTotal": bedCostSelfTotal,
  7208. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  7209. "operationCostTotal": operationCostTotal,
  7210. "operationCostSelfTotal": operationCostSelfTotal,
  7211. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  7212. "otherCostTotal": otherCostTotal,
  7213. "otherCostSelfTotal": otherCostSelfTotal,
  7214. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  7215. "materialCostTotal": materialCostTotal,
  7216. "materialCostSelfTotal": materialCostSelfTotal,
  7217. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  7218. "westernMedicineCostTotal": westernMedicineCostTotal,
  7219. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  7220. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  7221. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  7222. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  7223. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  7224. "checkCostTotal": checkCostTotal,
  7225. "checkCostSelfTotal": checkCostSelfTotal,
  7226. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  7227. "laboratoryCostTotal": laboratoryCostTotal,
  7228. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  7229. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  7230. "treatCostTotal": treatCostTotal,
  7231. "treatCostSelfTotal": treatCostSelfTotal,
  7232. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  7233. "doctor_code": adminRole_two.DoctorCode,
  7234. "doctor_name": doctor_name,
  7235. "health_card_no": order.PsnNo,
  7236. "department": departments.Name,
  7237. "yiliao_leibie": yiliao_leibie,
  7238. "after_money": order.AccountPrice,
  7239. "patient": patient,
  7240. "org_name": miConfig.OrgName,
  7241. "org_code": miConfig.Code,
  7242. "order_number": order.Number,
  7243. //"check_order_info": cus_slice,
  7244. })
  7245. }
  7246. }
  7247. }
  7248. func (c *HisApiController) CheckTreatment() {
  7249. patient_id, _ := c.GetInt64("patient_id")
  7250. id_card_no := c.GetString("id_card_no")
  7251. insutype := c.GetString("insutype")
  7252. med_type := c.GetString("med_type")
  7253. admin_user_id, _ := c.GetInt64("admin_user_id")
  7254. adminUser := c.GetAdminUserInfo()
  7255. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7256. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7257. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7258. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7259. if miConfig.MdtrtareaAdmvs == "421300" {
  7260. var res ResultTwo
  7261. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7262. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7263. "&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)
  7264. resp, requestErr := http.Get(api)
  7265. if requestErr != nil {
  7266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7267. return
  7268. }
  7269. body, ioErr := ioutil.ReadAll(resp.Body)
  7270. if ioErr != nil {
  7271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7273. return
  7274. }
  7275. var respJSON map[string]interface{}
  7276. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7279. return
  7280. }
  7281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7282. result, _ := json.Marshal(respJSON)
  7283. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7284. utils.ErrorLog("解析失败:%v", err)
  7285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7286. return
  7287. }
  7288. if res.Infcode == 0 {
  7289. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7290. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7291. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7292. resp, requestErr := http.Get(api)
  7293. if requestErr != nil {
  7294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7295. return
  7296. }
  7297. body, ioErr := ioutil.ReadAll(resp.Body)
  7298. if ioErr != nil {
  7299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7301. return
  7302. }
  7303. var respJSON map[string]interface{}
  7304. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7307. return
  7308. }
  7309. var res Result2001
  7310. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7311. result2, _ := json.Marshal(respJSON)
  7312. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7313. utils.ErrorLog("解析失败:%v", err)
  7314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7315. return
  7316. }
  7317. if res.Infcode == 0 {
  7318. c.ServeSuccessJSON(map[string]interface{}{
  7319. "msg": res.Output.Trtinfo,
  7320. })
  7321. }
  7322. } else {
  7323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7324. return
  7325. }
  7326. } else {
  7327. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7328. var dat map[string]interface{}
  7329. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7330. fmt.Println(dat)
  7331. } else {
  7332. fmt.Println(err)
  7333. }
  7334. userJSONBytes, _ := json.Marshal(dat)
  7335. var res ResultTwo
  7336. var res10265 ResultTwo10265
  7337. if miConfig.Code == "H15049901371" {
  7338. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7339. utils.ErrorLog("解析失败:%v", err)
  7340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7341. return
  7342. }
  7343. res.ErrMsg = res10265.ErrMsg
  7344. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7345. res.Infcode = infocode
  7346. res.Output = res10265.Output
  7347. res.InfRefmsgid = res10265.InfRefmsgid
  7348. } else {
  7349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7350. utils.ErrorLog("解析失败:%v", err)
  7351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7352. return
  7353. }
  7354. }
  7355. var user_name string
  7356. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7357. if role.ID == 0 {
  7358. user_name = "xxx"
  7359. } else {
  7360. user_name = role.UserName
  7361. }
  7362. baseParams := models.BaseParams{
  7363. SecretKey: miConfig.SecretKey,
  7364. FixmedinsCode: miConfig.Code,
  7365. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7366. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7367. OrgName: miConfig.OrgName,
  7368. Doctor: user_name,
  7369. }
  7370. if config.IsOpen == 1 {
  7371. if miConfig.Code == "H15049901371" {
  7372. if med_type == "14" {
  7373. if insutype == "390" {
  7374. med_type = "9933"
  7375. } else if insutype == "310" {
  7376. med_type = "990502"
  7377. }
  7378. } else if med_type == "11" {
  7379. med_type = "11"
  7380. }
  7381. }
  7382. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7383. var dat map[string]interface{}
  7384. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7385. fmt.Println(dat)
  7386. } else {
  7387. fmt.Println(err)
  7388. }
  7389. var res Result2001
  7390. var res10265 Result2001Org10265
  7391. if miConfig.Code == "H15049901371" {
  7392. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7393. utils.ErrorLog("解析失败:%v", err)
  7394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7395. return
  7396. }
  7397. res.ErrMsg = res10265.ErrMsg
  7398. res.Output = res10265.Output
  7399. res.InfRefmsgid = res10265.InfRefmsgid
  7400. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7401. res.Infcode = infocode
  7402. } else {
  7403. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7404. utils.ErrorLog("解析失败:%v", err)
  7405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7406. return
  7407. }
  7408. }
  7409. if res.Infcode == 0 {
  7410. c.ServeSuccessJSON(map[string]interface{}{
  7411. "msg": res.Output.Trtinfo,
  7412. })
  7413. }
  7414. }
  7415. }
  7416. }
  7417. //func (c *HisApiController) PutRecord() {
  7418. // id, _ := c.GetInt64("id")
  7419. // record_time := c.GetString("record_time")
  7420. // timeLayout := "2006-01-02"
  7421. // loc, _ := time.LoadLocation("Local")
  7422. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7423. // if err != nil {
  7424. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7425. // return
  7426. // }
  7427. // recordDateTime := theTime.Unix()
  7428. //
  7429. // adminInfo := c.GetAdminUserInfo()
  7430. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7431. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7432. //
  7433. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7434. //
  7435. // fmt.Println(miConfig.SecretKey)
  7436. //
  7437. // if patient == nil {
  7438. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7439. // return
  7440. // }
  7441. // if len(patient.IdCardNo) == 0 {
  7442. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7443. // return
  7444. // }
  7445. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7446. // if config.IsOpen == 1 {
  7447. // 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
  7448. // resp, requestErr := http.Get(api)
  7449. // if requestErr != nil {
  7450. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7451. // return
  7452. // }
  7453. // defer resp.Body.Close()
  7454. // body, ioErr := ioutil.ReadAll(resp.Body)
  7455. // if ioErr != nil {
  7456. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7457. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7458. // return
  7459. // }
  7460. // var respJSON map[string]interface{}
  7461. //
  7462. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7463. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7464. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7465. // return
  7466. // }
  7467. //
  7468. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7469. // userJSONBytes, _ := json.Marshal(userJSON)
  7470. // var res ResultTwo
  7471. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7472. // utils.ErrorLog("解析失败:%v", err)
  7473. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7474. // return
  7475. // }
  7476. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7477. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7478. // infoStr := string(Iinfos)
  7479. // idetinfoStr := string(Idetinfos)
  7480. //
  7481. // if res.Infcode == 0 {
  7482. // his := models.VMHisPatient{
  7483. // Status: 1,
  7484. // Ctime: time.Now().Unix(),
  7485. // Mtime: time.Now().Unix(),
  7486. // PsnNo: res.Output.Baseinfo.PsnNo,
  7487. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7488. // Certno: res.Output.Baseinfo.Certno,
  7489. // PsnName: res.Output.Baseinfo.PsnName,
  7490. // Gend: res.Output.Baseinfo.Gend,
  7491. // Naty: res.Output.Baseinfo.Naty,
  7492. // Brdy: res.Output.Baseinfo.Brdy,
  7493. // Age: res.Output.Baseinfo.Age,
  7494. // Iinfo: infoStr,
  7495. // Idetinfo: idetinfoStr,
  7496. // PatientId: patient.ID,
  7497. // RecordDate: theTime.Unix(),
  7498. // UserOrgId: adminInfo.CurrentOrgId,
  7499. // AdminUserId: adminInfo.AdminUser.Id,
  7500. // IsReturn: 1,
  7501. // }
  7502. //
  7503. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  7504. // //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")
  7505. // //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")
  7506. //
  7507. // //var dat map[string]interface{}
  7508. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7509. // // fmt.Println(dat)
  7510. // //} else {
  7511. // // fmt.Println(err)
  7512. // //}
  7513. //
  7514. // var dat2 map[string]interface{}
  7515. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  7516. // fmt.Println(dat2)
  7517. // } else {
  7518. // fmt.Println(err)
  7519. // }
  7520. //
  7521. // } else {
  7522. // adminUser := c.GetAdminUserInfo()
  7523. // errlog := &models.HisOrderError{
  7524. // UserOrgId: adminUser.CurrentOrgId,
  7525. // Ctime: time.Now().Unix(),
  7526. // Mtime: time.Now().Unix(),
  7527. // ErrMsg: res.ErrMsg,
  7528. // Status: 1,
  7529. // PatientId: id,
  7530. // RecordTime: recordDateTime,
  7531. // Stage: 1,
  7532. // }
  7533. // service.CreateErrMsgLog(errlog)
  7534. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7535. // return
  7536. // }
  7537. // }
  7538. //
  7539. //}
  7540. //func (c *HisApiController) GetUploadDiag() {
  7541. // id, _ := c.GetInt64("id")
  7542. // record_time := c.GetString("record_time")
  7543. //
  7544. // diagnosis_id, _ := c.GetInt64("diagnosis")
  7545. // sick_type, _ := c.GetInt64("sick_type")
  7546. // reg_type, _ := c.GetInt64("reg_type")
  7547. //
  7548. // timeLayout := "2006-01-02"
  7549. // loc, _ := time.LoadLocation("Local")
  7550. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7551. // if err != nil {
  7552. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7553. // return
  7554. // }
  7555. //
  7556. // var patientPrescription models.HisPrescriptionInfo
  7557. // recordDateTime := theTime.Unix()
  7558. // adminInfo := c.GetAdminUserInfo()
  7559. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7560. //
  7561. // if patientPrescription.ID == 0 {
  7562. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7563. // }
  7564. //
  7565. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7566. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7567. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7568. // sickConfig, _ := service.FindSickById(sick_type)
  7569. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7570. //
  7571. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  7572. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  7573. // "&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 +
  7574. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  7575. // resp2, requestErr2 := http.Get(api2)
  7576. // if requestErr2 != nil {
  7577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7578. // return
  7579. // }
  7580. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7581. // if ioErr2 != nil {
  7582. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7583. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7584. // return
  7585. // }
  7586. // var respJSON2 map[string]interface{}
  7587. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7588. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7589. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7590. // return
  7591. // }
  7592. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7593. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7594. //
  7595. // var res2 ResultSix
  7596. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7597. // utils.ErrorLog("解析失败:%v", err)
  7598. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7599. // return
  7600. // }
  7601. // if res2.Infcode != 0 {
  7602. // adminUser := c.GetAdminUserInfo()
  7603. // errlog := &models.HisOrderError{
  7604. // UserOrgId: adminUser.CurrentOrgId,
  7605. // Ctime: time.Now().Unix(),
  7606. // Mtime: time.Now().Unix(),
  7607. // ErrMsg: res2.ErrMsg,
  7608. // Status: 1,
  7609. // PatientId: id,
  7610. // RecordTime: recordDateTime,
  7611. // Stage: 3,
  7612. // }
  7613. // service.CreateErrMsgLog(errlog)
  7614. //
  7615. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  7616. // return
  7617. // }
  7618. //
  7619. // c.ServeSuccessJSON(map[string]interface{}{
  7620. // "msg": "上传成功",
  7621. // })
  7622. //
  7623. //}
  7624. type QueryResult struct {
  7625. ID int64
  7626. Name string
  7627. Code string
  7628. List_type_code string
  7629. }
  7630. func (c *HisApiController) GetCheckCode() {
  7631. ids_str := c.GetString("ids")
  7632. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7633. ids_arr := strings.Split(ids_str, ",")
  7634. var queryResult []QueryResult
  7635. ids := make([]int64, 0)
  7636. for _, item := range ids_arr {
  7637. id, _ := strconv.ParseInt(item, 10, 64)
  7638. ids = append(ids, id)
  7639. }
  7640. if record_type == 1 {
  7641. drugs, _ := service.GetBatchDrugList(ids)
  7642. for _, item := range drugs {
  7643. result := QueryResult{
  7644. ID: item.ID,
  7645. Name: item.DrugName,
  7646. Code: item.MedicalInsuranceNumber,
  7647. List_type_code: "101",
  7648. }
  7649. queryResult = append(queryResult, result)
  7650. }
  7651. } else if record_type == 2 {
  7652. goods, _ := service.GetBatchGoodInformationList(ids)
  7653. for _, item := range goods {
  7654. result := QueryResult{
  7655. ID: item.ID,
  7656. Name: item.GoodName,
  7657. Code: item.MedicalInsuranceNumber,
  7658. List_type_code: "301",
  7659. }
  7660. queryResult = append(queryResult, result)
  7661. }
  7662. } else if record_type == 3 {
  7663. projects, _ := service.GetBathchMyPorjecgList(ids)
  7664. for _, item := range projects {
  7665. result := QueryResult{
  7666. ID: item.ID,
  7667. Name: item.ProjectName,
  7668. Code: item.MedicalCode,
  7669. List_type_code: "201",
  7670. }
  7671. queryResult = append(queryResult, result)
  7672. }
  7673. }
  7674. admin_user_id, _ := c.GetInt64("admin_user_id")
  7675. adminUser := c.GetAdminUserInfo()
  7676. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7677. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7678. var user_name string
  7679. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7680. if role.ID == 0 {
  7681. user_name = "xxx"
  7682. } else {
  7683. user_name = role.UserName
  7684. }
  7685. baseParams := &models.BaseParams{
  7686. SecretKey: miConfig.SecretKey,
  7687. FixmedinsCode: miConfig.Code,
  7688. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7689. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7690. OrgName: miConfig.OrgName,
  7691. Doctor: user_name,
  7692. }
  7693. if config.IsOpen == 1 {
  7694. for _, item := range queryResult {
  7695. var result string
  7696. if record_type == 1 {
  7697. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7698. } else if record_type == 2 {
  7699. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7700. } else if record_type == 3 {
  7701. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7702. }
  7703. var dat map[string]interface{}
  7704. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7705. fmt.Println(dat)
  7706. } else {
  7707. fmt.Println(err)
  7708. }
  7709. userJSONBytes, _ := json.Marshal(dat)
  7710. var res ResultSix
  7711. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7712. utils.ErrorLog("解析失败:%v", err)
  7713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7714. return
  7715. }
  7716. if res.Infcode == 0 {
  7717. if record_type == 1 {
  7718. service.UpdateBaseDrugById(item.ID)
  7719. } else if record_type == 2 {
  7720. service.UpdateGoodInformaitonByDetail(item.ID)
  7721. } else if record_type == 3 {
  7722. service.UpdateProjectById(item.ID)
  7723. }
  7724. c.ServeSuccessJSON(map[string]interface{}{
  7725. "failed_code": 0,
  7726. "msg": "目录对照成功",
  7727. })
  7728. } else {
  7729. c.ServeSuccessJSON(map[string]interface{}{
  7730. "failed_code": -10,
  7731. "msg": res.ErrMsg,
  7732. })
  7733. }
  7734. }
  7735. }
  7736. }
  7737. func (c *HisApiController) UnCheckCode() {
  7738. ids_str := c.GetString("ids")
  7739. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7740. admin_user_id, _ := c.GetInt64("admin_user_id")
  7741. ids_arr := strings.Split(ids_str, ",")
  7742. var queryResult []QueryResult
  7743. ids := make([]int64, 0)
  7744. for _, item := range ids_arr {
  7745. id, _ := strconv.ParseInt(item, 10, 64)
  7746. ids = append(ids, id)
  7747. }
  7748. if record_type == 1 {
  7749. drugs, _ := service.GetBatchDrugList(ids)
  7750. for _, item := range drugs {
  7751. result := QueryResult{
  7752. ID: item.ID,
  7753. Name: item.DrugName,
  7754. Code: item.MedicalInsuranceNumber,
  7755. List_type_code: "101",
  7756. }
  7757. queryResult = append(queryResult, result)
  7758. }
  7759. } else if record_type == 2 {
  7760. goods, _ := service.GetBatchGoodInformationList(ids)
  7761. for _, item := range goods {
  7762. result := QueryResult{
  7763. ID: item.ID,
  7764. Name: item.GoodName,
  7765. Code: item.MedicalInsuranceNumber,
  7766. List_type_code: "301",
  7767. }
  7768. queryResult = append(queryResult, result)
  7769. }
  7770. } else if record_type == 3 {
  7771. projects, _ := service.GetBathchMyPorjecgList(ids)
  7772. for _, item := range projects {
  7773. result := QueryResult{
  7774. ID: item.ID,
  7775. Name: item.ProjectName,
  7776. Code: item.MedicalCode,
  7777. List_type_code: "201",
  7778. }
  7779. queryResult = append(queryResult, result)
  7780. }
  7781. }
  7782. adminUser := c.GetAdminUserInfo()
  7783. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7784. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7785. var user_name string
  7786. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7787. if role.ID == 0 {
  7788. user_name = "xxx"
  7789. } else {
  7790. user_name = role.UserName
  7791. }
  7792. baseParams := &models.BaseParams{
  7793. SecretKey: miConfig.SecretKey,
  7794. FixmedinsCode: miConfig.Code,
  7795. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7796. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7797. OrgName: miConfig.OrgName,
  7798. Doctor: user_name,
  7799. }
  7800. if config.IsOpen == 1 {
  7801. for _, item := range queryResult {
  7802. var result string
  7803. if record_type == 1 {
  7804. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7805. } else if record_type == 2 {
  7806. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7807. } else if record_type == 3 {
  7808. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7809. }
  7810. var dat2 map[string]interface{}
  7811. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  7812. fmt.Println(dat2)
  7813. } else {
  7814. fmt.Println(err)
  7815. }
  7816. userJSONBytes, _ := json.Marshal(dat2)
  7817. var res ResultSix
  7818. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7819. utils.ErrorLog("解析失败:%v", err)
  7820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7821. return
  7822. }
  7823. if res.Infcode == 0 {
  7824. if record_type == 1 {
  7825. service.UpdateDrugByIdDetail(item.ID)
  7826. } else if record_type == 2 {
  7827. service.UpdateGoodInfoById(item.ID)
  7828. } else if record_type == 3 {
  7829. service.UpdateMyProjectById(item.ID)
  7830. }
  7831. c.ServeSuccessJSON(map[string]interface{}{
  7832. "failed_code": 0,
  7833. "msg": "撤销目录对照成功",
  7834. })
  7835. } else {
  7836. c.ServeSuccessJSON(map[string]interface{}{
  7837. "failed_code": -10,
  7838. "msg": res.ErrMsg,
  7839. })
  7840. }
  7841. }
  7842. }
  7843. }
  7844. func (c *HisApiController) GetPatientInfo() {
  7845. id_card_no := c.GetString("id_card_no")
  7846. admin_user_id, _ := c.GetInt64("admin_user_id")
  7847. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  7848. if patient.ID == 0 {
  7849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7850. return
  7851. }
  7852. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7853. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7854. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  7855. if config.IsOpen == 1 {
  7856. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7857. var dat map[string]interface{}
  7858. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7859. fmt.Println(dat)
  7860. } else {
  7861. fmt.Println(err)
  7862. }
  7863. userJSONBytes, _ := json.Marshal(dat)
  7864. var res ResultTwo
  7865. var res10265 ResultTwo10265
  7866. if miConfig.Code == "H15049901371" {
  7867. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7868. utils.ErrorLog("解析失败:%v", err)
  7869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7870. return
  7871. }
  7872. res.ErrMsg = res10265.ErrMsg
  7873. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7874. res.Infcode = infocode
  7875. res.Output = res10265.Output
  7876. res.InfRefmsgid = res10265.InfRefmsgid
  7877. } else {
  7878. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7879. utils.ErrorLog("解析失败:%v", err)
  7880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7881. return
  7882. }
  7883. }
  7884. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7885. // utils.ErrorLog("解析失败:%v", err)
  7886. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7887. // return
  7888. //}
  7889. if res.Infcode != 0 {
  7890. c.ServeSuccessJSON(map[string]interface{}{
  7891. "failed_code": -10,
  7892. "msg": res.ErrMsg,
  7893. })
  7894. } else {
  7895. c.ServeSuccessJSON(map[string]interface{}{
  7896. "failed_code": 0,
  7897. "info": res,
  7898. })
  7899. }
  7900. }
  7901. }
  7902. func (c *HisApiController) PsnPutOnRecord() {
  7903. record_type, _ := c.GetInt64("type")
  7904. patient_id, _ := c.GetInt64("patient_id")
  7905. admin_user_id, _ := c.GetInt64("admin_user_id")
  7906. start_time := c.GetString("start_time")
  7907. end_time := c.GetString("end_time")
  7908. adminUser := c.GetAdminUserInfo()
  7909. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7910. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7911. var patients []*models.Patients
  7912. if record_type == 1 { //全部备案
  7913. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  7914. patients = append(patients, patient...)
  7915. } else { //单个备案
  7916. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7917. patients = append(patients, patient)
  7918. }
  7919. var user_name string
  7920. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7921. if role.ID == 0 {
  7922. user_name = "xxx"
  7923. } else {
  7924. user_name = role.UserName
  7925. }
  7926. if config.IsOpen == 1 {
  7927. for _, item := range patients {
  7928. 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
  7929. resp, requestErr := http.Get(api)
  7930. if requestErr != nil {
  7931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7932. return
  7933. }
  7934. defer resp.Body.Close()
  7935. body, ioErr := ioutil.ReadAll(resp.Body)
  7936. if ioErr != nil {
  7937. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7939. return
  7940. }
  7941. var respJSON map[string]interface{}
  7942. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7945. return
  7946. }
  7947. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7948. userJSONBytes, _ := json.Marshal(userJSON)
  7949. var res ResultTwo
  7950. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7951. utils.ErrorLog("解析失败:%v", err)
  7952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7953. return
  7954. }
  7955. if res.Infcode == 0 {
  7956. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  7957. var dat map[string]interface{}
  7958. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7959. fmt.Println(dat)
  7960. } else {
  7961. fmt.Println(err)
  7962. }
  7963. userJSONBytes, _ := json.Marshal(dat)
  7964. var res2 ResultThirteen
  7965. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7966. utils.ErrorLog("解析失败:%v", err)
  7967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7968. return
  7969. }
  7970. if res2.Infcode == 0 {
  7971. psnResult := &models.GdybPsnRecord{
  7972. UserOrgId: adminUser.CurrentOrgId,
  7973. PatientId: item.ID,
  7974. PsnNo: res.Output.Baseinfo.PsnNo,
  7975. Ctime: time.Now().Unix(),
  7976. Mtime: time.Now().Unix(),
  7977. Status: 1,
  7978. IsCancel: 1,
  7979. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7980. }
  7981. service.CreatePsnRecord(psnResult)
  7982. } else {
  7983. c.ServeSuccessJSON(map[string]interface{}{
  7984. "failed_code": -10,
  7985. "msg": res2.ErrMsg,
  7986. })
  7987. return
  7988. }
  7989. }
  7990. }
  7991. }
  7992. }
  7993. func (c *HisApiController) PsnUnPutOnRecord() {
  7994. id, _ := c.GetInt64("id")
  7995. //record_type, _ := c.GetInt64("type")
  7996. admin_user_id, _ := c.GetInt64("admin_user_id")
  7997. adminUser := c.GetAdminUserInfo()
  7998. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7999. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8000. var user_name string
  8001. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8002. if role.ID == 0 {
  8003. user_name = "xxx"
  8004. } else {
  8005. user_name = role.UserName
  8006. }
  8007. psn_record, _ := service.GetPsnRecordById(id)
  8008. if psn_record.ID == 0 {
  8009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8010. return
  8011. }
  8012. if config.IsOpen == 1 {
  8013. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8014. var dat map[string]interface{}
  8015. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8016. fmt.Println(dat)
  8017. } else {
  8018. fmt.Println(err)
  8019. }
  8020. userJSONBytes, _ := json.Marshal(dat)
  8021. var res ResultFourteen
  8022. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8023. utils.ErrorLog("解析失败:%v", err)
  8024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8025. return
  8026. }
  8027. if res.Infcode == 0 {
  8028. psn_record.IsCancel = 2
  8029. service.CreatePsnRecord(&psn_record)
  8030. } else {
  8031. c.ServeSuccessJSON(map[string]interface{}{
  8032. "failed_code": -10,
  8033. "msg": res.ErrMsg,
  8034. })
  8035. return
  8036. }
  8037. }
  8038. }
  8039. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8040. patient_id, _ := c.GetInt64("patient_id")
  8041. insutype_two := c.GetString("insutype")
  8042. psn_no := c.GetString("psn_no")
  8043. doctor_id, _ := c.GetInt64("doctor_id")
  8044. sick_id, _ := c.GetInt64("sick_id")
  8045. department_id, _ := c.GetInt64("department_id")
  8046. start_time := c.GetString("start_time")
  8047. end_time := c.GetString("end_time")
  8048. check_time := c.GetString("check_time")
  8049. adminUser := c.GetAdminUserInfo()
  8050. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8051. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8052. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8053. sick, _ := service.FindSickById(sick_id)
  8054. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8055. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8056. var res ResultTwo
  8057. var res10265 ResultTwo10265
  8058. if miConfig.MdtrtareaAdmvs == "320921" {
  8059. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8060. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8061. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8062. "&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
  8063. resp, requestErr := http.Get(api)
  8064. if requestErr != nil {
  8065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8066. return
  8067. }
  8068. body, ioErr := ioutil.ReadAll(resp.Body)
  8069. if ioErr != nil {
  8070. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8072. return
  8073. }
  8074. var respJSON map[string]interface{}
  8075. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8078. return
  8079. }
  8080. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8081. result, _ := json.Marshal(respJSON)
  8082. fmt.Println("log")
  8083. fmt.Println(string(result))
  8084. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8085. utils.ErrorLog("解析失败:%v", err)
  8086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8087. return
  8088. }
  8089. res.ErrMsg = res10265.ErrMsg
  8090. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8091. res.Infcode = infocode
  8092. res.Output = res10265.Output
  8093. res.InfRefmsgid = res10265.InfRefmsgid
  8094. } else {
  8095. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8096. if miConfig.Code == "H15049901371" {
  8097. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8098. utils.ErrorLog("解析失败:%v", err)
  8099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8100. return
  8101. }
  8102. res.ErrMsg = res10265.ErrMsg
  8103. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8104. res.Infcode = infocode
  8105. res.Output = res10265.Output
  8106. res.InfRefmsgid = res10265.InfRefmsgid
  8107. } else {
  8108. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8109. utils.ErrorLog("解析失败:%v", err)
  8110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8111. return
  8112. }
  8113. }
  8114. }
  8115. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8116. infoStr := string(Iinfos)
  8117. var rf []*ResultFive
  8118. json.Unmarshal([]byte(infoStr), &rf)
  8119. var insuplc_admdvs string
  8120. var insutype string
  8121. var is390 int = 0
  8122. var is310 int = 0
  8123. var insutypes []*ResultFive
  8124. for _, item := range rf {
  8125. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8126. insutypes = append(insutypes, item)
  8127. }
  8128. }
  8129. if len(insutypes) == 1 {
  8130. insutype = insutypes[0].Insutype
  8131. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8132. } else {
  8133. for _, i := range insutypes {
  8134. if i.Insutype == "390" {
  8135. is390 = 1
  8136. }
  8137. if i.Insutype == "310" {
  8138. is310 = 1
  8139. }
  8140. }
  8141. }
  8142. if is390 == 1 {
  8143. insutype = "390"
  8144. }
  8145. if is310 == 1 {
  8146. insutype = "310"
  8147. }
  8148. if len(insutypes) == 2 {
  8149. insutype = insutype_two
  8150. }
  8151. if len(insutypes) == 0 {
  8152. insutype = "310"
  8153. }
  8154. insutype = insutype_two
  8155. fmt.Println(insutype)
  8156. for _, item := range rf {
  8157. fmt.Println(item.Insutype)
  8158. fmt.Println(insutype)
  8159. if item.Insutype == insutype {
  8160. fmt.Println(item.Insutype)
  8161. fmt.Println(insutype)
  8162. insuplc_admdvs = item.InsuplcAdmdvs
  8163. }
  8164. }
  8165. fmt.Println(insuplc_admdvs)
  8166. var res2 ResultThirteen
  8167. var res10265_2 ResultThirteen10265
  8168. if config.IsOpen == 1 {
  8169. if miConfig.MdtrtareaAdmvs == "320921" {
  8170. } else {
  8171. 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)
  8172. var dat map[string]interface{}
  8173. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8174. fmt.Println(dat)
  8175. } else {
  8176. fmt.Println(err)
  8177. }
  8178. userJSONBytes, _ := json.Marshal(dat)
  8179. if miConfig.Code == "H15049901371" {
  8180. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8181. utils.ErrorLog("解析失败:%v", err)
  8182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8183. return
  8184. }
  8185. res2.ErrMsg = res10265_2.ErrMsg
  8186. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8187. res2.Infcode = infocode
  8188. res2.Output = res10265_2.Output
  8189. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8190. } else {
  8191. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8192. utils.ErrorLog("解析失败:%v", err)
  8193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8194. return
  8195. }
  8196. }
  8197. }
  8198. if res2.Infcode == 0 {
  8199. psnResult := &models.GdybPsnNcdsRecord{
  8200. UserOrgId: adminUser.CurrentOrgId,
  8201. PatientId: patient.ID,
  8202. PsnNo: psn_no,
  8203. DoctorId: doctor.AdminUserId,
  8204. DepartmentId: department_id,
  8205. SickType: sick_id,
  8206. Insutype: insutype,
  8207. Ctime: time.Now().Unix(),
  8208. Mtime: time.Now().Unix(),
  8209. Status: 1,
  8210. IsCancel: 1,
  8211. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8212. }
  8213. service.CreatePsnNCDSRecord(psnResult)
  8214. c.ServeSuccessJSON(map[string]interface{}{
  8215. "failed_code": 0,
  8216. "msg": "备案成功",
  8217. "result": psnResult,
  8218. })
  8219. } else {
  8220. c.ServeSuccessJSON(map[string]interface{}{
  8221. "failed_code": -10,
  8222. "msg": res2.ErrMsg,
  8223. })
  8224. return
  8225. }
  8226. }
  8227. }
  8228. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  8229. id, _ := c.GetInt64("id")
  8230. admin_user_id, _ := c.GetInt64("admin_user_id")
  8231. adminUser := c.GetAdminUserInfo()
  8232. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8233. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8234. //config, _ := service.Ge(adminUser.CurrentOrgId)
  8235. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  8236. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8237. //var user_name string
  8238. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8239. //if role.ID == 0 {
  8240. // user_name = "xxx"
  8241. //} else {
  8242. // user_name = role.UserName
  8243. //}
  8244. psn_record, _ := service.GetPsnNCDSRecordById(id)
  8245. if psn_record.ID == 0 {
  8246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8247. return
  8248. }
  8249. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8250. var res ResultTwo
  8251. var res10265 ResultTwo10265
  8252. if miConfig.Code == "H15049901371" {
  8253. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8254. utils.ErrorLog("解析失败:%v", err)
  8255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8256. return
  8257. }
  8258. res.ErrMsg = res10265.ErrMsg
  8259. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8260. res.Infcode = infocode
  8261. res.Output = res10265.Output
  8262. res.InfRefmsgid = res10265.InfRefmsgid
  8263. } else {
  8264. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8265. utils.ErrorLog("解析失败:%v", err)
  8266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8267. return
  8268. }
  8269. }
  8270. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8271. infoStr := string(Iinfos)
  8272. var rf []*ResultFive
  8273. json.Unmarshal([]byte(infoStr), &rf)
  8274. var insuplc_admdvs string
  8275. var insutype string
  8276. var is390 int = 0
  8277. var is310 int = 0
  8278. var insutypes []*ResultFive
  8279. for _, item := range rf {
  8280. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8281. insutypes = append(insutypes, item)
  8282. }
  8283. }
  8284. if len(insutypes) == 1 {
  8285. insutype = insutypes[0].Insutype
  8286. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8287. } else {
  8288. for _, i := range insutypes {
  8289. if i.Insutype == "390" {
  8290. is390 = 1
  8291. }
  8292. if i.Insutype == "310" {
  8293. is310 = 1
  8294. }
  8295. }
  8296. }
  8297. if is390 == 1 {
  8298. insutype = "390"
  8299. }
  8300. if is310 == 1 {
  8301. insutype = "310"
  8302. }
  8303. if len(insutypes) == 0 {
  8304. insutype = "310"
  8305. }
  8306. insutype = psn_record.Insutype
  8307. for _, item := range rf {
  8308. if item.Insutype == insutype {
  8309. insuplc_admdvs = item.InsuplcAdmdvs
  8310. }
  8311. }
  8312. if config.IsOpen == 1 {
  8313. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8314. var dat map[string]interface{}
  8315. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8316. fmt.Println(dat)
  8317. } else {
  8318. fmt.Println(err)
  8319. }
  8320. userJSONBytes, _ := json.Marshal(dat)
  8321. var res ResultFourteen
  8322. var res10265 ResultFourteen10265
  8323. if miConfig.Code == "H15049901371" {
  8324. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8325. utils.ErrorLog("解析失败:%v", err)
  8326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8327. return
  8328. }
  8329. res.ErrMsg = res10265.ErrMsg
  8330. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8331. res.Infcode = infocode
  8332. res.Output = res10265.Output
  8333. res.InfRefmsgid = res10265.InfRefmsgid
  8334. } else {
  8335. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8336. utils.ErrorLog("解析失败:%v", err)
  8337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8338. return
  8339. }
  8340. }
  8341. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8342. // utils.ErrorLog("解析失败:%v", err)
  8343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8344. // return
  8345. //}
  8346. if res.Infcode == 0 {
  8347. psn_record.IsCancel = 2
  8348. service.CreatePsnNCDSRecord(&psn_record)
  8349. c.ServeSuccessJSON(map[string]interface{}{
  8350. "failed_code": 0,
  8351. "msg": "撤销备案成功",
  8352. })
  8353. } else {
  8354. c.ServeSuccessJSON(map[string]interface{}{
  8355. "failed_code": -10,
  8356. "msg": res.ErrMsg,
  8357. })
  8358. return
  8359. }
  8360. }
  8361. }
  8362. func (c *HisApiController) TestTest() {
  8363. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8364. fmt.Println(patient.Iinfo)
  8365. }
  8366. type CustomData struct {
  8367. MsgId string
  8368. PsnNo string
  8369. Info string
  8370. }
  8371. func (c *HisApiController) ReversalData() {
  8372. var customData []*CustomData
  8373. custom := &CustomData{
  8374. MsgId: "H44022900158202103301714472004",
  8375. PsnNo: "44020000001101329945",
  8376. Info: "2207",
  8377. }
  8378. customData = append(customData, custom)
  8379. custom1 := &CustomData{
  8380. MsgId: "H4402290015820210330172057803",
  8381. PsnNo: "44020000001101161813",
  8382. Info: "2207",
  8383. }
  8384. customData = append(customData, custom1)
  8385. custom2 := &CustomData{
  8386. MsgId: "H44022900158202103301705198813",
  8387. PsnNo: "44190000133097375417",
  8388. Info: "2207",
  8389. }
  8390. customData = append(customData, custom2)
  8391. custom3 := &CustomData{
  8392. MsgId: "H44022900158202103301715524756",
  8393. PsnNo: "44020000001100187221",
  8394. Info: "2207",
  8395. }
  8396. customData = append(customData, custom3)
  8397. custom4 := &CustomData{
  8398. MsgId: "H44022900158202103301730376224",
  8399. PsnNo: "44020000001101959155",
  8400. Info: "2207",
  8401. }
  8402. customData = append(customData, custom4)
  8403. custom5 := &CustomData{
  8404. MsgId: "H44022900158202103301748008725",
  8405. PsnNo: "44020000001104246641",
  8406. Info: "2207",
  8407. }
  8408. customData = append(customData, custom5)
  8409. custom6 := &CustomData{
  8410. MsgId: "H44022900158202103301718096755",
  8411. PsnNo: "44020000001102211860",
  8412. Info: "2207",
  8413. }
  8414. customData = append(customData, custom6)
  8415. custom7 := &CustomData{
  8416. MsgId: "H44022900158202103301736551640",
  8417. PsnNo: "44020000001102687718",
  8418. Info: "2207",
  8419. }
  8420. customData = append(customData, custom7)
  8421. custom8 := &CustomData{
  8422. MsgId: "H44022900158202103301743097676",
  8423. PsnNo: "44020000001102127785",
  8424. Info: "2207",
  8425. }
  8426. customData = append(customData, custom8)
  8427. custom9 := &CustomData{
  8428. MsgId: "H44022900158202103301712304203",
  8429. PsnNo: "44020000001101518097",
  8430. Info: "2207",
  8431. }
  8432. customData = append(customData, custom9)
  8433. custom10 := &CustomData{
  8434. MsgId: "H44022900158202103301738448785",
  8435. PsnNo: "44020000001100500813",
  8436. Info: "2207",
  8437. }
  8438. customData = append(customData, custom10)
  8439. custom11 := &CustomData{
  8440. MsgId: "H44022900158202103301732455843",
  8441. PsnNo: "44020000001102690557",
  8442. Info: "2207",
  8443. }
  8444. customData = append(customData, custom11)
  8445. custom12 := &CustomData{
  8446. MsgId: "H44022900158202103301745421708",
  8447. PsnNo: "44020000001102211928",
  8448. Info: "2207",
  8449. }
  8450. customData = append(customData, custom12)
  8451. custom1212 := &CustomData{
  8452. MsgId: "H440229001582021033017351627",
  8453. PsnNo: "44020000001102481733",
  8454. Info: "2207",
  8455. }
  8456. customData = append(customData, custom1212)
  8457. custom13 := &CustomData{
  8458. MsgId: "H44022900158202103301740327951",
  8459. PsnNo: "44020000001103174866",
  8460. Info: "2207",
  8461. }
  8462. customData = append(customData, custom13)
  8463. custom14 := &CustomData{
  8464. MsgId: "H4402290015820210330174922668",
  8465. PsnNo: "44020000001102927272",
  8466. Info: "2207",
  8467. }
  8468. customData = append(customData, custom14)
  8469. custom15 := &CustomData{
  8470. MsgId: "H44022900158202103301752362273",
  8471. PsnNo: "44020000001102942890",
  8472. Info: "2207",
  8473. }
  8474. customData = append(customData, custom15)
  8475. custom16 := &CustomData{
  8476. MsgId: "H44022900158202103301751082917",
  8477. PsnNo: "44020000001101662162",
  8478. Info: "2207",
  8479. }
  8480. customData = append(customData, custom16)
  8481. custom17 := &CustomData{
  8482. MsgId: "H44022900158202103301754147728",
  8483. PsnNo: "44020000000229014511",
  8484. Info: "2207",
  8485. }
  8486. customData = append(customData, custom17)
  8487. adminUser := c.GetAdminUserInfo()
  8488. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8489. for _, item := range customData {
  8490. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8491. fmt.Println(result)
  8492. }
  8493. }
  8494. func (c *HisApiController) GetAllopatry() {
  8495. year := c.GetString("year")
  8496. month := c.GetString("month")
  8497. admin_user_id, _ := c.GetInt64("admin_user_id")
  8498. adminUser := c.GetAdminUserInfo()
  8499. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8500. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8501. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  8502. var dat map[string]interface{}
  8503. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8504. fmt.Println(dat)
  8505. } else {
  8506. fmt.Println(err)
  8507. }
  8508. userJSONBytes, _ := json.Marshal(dat)
  8509. var res models.Result9001
  8510. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8511. utils.ErrorLog("解析失败:%v", err)
  8512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8513. return
  8514. }
  8515. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  8516. var dat2 map[string]interface{}
  8517. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8518. fmt.Println(dat)
  8519. } else {
  8520. fmt.Println(err)
  8521. }
  8522. userJSONBytes2, _ := json.Marshal(dat2)
  8523. var res2 models.Result3260
  8524. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8525. utils.ErrorLog("解析失败:%v", err)
  8526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8527. return
  8528. }
  8529. if res2.Infcode == 0 {
  8530. c.ServeSuccessJSON(map[string]interface{}{
  8531. "list": res2.Output.Data,
  8532. })
  8533. return
  8534. } else {
  8535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8536. return
  8537. }
  8538. }
  8539. func (c *HisApiController) ComfirmAllopatry() {
  8540. year := c.GetString("year")
  8541. month := c.GetString("month")
  8542. admin_user_id, _ := c.GetInt64("admin_user_id")
  8543. adminUser := c.GetAdminUserInfo()
  8544. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8545. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8546. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  8547. var dat map[string]interface{}
  8548. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8549. fmt.Println(dat)
  8550. } else {
  8551. fmt.Println(err)
  8552. }
  8553. userJSONBytes, _ := json.Marshal(dat)
  8554. var res models.Result9001
  8555. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8556. utils.ErrorLog("解析失败:%v", err)
  8557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8558. return
  8559. }
  8560. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  8561. var dat2 map[string]interface{}
  8562. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8563. fmt.Println(dat)
  8564. } else {
  8565. fmt.Println(err)
  8566. }
  8567. userJSONBytes2, _ := json.Marshal(dat2)
  8568. var res2 models.Result3260
  8569. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8570. utils.ErrorLog("解析失败:%v", err)
  8571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8572. return
  8573. }
  8574. if res2.Infcode == 0 {
  8575. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  8576. var dat map[string]interface{}
  8577. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8578. fmt.Println(dat)
  8579. } else {
  8580. fmt.Println(err)
  8581. }
  8582. userJSONBytes, _ := json.Marshal(dat)
  8583. var res3 models.Result3261
  8584. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  8585. utils.ErrorLog("解析失败:%v", err)
  8586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8587. return
  8588. }
  8589. if res3.Infcode == 0 {
  8590. record := &models.HisYidiClearRecord{
  8591. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8592. Ctime: time.Now().Unix(),
  8593. Mtime: time.Now().Unix(),
  8594. Status: 1,
  8595. MsgId: msgId,
  8596. }
  8597. service.SaveClearRecord(record)
  8598. c.ServeSuccessJSON(map[string]interface{}{
  8599. "msg": "提取成功",
  8600. })
  8601. }
  8602. }
  8603. }
  8604. func (c *HisApiController) RefundAllopatry() {
  8605. year := c.GetString("year")
  8606. month := c.GetString("month")
  8607. id, _ := c.GetInt64("id")
  8608. admin_user_id, _ := c.GetInt64("admin_user_id")
  8609. adminUser := c.GetAdminUserInfo()
  8610. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8611. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8612. record, _ := service.GetClearRecordById(id)
  8613. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  8614. var dat map[string]interface{}
  8615. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8616. fmt.Println(dat)
  8617. } else {
  8618. fmt.Println(err)
  8619. }
  8620. userJSONBytes, _ := json.Marshal(dat)
  8621. var empty ResultFourteen
  8622. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  8623. utils.ErrorLog("解析失败:%v", err)
  8624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8625. return
  8626. }
  8627. if empty.Infcode == 0 {
  8628. c.ServeSuccessJSON(map[string]interface{}{
  8629. "msg": "撤销成功",
  8630. })
  8631. return
  8632. }
  8633. }
  8634. func (c *HisApiController) ReversalOtherData() {
  8635. var customData []*CustomData
  8636. custom := &CustomData{
  8637. MsgId: "H44022900158202103301714472004",
  8638. PsnNo: "44020000001101329945",
  8639. Info: "2208",
  8640. }
  8641. customData = append(customData, custom)
  8642. custom1 := &CustomData{
  8643. MsgId: "H4402290015820210330172057803",
  8644. PsnNo: "44020000001101161813",
  8645. Info: "2208",
  8646. }
  8647. customData = append(customData, custom1)
  8648. custom2 := &CustomData{
  8649. MsgId: "H44022900158202103301705198813",
  8650. PsnNo: "44190000133097375417",
  8651. Info: "2208",
  8652. }
  8653. customData = append(customData, custom2)
  8654. custom3 := &CustomData{
  8655. MsgId: "H44022900158202103301715524756",
  8656. PsnNo: "44020000001100187221",
  8657. Info: "2208",
  8658. }
  8659. customData = append(customData, custom3)
  8660. custom4 := &CustomData{
  8661. MsgId: "H44022900158202103301730376224",
  8662. PsnNo: "44020000001101959155",
  8663. Info: "2208",
  8664. }
  8665. customData = append(customData, custom4)
  8666. custom5 := &CustomData{
  8667. MsgId: "H44022900158202103301748008725",
  8668. PsnNo: "44020000001104246641",
  8669. Info: "2208",
  8670. }
  8671. customData = append(customData, custom5)
  8672. custom6 := &CustomData{
  8673. MsgId: "H44022900158202103301718096755",
  8674. PsnNo: "44020000001102211860",
  8675. Info: "2208",
  8676. }
  8677. customData = append(customData, custom6)
  8678. custom7 := &CustomData{
  8679. MsgId: "H44022900158202103301736551640",
  8680. PsnNo: "44020000001102687718",
  8681. Info: "2208",
  8682. }
  8683. customData = append(customData, custom7)
  8684. custom8 := &CustomData{
  8685. MsgId: "H44022900158202103301743097676",
  8686. PsnNo: "44020000001102127785",
  8687. Info: "2208",
  8688. }
  8689. customData = append(customData, custom8)
  8690. custom9 := &CustomData{
  8691. MsgId: "H44022900158202103301712304203",
  8692. PsnNo: "44020000001101518097",
  8693. Info: "2208",
  8694. }
  8695. customData = append(customData, custom9)
  8696. custom10 := &CustomData{
  8697. MsgId: "H44022900158202103301738448785",
  8698. PsnNo: "44020000001100500813",
  8699. Info: "2208",
  8700. }
  8701. customData = append(customData, custom10)
  8702. custom11 := &CustomData{
  8703. MsgId: "H44022900158202103301732455843",
  8704. PsnNo: "44020000001102690557",
  8705. Info: "2208",
  8706. }
  8707. customData = append(customData, custom11)
  8708. custom12 := &CustomData{
  8709. MsgId: "H44022900158202103301745421708",
  8710. PsnNo: "44020000001102211928",
  8711. Info: "2208",
  8712. }
  8713. customData = append(customData, custom12)
  8714. custom1212 := &CustomData{
  8715. MsgId: "H440229001582021033017351627",
  8716. PsnNo: "44020000001102481733",
  8717. Info: "2208",
  8718. }
  8719. customData = append(customData, custom1212)
  8720. custom13 := &CustomData{
  8721. MsgId: "H44022900158202103301740327951",
  8722. PsnNo: "44020000001103174866",
  8723. Info: "2208",
  8724. }
  8725. customData = append(customData, custom13)
  8726. custom14 := &CustomData{
  8727. MsgId: "H4402290015820210330174922668",
  8728. PsnNo: "44020000001102927272",
  8729. Info: "2208",
  8730. }
  8731. customData = append(customData, custom14)
  8732. custom15 := &CustomData{
  8733. MsgId: "H44022900158202103301752362273",
  8734. PsnNo: "44020000001102942890",
  8735. Info: "2208",
  8736. }
  8737. customData = append(customData, custom15)
  8738. custom16 := &CustomData{
  8739. MsgId: "H44022900158202103301751082917",
  8740. PsnNo: "44020000001101662162",
  8741. Info: "2208",
  8742. }
  8743. customData = append(customData, custom16)
  8744. custom17 := &CustomData{
  8745. MsgId: "H44022900158202103301754147728",
  8746. PsnNo: "44020000000229014511",
  8747. Info: "2208",
  8748. }
  8749. customData = append(customData, custom17)
  8750. adminUser := c.GetAdminUserInfo()
  8751. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8752. for _, item := range customData {
  8753. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8754. fmt.Println(result)
  8755. }
  8756. }
  8757. func PathExists(path string) (bool, error) {
  8758. _, err := os.Stat(path)
  8759. if err == nil {
  8760. return true, nil
  8761. }
  8762. if os.IsNotExist(err) {
  8763. return false, nil
  8764. }
  8765. return false, err
  8766. }
  8767. //创建文件夹
  8768. func Mkdir(dir string) {
  8769. // 创建文件夹
  8770. exist, err := PathExists(dir)
  8771. if err != nil {
  8772. fmt.Println(err.Error())
  8773. } else {
  8774. if exist {
  8775. fmt.Println(dir + "文件夹已存在!")
  8776. } else {
  8777. // 文件夹名称,权限
  8778. err := os.Mkdir(dir, os.ModePerm)
  8779. if err != nil {
  8780. fmt.Println(dir+"文件夹创建失败:", err.Error())
  8781. } else {
  8782. fmt.Println(dir + "文件夹创建成功!")
  8783. }
  8784. }
  8785. }
  8786. }
  8787. //压缩文件
  8788. func Zip(srcFile string, destZip string) error {
  8789. zipfile, err := os.Create(destZip)
  8790. if err != nil {
  8791. return err
  8792. }
  8793. defer zipfile.Close()
  8794. archive := zip.NewWriter(zipfile)
  8795. defer archive.Close()
  8796. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  8797. if err != nil {
  8798. return err
  8799. }
  8800. header, err := zip.FileInfoHeader(info)
  8801. if err != nil {
  8802. return err
  8803. }
  8804. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  8805. // header.Name = path
  8806. if info.IsDir() {
  8807. header.Name += "/"
  8808. } else {
  8809. header.Method = zip.Deflate
  8810. }
  8811. writer, err := archive.CreateHeader(header)
  8812. if err != nil {
  8813. return err
  8814. }
  8815. if !info.IsDir() {
  8816. file, err := os.Open(path)
  8817. if err != nil {
  8818. return err
  8819. }
  8820. defer file.Close()
  8821. _, err = io.Copy(writer, file)
  8822. }
  8823. return err
  8824. })
  8825. return err
  8826. }
  8827. func ReadFile(filePath string) []byte {
  8828. f, err := os.Open(filePath)
  8829. if err != nil {
  8830. fmt.Println("read file fail", err)
  8831. return nil
  8832. }
  8833. defer f.Close()
  8834. fd, err := ioutil.ReadAll(f)
  8835. if err != nil {
  8836. fmt.Println("read to fd fail", err)
  8837. return nil
  8838. }
  8839. return fd
  8840. }
  8841. func saveLog(result string, request string, infno string, desc string) {
  8842. org_id, _ := beego.AppConfig.Int64("org_id")
  8843. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  8844. dir := miConfig.OrgName + "日志"
  8845. utils.Mkdir(dir)
  8846. month := time.Unix(1557042972, 0).Format("1")
  8847. year := time.Now().Format("2006")
  8848. month = time.Now().Format("01")
  8849. day := time.Now().Format("02")
  8850. hour := time.Now().Format("15")
  8851. min := time.Now().Format("04")
  8852. sec := time.Now().Format("05")
  8853. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  8854. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  8855. file_name := file + ".txt"
  8856. file_path := miConfig.OrgName + "日志" + "/" + file_name
  8857. exist, _ := utils.PathExists(file_path)
  8858. if exist { //存在
  8859. fmt.Println("存在")
  8860. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  8861. if err != nil {
  8862. fmt.Println("read fail")
  8863. }
  8864. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  8865. n, _ := f.Seek(0, 2)
  8866. _, err = f.WriteAt([]byte(content), n)
  8867. } else { //不存在
  8868. fmt.Println("文件不存在,创建文件")
  8869. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  8870. defer f.Close()
  8871. if err != nil {
  8872. } else {
  8873. _, err = f.Write([]byte("记录日志"))
  8874. }
  8875. }
  8876. }
  8877. type Charset string
  8878. const (
  8879. UTF8 = Charset("UTF-8")
  8880. GB18030 = Charset("GB18030")
  8881. )
  8882. func ConvertToString(src string, srcCode string, tagCode string) string {
  8883. srcCoder := mahonia.NewDecoder(srcCode)
  8884. srcResult := srcCoder.ConvertString(src)
  8885. tagCoder := mahonia.NewDecoder(tagCode)
  8886. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  8887. result := string(cdata)
  8888. return result
  8889. }