his_api_controller.go 341KB

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