his_api_controller.go 342KB

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