his_api_controller.go 339KB

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