his_api_controller.go 339KB

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