his_api_controller.go 339KB

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