his_api_controller.go 309KB

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