his_api_controller.go 336KB

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