his_api_controller.go 399KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840
  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/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. }
  73. func (c *HisApiController) GetPsnNcdsInfo() {
  74. admin_user_id, _ := c.GetInt64("admin_user_id")
  75. patient_id, _ := c.GetInt64("patient_id")
  76. id, _ := c.GetInt64("id")
  77. adminUser := c.GetAdminUserInfo()
  78. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  79. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  80. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  81. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  82. psn_record, _ := service.GetPsnNCDSRecordById(id)
  83. //
  84. //if psn_record.ID == 0 {
  85. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  86. // return
  87. //}
  88. var res Result5301
  89. var res10265 Result5301For10265
  90. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  91. psn_info, _ := service.GetPsnByPatientId(patient_id)
  92. var api string
  93. if miConfig.MdtrtareaAdmvs == "320921" {
  94. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  95. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  96. } else {
  97. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  98. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  99. }
  100. resp, requestErr := http.Get(api)
  101. if requestErr != nil {
  102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  103. return
  104. }
  105. body, ioErr := ioutil.ReadAll(resp.Body)
  106. if ioErr != nil {
  107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  109. return
  110. }
  111. var respJSON map[string]interface{}
  112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  115. return
  116. }
  117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  118. result, _ := json.Marshal(respJSON)
  119. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  120. utils.ErrorLog("解析失败:%v", err)
  121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  122. return
  123. }
  124. res.ErrMsg = res10265.ErrMsg
  125. res.Output = res10265.Output
  126. res.InfRefmsgid = res10265.InfRefmsgid
  127. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  128. res.Infcode = infocode
  129. } else {
  130. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  131. var dat map[string]interface{}
  132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  133. fmt.Println(dat)
  134. } else {
  135. fmt.Println(err)
  136. }
  137. userJSONBytes, _ := json.Marshal(dat)
  138. if miConfig.Code == "H15049901371" {
  139. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  140. utils.ErrorLog("解析失败:%v", err)
  141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  142. return
  143. }
  144. res.InfRefmsgid = res10265.InfRefmsgid
  145. res.Output = res10265.Output
  146. res.ErrMsg = res10265.ErrMsg
  147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  148. res.Infcode = infocode
  149. } else {
  150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  151. utils.ErrorLog("解析失败:%v", err)
  152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  153. return
  154. }
  155. }
  156. }
  157. if res.Infcode == 0 {
  158. c.ServeSuccessJSON(map[string]interface{}{
  159. "result": res.Output.Result,
  160. })
  161. }
  162. }
  163. func (c *HisApiController) CheckInsutype() {
  164. his_patient_id, _ := c.GetInt64("his_patient_id")
  165. admin_user_id, _ := c.GetInt64("admin_user_id")
  166. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  167. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  168. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  169. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  170. var dat map[string]interface{}
  171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  172. fmt.Println(dat)
  173. } else {
  174. fmt.Println(err)
  175. }
  176. userJSONBytes, _ := json.Marshal(dat)
  177. var res Result90100
  178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  179. utils.ErrorLog("解析失败:%v", err)
  180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  181. return
  182. }
  183. if res.Infcode != 0 {
  184. c.ServeSuccessJSON(map[string]interface{}{
  185. "failed_code": -10,
  186. "msg": res.ErrMsg,
  187. })
  188. return
  189. } else {
  190. fmt.Println(res)
  191. }
  192. }
  193. func (c *HisApiController) CheckCardPWD() {
  194. card_pwd := c.GetString("card_pwd")
  195. his_patient_id, _ := c.GetInt64("his_patient_id")
  196. admin_user_id, _ := c.GetInt64("admin_user_id")
  197. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  198. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  199. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  200. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  201. var dat map[string]interface{}
  202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  203. fmt.Println(dat)
  204. } else {
  205. fmt.Println(err)
  206. }
  207. userJSONBytes, _ := json.Marshal(dat)
  208. var res Result90991
  209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  210. utils.ErrorLog("解析失败:%v", err)
  211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  212. return
  213. }
  214. if res.Infcode != 0 {
  215. c.ServeSuccessJSON(map[string]interface{}{
  216. "failed_code": -10,
  217. "msg": res.ErrMsg,
  218. })
  219. return
  220. } else {
  221. if res.Output.Result.CheckStat == "0" {
  222. var msg string
  223. switch res.Output.Result.CardStat {
  224. case "00":
  225. msg = "未激活"
  226. break
  227. case "10":
  228. msg = "激活"
  229. break
  230. case "20":
  231. msg = "窗口挂失"
  232. break
  233. case "21":
  234. msg = "电话挂失"
  235. break
  236. case "22":
  237. msg = "单位网上申报挂失"
  238. break
  239. case "23":
  240. msg = "保健办挂失"
  241. break
  242. case "24":
  243. msg = "个人网上挂失"
  244. break
  245. case "25":
  246. msg = "网上服务大厅挂失"
  247. break
  248. case "30":
  249. msg = "注销"
  250. break
  251. case "40":
  252. msg = "回收"
  253. break
  254. case "99":
  255. msg = "制卡中(无效卡)"
  256. break
  257. }
  258. c.ServeSuccessJSON(map[string]interface{}{
  259. "failed_code": -10,
  260. "msg": msg,
  261. })
  262. return
  263. } else {
  264. c.ServeSuccessJSON(map[string]interface{}{
  265. "msg": "校验成功",
  266. })
  267. return
  268. }
  269. }
  270. }
  271. func (c *HisApiController) ReadCard() {
  272. id_card_type, _ := c.GetInt64("id_card_type")
  273. admin_user_id, _ := c.GetInt64("admin_user_id")
  274. certificates, _ := c.GetInt64("certificates")
  275. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  276. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  278. switch id_card_type {
  279. case 1:
  280. if miConfig.MdtrtareaAdmvs == "421300" {
  281. var res ResultTwo
  282. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  283. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  284. "&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)
  285. resp, requestErr := http.Get(api)
  286. if requestErr != nil {
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. body, ioErr := ioutil.ReadAll(resp.Body)
  291. if ioErr != nil {
  292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  294. return
  295. }
  296. var respJSON map[string]interface{}
  297. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  300. return
  301. }
  302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  303. result, _ := json.Marshal(respJSON)
  304. fmt.Println("log")
  305. fmt.Println(string(result))
  306. if err := json.Unmarshal([]byte(result), &res); err != nil {
  307. utils.ErrorLog("解析失败:%v", err)
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. if res.Infcode == 0 {
  312. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  313. if err == gorm.ErrRecordNotFound {
  314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  315. return
  316. } else if err != nil {
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  318. return
  319. } else {
  320. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  321. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  322. infoStr := string(Iinfos)
  323. idetinfoStr := string(Idetinfos)
  324. psn := &models.HisPsn{
  325. PsnNo: res.Output.Baseinfo.PsnNo,
  326. Age: res.Output.Baseinfo.Age,
  327. PatientId: patient.ID,
  328. Certno: res.Output.Baseinfo.Certno,
  329. Brdy: res.Output.Baseinfo.Brdy,
  330. Gend: res.Output.Baseinfo.Gend,
  331. Naty: res.Output.Baseinfo.Naty,
  332. PsnCertType: res.Output.Baseinfo.PsnCertType,
  333. PsnName: res.Output.Baseinfo.PsnName,
  334. Idetinfo: idetinfoStr,
  335. Insuinfo: infoStr,
  336. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  337. }
  338. service.CreateHisPsn(psn)
  339. c.ServeSuccessJSON(map[string]interface{}{
  340. "patient": patient,
  341. "number": res.Output.Baseinfo.Certno,
  342. })
  343. }
  344. } else {
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  346. return
  347. }
  348. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  349. var api string
  350. if miConfig.MdtrtareaAdmvs == "320921" {
  351. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  352. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  353. fmt.Println(api)
  354. } else {
  355. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  356. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  357. }
  358. resp, requestErr := http.Get(api)
  359. if requestErr != nil {
  360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  361. return
  362. }
  363. body, ioErr := ioutil.ReadAll(resp.Body)
  364. if ioErr != nil {
  365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  367. return
  368. }
  369. var respJSON map[string]interface{}
  370. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  373. return
  374. }
  375. var status string
  376. status = respJSON["data"].(map[string]interface{})["status"].(string)
  377. fmt.Println(respJSON["data"])
  378. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  379. //console.log()
  380. fmt.Println("type===")
  381. fmt.Println(card_type)
  382. var token string
  383. var res ResultTwo //1101结果
  384. var res10265 ResultTwo10265 //1101结果
  385. var card_info string //卡信息
  386. var busi_card_info string
  387. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  388. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  389. if status == "0" { //读卡成功
  390. if card_type == "1" {
  391. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  392. result, _ := json.Marshal(respJSON)
  393. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  394. utils.ErrorLog("解析失败:%v", err)
  395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  396. return
  397. }
  398. res.ErrMsg = res10265.ErrMsg
  399. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  400. res.Infcode = infocode
  401. res.Output = res10265.Output
  402. res.InfRefmsgid = res10265.InfRefmsgid
  403. } else {
  404. //var card_info string //卡信息
  405. //var busi_card_info string
  406. token = respJSON["data"].(map[string]interface{})["token"].(string)
  407. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  408. //fmt.Println(card_info)
  409. //fmt.Println(busi_card_info)
  410. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  411. result, _ := json.Marshal(respJSON)
  412. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  413. utils.ErrorLog("解析失败:%v", err)
  414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  415. return
  416. }
  417. res.ErrMsg = res10265.ErrMsg
  418. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  419. res.Infcode = infocode
  420. res.Output = res10265.Output
  421. res.InfRefmsgid = res10265.InfRefmsgid
  422. }
  423. if res.Infcode == 0 {
  424. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  425. if err == gorm.ErrRecordNotFound {
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  427. return
  428. } else if err != nil {
  429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  430. return
  431. } else {
  432. if card_type == "1" {
  433. bas := strings.Split(card_info, "|")
  434. basNumber := bas[2]
  435. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  436. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  437. infoStr := string(Iinfos)
  438. idetinfoStr := string(Idetinfos)
  439. psn := &models.HisPsn{
  440. PsnNo: res.Output.Baseinfo.PsnNo,
  441. Age: res.Output.Baseinfo.Age,
  442. PatientId: patient.ID,
  443. Certno: res.Output.Baseinfo.Certno,
  444. Brdy: res.Output.Baseinfo.Brdy,
  445. Gend: res.Output.Baseinfo.Gend,
  446. Naty: res.Output.Baseinfo.Naty,
  447. PsnCertType: res.Output.Baseinfo.PsnCertType,
  448. PsnName: res.Output.Baseinfo.PsnName,
  449. Idetinfo: idetinfoStr,
  450. Insuinfo: infoStr,
  451. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  452. CardInfo: card_info,
  453. VerifyNumber: busi_card_info,
  454. }
  455. service.CreateHisPsn(psn)
  456. c.ServeSuccessJSON(map[string]interface{}{
  457. "patient": patient,
  458. "number": basNumber,
  459. })
  460. } else {
  461. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  462. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  463. infoStr := string(Iinfos)
  464. idetinfoStr := string(Idetinfos)
  465. psn := &models.HisPsn{
  466. PsnNo: res.Output.Baseinfo.PsnNo,
  467. Age: res.Output.Baseinfo.Age,
  468. PatientId: patient.ID,
  469. Certno: res.Output.Baseinfo.Certno,
  470. Brdy: res.Output.Baseinfo.Brdy,
  471. Gend: res.Output.Baseinfo.Gend,
  472. Naty: res.Output.Baseinfo.Naty,
  473. PsnCertType: res.Output.Baseinfo.PsnCertType,
  474. PsnName: res.Output.Baseinfo.PsnName,
  475. Idetinfo: idetinfoStr,
  476. Insuinfo: infoStr,
  477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  478. CardInfo: card_info,
  479. VerifyNumber: token,
  480. }
  481. service.CreateHisPsn(psn)
  482. c.ServeSuccessJSON(map[string]interface{}{
  483. "patient": patient,
  484. "number": token,
  485. })
  486. }
  487. }
  488. } else {
  489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  490. return
  491. }
  492. } else { //读卡失败
  493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  494. return
  495. }
  496. } else {
  497. if initFlag == 0 {
  498. c.TestGetBasBaseInit()
  499. }
  500. basStr := c.GetBasBaseInfo()
  501. if len(basStr) == 0 {
  502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  503. return
  504. }
  505. fmt.Println(basStr)
  506. bas := strings.Split(basStr, "|")
  507. basNumber := bas[1]
  508. fmt.Println(basNumber)
  509. card_sn := bas[3]
  510. fmt.Println(card_sn)
  511. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  512. var dat map[string]interface{}
  513. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  514. fmt.Println(dat)
  515. } else {
  516. fmt.Println(err)
  517. }
  518. userJSONBytes, _ := json.Marshal(dat)
  519. var res ResultTwo
  520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  521. utils.ErrorLog("解析失败:%v", err)
  522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  523. return
  524. }
  525. if res.Infcode == 0 {
  526. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  527. if err == gorm.ErrRecordNotFound {
  528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  529. return
  530. } else if err != nil {
  531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  532. return
  533. } else {
  534. c.ServeSuccessJSON(map[string]interface{}{
  535. "patient": patient,
  536. "number": basNumber,
  537. })
  538. }
  539. } else {
  540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  541. return
  542. }
  543. break
  544. }
  545. case 2:
  546. SFZStr := c.GetSFZBaseInfo()
  547. id_card_str := strings.Split(SFZStr, "^")
  548. id_card_number := id_card_str[0]
  549. card_sn := ""
  550. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  551. var dat map[string]interface{}
  552. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  553. fmt.Println(dat)
  554. } else {
  555. fmt.Println(err)
  556. }
  557. userJSONBytes, _ := json.Marshal(dat)
  558. var res ResultTwo
  559. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  560. utils.ErrorLog("解析失败:%v", err)
  561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  562. return
  563. }
  564. if res.Infcode == 0 {
  565. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  566. if err == gorm.ErrRecordNotFound {
  567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  568. return
  569. } else if err != nil {
  570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  571. return
  572. } else {
  573. c.ServeSuccessJSON(map[string]interface{}{
  574. "patient": patient,
  575. "number": id_card_number,
  576. })
  577. }
  578. } else {
  579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  580. return
  581. }
  582. break
  583. case 3:
  584. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  585. var api string
  586. if miConfig.MdtrtareaAdmvs == "320921" {
  587. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  588. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  589. fmt.Println(api)
  590. } else {
  591. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  592. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  593. }
  594. resp, requestErr := http.Get(api)
  595. if requestErr != nil {
  596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  597. return
  598. }
  599. body, ioErr := ioutil.ReadAll(resp.Body)
  600. if ioErr != nil {
  601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  603. return
  604. }
  605. var respJSON map[string]interface{}
  606. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  609. return
  610. }
  611. var status string
  612. status = respJSON["data"].(map[string]interface{})["status"].(string)
  613. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  614. var token string
  615. var res ResultTwo //1101结果
  616. var res10265 ResultTwo10265 //1101结果
  617. var card_info string //卡信息
  618. var busi_card_info string
  619. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  620. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  621. if status == "0" { //读卡成功
  622. if card_type == "1" {
  623. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  624. result, _ := json.Marshal(respJSON)
  625. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  626. utils.ErrorLog("解析失败:%v", err)
  627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  628. return
  629. }
  630. res.ErrMsg = res10265.ErrMsg
  631. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  632. res.Infcode = infocode
  633. res.Output = res10265.Output
  634. res.InfRefmsgid = res10265.InfRefmsgid
  635. } else {
  636. //var card_info string //卡信息
  637. //var busi_card_info string
  638. token = respJSON["data"].(map[string]interface{})["token"].(string)
  639. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  640. //fmt.Println(card_info)
  641. //fmt.Println(busi_card_info)
  642. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  643. result, _ := json.Marshal(respJSON)
  644. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  645. utils.ErrorLog("解析失败:%v", err)
  646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  647. return
  648. }
  649. res.ErrMsg = res10265.ErrMsg
  650. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  651. res.Infcode = infocode
  652. res.Output = res10265.Output
  653. res.InfRefmsgid = res10265.InfRefmsgid
  654. }
  655. if res.Infcode == 0 {
  656. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  657. if err == gorm.ErrRecordNotFound {
  658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  659. return
  660. } else if err != nil {
  661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  662. return
  663. } else {
  664. if card_type == "1" {
  665. bas := strings.Split(card_info, "|")
  666. basNumber := bas[2]
  667. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  668. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  669. infoStr := string(Iinfos)
  670. idetinfoStr := string(Idetinfos)
  671. psn := &models.HisPsn{
  672. PsnNo: res.Output.Baseinfo.PsnNo,
  673. Age: res.Output.Baseinfo.Age,
  674. PatientId: patient.ID,
  675. Certno: res.Output.Baseinfo.Certno,
  676. Brdy: res.Output.Baseinfo.Brdy,
  677. Gend: res.Output.Baseinfo.Gend,
  678. Naty: res.Output.Baseinfo.Naty,
  679. PsnCertType: res.Output.Baseinfo.PsnCertType,
  680. PsnName: res.Output.Baseinfo.PsnName,
  681. Idetinfo: idetinfoStr,
  682. Insuinfo: infoStr,
  683. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  684. CardInfo: card_info,
  685. VerifyNumber: busi_card_info,
  686. }
  687. service.CreateHisPsn(psn)
  688. c.ServeSuccessJSON(map[string]interface{}{
  689. "patient": patient,
  690. "number": basNumber,
  691. })
  692. } else {
  693. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  694. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  695. infoStr := string(Iinfos)
  696. idetinfoStr := string(Idetinfos)
  697. psn := &models.HisPsn{
  698. PsnNo: res.Output.Baseinfo.PsnNo,
  699. Age: res.Output.Baseinfo.Age,
  700. PatientId: patient.ID,
  701. Certno: res.Output.Baseinfo.Certno,
  702. Brdy: res.Output.Baseinfo.Brdy,
  703. Gend: res.Output.Baseinfo.Gend,
  704. Naty: res.Output.Baseinfo.Naty,
  705. PsnCertType: res.Output.Baseinfo.PsnCertType,
  706. PsnName: res.Output.Baseinfo.PsnName,
  707. Idetinfo: idetinfoStr,
  708. Insuinfo: infoStr,
  709. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  710. CardInfo: card_info,
  711. VerifyNumber: token,
  712. }
  713. service.CreateHisPsn(psn)
  714. c.ServeSuccessJSON(map[string]interface{}{
  715. "patient": patient,
  716. "number": token,
  717. })
  718. }
  719. }
  720. } else {
  721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  722. return
  723. }
  724. } else { //读卡失败
  725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  726. return
  727. }
  728. }
  729. break
  730. }
  731. }
  732. var initFlag int64 = 0
  733. func (c *HisApiController) TestGetBasBaseInit() {
  734. DllDef := syscall.MustLoadDLL("SSCard.dll")
  735. Iinit := DllDef.MustFindProc("Init")
  736. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  737. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  738. if ret != 0 {
  739. fmt.Println("SSCard的报错原因:", err)
  740. fmt.Println("SSCard的运算结果为:", ret)
  741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  742. return
  743. }
  744. result := int(ret)
  745. fmt.Println("SSCard的运算结果为1:", result)
  746. initFlag = 1
  747. return
  748. }
  749. func (c *HisApiController) GetSFZBaseInfo() string {
  750. DllDef := syscall.MustLoadDLL("SSCard.dll")
  751. readCard := DllDef.MustFindProc("ReadSFZ")
  752. if readCard == nil {
  753. fmt.Println("readcard is nil")
  754. readCard = DllDef.MustFindProc("ReadSFZ")
  755. }
  756. str := make([]byte, 256)
  757. str1 := make([]byte, 256)
  758. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  759. fmt.Println(r)
  760. return string(str)
  761. }
  762. func (c *HisApiController) GetBasBaseInfo() string {
  763. DllDef := syscall.MustLoadDLL("SSCard.dll")
  764. readCard := DllDef.MustFindProc("ReadCardBas")
  765. if readCard == nil {
  766. fmt.Println("readcard is nil")
  767. readCard = DllDef.MustFindProc("ReadCardBas")
  768. }
  769. str := make([]byte, 1024)
  770. str1 := make([]byte, 1024)
  771. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  772. fmt.Println(string(str1))
  773. fmt.Println(string(str))
  774. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  775. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  776. if ret2 != 0 {
  777. return ""
  778. }
  779. return string(str)
  780. }
  781. type CustomFundPay struct {
  782. FundPayType string `json:"fund_pay_type"`
  783. FundPayamt float64 `json:"fund_payamt"`
  784. }
  785. func (c *HisApiController) GetSettleList() {
  786. order_id, _ := c.GetInt64("order_id")
  787. admin_user_id, _ := c.GetInt64("admin_user_id")
  788. order, _ := service.GetHisOrderByIDTwo(order_id)
  789. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  790. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  791. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  792. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  793. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  794. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  795. if order.ID == 0 {
  796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  797. return
  798. }
  799. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  800. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  801. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  802. fmt.Println(count)
  803. var zero string
  804. number := count + 1
  805. if number >= 1000 {
  806. zero = "0000" + strconv.FormatInt(number, 10)
  807. } else if number >= 10000 {
  808. zero = "000" + strconv.FormatInt(number, 10)
  809. } else if number >= 100000 {
  810. zero = "00" + strconv.FormatInt(number, 10)
  811. } else if number >= 1000000 {
  812. zero = "0" + strconv.FormatInt(number, 10)
  813. } else {
  814. zero = strconv.FormatInt(number, 10)
  815. }
  816. fmt.Println(zero)
  817. struct4101 := service.Struct4101{
  818. PsnNo: order.PsnNo,
  819. MdtrtId: order.MdtrtId,
  820. SetlId: order.SetlId,
  821. PsnName: order.PsnName,
  822. Gend: order.Gend,
  823. Brdy: his.Brdy,
  824. Age: his.Age,
  825. Naty: order.Naty,
  826. PatnCertType: "01",
  827. Certno: order.Certno,
  828. Prfs: "90",
  829. ConerName: roles[0].UserName,
  830. PatnRlts: "99",
  831. ConerAddr: miConfig.OrgName,
  832. ConerTel: admin.Mobile,
  833. HiType: order.Insutype,
  834. Insuplc: miConfig.InsuplcAdmdvs,
  835. MaindiagFlag: "1",
  836. BillCode: last_order.FaPiaoCode,
  837. BillNo: zero,
  838. BizSn: order.Number,
  839. PsnSelfPay: order.PsnPartAmt,
  840. PsnOwnPay: order.PsnPartAmt,
  841. AcctPay: order.AcctPay,
  842. PsnCashpay: order.PsnCashPay,
  843. HiPaymtd: "1",
  844. Hsorg: miConfig.InsuplcAdmdvs,
  845. HsorgOpter: miConfig.InsuplcAdmdvs,
  846. MedinsFillPsn: curRoles.UserName,
  847. MedinsFillDept: depart.Name,
  848. IptMedType: "2",
  849. }
  850. struct4101.SetlBegnDate = order.SetlTime
  851. struct4101.SetlEndDate = order.SetlTime
  852. time_arr := strings.Split(order.SetlTime, " ")
  853. struct4101.AdmTime = time_arr[0]
  854. struct4101.AdmEndTime = time_arr[0]
  855. var rf []CustomFundPay
  856. json.Unmarshal([]byte(order.SetlDetail), &rf)
  857. var tempFunPays []service.CustomStruct
  858. for _, item := range rf {
  859. var tempFunPay service.CustomStruct
  860. tempFunPay.FundPayamt = item.FundPayamt
  861. tempFunPay.FundPayType = item.FundPayType
  862. tempFunPays = append(tempFunPays, tempFunPay)
  863. }
  864. struct4101.CustomStruct = tempFunPays
  865. var tempDiaginfos []service.DiaginfoStructTwo
  866. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  867. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  868. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  869. var config []*models.HisXtDiagnoseConfig
  870. for _, item := range diagnosis_ids {
  871. id, _ := strconv.ParseInt(item, 10, 64)
  872. diagnosisConfig, _ := service.FindDiagnoseById(id)
  873. config = append(config, &diagnosisConfig)
  874. }
  875. for index, item := range config {
  876. if index == 0 {
  877. var tempDiaginfo service.DiaginfoStructTwo
  878. tempDiaginfo.DiagCode = item.CountryCode
  879. tempDiaginfo.DiagName = item.CountryContentName
  880. tempDiaginfo.DiagType = "1"
  881. tempDiaginfo.MaindiagFlag = "1"
  882. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  883. } else {
  884. var tempDiaginfo service.DiaginfoStructTwo
  885. tempDiaginfo.DiagCode = item.CountryCode
  886. tempDiaginfo.DiagName = item.CountryContentName
  887. tempDiaginfo.DiagType = "2"
  888. tempDiaginfo.MaindiagFlag = "0"
  889. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  890. }
  891. }
  892. struct4101.Diseinfo = tempDiaginfos
  893. sickConfigTwo, _ := service.FindSickById(his.SickType)
  894. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  895. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  896. tempOpspdiseinfo2.OprnOprtCode = ""
  897. tempOpspdiseinfo2.OprnOprtName = ""
  898. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  899. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  900. var iteminfo service.IteminfoStruct
  901. var bedCostTotal float64 = 0 //床位总费
  902. var bedCostSelfTotal float64 = 0 //床位自费
  903. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  904. var operationCostTotal float64 = 0 //手术费
  905. var operationCostSelfTotal float64 = 0 //手术费
  906. var operationCostPartSelfTotal float64 = 0 //手术费
  907. var otherCostTotal float64 = 0 //其他费用
  908. var otherCostSelfTotal float64 = 0 //其他费用
  909. var otherCostPartSelfTotal float64 = 0 //其他费用
  910. var materialCostTotal float64 = 0 //材料费
  911. var materialCostSelfTotal float64 = 0 //材料费
  912. var materialCostPartSelfTotal float64 = 0 //材料费
  913. var westernMedicineCostTotal float64 = 0 //西药费
  914. var westernMedicineCostSelfTotal float64 = 0 //西药费
  915. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  916. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  917. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  918. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  919. var checkCostTotal float64 = 0 //检查费
  920. var checkCostSelfTotal float64 = 0 //检查费
  921. var checkCostPartSelfTotal float64 = 0 //检查费
  922. var laboratoryCostTotal float64 = 0 //化验费
  923. var laboratoryCostSelfTotal float64 = 0 //化验费
  924. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  925. var treatCostTotal float64 = 0 //治疗费用
  926. var treatCostSelfTotal float64 = 0 //治疗费用
  927. var treatCostPartSelfTotal float64 = 0 //治疗费用
  928. decimal.DivisionPrecision = 2
  929. var bed_fulamt_ownpay_amt float64 = 0
  930. var operation_fulamt_ownpay_amt float64 = 0
  931. var other_fulamt_ownpay_amt float64 = 0
  932. var westernMedicine_fulamt_ownpay_amt float64 = 0
  933. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  934. var check_fulamt_ownpay_amt float64 = 0
  935. var material_fulamt_ownpay_amt float64 = 0
  936. var laboratory_fulamt_ownpay_amt float64 = 0
  937. var treat_fulamt_ownpay_amt float64 = 0
  938. var bed_claa_sunmfee float64 = 0
  939. var bed_clab_amt float64 = 0
  940. var bed_other_amt float64 = 0
  941. var operation_claa_sunmfee float64 = 0
  942. var operation_clab_amt float64 = 0
  943. var operation_other_amt float64 = 0
  944. var other_claa_sunmfee float64 = 0
  945. var other_clab_amt float64 = 0
  946. var other_other_amt float64 = 0
  947. var westernMedicine_claa_sunmfee float64 = 0
  948. var westernMedicine_clab_amt float64 = 0
  949. var westernMedicine_other_amt float64 = 0
  950. var chineseTraditional_claa_sunmfee float64 = 0
  951. var chineseTraditional_clab_amt float64 = 0
  952. var chineseTraditional_other_amt float64 = 0
  953. var check_claa_sunmfee float64 = 0
  954. var check_clab_amt float64 = 0
  955. var check_other_amt float64 = 0
  956. var material_claa_sunmfee float64 = 0
  957. var material_clab_amt float64 = 0
  958. var material_other_amt float64 = 0
  959. var laboratory_claa_sunmfee float64 = 0
  960. var laboratory_clab_amt float64 = 0
  961. var laboratory_other_amt float64 = 0
  962. var treat_claa_sunmfee float64 = 0
  963. var treat_clab_amt float64 = 0
  964. var treat_other_amt float64 = 0
  965. for _, item := range order.HisOrderInfo {
  966. if item.MedChrgitmType == "01" { //床位费
  967. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  968. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  969. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  970. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  971. if item.ChrgitmLv == "1" {
  972. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  973. }
  974. if item.ChrgitmLv == "2" {
  975. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  976. }
  977. if item.ChrgitmLv == "3" {
  978. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  979. }
  980. }
  981. if item.MedChrgitmType == "03" { //检查费
  982. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  983. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  984. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  985. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  986. if item.ChrgitmLv == "1" {
  987. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  988. }
  989. if item.ChrgitmLv == "2" {
  990. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  991. }
  992. if item.ChrgitmLv == "3" {
  993. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  994. }
  995. }
  996. if item.MedChrgitmType == "04" { //化验费
  997. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  998. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  999. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1000. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1001. if item.ChrgitmLv == "1" {
  1002. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1003. }
  1004. if item.ChrgitmLv == "2" {
  1005. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1006. }
  1007. if item.ChrgitmLv == "3" {
  1008. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1009. }
  1010. }
  1011. if item.MedChrgitmType == "05" { //治疗费
  1012. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1013. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1014. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1015. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1016. if item.ChrgitmLv == "1" {
  1017. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1018. }
  1019. if item.ChrgitmLv == "2" {
  1020. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1021. }
  1022. if item.ChrgitmLv == "3" {
  1023. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1024. }
  1025. }
  1026. if item.MedChrgitmType == "06" { //手术费
  1027. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1028. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1029. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1030. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1031. if item.ChrgitmLv == "1" {
  1032. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1033. }
  1034. if item.ChrgitmLv == "2" {
  1035. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1036. }
  1037. if item.ChrgitmLv == "3" {
  1038. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1039. }
  1040. }
  1041. if item.MedChrgitmType == "08" { //材料费
  1042. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1043. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1044. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1045. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1046. if item.ChrgitmLv == "1" {
  1047. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1048. }
  1049. if item.ChrgitmLv == "2" {
  1050. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1051. }
  1052. if item.ChrgitmLv == "3" {
  1053. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1054. }
  1055. }
  1056. if item.MedChrgitmType == "09" { //西药费
  1057. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1058. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1059. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1060. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1061. if item.ChrgitmLv == "1" {
  1062. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1063. }
  1064. if item.ChrgitmLv == "2" {
  1065. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1066. }
  1067. if item.ChrgitmLv == "3" {
  1068. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1069. }
  1070. }
  1071. if item.MedChrgitmType == "11" { //中成费
  1072. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1073. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1074. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1075. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1076. if item.ChrgitmLv == "1" {
  1077. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1078. }
  1079. if item.ChrgitmLv == "2" {
  1080. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1081. }
  1082. if item.ChrgitmLv == "3" {
  1083. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1084. }
  1085. }
  1086. if item.MedChrgitmType == "14" { //其他费
  1087. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1088. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1089. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1090. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1091. if item.ChrgitmLv == "1" {
  1092. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1093. }
  1094. if item.ChrgitmLv == "2" {
  1095. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1096. }
  1097. if item.ChrgitmLv == "3" {
  1098. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1099. }
  1100. }
  1101. }
  1102. var iteminfoStructs []service.IteminfoStruct
  1103. if bedCostTotal != 0 {
  1104. iteminfo.MedChrgitm = "01"
  1105. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1106. iteminfo.Amt = bedCostTotal
  1107. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1108. iteminfo.ClabAmt = bed_clab_amt
  1109. iteminfo.OthAmt = bed_other_amt
  1110. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1111. }
  1112. if checkCostTotal != 0 {
  1113. iteminfo.MedChrgitm = "03"
  1114. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1115. iteminfo.Amt = checkCostTotal
  1116. iteminfo.ClaaSumfee = check_claa_sunmfee
  1117. iteminfo.ClabAmt = check_clab_amt
  1118. iteminfo.OthAmt = check_other_amt
  1119. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1120. }
  1121. if laboratoryCostTotal != 0 {
  1122. iteminfo.MedChrgitm = "04"
  1123. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1124. iteminfo.Amt = laboratoryCostTotal
  1125. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1126. iteminfo.ClabAmt = laboratory_clab_amt
  1127. iteminfo.OthAmt = laboratory_other_amt
  1128. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1129. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1130. }
  1131. if treatCostTotal != 0 {
  1132. iteminfo.MedChrgitm = "05"
  1133. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1134. iteminfo.Amt = treatCostTotal
  1135. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1136. iteminfo.ClabAmt = treat_clab_amt
  1137. iteminfo.OthAmt = treat_other_amt
  1138. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1139. //(struct4101.IteminfoStruct, iteminfo)
  1140. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1141. }
  1142. if operationCostTotal != 0 {
  1143. iteminfo.MedChrgitm = "06"
  1144. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1145. iteminfo.Amt = operationCostTotal
  1146. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1147. iteminfo.ClabAmt = operation_clab_amt
  1148. iteminfo.OthAmt = operation_other_amt
  1149. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1150. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1151. }
  1152. if materialCostTotal != 0 {
  1153. iteminfo.MedChrgitm = "08"
  1154. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1155. iteminfo.Amt = materialCostTotal
  1156. iteminfo.ClaaSumfee = material_claa_sunmfee
  1157. iteminfo.ClabAmt = material_clab_amt
  1158. iteminfo.OthAmt = material_other_amt
  1159. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1160. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1161. }
  1162. if westernMedicineCostTotal != 0 {
  1163. iteminfo.MedChrgitm = "09"
  1164. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1165. iteminfo.Amt = westernMedicineCostTotal
  1166. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1167. iteminfo.ClabAmt = westernMedicine_clab_amt
  1168. iteminfo.OthAmt = westernMedicine_other_amt
  1169. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1170. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1171. }
  1172. if chineseTraditionalMedicineCostTotal != 0 {
  1173. iteminfo.MedChrgitm = "11"
  1174. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1175. iteminfo.Amt = westernMedicineCostTotal
  1176. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1177. iteminfo.ClabAmt = westernMedicine_clab_amt
  1178. iteminfo.OthAmt = westernMedicine_other_amt
  1179. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1180. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1181. }
  1182. if otherCostTotal != 0 {
  1183. iteminfo.MedChrgitm = "14"
  1184. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1185. iteminfo.Amt = otherCostTotal
  1186. iteminfo.ClaaSumfee = other_claa_sunmfee
  1187. iteminfo.ClabAmt = other_clab_amt
  1188. iteminfo.OthAmt = other_other_amt
  1189. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1190. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1191. }
  1192. struct4101.IteminfoStruct = iteminfoStructs
  1193. struct4101.Ntly = "中国"
  1194. struct4101.AdmCaty = "A03.06"
  1195. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1196. fmt.Println(result)
  1197. var dat map[string]interface{}
  1198. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1199. fmt.Println(dat)
  1200. } else {
  1201. fmt.Println(err)
  1202. }
  1203. userJSONBytes, _ := json.Marshal(dat)
  1204. var res ResultSeventeen
  1205. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1206. utils.ErrorLog("解析失败:%v", err)
  1207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1208. return
  1209. }
  1210. if res.Infcode != 0 {
  1211. c.ServeSuccessJSON(map[string]interface{}{
  1212. "failed_code": -10,
  1213. "msg": res.ErrMsg,
  1214. })
  1215. return
  1216. } else {
  1217. order.FaPiaoNumber = zero
  1218. order.FaPiaoCode = last_order.FaPiaoCode
  1219. service.UpdateOrder(order)
  1220. hisFundSettleListResult := &models.HisFundSettleListResult{
  1221. Number: res.Output.SetlListId,
  1222. Status: 1,
  1223. Ctime: time.Now().Unix(),
  1224. Mtime: time.Now().Unix(),
  1225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1226. IsUpload: 1,
  1227. OrderId: order_id,
  1228. }
  1229. service.CreateUploadRecord(hisFundSettleListResult)
  1230. c.ServeSuccessJSON(map[string]interface{}{
  1231. "msg": "上传成功",
  1232. "result": hisFundSettleListResult,
  1233. })
  1234. return
  1235. }
  1236. }
  1237. func (c *HisApiController) GetSettleListHospital() {
  1238. order_id, _ := c.GetInt64("order_id")
  1239. admin_user_id, _ := c.GetInt64("admin_user_id")
  1240. order, _ := service.GetHisOrderByIDTwo(order_id)
  1241. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1242. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1243. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1244. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1245. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1246. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1247. if order.ID == 0 {
  1248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1249. return
  1250. }
  1251. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1252. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1253. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1254. fmt.Println(count)
  1255. var zero string
  1256. number := count + 1
  1257. if number >= 1000 {
  1258. zero = "0000" + strconv.FormatInt(number, 10)
  1259. } else if number >= 10000 {
  1260. zero = "000" + strconv.FormatInt(number, 10)
  1261. } else if number >= 100000 {
  1262. zero = "00" + strconv.FormatInt(number, 10)
  1263. } else if number >= 1000000 {
  1264. zero = "0" + strconv.FormatInt(number, 10)
  1265. } else {
  1266. zero = strconv.FormatInt(number, 10)
  1267. }
  1268. fmt.Println(zero)
  1269. struct4101 := service.Struct4101{
  1270. PsnNo: order.PsnNo,
  1271. MdtrtId: order.MdtrtId,
  1272. SetlId: order.SetlId,
  1273. PsnName: order.PsnName,
  1274. Gend: order.Gend,
  1275. Brdy: his.Brdy,
  1276. Age: int64(order.Age),
  1277. Naty: order.Naty,
  1278. PatnCertType: "01",
  1279. Certno: order.Certno,
  1280. Prfs: "90",
  1281. ConerName: roles[0].UserName,
  1282. PatnRlts: "99",
  1283. ConerAddr: miConfig.OrgName,
  1284. ConerTel: admin.Mobile,
  1285. HiType: order.Insutype,
  1286. Insuplc: miConfig.InsuplcAdmdvs,
  1287. MaindiagFlag: "1",
  1288. BillCode: last_order.FaPiaoCode,
  1289. BillNo: zero,
  1290. BizSn: order.Number,
  1291. PsnSelfPay: order.PsnPartAmt,
  1292. PsnOwnPay: order.PsnPartAmt,
  1293. AcctPay: order.AcctPay,
  1294. PsnCashpay: order.PsnCashPay,
  1295. HiPaymtd: "1",
  1296. Hsorg: miConfig.InsuplcAdmdvs,
  1297. HsorgOpter: miConfig.InsuplcAdmdvs,
  1298. MedinsFillPsn: curRoles.UserName,
  1299. MedinsFillDept: depart.Name,
  1300. IptMedType: "2",
  1301. AdmTime: his.InHosptialTime,
  1302. AdmEndTime: his.OutHosptialTime,
  1303. }
  1304. struct4101.SetlBegnDate = order.SetlTime
  1305. struct4101.SetlEndDate = order.SetlTime
  1306. var rf []CustomFundPay
  1307. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1308. var tempFunPays []service.CustomStruct
  1309. for _, item := range rf {
  1310. var tempFunPay service.CustomStruct
  1311. tempFunPay.FundPayamt = item.FundPayamt
  1312. tempFunPay.FundPayType = item.FundPayType
  1313. tempFunPays = append(tempFunPays, tempFunPay)
  1314. }
  1315. struct4101.CustomStruct = tempFunPays
  1316. var tempDiaginfos []service.DiaginfoStructTwo
  1317. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1318. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1319. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1320. var config []*models.HisXtDiagnoseConfig
  1321. for _, item := range diagnosis_ids {
  1322. id, _ := strconv.ParseInt(item, 10, 64)
  1323. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1324. config = append(config, &diagnosisConfig)
  1325. }
  1326. for index, item := range config {
  1327. if index == 0 {
  1328. var tempDiaginfo service.DiaginfoStructTwo
  1329. tempDiaginfo.DiagCode = item.CountryCode
  1330. tempDiaginfo.DiagName = item.CountryContentName
  1331. tempDiaginfo.DiagType = "1"
  1332. tempDiaginfo.MaindiagFlag = "1"
  1333. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1334. } else {
  1335. var tempDiaginfo service.DiaginfoStructTwo
  1336. tempDiaginfo.DiagCode = item.CountryCode
  1337. tempDiaginfo.DiagName = item.CountryContentName
  1338. tempDiaginfo.DiagType = "2"
  1339. tempDiaginfo.MaindiagFlag = "0"
  1340. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1341. }
  1342. }
  1343. struct4101.Diseinfo = tempDiaginfos
  1344. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1345. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1346. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1347. tempOpspdiseinfo2.OprnOprtCode = ""
  1348. tempOpspdiseinfo2.OprnOprtName = ""
  1349. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1350. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1351. var iteminfo service.IteminfoStruct
  1352. var bedCostTotal float64 = 0 //床位总费
  1353. var bedCostSelfTotal float64 = 0 //床位自费
  1354. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1355. var operationCostTotal float64 = 0 //手术费
  1356. var operationCostSelfTotal float64 = 0 //手术费
  1357. var operationCostPartSelfTotal float64 = 0 //手术费
  1358. var otherCostTotal float64 = 0 //其他费用
  1359. var otherCostSelfTotal float64 = 0 //其他费用
  1360. var otherCostPartSelfTotal float64 = 0 //其他费用
  1361. var materialCostTotal float64 = 0 //材料费
  1362. var materialCostSelfTotal float64 = 0 //材料费
  1363. var materialCostPartSelfTotal float64 = 0 //材料费
  1364. var westernMedicineCostTotal float64 = 0 //西药费
  1365. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1366. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1367. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1368. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1369. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1370. var checkCostTotal float64 = 0 //检查费
  1371. var checkCostSelfTotal float64 = 0 //检查费
  1372. var checkCostPartSelfTotal float64 = 0 //检查费
  1373. var laboratoryCostTotal float64 = 0 //化验费
  1374. var laboratoryCostSelfTotal float64 = 0 //化验费
  1375. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1376. var treatCostTotal float64 = 0 //治疗费用
  1377. var treatCostSelfTotal float64 = 0 //治疗费用
  1378. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1379. decimal.DivisionPrecision = 2
  1380. var bed_fulamt_ownpay_amt float64 = 0
  1381. var operation_fulamt_ownpay_amt float64 = 0
  1382. var other_fulamt_ownpay_amt float64 = 0
  1383. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1384. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1385. var check_fulamt_ownpay_amt float64 = 0
  1386. var material_fulamt_ownpay_amt float64 = 0
  1387. var laboratory_fulamt_ownpay_amt float64 = 0
  1388. var treat_fulamt_ownpay_amt float64 = 0
  1389. var bed_claa_sunmfee float64 = 0
  1390. var bed_clab_amt float64 = 0
  1391. var bed_other_amt float64 = 0
  1392. var operation_claa_sunmfee float64 = 0
  1393. var operation_clab_amt float64 = 0
  1394. var operation_other_amt float64 = 0
  1395. var other_claa_sunmfee float64 = 0
  1396. var other_clab_amt float64 = 0
  1397. var other_other_amt float64 = 0
  1398. var westernMedicine_claa_sunmfee float64 = 0
  1399. var westernMedicine_clab_amt float64 = 0
  1400. var westernMedicine_other_amt float64 = 0
  1401. var chineseTraditional_claa_sunmfee float64 = 0
  1402. var chineseTraditional_clab_amt float64 = 0
  1403. var chineseTraditional_other_amt float64 = 0
  1404. var check_claa_sunmfee float64 = 0
  1405. var check_clab_amt float64 = 0
  1406. var check_other_amt float64 = 0
  1407. var material_claa_sunmfee float64 = 0
  1408. var material_clab_amt float64 = 0
  1409. var material_other_amt float64 = 0
  1410. var laboratory_claa_sunmfee float64 = 0
  1411. var laboratory_clab_amt float64 = 0
  1412. var laboratory_other_amt float64 = 0
  1413. var treat_claa_sunmfee float64 = 0
  1414. var treat_clab_amt float64 = 0
  1415. var treat_other_amt float64 = 0
  1416. for _, item := range order.HisOrderInfo {
  1417. if item.MedChrgitmType == "01" { //床位费
  1418. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1419. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1420. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1421. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1422. if item.ChrgitmLv == "1" {
  1423. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1424. }
  1425. if item.ChrgitmLv == "2" {
  1426. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1427. }
  1428. if item.ChrgitmLv == "3" {
  1429. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1430. }
  1431. }
  1432. if item.MedChrgitmType == "03" { //检查费
  1433. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1434. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1435. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1436. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1437. if item.ChrgitmLv == "1" {
  1438. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1439. }
  1440. if item.ChrgitmLv == "2" {
  1441. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1442. }
  1443. if item.ChrgitmLv == "3" {
  1444. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1445. }
  1446. }
  1447. if item.MedChrgitmType == "04" { //化验费
  1448. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1449. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1450. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1451. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1452. if item.ChrgitmLv == "1" {
  1453. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1454. }
  1455. if item.ChrgitmLv == "2" {
  1456. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1457. }
  1458. if item.ChrgitmLv == "3" {
  1459. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1460. }
  1461. }
  1462. if item.MedChrgitmType == "05" { //治疗费
  1463. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1464. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1465. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1466. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1467. if item.ChrgitmLv == "1" {
  1468. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1469. }
  1470. if item.ChrgitmLv == "2" {
  1471. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1472. }
  1473. if item.ChrgitmLv == "3" {
  1474. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1475. }
  1476. }
  1477. if item.MedChrgitmType == "06" { //手术费
  1478. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1479. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1480. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1481. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1482. if item.ChrgitmLv == "1" {
  1483. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1484. }
  1485. if item.ChrgitmLv == "2" {
  1486. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1487. }
  1488. if item.ChrgitmLv == "3" {
  1489. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1490. }
  1491. }
  1492. if item.MedChrgitmType == "08" { //材料费
  1493. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1494. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1495. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1496. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1497. if item.ChrgitmLv == "1" {
  1498. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1499. }
  1500. if item.ChrgitmLv == "2" {
  1501. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1502. }
  1503. if item.ChrgitmLv == "3" {
  1504. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1505. }
  1506. }
  1507. if item.MedChrgitmType == "09" { //西药费
  1508. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1509. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1510. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1511. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1512. if item.ChrgitmLv == "1" {
  1513. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1514. }
  1515. if item.ChrgitmLv == "2" {
  1516. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1517. }
  1518. if item.ChrgitmLv == "3" {
  1519. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1520. }
  1521. }
  1522. if item.MedChrgitmType == "11" { //中成费
  1523. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1524. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1525. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1526. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1527. if item.ChrgitmLv == "1" {
  1528. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1529. }
  1530. if item.ChrgitmLv == "2" {
  1531. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1532. }
  1533. if item.ChrgitmLv == "3" {
  1534. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1535. }
  1536. }
  1537. if item.MedChrgitmType == "14" { //其他费
  1538. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1539. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1540. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1541. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1542. if item.ChrgitmLv == "1" {
  1543. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1544. }
  1545. if item.ChrgitmLv == "2" {
  1546. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1547. }
  1548. if item.ChrgitmLv == "3" {
  1549. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1550. }
  1551. }
  1552. }
  1553. var iteminfoStructs []service.IteminfoStruct
  1554. if bedCostTotal != 0 {
  1555. iteminfo.MedChrgitm = "01"
  1556. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1557. iteminfo.Amt = bedCostTotal
  1558. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1559. iteminfo.ClabAmt = bed_clab_amt
  1560. iteminfo.OthAmt = bed_other_amt
  1561. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1562. }
  1563. if checkCostTotal != 0 {
  1564. iteminfo.MedChrgitm = "03"
  1565. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1566. iteminfo.Amt = checkCostTotal
  1567. iteminfo.ClaaSumfee = check_claa_sunmfee
  1568. iteminfo.ClabAmt = check_clab_amt
  1569. iteminfo.OthAmt = check_other_amt
  1570. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1571. }
  1572. if laboratoryCostTotal != 0 {
  1573. iteminfo.MedChrgitm = "04"
  1574. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1575. iteminfo.Amt = laboratoryCostTotal
  1576. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1577. iteminfo.ClabAmt = laboratory_clab_amt
  1578. iteminfo.OthAmt = laboratory_other_amt
  1579. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1580. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1581. }
  1582. if treatCostTotal != 0 {
  1583. iteminfo.MedChrgitm = "05"
  1584. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1585. iteminfo.Amt = treatCostTotal
  1586. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1587. iteminfo.ClabAmt = treat_clab_amt
  1588. iteminfo.OthAmt = treat_other_amt
  1589. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1590. //(struct4101.IteminfoStruct, iteminfo)
  1591. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1592. }
  1593. if operationCostTotal != 0 {
  1594. iteminfo.MedChrgitm = "06"
  1595. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1596. iteminfo.Amt = operationCostTotal
  1597. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1598. iteminfo.ClabAmt = operation_clab_amt
  1599. iteminfo.OthAmt = operation_other_amt
  1600. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1601. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1602. }
  1603. if materialCostTotal != 0 {
  1604. iteminfo.MedChrgitm = "08"
  1605. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1606. iteminfo.Amt = materialCostTotal
  1607. iteminfo.ClaaSumfee = material_claa_sunmfee
  1608. iteminfo.ClabAmt = material_clab_amt
  1609. iteminfo.OthAmt = material_other_amt
  1610. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1611. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1612. }
  1613. if westernMedicineCostTotal != 0 {
  1614. iteminfo.MedChrgitm = "09"
  1615. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1616. iteminfo.Amt = westernMedicineCostTotal
  1617. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1618. iteminfo.ClabAmt = westernMedicine_clab_amt
  1619. iteminfo.OthAmt = westernMedicine_other_amt
  1620. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1621. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1622. }
  1623. if chineseTraditionalMedicineCostTotal != 0 {
  1624. iteminfo.MedChrgitm = "11"
  1625. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1626. iteminfo.Amt = westernMedicineCostTotal
  1627. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1628. iteminfo.ClabAmt = westernMedicine_clab_amt
  1629. iteminfo.OthAmt = westernMedicine_other_amt
  1630. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1631. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1632. }
  1633. if otherCostTotal != 0 {
  1634. iteminfo.MedChrgitm = "14"
  1635. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1636. iteminfo.Amt = otherCostTotal
  1637. iteminfo.ClaaSumfee = other_claa_sunmfee
  1638. iteminfo.ClabAmt = other_clab_amt
  1639. iteminfo.OthAmt = other_other_amt
  1640. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1641. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1642. }
  1643. struct4101.IteminfoStruct = iteminfoStructs
  1644. struct4101.Ntly = "中国"
  1645. struct4101.AdmCaty = "A03.06"
  1646. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1647. fmt.Println(result)
  1648. var dat map[string]interface{}
  1649. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1650. fmt.Println(dat)
  1651. } else {
  1652. fmt.Println(err)
  1653. }
  1654. userJSONBytes, _ := json.Marshal(dat)
  1655. var res ResultSeventeen
  1656. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1657. utils.ErrorLog("解析失败:%v", err)
  1658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1659. return
  1660. }
  1661. if res.Infcode != 0 {
  1662. c.ServeSuccessJSON(map[string]interface{}{
  1663. "failed_code": -10,
  1664. "msg": res.ErrMsg,
  1665. })
  1666. return
  1667. } else {
  1668. order.FaPiaoNumber = zero
  1669. order.FaPiaoCode = last_order.FaPiaoCode
  1670. service.UpdateOrder(order)
  1671. hisFundSettleListResult := &models.HisFundSettleListResult{
  1672. Number: res.Output.SetlListId,
  1673. Status: 1,
  1674. Ctime: time.Now().Unix(),
  1675. Mtime: time.Now().Unix(),
  1676. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1677. IsUpload: 1,
  1678. OrderId: order_id,
  1679. }
  1680. service.CreateUploadRecord(hisFundSettleListResult)
  1681. c.ServeSuccessJSON(map[string]interface{}{
  1682. "msg": "上传成功",
  1683. "result": hisFundSettleListResult,
  1684. })
  1685. return
  1686. }
  1687. }
  1688. func (c *HisApiController) GetBatchSettleList() {
  1689. orders, _ := service.GetAllHisOrder(10106)
  1690. for _, item := range orders {
  1691. order_id := item.ID
  1692. order, _ := service.GetHisOrderByIDTwo(order_id)
  1693. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1694. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1695. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1696. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  1697. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1698. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1699. if order.ID == 0 {
  1700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1701. return
  1702. }
  1703. if his.BalanceAccountsType == 2 {
  1704. continue
  1705. }
  1706. struct4101 := service.Struct4101{
  1707. PsnNo: order.PsnNo,
  1708. MdtrtId: order.MdtrtId,
  1709. SetlId: order.SetlId,
  1710. PsnName: order.PsnName,
  1711. Gend: order.Gend,
  1712. Brdy: his.Brdy,
  1713. Age: his.Age,
  1714. Naty: order.Naty,
  1715. PatnCertType: "01",
  1716. Certno: order.Certno,
  1717. Prfs: "90",
  1718. ConerName: roles[0].UserName,
  1719. PatnRlts: "99",
  1720. ConerAddr: miConfig.OrgName,
  1721. ConerTel: admin.Mobile,
  1722. HiType: order.Insutype,
  1723. Insuplc: his.InsuplcAdmdvs,
  1724. MaindiagFlag: "1",
  1725. BillCode: order.FaPiaoCode,
  1726. BillNo: order.FaPiaoNumber,
  1727. BizSn: order.Number,
  1728. PsnSelfPay: order.PsnPartAmt,
  1729. PsnOwnPay: order.PsnPartAmt,
  1730. AcctPay: order.AcctPay,
  1731. PsnCashpay: order.PsnCashPay,
  1732. HiPaymtd: "1",
  1733. Hsorg: his.InsuplcAdmdvs,
  1734. HsorgOpter: his.InsuplcAdmdvs,
  1735. MedinsFillPsn: curRoles.UserName,
  1736. MedinsFillDept: depart.Name,
  1737. IptMedType: "2",
  1738. }
  1739. struct4101.SetlBegnDate = order.SetlTime
  1740. struct4101.SetlEndDate = order.SetlTime
  1741. //if order.SettleType == 1 {
  1742. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1743. // dateStr := t.Format("2006-01-02")
  1744. // struct4101.SetlBegnDate = dateStr
  1745. // struct4101.SetlEndDate = dateStr
  1746. //} else {
  1747. // t := time.Unix(int64(order.SettleStartTime), 0)
  1748. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1749. // dateStartStr := t.Format("2006-01-02")
  1750. // dateEndStr := t2.Format("2006-01-02")
  1751. // struct4101.SetlBegnDate = dateStartStr
  1752. // struct4101.SetlEndDate = dateEndStr
  1753. //}
  1754. var rf []CustomFundPay
  1755. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1756. var tempFunPays []service.CustomStruct
  1757. var tempFunPay610100 service.CustomStruct
  1758. for _, item := range rf {
  1759. if item.FundPayType == "610100" {
  1760. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1761. tempFunPay610100.FundPayType = item.FundPayType
  1762. } else {
  1763. var tempFunPay service.CustomStruct
  1764. tempFunPay.FundPayamt = item.FundPayamt
  1765. tempFunPay.FundPayType = item.FundPayType
  1766. tempFunPays = append(tempFunPays, tempFunPay)
  1767. }
  1768. }
  1769. tempFunPays = append(tempFunPays, tempFunPay610100)
  1770. struct4101.CustomStruct = tempFunPays
  1771. var tempDiaginfos []service.DiaginfoStructTwo
  1772. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1773. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1774. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1775. var config []*models.HisXtDiagnoseConfig
  1776. for _, item := range diagnosis_ids {
  1777. id, _ := strconv.ParseInt(item, 10, 64)
  1778. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1779. config = append(config, &diagnosisConfig)
  1780. }
  1781. for index, item := range config {
  1782. if index == 0 {
  1783. var tempDiaginfo service.DiaginfoStructTwo
  1784. tempDiaginfo.DiagCode = item.CountryCode
  1785. tempDiaginfo.DiagName = item.CountryContentName
  1786. tempDiaginfo.DiagType = "1"
  1787. tempDiaginfo.MaindiagFlag = "1"
  1788. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1789. } else {
  1790. var tempDiaginfo service.DiaginfoStructTwo
  1791. tempDiaginfo.DiagCode = item.CountryCode
  1792. tempDiaginfo.DiagName = item.CountryContentName
  1793. tempDiaginfo.DiagType = "2"
  1794. tempDiaginfo.MaindiagFlag = "0"
  1795. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1796. }
  1797. }
  1798. struct4101.Diseinfo = tempDiaginfos
  1799. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1800. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1801. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1802. tempOpspdiseinfo2.OprnOprtCode = ""
  1803. tempOpspdiseinfo2.OprnOprtName = ""
  1804. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1805. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1806. var iteminfo service.IteminfoStruct
  1807. var bedCostTotal float64 = 0 //床位总费
  1808. var bedCostSelfTotal float64 = 0 //床位自费
  1809. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1810. var examineCostTotal float64 = 0 //诊查总费
  1811. var examineCostSelfTotal float64 = 0 //诊查自费
  1812. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1813. var nursingCostTotal float64 = 0 //护理总费
  1814. var nursingCostSelfTotal float64 = 0 //护理自费
  1815. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1816. var chineseMedicineCostTotal float64 = 0 //中成药
  1817. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1818. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1819. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1820. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1821. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1822. var registerCostTotal float64 = 0 //一般诊疗费
  1823. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1824. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1825. var operationCostTotal float64 = 0 //手术费
  1826. var operationCostSelfTotal float64 = 0 //手术费
  1827. var operationCostPartSelfTotal float64 = 0 //手术费
  1828. var otherCostTotal float64 = 0 //其他费用
  1829. var otherCostSelfTotal float64 = 0 //其他费用
  1830. var otherCostPartSelfTotal float64 = 0 //其他费用
  1831. var materialCostTotal float64 = 0 //材料费
  1832. var materialCostSelfTotal float64 = 0 //材料费
  1833. var materialCostPartSelfTotal float64 = 0 //材料费
  1834. var westernMedicineCostTotal float64 = 0 //西药费
  1835. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1836. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1837. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1838. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1839. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1840. var checkCostTotal float64 = 0 //检查费
  1841. var checkCostSelfTotal float64 = 0 //检查费
  1842. var checkCostPartSelfTotal float64 = 0 //检查费
  1843. var laboratoryCostTotal float64 = 0 //化验费
  1844. var laboratoryCostSelfTotal float64 = 0 //化验费
  1845. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1846. var treatCostTotal float64 = 0 //治疗费用
  1847. var treatCostSelfTotal float64 = 0 //治疗费用
  1848. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1849. decimal.DivisionPrecision = 2
  1850. var bed_fulamt_ownpay_amt float64 = 0
  1851. var examine_fulamt_ownpay_amt float64 = 0
  1852. var nursing_fulamt_ownpay_amt float64 = 0
  1853. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1854. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1855. var register_fulamt_ownpay_amt float64 = 0
  1856. var operation_fulamt_ownpay_amt float64 = 0
  1857. var other_fulamt_ownpay_amt float64 = 0
  1858. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1859. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1860. var check_fulamt_ownpay_amt float64 = 0
  1861. var material_fulamt_ownpay_amt float64 = 0
  1862. var laboratory_fulamt_ownpay_amt float64 = 0
  1863. var treat_fulamt_ownpay_amt float64 = 0
  1864. var bed_claa_sunmfee float64 = 0
  1865. var bed_clab_amt float64 = 0
  1866. var bed_other_amt float64 = 0
  1867. var examine_claa_sunmfee float64 = 0
  1868. var examine_clab_amt float64 = 0
  1869. var examine_other_amt float64 = 0
  1870. var nursing_claa_sunmfee float64 = 0
  1871. var nursing_clab_amt float64 = 0
  1872. var nursing_other_amt float64 = 0
  1873. var chinese_medicine_claa_sunmfee float64 = 0
  1874. var chinese_medicine_clab_amt float64 = 0
  1875. var chinese_medicine_other_amt float64 = 0
  1876. var commonly_treatment_claa_sunmfee float64 = 0
  1877. var commonly_treatment_clab_amt float64 = 0
  1878. var commonly_treatment_other_amt float64 = 0
  1879. var operation_claa_sunmfee float64 = 0
  1880. var operation_clab_amt float64 = 0
  1881. var operation_other_amt float64 = 0
  1882. var other_claa_sunmfee float64 = 0
  1883. var other_clab_amt float64 = 0
  1884. var other_other_amt float64 = 0
  1885. var westernMedicine_claa_sunmfee float64 = 0
  1886. var westernMedicine_clab_amt float64 = 0
  1887. var westernMedicine_other_amt float64 = 0
  1888. var chineseTraditional_claa_sunmfee float64 = 0
  1889. var chineseTraditional_clab_amt float64 = 0
  1890. var chineseTraditional_other_amt float64 = 0
  1891. var check_claa_sunmfee float64 = 0
  1892. var check_clab_amt float64 = 0
  1893. var check_other_amt float64 = 0
  1894. var material_claa_sunmfee float64 = 0
  1895. var material_clab_amt float64 = 0
  1896. var material_other_amt float64 = 0
  1897. var laboratory_claa_sunmfee float64 = 0
  1898. var laboratory_clab_amt float64 = 0
  1899. var laboratory_other_amt float64 = 0
  1900. var treat_claa_sunmfee float64 = 0
  1901. var treat_clab_amt float64 = 0
  1902. var treat_other_amt float64 = 0
  1903. var register_claa_sunmfee float64 = 0
  1904. var register_clab_amt float64 = 0
  1905. var register_other_amt float64 = 0
  1906. for _, item := range order.HisOrderInfo {
  1907. if item.MedChrgitmType == "01" { //床位费
  1908. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1909. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1910. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1911. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1912. if item.ChrgitmLv == "1" {
  1913. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1914. }
  1915. if item.ChrgitmLv == "2" {
  1916. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1917. }
  1918. if item.ChrgitmLv == "3" {
  1919. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1920. }
  1921. }
  1922. if item.MedChrgitmType == "02" { //诊查
  1923. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1924. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1925. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1926. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1927. if item.ChrgitmLv == "1" {
  1928. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1929. }
  1930. if item.ChrgitmLv == "2" {
  1931. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1932. }
  1933. if item.ChrgitmLv == "3" {
  1934. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1935. }
  1936. }
  1937. if item.MedChrgitmType == "03" { //检查费
  1938. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1939. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1940. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1941. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1942. if item.ChrgitmLv == "1" {
  1943. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1944. }
  1945. if item.ChrgitmLv == "2" {
  1946. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1947. }
  1948. if item.ChrgitmLv == "3" {
  1949. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1950. }
  1951. }
  1952. if item.MedChrgitmType == "04" { //化验费
  1953. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1954. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1955. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1956. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1957. if item.ChrgitmLv == "1" {
  1958. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1959. }
  1960. if item.ChrgitmLv == "2" {
  1961. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1962. }
  1963. if item.ChrgitmLv == "3" {
  1964. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1965. }
  1966. }
  1967. if item.MedChrgitmType == "05" { //治疗费
  1968. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1969. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1970. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1971. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1972. if item.ChrgitmLv == "1" {
  1973. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1974. }
  1975. if item.ChrgitmLv == "2" {
  1976. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1977. }
  1978. if item.ChrgitmLv == "3" {
  1979. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1980. }
  1981. }
  1982. if item.MedChrgitmType == "06" { //手术费
  1983. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1984. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1985. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1986. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1987. if item.ChrgitmLv == "1" {
  1988. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1989. }
  1990. if item.ChrgitmLv == "2" {
  1991. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1992. }
  1993. if item.ChrgitmLv == "3" {
  1994. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1995. }
  1996. }
  1997. if item.MedChrgitmType == "07" { //手术费
  1998. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1999. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2000. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2001. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2002. if item.ChrgitmLv == "1" {
  2003. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2004. }
  2005. if item.ChrgitmLv == "2" {
  2006. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2007. }
  2008. if item.ChrgitmLv == "3" {
  2009. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2010. }
  2011. }
  2012. if item.MedChrgitmType == "08" { //材料费
  2013. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2014. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2015. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2016. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2017. if item.ChrgitmLv == "1" {
  2018. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2019. }
  2020. if item.ChrgitmLv == "2" {
  2021. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2022. }
  2023. if item.ChrgitmLv == "3" {
  2024. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2025. }
  2026. }
  2027. if item.MedChrgitmType == "09" { //西药费
  2028. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2029. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2030. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2031. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2032. if item.ChrgitmLv == "1" {
  2033. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2034. }
  2035. if item.ChrgitmLv == "2" {
  2036. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2037. }
  2038. if item.ChrgitmLv == "3" {
  2039. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2040. }
  2041. }
  2042. if item.MedChrgitmType == "10" { //中药饮片
  2043. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2044. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2045. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2046. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2047. if item.ChrgitmLv == "1" {
  2048. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2049. }
  2050. if item.ChrgitmLv == "2" {
  2051. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2052. }
  2053. if item.ChrgitmLv == "3" {
  2054. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2055. }
  2056. }
  2057. if item.MedChrgitmType == "11" { //中成费
  2058. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2059. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2060. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2061. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2062. if item.ChrgitmLv == "1" {
  2063. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2064. }
  2065. if item.ChrgitmLv == "2" {
  2066. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2067. }
  2068. if item.ChrgitmLv == "3" {
  2069. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2070. }
  2071. }
  2072. if item.MedChrgitmType == "12" { //中成费
  2073. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2074. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2075. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2076. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2077. if item.ChrgitmLv == "1" {
  2078. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2079. }
  2080. if item.ChrgitmLv == "2" {
  2081. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2082. }
  2083. if item.ChrgitmLv == "3" {
  2084. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2085. }
  2086. }
  2087. if item.MedChrgitmType == "13" { //中成费
  2088. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2089. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2090. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2091. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2092. if item.ChrgitmLv == "1" {
  2093. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2094. }
  2095. if item.ChrgitmLv == "2" {
  2096. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2097. }
  2098. if item.ChrgitmLv == "3" {
  2099. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2100. }
  2101. }
  2102. if item.MedChrgitmType == "14" { //其他费
  2103. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2104. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2105. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2106. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2107. if item.ChrgitmLv == "1" {
  2108. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2109. }
  2110. if item.ChrgitmLv == "2" {
  2111. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2112. }
  2113. if item.ChrgitmLv == "3" {
  2114. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2115. }
  2116. }
  2117. }
  2118. var iteminfoStructs []service.IteminfoStruct
  2119. if bedCostTotal != 0 {
  2120. iteminfo.MedChrgitm = "01"
  2121. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2122. iteminfo.Amt = bedCostTotal
  2123. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2124. iteminfo.ClabAmt = bed_clab_amt
  2125. iteminfo.OthAmt = bed_other_amt
  2126. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2127. }
  2128. if examineCostTotal != 0 {
  2129. iteminfo.MedChrgitm = "02"
  2130. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2131. iteminfo.Amt = examineCostTotal
  2132. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2133. iteminfo.ClabAmt = examine_clab_amt
  2134. iteminfo.OthAmt = examine_other_amt
  2135. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2136. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2137. }
  2138. if checkCostTotal != 0 {
  2139. iteminfo.MedChrgitm = "03"
  2140. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2141. iteminfo.Amt = checkCostTotal
  2142. iteminfo.ClaaSumfee = check_claa_sunmfee
  2143. iteminfo.ClabAmt = check_clab_amt
  2144. iteminfo.OthAmt = check_other_amt
  2145. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2146. }
  2147. if laboratoryCostTotal != 0 {
  2148. iteminfo.MedChrgitm = "04"
  2149. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2150. iteminfo.Amt = laboratoryCostTotal
  2151. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2152. iteminfo.ClabAmt = laboratory_clab_amt
  2153. iteminfo.OthAmt = laboratory_other_amt
  2154. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2155. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2156. }
  2157. if treatCostTotal != 0 {
  2158. iteminfo.MedChrgitm = "05"
  2159. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2160. iteminfo.Amt = treatCostTotal
  2161. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2162. iteminfo.ClabAmt = treat_clab_amt
  2163. iteminfo.OthAmt = treat_other_amt
  2164. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2165. //(struct4101.IteminfoStruct, iteminfo)
  2166. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2167. }
  2168. if operationCostTotal != 0 {
  2169. iteminfo.MedChrgitm = "06"
  2170. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2171. iteminfo.Amt = operationCostTotal
  2172. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2173. iteminfo.ClabAmt = operation_clab_amt
  2174. iteminfo.OthAmt = operation_other_amt
  2175. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2176. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2177. }
  2178. if nursingCostTotal != 0 {
  2179. iteminfo.MedChrgitm = "07"
  2180. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2181. iteminfo.Amt = nursingCostTotal
  2182. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2183. iteminfo.ClabAmt = nursing_clab_amt
  2184. iteminfo.OthAmt = nursing_other_amt
  2185. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2186. }
  2187. if materialCostTotal != 0 {
  2188. iteminfo.MedChrgitm = "08"
  2189. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2190. iteminfo.Amt = materialCostTotal
  2191. iteminfo.ClaaSumfee = material_claa_sunmfee
  2192. iteminfo.ClabAmt = material_clab_amt
  2193. iteminfo.OthAmt = material_other_amt
  2194. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2195. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2196. }
  2197. if westernMedicineCostTotal != 0 {
  2198. iteminfo.MedChrgitm = "09"
  2199. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2200. iteminfo.Amt = westernMedicineCostTotal
  2201. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2202. iteminfo.ClabAmt = westernMedicine_clab_amt
  2203. iteminfo.OthAmt = westernMedicine_other_amt
  2204. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2205. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2206. }
  2207. if chineseMedicineCostTotal != 0 {
  2208. iteminfo.MedChrgitm = "10"
  2209. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2210. iteminfo.Amt = chineseMedicineCostTotal
  2211. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2212. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2213. iteminfo.OthAmt = chinese_medicine_other_amt
  2214. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2215. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2216. }
  2217. if chineseTraditionalMedicineCostTotal != 0 {
  2218. iteminfo.MedChrgitm = "11"
  2219. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2220. iteminfo.Amt = westernMedicineCostTotal
  2221. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2222. iteminfo.ClabAmt = westernMedicine_clab_amt
  2223. iteminfo.OthAmt = westernMedicine_other_amt
  2224. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2225. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2226. }
  2227. if commonlyTreatmentCostTotal != 0 {
  2228. iteminfo.MedChrgitm = "12"
  2229. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2230. iteminfo.Amt = commonlyTreatmentCostTotal
  2231. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2232. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2233. iteminfo.OthAmt = commonly_treatment_other_amt
  2234. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2235. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2236. }
  2237. if registerCostTotal != 0 {
  2238. iteminfo.MedChrgitm = "13"
  2239. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2240. iteminfo.Amt = registerCostTotal
  2241. iteminfo.ClaaSumfee = register_claa_sunmfee
  2242. iteminfo.ClabAmt = register_clab_amt
  2243. iteminfo.OthAmt = register_other_amt
  2244. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2245. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2246. }
  2247. if otherCostTotal != 0 {
  2248. iteminfo.MedChrgitm = "14"
  2249. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2250. iteminfo.Amt = otherCostTotal
  2251. iteminfo.ClaaSumfee = other_claa_sunmfee
  2252. iteminfo.ClabAmt = other_clab_amt
  2253. iteminfo.OthAmt = other_other_amt
  2254. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2255. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2256. }
  2257. struct4101.IteminfoStruct = iteminfoStructs
  2258. struct4101.Ntly = "中国"
  2259. struct4101.AdmCaty = "A03.06"
  2260. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2261. fmt.Println(result)
  2262. var dat map[string]interface{}
  2263. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2264. fmt.Println(dat)
  2265. } else {
  2266. fmt.Println(err)
  2267. }
  2268. userJSONBytes, _ := json.Marshal(dat)
  2269. var res ResultSeventeen
  2270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2271. utils.ErrorLog("解析失败:%v", err)
  2272. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2273. adminUser := c.GetAdminUserInfo()
  2274. errlog := &models.HisOrderError{
  2275. UserOrgId: adminUser.CurrentOrgId,
  2276. Ctime: time.Now().Unix(),
  2277. Mtime: time.Now().Unix(),
  2278. ErrMsg: res.ErrMsg + "解析失败",
  2279. Status: 1,
  2280. PatientId: order_id,
  2281. Stage: 10106,
  2282. }
  2283. service.CreateErrMsgLog(errlog)
  2284. continue
  2285. }
  2286. if res.Infcode != 0 {
  2287. adminUser := c.GetAdminUserInfo()
  2288. errlog := &models.HisOrderError{
  2289. UserOrgId: adminUser.CurrentOrgId,
  2290. Ctime: time.Now().Unix(),
  2291. Mtime: time.Now().Unix(),
  2292. ErrMsg: res.ErrMsg,
  2293. Status: 1,
  2294. PatientId: order_id,
  2295. Stage: 10106,
  2296. }
  2297. service.CreateErrMsgLog(errlog)
  2298. continue
  2299. } else {
  2300. hisFundSettleListResult := &models.HisFundSettleListResult{
  2301. Number: res.Output.SetlListId,
  2302. Status: 1,
  2303. Ctime: time.Now().Unix(),
  2304. Mtime: time.Now().Unix(),
  2305. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2306. IsUpload: 1,
  2307. OrderId: order_id,
  2308. }
  2309. service.CreateUploadRecord(hisFundSettleListResult)
  2310. continue
  2311. }
  2312. }
  2313. }
  2314. func (c *HisApiController) GetOrgInfo() {
  2315. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2316. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2317. }
  2318. func (c *HisApiController) GetHisPatientInfo() {
  2319. medical_insurance_card := c.GetString("medical_insurance_card")
  2320. id_card_type, _ := c.GetInt64("id_card_type")
  2321. id_card := c.GetString("id_card")
  2322. adminInfo := c.GetAdminUserInfo()
  2323. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2324. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2325. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2326. IdCardNo := ""
  2327. if id_card_type == 1 {
  2328. IdCardNo = medical_insurance_card
  2329. } else if id_card_type == 2 {
  2330. IdCardNo = id_card
  2331. }
  2332. if config.IsOpen == 1 {
  2333. 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
  2334. resp, requestErr := http.Get(api)
  2335. if requestErr != nil {
  2336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2337. return
  2338. }
  2339. defer resp.Body.Close()
  2340. body, ioErr := ioutil.ReadAll(resp.Body)
  2341. if ioErr != nil {
  2342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2344. return
  2345. }
  2346. var respJSON map[string]interface{}
  2347. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2350. return
  2351. }
  2352. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2353. userJSONBytes, _ := json.Marshal(userJSON)
  2354. var res ResultTwo
  2355. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2356. utils.ErrorLog("解析失败:%v", err)
  2357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2358. return
  2359. }
  2360. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2361. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2362. infoStr := string(Iinfos)
  2363. idetinfoStr := string(Idetinfos)
  2364. if res.Infcode == 0 {
  2365. his := models.VMHisPatient{
  2366. Status: 1,
  2367. Ctime: time.Now().Unix(),
  2368. Mtime: time.Now().Unix(),
  2369. PsnNo: res.Output.Baseinfo.PsnNo,
  2370. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2371. Certno: res.Output.Baseinfo.Certno,
  2372. PsnName: res.Output.Baseinfo.PsnName,
  2373. Gend: res.Output.Baseinfo.Gend,
  2374. Naty: res.Output.Baseinfo.Naty,
  2375. Brdy: res.Output.Baseinfo.Brdy,
  2376. Age: res.Output.Baseinfo.Age,
  2377. Iinfo: infoStr,
  2378. Idetinfo: idetinfoStr,
  2379. UserOrgId: adminInfo.CurrentOrgId,
  2380. IsReturn: 1,
  2381. IdCardType: id_card_type,
  2382. }
  2383. c.ServeSuccessJSON(map[string]interface{}{
  2384. "info": his,
  2385. })
  2386. } else {
  2387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2388. return
  2389. }
  2390. }
  2391. }
  2392. //func GetBasBaseInfo() (jsonStr string, err error) {
  2393. //
  2394. // handle := syscall.NewLazyDLL("SSCard.dll")
  2395. // add := handle.NewProc("ReadCardBas")
  2396. // str := make([]byte, 1024)
  2397. // str1 := make([]byte, 1024)
  2398. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2399. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2400. //
  2401. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2402. //
  2403. // fmt.Println("> Add(4,5)的结果为:", ret)
  2404. // handle.Release()
  2405. //
  2406. // return "", nil
  2407. //
  2408. //}
  2409. //func GetQRBaseInfo() (jsonStr string, err error) {
  2410. // handle := syscall.LoadDLL("SSCard.dll")
  2411. // ReadCardBas := handle.FindProc("GetQRBase")
  2412. //
  2413. // str := make([]byte, 256)
  2414. // str1 := make([]byte, 256)
  2415. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2416. //
  2417. // fmt.Println(string(str))
  2418. // fmt.Println(r)
  2419. // return string(str), nil
  2420. //}
  2421. //func CardInit() int {
  2422. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2423. // add := DllTestDef.MustFindProc("Init")
  2424. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2425. // if err != nil {
  2426. // fmt.Println("SSCard的运算结果为:", ret)
  2427. // }
  2428. // result := int(ret)
  2429. // return result
  2430. //}
  2431. //func CardInit() int {
  2432. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2433. // if err != nil {
  2434. // fmt.Println("SSCard的运算结果为:", ret)
  2435. // }
  2436. // fmt.Println(err)
  2437. // result := int(ret)
  2438. // return result
  2439. //}
  2440. func IntPtr(n int) uintptr {
  2441. return uintptr(n)
  2442. }
  2443. func StrPtr(s string) uintptr {
  2444. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2445. }
  2446. type Result2001 struct {
  2447. Cainfo interface{} `json:"cainfo"`
  2448. ErrMsg string `json:"err_msg"`
  2449. InfRefmsgid string `json:"inf_refmsgid"`
  2450. Infcode int64 `json:"infcode"`
  2451. Output struct {
  2452. Trtinfo struct {
  2453. PsnNo string `json:"psn_no"`
  2454. TrtChkType string `json:"trt_chk_type"`
  2455. FundPayType string `json:"fund_pay_type"`
  2456. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2457. Begndate string `json:"begndate"`
  2458. Enddate string `json:"enddate"`
  2459. TrtChkRslt string `json:"trt_chk_rslt"`
  2460. } `json:"trtinfo"`
  2461. } `json:"output"`
  2462. RefmsgTime string `json:"refmsg_time"`
  2463. RespondTime string `json:"respond_time"`
  2464. Signtype interface{} `json:"signtype"`
  2465. WarnMsg interface{} `json:"warn_msg"`
  2466. }
  2467. type Result2001Org10265 struct {
  2468. Cainfo interface{} `json:"cainfo"`
  2469. ErrMsg string `json:"err_msg"`
  2470. InfRefmsgid string `json:"inf_refmsgid"`
  2471. Infcode string `json:"infcode"`
  2472. Output struct {
  2473. Trtinfo struct {
  2474. PsnNo string `json:"psn_no"`
  2475. TrtChkType string `json:"trt_chk_type"`
  2476. FundPayType string `json:"fund_pay_type"`
  2477. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2478. Begndate string `json:"begndate"`
  2479. Enddate string `json:"enddate"`
  2480. TrtChkRslt string `json:"trt_chk_rslt"`
  2481. } `json:"trtinfo"`
  2482. } `json:"output"`
  2483. RefmsgTime string `json:"refmsg_time"`
  2484. RespondTime string `json:"respond_time"`
  2485. Signtype interface{} `json:"signtype"`
  2486. WarnMsg interface{} `json:"warn_msg"`
  2487. }
  2488. type ResultTwo struct {
  2489. ErrMsg string `json:"err_msg"`
  2490. InfRefmsgid string `json:"inf_refmsgid"`
  2491. Infcode int64 `json:"infcode"`
  2492. Output struct {
  2493. Baseinfo struct {
  2494. Age float64 `json:"age"`
  2495. Brdy string `json:"brdy"`
  2496. Certno string `json:"certno"`
  2497. Gend string `json:"gend"`
  2498. Naty string `json:"naty"`
  2499. PsnCertType string `json:"psn_cert_type"`
  2500. PsnName string `json:"psn_name"`
  2501. PsnNo string `json:"psn_no"`
  2502. } `json:"baseinfo"`
  2503. Idetinfo []interface{} `json:"idetinfo"`
  2504. Iinfo []struct {
  2505. Balc float64 `json:"balc"`
  2506. CvlservFlag string `json:"cvlserv_flag"`
  2507. EmpName string `json:"emp_name"`
  2508. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2509. Insutype string `json:"insutype"`
  2510. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2511. PausInsuDate string `json:"paus_insu_date"`
  2512. PsnInsuDate string `json:"psn_insu_date"`
  2513. PsnInsuStas string `json:"psn_insu_stas"`
  2514. PsnType string `json:"psn_type"`
  2515. } `json:"insuinfo"`
  2516. } `json:"output"`
  2517. RefmsgTime string `json:"refmsg_time"`
  2518. RespondTime string `json:"respond_time"`
  2519. Signtype interface{} `json:"signtype"`
  2520. WarnInfo interface{} `json:"warn_info"`
  2521. }
  2522. type ResultTwo10265 struct {
  2523. ErrMsg string `json:"err_msg"`
  2524. InfRefmsgid string `json:"inf_refmsgid"`
  2525. Infcode string `json:"infcode"`
  2526. Output struct {
  2527. Baseinfo struct {
  2528. Age float64 `json:"age"`
  2529. Brdy string `json:"brdy"`
  2530. Certno string `json:"certno"`
  2531. Gend string `json:"gend"`
  2532. Naty string `json:"naty"`
  2533. PsnCertType string `json:"psn_cert_type"`
  2534. PsnName string `json:"psn_name"`
  2535. PsnNo string `json:"psn_no"`
  2536. } `json:"baseinfo"`
  2537. Idetinfo []interface{} `json:"idetinfo"`
  2538. Iinfo []struct {
  2539. Balc float64 `json:"balc"`
  2540. CvlservFlag string `json:"cvlserv_flag"`
  2541. EmpName string `json:"emp_name"`
  2542. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2543. Insutype string `json:"insutype"`
  2544. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2545. PausInsuDate string `json:"paus_insu_date"`
  2546. PsnInsuDate string `json:"psn_insu_date"`
  2547. PsnInsuStas string `json:"psn_insu_stas"`
  2548. PsnType string `json:"psn_type"`
  2549. } `json:"insuinfo"`
  2550. } `json:"output"`
  2551. RefmsgTime string `json:"refmsg_time"`
  2552. RespondTime string `json:"respond_time"`
  2553. Signtype interface{} `json:"signtype"`
  2554. WarnInfo interface{} `json:"warn_info"`
  2555. }
  2556. type ResultThree struct {
  2557. Cainfo interface{} `json:"cainfo"`
  2558. ErrMsg string `json:"err_msg"`
  2559. InfRefmsgid string `json:"inf_refmsgid"`
  2560. Infcode int64 `json:"infcode"`
  2561. Output struct {
  2562. Data struct {
  2563. IptOtpNo string `json:"ipt_otp_no"`
  2564. MdtrtID string `json:"mdtrt_id"`
  2565. PsnNo string `json:"psn_no"`
  2566. } `json:"data"`
  2567. } `json:"output"`
  2568. RefmsgTime string `json:"refmsg_time"`
  2569. RespondTime string `json:"respond_time"`
  2570. Signtype interface{} `json:"signtype"`
  2571. WarnMsg interface{} `json:"warn_msg"`
  2572. }
  2573. type ResultThree10265 struct {
  2574. Cainfo interface{} `json:"cainfo"`
  2575. ErrMsg string `json:"err_msg"`
  2576. InfRefmsgid string `json:"inf_refmsgid"`
  2577. Infcode string `json:"infcode"`
  2578. Output struct {
  2579. Data struct {
  2580. IptOtpNo string `json:"ipt_otp_no"`
  2581. MdtrtID string `json:"mdtrt_id"`
  2582. PsnNo string `json:"psn_no"`
  2583. } `json:"data"`
  2584. } `json:"output"`
  2585. RefmsgTime string `json:"refmsg_time"`
  2586. RespondTime string `json:"respond_time"`
  2587. Signtype interface{} `json:"signtype"`
  2588. WarnMsg interface{} `json:"warn_msg"`
  2589. }
  2590. type ResultFour struct {
  2591. Cainfo string `json:"cainfo"`
  2592. ErrMsg string `json:"err_msg"`
  2593. InfRefmsgid string `json:"inf_refmsgid"`
  2594. Infcode int64 `json:"infcode"`
  2595. Output struct {
  2596. Result []struct {
  2597. BasMednFlag string `json:"bas_medn_flag"`
  2598. ChldMedcFlag string `json:"chld_medc_flag"`
  2599. ChrgitmLv string `json:"chrgitm_lv"`
  2600. Cnt float64 `json:"cnt"`
  2601. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2602. DrtReimFlag string `json:"drt_reim_flag"`
  2603. FeedetlSn string `json:"feedetl_sn"`
  2604. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2605. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2606. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2607. ListSpItemFlag string `json:"list_sp_item_flag"`
  2608. LmtUsedFlag string `json:"lmt_used_flag"`
  2609. MedChrgitmType string `json:"med_chrgitm_type"`
  2610. Memo string `json:"memo"`
  2611. OverlmtAmt float64 `json:"overlmt_amt"`
  2612. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2613. Pric float64 `json:"pric"`
  2614. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2615. SelfpayProp float64 `json:"selfpay_prop"`
  2616. } `json:"result"`
  2617. } `json:"output"`
  2618. RefmsgTime string `json:"refmsg_time"`
  2619. RespondTime string `json:"respond_time"`
  2620. Signtype string `json:"signtype"`
  2621. WarnMsg string `json:"warn_msg"`
  2622. }
  2623. type ResultFour10265 struct {
  2624. Cainfo string `json:"cainfo"`
  2625. ErrMsg string `json:"err_msg"`
  2626. InfRefmsgid string `json:"inf_refmsgid"`
  2627. Infcode string `json:"infcode"`
  2628. Output struct {
  2629. Result []struct {
  2630. BasMednFlag string `json:"bas_medn_flag"`
  2631. ChldMedcFlag string `json:"chld_medc_flag"`
  2632. ChrgitmLv string `json:"chrgitm_lv"`
  2633. Cnt float64 `json:"cnt"`
  2634. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2635. DrtReimFlag string `json:"drt_reim_flag"`
  2636. FeedetlSn string `json:"feedetl_sn"`
  2637. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2638. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2639. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2640. ListSpItemFlag string `json:"list_sp_item_flag"`
  2641. LmtUsedFlag string `json:"lmt_used_flag"`
  2642. MedChrgitmType string `json:"med_chrgitm_type"`
  2643. Memo string `json:"memo"`
  2644. OverlmtAmt float64 `json:"overlmt_amt"`
  2645. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2646. Pric float64 `json:"pric"`
  2647. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2648. SelfpayProp float64 `json:"selfpay_prop"`
  2649. } `json:"result"`
  2650. } `json:"output"`
  2651. RefmsgTime string `json:"refmsg_time"`
  2652. RespondTime string `json:"respond_time"`
  2653. Signtype string `json:"signtype"`
  2654. WarnMsg string `json:"warn_msg"`
  2655. }
  2656. type ResultFive struct {
  2657. Balc float64 `json:"balc"`
  2658. CvlservFlag string `json:"cvlserv_flag"`
  2659. EmpName string `json:"emp_name"`
  2660. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2661. Insutype string `json:"insutype"`
  2662. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2663. PausInsuDate string `json:"paus_insu_date"`
  2664. PsnInsuDate string `json:"psn_insu_date"`
  2665. PsnInsuStas string `json:"psn_insu_stas"`
  2666. PsnType string `json:"psn_type"`
  2667. }
  2668. type ResultSix struct {
  2669. Cainfo interface{} `json:"cainfo"`
  2670. ErrMsg string `json:"err_msg"`
  2671. InfRefmsgid string `json:"inf_refmsgid"`
  2672. Infcode int64 `json:"infcode"`
  2673. Output struct {
  2674. } `json:"output"`
  2675. RefmsgTime string `json:"refmsg_time"`
  2676. RespondTime string `json:"respond_time"`
  2677. Signtype interface{} `json:"signtype"`
  2678. WarnMsg interface{} `json:"warn_msg"`
  2679. }
  2680. type ResultSix10265 struct {
  2681. Cainfo interface{} `json:"cainfo"`
  2682. ErrMsg string `json:"err_msg"`
  2683. InfRefmsgid string `json:"inf_refmsgid"`
  2684. Infcode string `json:"infcode"`
  2685. Output struct {
  2686. } `json:"output"`
  2687. RefmsgTime string `json:"refmsg_time"`
  2688. RespondTime string `json:"respond_time"`
  2689. Signtype interface{} `json:"signtype"`
  2690. WarnMsg interface{} `json:"warn_msg"`
  2691. }
  2692. type ResultSeven struct {
  2693. Cainfo string `json:"cainfo"`
  2694. ErrMsg string `json:"err_msg"`
  2695. InfRefmsgid string `json:"inf_refmsgid"`
  2696. Infcode int64 `json:"infcode"`
  2697. Output struct {
  2698. Setldetail []interface{} `json:"setldetail"`
  2699. Setlinfo struct {
  2700. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2701. AcctPay float64 `json:"acct_pay"`
  2702. ActPayDedc float64 `json:"act_pay_dedc"`
  2703. Age float64 `json:"age"`
  2704. Balc float64 `json:"balc"`
  2705. Brdy string `json:"brdy"`
  2706. Certno string `json:"certno"`
  2707. ClrOptins string `json:"clr_optins"`
  2708. ClrType string `json:"clr_type"`
  2709. ClrWay string `json:"clr_way"`
  2710. CvlservFlag string `json:"cvlserv_flag"`
  2711. CvlservPay float64 `json:"cvlserv_pay"`
  2712. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2713. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2714. Gend string `json:"gend"`
  2715. HifesPay float64 `json:"hifes_pay"`
  2716. HifmiPay float64 `json:"hifmi_pay"`
  2717. HifpPay float64 `json:"hifp_pay"`
  2718. HospPartAmt float64 `json:"hosp_part_amt"`
  2719. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2720. Insutype string `json:"insutype"`
  2721. MafPay float64 `json:"maf_pay"`
  2722. MdtrtCertType string `json:"mdtrt_cert_type"`
  2723. HifobPay float64 `json:"hifob_pay"`
  2724. MdtrtID string `json:"mdtrt_id"`
  2725. MedType string `json:"med_type"`
  2726. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2727. MedinsSetlID string `json:"medins_setl_id"`
  2728. Naty string `json:"naty"`
  2729. OthPay float64 `json:"oth_pay"`
  2730. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2731. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2732. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2733. PsnCashPay float64 `json:"psn_cash_pay"`
  2734. PsnCertType string `json:"psn_cert_type"`
  2735. PsnName string `json:"psn_name"`
  2736. PsnNo string `json:"psn_no"`
  2737. PsnPartAmt float64 `json:"psn_part_amt"`
  2738. PsnType string `json:"psn_type"`
  2739. SetlID string `json:"setl_id"`
  2740. SetlTime string `json:"setl_time"`
  2741. } `json:"setlinfo"`
  2742. } `json:"output"`
  2743. RefmsgTime string `json:"refmsg_time"`
  2744. RespondTime string `json:"respond_time"`
  2745. Signtype interface{} `json:"signtype"`
  2746. WarnMsg interface{} `json:"warn_msg"`
  2747. }
  2748. type ResultSeven10265 struct {
  2749. Cainfo string `json:"cainfo"`
  2750. ErrMsg string `json:"err_msg"`
  2751. InfRefmsgid string `json:"inf_refmsgid"`
  2752. Infcode string `json:"infcode"`
  2753. Output struct {
  2754. Setldetail []interface{} `json:"setldetail"`
  2755. Setlinfo struct {
  2756. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2757. AcctPay float64 `json:"acct_pay"`
  2758. ActPayDedc float64 `json:"act_pay_dedc"`
  2759. Age float64 `json:"age"`
  2760. Balc float64 `json:"balc"`
  2761. Brdy string `json:"brdy"`
  2762. Certno string `json:"certno"`
  2763. ClrOptins string `json:"clr_optins"`
  2764. ClrType string `json:"clr_type"`
  2765. ClrWay string `json:"clr_way"`
  2766. CvlservFlag string `json:"cvlserv_flag"`
  2767. CvlservPay float64 `json:"cvlserv_pay"`
  2768. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2769. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2770. Gend string `json:"gend"`
  2771. HifesPay float64 `json:"hifes_pay"`
  2772. HifmiPay float64 `json:"hifmi_pay"`
  2773. HifpPay float64 `json:"hifp_pay"`
  2774. HospPartAmt float64 `json:"hosp_part_amt"`
  2775. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2776. Insutype string `json:"insutype"`
  2777. MafPay float64 `json:"maf_pay"`
  2778. MdtrtCertType string `json:"mdtrt_cert_type"`
  2779. HifobPay float64 `json:"hifob_pay"`
  2780. MdtrtID string `json:"mdtrt_id"`
  2781. MedType string `json:"med_type"`
  2782. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2783. MedinsSetlID string `json:"medins_setl_id"`
  2784. Naty string `json:"naty"`
  2785. OthPay float64 `json:"oth_pay"`
  2786. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2787. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2788. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2789. PsnCashPay float64 `json:"psn_cash_pay"`
  2790. PsnCertType string `json:"psn_cert_type"`
  2791. PsnName string `json:"psn_name"`
  2792. PsnNo string `json:"psn_no"`
  2793. PsnPartAmt float64 `json:"psn_part_amt"`
  2794. PsnType string `json:"psn_type"`
  2795. SetlID string `json:"setl_id"`
  2796. SetlTime string `json:"setl_time"`
  2797. } `json:"setlinfo"`
  2798. } `json:"output"`
  2799. RefmsgTime string `json:"refmsg_time"`
  2800. RespondTime string `json:"respond_time"`
  2801. Signtype interface{} `json:"signtype"`
  2802. WarnMsg interface{} `json:"warn_msg"`
  2803. }
  2804. type ResultEight struct {
  2805. Cainfo string `json:"cainfo"`
  2806. ErrMsg string `json:"err_msg"`
  2807. InfRefmsgid string `json:"inf_refmsgid"`
  2808. Infcode int64 `json:"infcode"`
  2809. Output struct {
  2810. Stmtinfo struct {
  2811. SetlOptins string `json:"setl_optins"`
  2812. StmtRslt string `json:"stmt_rslt"`
  2813. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2814. } `json:"stmtinfo"`
  2815. } `json:"output"`
  2816. RefmsgTime string `json:"refmsg_time"`
  2817. RespondTime string `json:"respond_time"`
  2818. Signtype interface{} `json:"signtype"`
  2819. WarnMsg interface{} `json:"warn_msg"`
  2820. }
  2821. type ResultEightFor10188 struct {
  2822. Cainfo string `json:"cainfo"`
  2823. ErrMsg string `json:"err_msg"`
  2824. InfRefmsgid string `json:"inf_refmsgid"`
  2825. Infcode string `json:"infcode"`
  2826. Output struct {
  2827. Stmtinfo struct {
  2828. SetlOptins string `json:"setl_optins"`
  2829. StmtRslt string `json:"stmt_rslt"`
  2830. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2831. } `json:"stmtinfo"`
  2832. } `json:"output"`
  2833. RefmsgTime string `json:"refmsg_time"`
  2834. RespondTime string `json:"respond_time"`
  2835. Signtype interface{} `json:"signtype"`
  2836. WarnMsg interface{} `json:"warn_msg"`
  2837. }
  2838. type ResultNine struct {
  2839. Cainfo string `json:"cainfo"`
  2840. ErrMsg string `json:"err_msg"`
  2841. InfRefmsgid string `json:"inf_refmsgid"`
  2842. Infcode int64 `json:"infcode"`
  2843. Output struct {
  2844. FileQuryNo string `json:"file_qury_no"`
  2845. } `json:"output"`
  2846. RefmsgTime string `json:"refmsg_time"`
  2847. RespondTime string `json:"respond_time"`
  2848. Signtype interface{} `json:"signtype"`
  2849. WarnMsg interface{} `json:"warn_msg"`
  2850. }
  2851. type ResultTen struct {
  2852. Cainfo string `json:"cainfo"`
  2853. ErrMsg string `json:"err_msg"`
  2854. InfRefmsgid string `json:"inf_refmsgid"`
  2855. Infcode int64 `json:"infcode"`
  2856. Output struct {
  2857. DldEndtime string `json:"dld_endtime"`
  2858. FileQuryNo string `json:"file_qury_no"`
  2859. Filename string `json:"filename"`
  2860. } `json:"output"`
  2861. RefmsgTime string `json:"refmsg_time"`
  2862. RespondTime string `json:"respond_time"`
  2863. Signtype interface{} `json:"signtype"`
  2864. WarnMsg interface{} `json:"warn_msg"`
  2865. }
  2866. //type Autogenerated struct {
  2867. // Output struct {
  2868. // Setlinfo struct {
  2869. // SetlTime string `json:"setl_time"`
  2870. // CvlservPay float64 `json:"cvlserv_pay"`
  2871. // Year string `json:"year"`
  2872. // MedType string `json:"med_type"`
  2873. // PsnPay float64 `json:"psn_pay"`
  2874. // OpterID string `json:"opter_id"`
  2875. // Begndate string `json:"begndate"`
  2876. // FlxempeFlag string `json:"flxempe_flag"`
  2877. // HifmiPay float64 `json:"hifmi_pay"`
  2878. // PsnNo string `json:"psn_no"`
  2879. // ActPayDedc float64 `json:"act_pay_dedc"`
  2880. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2881. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2882. // ClrWay string `json:"clr_way"`
  2883. // OthPay float64 `json:"oth_pay"`
  2884. // Gend string `json:"gend"`
  2885. // MdtrtID string `json:"mdtrt_id"`
  2886. // AcctPay float64 `json:"acct_pay"`
  2887. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2888. // Insutype string `json:"insutype"`
  2889. // Invono interface{} `json:"invono"`
  2890. // Enddate string `json:"enddate"`
  2891. // CashPayamt float64 `json:"cash_payamt"`
  2892. // PsnType string `json:"psn_type"`
  2893. // FixmedinsName string `json:"fixmedins_name"`
  2894. // HifpPay float64 `json:"hifp_pay"`
  2895. // NewFlag interface{} `json:"new_flag"`
  2896. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2897. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2898. // PayLoc string `json:"pay_loc"`
  2899. // ClrType string `json:"clr_type"`
  2900. // RefdSetlFlag string `json:"refd_setl_flag"`
  2901. // CvlservFlag string `json:"cvlserv_flag"`
  2902. // EmpName string `json:"emp_name"`
  2903. // Brdy string `json:"brdy"`
  2904. // Naty string `json:"naty"`
  2905. // Certno string `json:"certno"`
  2906. // DiseCode string `json:"dise_code"`
  2907. // FixmedinsCode string `json:"fixmedins_code"`
  2908. // DedcHospLv string `json:"dedc_hosp_lv"`
  2909. // OpterName string `json:"opter_name"`
  2910. // Balc float64 `json:"balc"`
  2911. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2912. // PsnCertType string `json:"psn_cert_type"`
  2913. // HifobPay float64 `json:"hifob_pay"`
  2914. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2915. // HifesPay float64 `json:"hifes_pay"`
  2916. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2917. // OptTime string `json:"opt_time"`
  2918. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2919. // SetlID string `json:"setl_id"`
  2920. // MafPay float64 `json:"maf_pay"`
  2921. // PsnName string `json:"psn_name"`
  2922. // InsuOptins interface{} `json:"insu_optins"`
  2923. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2924. // ClrOptins string `json:"clr_optins"`
  2925. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2926. // DiseName string `json:"dise_name"`
  2927. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2928. // Age float64 `json:"age"`
  2929. // DtrtCertType string `json:"dtrt_cert_type"`
  2930. // HospLv string `json:"hosp_lv"`
  2931. // } `json:"setlinfo"`
  2932. // Setldetail []struct {
  2933. // FundPayType string `json:"fund_pay_type"`
  2934. // FundPayamt float64 `json:"fund_payamt"`
  2935. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2936. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2937. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2938. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2939. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2940. // } `json:"setldetail"`
  2941. // } `json:"output"`
  2942. // Infcode int `json:"infcode"`
  2943. // WarnMsg interface{} `json:"warn_msg"`
  2944. // Cainfo interface{} `json:"cainfo"`
  2945. // ErrMsg interface{} `json:"err_msg"`
  2946. // RefmsgTime string `json:"refmsg_time"`
  2947. // Signtype interface{} `json:"signtype"`
  2948. // RespondTime string `json:"respond_time"`
  2949. // InfRefmsgid string `json:"inf_refmsgid"`
  2950. //}
  2951. type ResultEleven struct {
  2952. Cainfo string `json:"cainfo"`
  2953. ErrMsg string `json:"err_msg"`
  2954. InfRefmsgid string `json:"inf_refmsgid"`
  2955. Infcode int64 `json:"infcode"`
  2956. Output struct {
  2957. Setlinfo struct {
  2958. SetlTime string `json:"setl_time"`
  2959. CvlservPay float64 `json:"cvlserv_pay"`
  2960. Year string `json:"year"`
  2961. MedType string `json:"med_type"`
  2962. PsnPay float64 `json:"psn_pay"`
  2963. OpterID string `json:"opter_id"`
  2964. Begndate string `json:"begndate"`
  2965. FlxempeFlag string `json:"flxempe_flag"`
  2966. HifmiPay float64 `json:"hifmi_pay"`
  2967. PsnNo string `json:"psn_no"`
  2968. ActPayDedc float64 `json:"act_pay_dedc"`
  2969. MedinsSetlID interface{} `json:"medins_setl_id"`
  2970. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2971. ClrWay string `json:"clr_way"`
  2972. OthPay float64 `json:"oth_pay"`
  2973. Gend string `json:"gend"`
  2974. MdtrtID string `json:"mdtrt_id"`
  2975. AcctPay float64 `json:"acct_pay"`
  2976. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2977. Insutype string `json:"insutype"`
  2978. Invono interface{} `json:"invono"`
  2979. Enddate string `json:"enddate"`
  2980. CashPayamt float64 `json:"cash_payamt"`
  2981. PsnType string `json:"psn_type"`
  2982. FixmedinsName string `json:"fixmedins_name"`
  2983. HifpPay float64 `json:"hifp_pay"`
  2984. NewFlag interface{} `json:"new_flag"`
  2985. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2986. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2987. PayLoc string `json:"pay_loc"`
  2988. ClrType string `json:"clr_type"`
  2989. RefdSetlFlag string `json:"refd_setl_flag"`
  2990. CvlservFlag string `json:"cvlserv_flag"`
  2991. EmpName string `json:"emp_name"`
  2992. Brdy string `json:"brdy"`
  2993. Naty string `json:"naty"`
  2994. Certno string `json:"certno"`
  2995. DiseCode string `json:"dise_code"`
  2996. FixmedinsCode string `json:"fixmedins_code"`
  2997. DedcHospLv string `json:"dedc_hosp_lv"`
  2998. OpterName string `json:"opter_name"`
  2999. Balc float64 `json:"balc"`
  3000. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3001. PsnCertType string `json:"psn_cert_type"`
  3002. HifobPay float64 `json:"hifob_pay"`
  3003. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3004. HifesPay float64 `json:"hifes_pay"`
  3005. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3006. OptTime string `json:"opt_time"`
  3007. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3008. SetlID string `json:"setl_id"`
  3009. MafPay float64 `json:"maf_pay"`
  3010. PsnName string `json:"psn_name"`
  3011. InsuOptins interface{} `json:"insu_optins"`
  3012. PrefFundPay interface{} `json:"pref_fund_pay"`
  3013. ClrOptins string `json:"clr_optins"`
  3014. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3015. DiseName string `json:"dise_name"`
  3016. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3017. Age float64 `json:"age"`
  3018. DtrtCertType string `json:"dtrt_cert_type"`
  3019. HospLv string `json:"hosp_lv"`
  3020. } `json:"setlinfo"`
  3021. } `json:"output"`
  3022. RefmsgTime string `json:"refmsg_time"`
  3023. RespondTime string `json:"respond_time"`
  3024. Signtype interface{} `json:"signtype"`
  3025. WarnMsg interface{} `json:"warn_msg"`
  3026. }
  3027. type ResultEleven10265 struct {
  3028. Cainfo string `json:"cainfo"`
  3029. ErrMsg string `json:"err_msg"`
  3030. InfRefmsgid string `json:"inf_refmsgid"`
  3031. Infcode string `json:"infcode"`
  3032. Output struct {
  3033. Setlinfo struct {
  3034. SetlTime string `json:"setl_time"`
  3035. CvlservPay float64 `json:"cvlserv_pay"`
  3036. Year string `json:"year"`
  3037. MedType string `json:"med_type"`
  3038. PsnPay float64 `json:"psn_pay"`
  3039. OpterID string `json:"opter_id"`
  3040. Begndate string `json:"begndate"`
  3041. FlxempeFlag string `json:"flxempe_flag"`
  3042. HifmiPay float64 `json:"hifmi_pay"`
  3043. PsnNo string `json:"psn_no"`
  3044. ActPayDedc float64 `json:"act_pay_dedc"`
  3045. MedinsSetlID interface{} `json:"medins_setl_id"`
  3046. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3047. ClrWay string `json:"clr_way"`
  3048. OthPay float64 `json:"oth_pay"`
  3049. Gend string `json:"gend"`
  3050. MdtrtID string `json:"mdtrt_id"`
  3051. AcctPay float64 `json:"acct_pay"`
  3052. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3053. Insutype string `json:"insutype"`
  3054. Invono interface{} `json:"invono"`
  3055. Enddate string `json:"enddate"`
  3056. CashPayamt float64 `json:"cash_payamt"`
  3057. PsnType string `json:"psn_type"`
  3058. FixmedinsName string `json:"fixmedins_name"`
  3059. HifpPay float64 `json:"hifp_pay"`
  3060. NewFlag interface{} `json:"new_flag"`
  3061. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3062. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3063. PayLoc string `json:"pay_loc"`
  3064. ClrType string `json:"clr_type"`
  3065. RefdSetlFlag string `json:"refd_setl_flag"`
  3066. CvlservFlag string `json:"cvlserv_flag"`
  3067. EmpName string `json:"emp_name"`
  3068. Brdy string `json:"brdy"`
  3069. Naty string `json:"naty"`
  3070. Certno string `json:"certno"`
  3071. DiseCode string `json:"dise_code"`
  3072. FixmedinsCode string `json:"fixmedins_code"`
  3073. DedcHospLv string `json:"dedc_hosp_lv"`
  3074. OpterName string `json:"opter_name"`
  3075. Balc float64 `json:"balc"`
  3076. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3077. PsnCertType string `json:"psn_cert_type"`
  3078. HifobPay float64 `json:"hifob_pay"`
  3079. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3080. HifesPay float64 `json:"hifes_pay"`
  3081. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3082. OptTime string `json:"opt_time"`
  3083. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3084. SetlID string `json:"setl_id"`
  3085. MafPay float64 `json:"maf_pay"`
  3086. PsnName string `json:"psn_name"`
  3087. InsuOptins interface{} `json:"insu_optins"`
  3088. PrefFundPay interface{} `json:"pref_fund_pay"`
  3089. ClrOptins string `json:"clr_optins"`
  3090. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3091. DiseName string `json:"dise_name"`
  3092. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3093. Age float64 `json:"age"`
  3094. DtrtCertType string `json:"dtrt_cert_type"`
  3095. HospLv string `json:"hosp_lv"`
  3096. } `json:"setlinfo"`
  3097. } `json:"output"`
  3098. RefmsgTime string `json:"refmsg_time"`
  3099. RespondTime string `json:"respond_time"`
  3100. Signtype interface{} `json:"signtype"`
  3101. WarnMsg interface{} `json:"warn_msg"`
  3102. }
  3103. type ResultTwelve struct {
  3104. Cainfo string `json:"cainfo"`
  3105. ErrMsg string `json:"err_msg"`
  3106. InfRefmsgid string `json:"inf_refmsgid"`
  3107. Infcode int64 `json:"infcode"`
  3108. Output struct {
  3109. MdtrtId string `json:"mdtrt_id"`
  3110. ChrgBchno string `json:"chrg_bchno"`
  3111. PsnNo string `json:"psn_no"`
  3112. } `json:"output"`
  3113. RefmsgTime string `json:"refmsg_time"`
  3114. RespondTime string `json:"respond_time"`
  3115. Signtype interface{} `json:"signtype"`
  3116. WarnMsg interface{} `json:"warn_msg"`
  3117. }
  3118. type ResultThirteen struct {
  3119. ErrMsg string `json:"err_msg"`
  3120. InfRefmsgid string `json:"inf_refmsgid"`
  3121. Infcode int64 `json:"infcode"`
  3122. Output struct {
  3123. Result struct {
  3124. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3125. } `json:"result"`
  3126. } `json:"output"`
  3127. RefmsgTime string `json:"refmsg_time"`
  3128. RespondTime string `json:"respond_time"`
  3129. Signtype interface{} `json:"signtype"`
  3130. WarnInfo interface{} `json:"warn_info"`
  3131. }
  3132. type ResultThirteen10265 struct {
  3133. ErrMsg string `json:"err_msg"`
  3134. InfRefmsgid string `json:"inf_refmsgid"`
  3135. Infcode string `json:"infcode"`
  3136. Output struct {
  3137. Result struct {
  3138. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3139. } `json:"result"`
  3140. } `json:"output"`
  3141. RefmsgTime string `json:"refmsg_time"`
  3142. RespondTime string `json:"respond_time"`
  3143. Signtype interface{} `json:"signtype"`
  3144. WarnInfo interface{} `json:"warn_info"`
  3145. }
  3146. type ResultFourteen struct {
  3147. ErrMsg string `json:"err_msg"`
  3148. InfRefmsgid string `json:"inf_refmsgid"`
  3149. Infcode int64 `json:"infcode"`
  3150. Output struct {
  3151. } `json:"output"`
  3152. RefmsgTime string `json:"refmsg_time"`
  3153. RespondTime string `json:"respond_time"`
  3154. Signtype interface{} `json:"signtype"`
  3155. WarnInfo interface{} `json:"warn_info"`
  3156. }
  3157. type ResultFourteen10265 struct {
  3158. ErrMsg string `json:"err_msg"`
  3159. InfRefmsgid string `json:"inf_refmsgid"`
  3160. Infcode string `json:"infcode"`
  3161. Output struct {
  3162. } `json:"output"`
  3163. RefmsgTime string `json:"refmsg_time"`
  3164. RespondTime string `json:"respond_time"`
  3165. Signtype interface{} `json:"signtype"`
  3166. WarnInfo interface{} `json:"warn_info"`
  3167. }
  3168. type ResultSixteen struct {
  3169. Cainfo string `json:"cainfo"`
  3170. ErrMsg string `json:"err_msg"`
  3171. InfRefmsgid string `json:"inf_refmsgid"`
  3172. Infcode int64 `json:"infcode"`
  3173. Output struct {
  3174. Setldetail []interface{} `json:"setldetail"`
  3175. Setlinfo struct {
  3176. MdtrtID string `json:"mdtrt_id"`
  3177. SetlID string `json:"setl_id"`
  3178. ClrOptins string `json:"clr_optins"`
  3179. SetlTime string `json:"setl_time"`
  3180. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3181. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3182. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3183. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3184. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3185. ActPayDedc float64 `json:"act_pay_dedc"`
  3186. HifpPay float64 `json:"hifp_pay"`
  3187. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3188. Lfpay float64 `json:"selfpay"`
  3189. CvlservPay float64 `json:"cvlserv_pay"`
  3190. HifesPay float64 `json:"hifes_pay"`
  3191. HifmiPay float64 `json:"hifmi_pay"`
  3192. HifobPay float64 `json:"hifob_pay"`
  3193. MafPay float64 `json:"maf_pay"`
  3194. OthPay float64 `json:"oth_pay"`
  3195. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3196. PsnPartAmt float64 `json:"psn_part_amt"`
  3197. AcctPay float64 `json:"acct_pay"`
  3198. Balc float64 `json:"balc"`
  3199. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3200. HospPartAmt float64 `json:"hosp_part_amt"`
  3201. MedinsSetlID string `json:"medins_setl_id"`
  3202. PdnCashPay string `json:"pdn_cash_pay"`
  3203. } `json:"setlinfo"`
  3204. } `json:"output"`
  3205. RefmsgTime string `json:"refmsg_time"`
  3206. RespondTime string `json:"respond_time"`
  3207. Signtype interface{} `json:"signtype"`
  3208. WarnMsg interface{} `json:"warn_msg"`
  3209. }
  3210. type ResultSixteen10265 struct {
  3211. Cainfo string `json:"cainfo"`
  3212. ErrMsg string `json:"err_msg"`
  3213. InfRefmsgid string `json:"inf_refmsgid"`
  3214. Infcode string `json:"infcode"`
  3215. Output struct {
  3216. Setldetail []interface{} `json:"setldetail"`
  3217. Setlinfo struct {
  3218. MdtrtID string `json:"mdtrt_id"`
  3219. SetlID string `json:"setl_id"`
  3220. ClrOptins string `json:"clr_optins"`
  3221. SetlTime string `json:"setl_time"`
  3222. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3223. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3224. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3225. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3226. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3227. ActPayDedc float64 `json:"act_pay_dedc"`
  3228. HifpPay float64 `json:"hifp_pay"`
  3229. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3230. Lfpay float64 `json:"selfpay"`
  3231. CvlservPay float64 `json:"cvlserv_pay"`
  3232. HifesPay float64 `json:"hifes_pay"`
  3233. HifmiPay float64 `json:"hifmi_pay"`
  3234. HifobPay float64 `json:"hifob_pay"`
  3235. MafPay float64 `json:"maf_pay"`
  3236. OthPay float64 `json:"oth_pay"`
  3237. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3238. PsnPartAmt float64 `json:"psn_part_amt"`
  3239. AcctPay float64 `json:"acct_pay"`
  3240. Balc float64 `json:"balc"`
  3241. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3242. HospPartAmt float64 `json:"hosp_part_amt"`
  3243. MedinsSetlID string `json:"medins_setl_id"`
  3244. PdnCashPay string `json:"pdn_cash_pay"`
  3245. } `json:"setlinfo"`
  3246. } `json:"output"`
  3247. RefmsgTime string `json:"refmsg_time"`
  3248. RespondTime string `json:"respond_time"`
  3249. Signtype interface{} `json:"signtype"`
  3250. WarnMsg interface{} `json:"warn_msg"`
  3251. }
  3252. type ResultSeventeen struct {
  3253. ErrMsg string `json:"err_msg"`
  3254. InfRefmsgid string `json:"inf_refmsgid"`
  3255. Infcode int64 `json:"infcode"`
  3256. Output struct {
  3257. SetlListId string `json:"setl_list_id"`
  3258. } `json:"output"`
  3259. RefmsgTime string `json:"refmsg_time"`
  3260. RespondTime string `json:"respond_time"`
  3261. Signtype string `json:"signtype"`
  3262. WarnInfo string `json:"warn_info"`
  3263. }
  3264. type Result90991 struct {
  3265. ErrMsg string `json:"err_msg"`
  3266. InfRefmsgid string `json:"inf_refmsgid"`
  3267. Infcode int64 `json:"infcode"`
  3268. Output struct {
  3269. Result struct {
  3270. PsnNo string `json:"psn_no"`
  3271. CardStat string `json:"card_stat"`
  3272. Certno string `json:"certno"`
  3273. PsnName string `json:"psn_name"`
  3274. CheckStat string `json:"check_stat"`
  3275. } `json:"result"`
  3276. } `json:"output"`
  3277. RefmsgTime string `json:"refmsg_time"`
  3278. RespondTime string `json:"respond_time"`
  3279. Signtype interface{} `json:"signtype"`
  3280. WarnInfo interface{} `json:"warn_info"`
  3281. }
  3282. type Result90100 struct {
  3283. ErrMsg string `json:"err_msg"`
  3284. InfRefmsgid string `json:"inf_refmsgid"`
  3285. Infcode int64 `json:"infcode"`
  3286. Output struct {
  3287. PoolareaNo string `json:"poolarea_no"`
  3288. PoolareaNoName string `json:"poolarea_no_name"`
  3289. Insutype string `json:"insutype"`
  3290. InsutypeName string `json:"insutype_name"`
  3291. ClctType string `json:"clct_type"`
  3292. ClctTypeName string `json:"clct_type_name"`
  3293. ClctFlag string `json:"clct_flag"`
  3294. ClctFlagName string `json:"clct_flag_name"`
  3295. AccrymBegn string `json:"accrym_begn"`
  3296. AccrymEnd string `json:"accrym_end"`
  3297. ClctTime string `json:"clct_time"`
  3298. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3299. } `json:"output"`
  3300. RefmsgTime string `json:"refmsg_time"`
  3301. RespondTime string `json:"respond_time"`
  3302. Signtype interface{} `json:"signtype"`
  3303. WarnInfo interface{} `json:"warn_info"`
  3304. }
  3305. type Custom struct {
  3306. DetItemFeeSumamt string
  3307. Cut string
  3308. FeedetlSn string
  3309. Price string
  3310. MedListCodg string
  3311. Type int64
  3312. AdviceId int64
  3313. ProjectId int64
  3314. ItemId int64
  3315. }
  3316. type Result5301 struct {
  3317. ErrMsg string `json:"err_msg"`
  3318. InfRefmsgid string `json:"inf_refmsgid"`
  3319. Infcode int64 `json:"infcode"`
  3320. Output struct {
  3321. Result []struct {
  3322. OpspDiseCode string `json:"opsp_dise_code"`
  3323. OpspDiseName string `json:"opsp_dise_name"`
  3324. Begndate string `json:"begndate"`
  3325. Enddate string `json:"enddate"`
  3326. } `json:"feedetail"`
  3327. } `json:"output"`
  3328. RefmsgTime string `json:"refmsg_time"`
  3329. RespondTime string `json:"respond_time"`
  3330. Signtype interface{} `json:"signtype"`
  3331. WarnInfo interface{} `json:"warn_info"`
  3332. }
  3333. type Result5301For10265 struct {
  3334. ErrMsg string `json:"err_msg"`
  3335. InfRefmsgid string `json:"inf_refmsgid"`
  3336. Infcode string `json:"infcode"`
  3337. Output struct {
  3338. Result []struct {
  3339. OpspDiseCode string `json:"opsp_dise_code"`
  3340. OpspDiseName string `json:"opsp_dise_name"`
  3341. Begndate string `json:"begndate"`
  3342. Enddate string `json:"enddate"`
  3343. } `json:"feedetail"`
  3344. } `json:"output"`
  3345. RefmsgTime string `json:"refmsg_time"`
  3346. RespondTime string `json:"respond_time"`
  3347. Signtype interface{} `json:"signtype"`
  3348. WarnInfo interface{} `json:"warn_info"`
  3349. }
  3350. //获取个人信息----挂号-----上传就诊信息
  3351. func (c *HisApiController) GetRegisterInfo() {
  3352. id, _ := c.GetInt64("id")
  3353. record_time := c.GetString("record_time")
  3354. settlementValue, _ := c.GetInt64("settlement_value")
  3355. medical_insurance_card := c.GetString("medical_insurance_card")
  3356. name := c.GetString("name")
  3357. id_card_type, _ := c.GetInt64("id_card_type")
  3358. certificates, _ := c.GetInt64("certificates")
  3359. medical_care, _ := c.GetInt64("medical_care")
  3360. birthday := c.GetString("birthday")
  3361. id_card := c.GetString("id_card")
  3362. register_type, _ := c.GetInt64("register")
  3363. doctor, _ := c.GetInt64("doctor")
  3364. department, _ := c.GetInt64("department")
  3365. gender, _ := c.GetInt64("sex")
  3366. registration_fee, _ := c.GetFloat("registration_fee")
  3367. medical_expenses, _ := c.GetFloat("medical_expenses")
  3368. social_type, _ := c.GetInt64("social_type")
  3369. med_type := c.GetString("social_type")
  3370. admin_user_id, _ := c.GetInt64("admin_user_id")
  3371. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3372. timeLayout := "2006-01-02"
  3373. loc, _ := time.LoadLocation("Local")
  3374. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3375. birthUnix := birthdays.Unix()
  3376. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3377. if err != nil {
  3378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3379. return
  3380. }
  3381. recordDateTime := theTime.Unix()
  3382. adminInfo := c.GetAdminUserInfo()
  3383. var patient service.Patients
  3384. if id == 0 {
  3385. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3386. } else {
  3387. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3388. }
  3389. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3390. if patientPrescription.ID == 0 {
  3391. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3392. }
  3393. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3394. if patient.ID == 0 {
  3395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3396. return
  3397. }
  3398. if len(patient.IdCardNo) == 0 {
  3399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3400. return
  3401. }
  3402. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3403. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3404. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3405. //就诊结算未完成,不能进行二次挂号
  3406. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3407. if len(his) >= 1 {
  3408. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3409. if len(his) >= 1 && order.ID == 0 {
  3410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3411. return
  3412. }
  3413. }
  3414. //var register_log string
  3415. if config.IsOpen == 1 {
  3416. var res ResultTwo
  3417. var res10265 ResultTwo10265
  3418. var PsnNo string
  3419. var PsnCertType string
  3420. var Certno string
  3421. var PsnName string
  3422. var Gend string
  3423. var Naty string
  3424. var Brdy string
  3425. var Age float64
  3426. var infoStr string
  3427. var idetinfoStr string
  3428. var infocode int64
  3429. var verify_number string
  3430. fmt.Println(verify_number)
  3431. if miConfig.MdtrtareaAdmvs == "421300" {
  3432. psn_info, _ := service.GetPsnByPatientId(id)
  3433. PsnNo = psn_info.PsnNo
  3434. PsnCertType = psn_info.PsnCertType
  3435. Certno = psn_info.Certno
  3436. PsnName = psn_info.PsnName
  3437. Gend = psn_info.Gend
  3438. Naty = psn_info.Naty
  3439. Brdy = psn_info.Brdy
  3440. Age = psn_info.Age
  3441. infoStr = psn_info.Insuinfo
  3442. idetinfoStr = psn_info.Idetinfo
  3443. infocode = 0
  3444. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3445. psn_info, _ := service.GetPsnByPatientId(id)
  3446. PsnNo = psn_info.PsnNo
  3447. PsnCertType = psn_info.PsnCertType
  3448. Certno = psn_info.Certno
  3449. PsnName = psn_info.PsnName
  3450. Gend = psn_info.Gend
  3451. Naty = psn_info.Naty
  3452. Brdy = psn_info.Brdy
  3453. Age = psn_info.Age
  3454. infoStr = psn_info.Insuinfo
  3455. idetinfoStr = psn_info.Idetinfo
  3456. infocode = 0
  3457. verify_number = psn_info.VerifyNumber
  3458. } else {
  3459. var result string
  3460. var requestLog string
  3461. if miConfig.UserOrgId == 10138 {
  3462. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  3463. } else {
  3464. 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)
  3465. }
  3466. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3467. if miConfig.Code == "H15049901371" {
  3468. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3469. utils.ErrorLog("解析失败:%v", err)
  3470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3471. return
  3472. }
  3473. res.ErrMsg = res10265.ErrMsg
  3474. res.Output = res10265.Output
  3475. res.InfRefmsgid = res10265.InfRefmsgid
  3476. } else {
  3477. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3478. utils.ErrorLog("解析失败:%v", err)
  3479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3480. return
  3481. }
  3482. }
  3483. PsnNo = res.Output.Baseinfo.PsnNo
  3484. PsnCertType = res.Output.Baseinfo.PsnCertType
  3485. Certno = res.Output.Baseinfo.Certno
  3486. PsnName = res.Output.Baseinfo.PsnName
  3487. Gend = res.Output.Baseinfo.Gend
  3488. Naty = res.Output.Baseinfo.Naty
  3489. Brdy = res.Output.Baseinfo.Brdy
  3490. Age = res.Output.Baseinfo.Age
  3491. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3492. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3493. infoStr = string(Iinfos)
  3494. idetinfoStr = string(Idetinfos)
  3495. if miConfig.Code == "H15049901371" {
  3496. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3497. } else {
  3498. infocode = res.Infcode
  3499. }
  3500. }
  3501. if infocode == 0 {
  3502. his := models.VMHisPatient{
  3503. Name: name,
  3504. Gender: gender,
  3505. Birthday: birthUnix,
  3506. MedicalTreatmentType: medical_care,
  3507. IdType: certificates,
  3508. IdCardNo: id_card,
  3509. BalanceAccountsType: settlementValue,
  3510. SocialType: social_type,
  3511. MedicalInsuranceNumber: medical_insurance_card,
  3512. RegisterType: register_type,
  3513. RegisterCost: registration_fee,
  3514. TreatmentCost: medical_expenses,
  3515. Status: 1,
  3516. Ctime: time.Now().Unix(),
  3517. Mtime: time.Now().Unix(),
  3518. PsnNo: PsnNo,
  3519. PsnCertType: PsnCertType,
  3520. Certno: Certno,
  3521. PsnName: PsnName,
  3522. Gend: Gend,
  3523. Naty: Naty,
  3524. Brdy: Brdy,
  3525. Age: Age,
  3526. Iinfo: infoStr,
  3527. Idetinfo: idetinfoStr,
  3528. PatientId: patient.ID,
  3529. RecordDate: theTime.Unix(),
  3530. UserOrgId: adminInfo.CurrentOrgId,
  3531. AdminUserId: admin_user_id,
  3532. IsReturn: 1,
  3533. IdCardType: id_card_type,
  3534. Doctor: doctor,
  3535. Departments: department,
  3536. }
  3537. timestamp := time.Now().Unix()
  3538. tempTime := time.Unix(timestamp, 0)
  3539. timeFormat := tempTime.Format("20060102150405")
  3540. chrgBchno := rand.Intn(100000) + 10000
  3541. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3542. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3543. department, _ := service.GetDepartMentDetail(department)
  3544. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3545. IdCardNo := ""
  3546. if id_card_type == 1 {
  3547. // IdCardNo = medical_insurance_card
  3548. IdCardNo = patient.IdCardNo
  3549. } else {
  3550. IdCardNo = patient.IdCardNo
  3551. }
  3552. var rf []*ResultFive
  3553. json.Unmarshal([]byte(his.Iinfo), &rf)
  3554. var insutypes []*ResultFive
  3555. var insutype string
  3556. var insuplc_admdvs_temp string
  3557. var is390 int = 0
  3558. var is310 int = 0
  3559. for _, item := range rf {
  3560. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3561. insutypes = append(insutypes, item)
  3562. }
  3563. }
  3564. if len(insutypes) == 1 {
  3565. insutype = insutypes[0].Insutype
  3566. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3567. } else {
  3568. for _, i := range insutypes {
  3569. if i.Insutype == "390" {
  3570. is390 = 1
  3571. }
  3572. if i.Insutype == "310" {
  3573. is310 = 1
  3574. }
  3575. }
  3576. }
  3577. if is390 == 1 {
  3578. insutype = "390"
  3579. }
  3580. if is310 == 1 {
  3581. insutype = "310"
  3582. }
  3583. if len(insutypes) == 0 {
  3584. insutype = "310"
  3585. }
  3586. if len(insutypes) == 2 {
  3587. insutype = med_type
  3588. }
  3589. if len(med_type) > 0 {
  3590. insutype = med_type
  3591. }
  3592. //for _, item := range rf {
  3593. // if item.Insutype == insutype {
  3594. // insuplc_admdvs = item.InsuplcAdmdvs
  3595. // }
  3596. //}
  3597. var infocode int64
  3598. var resThree ResultThree
  3599. var resThree10265 ResultThree10265
  3600. if len(insuplc_admdvs) == 0 {
  3601. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3602. } else {
  3603. insuplc_admdvs_temp = insuplc_admdvs
  3604. }
  3605. if miConfig.MdtrtareaAdmvs == "421300" {
  3606. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3607. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3608. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&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
  3609. resp, requestErr := http.Get(api)
  3610. if requestErr != nil {
  3611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3612. return
  3613. }
  3614. body, ioErr := ioutil.ReadAll(resp.Body)
  3615. if ioErr != nil {
  3616. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3618. return
  3619. }
  3620. var respJSON map[string]interface{}
  3621. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3622. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3624. return
  3625. }
  3626. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3627. result, _ := json.Marshal(respJSON)
  3628. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3629. utils.ErrorLog("解析失败:%v", err)
  3630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3631. return
  3632. }
  3633. infocode = resThree.Infcode
  3634. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3635. psn_info, _ := service.GetPsnByPatientId(id)
  3636. bas := strings.Split(psn_info.CardInfo, "|")
  3637. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3638. var api string
  3639. if miConfig.MdtrtareaAdmvs == "320921" {
  3640. api = "http://192.168.3.111:9532/" + "jsyb/1101D?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3641. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3642. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&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.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3643. resp, requestErr := http.Get(api)
  3644. if requestErr != nil {
  3645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3646. return
  3647. }
  3648. body, ioErr := ioutil.ReadAll(resp.Body)
  3649. if ioErr != nil {
  3650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3652. return
  3653. }
  3654. fmt.Println(body)
  3655. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3656. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3657. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&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.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3658. } else {
  3659. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3660. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3661. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&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.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3662. }
  3663. resp, requestErr := http.Get(api)
  3664. if requestErr != nil {
  3665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3666. return
  3667. }
  3668. body, ioErr := ioutil.ReadAll(resp.Body)
  3669. if ioErr != nil {
  3670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3672. return
  3673. }
  3674. var respJSON map[string]interface{}
  3675. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3678. return
  3679. }
  3680. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3681. result, _ := json.Marshal(respJSON)
  3682. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3683. utils.ErrorLog("解析失败:%v", err)
  3684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3685. return
  3686. }
  3687. resThree.ErrMsg = resThree10265.ErrMsg
  3688. resThree.Output = resThree10265.Output
  3689. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3690. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3691. } else {
  3692. 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, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  3693. saveLog(result, requestLog, "2201", "挂号")
  3694. if miConfig.Code == "H15049901371" {
  3695. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3696. utils.ErrorLog("解析失败:%v", err)
  3697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3698. return
  3699. }
  3700. resThree.ErrMsg = resThree10265.ErrMsg
  3701. resThree.Output = resThree10265.Output
  3702. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3703. } else {
  3704. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3705. utils.ErrorLog("解析失败:%v", err)
  3706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3707. return
  3708. }
  3709. }
  3710. if miConfig.Code == "H15049901371" {
  3711. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3712. } else {
  3713. infocode = resThree.Infcode
  3714. }
  3715. }
  3716. if infocode != 0 {
  3717. adminUser := c.GetAdminUserInfo()
  3718. errlog := &models.HisOrderError{
  3719. UserOrgId: adminUser.CurrentOrgId,
  3720. Ctime: time.Now().Unix(),
  3721. Mtime: time.Now().Unix(),
  3722. ErrMsg: resThree.ErrMsg,
  3723. Status: 1,
  3724. PatientId: id,
  3725. RecordTime: recordDateTime,
  3726. Stage: 2,
  3727. }
  3728. service.CreateErrMsgLog(errlog)
  3729. c.ServeSuccessJSON(map[string]interface{}{
  3730. "failed_code": -10,
  3731. "msg": resThree.ErrMsg,
  3732. })
  3733. return
  3734. }
  3735. his.Number = resThree.Output.Data.MdtrtID
  3736. his.PsnNo = resThree.Output.Data.PsnNo
  3737. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3738. his.IdCardNo = patient.IdCardNo
  3739. his.PhoneNumber = patient.Phone
  3740. his.UserOrgId = adminInfo.CurrentOrgId
  3741. his.Insutype = insutype
  3742. his.Ctime = time.Now().Unix()
  3743. his.Mtime = time.Now().Unix()
  3744. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3745. his.Status = 1
  3746. service.UpdateHisPatientStatus(&his)
  3747. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3748. c.ServeSuccessJSON(map[string]interface{}{
  3749. "his_info": his,
  3750. })
  3751. } else {
  3752. adminUser := c.GetAdminUserInfo()
  3753. errlog := &models.HisOrderError{
  3754. UserOrgId: adminUser.CurrentOrgId,
  3755. Ctime: time.Now().Unix(),
  3756. Mtime: time.Now().Unix(),
  3757. ErrMsg: res.ErrMsg,
  3758. Status: 1,
  3759. PatientId: id,
  3760. RecordTime: recordDateTime,
  3761. Stage: 1,
  3762. }
  3763. service.CreateErrMsgLog(errlog)
  3764. c.ServeSuccessJSON(map[string]interface{}{
  3765. "failed_code": -10,
  3766. "msg": res.ErrMsg,
  3767. })
  3768. return
  3769. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3770. }
  3771. }
  3772. }
  3773. //上传明细----预结算----确认订单
  3774. func (c *HisApiController) GetUploadInfo() {
  3775. id, _ := c.GetInt64("id")
  3776. record_time := c.GetString("record_time")
  3777. his_patient_id, _ := c.GetInt64("his_patient_id")
  3778. order_id, _ := c.GetInt64("order_id")
  3779. pay_way, _ := c.GetInt64("pay_way")
  3780. pay_price, _ := c.GetFloat("pay_price")
  3781. pay_card_no := c.GetString("pay_card_no")
  3782. discount_price, _ := c.GetFloat("discount_price")
  3783. preferential_price, _ := c.GetFloat("preferential_price")
  3784. reality_price, _ := c.GetFloat("reality_price")
  3785. found_price, _ := c.GetFloat("found_price")
  3786. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3787. private_price, _ := c.GetFloat("private_price")
  3788. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3789. admin_user_id, _ := c.GetInt64("admin_user_id")
  3790. fapiao_code := c.GetString("fapiao_code")
  3791. fapiao_number := c.GetString("fapiao_number")
  3792. diagnosis_id := c.GetString("diagnosis")
  3793. sick_type, _ := c.GetInt64("sick_type")
  3794. reg_type, _ := c.GetInt64("p_type")
  3795. begin_time := c.GetString("begin_time")
  3796. id_str := c.GetString("ids")
  3797. ids_arr := strings.Split(id_str, ",")
  3798. timeLayout := "2006-01-02"
  3799. loc, _ := time.LoadLocation("Local")
  3800. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3801. if err != nil {
  3802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3803. return
  3804. }
  3805. recordDateTime := theTime.Unix()
  3806. adminUser := c.GetAdminUserInfo()
  3807. var tempOrder models.HisOrder
  3808. tempOrder, _ = service.GetHisOrderByID(order_id)
  3809. var prescriptions []*models.HisPrescription
  3810. var start_time int64
  3811. var end_time int64
  3812. //if adminUser.CurrentOrgId == 10106{
  3813. // if len(fapiao_code) == 0{
  3814. // fapiao_code = "144072080589"
  3815. // }
  3816. // if len(fapiao_number) == 0{
  3817. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3818. // if order.ID == 0{
  3819. // fapiao_number = "00001520"
  3820. // }else{
  3821. // //fapiao_code = "00001520"
  3822. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3823. // var zero string
  3824. // if fpNumber >= 1000{
  3825. // zero = "0000" + strconv.Itoa(fpNumber)
  3826. // }else if fpNumber >= 10000{
  3827. // zero = "000" + strconv.Itoa(fpNumber)
  3828. // } else if fpNumber >= 100000{
  3829. // zero = "00" + strconv.Itoa(fpNumber)
  3830. // } else if fpNumber >= 1000000{
  3831. // zero = "0" + strconv.Itoa(fpNumber)
  3832. // }else {
  3833. // zero = strconv.Itoa(fpNumber)
  3834. // }
  3835. // fapiao_number = zero
  3836. // }
  3837. // }
  3838. //}
  3839. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3840. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3841. var patientPrescription models.HisPrescriptionInfo
  3842. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3843. if patientPrescription.ID == 0 {
  3844. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3845. }
  3846. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3847. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3848. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3849. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3850. var config []*models.HisXtDiagnoseConfig
  3851. for _, item := range diagnosis_ids {
  3852. id, _ := strconv.ParseInt(item, 10, 64)
  3853. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3854. config = append(config, &diagnosisConfig)
  3855. }
  3856. sickConfig, _ := service.FindSickById(sick_type)
  3857. //if tempOrder.ID == 0 {
  3858. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3859. //}
  3860. if tempOrder.ID == 0 {
  3861. var result string
  3862. var requestLog string
  3863. var res2 ResultSix
  3864. var ressix10265 ResultSix10265
  3865. if miConfig.MdtrtareaAdmvs == "421300" {
  3866. data := make(map[string]interface{})
  3867. client := &http.Client{}
  3868. data["psn_no"] = his.PsnNo
  3869. data["mdtrt_id"] = his.Number
  3870. data["doctor"] = roles.UserName
  3871. data["department"] = department.Name
  3872. data["org_name"] = miConfig.OrgName
  3873. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3874. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3875. data["fixmedins_code"] = miConfig.Code
  3876. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3877. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3878. data["secret_key"] = miConfig.SecretKey
  3879. data["sick_code"] = sickConfig.CountryCode
  3880. data["sick_name"] = sickConfig.ClassName
  3881. data["dept"] = strconv.FormatInt(department.ID, 10)
  3882. data["config"] = config
  3883. data["begin_time"] = begin_time
  3884. bytesData, _ := json.Marshal(data)
  3885. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3886. resp, _ := client.Do(req)
  3887. defer resp.Body.Close()
  3888. body, ioErr := ioutil.ReadAll(resp.Body)
  3889. if ioErr != nil {
  3890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3892. return
  3893. }
  3894. var respJSON map[string]interface{}
  3895. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3898. return
  3899. }
  3900. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3901. userJSONBytes, _ := json.Marshal(respJSON)
  3902. fmt.Println("log")
  3903. fmt.Println(string(userJSONBytes))
  3904. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3905. utils.ErrorLog("解析失败:%v", err)
  3906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3907. return
  3908. }
  3909. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3910. //江苏地区国家医保医疗类别
  3911. //职工透析:医疗类别选特殊情况门诊9933
  3912. //居民血透门慢: 医疗类别选门诊慢病1402
  3913. //var med_type string
  3914. //if his.Insutype == "310" {
  3915. // if reg_type == 14 {
  3916. // med_type = "9933"
  3917. // } else if reg_type == 11 {
  3918. // med_type = "11"
  3919. //
  3920. // }
  3921. //} else if his.Insutype == "390" {
  3922. // if reg_type == 14 {
  3923. // med_type = "1402"
  3924. // } else if reg_type == 11 {
  3925. // med_type = "11"
  3926. // }
  3927. //}
  3928. data := make(map[string]interface{})
  3929. client := &http.Client{}
  3930. data["psn_no"] = his.PsnNo
  3931. data["mdtrt_id"] = his.Number
  3932. data["doctor"] = roles.UserName
  3933. data["department"] = department.Name
  3934. data["org_name"] = miConfig.OrgName
  3935. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3936. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3937. data["fixmedins_code"] = miConfig.Code
  3938. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3939. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3940. data["secret_key"] = miConfig.SecretKey
  3941. data["sick_code"] = sickConfig.CountryCode
  3942. data["sick_name"] = sickConfig.ClassName
  3943. data["url"] = miConfig.Url
  3944. data["ak"] = miConfig.AccessKey
  3945. data["begin_time"] = begin_time
  3946. data["cainfo"] = miConfig.Cainfo
  3947. data["dept"] = strconv.FormatInt(department.ID, 10)
  3948. data["config"] = config
  3949. bytesData, _ := json.Marshal(data)
  3950. var req *http.Request
  3951. if miConfig.MdtrtareaAdmvs == "320921" {
  3952. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3953. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3954. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  3955. } else {
  3956. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3957. }
  3958. resp, _ := client.Do(req)
  3959. defer resp.Body.Close()
  3960. body, ioErr := ioutil.ReadAll(resp.Body)
  3961. if ioErr != nil {
  3962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3964. return
  3965. }
  3966. var respJSON map[string]interface{}
  3967. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3970. return
  3971. }
  3972. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3973. userJSONBytes, _ := json.Marshal(respJSON)
  3974. fmt.Println("log")
  3975. fmt.Println(string(userJSONBytes))
  3976. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3977. utils.ErrorLog("解析失败:%v", err)
  3978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3979. return
  3980. }
  3981. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3982. res2.Output = ressix10265.Output
  3983. res2.ErrMsg = ressix10265.ErrMsg
  3984. res2.Cainfo = ressix10265.Cainfo
  3985. res2.WarnMsg = ressix10265.WarnMsg
  3986. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3987. res2.Infcode = infocode
  3988. } else {
  3989. if miConfig.MdtrtareaAdmvs == "440781" { //
  3990. 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, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3991. } else {
  3992. if miConfig.Code == "H15049901371" {
  3993. //赤峰地区国家医保医疗类别
  3994. //职工透析:医疗类别选特殊情况门诊990502
  3995. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3996. var med_type string
  3997. if his.Insutype == "390" {
  3998. if reg_type == 14 {
  3999. med_type = "9933"
  4000. } else if reg_type == 11 {
  4001. med_type = "11"
  4002. }
  4003. } else if his.Insutype == "310" {
  4004. if reg_type == 14 {
  4005. med_type = "990502"
  4006. } else if reg_type == 11 {
  4007. med_type = "11"
  4008. }
  4009. }
  4010. 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)
  4011. } else {
  4012. 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)
  4013. }
  4014. }
  4015. saveLog(result, requestLog, "2203", "上传就诊信息")
  4016. var respJSON2 map[string]interface{}
  4017. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4018. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4020. return
  4021. }
  4022. userJSONBytes2, _ := json.Marshal(respJSON2)
  4023. if miConfig.Code == "H15049901371" {
  4024. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4025. utils.ErrorLog("解析失败:%v", err)
  4026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4027. return
  4028. }
  4029. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4030. res2.Output = ressix10265.Output
  4031. res2.ErrMsg = ressix10265.ErrMsg
  4032. res2.Cainfo = ressix10265.Cainfo
  4033. res2.WarnMsg = ressix10265.WarnMsg
  4034. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4035. res2.Infcode = infocode
  4036. } else {
  4037. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4038. utils.ErrorLog("解析失败:%v", err)
  4039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4040. return
  4041. }
  4042. }
  4043. }
  4044. if res2.Infcode != 0 {
  4045. adminUser := c.GetAdminUserInfo()
  4046. errlog := &models.HisOrderError{
  4047. UserOrgId: adminUser.CurrentOrgId,
  4048. Ctime: time.Now().Unix(),
  4049. Mtime: time.Now().Unix(),
  4050. ErrMsg: res2.ErrMsg,
  4051. Status: 1,
  4052. PatientId: id,
  4053. RecordTime: recordDateTime,
  4054. Stage: 3,
  4055. }
  4056. service.CreateErrMsgLog(errlog)
  4057. c.ServeSuccessJSON(map[string]interface{}{
  4058. "failed_code": -10,
  4059. "msg": res2.ErrMsg,
  4060. })
  4061. return
  4062. } else {
  4063. his.Diagnosis = diagnosis_id
  4064. his.SickType = sickConfig.ID
  4065. var p_type int64
  4066. if reg_type == 1111 || reg_type == 1112 {
  4067. p_type = 11
  4068. }
  4069. his.PType = fmt.Sprintf("%d", p_type)
  4070. service.UpdateHisPatientThree(&his)
  4071. data := make(map[string]interface{})
  4072. if settle_accounts_type == 1 { //日结
  4073. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4074. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4075. } else {
  4076. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4077. }
  4078. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4079. data["pre"] = prescriptions
  4080. } else { //月结
  4081. start_time_str := c.GetString("start_time")
  4082. end_time_str := c.GetString("end_time")
  4083. timeLayout := "2006-01-02"
  4084. loc, _ := time.LoadLocation("Local")
  4085. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4086. if err != nil {
  4087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4088. return
  4089. }
  4090. recordStartTime := theStartTime.Unix()
  4091. start_time = recordStartTime
  4092. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4093. if err != nil {
  4094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4095. return
  4096. }
  4097. recordEndTime := theEndTime.Unix()
  4098. end_time = recordEndTime
  4099. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4100. data["pre"] = prescriptions
  4101. }
  4102. timestamp := time.Now().Unix()
  4103. tempTime := time.Unix(timestamp, 0)
  4104. timeFormat := tempTime.Format("20060102150405")
  4105. chrgBchno := rand.Intn(100000) + 10000
  4106. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4107. strconv.FormatInt(his.PatientId, 10)
  4108. client := &http.Client{}
  4109. data["psn_no"] = his.PsnNo
  4110. data["mdtrt_id"] = his.Number
  4111. data["chrg_bchno"] = chrg_bchno
  4112. data["org_name"] = miConfig.OrgName
  4113. data["doctor"] = roles.UserName
  4114. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4115. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4116. data["fixmedins_code"] = miConfig.Code
  4117. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4118. // data["dept_code"] = "15"
  4119. //} else {
  4120. data["dept_code"] = department.Number
  4121. //}
  4122. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4123. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4124. data["secret_key"] = miConfig.SecretKey
  4125. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4126. data["url"] = miConfig.Url
  4127. data["ak"] = miConfig.AccessKey
  4128. data["new_doctor_name"] = patientPrescription.Doctor
  4129. data["diag_code"] = sickConfig.CountryCode
  4130. data["cainfo"] = miConfig.Cainfo
  4131. var ids []int64
  4132. for _, item := range prescriptions {
  4133. ids = append(ids, item.ID)
  4134. }
  4135. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4136. if config.IsOpen == 1 { //对接了医保,走医保流程
  4137. var res ResultFour
  4138. var resFour10265 ResultFour10265
  4139. if miConfig.MdtrtareaAdmvs == "421300" {
  4140. bytesData, _ := json.Marshal(data)
  4141. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4142. resp, _ := client.Do(req)
  4143. defer resp.Body.Close()
  4144. body, ioErr := ioutil.ReadAll(resp.Body)
  4145. if ioErr != nil {
  4146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4148. return
  4149. }
  4150. var respJSON map[string]interface{}
  4151. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4154. return
  4155. }
  4156. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4157. userJSONBytes, _ := json.Marshal(respJSON)
  4158. fmt.Println("log")
  4159. fmt.Println(string(userJSONBytes))
  4160. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4161. utils.ErrorLog("解析失败:%v", err)
  4162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4163. return
  4164. }
  4165. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4166. bytesData, _ := json.Marshal(data)
  4167. var req *http.Request
  4168. if miConfig.MdtrtareaAdmvs == "320921" {
  4169. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4170. } else {
  4171. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4172. }
  4173. resp, _ := client.Do(req)
  4174. defer resp.Body.Close()
  4175. body, ioErr := ioutil.ReadAll(resp.Body)
  4176. if ioErr != nil {
  4177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4179. return
  4180. }
  4181. var respJSON map[string]interface{}
  4182. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4185. return
  4186. }
  4187. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4188. userJSONBytes, _ := json.Marshal(respJSON)
  4189. fmt.Println("log")
  4190. fmt.Println(string(userJSONBytes))
  4191. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4192. utils.ErrorLog("解析失败:%v", err)
  4193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4194. return
  4195. }
  4196. res.InfRefmsgid = resFour10265.InfRefmsgid
  4197. res.Output = resFour10265.Output
  4198. res.ErrMsg = resFour10265.ErrMsg
  4199. res.Cainfo = resFour10265.Cainfo
  4200. res.WarnMsg = resFour10265.WarnMsg
  4201. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4202. res.Infcode = infocode
  4203. } else {
  4204. if miConfig.Code == "H15049901371" {
  4205. 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)
  4206. var dat map[string]interface{}
  4207. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4208. fmt.Println(dat)
  4209. } else {
  4210. fmt.Println(err)
  4211. }
  4212. saveLog(result, request_log, "2204", "上传费用明细")
  4213. userJSONBytes, _ := json.Marshal(dat)
  4214. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4215. utils.ErrorLog("解析失败:%v", err)
  4216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4217. return
  4218. }
  4219. res.InfRefmsgid = resFour10265.InfRefmsgid
  4220. res.Output = resFour10265.Output
  4221. res.ErrMsg = resFour10265.ErrMsg
  4222. res.Cainfo = resFour10265.Cainfo
  4223. res.WarnMsg = resFour10265.WarnMsg
  4224. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4225. res.Infcode = infocode
  4226. } else {
  4227. 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)
  4228. var dat map[string]interface{}
  4229. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4230. fmt.Println(dat)
  4231. } else {
  4232. fmt.Println(err)
  4233. }
  4234. saveLog(result, request_log, "2204", "上传费用明细")
  4235. userJSONBytes, _ := json.Marshal(dat)
  4236. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4237. utils.ErrorLog("解析失败:%v", err)
  4238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4239. return
  4240. }
  4241. }
  4242. }
  4243. if res.Infcode == 0 {
  4244. order := &models.HisOrder{
  4245. UserOrgId: adminUser.CurrentOrgId,
  4246. HisPatientId: his.ID,
  4247. PatientId: his.PatientId,
  4248. SettleAccountsDate: recordDateTime,
  4249. MdtrtId: his.Number,
  4250. PsnNo: his.PsnNo,
  4251. MedType: strconv.FormatInt(reg_type, 10),
  4252. Ctime: time.Now().Unix(),
  4253. Mtime: time.Now().Unix(),
  4254. Status: 1,
  4255. Number: chrg_bchno,
  4256. Infcode: res.Infcode,
  4257. WarnMsg: res.WarnMsg,
  4258. Cainfo: res.Cainfo,
  4259. ErrMsg: res.ErrMsg,
  4260. RespondTime: res.RefmsgTime,
  4261. InfRefmsgid: res.InfRefmsgid,
  4262. OrderStatus: 1,
  4263. PayWay: pay_way,
  4264. PayPrice: pay_price,
  4265. PayCardNo: pay_card_no,
  4266. DiscountPrice: discount_price,
  4267. PreferentialPrice: preferential_price,
  4268. RealityPrice: reality_price,
  4269. FoundPrice: found_price,
  4270. MedicalInsurancePrice: medical_insurance_price,
  4271. PrivatePrice: private_price,
  4272. IsMedicineInsurance: 1,
  4273. SettleType: settle_accounts_type,
  4274. SettleStartTime: start_time,
  4275. SettleEndTime: end_time,
  4276. Creator: roles.AdminUserId,
  4277. Modify: roles.AdminUserId,
  4278. FaPiaoNumber: fapiao_number,
  4279. FaPiaoCode: fapiao_code,
  4280. PType: 2,
  4281. Diagnosis: diagnosis_id,
  4282. }
  4283. err = service.CreateOrder(order)
  4284. if err != nil {
  4285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4286. return
  4287. }
  4288. for _, item := range res.Output.Result {
  4289. temp := strings.Split(item.FeedetlSn, "-")
  4290. var advice_id int64 = 0
  4291. var project_id int64 = 0
  4292. var types int64 = 0
  4293. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4294. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4295. if temp[1] == "1" {
  4296. advice_id = id
  4297. project_id = 0
  4298. } else if temp[1] == "2" {
  4299. advice_id = 0
  4300. project_id = id
  4301. }
  4302. info := &models.HisOrderInfo{
  4303. OrderNumber: order.Number,
  4304. FeedetlSn: item.FeedetlSn,
  4305. UploadDate: time.Now().Unix(),
  4306. AdviceId: advice_id,
  4307. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4308. Cnt: item.Cnt,
  4309. Pric: float64(item.Pric),
  4310. PatientId: his.PatientId,
  4311. PricUplmtAmt: item.PricUplmtAmt,
  4312. SelfpayProp: item.SelfpayProp,
  4313. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4314. OverlmtAmt: item.OverlmtAmt,
  4315. PreselfpayAmt: item.PreselfpayAmt,
  4316. BasMednFlag: item.BasMednFlag,
  4317. MedChrgitmType: item.MedChrgitmType,
  4318. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4319. Status: 1,
  4320. Memo: item.Memo,
  4321. Mtime: time.Now().Unix(),
  4322. InscpScpAmt: item.InscpScpAmt,
  4323. DrtReimFlag: item.DrtReimFlag,
  4324. Ctime: time.Now().Unix(),
  4325. ListSpItemFlag: item.ListSpItemFlag,
  4326. ChldMedcFlag: item.ChldMedcFlag,
  4327. LmtUsedFlag: item.LmtUsedFlag,
  4328. ChrgitmLv: item.ChrgitmLv,
  4329. UserOrgId: adminUser.CurrentOrgId,
  4330. HisPatientId: his.ID,
  4331. OrderId: order.ID,
  4332. ProjectId: project_id,
  4333. Type: types,
  4334. }
  4335. service.CreateOrderInfo(info)
  4336. }
  4337. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4338. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4339. var total float64
  4340. for _, item := range prescriptions {
  4341. if item.Type == 1 { //药品
  4342. for _, subItem := range item.HisDoctorAdviceInfo {
  4343. total = total + (subItem.Price * subItem.PrescribingNumber)
  4344. }
  4345. }
  4346. if item.Type == 2 { //项目
  4347. for _, subItem := range item.HisPrescriptionProject {
  4348. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4349. total = total + (subItem.Price * cnt)
  4350. }
  4351. }
  4352. }
  4353. for _, item := range prescriptions {
  4354. for _, subItem := range item.HisAdditionalCharge {
  4355. total = total + (subItem.Price * float64(subItem.Count))
  4356. }
  4357. }
  4358. var allTotal string
  4359. if adminUser.CurrentOrgId == 9919 {
  4360. allTotal = fmt.Sprintf("%.4f", total)
  4361. } else {
  4362. allTotal = fmt.Sprintf("%.4f", total)
  4363. }
  4364. if res.Infcode == 0 {
  4365. var rf []*ResultFive
  4366. json.Unmarshal([]byte(his.Iinfo), &rf)
  4367. chrg_bchno := chrg_bchno
  4368. cert_no := his.Certno
  4369. var insutypes []string
  4370. var insutype string
  4371. var is390 int = 0
  4372. var is310 int = 0
  4373. for _, item := range rf {
  4374. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4375. insutypes = append(insutypes, item.Insutype)
  4376. }
  4377. }
  4378. if len(insutypes) == 1 {
  4379. insutype = insutypes[0]
  4380. } else {
  4381. for _, i := range insutypes {
  4382. if i == "390" {
  4383. is390 = 1
  4384. }
  4385. if i == "310" {
  4386. is310 = 1
  4387. }
  4388. }
  4389. }
  4390. if is390 == 1 {
  4391. insutype = "390"
  4392. }
  4393. if is310 == 1 {
  4394. insutype = "310"
  4395. }
  4396. if len(insutypes) == 0 {
  4397. insutype = "310"
  4398. }
  4399. if len(insutypes) == 2 {
  4400. insutype = strconv.FormatInt(his.SocialType, 10)
  4401. }
  4402. insutype = strconv.FormatInt(his.SocialType, 10)
  4403. //insutype = "390"
  4404. if his.IdCardType == 1 {
  4405. // cert_no = his.MedicalInsuranceNumber
  4406. cert_no = his.Certno
  4407. } else {
  4408. cert_no = his.Certno
  4409. }
  4410. var res ResultSeven
  4411. var resSeven10265 ResultSeven10265
  4412. var src_resquest string
  4413. var result2 string
  4414. var acct_used_flag string
  4415. fmt.Println("pay_way")
  4416. fmt.Println(pay_way)
  4417. fmt.Println("pay_way")
  4418. if pay_way == 4 {
  4419. acct_used_flag = "1"
  4420. } else {
  4421. acct_used_flag = "0"
  4422. }
  4423. if miConfig.MdtrtareaAdmvs == "421300" {
  4424. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4425. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4426. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4427. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4428. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4429. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4430. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4431. resp, requestErr := http.Get(api)
  4432. if requestErr != nil {
  4433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4434. return
  4435. }
  4436. body, ioErr := ioutil.ReadAll(resp.Body)
  4437. if ioErr != nil {
  4438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4440. return
  4441. }
  4442. var respJSON map[string]interface{}
  4443. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4446. return
  4447. }
  4448. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4449. result, _ := json.Marshal(respJSON)
  4450. if miConfig.Code == "H15049901371" {
  4451. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4452. utils.ErrorLog("解析失败:%v", err)
  4453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4454. return
  4455. }
  4456. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4457. res.Output = resSeven10265.Output
  4458. res.ErrMsg = resSeven10265.ErrMsg
  4459. res.Cainfo = resSeven10265.Cainfo
  4460. res.WarnMsg = resSeven10265.WarnMsg
  4461. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4462. res.Infcode = infocode
  4463. } else {
  4464. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4465. utils.ErrorLog("解析失败:%v", err)
  4466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4467. return
  4468. }
  4469. }
  4470. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4471. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4472. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4473. //psn_info, _ := service.GetPsnByPatientId(id)
  4474. bas := strings.Split(psn_info.CardInfo, "|")
  4475. if his.IdCardType == 1 {
  4476. cert_no = bas[2]
  4477. } else {
  4478. cert_no = bas[1]
  4479. }
  4480. //江苏地区国家医保医疗类别
  4481. //职工透析:医疗类别选特殊情况门诊9933
  4482. //居民血透门慢: 医疗类别选门诊慢病1402
  4483. //var med_type string
  4484. //if his.Insutype == "310" {
  4485. // if reg_type == 14 {
  4486. // med_type = "9933"
  4487. // } else if reg_type == 11 {
  4488. // med_type = "11"
  4489. //
  4490. // }
  4491. //} else if his.Insutype == "390" {
  4492. // if reg_type == 14 {
  4493. // med_type = "1402"
  4494. // } else if reg_type == 11 {
  4495. // med_type = "11"
  4496. // }
  4497. //}
  4498. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4499. var api string
  4500. if miConfig.MdtrtareaAdmvs == "320921" {
  4501. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4502. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4503. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4504. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4505. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4506. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4507. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4508. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4509. } else {
  4510. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4511. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4512. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4513. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4514. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4515. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4516. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4517. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4518. }
  4519. resp, requestErr := http.Get(api)
  4520. if requestErr != nil {
  4521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4522. return
  4523. }
  4524. body, ioErr := ioutil.ReadAll(resp.Body)
  4525. if ioErr != nil {
  4526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4528. return
  4529. }
  4530. var respJSON map[string]interface{}
  4531. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4534. return
  4535. }
  4536. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4537. result, _ := json.Marshal(respJSON)
  4538. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4539. utils.ErrorLog("解析失败:%v", err)
  4540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4541. return
  4542. }
  4543. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4544. res.Output = resSeven10265.Output
  4545. res.ErrMsg = resSeven10265.ErrMsg
  4546. res.Cainfo = resSeven10265.Cainfo
  4547. res.WarnMsg = resSeven10265.WarnMsg
  4548. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4549. res.Infcode = infocode
  4550. } else {
  4551. if miConfig.Code == "H15049901371" {
  4552. //赤峰地区国家医保医疗类别
  4553. //职工透析:医疗类别选特殊情况门诊990502
  4554. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4555. var med_type string
  4556. if his.Insutype == "390" {
  4557. if reg_type == 14 {
  4558. med_type = "9933"
  4559. } else if reg_type == 11 {
  4560. med_type = "11"
  4561. }
  4562. } else if his.Insutype == "310" {
  4563. if reg_type == 14 {
  4564. med_type = "990502"
  4565. } else if reg_type == 11 {
  4566. med_type = "11"
  4567. }
  4568. }
  4569. 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)
  4570. } else {
  4571. 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, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4572. }
  4573. //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)
  4574. var dat map[string]interface{}
  4575. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4576. fmt.Println(dat)
  4577. } else {
  4578. fmt.Println(err)
  4579. }
  4580. saveLog(result2, src_resquest, "2207", "结算")
  4581. userJSONBytes, _ := json.Marshal(dat)
  4582. if miConfig.Code == "H15049901371" {
  4583. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4584. utils.ErrorLog("解析失败:%v", err)
  4585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4586. return
  4587. }
  4588. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4589. res.Output = resSeven10265.Output
  4590. res.ErrMsg = resSeven10265.ErrMsg
  4591. res.Cainfo = resSeven10265.Cainfo
  4592. res.WarnMsg = resSeven10265.WarnMsg
  4593. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4594. res.Infcode = infocode
  4595. } else {
  4596. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4597. utils.ErrorLog("解析失败:%v", err)
  4598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4599. return
  4600. }
  4601. }
  4602. }
  4603. if res.Infcode != 0 {
  4604. errlog := &models.HisOrderError{
  4605. UserOrgId: adminUser.CurrentOrgId,
  4606. Ctime: time.Now().Unix(),
  4607. Mtime: time.Now().Unix(),
  4608. Number: chrg_bchno,
  4609. ErrMsg: res.ErrMsg,
  4610. Status: 1,
  4611. PatientId: id,
  4612. RecordTime: recordDateTime,
  4613. Stage: 6,
  4614. }
  4615. service.CreateErrMsgLog(errlog)
  4616. c.ServeSuccessJSON(map[string]interface{}{
  4617. "failed_code": -10,
  4618. "msg": res.ErrMsg,
  4619. })
  4620. return
  4621. } else {
  4622. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4623. order.OrderStatus = 2
  4624. order.Status = 1
  4625. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4626. order.SetlId = res.Output.Setlinfo.SetlID
  4627. order.PsnNo = res.Output.Setlinfo.PsnNo
  4628. order.PsnName = res.Output.Setlinfo.PsnName
  4629. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4630. order.Certno = res.Output.Setlinfo.Certno
  4631. order.Gend = res.Output.Setlinfo.Gend
  4632. order.Naty = res.Output.Setlinfo.Naty
  4633. order.Age = res.Output.Setlinfo.Age
  4634. order.Insutype = res.Output.Setlinfo.Insutype
  4635. order.PsnType = res.Output.Setlinfo.PsnType
  4636. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4637. order.SetlTime = res.Output.Setlinfo.SetlTime
  4638. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4639. if res.Output.Setlinfo.MedType == "140101" {
  4640. order.MedType = "14"
  4641. } else {
  4642. order.MedType = res.Output.Setlinfo.MedType
  4643. }
  4644. if reg_type == 1112 {
  4645. order.MedType = "1112"
  4646. }
  4647. if reg_type == 1111 {
  4648. order.MedType = "1111"
  4649. }
  4650. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4651. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4652. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4653. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4654. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4655. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4656. order.HifpPay = res.Output.Setlinfo.HifpPay
  4657. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4658. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4659. order.HifesPay = res.Output.Setlinfo.HifesPay
  4660. order.HifobPay = res.Output.Setlinfo.HifobPay
  4661. order.MafPay = res.Output.Setlinfo.MafPay
  4662. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4663. order.OthPay = res.Output.Setlinfo.OthPay
  4664. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4665. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4666. order.AcctPay = res.Output.Setlinfo.AcctPay
  4667. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4668. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4669. order.Balc = res.Output.Setlinfo.Balc
  4670. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4671. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4672. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4673. order.ClrType = res.Output.Setlinfo.ClrType
  4674. order.ClrWay = res.Output.Setlinfo.ClrWay
  4675. order.Creator = order.Creator
  4676. order.Modify = roles.AdminUserId
  4677. order.RequestLog = src_resquest
  4678. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4679. detailStr := string(setlDetail)
  4680. order.SetlDetail = detailStr
  4681. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4682. err = service.UpDateOrder(order)
  4683. if err == nil {
  4684. c.ServeSuccessJSON(map[string]interface{}{
  4685. "msg": "结算成功",
  4686. })
  4687. } else {
  4688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4689. return
  4690. }
  4691. }
  4692. } else {
  4693. adminUser := c.GetAdminUserInfo()
  4694. errlog := &models.HisOrderError{
  4695. UserOrgId: adminUser.CurrentOrgId,
  4696. Ctime: time.Now().Unix(),
  4697. Mtime: time.Now().Unix(),
  4698. ErrMsg: res.ErrMsg,
  4699. Status: 1,
  4700. PatientId: id,
  4701. RecordTime: recordDateTime,
  4702. Stage: 4,
  4703. }
  4704. service.CreateErrMsgLog(errlog)
  4705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4706. return
  4707. }
  4708. } else {
  4709. adminUser := c.GetAdminUserInfo()
  4710. errlog := &models.HisOrderError{
  4711. UserOrgId: adminUser.CurrentOrgId,
  4712. Ctime: time.Now().Unix(),
  4713. Mtime: time.Now().Unix(),
  4714. ErrMsg: res.ErrMsg,
  4715. Status: 1,
  4716. PatientId: id,
  4717. RecordTime: recordDateTime,
  4718. Stage: 4,
  4719. }
  4720. service.CreateErrMsgLog(errlog)
  4721. c.ServeSuccessJSON(map[string]interface{}{
  4722. "failed_code": -10,
  4723. "msg": res.ErrMsg,
  4724. })
  4725. return
  4726. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4727. //return
  4728. }
  4729. }
  4730. }
  4731. } else if tempOrder.ID > 0 {
  4732. if tempOrder.IsPre == 1 {
  4733. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4734. var rf []*ResultFive
  4735. json.Unmarshal([]byte(his.Iinfo), &rf)
  4736. chrg_bchno := tempOrder.Number
  4737. cert_no := his.Certno
  4738. var insutypes []string
  4739. var insutype string
  4740. var is390 int = 0
  4741. var is310 int = 0
  4742. for _, item := range rf {
  4743. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4744. insutypes = append(insutypes, item.Insutype)
  4745. }
  4746. }
  4747. if len(insutypes) == 1 {
  4748. insutype = insutypes[0]
  4749. } else {
  4750. for _, i := range insutypes {
  4751. if i == "390" {
  4752. is390 = 1
  4753. }
  4754. if i == "310" {
  4755. is310 = 1
  4756. }
  4757. }
  4758. }
  4759. if is390 == 1 {
  4760. insutype = "390"
  4761. }
  4762. if is310 == 1 {
  4763. insutype = "310"
  4764. }
  4765. if len(insutypes) == 0 {
  4766. insutype = "310"
  4767. }
  4768. if len(insutypes) == 2 {
  4769. insutype = strconv.FormatInt(his.SocialType, 64)
  4770. }
  4771. //insutype = "390"
  4772. if his.IdCardType == 1 {
  4773. // cert_no = his.MedicalInsuranceNumber
  4774. cert_no = his.Certno
  4775. } else {
  4776. cert_no = his.Certno
  4777. }
  4778. var res ResultSeven
  4779. var resSeven10265 ResultSeven10265
  4780. var src_resquest string
  4781. var result2 string
  4782. var acct_used_flag string
  4783. fmt.Println("pay_way")
  4784. fmt.Println(pay_way)
  4785. fmt.Println("pay_way")
  4786. if pay_way == 4 {
  4787. acct_used_flag = "1"
  4788. } else {
  4789. acct_used_flag = "0"
  4790. }
  4791. if miConfig.MdtrtareaAdmvs == "421300" {
  4792. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4793. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4794. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4795. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4796. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4797. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4798. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4799. resp, requestErr := http.Get(api)
  4800. if requestErr != nil {
  4801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4802. return
  4803. }
  4804. body, ioErr := ioutil.ReadAll(resp.Body)
  4805. if ioErr != nil {
  4806. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4808. return
  4809. }
  4810. var respJSON map[string]interface{}
  4811. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4812. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4814. return
  4815. }
  4816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4817. result, _ := json.Marshal(respJSON)
  4818. fmt.Println("log")
  4819. fmt.Println(string(result))
  4820. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4821. utils.ErrorLog("解析失败:%v", err)
  4822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4823. return
  4824. }
  4825. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4826. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4827. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4828. //psn_info, _ := service.GetPsnByPatientId(id)
  4829. bas := strings.Split(psn_info.CardInfo, "|")
  4830. if his.IdCardType == 1 {
  4831. cert_no = bas[2]
  4832. } else {
  4833. cert_no = bas[1]
  4834. }
  4835. //江苏地区国家医保医疗类别
  4836. //职工透析:医疗类别选特殊情况门诊9933
  4837. //居民血透门慢: 医疗类别选门诊慢病1402
  4838. //var med_type string
  4839. //if his.Insutype == "310" {
  4840. // if reg_type == 14 {
  4841. // med_type = "9933"
  4842. // } else if reg_type == 11 {
  4843. // med_type = "11"
  4844. //
  4845. // }
  4846. //} else if his.Insutype == "390" {
  4847. // if reg_type == 14 {
  4848. // med_type = "1402"
  4849. // } else if reg_type == 11 {
  4850. // med_type = "11"
  4851. // }
  4852. //}
  4853. var api string
  4854. if miConfig.MdtrtareaAdmvs == "320921" {
  4855. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4856. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4857. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4858. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4859. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4860. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4861. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4862. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4863. } else {
  4864. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4865. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4866. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4867. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4868. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4869. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4870. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4871. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4872. }
  4873. resp, requestErr := http.Get(api)
  4874. if requestErr != nil {
  4875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4876. return
  4877. }
  4878. body, ioErr := ioutil.ReadAll(resp.Body)
  4879. if ioErr != nil {
  4880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4882. return
  4883. }
  4884. var respJSON map[string]interface{}
  4885. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4888. return
  4889. }
  4890. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4891. result, _ := json.Marshal(respJSON)
  4892. fmt.Println("log")
  4893. fmt.Println(string(result))
  4894. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4895. utils.ErrorLog("解析失败:%v", err)
  4896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4897. return
  4898. }
  4899. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4900. res.Output = resSeven10265.Output
  4901. res.ErrMsg = resSeven10265.ErrMsg
  4902. res.Cainfo = resSeven10265.Cainfo
  4903. res.WarnMsg = resSeven10265.WarnMsg
  4904. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4905. res.Infcode = infocode
  4906. } else {
  4907. var src_resquest string
  4908. if miConfig.Code == "H15049901371" {
  4909. //赤峰地区国家医保医疗类别
  4910. //职工透析:医疗类别选特殊情况门诊990502
  4911. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4912. var med_type string
  4913. if his.Insutype == "390" {
  4914. if reg_type == 14 {
  4915. med_type = "9933"
  4916. } else if reg_type == 11 {
  4917. med_type = "11"
  4918. }
  4919. } else if his.Insutype == "310" {
  4920. if reg_type == 14 {
  4921. med_type = "990502"
  4922. } else if reg_type == 11 {
  4923. med_type = "11"
  4924. }
  4925. }
  4926. 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)
  4927. } else {
  4928. 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, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4929. }
  4930. var dat map[string]interface{}
  4931. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4932. fmt.Println(dat)
  4933. } else {
  4934. fmt.Println(err)
  4935. }
  4936. saveLog(result2, src_resquest, "2207", "结算")
  4937. userJSONBytes, _ := json.Marshal(dat)
  4938. if miConfig.Code == "H15049901371" {
  4939. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4940. utils.ErrorLog("解析失败:%v", err)
  4941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4942. return
  4943. }
  4944. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4945. res.Output = resSeven10265.Output
  4946. res.ErrMsg = resSeven10265.ErrMsg
  4947. res.Cainfo = resSeven10265.Cainfo
  4948. res.WarnMsg = resSeven10265.WarnMsg
  4949. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4950. res.Infcode = infocode
  4951. } else {
  4952. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4953. utils.ErrorLog("解析失败:%v", err)
  4954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4955. return
  4956. }
  4957. }
  4958. }
  4959. if res.Infcode != 0 {
  4960. errlog := &models.HisOrderError{
  4961. UserOrgId: adminUser.CurrentOrgId,
  4962. Ctime: time.Now().Unix(),
  4963. Mtime: time.Now().Unix(),
  4964. Number: chrg_bchno,
  4965. ErrMsg: res.ErrMsg,
  4966. Status: 1,
  4967. PatientId: id,
  4968. RecordTime: recordDateTime,
  4969. Stage: 6,
  4970. }
  4971. service.CreateErrMsgLog(errlog)
  4972. c.ServeSuccessJSON(map[string]interface{}{
  4973. "failed_code": -10,
  4974. "msg": res.ErrMsg,
  4975. })
  4976. return
  4977. } else {
  4978. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4979. order.OrderStatus = 2
  4980. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4981. order.SetlId = res.Output.Setlinfo.SetlID
  4982. order.PsnNo = res.Output.Setlinfo.PsnNo
  4983. order.PsnName = res.Output.Setlinfo.PsnName
  4984. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4985. order.Certno = res.Output.Setlinfo.Certno
  4986. order.Gend = res.Output.Setlinfo.Gend
  4987. order.Naty = res.Output.Setlinfo.Naty
  4988. order.Age = res.Output.Setlinfo.Age
  4989. order.Insutype = res.Output.Setlinfo.Insutype
  4990. order.PsnType = res.Output.Setlinfo.PsnType
  4991. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4992. order.SetlTime = res.Output.Setlinfo.SetlTime
  4993. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4994. //order.MedType = res.Output.Setlinfo.MedType
  4995. if reg_type == 1112 {
  4996. order.MedType = "1112"
  4997. }
  4998. if reg_type == 1111 {
  4999. order.MedType = "1111"
  5000. }
  5001. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5002. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5003. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5004. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5005. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5006. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5007. order.HifpPay = res.Output.Setlinfo.HifpPay
  5008. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5009. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5010. order.HifesPay = res.Output.Setlinfo.HifesPay
  5011. order.HifobPay = res.Output.Setlinfo.HifobPay
  5012. order.MafPay = res.Output.Setlinfo.MafPay
  5013. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5014. order.OthPay = res.Output.Setlinfo.OthPay
  5015. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5016. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5017. order.AcctPay = res.Output.Setlinfo.AcctPay
  5018. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5019. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5020. order.Balc = res.Output.Setlinfo.Balc
  5021. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5022. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5023. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5024. order.ClrWay = res.Output.Setlinfo.ClrWay
  5025. order.Creator = order.Creator
  5026. order.Modify = roles.AdminUserId
  5027. order.RequestLog = src_resquest
  5028. order.Diagnosis = diagnosis_id
  5029. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5030. detailStr := string(setlDetail)
  5031. order.SetlDetail = detailStr
  5032. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5033. err = service.UpDateOrder(order)
  5034. if err == nil {
  5035. c.ServeSuccessJSON(map[string]interface{}{
  5036. "msg": "结算成功",
  5037. })
  5038. } else {
  5039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5040. return
  5041. }
  5042. }
  5043. }
  5044. }
  5045. }
  5046. //func (c *HisApiController) GetPreUploadInfo() {
  5047. // id, _ := c.GetInt64("id")
  5048. // record_time := c.GetString("record_time")
  5049. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5050. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5051. //
  5052. // timeLayout := "2006-01-02"
  5053. // loc, _ := time.LoadLocation("Local")
  5054. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5055. // if err != nil {
  5056. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5057. // return
  5058. // }
  5059. // recordDateTime := theTime.Unix()
  5060. // adminUser := c.GetAdminUserInfo()
  5061. //
  5062. // var prescriptions []*models.HisPrescription
  5063. //
  5064. // var start_time int64
  5065. // var end_time int64
  5066. //
  5067. // data := make(map[string]interface{})
  5068. // if settle_accounts_type == 1 { //日结
  5069. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5070. // data["pre"] = prescriptions
  5071. //
  5072. // } else { //月结
  5073. // start_time_str := c.GetString("start_time")
  5074. // end_time_str := c.GetString("end_time")
  5075. // timeLayout := "2006-01-02"
  5076. // loc, _ := time.LoadLocation("Local")
  5077. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5078. // if err != nil {
  5079. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5080. // return
  5081. // }
  5082. // recordStartTime := theStartTime.Unix()
  5083. // start_time = recordStartTime
  5084. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5085. // if err != nil {
  5086. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5087. // return
  5088. // }
  5089. // recordEndTime := theEndTime.Unix()
  5090. // end_time = recordEndTime
  5091. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5092. // data["pre"] = prescriptions
  5093. //
  5094. // }
  5095. //
  5096. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5097. //
  5098. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5099. // timestamp := time.Now().Unix()
  5100. // tempTime := time.Unix(timestamp, 0)
  5101. // timeFormat := tempTime.Format("20060102150405")
  5102. // chrgBchno := rand.Intn(100000) + 10000
  5103. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5104. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5105. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5106. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5107. // strconv.FormatInt(his.PatientId, 10)
  5108. // client := &http.Client{}
  5109. // data["psn_no"] = his.PsnNo
  5110. // data["mdtrt_id"] = his.Number
  5111. // data["chrg_bchno"] = chrg_bchno
  5112. // data["org_name"] = miConfig.OrgName
  5113. // data["doctor"] = roles.UserName
  5114. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5115. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5116. // data["fixmedins_code"] = miConfig.Code
  5117. // data["dept_code"] = department.Number
  5118. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5119. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5120. // data["secret_key"] = miConfig.SecretKey
  5121. // var ids []int64
  5122. //
  5123. // for _, item := range prescriptions {
  5124. // ids = append(ids, item.ID)
  5125. // }
  5126. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5127. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5128. // bytesData, _ := json.Marshal(data)
  5129. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5130. // resp, _ := client.Do(req)
  5131. // defer resp.Body.Close()
  5132. // body, ioErr := ioutil.ReadAll(resp.Body)
  5133. // if ioErr != nil {
  5134. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5135. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5136. // return
  5137. // }
  5138. // var respJSON map[string]interface{}
  5139. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5140. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5141. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5142. // return
  5143. // }
  5144. //
  5145. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5146. // userJSONBytes, _ := json.Marshal(respJSON)
  5147. // var res ResultFour
  5148. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5149. // utils.ErrorLog("解析失败:%v", err)
  5150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5151. // return
  5152. // }
  5153. //
  5154. // if res.Infcode == 0 {
  5155. // order := &models.HisOrder{
  5156. // UserOrgId: adminUser.CurrentOrgId,
  5157. // HisPatientId: his.ID,
  5158. // PatientId: his.PatientId,
  5159. // SettleAccountsDate: recordDateTime,
  5160. // Ctime: time.Now().Unix(),
  5161. // Mtime: time.Now().Unix(),
  5162. // Status: 1,
  5163. // Number: chrg_bchno,
  5164. // Infcode: res.Infcode,
  5165. // WarnMsg: res.WarnMsg,
  5166. // Cainfo: res.Cainfo,
  5167. // ErrMsg: res.ErrMsg,
  5168. // RespondTime: res.RefmsgTime,
  5169. // InfRefmsgid: res.InfRefmsgid,
  5170. // OrderStatus: 1,
  5171. // IsMedicineInsurance: 1,
  5172. // SettleType: settle_accounts_type,
  5173. // SettleStartTime: start_time,
  5174. // SettleEndTime: end_time,
  5175. // Creator: roles.ID,
  5176. // Modify: roles.ID,
  5177. // PType: 2,
  5178. // }
  5179. // err = service.CreateOrder(order)
  5180. // if err != nil {
  5181. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5182. // return
  5183. // }
  5184. //
  5185. // for _, item := range res.Output.Result {
  5186. // temp := strings.Split(item.FeedetlSn, "-")
  5187. // var advice_id int64 = 0
  5188. // var project_id int64 = 0
  5189. // var types int64 = 0
  5190. //
  5191. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5192. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5193. //
  5194. // if temp[1] == "1" {
  5195. // advice_id = id
  5196. // project_id = 0
  5197. // } else if temp[1] == "2" {
  5198. // advice_id = 0
  5199. // project_id = id
  5200. // }
  5201. //
  5202. // info := &models.HisOrderInfo{
  5203. // OrderNumber: order.Number,
  5204. // FeedetlSn: item.FeedetlSn,
  5205. // UploadDate: time.Now().Unix(),
  5206. // AdviceId: advice_id,
  5207. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5208. // Cnt: item.Cnt,
  5209. // Pric: float64(item.Pric),
  5210. // PatientId: his.PatientId,
  5211. // PricUplmtAmt: item.PricUplmtAmt,
  5212. // SelfpayProp: item.SelfpayProp,
  5213. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5214. // OverlmtAmt: item.OverlmtAmt,
  5215. // PreselfpayAmt: item.PreselfpayAmt,
  5216. // BasMednFlag: item.BasMednFlag,
  5217. // MedChrgitmType: item.MedChrgitmType,
  5218. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5219. // Status: 1,
  5220. // Memo: item.Memo,
  5221. // Mtime: time.Now().Unix(),
  5222. // InscpScpAmt: item.InscpScpAmt,
  5223. // DrtReimFlag: item.DrtReimFlag,
  5224. // Ctime: time.Now().Unix(),
  5225. // ListSpItemFlag: item.ListSpItemFlag,
  5226. // ChldMedcFlag: item.ChldMedcFlag,
  5227. // LmtUsedFlag: item.LmtUsedFlag,
  5228. // ChrgitmLv: item.ChrgitmLv,
  5229. // UserOrgId: adminUser.CurrentOrgId,
  5230. // HisPatientId: his.ID,
  5231. // OrderId: order.ID,
  5232. // ProjectId: project_id,
  5233. // Type: types,
  5234. // }
  5235. // service.CreateOrderInfo(info)
  5236. //
  5237. // }
  5238. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5239. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5240. //
  5241. // var total float64
  5242. // for _, item := range prescriptions {
  5243. // if item.Type == 1 { //药品
  5244. // for _, subItem := range item.HisDoctorAdviceInfo {
  5245. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5246. // }
  5247. // }
  5248. // if item.Type == 2 { //项目
  5249. // for _, subItem := range item.HisPrescriptionProject {
  5250. // total = total + (subItem.Price * float64(subItem.Count))
  5251. // }
  5252. // }
  5253. // }
  5254. //
  5255. // for _, item := range prescriptions {
  5256. // for _, subItem := range item.HisAdditionalCharge {
  5257. // total = total + (subItem.Price * float64(subItem.Count))
  5258. // }
  5259. // }
  5260. //
  5261. // allTotal := fmt.Sprintf("%.2f", total)
  5262. // if res.Infcode == 0 {
  5263. // var rf []*ResultFive
  5264. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5265. // psn_no := his.PsnNo
  5266. // mdtrt_id := his.Number
  5267. // chrg_bchno := chrg_bchno
  5268. // cert_no := his.Certno
  5269. // insutype := rf[0].Insutype
  5270. //
  5271. // if his.IdCardType == 1 {
  5272. // cert_no = his.MedicalInsuranceNumber
  5273. //
  5274. // } else {
  5275. //
  5276. // cert_no = his.Certno
  5277. //
  5278. // }
  5279. //
  5280. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5281. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5282. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5283. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5284. // resp, requestErr := http.Get(api)
  5285. // if requestErr != nil {
  5286. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5287. // return
  5288. // }
  5289. // defer resp.Body.Close()
  5290. // body, ioErr := ioutil.ReadAll(resp.Body)
  5291. // if ioErr != nil {
  5292. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5293. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5294. // return
  5295. // }
  5296. // var respJSON map[string]interface{}
  5297. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5298. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5299. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5300. // return
  5301. // }
  5302. // fmt.Println(respJSON)
  5303. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5304. // userJSONBytes, _ := json.Marshal(respJSON)
  5305. // var res ResultSeven
  5306. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5307. // utils.ErrorLog("解析失败:%v", err)
  5308. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5309. // return
  5310. // }
  5311. // if res.Infcode != 0 {
  5312. // errlog := &models.HisOrderError{
  5313. // UserOrgId: adminUser.CurrentOrgId,
  5314. // Ctime: time.Now().Unix(),
  5315. // Mtime: time.Now().Unix(),
  5316. // Number: chrg_bchno,
  5317. // ErrMsg: res.ErrMsg,
  5318. // Status: 1,
  5319. // PatientId: id,
  5320. // RecordTime: recordDateTime,
  5321. // Stage: 7,
  5322. // }
  5323. // service.CreateErrMsgLog(errlog)
  5324. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5325. // return
  5326. // } else {
  5327. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5328. // order.OrderStatus = 1
  5329. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5330. // order.SetlId = res.Output.Setlinfo.SetlID
  5331. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5332. // order.PsnName = res.Output.Setlinfo.PsnName
  5333. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5334. // order.Certno = res.Output.Setlinfo.Certno
  5335. // order.Gend = res.Output.Setlinfo.Gend
  5336. // order.Naty = res.Output.Setlinfo.Naty
  5337. // order.Age = res.Output.Setlinfo.Age
  5338. // order.Insutype = res.Output.Setlinfo.Insutype
  5339. // order.PsnType = res.Output.Setlinfo.PsnType
  5340. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5341. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5342. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5343. // order.MedType = res.Output.Setlinfo.MedType
  5344. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5345. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5346. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5347. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5348. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5349. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5350. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5351. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5352. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5353. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5354. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5355. // order.MafPay = res.Output.Setlinfo.MafPay
  5356. // order.OthPay = res.Output.Setlinfo.OthPay
  5357. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5358. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5359. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5360. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5361. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5362. // order.Balc = res.Output.Setlinfo.Balc
  5363. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5364. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5365. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5366. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5367. // order.Creator = order.Creator
  5368. // order.Modify = roles.ID
  5369. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5370. // detailStr := string(setlDetail)
  5371. // order.SetlDetail = detailStr
  5372. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5373. // err = service.UpDateOrder(order)
  5374. // if err == nil {
  5375. // c.ServeSuccessJSON(map[string]interface{}{
  5376. // "msg": "预结算成功",
  5377. // })
  5378. // } else {
  5379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5380. // return
  5381. // }
  5382. // }
  5383. // } else {
  5384. // adminUser := c.GetAdminUserInfo()
  5385. // errlog := &models.HisOrderError{
  5386. // UserOrgId: adminUser.CurrentOrgId,
  5387. // Ctime: time.Now().Unix(),
  5388. // Mtime: time.Now().Unix(),
  5389. // ErrMsg: res.ErrMsg,
  5390. // Status: 1,
  5391. // PatientId: id,
  5392. // RecordTime: recordDateTime,
  5393. // Stage: 4,
  5394. // }
  5395. // service.CreateErrMsgLog(errlog)
  5396. //
  5397. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5398. // return
  5399. // }
  5400. // } else {
  5401. // adminUser := c.GetAdminUserInfo()
  5402. // errlog := &models.HisOrderError{
  5403. // UserOrgId: adminUser.CurrentOrgId,
  5404. // Ctime: time.Now().Unix(),
  5405. // Mtime: time.Now().Unix(),
  5406. // ErrMsg: res.ErrMsg,
  5407. // Status: 1,
  5408. // PatientId: id,
  5409. // RecordTime: recordDateTime,
  5410. // Stage: 4,
  5411. // }
  5412. // service.CreateErrMsgLog(errlog)
  5413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5414. // return
  5415. // }
  5416. //
  5417. // } else {
  5418. // var total float64
  5419. // for _, item := range prescriptions {
  5420. // if item.Type == 1 { //药品
  5421. // for _, subItem := range item.HisDoctorAdviceInfo {
  5422. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5423. // }
  5424. // }
  5425. // if item.Type == 2 { //项目
  5426. // for _, subItem := range item.HisPrescriptionProject {
  5427. // total = total + (subItem.Price * float64(subItem.Count))
  5428. // }
  5429. // }
  5430. //
  5431. // for _, subItem := range item.HisAdditionalCharge {
  5432. // total = total + (subItem.Price * float64(subItem.Count))
  5433. // }
  5434. // }
  5435. //
  5436. // allTotal := fmt.Sprintf("%.2f", total)
  5437. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5438. // order := &models.HisOrder{
  5439. // UserOrgId: adminUser.CurrentOrgId,
  5440. // HisPatientId: his.ID,
  5441. // PatientId: id,
  5442. // SettleAccountsDate: recordDateTime,
  5443. // Ctime: time.Now().Unix(),
  5444. // Mtime: time.Now().Unix(),
  5445. // Status: 1,
  5446. // OrderStatus: 2,
  5447. // Number: chrg_bchno,
  5448. // MedfeeSumamt: totals,
  5449. // }
  5450. // err = service.CreateOrder(order)
  5451. // if err != nil {
  5452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5453. // return
  5454. // }
  5455. //
  5456. // var customs []*Custom
  5457. // for _, item := range prescriptions {
  5458. //
  5459. // if item.Type == 1 { //药品
  5460. // for _, subItem := range item.HisDoctorAdviceInfo {
  5461. // cus := &Custom{
  5462. // AdviceId: subItem.ID,
  5463. // ProjectId: 0,
  5464. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5465. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5466. // FeedetlSn: subItem.FeedetlSn,
  5467. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5468. // MedListCodg: subItem.MedListCodg,
  5469. // Type: 1,
  5470. // }
  5471. // customs = append(customs, cus)
  5472. // }
  5473. // }
  5474. //
  5475. // if item.Type == 2 { //项目
  5476. // for _, subItem := range item.HisPrescriptionProject {
  5477. //
  5478. // cus := &Custom{
  5479. // AdviceId: 0,
  5480. // ProjectId: subItem.ID,
  5481. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5482. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5483. // FeedetlSn: subItem.FeedetlSn,
  5484. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5485. // MedListCodg: subItem.MedListCodg,
  5486. // Type: 2,
  5487. // }
  5488. //
  5489. // customs = append(customs, cus)
  5490. // }
  5491. // }
  5492. //
  5493. // for _, item := range item.HisAdditionalCharge {
  5494. // cus := &Custom{
  5495. // ItemId: item.ID,
  5496. // AdviceId: 0,
  5497. // ProjectId: 0,
  5498. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5499. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5500. // FeedetlSn: item.FeedetlSn,
  5501. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5502. // MedListCodg: item.XtHisAddtionConfig.Code,
  5503. // Type: 3,
  5504. // }
  5505. //
  5506. // customs = append(customs, cus)
  5507. // }
  5508. //
  5509. // }
  5510. //
  5511. // for _, item := range customs {
  5512. // var advice_id int64 = 0
  5513. // var project_id int64 = 0
  5514. // var item_id int64 = 0
  5515. //
  5516. // var types int64 = 0
  5517. //
  5518. // if item.Type == 1 {
  5519. // advice_id = item.AdviceId
  5520. // project_id = 0
  5521. // item_id = 0
  5522. // } else if item.Type == 2 {
  5523. // advice_id = 0
  5524. // item_id = 0
  5525. //
  5526. // project_id = item.ProjectId
  5527. // } else if item.Type == 3 {
  5528. // advice_id = 0
  5529. // item_id = item.ItemId
  5530. // project_id = 0
  5531. // }
  5532. //
  5533. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5534. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5535. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5536. //
  5537. // info := &models.HisOrderInfo{
  5538. // OrderNumber: order.Number,
  5539. // UploadDate: time.Now().Unix(),
  5540. // AdviceId: advice_id,
  5541. // DetItemFeeSumamt: detItemFeeSumamt,
  5542. // Cnt: cut,
  5543. // Pric: pric,
  5544. // PatientId: id,
  5545. // Status: 1,
  5546. // Mtime: time.Now().Unix(),
  5547. // Ctime: time.Now().Unix(),
  5548. // UserOrgId: adminUser.CurrentOrgId,
  5549. // HisPatientId: his.ID,
  5550. // OrderId: order.ID,
  5551. // ProjectId: project_id,
  5552. // Type: types,
  5553. // ItemId: item_id,
  5554. // }
  5555. // service.CreateOrderInfo(info)
  5556. // }
  5557. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5558. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5559. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5560. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5561. // if err == nil {
  5562. // c.ServeSuccessJSON(map[string]interface{}{
  5563. // "msg": "结算成功",
  5564. // })
  5565. // } else {
  5566. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5567. // return
  5568. // }
  5569. // }
  5570. //}
  5571. //上传明细-预结算-
  5572. func (c *HisApiController) GetPreUploadInfo() {
  5573. id, _ := c.GetInt64("id")
  5574. record_time := c.GetString("record_time")
  5575. his_patient_id, _ := c.GetInt64("his_patient_id")
  5576. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5577. admin_user_id, _ := c.GetInt64("admin_user_id")
  5578. diagnosis_id := c.GetString("diagnosis")
  5579. sick_type, _ := c.GetInt64("sick_type")
  5580. reg_type, _ := c.GetInt64("p_type")
  5581. begin_time := c.GetString("begin_time")
  5582. id_str := c.GetString("ids")
  5583. ids_arr := strings.Split(id_str, ",")
  5584. timeLayout := "2006-01-02"
  5585. loc, _ := time.LoadLocation("Local")
  5586. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5587. if err != nil {
  5588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5589. return
  5590. }
  5591. recordDateTime := theTime.Unix()
  5592. adminUser := c.GetAdminUserInfo()
  5593. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5594. var config []*models.HisXtDiagnoseConfig
  5595. for _, item := range diagnosis_ids {
  5596. id, _ := strconv.ParseInt(item, 10, 64)
  5597. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5598. config = append(config, &diagnosisConfig)
  5599. }
  5600. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5601. sickConfig, _ := service.FindSickById(sick_type)
  5602. var prescriptions []*models.HisPrescription
  5603. var start_time int64
  5604. var end_time int64
  5605. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5606. fmt.Println(his_patient_id)
  5607. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5608. timestamp := time.Now().Unix()
  5609. tempTime := time.Unix(timestamp, 0)
  5610. timeFormat := tempTime.Format("20060102150405")
  5611. chrgBchno := rand.Intn(100000) + 10000
  5612. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5613. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5614. var patientPrescription models.HisPrescriptionInfo
  5615. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5616. if patientPrescription.ID == 0 {
  5617. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5618. }
  5619. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5620. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5621. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5622. strconv.FormatInt(his.PatientId, 10)
  5623. var res2 ResultSix
  5624. var resSix10265 ResultSix10265
  5625. var time_stamp string
  5626. if miConfig.MdtrtareaAdmvs == "421300" {
  5627. data := make(map[string]interface{})
  5628. client := &http.Client{}
  5629. data["psn_no"] = his.PsnNo
  5630. data["mdtrt_id"] = his.Number
  5631. data["doctor"] = roles.UserName
  5632. data["department"] = department.Name
  5633. data["org_name"] = miConfig.OrgName
  5634. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5635. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5636. data["fixmedins_code"] = miConfig.Code
  5637. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5638. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5639. data["secret_key"] = miConfig.SecretKey
  5640. data["sick_code"] = sickConfig.CountryCode
  5641. data["sick_name"] = sickConfig.ClassName
  5642. data["begin_time"] = begin_time
  5643. data["dept"] = strconv.FormatInt(department.ID, 10)
  5644. data["config"] = config
  5645. fmt.Println(data)
  5646. bytesData, _ := json.Marshal(data)
  5647. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5648. resp, _ := client.Do(req)
  5649. defer resp.Body.Close()
  5650. body, ioErr := ioutil.ReadAll(resp.Body)
  5651. if ioErr != nil {
  5652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5654. return
  5655. }
  5656. var respJSON map[string]interface{}
  5657. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5660. return
  5661. }
  5662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5663. userJSONBytes, _ := json.Marshal(respJSON)
  5664. fmt.Println("log")
  5665. fmt.Println(string(userJSONBytes))
  5666. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5667. utils.ErrorLog("解析失败:%v", err)
  5668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5669. return
  5670. }
  5671. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5672. //江苏地区国家医保医疗类别
  5673. //职工透析:医疗类别选特殊情况门诊9933
  5674. //居民血透门慢: 医疗类别选门诊慢病1402
  5675. //var med_type string
  5676. //if his.Insutype == "310" {
  5677. // if reg_type == 14 {
  5678. // med_type = "9933"
  5679. // } else if reg_type == 11 {
  5680. // med_type = "11"
  5681. //
  5682. // }
  5683. //} else if his.Insutype == "390" {
  5684. // if reg_type == 14 {
  5685. // med_type = "1402"
  5686. // } else if reg_type == 11 {
  5687. // med_type = "11"
  5688. // }
  5689. //}
  5690. data := make(map[string]interface{})
  5691. client := &http.Client{}
  5692. data["psn_no"] = his.PsnNo
  5693. data["mdtrt_id"] = his.Number
  5694. data["doctor"] = roles.UserName
  5695. data["department"] = department.Name
  5696. data["org_name"] = miConfig.OrgName
  5697. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5698. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5699. data["fixmedins_code"] = miConfig.Code
  5700. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5701. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5702. data["secret_key"] = miConfig.SecretKey
  5703. data["sick_code"] = sickConfig.CountryCode
  5704. data["sick_name"] = sickConfig.ClassName
  5705. data["begin_time"] = begin_time
  5706. data["dept"] = strconv.FormatInt(department.ID, 10)
  5707. data["config"] = config
  5708. data["url"] = miConfig.Url
  5709. data["ak"] = miConfig.AccessKey
  5710. data["cainfo"] = miConfig.Cainfo
  5711. bytesData, _ := json.Marshal(data)
  5712. var req *http.Request
  5713. if miConfig.MdtrtareaAdmvs == "320921" {
  5714. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5715. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5716. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5717. } else {
  5718. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5719. }
  5720. resp, _ := client.Do(req)
  5721. defer resp.Body.Close()
  5722. body, ioErr := ioutil.ReadAll(resp.Body)
  5723. if ioErr != nil {
  5724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5726. return
  5727. }
  5728. var respJSON map[string]interface{}
  5729. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5732. return
  5733. }
  5734. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5735. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5736. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5737. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5738. userJSONBytes, _ := json.Marshal(respJSON)
  5739. fmt.Println("log")
  5740. fmt.Println(string(userJSONBytes))
  5741. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5742. utils.ErrorLog("解析失败:%v", err)
  5743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5744. return
  5745. }
  5746. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5747. res2.Output = resSix10265.Output
  5748. res2.ErrMsg = resSix10265.ErrMsg
  5749. res2.Cainfo = resSix10265.Cainfo
  5750. res2.WarnMsg = resSix10265.WarnMsg
  5751. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5752. res2.Infcode = infocode
  5753. } else {
  5754. var result string
  5755. var requestLog string
  5756. if miConfig.MdtrtareaAdmvs == "440781" { //
  5757. 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)
  5758. } else {
  5759. if miConfig.Code == "H15049901371" {
  5760. //赤峰地区国家医保医疗类别
  5761. //职工透析:医疗类别选特殊情况门诊990502
  5762. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5763. var med_type string
  5764. if his.Insutype == "390" {
  5765. if reg_type == 14 {
  5766. med_type = "9933"
  5767. } else if reg_type == 11 {
  5768. med_type = "11"
  5769. }
  5770. } else if his.Insutype == "310" {
  5771. if reg_type == 14 {
  5772. med_type = "990502"
  5773. } else if reg_type == 11 {
  5774. med_type = "11"
  5775. }
  5776. }
  5777. 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)
  5778. } else {
  5779. 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)
  5780. }
  5781. saveLog(result, requestLog, "2203", "上传就诊信息")
  5782. var respJSON2 map[string]interface{}
  5783. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5786. return
  5787. }
  5788. userJSONBytes2, _ := json.Marshal(respJSON2)
  5789. if miConfig.Code == "H15049901371" {
  5790. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5791. utils.ErrorLog("解析失败:%v", err)
  5792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5793. return
  5794. }
  5795. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5796. res2.Output = resSix10265.Output
  5797. res2.ErrMsg = resSix10265.ErrMsg
  5798. res2.Cainfo = resSix10265.Cainfo
  5799. res2.WarnMsg = resSix10265.WarnMsg
  5800. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5801. res2.Infcode = infocode
  5802. } else {
  5803. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5804. utils.ErrorLog("解析失败:%v", err)
  5805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5806. return
  5807. }
  5808. }
  5809. }
  5810. }
  5811. if res2.Infcode != 0 {
  5812. adminUser := c.GetAdminUserInfo()
  5813. errlog := &models.HisOrderError{
  5814. UserOrgId: adminUser.CurrentOrgId,
  5815. Ctime: time.Now().Unix(),
  5816. Mtime: time.Now().Unix(),
  5817. ErrMsg: res2.ErrMsg,
  5818. Status: 1,
  5819. PatientId: id,
  5820. RecordTime: recordDateTime,
  5821. Stage: 3,
  5822. }
  5823. service.CreateErrMsgLog(errlog)
  5824. c.ServeSuccessJSON(map[string]interface{}{
  5825. "failed_code": -10,
  5826. "msg": res2.ErrMsg,
  5827. })
  5828. return
  5829. } else {
  5830. his.Diagnosis = diagnosis_id
  5831. his.SickType = sickConfig.ID
  5832. his.PType = fmt.Sprintf("%d", reg_type)
  5833. service.UpdateHisPatientThree(&his)
  5834. data := make(map[string]interface{})
  5835. if settle_accounts_type == 1 { //日结
  5836. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5837. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5838. } else {
  5839. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5840. }
  5841. data["pre"] = prescriptions
  5842. } else { //月结
  5843. start_time_str := c.GetString("start_time")
  5844. end_time_str := c.GetString("end_time")
  5845. timeLayout := "2006-01-02"
  5846. loc, _ := time.LoadLocation("Local")
  5847. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5848. if err != nil {
  5849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5850. return
  5851. }
  5852. recordStartTime := theStartTime.Unix()
  5853. start_time = recordStartTime
  5854. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5855. if err != nil {
  5856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5857. return
  5858. }
  5859. recordEndTime := theEndTime.Unix()
  5860. end_time = recordEndTime
  5861. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5862. data["pre"] = prescriptions
  5863. }
  5864. client := &http.Client{}
  5865. data["psn_no"] = his.PsnNo
  5866. data["mdtrt_id"] = his.Number
  5867. data["chrg_bchno"] = chrg_bchno
  5868. data["org_name"] = miConfig.OrgName
  5869. data["doctor"] = roles.UserName
  5870. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5871. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5872. data["fixmedins_code"] = miConfig.Code
  5873. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5874. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5875. data["dept_code"] = "15"
  5876. } else {
  5877. data["dept_code"] = department.Number
  5878. }
  5879. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5880. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5881. data["secret_key"] = miConfig.SecretKey
  5882. data["url"] = miConfig.Url
  5883. data["ak"] = miConfig.AccessKey
  5884. data["new_doctor_name"] = patientPrescription.Doctor
  5885. data["diag_code"] = sickConfig.CountryCode
  5886. data["time_stamp"] = time_stamp
  5887. data["cainfo"] = miConfig.Cainfo
  5888. var ids []int64
  5889. for _, item := range prescriptions {
  5890. ids = append(ids, item.ID)
  5891. }
  5892. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5893. if config.IsOpen == 1 { //对接了医保,走医保流程
  5894. var res ResultFour
  5895. var resFour10265 ResultFour10265
  5896. if miConfig.MdtrtareaAdmvs == "421300" {
  5897. bytesData, _ := json.Marshal(data)
  5898. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5899. resp, _ := client.Do(req)
  5900. defer resp.Body.Close()
  5901. body, ioErr := ioutil.ReadAll(resp.Body)
  5902. if ioErr != nil {
  5903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5905. return
  5906. }
  5907. var respJSON map[string]interface{}
  5908. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5911. return
  5912. }
  5913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5914. userJSONBytes, _ := json.Marshal(respJSON)
  5915. fmt.Println("log")
  5916. fmt.Println(string(userJSONBytes))
  5917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5918. utils.ErrorLog("解析失败:%v", err)
  5919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5920. return
  5921. }
  5922. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5923. bytesData, _ := json.Marshal(data)
  5924. var req *http.Request
  5925. if miConfig.MdtrtareaAdmvs == "320921" {
  5926. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5927. } else {
  5928. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5929. }
  5930. resp, _ := client.Do(req)
  5931. defer resp.Body.Close()
  5932. body, ioErr := ioutil.ReadAll(resp.Body)
  5933. if ioErr != nil {
  5934. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5936. return
  5937. }
  5938. var respJSON map[string]interface{}
  5939. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5942. return
  5943. }
  5944. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5945. userJSONBytes, _ := json.Marshal(respJSON)
  5946. fmt.Println("log")
  5947. fmt.Println(string(userJSONBytes))
  5948. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5949. utils.ErrorLog("解析失败:%v", err)
  5950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5951. return
  5952. }
  5953. res.InfRefmsgid = resFour10265.InfRefmsgid
  5954. res.Output = resFour10265.Output
  5955. res.ErrMsg = resFour10265.ErrMsg
  5956. res.Cainfo = resFour10265.Cainfo
  5957. res.WarnMsg = resFour10265.WarnMsg
  5958. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5959. res.Infcode = infocode
  5960. } else {
  5961. if miConfig.Code == "H15049901371" {
  5962. 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)
  5963. var dat map[string]interface{}
  5964. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5965. fmt.Println(dat)
  5966. } else {
  5967. fmt.Println(err)
  5968. }
  5969. saveLog(result, request_log, "2204", "上传费用明细")
  5970. userJSONBytes, _ := json.Marshal(dat)
  5971. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5972. utils.ErrorLog("解析失败:%v", err)
  5973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5974. return
  5975. }
  5976. res.InfRefmsgid = resFour10265.InfRefmsgid
  5977. res.Output = resFour10265.Output
  5978. res.ErrMsg = resFour10265.ErrMsg
  5979. res.Cainfo = resFour10265.Cainfo
  5980. res.WarnMsg = resFour10265.WarnMsg
  5981. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5982. res.Infcode = infocode
  5983. } else {
  5984. 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)
  5985. var dat map[string]interface{}
  5986. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5987. fmt.Println(dat)
  5988. } else {
  5989. fmt.Println(err)
  5990. }
  5991. saveLog(result, request_log, "2204", "上传费用明细")
  5992. userJSONBytes, _ := json.Marshal(dat)
  5993. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5994. utils.ErrorLog("解析失败:%v", err)
  5995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5996. return
  5997. }
  5998. }
  5999. }
  6000. if res.Infcode == 0 {
  6001. order := &models.HisOrder{
  6002. UserOrgId: adminUser.CurrentOrgId,
  6003. HisPatientId: his.ID,
  6004. PatientId: his.PatientId,
  6005. SettleAccountsDate: recordDateTime,
  6006. Ctime: time.Now().Unix(),
  6007. Mtime: time.Now().Unix(),
  6008. MdtrtId: his.Number,
  6009. PsnNo: his.PsnNo,
  6010. MedType: strconv.FormatInt(reg_type, 10),
  6011. Status: 1,
  6012. Number: chrg_bchno,
  6013. Infcode: res.Infcode,
  6014. WarnMsg: res.WarnMsg,
  6015. Cainfo: res.Cainfo,
  6016. ErrMsg: res.ErrMsg,
  6017. RespondTime: res.RefmsgTime,
  6018. InfRefmsgid: res.InfRefmsgid,
  6019. OrderStatus: 1,
  6020. IsMedicineInsurance: 1,
  6021. SettleType: settle_accounts_type,
  6022. SettleStartTime: start_time,
  6023. SettleEndTime: end_time,
  6024. Creator: roles.AdminUserId,
  6025. Modify: roles.AdminUserId,
  6026. PType: 2,
  6027. Diagnosis: diagnosis_id,
  6028. }
  6029. err = service.CreateOrder(order)
  6030. if err != nil {
  6031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6032. return
  6033. }
  6034. for _, item := range res.Output.Result {
  6035. temp := strings.Split(item.FeedetlSn, "-")
  6036. var advice_id int64 = 0
  6037. var project_id int64 = 0
  6038. var types int64 = 0
  6039. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6040. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6041. if temp[1] == "1" {
  6042. advice_id = id
  6043. project_id = 0
  6044. } else if temp[1] == "2" {
  6045. advice_id = 0
  6046. project_id = id
  6047. }
  6048. info := &models.HisOrderInfo{
  6049. OrderNumber: order.Number,
  6050. FeedetlSn: item.FeedetlSn,
  6051. UploadDate: time.Now().Unix(),
  6052. AdviceId: advice_id,
  6053. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6054. Cnt: item.Cnt,
  6055. Pric: float64(item.Pric),
  6056. PatientId: his.PatientId,
  6057. PricUplmtAmt: item.PricUplmtAmt,
  6058. SelfpayProp: item.SelfpayProp,
  6059. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6060. OverlmtAmt: item.OverlmtAmt,
  6061. PreselfpayAmt: item.PreselfpayAmt,
  6062. BasMednFlag: item.BasMednFlag,
  6063. MedChrgitmType: item.MedChrgitmType,
  6064. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6065. Status: 1,
  6066. Memo: item.Memo,
  6067. Mtime: time.Now().Unix(),
  6068. InscpScpAmt: item.InscpScpAmt,
  6069. DrtReimFlag: item.DrtReimFlag,
  6070. Ctime: time.Now().Unix(),
  6071. ListSpItemFlag: item.ListSpItemFlag,
  6072. ChldMedcFlag: item.ChldMedcFlag,
  6073. LmtUsedFlag: item.LmtUsedFlag,
  6074. ChrgitmLv: item.ChrgitmLv,
  6075. UserOrgId: adminUser.CurrentOrgId,
  6076. HisPatientId: his.ID,
  6077. OrderId: order.ID,
  6078. ProjectId: project_id,
  6079. Type: types,
  6080. }
  6081. service.CreateOrderInfo(info)
  6082. }
  6083. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6084. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6085. var total float64
  6086. for _, item := range prescriptions {
  6087. if item.Type == 1 { //药品
  6088. for _, subItem := range item.HisDoctorAdviceInfo {
  6089. total = total + (subItem.Price * subItem.PrescribingNumber)
  6090. }
  6091. }
  6092. if item.Type == 2 { //项目
  6093. for _, subItem := range item.HisPrescriptionProject {
  6094. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6095. total = total + (subItem.Price * cnt)
  6096. }
  6097. }
  6098. }
  6099. for _, item := range prescriptions {
  6100. for _, subItem := range item.HisAdditionalCharge {
  6101. total = total + (subItem.Price * float64(subItem.Count))
  6102. }
  6103. }
  6104. allTotal := fmt.Sprintf("%.4f", total)
  6105. if res.Infcode == 0 {
  6106. var rf []*ResultFive
  6107. json.Unmarshal([]byte(his.Iinfo), &rf)
  6108. chrg_bchno := chrg_bchno
  6109. cert_no := his.Certno
  6110. var insutypes []string
  6111. var insutype string
  6112. var is390 int = 0
  6113. var is310 int = 0
  6114. for _, item := range rf {
  6115. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6116. insutypes = append(insutypes, item.Insutype)
  6117. }
  6118. }
  6119. if len(insutypes) == 1 {
  6120. insutype = insutypes[0]
  6121. } else {
  6122. for _, i := range insutypes {
  6123. if i == "390" {
  6124. is390 = 1
  6125. }
  6126. if i == "310" {
  6127. is310 = 1
  6128. }
  6129. }
  6130. }
  6131. if is390 == 1 {
  6132. insutype = "390"
  6133. }
  6134. if is310 == 1 {
  6135. insutype = "310"
  6136. }
  6137. if len(insutypes) == 0 {
  6138. insutype = "310"
  6139. }
  6140. if len(insutypes) == 2 {
  6141. insutype = strconv.FormatInt(his.SocialType, 64)
  6142. }
  6143. //insutype = "390"
  6144. if his.IdCardType == 1 {
  6145. cert_no = his.MedicalInsuranceNumber
  6146. } else {
  6147. cert_no = his.Certno
  6148. }
  6149. var res ResultSeven
  6150. var resSeven10265 ResultSeven10265
  6151. if miConfig.MdtrtareaAdmvs == "421300" {
  6152. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6153. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6154. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6155. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6156. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6157. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6158. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6159. resp, requestErr := http.Get(api)
  6160. if requestErr != nil {
  6161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6162. return
  6163. }
  6164. body, ioErr := ioutil.ReadAll(resp.Body)
  6165. if ioErr != nil {
  6166. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6168. return
  6169. }
  6170. var respJSON map[string]interface{}
  6171. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6172. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6174. return
  6175. }
  6176. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6177. result, _ := json.Marshal(respJSON)
  6178. fmt.Println("log")
  6179. fmt.Println(string(result))
  6180. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6181. utils.ErrorLog("解析失败:%v", err)
  6182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6183. return
  6184. }
  6185. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6186. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6187. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6188. bas := strings.Split(psn_info.CardInfo, "|")
  6189. if his.IdCardType == 1 {
  6190. cert_no = bas[2]
  6191. } else {
  6192. cert_no = bas[1]
  6193. }
  6194. //江苏地区国家医保医疗类别
  6195. //职工透析:医疗类别选特殊情况门诊9933
  6196. //居民血透门慢: 医疗类别选门诊慢病1402
  6197. //var med_type string
  6198. //if his.Insutype == "310" {
  6199. // if reg_type == 14 {
  6200. // med_type = "9933"
  6201. // } else if reg_type == 11 {
  6202. // med_type = "11"
  6203. //
  6204. // }
  6205. //} else if his.Insutype == "390" {
  6206. // if reg_type == 14 {
  6207. // med_type = "1402"
  6208. // } else if reg_type == 11 {
  6209. // med_type = "11"
  6210. // }
  6211. //}
  6212. var api string
  6213. if miConfig.MdtrtareaAdmvs == "320921" {
  6214. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6215. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6216. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6217. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6218. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6219. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6220. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6221. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6222. } else {
  6223. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6224. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6225. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6226. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6227. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6228. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6229. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6230. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6231. }
  6232. resp, requestErr := http.Get(api)
  6233. if requestErr != nil {
  6234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6235. return
  6236. }
  6237. body, ioErr := ioutil.ReadAll(resp.Body)
  6238. if ioErr != nil {
  6239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6241. return
  6242. }
  6243. var respJSON map[string]interface{}
  6244. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6247. return
  6248. }
  6249. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6250. result, _ := json.Marshal(respJSON)
  6251. fmt.Println("log")
  6252. fmt.Println(string(result))
  6253. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6254. utils.ErrorLog("解析失败:%v", err)
  6255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6256. return
  6257. }
  6258. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6259. res.Output = resSeven10265.Output
  6260. res.ErrMsg = resSeven10265.ErrMsg
  6261. res.Cainfo = resSeven10265.Cainfo
  6262. res.WarnMsg = resSeven10265.WarnMsg
  6263. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6264. res.Infcode = infocode
  6265. } else {
  6266. var result string
  6267. var request_log string
  6268. if miConfig.Code == "H15049901371" {
  6269. //赤峰地区国家医保医疗类别
  6270. //职工透析:医疗类别选特殊情况门诊990502
  6271. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6272. var med_type string
  6273. if his.Insutype == "390" {
  6274. if reg_type == 14 {
  6275. med_type = "9933"
  6276. } else if reg_type == 11 {
  6277. med_type = "11"
  6278. }
  6279. } else if his.Insutype == "310" {
  6280. if reg_type == 14 {
  6281. med_type = "990502"
  6282. } else if reg_type == 11 {
  6283. med_type = "11"
  6284. }
  6285. }
  6286. 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)
  6287. } else {
  6288. 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, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  6289. }
  6290. var dat map[string]interface{}
  6291. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6292. fmt.Println(dat)
  6293. } else {
  6294. fmt.Println(err)
  6295. }
  6296. saveLog(result, request_log, "2206", "预结算")
  6297. //userJSONBytes, _ := json.Marshal(dat)
  6298. //
  6299. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6300. // utils.ErrorLog("解析失败:%v", err)
  6301. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6302. // return
  6303. //}
  6304. userJSONBytes, _ := json.Marshal(dat)
  6305. if miConfig.Code == "H15049901371" {
  6306. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6307. utils.ErrorLog("解析失败:%v", err)
  6308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6309. return
  6310. }
  6311. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6312. res.Output = resSeven10265.Output
  6313. res.ErrMsg = resSeven10265.ErrMsg
  6314. res.Cainfo = resSeven10265.Cainfo
  6315. res.WarnMsg = resSeven10265.WarnMsg
  6316. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6317. res.Infcode = infocode
  6318. } else {
  6319. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6320. utils.ErrorLog("解析失败:%v", err)
  6321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6322. return
  6323. }
  6324. }
  6325. }
  6326. if res.Infcode != 0 {
  6327. errlog := &models.HisOrderError{
  6328. UserOrgId: adminUser.CurrentOrgId,
  6329. Ctime: time.Now().Unix(),
  6330. Mtime: time.Now().Unix(),
  6331. Number: chrg_bchno,
  6332. ErrMsg: res.ErrMsg,
  6333. Status: 1,
  6334. PatientId: id,
  6335. RecordTime: recordDateTime,
  6336. Stage: 20,
  6337. }
  6338. service.CreateErrMsgLog(errlog)
  6339. c.ServeSuccessJSON(map[string]interface{}{
  6340. "failed_code": -10,
  6341. "msg": res.ErrMsg,
  6342. })
  6343. return
  6344. } else {
  6345. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6346. order.OrderStatus = 1
  6347. order.IsPre = 1
  6348. order.Status = 1
  6349. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6350. order.SetlId = res.Output.Setlinfo.SetlID
  6351. order.PsnNo = res.Output.Setlinfo.PsnNo
  6352. order.PsnName = res.Output.Setlinfo.PsnName
  6353. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6354. order.Certno = res.Output.Setlinfo.Certno
  6355. order.Gend = res.Output.Setlinfo.Gend
  6356. order.Naty = res.Output.Setlinfo.Naty
  6357. order.Age = res.Output.Setlinfo.Age
  6358. order.Insutype = res.Output.Setlinfo.Insutype
  6359. order.PsnType = res.Output.Setlinfo.PsnType
  6360. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6361. order.SetlTime = res.Output.Setlinfo.SetlTime
  6362. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6363. if res.Output.Setlinfo.MedType == "140101" {
  6364. order.MedType = "14"
  6365. } else {
  6366. order.MedType = res.Output.Setlinfo.MedType
  6367. }
  6368. if reg_type == 1112 {
  6369. order.MedType = "1112"
  6370. }
  6371. if reg_type == 1111 {
  6372. order.MedType = "1111"
  6373. }
  6374. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6375. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6376. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6377. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6378. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6379. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6380. order.HifpPay = res.Output.Setlinfo.HifpPay
  6381. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6382. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6383. order.HifesPay = res.Output.Setlinfo.HifesPay
  6384. order.HifobPay = res.Output.Setlinfo.HifobPay
  6385. order.MafPay = res.Output.Setlinfo.MafPay
  6386. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6387. order.OthPay = res.Output.Setlinfo.OthPay
  6388. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6389. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6390. order.AcctPay = res.Output.Setlinfo.AcctPay
  6391. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6392. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6393. order.Balc = res.Output.Setlinfo.Balc
  6394. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6395. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6396. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6397. order.ClrWay = res.Output.Setlinfo.ClrWay
  6398. order.Creator = order.Creator
  6399. order.Modify = roles.AdminUserId
  6400. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6401. detailStr := string(setlDetail)
  6402. order.SetlDetail = detailStr
  6403. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6404. err = service.UpDateOrder(order)
  6405. if err == nil {
  6406. c.ServeSuccessJSON(map[string]interface{}{
  6407. "msg": "预结算成功",
  6408. })
  6409. } else {
  6410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6411. return
  6412. }
  6413. }
  6414. } else {
  6415. adminUser := c.GetAdminUserInfo()
  6416. errlog := &models.HisOrderError{
  6417. UserOrgId: adminUser.CurrentOrgId,
  6418. Ctime: time.Now().Unix(),
  6419. Mtime: time.Now().Unix(),
  6420. ErrMsg: res.ErrMsg,
  6421. Status: 1,
  6422. PatientId: id,
  6423. RecordTime: recordDateTime,
  6424. Stage: 4,
  6425. }
  6426. service.CreateErrMsgLog(errlog)
  6427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6428. return
  6429. }
  6430. } else {
  6431. adminUser := c.GetAdminUserInfo()
  6432. errlog := &models.HisOrderError{
  6433. UserOrgId: adminUser.CurrentOrgId,
  6434. Ctime: time.Now().Unix(),
  6435. Mtime: time.Now().Unix(),
  6436. ErrMsg: res.ErrMsg,
  6437. Status: 1,
  6438. PatientId: id,
  6439. RecordTime: recordDateTime,
  6440. Stage: 4,
  6441. }
  6442. service.CreateErrMsgLog(errlog)
  6443. c.ServeSuccessJSON(map[string]interface{}{
  6444. "failed_code": -10,
  6445. "msg": res.ErrMsg,
  6446. })
  6447. return
  6448. }
  6449. }
  6450. }
  6451. }
  6452. //func (c *HisApiController) GetSettleInfo() {
  6453. // id, _ := c.GetInt64("id")
  6454. // order_id, _ := c.GetInt64("order_id")
  6455. //
  6456. // record_time := c.GetString("record_time")
  6457. // pay_way, _ := c.GetInt64("pay_way")
  6458. // pay_price, _ := c.GetFloat("pay_price")
  6459. // pay_card_no := c.GetString("pay_card_no")
  6460. // discount_price, _ := c.GetFloat("discount_price")
  6461. // preferential_price, _ := c.GetFloat("preferential_price")
  6462. // reality_price, _ := c.GetFloat("reality_price")
  6463. // found_price, _ := c.GetFloat("found_price")
  6464. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6465. // private_price, _ := c.GetFloat("private_price")
  6466. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6467. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6468. //
  6469. // timeLayout := "2006-01-02"
  6470. // loc, _ := time.LoadLocation("Local")
  6471. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6472. // if err != nil {
  6473. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6474. // return
  6475. // }
  6476. // recordDateTime := theTime.Unix()
  6477. // adminUser := c.GetAdminUserInfo()
  6478. //
  6479. // var prescriptions []*models.HisPrescription
  6480. //
  6481. // data := make(map[string]interface{})
  6482. // if settle_accounts_type == 1 { //日结
  6483. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6484. // data["pre"] = prescriptions
  6485. //
  6486. // } else { //月结
  6487. // start_time_str := c.GetString("start_time")
  6488. // end_time_str := c.GetString("end_time")
  6489. // timeLayout := "2006-01-02"
  6490. // loc, _ := time.LoadLocation("Local")
  6491. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6492. // if err != nil {
  6493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6494. // return
  6495. // }
  6496. // recordStartTime := theStartTime.Unix()
  6497. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6498. // if err != nil {
  6499. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6500. // return
  6501. // }
  6502. // recordEndTime := theEndTime.Unix()
  6503. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6504. // data["pre"] = prescriptions
  6505. //
  6506. // }
  6507. //
  6508. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6509. //
  6510. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6511. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6512. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6513. // strconv.FormatInt(his.PatientId, 10)
  6514. //
  6515. // order_src, _ := service.GetHisOrderByID(order_id)
  6516. //
  6517. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6518. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6519. //
  6520. // var total float64
  6521. // for _, item := range prescriptions {
  6522. // if item.Type == 1 { //药品
  6523. // for _, subItem := range item.HisDoctorAdviceInfo {
  6524. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6525. // }
  6526. // }
  6527. // if item.Type == 2 { //项目
  6528. // for _, subItem := range item.HisPrescriptionProject {
  6529. // total = total + (subItem.Price * float64(subItem.Count))
  6530. // }
  6531. // }
  6532. // }
  6533. //
  6534. // for _, item := range prescriptions {
  6535. // for _, subItem := range item.HisAdditionalCharge {
  6536. // total = total + (subItem.Price * float64(subItem.Count))
  6537. // }
  6538. // }
  6539. //
  6540. // allTotal := fmt.Sprintf("%.2f", total)
  6541. // var rf []*ResultFive
  6542. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6543. // psn_no := order_src.PsnNo
  6544. // mdtrt_id := order_src.MdtrtId
  6545. // chrg_bchno := order_src.Number
  6546. // cert_no := order_src.Certno
  6547. // insutype := rf[0].Insutype
  6548. //
  6549. // if his.IdCardType == 1 {
  6550. // cert_no = his.MedicalInsuranceNumber
  6551. // } else {
  6552. // cert_no = his.Certno
  6553. // }
  6554. //
  6555. // 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)
  6556. // var dat map[string]interface{}
  6557. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6558. // fmt.Println(dat)
  6559. // } else {
  6560. // fmt.Println(err)
  6561. // }
  6562. //
  6563. // userJSONBytes, _ := json.Marshal(dat)
  6564. //
  6565. //
  6566. //
  6567. // var res ResultSeven
  6568. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6569. // utils.ErrorLog("解析失败:%v", err)
  6570. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6571. // return
  6572. // }
  6573. // if res.Infcode == -1 {
  6574. // errlog := &models.HisOrderError{
  6575. // UserOrgId: adminUser.CurrentOrgId,
  6576. // Ctime: time.Now().Unix(),
  6577. // Mtime: time.Now().Unix(),
  6578. // Number: chrg_bchno,
  6579. // ErrMsg: res.ErrMsg,
  6580. // Status: 1,
  6581. // PatientId: id,
  6582. // RecordTime: recordDateTime,
  6583. // Stage: 6,
  6584. // }
  6585. // service.CreateErrMsgLog(errlog)
  6586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6587. // return
  6588. // } else {
  6589. // order_src.OrderStatus = 2
  6590. // order_src.PayWay = pay_way
  6591. // order_src.PayPrice = pay_price
  6592. // order_src.PayCardNo = pay_card_no
  6593. // order_src.DiscountPrice = discount_price
  6594. // order_src.PreferentialPrice = preferential_price
  6595. // order_src.RealityPrice = reality_price
  6596. // order_src.FoundPrice = found_price
  6597. // order_src.MedicalInsurancePrice = medical_insurance_price
  6598. // order_src.PrivatePrice = private_price
  6599. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6600. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6601. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6602. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6603. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6604. // order_src.Certno = res.Output.Setlinfo.Certno
  6605. // order_src.Gend = res.Output.Setlinfo.Gend
  6606. // order_src.Naty = res.Output.Setlinfo.Naty
  6607. // order_src.Age = res.Output.Setlinfo.Age
  6608. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6609. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6610. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6611. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6612. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6613. // order_src.MedType = res.Output.Setlinfo.MedType
  6614. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6615. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6616. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6617. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6618. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6619. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6620. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6621. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6622. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6623. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6624. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6625. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6626. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6627. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6628. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6629. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6630. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6631. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6632. // order_src.Balc = res.Output.Setlinfo.Balc
  6633. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6634. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6635. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6636. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6637. // order_src.Creator = order_src.Creator
  6638. // order_src.Modify = roles.ID
  6639. // order_src.RequestLog = src_resquest
  6640. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6641. // detailStr := string(setlDetail)
  6642. // order_src.SetlDetail = detailStr
  6643. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6644. // err = service.UpDateOrder(order_src)
  6645. //
  6646. // if err == nil {
  6647. // c.ServeSuccessJSON(map[string]interface{}{
  6648. // "msg": "结算成功",
  6649. // })
  6650. // } else {
  6651. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6652. // return
  6653. // }
  6654. // }
  6655. // }
  6656. //}
  6657. //退款
  6658. func (c *HisApiController) Refund() {
  6659. order_id, _ := c.GetInt64("order_id")
  6660. admin_user_id, _ := c.GetInt64("admin_user_id")
  6661. adminUser := c.GetAdminUserInfo()
  6662. var order models.HisOrder
  6663. order, _ = service.GetHisOrderByID(order_id)
  6664. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6665. if order.ID == 0 {
  6666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6667. return
  6668. }
  6669. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6670. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6671. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6672. if config.IsOpen == 1 { //对接了医保,走医保流程
  6673. var res ResultSixteen
  6674. var resSixteen10265 ResultSixteen10265
  6675. var src_resquest string
  6676. var result string
  6677. if miConfig.MdtrtareaAdmvs == "421300" {
  6678. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6679. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6680. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6681. resp3, requestErr3 := http.Get(api3)
  6682. if requestErr3 != nil {
  6683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6684. return
  6685. }
  6686. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6687. if ioErr3 != nil {
  6688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6690. return
  6691. }
  6692. var respJSON3 map[string]interface{}
  6693. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6696. return
  6697. }
  6698. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6699. userJSONBytes3, _ := json.Marshal(respJSON3)
  6700. fmt.Println("log")
  6701. fmt.Println(string(userJSONBytes3))
  6702. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6703. utils.ErrorLog("解析失败:%v", err)
  6704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6705. return
  6706. }
  6707. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6708. var api3 string
  6709. if miConfig.MdtrtareaAdmvs == "320921" {
  6710. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6711. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6712. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6713. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6714. } else {
  6715. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6716. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6717. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6718. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6719. }
  6720. resp3, requestErr3 := http.Get(api3)
  6721. if requestErr3 != nil {
  6722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6723. return
  6724. }
  6725. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6726. if ioErr3 != nil {
  6727. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6729. return
  6730. }
  6731. var respJSON3 map[string]interface{}
  6732. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6733. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6735. return
  6736. }
  6737. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6738. userJSONBytes3, _ := json.Marshal(respJSON3)
  6739. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6740. utils.ErrorLog("解析失败:%v", err)
  6741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6742. return
  6743. }
  6744. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6745. res.Output = resSixteen10265.Output
  6746. res.ErrMsg = resSixteen10265.ErrMsg
  6747. res.Cainfo = resSixteen10265.Cainfo
  6748. res.WarnMsg = resSixteen10265.WarnMsg
  6749. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6750. res.Infcode = infocode
  6751. } else {
  6752. if miConfig.Code == "H15049901371" {
  6753. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6754. var dat map[string]interface{}
  6755. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6756. fmt.Println(dat)
  6757. } else {
  6758. fmt.Println(err)
  6759. }
  6760. saveLog(result, src_resquest, "2208", "退费")
  6761. userJSONBytes, _ := json.Marshal(dat)
  6762. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6763. utils.ErrorLog("解析失败:%v", err)
  6764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6765. return
  6766. }
  6767. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6768. res.Output = resSixteen10265.Output
  6769. res.ErrMsg = resSixteen10265.ErrMsg
  6770. res.Cainfo = resSixteen10265.Cainfo
  6771. res.WarnMsg = resSixteen10265.WarnMsg
  6772. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6773. res.Infcode = infocode
  6774. } else {
  6775. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6776. var dat map[string]interface{}
  6777. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6778. fmt.Println(dat)
  6779. } else {
  6780. fmt.Println(err)
  6781. }
  6782. saveLog(result, src_resquest, "2208", "退费")
  6783. userJSONBytes, _ := json.Marshal(dat)
  6784. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6785. utils.ErrorLog("解析失败:%v", err)
  6786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6787. return
  6788. }
  6789. }
  6790. }
  6791. if res.Infcode == 0 {
  6792. var res2 ResultSix
  6793. var resSix10265 ResultSix10265
  6794. if miConfig.MdtrtareaAdmvs == "421300" {
  6795. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6796. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6797. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6798. resp3, requestErr3 := http.Get(api3)
  6799. if requestErr3 != nil {
  6800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6801. return
  6802. }
  6803. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6804. if ioErr3 != nil {
  6805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6807. return
  6808. }
  6809. var respJSON3 map[string]interface{}
  6810. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6813. return
  6814. }
  6815. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6816. userJSONBytes3, _ := json.Marshal(respJSON3)
  6817. fmt.Println("log")
  6818. fmt.Println(string(userJSONBytes3))
  6819. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6820. utils.ErrorLog("解析失败:%v", err)
  6821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6822. return
  6823. }
  6824. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6825. var api3 string
  6826. if miConfig.MdtrtareaAdmvs == "320921" {
  6827. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6828. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6829. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6830. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6831. } else {
  6832. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6833. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6834. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6835. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6836. }
  6837. resp3, requestErr3 := http.Get(api3)
  6838. if requestErr3 != nil {
  6839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6840. return
  6841. }
  6842. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6843. if ioErr3 != nil {
  6844. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6846. return
  6847. }
  6848. var respJSON3 map[string]interface{}
  6849. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6852. return
  6853. }
  6854. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6855. userJSONBytes3, _ := json.Marshal(respJSON3)
  6856. fmt.Println("log")
  6857. fmt.Println(string(userJSONBytes3))
  6858. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6859. utils.ErrorLog("解析失败:%v", err)
  6860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6861. return
  6862. }
  6863. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6864. res2.Output = resSix10265.Output
  6865. res2.ErrMsg = resSix10265.ErrMsg
  6866. res2.Cainfo = resSix10265.Cainfo
  6867. res2.WarnMsg = resSix10265.WarnMsg
  6868. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6869. res2.Infcode = infocode
  6870. } else {
  6871. if miConfig.Code == "H15049901371" {
  6872. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6873. var dat map[string]interface{}
  6874. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6875. fmt.Println(dat)
  6876. } else {
  6877. fmt.Println(err)
  6878. }
  6879. saveLog(result2, src_request, "2205", "撤销明细")
  6880. userJSONBytes, _ := json.Marshal(dat)
  6881. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6882. utils.ErrorLog("解析失败:%v", err)
  6883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6884. return
  6885. }
  6886. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6887. res2.Output = resSix10265.Output
  6888. res2.ErrMsg = resSix10265.ErrMsg
  6889. res2.Cainfo = resSix10265.Cainfo
  6890. res2.WarnMsg = resSix10265.WarnMsg
  6891. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6892. res2.Infcode = infocode
  6893. } else {
  6894. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6895. var dat map[string]interface{}
  6896. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6897. fmt.Println(dat)
  6898. } else {
  6899. fmt.Println(err)
  6900. }
  6901. saveLog(result2, src_request, "2205", "撤销明细")
  6902. userJSONBytes, _ := json.Marshal(dat)
  6903. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6904. utils.ErrorLog("解析失败:%v", err)
  6905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6906. return
  6907. }
  6908. }
  6909. }
  6910. if res2.Infcode == 0 {
  6911. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6912. if err == nil {
  6913. c.ServeSuccessJSON(map[string]interface{}{
  6914. "msg": "退费成功",
  6915. })
  6916. } else {
  6917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6918. return
  6919. }
  6920. } else {
  6921. c.ServeSuccessJSON(map[string]interface{}{
  6922. "code": -10,
  6923. "msg": res2.ErrMsg,
  6924. })
  6925. }
  6926. } else {
  6927. c.ServeSuccessJSON(map[string]interface{}{
  6928. "code": -10,
  6929. "msg": res.ErrMsg,
  6930. })
  6931. }
  6932. }
  6933. }
  6934. func (c *HisApiController) RefundNumber() {
  6935. record_time := c.GetString("record_time")
  6936. //patient_id, _ := c.GetInt64("patient_id")
  6937. admin_user_id, _ := c.GetInt64("admin_user_id")
  6938. his_patient_id, _ := c.GetInt64("id")
  6939. timeLayout := "2006-01-02"
  6940. loc, _ := time.LoadLocation("Local")
  6941. adminUser := c.GetAdminUserInfo()
  6942. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6943. fmt.Println(err)
  6944. if err != nil {
  6945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6946. return
  6947. }
  6948. recordDateTime := theTime.Unix()
  6949. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6950. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6951. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6952. //order, _ := service.GetHisOrderByID(order_id)
  6953. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6954. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6955. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6956. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6957. if count > 0 {
  6958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6959. return
  6960. }
  6961. if config.IsOpen == 1 { //对接了医保,走医保流程
  6962. var res2 ResultSix
  6963. var resSix10265 ResultSix10265
  6964. if miConfig.MdtrtareaAdmvs == "421300" {
  6965. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6966. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6967. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6968. resp3, requestErr3 := http.Get(api3)
  6969. if requestErr3 != nil {
  6970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6971. return
  6972. }
  6973. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6974. if ioErr3 != nil {
  6975. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6977. return
  6978. }
  6979. var respJSON3 map[string]interface{}
  6980. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6983. return
  6984. }
  6985. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6986. userJSONBytes3, _ := json.Marshal(respJSON3)
  6987. fmt.Println("log")
  6988. fmt.Println(string(userJSONBytes3))
  6989. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6990. utils.ErrorLog("解析失败:%v", err)
  6991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6992. return
  6993. }
  6994. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6995. var api3 string
  6996. if miConfig.MdtrtareaAdmvs == "320921" {
  6997. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6998. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6999. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7000. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7001. } else {
  7002. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7003. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7004. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7005. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7006. }
  7007. resp3, requestErr3 := http.Get(api3)
  7008. if requestErr3 != nil {
  7009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7010. return
  7011. }
  7012. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7013. if ioErr3 != nil {
  7014. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7016. return
  7017. }
  7018. var respJSON3 map[string]interface{}
  7019. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7022. return
  7023. }
  7024. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7025. userJSONBytes3, _ := json.Marshal(respJSON3)
  7026. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7027. utils.ErrorLog("解析失败:%v", err)
  7028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7029. return
  7030. }
  7031. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7032. res2.Output = resSix10265.Output
  7033. res2.ErrMsg = resSix10265.ErrMsg
  7034. res2.Cainfo = resSix10265.Cainfo
  7035. res2.WarnMsg = resSix10265.WarnMsg
  7036. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7037. res2.Infcode = infocode
  7038. } else {
  7039. var api3 string
  7040. if miConfig.Code == "H15049901371" {
  7041. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7042. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7043. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7044. } else {
  7045. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7046. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7047. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7048. }
  7049. resp3, requestErr3 := http.Get(api3)
  7050. if requestErr3 != nil {
  7051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7052. return
  7053. }
  7054. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7055. if ioErr3 != nil {
  7056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7058. return
  7059. }
  7060. var respJSON3 map[string]interface{}
  7061. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7064. return
  7065. }
  7066. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7067. userJSONBytes3, _ := json.Marshal(respJSON3)
  7068. if miConfig.Code == "H15049901371" {
  7069. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7070. utils.ErrorLog("解析失败:%v", err)
  7071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7072. return
  7073. }
  7074. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7075. res2.Output = resSix10265.Output
  7076. res2.ErrMsg = resSix10265.ErrMsg
  7077. res2.Cainfo = resSix10265.Cainfo
  7078. res2.WarnMsg = resSix10265.WarnMsg
  7079. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7080. res2.Infcode = infocode
  7081. } else {
  7082. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7083. utils.ErrorLog("解析失败:%v", err)
  7084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7085. return
  7086. }
  7087. }
  7088. }
  7089. if res2.Infcode == 0 {
  7090. if err == nil {
  7091. c.ServeSuccessJSON(map[string]interface{}{
  7092. "msg": "退号成功",
  7093. })
  7094. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7095. } else {
  7096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7097. return
  7098. }
  7099. } else {
  7100. c.ServeSuccessJSON(map[string]interface{}{
  7101. "code": -10,
  7102. "msg": res2.ErrMsg,
  7103. })
  7104. }
  7105. } else {
  7106. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7107. //if err == nil {
  7108. // c.ServeSuccessJSON(map[string]interface{}{
  7109. // "msg": "退费成功",
  7110. // })
  7111. //} else {
  7112. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7113. // return
  7114. //}
  7115. }
  7116. }
  7117. func (c *HisApiController) RefundDetail() {
  7118. order_id, _ := c.GetInt64("order_id")
  7119. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7120. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7121. number := c.GetString("number")
  7122. record_time := c.GetString("record_time")
  7123. patient_id, _ := c.GetInt64("patient_id")
  7124. //med_type, _ := c.GetInt64("med_type")
  7125. timeLayout := "2006-01-02"
  7126. loc, _ := time.LoadLocation("Local")
  7127. adminUser := c.GetAdminUserInfo()
  7128. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7129. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7130. fmt.Println(err)
  7131. if err != nil {
  7132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7133. return
  7134. }
  7135. recordDateTime := theTime.Unix()
  7136. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7137. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7138. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7139. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7140. var order models.HisOrder
  7141. order, _ = service.GetHisOrderByID(order_id)
  7142. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7143. if config.IsOpen == 1 { //对接了医保,走医保流程
  7144. var res2 ResultSix
  7145. if miConfig.MdtrtareaAdmvs == "421300" {
  7146. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7147. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7148. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7149. resp3, requestErr3 := http.Get(api3)
  7150. if requestErr3 != nil {
  7151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7152. return
  7153. }
  7154. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7155. if ioErr3 != nil {
  7156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7158. return
  7159. }
  7160. var respJSON3 map[string]interface{}
  7161. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7164. return
  7165. }
  7166. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7167. userJSONBytes3, _ := json.Marshal(respJSON3)
  7168. fmt.Println("log")
  7169. fmt.Println(string(userJSONBytes3))
  7170. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7171. utils.ErrorLog("解析失败:%v", err)
  7172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7173. return
  7174. }
  7175. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7176. if err == nil {
  7177. c.ServeSuccessJSON(map[string]interface{}{
  7178. "msg": "撤销明细成功",
  7179. })
  7180. return
  7181. } else {
  7182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7183. return
  7184. }
  7185. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7186. var resSix10265 ResultSix10265
  7187. var api3 string
  7188. if miConfig.MdtrtareaAdmvs == "320921" {
  7189. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7190. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7191. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7192. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7193. } else {
  7194. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7195. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7196. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7197. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7198. }
  7199. resp3, requestErr3 := http.Get(api3)
  7200. if requestErr3 != nil {
  7201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7202. return
  7203. }
  7204. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7205. if ioErr3 != nil {
  7206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7208. return
  7209. }
  7210. var respJSON3 map[string]interface{}
  7211. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7214. return
  7215. }
  7216. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7217. userJSONBytes3, _ := json.Marshal(respJSON3)
  7218. fmt.Println("log")
  7219. fmt.Println(string(userJSONBytes3))
  7220. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7221. utils.ErrorLog("解析失败:%v", err)
  7222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7223. return
  7224. }
  7225. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7226. res2.Output = resSix10265.Output
  7227. res2.ErrMsg = resSix10265.ErrMsg
  7228. res2.Cainfo = resSix10265.Cainfo
  7229. res2.WarnMsg = resSix10265.WarnMsg
  7230. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7231. res2.Infcode = infocode
  7232. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7233. if err == nil {
  7234. c.ServeSuccessJSON(map[string]interface{}{
  7235. "msg": "撤销明细成功",
  7236. })
  7237. return
  7238. } else {
  7239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7240. return
  7241. }
  7242. } else {
  7243. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7244. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7245. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7246. resp2, requestErr2 := http.Get(api2)
  7247. if requestErr2 != nil {
  7248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7249. return
  7250. }
  7251. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7252. if ioErr2 != nil {
  7253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7255. return
  7256. }
  7257. var respJSON2 map[string]interface{}
  7258. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7261. return
  7262. }
  7263. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7264. if err == nil {
  7265. c.ServeSuccessJSON(map[string]interface{}{
  7266. "msg": "撤销明细成功",
  7267. })
  7268. return
  7269. } else {
  7270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7271. return
  7272. }
  7273. }
  7274. } else {
  7275. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7276. if err == nil {
  7277. c.ServeSuccessJSON(map[string]interface{}{
  7278. "msg": "退费成功",
  7279. })
  7280. } else {
  7281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7282. return
  7283. }
  7284. }
  7285. }
  7286. //对账
  7287. func (c *HisApiController) GetCheckAccount() {
  7288. start_time := c.GetString("start_time")
  7289. end_time := c.GetString("end_time")
  7290. insutype := c.GetString("insutype")
  7291. clr_type := c.GetString("clr_type")
  7292. clr_org := c.GetString("clr_optins")
  7293. admin_user_id, _ := c.GetInt64("admin_user_id")
  7294. adminUser := c.GetAdminUserInfo()
  7295. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7296. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7297. if len(clr_org) == 0 {
  7298. clr_org = miConfig.MdtrtareaAdmvs
  7299. }
  7300. timeLayout := "2006-01-02"
  7301. loc, _ := time.LoadLocation("Local")
  7302. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7303. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7304. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7305. fixmedins_setl_cnt := int64(len(orders))
  7306. var medfee_sumamt float64
  7307. var acct_pay float64
  7308. var fund_pay_sumamt float64
  7309. for _, item := range orders {
  7310. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7311. acct_pay = acct_pay + item.AcctPay
  7312. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7313. }
  7314. var user_name string
  7315. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7316. if role.ID == 0 {
  7317. user_name = "xxx"
  7318. } else {
  7319. user_name = role.UserName
  7320. }
  7321. var res ResultEight
  7322. var res10188 ResultEightFor10188
  7323. if config.IsOpen == 1 {
  7324. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7325. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7326. "insutype=" + insutype +
  7327. "&clr_type=" + "11" +
  7328. "&setl_optins=" + clr_org +
  7329. "&stmt_begndate=" + start_time +
  7330. "&stm_enddate=" + end_time +
  7331. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7332. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7333. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7334. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7335. "&fixmedins_code=" + miConfig.Code +
  7336. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7337. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7338. "&secret_key=" + miConfig.SecretKey +
  7339. "&org_name=" + miConfig.OrgName +
  7340. "&doctor=" + user_name +
  7341. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7342. fmt.Println(api)
  7343. resp, requestErr := http.Get(api)
  7344. if requestErr != nil {
  7345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7346. return
  7347. }
  7348. body, ioErr := ioutil.ReadAll(resp.Body)
  7349. fmt.Println(body)
  7350. if ioErr != nil {
  7351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7353. return
  7354. }
  7355. var respJSON map[string]interface{}
  7356. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7359. return
  7360. }
  7361. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7362. userJSONBytes, _ := json.Marshal(respJSON)
  7363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7364. utils.ErrorLog("解析失败:%v", err)
  7365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7366. return
  7367. }
  7368. res.InfRefmsgid = res10188.InfRefmsgid
  7369. res.Output = res10188.Output
  7370. res.ErrMsg = res10188.ErrMsg
  7371. res.Cainfo = res10188.Cainfo
  7372. res.WarnMsg = res10188.WarnMsg
  7373. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7374. res.Infcode = infocode
  7375. } else {
  7376. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7377. "insutype=" + insutype +
  7378. "&clr_type=" + clr_type +
  7379. "&setl_optins=" + clr_org +
  7380. "&stmt_begndate=" + start_time +
  7381. "&stm_enddate=" + end_time +
  7382. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7383. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7384. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7385. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7386. "&fixmedins_code=" + miConfig.Code +
  7387. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7388. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7389. "&secret_key=" + miConfig.SecretKey +
  7390. "&org_name=" + miConfig.OrgName +
  7391. "&doctor=" + user_name
  7392. fmt.Println(api)
  7393. resp, requestErr := http.Get(api)
  7394. if requestErr != nil {
  7395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7396. return
  7397. }
  7398. body, ioErr := ioutil.ReadAll(resp.Body)
  7399. fmt.Println(body)
  7400. if ioErr != nil {
  7401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7403. return
  7404. }
  7405. var respJSON map[string]interface{}
  7406. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7409. return
  7410. }
  7411. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7412. userJSONBytes, _ := json.Marshal(respJSON)
  7413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7414. utils.ErrorLog("解析失败:%v", err)
  7415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7416. return
  7417. }
  7418. }
  7419. if res.Infcode == 0 {
  7420. if res.Output.Stmtinfo.StmtRslt == "0" {
  7421. micc := &models.MedicalInsuranceCostCompare{
  7422. StartTime: startime.Unix(),
  7423. EndTime: endtime.Unix(),
  7424. Insutype: insutype,
  7425. CheckType: 1,
  7426. Num: fixmedins_setl_cnt,
  7427. Mtime: time.Now().Unix(),
  7428. Status: 1,
  7429. UserOrgId: adminUser.CurrentOrgId,
  7430. CostTotal: medfee_sumamt,
  7431. FuncTotal: fund_pay_sumamt,
  7432. PsnPay: acct_pay,
  7433. Creator: admin_user_id,
  7434. Ctime: time.Now().Unix(),
  7435. ClrType: clr_type,
  7436. }
  7437. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7438. if err == nil {
  7439. c.ServeSuccessJSON(map[string]interface{}{
  7440. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7441. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7442. })
  7443. } else {
  7444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7445. }
  7446. } else {
  7447. c.ServeSuccessJSON(map[string]interface{}{
  7448. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7449. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7450. })
  7451. }
  7452. } else {
  7453. c.ServeSuccessJSON(map[string]interface{}{
  7454. "code": -10,
  7455. "msg": res.ErrMsg,
  7456. })
  7457. }
  7458. }
  7459. }
  7460. func (c *HisApiController) Check310() {
  7461. adminUser := c.GetAdminUserInfo()
  7462. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7463. var user_name string
  7464. user_name = "高慧裕"
  7465. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7466. "insutype=" + "310" +
  7467. "&clr_type=" + "" +
  7468. "&setl_optins=" + "441202" +
  7469. "&stmt_begndate=" + "2022-03-01" +
  7470. "&stm_enddate=" + "2022-03-31" +
  7471. "&medfee_sumamt=" + "194930.12" +
  7472. "&fund_pay_sumamt=" + "188741.46" +
  7473. "&acct_pay=" + "0" +
  7474. "&fixmedins_setl_cnt=" + "452" +
  7475. "&fixmedins_code=" + miConfig.Code +
  7476. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7477. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7478. "&secret_key=" + miConfig.SecretKey +
  7479. "&org_name=" + miConfig.OrgName +
  7480. "&doctor=" + user_name
  7481. fmt.Println(api)
  7482. resp, requestErr := http.Get(api)
  7483. if requestErr != nil {
  7484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7485. return
  7486. }
  7487. body, ioErr := ioutil.ReadAll(resp.Body)
  7488. fmt.Println(body)
  7489. if ioErr != nil {
  7490. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7492. return
  7493. }
  7494. var respJSON map[string]interface{}
  7495. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7496. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7498. return
  7499. }
  7500. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7501. userJSONBytes, _ := json.Marshal(respJSON)
  7502. var res ResultEight
  7503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7504. utils.ErrorLog("解析失败:%v", err)
  7505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7506. return
  7507. }
  7508. }
  7509. func (c *HisApiController) Check390() {
  7510. adminUser := c.GetAdminUserInfo()
  7511. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7512. var user_name string
  7513. user_name = "高慧裕"
  7514. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7515. "insutype=" + "390" +
  7516. "&clr_type=" + "" +
  7517. "&setl_optins=" + "441202" +
  7518. "&stmt_begndate=" + "2022-03-01" +
  7519. "&stm_enddate=" + "2022-03-31" +
  7520. "&medfee_sumamt=" + "1068448.89" +
  7521. "&fund_pay_sumamt=" + "1014677.62" +
  7522. "&acct_pay=" + "0" +
  7523. "&fixmedins_setl_cnt=" + "1950" +
  7524. "&fixmedins_code=" + miConfig.Code +
  7525. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7526. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7527. "&secret_key=" + miConfig.SecretKey +
  7528. "&org_name=" + miConfig.OrgName +
  7529. "&doctor=" + user_name
  7530. fmt.Println(api)
  7531. resp, requestErr := http.Get(api)
  7532. if requestErr != nil {
  7533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7534. return
  7535. }
  7536. body, ioErr := ioutil.ReadAll(resp.Body)
  7537. fmt.Println(body)
  7538. if ioErr != nil {
  7539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7541. return
  7542. }
  7543. var respJSON map[string]interface{}
  7544. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7547. return
  7548. }
  7549. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7550. userJSONBytes, _ := json.Marshal(respJSON)
  7551. var res ResultEight
  7552. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7553. utils.ErrorLog("解析失败:%v", err)
  7554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7555. return
  7556. }
  7557. }
  7558. //对账明细
  7559. func (c *HisApiController) GetCheckDetailAccount() {
  7560. start_time := c.GetString("start_time")
  7561. end_time := c.GetString("end_time")
  7562. admin_user_id, _ := c.GetInt64("admin_user_id")
  7563. adminUser := c.GetAdminUserInfo()
  7564. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7565. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7566. timeLayout := "2006-01-02"
  7567. loc, _ := time.LoadLocation("Local")
  7568. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7569. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7570. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7571. Mkdir(miConfig.OrgName)
  7572. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7573. file_name := file + ".txt"
  7574. zip_name := file + ".zip"
  7575. zip_path := miConfig.OrgName + "/" + zip_name
  7576. file_path := miConfig.OrgName + "/" + file_name
  7577. decimal.DivisionPrecision = 2
  7578. var medfee_sumamt float64
  7579. var psn_cash_pay float64
  7580. var fund_pay_sumamt float64
  7581. fixmedins_setl_cnt := int64(len(orders))
  7582. for _, item := range orders {
  7583. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7584. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7585. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7586. }
  7587. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7588. defer f.Close()
  7589. if err != nil {
  7590. fmt.Println(err.Error())
  7591. } else {
  7592. for _, item := range orders {
  7593. var refd_setl_flag string
  7594. if item.OrderStatus == 2 {
  7595. refd_setl_flag = "0"
  7596. var str string
  7597. str = item.SetlId + " " +
  7598. item.MdtrtId + " " +
  7599. item.PsnNo + " " +
  7600. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7601. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7602. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7603. _, err = f.Write([]byte(str))
  7604. }
  7605. if item.OrderStatus == 3 {
  7606. var str string
  7607. str = item.SetlId + " " +
  7608. item.MdtrtId + " " +
  7609. item.PsnNo + " " +
  7610. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7611. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7612. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7613. _, err = f.Write([]byte(str))
  7614. var str2 string
  7615. str2 = item.SetlId + " " +
  7616. item.MdtrtId + " " +
  7617. item.PsnNo + " " +
  7618. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7619. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7620. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7621. _, err = f.Write([]byte(str2))
  7622. }
  7623. }
  7624. }
  7625. Zip(file_path, zip_path)
  7626. fmt.Println(ReadFile(zip_path))
  7627. fmt.Println(string(ReadFile(zip_path)))
  7628. if config.IsOpen == 1 {
  7629. var user_name string
  7630. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7631. if role.ID == 0 {
  7632. user_name = "管理员"
  7633. } else {
  7634. user_name = role.UserName
  7635. }
  7636. baseParams := models.BaseParams{
  7637. SecretKey: miConfig.SecretKey,
  7638. FixmedinsCode: miConfig.Code,
  7639. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7640. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7641. OrgName: miConfig.OrgName,
  7642. Doctor: user_name,
  7643. }
  7644. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7645. var dat map[string]interface{}
  7646. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7647. fmt.Println(dat)
  7648. } else {
  7649. fmt.Println(err)
  7650. }
  7651. userJSONBytes, _ := json.Marshal(dat)
  7652. var res ResultNine
  7653. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7654. utils.ErrorLog("解析失败:%v", err)
  7655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7656. return
  7657. }
  7658. if res.Infcode == 0 {
  7659. fileNo := res.Output.FileQuryNo
  7660. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7661. "file_qury_no=" + fileNo +
  7662. "&setl_optins=" + "定点医保中心" +
  7663. "&stmt_begndate=" + start_time +
  7664. "&stm_enddate=" + end_time +
  7665. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7666. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7667. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7668. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7669. "&fixmedins_code=" + miConfig.Code +
  7670. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7671. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7672. "&secret_key=" + miConfig.SecretKey +
  7673. "&org_name=" + miConfig.OrgName +
  7674. "&doctor=" + user_name
  7675. resp, requestErr := http.Get(api)
  7676. if requestErr != nil {
  7677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7678. return
  7679. }
  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. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7693. userJSONBytes, _ := json.Marshal(respJSON)
  7694. var res ResultTen
  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. service.Gdyb9102(baseParams, zip_name, fileNo)
  7702. micc := &models.MedicalInsuranceCostCompare{
  7703. StartTime: startime.Unix(),
  7704. EndTime: endtime.Unix(),
  7705. Insutype: "0",
  7706. CheckType: 2,
  7707. Num: fixmedins_setl_cnt,
  7708. Mtime: time.Now().Unix(),
  7709. Status: 1,
  7710. UserOrgId: adminUser.CurrentOrgId,
  7711. CostTotal: medfee_sumamt,
  7712. FuncTotal: fund_pay_sumamt,
  7713. PsnPay: psn_cash_pay,
  7714. Creator: admin_user_id,
  7715. Ctime: time.Now().Unix(),
  7716. }
  7717. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7718. c.ServeSuccessJSON(map[string]interface{}{
  7719. "msg": "明细对账成功",
  7720. })
  7721. }
  7722. } else {
  7723. }
  7724. }
  7725. }
  7726. type CustomOrderInfo struct {
  7727. Name string
  7728. Spec string
  7729. Unit string
  7730. Count float64
  7731. Price float64
  7732. Total float64
  7733. }
  7734. func (c *HisApiController) GetSettleAccounts() {
  7735. //id, _ := c.GetInt64("id")
  7736. //record_time := c.GetString("record_time")
  7737. order_id, _ := c.GetInt64("order_id")
  7738. admin_user_id, _ := c.GetInt64("admin_user_id")
  7739. //timeLayout := "2006-01-02"
  7740. //loc, _ := time.LoadLocation("Local")
  7741. //
  7742. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7743. //if err != nil {
  7744. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7745. // return
  7746. //}
  7747. //recordDateTime := theTime.Unix()
  7748. adminUser := c.GetAdminUserInfo()
  7749. order, _ := service.GetHisOrderByID(order_id)
  7750. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7751. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7752. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7753. orderInfos = append(orderInfos, orderInfos_two...)
  7754. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7755. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7756. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7757. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7758. //var config []*models.HisXtDiagnoseConfig
  7759. var name string
  7760. for _, item := range diagnosis_ids {
  7761. id, _ := strconv.ParseInt(item, 10, 64)
  7762. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7763. if len(name) == 0 {
  7764. name = diagnosisConfig.ClassName
  7765. } else {
  7766. name = name + "," + diagnosisConfig.ClassName
  7767. }
  7768. }
  7769. var bedCostTotal float64 = 0 //床位总费
  7770. var bedCostSelfTotal float64 = 0 //床位自费
  7771. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7772. var operationCostTotal float64 = 0 //手术费
  7773. var operationCostSelfTotal float64 = 0 //手术费
  7774. var operationCostPartSelfTotal float64 = 0 //手术费
  7775. var otherCostTotal float64 = 0 //其他费用
  7776. var otherCostSelfTotal float64 = 0 //其他费用
  7777. var otherCostPartSelfTotal float64 = 0 //其他费用
  7778. var materialCostTotal float64 = 0 //材料费
  7779. var materialCostSelfTotal float64 = 0 //材料费
  7780. var materialCostPartSelfTotal float64 = 0 //材料费
  7781. var westernMedicineCostTotal float64 = 0 //西药费
  7782. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7783. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7784. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7785. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7786. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7787. var checkCostTotal float64 = 0 //检查费
  7788. var checkCostSelfTotal float64 = 0 //检查费
  7789. var checkCostPartSelfTotal float64 = 0 //检查费
  7790. var laboratoryCostTotal float64 = 0 //化验费
  7791. var laboratoryCostSelfTotal float64 = 0 //化验费
  7792. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7793. var treatCostTotal float64 = 0 //治疗费用
  7794. var treatCostSelfTotal float64 = 0 //治疗费用
  7795. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7796. decimal.DivisionPrecision = 2
  7797. for _, item := range orderInfos {
  7798. if item.MedChrgitmType == "01" { //床位费
  7799. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7800. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7801. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7802. }
  7803. if item.MedChrgitmType == "03" { //检查费
  7804. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7805. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7806. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7807. }
  7808. if item.MedChrgitmType == "04" { //化验费
  7809. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7810. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7811. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7812. }
  7813. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  7814. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7815. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7816. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7817. }
  7818. if item.MedChrgitmType == "06" { //手术费
  7819. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7820. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7821. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7822. }
  7823. if item.MedChrgitmType == "08" { //材料费
  7824. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7825. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7826. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7827. }
  7828. if item.MedChrgitmType == "09" { //西药费
  7829. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7830. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7831. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7832. }
  7833. if item.MedChrgitmType == "11" { //中成费
  7834. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7835. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7836. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7837. }
  7838. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  7839. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7840. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7841. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7842. }
  7843. }
  7844. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7845. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7846. var user_name string
  7847. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7848. if role.ID == 0 {
  7849. user_name = "管理员"
  7850. } else {
  7851. user_name = role.UserName
  7852. }
  7853. baseParams := models.BaseParams{
  7854. SecretKey: miConfig.SecretKey,
  7855. FixmedinsCode: miConfig.Code,
  7856. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7857. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7858. OrgName: miConfig.OrgName,
  7859. Doctor: user_name,
  7860. }
  7861. businessParams := models.BusinessParams{
  7862. PsnNo: order.PsnNo,
  7863. MdtrtId: order.MdtrtId,
  7864. SetlId: order.SetlId,
  7865. }
  7866. var res ResultEleven
  7867. var resEleven10265 ResultEleven10265
  7868. if config.IsOpen == 1 {
  7869. if miConfig.MdtrtareaAdmvs == "421300" {
  7870. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7871. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7872. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7873. resp, requestErr := http.Get(api)
  7874. if requestErr != nil {
  7875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7876. return
  7877. }
  7878. body, ioErr := ioutil.ReadAll(resp.Body)
  7879. if ioErr != nil {
  7880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7882. return
  7883. }
  7884. var respJSON map[string]interface{}
  7885. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7888. return
  7889. }
  7890. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7891. result, _ := json.Marshal(respJSON)
  7892. fmt.Println("log")
  7893. fmt.Println(string(result))
  7894. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7895. utils.ErrorLog("解析失败:%v", err)
  7896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7897. return
  7898. }
  7899. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7900. var api string
  7901. if miConfig.MdtrtareaAdmvs == "320921" {
  7902. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7903. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7904. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7905. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7906. } else {
  7907. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7908. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7909. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7910. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7911. }
  7912. resp, requestErr := http.Get(api)
  7913. if requestErr != nil {
  7914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7915. return
  7916. }
  7917. body, ioErr := ioutil.ReadAll(resp.Body)
  7918. if ioErr != nil {
  7919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7921. return
  7922. }
  7923. var respJSON map[string]interface{}
  7924. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7927. return
  7928. }
  7929. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7930. result, _ := json.Marshal(respJSON)
  7931. fmt.Println("log")
  7932. fmt.Println(string(result))
  7933. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7934. utils.ErrorLog("解析失败:%v", err)
  7935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7936. return
  7937. }
  7938. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7939. res.Output = resEleven10265.Output
  7940. res.ErrMsg = resEleven10265.ErrMsg
  7941. res.Cainfo = resEleven10265.Cainfo
  7942. res.WarnMsg = resEleven10265.WarnMsg
  7943. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7944. res.Infcode = infocode
  7945. } else {
  7946. //result2 := service.Gdyb1101()
  7947. result2 := service.Gdyb5204(baseParams, businessParams)
  7948. saveLog(result2, "", "5204", "查询")
  7949. result := service.Gdyb5203(baseParams, businessParams)
  7950. var dat map[string]interface{}
  7951. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7952. fmt.Println(dat)
  7953. } else {
  7954. fmt.Println(err)
  7955. }
  7956. userJSONBytes, _ := json.Marshal(dat)
  7957. if miConfig.Code == "H15049901371" {
  7958. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7959. utils.ErrorLog("解析失败:%v", err)
  7960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7961. return
  7962. }
  7963. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7964. res.Output = resEleven10265.Output
  7965. res.ErrMsg = resEleven10265.ErrMsg
  7966. res.Cainfo = resEleven10265.Cainfo
  7967. res.WarnMsg = resEleven10265.WarnMsg
  7968. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7969. res.Infcode = infocode
  7970. } else {
  7971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7972. utils.ErrorLog("解析失败:%v", err)
  7973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7974. return
  7975. }
  7976. }
  7977. }
  7978. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7979. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7980. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7981. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7982. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7983. var doctor_name string
  7984. if roles.ID == 0 {
  7985. doctor_name = "管理员"
  7986. } else {
  7987. doctor_name = roles.UserName
  7988. }
  7989. yiliao_leibie := ""
  7990. switch order.MedType {
  7991. case "11":
  7992. yiliao_leibie = "普通门诊"
  7993. break
  7994. case "12":
  7995. yiliao_leibie = "门诊挂号"
  7996. break
  7997. case "13":
  7998. yiliao_leibie = "急诊"
  7999. break
  8000. case "14":
  8001. yiliao_leibie = "门诊特殊病"
  8002. break
  8003. case "15":
  8004. yiliao_leibie = "门诊统筹"
  8005. break
  8006. case "16":
  8007. yiliao_leibie = "门诊慢性病"
  8008. break
  8009. case "21":
  8010. yiliao_leibie = "普通住院"
  8011. break
  8012. }
  8013. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8014. if res.Infcode == 0 {
  8015. c.ServeSuccessJSON(map[string]interface{}{
  8016. "diagnosis": name,
  8017. "order_infos": orderInfos,
  8018. "number": order.MdtrtId,
  8019. "date": order.SettleAccountsDate,
  8020. "charge_admin": charge_admin,
  8021. "printor_admin": printor_admin,
  8022. "info": res.Output.Setlinfo,
  8023. "bedCostTotal": bedCostTotal,
  8024. "bedCostSelfTotal": bedCostSelfTotal,
  8025. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8026. "operationCostTotal": operationCostTotal,
  8027. "operationCostSelfTotal": operationCostSelfTotal,
  8028. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8029. "otherCostTotal": otherCostTotal,
  8030. "otherCostSelfTotal": otherCostSelfTotal,
  8031. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8032. "materialCostTotal": materialCostTotal,
  8033. "materialCostSelfTotal": materialCostSelfTotal,
  8034. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8035. "westernMedicineCostTotal": westernMedicineCostTotal,
  8036. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8037. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8038. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8039. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8040. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8041. "checkCostTotal": checkCostTotal,
  8042. "checkCostSelfTotal": checkCostSelfTotal,
  8043. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8044. "laboratoryCostTotal": laboratoryCostTotal,
  8045. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8046. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8047. "treatCostTotal": treatCostTotal,
  8048. "treatCostSelfTotal": treatCostSelfTotal,
  8049. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8050. "doctor_code": adminRole_two.DoctorCode,
  8051. "doctor_name": doctor_name,
  8052. "health_card_no": order.PsnNo,
  8053. "department": departments.Name,
  8054. "yiliao_leibie": yiliao_leibie,
  8055. "after_money": order.AccountPrice,
  8056. "patient": patient,
  8057. "org_name": miConfig.OrgName,
  8058. "org_code": miConfig.Code,
  8059. "order_number": order.Number,
  8060. "his_hospital": his_hospital,
  8061. "his": his,
  8062. //"check_order_info": cus_slice,
  8063. })
  8064. }
  8065. }
  8066. }
  8067. func (c *HisApiController) CheckTreatment() {
  8068. patient_id, _ := c.GetInt64("patient_id")
  8069. id_card_no := c.GetString("id_card_no")
  8070. insutype := c.GetString("insutype")
  8071. med_type := c.GetString("med_type")
  8072. admin_user_id, _ := c.GetInt64("admin_user_id")
  8073. adminUser := c.GetAdminUserInfo()
  8074. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8075. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8076. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8077. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8078. if miConfig.MdtrtareaAdmvs == "421300" {
  8079. var res ResultTwo
  8080. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8081. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8082. "&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)
  8083. resp, requestErr := http.Get(api)
  8084. if requestErr != nil {
  8085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8086. return
  8087. }
  8088. body, ioErr := ioutil.ReadAll(resp.Body)
  8089. if ioErr != nil {
  8090. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8092. return
  8093. }
  8094. var respJSON map[string]interface{}
  8095. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8098. return
  8099. }
  8100. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8101. result, _ := json.Marshal(respJSON)
  8102. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8103. utils.ErrorLog("解析失败:%v", err)
  8104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8105. return
  8106. }
  8107. if res.Infcode == 0 {
  8108. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8109. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8110. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8111. resp, requestErr := http.Get(api)
  8112. if requestErr != nil {
  8113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8114. return
  8115. }
  8116. body, ioErr := ioutil.ReadAll(resp.Body)
  8117. if ioErr != nil {
  8118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8120. return
  8121. }
  8122. var respJSON map[string]interface{}
  8123. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8126. return
  8127. }
  8128. var res Result2001
  8129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8130. result2, _ := json.Marshal(respJSON)
  8131. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8132. utils.ErrorLog("解析失败:%v", err)
  8133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8134. return
  8135. }
  8136. if res.Infcode == 0 {
  8137. c.ServeSuccessJSON(map[string]interface{}{
  8138. "msg": res.Output.Trtinfo,
  8139. })
  8140. }
  8141. } else {
  8142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8143. return
  8144. }
  8145. } else {
  8146. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8147. var dat map[string]interface{}
  8148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8149. fmt.Println(dat)
  8150. } else {
  8151. fmt.Println(err)
  8152. }
  8153. userJSONBytes, _ := json.Marshal(dat)
  8154. var res ResultTwo
  8155. var res10265 ResultTwo10265
  8156. if miConfig.Code == "H15049901371" {
  8157. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8158. utils.ErrorLog("解析失败:%v", err)
  8159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8160. return
  8161. }
  8162. res.ErrMsg = res10265.ErrMsg
  8163. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8164. res.Infcode = infocode
  8165. res.Output = res10265.Output
  8166. res.InfRefmsgid = res10265.InfRefmsgid
  8167. } else {
  8168. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8169. utils.ErrorLog("解析失败:%v", err)
  8170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8171. return
  8172. }
  8173. }
  8174. var user_name string
  8175. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8176. if role.ID == 0 {
  8177. user_name = "xxx"
  8178. } else {
  8179. user_name = role.UserName
  8180. }
  8181. baseParams := models.BaseParams{
  8182. SecretKey: miConfig.SecretKey,
  8183. FixmedinsCode: miConfig.Code,
  8184. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8185. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8186. OrgName: miConfig.OrgName,
  8187. Doctor: user_name,
  8188. }
  8189. if config.IsOpen == 1 {
  8190. if miConfig.Code == "H15049901371" {
  8191. if med_type == "14" {
  8192. if insutype == "390" {
  8193. med_type = "9933"
  8194. } else if insutype == "310" {
  8195. med_type = "990502"
  8196. }
  8197. } else if med_type == "11" {
  8198. med_type = "11"
  8199. }
  8200. }
  8201. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8202. var dat map[string]interface{}
  8203. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8204. fmt.Println(dat)
  8205. } else {
  8206. fmt.Println(err)
  8207. }
  8208. var res Result2001
  8209. var res10265 Result2001Org10265
  8210. if miConfig.Code == "H15049901371" {
  8211. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8212. utils.ErrorLog("解析失败:%v", err)
  8213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8214. return
  8215. }
  8216. res.ErrMsg = res10265.ErrMsg
  8217. res.Output = res10265.Output
  8218. res.InfRefmsgid = res10265.InfRefmsgid
  8219. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8220. res.Infcode = infocode
  8221. } else {
  8222. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8223. utils.ErrorLog("解析失败:%v", err)
  8224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8225. return
  8226. }
  8227. }
  8228. if res.Infcode == 0 {
  8229. c.ServeSuccessJSON(map[string]interface{}{
  8230. "msg": res.Output.Trtinfo,
  8231. })
  8232. }
  8233. }
  8234. }
  8235. }
  8236. //func (c *HisApiController) PutRecord() {
  8237. // id, _ := c.GetInt64("id")
  8238. // record_time := c.GetString("record_time")
  8239. // timeLayout := "2006-01-02"
  8240. // loc, _ := time.LoadLocation("Local")
  8241. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8242. // if err != nil {
  8243. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8244. // return
  8245. // }
  8246. // recordDateTime := theTime.Unix()
  8247. //
  8248. // adminInfo := c.GetAdminUserInfo()
  8249. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8250. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8251. //
  8252. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8253. //
  8254. // fmt.Println(miConfig.SecretKey)
  8255. //
  8256. // if patient == nil {
  8257. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8258. // return
  8259. // }
  8260. // if len(patient.IdCardNo) == 0 {
  8261. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8262. // return
  8263. // }
  8264. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8265. // if config.IsOpen == 1 {
  8266. // 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
  8267. // resp, requestErr := http.Get(api)
  8268. // if requestErr != nil {
  8269. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8270. // return
  8271. // }
  8272. // defer resp.Body.Close()
  8273. // body, ioErr := ioutil.ReadAll(resp.Body)
  8274. // if ioErr != nil {
  8275. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8277. // return
  8278. // }
  8279. // var respJSON map[string]interface{}
  8280. //
  8281. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8282. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8283. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8284. // return
  8285. // }
  8286. //
  8287. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8288. // userJSONBytes, _ := json.Marshal(userJSON)
  8289. // var res ResultTwo
  8290. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8291. // utils.ErrorLog("解析失败:%v", err)
  8292. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8293. // return
  8294. // }
  8295. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8296. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8297. // infoStr := string(Iinfos)
  8298. // idetinfoStr := string(Idetinfos)
  8299. //
  8300. // if res.Infcode == 0 {
  8301. // his := models.VMHisPatient{
  8302. // Status: 1,
  8303. // Ctime: time.Now().Unix(),
  8304. // Mtime: time.Now().Unix(),
  8305. // PsnNo: res.Output.Baseinfo.PsnNo,
  8306. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8307. // Certno: res.Output.Baseinfo.Certno,
  8308. // PsnName: res.Output.Baseinfo.PsnName,
  8309. // Gend: res.Output.Baseinfo.Gend,
  8310. // Naty: res.Output.Baseinfo.Naty,
  8311. // Brdy: res.Output.Baseinfo.Brdy,
  8312. // Age: res.Output.Baseinfo.Age,
  8313. // Iinfo: infoStr,
  8314. // Idetinfo: idetinfoStr,
  8315. // PatientId: patient.ID,
  8316. // RecordDate: theTime.Unix(),
  8317. // UserOrgId: adminInfo.CurrentOrgId,
  8318. // AdminUserId: adminInfo.AdminUser.Id,
  8319. // IsReturn: 1,
  8320. // }
  8321. //
  8322. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8323. // //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")
  8324. // //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")
  8325. //
  8326. // //var dat map[string]interface{}
  8327. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8328. // // fmt.Println(dat)
  8329. // //} else {
  8330. // // fmt.Println(err)
  8331. // //}
  8332. //
  8333. // var dat2 map[string]interface{}
  8334. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8335. // fmt.Println(dat2)
  8336. // } else {
  8337. // fmt.Println(err)
  8338. // }
  8339. //
  8340. // } else {
  8341. // adminUser := c.GetAdminUserInfo()
  8342. // errlog := &models.HisOrderError{
  8343. // UserOrgId: adminUser.CurrentOrgId,
  8344. // Ctime: time.Now().Unix(),
  8345. // Mtime: time.Now().Unix(),
  8346. // ErrMsg: res.ErrMsg,
  8347. // Status: 1,
  8348. // PatientId: id,
  8349. // RecordTime: recordDateTime,
  8350. // Stage: 1,
  8351. // }
  8352. // service.CreateErrMsgLog(errlog)
  8353. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8354. // return
  8355. // }
  8356. // }
  8357. //
  8358. //}
  8359. //func (c *HisApiController) GetUploadDiag() {
  8360. // id, _ := c.GetInt64("id")
  8361. // record_time := c.GetString("record_time")
  8362. //
  8363. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8364. // sick_type, _ := c.GetInt64("sick_type")
  8365. // reg_type, _ := c.GetInt64("reg_type")
  8366. //
  8367. // timeLayout := "2006-01-02"
  8368. // loc, _ := time.LoadLocation("Local")
  8369. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8370. // if err != nil {
  8371. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8372. // return
  8373. // }
  8374. //
  8375. // var patientPrescription models.HisPrescriptionInfo
  8376. // recordDateTime := theTime.Unix()
  8377. // adminInfo := c.GetAdminUserInfo()
  8378. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8379. //
  8380. // if patientPrescription.ID == 0 {
  8381. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8382. // }
  8383. //
  8384. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8385. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8386. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8387. // sickConfig, _ := service.FindSickById(sick_type)
  8388. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8389. //
  8390. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8391. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8392. // "&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 +
  8393. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8394. // resp2, requestErr2 := http.Get(api2)
  8395. // if requestErr2 != nil {
  8396. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8397. // return
  8398. // }
  8399. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8400. // if ioErr2 != nil {
  8401. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8402. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8403. // return
  8404. // }
  8405. // var respJSON2 map[string]interface{}
  8406. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8407. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8408. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8409. // return
  8410. // }
  8411. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8412. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8413. //
  8414. // var res2 ResultSix
  8415. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8416. // utils.ErrorLog("解析失败:%v", err)
  8417. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8418. // return
  8419. // }
  8420. // if res2.Infcode != 0 {
  8421. // adminUser := c.GetAdminUserInfo()
  8422. // errlog := &models.HisOrderError{
  8423. // UserOrgId: adminUser.CurrentOrgId,
  8424. // Ctime: time.Now().Unix(),
  8425. // Mtime: time.Now().Unix(),
  8426. // ErrMsg: res2.ErrMsg,
  8427. // Status: 1,
  8428. // PatientId: id,
  8429. // RecordTime: recordDateTime,
  8430. // Stage: 3,
  8431. // }
  8432. // service.CreateErrMsgLog(errlog)
  8433. //
  8434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8435. // return
  8436. // }
  8437. //
  8438. // c.ServeSuccessJSON(map[string]interface{}{
  8439. // "msg": "上传成功",
  8440. // })
  8441. //
  8442. //}
  8443. type QueryResult struct {
  8444. ID int64
  8445. Name string
  8446. Code string
  8447. List_type_code string
  8448. }
  8449. func (c *HisApiController) GetCheckCode() {
  8450. ids_str := c.GetString("ids")
  8451. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8452. ids_arr := strings.Split(ids_str, ",")
  8453. var queryResult []QueryResult
  8454. ids := make([]int64, 0)
  8455. for _, item := range ids_arr {
  8456. id, _ := strconv.ParseInt(item, 10, 64)
  8457. ids = append(ids, id)
  8458. }
  8459. if record_type == 1 {
  8460. drugs, _ := service.GetBatchDrugList(ids)
  8461. for _, item := range drugs {
  8462. result := QueryResult{
  8463. ID: item.ID,
  8464. Name: item.DrugName,
  8465. Code: item.MedicalInsuranceNumber,
  8466. List_type_code: "101",
  8467. }
  8468. queryResult = append(queryResult, result)
  8469. }
  8470. } else if record_type == 2 {
  8471. goods, _ := service.GetBatchGoodInformationList(ids)
  8472. for _, item := range goods {
  8473. result := QueryResult{
  8474. ID: item.ID,
  8475. Name: item.GoodName,
  8476. Code: item.MedicalInsuranceNumber,
  8477. List_type_code: "301",
  8478. }
  8479. queryResult = append(queryResult, result)
  8480. }
  8481. } else if record_type == 3 {
  8482. projects, _ := service.GetBathchMyPorjecgList(ids)
  8483. for _, item := range projects {
  8484. result := QueryResult{
  8485. ID: item.ID,
  8486. Name: item.ProjectName,
  8487. Code: item.MedicalCode,
  8488. List_type_code: "201",
  8489. }
  8490. queryResult = append(queryResult, result)
  8491. }
  8492. }
  8493. admin_user_id, _ := c.GetInt64("admin_user_id")
  8494. adminUser := c.GetAdminUserInfo()
  8495. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8496. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8497. var user_name string
  8498. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8499. if role.ID == 0 {
  8500. user_name = "xxx"
  8501. } else {
  8502. user_name = role.UserName
  8503. }
  8504. baseParams := &models.BaseParams{
  8505. SecretKey: miConfig.SecretKey,
  8506. FixmedinsCode: miConfig.Code,
  8507. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8508. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8509. OrgName: miConfig.OrgName,
  8510. Doctor: user_name,
  8511. }
  8512. if config.IsOpen == 1 {
  8513. for _, item := range queryResult {
  8514. var result string
  8515. if record_type == 1 {
  8516. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8517. } else if record_type == 2 {
  8518. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8519. } else if record_type == 3 {
  8520. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8521. }
  8522. var dat map[string]interface{}
  8523. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8524. fmt.Println(dat)
  8525. } else {
  8526. fmt.Println(err)
  8527. }
  8528. userJSONBytes, _ := json.Marshal(dat)
  8529. var res ResultSix
  8530. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8531. utils.ErrorLog("解析失败:%v", err)
  8532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8533. return
  8534. }
  8535. if res.Infcode == 0 {
  8536. if record_type == 1 {
  8537. service.UpdateBaseDrugById(item.ID)
  8538. } else if record_type == 2 {
  8539. service.UpdateGoodInformaitonByDetail(item.ID)
  8540. } else if record_type == 3 {
  8541. service.UpdateProjectById(item.ID)
  8542. }
  8543. c.ServeSuccessJSON(map[string]interface{}{
  8544. "failed_code": 0,
  8545. "msg": "目录对照成功",
  8546. })
  8547. } else {
  8548. c.ServeSuccessJSON(map[string]interface{}{
  8549. "failed_code": -10,
  8550. "msg": res.ErrMsg,
  8551. })
  8552. }
  8553. }
  8554. }
  8555. }
  8556. func (c *HisApiController) UnCheckCode() {
  8557. ids_str := c.GetString("ids")
  8558. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8559. admin_user_id, _ := c.GetInt64("admin_user_id")
  8560. ids_arr := strings.Split(ids_str, ",")
  8561. var queryResult []QueryResult
  8562. ids := make([]int64, 0)
  8563. for _, item := range ids_arr {
  8564. id, _ := strconv.ParseInt(item, 10, 64)
  8565. ids = append(ids, id)
  8566. }
  8567. if record_type == 1 {
  8568. drugs, _ := service.GetBatchDrugList(ids)
  8569. for _, item := range drugs {
  8570. result := QueryResult{
  8571. ID: item.ID,
  8572. Name: item.DrugName,
  8573. Code: item.MedicalInsuranceNumber,
  8574. List_type_code: "101",
  8575. }
  8576. queryResult = append(queryResult, result)
  8577. }
  8578. } else if record_type == 2 {
  8579. goods, _ := service.GetBatchGoodInformationList(ids)
  8580. for _, item := range goods {
  8581. result := QueryResult{
  8582. ID: item.ID,
  8583. Name: item.GoodName,
  8584. Code: item.MedicalInsuranceNumber,
  8585. List_type_code: "301",
  8586. }
  8587. queryResult = append(queryResult, result)
  8588. }
  8589. } else if record_type == 3 {
  8590. projects, _ := service.GetBathchMyPorjecgList(ids)
  8591. for _, item := range projects {
  8592. result := QueryResult{
  8593. ID: item.ID,
  8594. Name: item.ProjectName,
  8595. Code: item.MedicalCode,
  8596. List_type_code: "201",
  8597. }
  8598. queryResult = append(queryResult, result)
  8599. }
  8600. }
  8601. adminUser := c.GetAdminUserInfo()
  8602. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8603. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8604. var user_name string
  8605. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8606. if role.ID == 0 {
  8607. user_name = "xxx"
  8608. } else {
  8609. user_name = role.UserName
  8610. }
  8611. baseParams := &models.BaseParams{
  8612. SecretKey: miConfig.SecretKey,
  8613. FixmedinsCode: miConfig.Code,
  8614. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8615. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8616. OrgName: miConfig.OrgName,
  8617. Doctor: user_name,
  8618. }
  8619. if config.IsOpen == 1 {
  8620. for _, item := range queryResult {
  8621. var result string
  8622. if record_type == 1 {
  8623. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8624. } else if record_type == 2 {
  8625. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8626. } else if record_type == 3 {
  8627. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8628. }
  8629. var dat2 map[string]interface{}
  8630. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8631. fmt.Println(dat2)
  8632. } else {
  8633. fmt.Println(err)
  8634. }
  8635. userJSONBytes, _ := json.Marshal(dat2)
  8636. var res ResultSix
  8637. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8638. utils.ErrorLog("解析失败:%v", err)
  8639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8640. return
  8641. }
  8642. if res.Infcode == 0 {
  8643. if record_type == 1 {
  8644. service.UpdateDrugByIdDetail(item.ID)
  8645. } else if record_type == 2 {
  8646. service.UpdateGoodInfoById(item.ID)
  8647. } else if record_type == 3 {
  8648. service.UpdateMyProjectById(item.ID)
  8649. }
  8650. c.ServeSuccessJSON(map[string]interface{}{
  8651. "failed_code": 0,
  8652. "msg": "撤销目录对照成功",
  8653. })
  8654. } else {
  8655. c.ServeSuccessJSON(map[string]interface{}{
  8656. "failed_code": -10,
  8657. "msg": res.ErrMsg,
  8658. })
  8659. }
  8660. }
  8661. }
  8662. }
  8663. func (c *HisApiController) GetPatientInfo() {
  8664. id_card_no := c.GetString("id_card_no")
  8665. admin_user_id, _ := c.GetInt64("admin_user_id")
  8666. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8667. if patient.ID == 0 {
  8668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8669. return
  8670. }
  8671. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8672. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8673. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8674. if config.IsOpen == 1 {
  8675. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8676. var dat map[string]interface{}
  8677. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8678. fmt.Println(dat)
  8679. } else {
  8680. fmt.Println(err)
  8681. }
  8682. userJSONBytes, _ := json.Marshal(dat)
  8683. var res ResultTwo
  8684. var res10265 ResultTwo10265
  8685. if miConfig.Code == "H15049901371" {
  8686. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8687. utils.ErrorLog("解析失败:%v", err)
  8688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8689. return
  8690. }
  8691. res.ErrMsg = res10265.ErrMsg
  8692. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8693. res.Infcode = infocode
  8694. res.Output = res10265.Output
  8695. res.InfRefmsgid = res10265.InfRefmsgid
  8696. } else {
  8697. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8698. utils.ErrorLog("解析失败:%v", err)
  8699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8700. return
  8701. }
  8702. }
  8703. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8704. // utils.ErrorLog("解析失败:%v", err)
  8705. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8706. // return
  8707. //}
  8708. if res.Infcode != 0 {
  8709. c.ServeSuccessJSON(map[string]interface{}{
  8710. "failed_code": -10,
  8711. "msg": res.ErrMsg,
  8712. })
  8713. } else {
  8714. c.ServeSuccessJSON(map[string]interface{}{
  8715. "failed_code": 0,
  8716. "info": res,
  8717. })
  8718. }
  8719. }
  8720. }
  8721. func (c *HisApiController) PsnPutOnRecord() {
  8722. record_type, _ := c.GetInt64("type")
  8723. patient_id, _ := c.GetInt64("patient_id")
  8724. admin_user_id, _ := c.GetInt64("admin_user_id")
  8725. start_time := c.GetString("start_time")
  8726. end_time := c.GetString("end_time")
  8727. adminUser := c.GetAdminUserInfo()
  8728. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8729. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8730. var patients []*models.Patients
  8731. if record_type == 1 { //全部备案
  8732. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8733. patients = append(patients, patient...)
  8734. } else { //单个备案
  8735. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8736. patients = append(patients, patient)
  8737. }
  8738. var user_name string
  8739. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8740. if role.ID == 0 {
  8741. user_name = "xxx"
  8742. } else {
  8743. user_name = role.UserName
  8744. }
  8745. if config.IsOpen == 1 {
  8746. for _, item := range patients {
  8747. 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
  8748. resp, requestErr := http.Get(api)
  8749. if requestErr != nil {
  8750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8751. return
  8752. }
  8753. defer resp.Body.Close()
  8754. body, ioErr := ioutil.ReadAll(resp.Body)
  8755. if ioErr != nil {
  8756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8758. return
  8759. }
  8760. var respJSON map[string]interface{}
  8761. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8764. return
  8765. }
  8766. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8767. userJSONBytes, _ := json.Marshal(userJSON)
  8768. var res ResultTwo
  8769. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8770. utils.ErrorLog("解析失败:%v", err)
  8771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8772. return
  8773. }
  8774. if res.Infcode == 0 {
  8775. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8776. var dat map[string]interface{}
  8777. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8778. fmt.Println(dat)
  8779. } else {
  8780. fmt.Println(err)
  8781. }
  8782. userJSONBytes, _ := json.Marshal(dat)
  8783. var res2 ResultThirteen
  8784. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8785. utils.ErrorLog("解析失败:%v", err)
  8786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8787. return
  8788. }
  8789. if res2.Infcode == 0 {
  8790. psnResult := &models.GdybPsnRecord{
  8791. UserOrgId: adminUser.CurrentOrgId,
  8792. PatientId: item.ID,
  8793. PsnNo: res.Output.Baseinfo.PsnNo,
  8794. Ctime: time.Now().Unix(),
  8795. Mtime: time.Now().Unix(),
  8796. Status: 1,
  8797. IsCancel: 1,
  8798. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8799. }
  8800. service.CreatePsnRecord(psnResult)
  8801. } else {
  8802. c.ServeSuccessJSON(map[string]interface{}{
  8803. "failed_code": -10,
  8804. "msg": res2.ErrMsg,
  8805. })
  8806. return
  8807. }
  8808. }
  8809. }
  8810. }
  8811. }
  8812. func (c *HisApiController) PsnUnPutOnRecord() {
  8813. id, _ := c.GetInt64("id")
  8814. //record_type, _ := c.GetInt64("type")
  8815. admin_user_id, _ := c.GetInt64("admin_user_id")
  8816. adminUser := c.GetAdminUserInfo()
  8817. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8818. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8819. var user_name string
  8820. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8821. if role.ID == 0 {
  8822. user_name = "xxx"
  8823. } else {
  8824. user_name = role.UserName
  8825. }
  8826. psn_record, _ := service.GetPsnRecordById(id)
  8827. if psn_record.ID == 0 {
  8828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8829. return
  8830. }
  8831. if config.IsOpen == 1 {
  8832. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8833. var dat map[string]interface{}
  8834. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8835. fmt.Println(dat)
  8836. } else {
  8837. fmt.Println(err)
  8838. }
  8839. userJSONBytes, _ := json.Marshal(dat)
  8840. var res ResultFourteen
  8841. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8842. utils.ErrorLog("解析失败:%v", err)
  8843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8844. return
  8845. }
  8846. if res.Infcode == 0 {
  8847. psn_record.IsCancel = 2
  8848. service.CreatePsnRecord(&psn_record)
  8849. } else {
  8850. c.ServeSuccessJSON(map[string]interface{}{
  8851. "failed_code": -10,
  8852. "msg": res.ErrMsg,
  8853. })
  8854. return
  8855. }
  8856. }
  8857. }
  8858. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8859. patient_id, _ := c.GetInt64("patient_id")
  8860. insutype_two := c.GetString("insutype")
  8861. psn_no := c.GetString("psn_no")
  8862. doctor_id, _ := c.GetInt64("doctor_id")
  8863. sick_id, _ := c.GetInt64("sick_id")
  8864. department_id, _ := c.GetInt64("department_id")
  8865. start_time := c.GetString("start_time")
  8866. end_time := c.GetString("end_time")
  8867. check_time := c.GetString("check_time")
  8868. adminUser := c.GetAdminUserInfo()
  8869. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8870. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8871. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8872. sick, _ := service.FindSickById(sick_id)
  8873. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8874. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8875. var res ResultTwo
  8876. var res10265 ResultTwo10265
  8877. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8878. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8879. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8880. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8881. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(3, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  8882. resp, requestErr := http.Get(api)
  8883. if requestErr != nil {
  8884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8885. return
  8886. }
  8887. body, ioErr := ioutil.ReadAll(resp.Body)
  8888. if ioErr != nil {
  8889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8891. return
  8892. }
  8893. var respJSON map[string]interface{}
  8894. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8897. return
  8898. }
  8899. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8900. result, _ := json.Marshal(respJSON)
  8901. fmt.Println("log")
  8902. fmt.Println(string(result))
  8903. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8904. utils.ErrorLog("解析失败:%v", err)
  8905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8906. return
  8907. }
  8908. res.ErrMsg = res10265.ErrMsg
  8909. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8910. res.Infcode = infocode
  8911. res.Output = res10265.Output
  8912. res.InfRefmsgid = res10265.InfRefmsgid
  8913. } else {
  8914. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8915. if miConfig.Code == "H15049901371" {
  8916. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8917. utils.ErrorLog("解析失败:%v", err)
  8918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8919. return
  8920. }
  8921. res.ErrMsg = res10265.ErrMsg
  8922. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8923. res.Infcode = infocode
  8924. res.Output = res10265.Output
  8925. res.InfRefmsgid = res10265.InfRefmsgid
  8926. } else {
  8927. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8928. utils.ErrorLog("解析失败:%v", err)
  8929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8930. return
  8931. }
  8932. }
  8933. }
  8934. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8935. infoStr := string(Iinfos)
  8936. var rf []*ResultFive
  8937. json.Unmarshal([]byte(infoStr), &rf)
  8938. var insuplc_admdvs string
  8939. var insutype string
  8940. var is390 int = 0
  8941. var is310 int = 0
  8942. var insutypes []*ResultFive
  8943. for _, item := range rf {
  8944. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8945. insutypes = append(insutypes, item)
  8946. }
  8947. }
  8948. if len(insutypes) == 1 {
  8949. insutype = insutypes[0].Insutype
  8950. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8951. } else {
  8952. for _, i := range insutypes {
  8953. if i.Insutype == "390" {
  8954. is390 = 1
  8955. }
  8956. if i.Insutype == "310" {
  8957. is310 = 1
  8958. }
  8959. }
  8960. }
  8961. if is390 == 1 {
  8962. insutype = "390"
  8963. }
  8964. if is310 == 1 {
  8965. insutype = "310"
  8966. }
  8967. if len(insutypes) == 2 {
  8968. insutype = insutype_two
  8969. }
  8970. if len(insutypes) == 0 {
  8971. insutype = "310"
  8972. }
  8973. insutype = insutype_two
  8974. fmt.Println(insutype)
  8975. for _, item := range rf {
  8976. fmt.Println(item.Insutype)
  8977. fmt.Println(insutype)
  8978. if item.Insutype == insutype {
  8979. fmt.Println(item.Insutype)
  8980. fmt.Println(insutype)
  8981. insuplc_admdvs = item.InsuplcAdmdvs
  8982. }
  8983. }
  8984. fmt.Println(insuplc_admdvs)
  8985. var res2 ResultThirteen
  8986. var res10265_2 ResultThirteen10265
  8987. if config.IsOpen == 1 {
  8988. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8989. } else {
  8990. 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)
  8991. var dat map[string]interface{}
  8992. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8993. fmt.Println(dat)
  8994. } else {
  8995. fmt.Println(err)
  8996. }
  8997. userJSONBytes, _ := json.Marshal(dat)
  8998. if miConfig.Code == "H15049901371" {
  8999. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9000. utils.ErrorLog("解析失败:%v", err)
  9001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9002. return
  9003. }
  9004. res2.ErrMsg = res10265_2.ErrMsg
  9005. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9006. res2.Infcode = infocode
  9007. res2.Output = res10265_2.Output
  9008. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9009. } else {
  9010. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9011. utils.ErrorLog("解析失败:%v", err)
  9012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9013. return
  9014. }
  9015. }
  9016. }
  9017. if res2.Infcode == 0 {
  9018. psnResult := &models.GdybPsnNcdsRecord{
  9019. UserOrgId: adminUser.CurrentOrgId,
  9020. PatientId: patient.ID,
  9021. PsnNo: psn_no,
  9022. DoctorId: doctor.AdminUserId,
  9023. DepartmentId: department_id,
  9024. SickType: sick_id,
  9025. Insutype: insutype,
  9026. Ctime: time.Now().Unix(),
  9027. Mtime: time.Now().Unix(),
  9028. Status: 1,
  9029. IsCancel: 1,
  9030. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9031. }
  9032. service.CreatePsnNCDSRecord(psnResult)
  9033. c.ServeSuccessJSON(map[string]interface{}{
  9034. "failed_code": 0,
  9035. "msg": "备案成功",
  9036. "result": psnResult,
  9037. })
  9038. } else {
  9039. c.ServeSuccessJSON(map[string]interface{}{
  9040. "failed_code": -10,
  9041. "msg": res2.ErrMsg,
  9042. })
  9043. return
  9044. }
  9045. }
  9046. }
  9047. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9048. id, _ := c.GetInt64("id")
  9049. admin_user_id, _ := c.GetInt64("admin_user_id")
  9050. adminUser := c.GetAdminUserInfo()
  9051. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9052. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9053. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9054. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9055. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9056. //var user_name string
  9057. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9058. //if role.ID == 0 {
  9059. // user_name = "xxx"
  9060. //} else {
  9061. // user_name = role.UserName
  9062. //}
  9063. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9064. if psn_record.ID == 0 {
  9065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9066. return
  9067. }
  9068. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9069. var res ResultTwo
  9070. var res10265 ResultTwo10265
  9071. if miConfig.Code == "H15049901371" {
  9072. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9073. utils.ErrorLog("解析失败:%v", err)
  9074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9075. return
  9076. }
  9077. res.ErrMsg = res10265.ErrMsg
  9078. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9079. res.Infcode = infocode
  9080. res.Output = res10265.Output
  9081. res.InfRefmsgid = res10265.InfRefmsgid
  9082. } else {
  9083. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9084. utils.ErrorLog("解析失败:%v", err)
  9085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9086. return
  9087. }
  9088. }
  9089. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9090. infoStr := string(Iinfos)
  9091. var rf []*ResultFive
  9092. json.Unmarshal([]byte(infoStr), &rf)
  9093. var insuplc_admdvs string
  9094. var insutype string
  9095. var is390 int = 0
  9096. var is310 int = 0
  9097. var insutypes []*ResultFive
  9098. for _, item := range rf {
  9099. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9100. insutypes = append(insutypes, item)
  9101. }
  9102. }
  9103. if len(insutypes) == 1 {
  9104. insutype = insutypes[0].Insutype
  9105. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9106. } else {
  9107. for _, i := range insutypes {
  9108. if i.Insutype == "390" {
  9109. is390 = 1
  9110. }
  9111. if i.Insutype == "310" {
  9112. is310 = 1
  9113. }
  9114. }
  9115. }
  9116. if is390 == 1 {
  9117. insutype = "390"
  9118. }
  9119. if is310 == 1 {
  9120. insutype = "310"
  9121. }
  9122. if len(insutypes) == 0 {
  9123. insutype = "310"
  9124. }
  9125. insutype = psn_record.Insutype
  9126. for _, item := range rf {
  9127. if item.Insutype == insutype {
  9128. insuplc_admdvs = item.InsuplcAdmdvs
  9129. }
  9130. }
  9131. if config.IsOpen == 1 {
  9132. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9133. var dat map[string]interface{}
  9134. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9135. fmt.Println(dat)
  9136. } else {
  9137. fmt.Println(err)
  9138. }
  9139. userJSONBytes, _ := json.Marshal(dat)
  9140. var res ResultFourteen
  9141. var res10265 ResultFourteen10265
  9142. if miConfig.Code == "H15049901371" {
  9143. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9144. utils.ErrorLog("解析失败:%v", err)
  9145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9146. return
  9147. }
  9148. res.ErrMsg = res10265.ErrMsg
  9149. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9150. res.Infcode = infocode
  9151. res.Output = res10265.Output
  9152. res.InfRefmsgid = res10265.InfRefmsgid
  9153. } else {
  9154. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9155. utils.ErrorLog("解析失败:%v", err)
  9156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9157. return
  9158. }
  9159. }
  9160. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9161. // utils.ErrorLog("解析失败:%v", err)
  9162. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9163. // return
  9164. //}
  9165. if res.Infcode == 0 {
  9166. psn_record.IsCancel = 2
  9167. service.CreatePsnNCDSRecord(&psn_record)
  9168. c.ServeSuccessJSON(map[string]interface{}{
  9169. "failed_code": 0,
  9170. "msg": "撤销备案成功",
  9171. })
  9172. } else {
  9173. c.ServeSuccessJSON(map[string]interface{}{
  9174. "failed_code": -10,
  9175. "msg": res.ErrMsg,
  9176. })
  9177. return
  9178. }
  9179. }
  9180. }
  9181. func (c *HisApiController) TestTest() {
  9182. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9183. fmt.Println(patient.Iinfo)
  9184. }
  9185. type CustomData struct {
  9186. MsgId string
  9187. PsnNo string
  9188. Info string
  9189. }
  9190. func (c *HisApiController) ReversalData() {
  9191. var customData []*CustomData
  9192. custom := &CustomData{
  9193. MsgId: "H44022900158202103301714472004",
  9194. PsnNo: "44020000001101329945",
  9195. Info: "2207",
  9196. }
  9197. customData = append(customData, custom)
  9198. custom1 := &CustomData{
  9199. MsgId: "H4402290015820210330172057803",
  9200. PsnNo: "44020000001101161813",
  9201. Info: "2207",
  9202. }
  9203. customData = append(customData, custom1)
  9204. custom2 := &CustomData{
  9205. MsgId: "H44022900158202103301705198813",
  9206. PsnNo: "44190000133097375417",
  9207. Info: "2207",
  9208. }
  9209. customData = append(customData, custom2)
  9210. custom3 := &CustomData{
  9211. MsgId: "H44022900158202103301715524756",
  9212. PsnNo: "44020000001100187221",
  9213. Info: "2207",
  9214. }
  9215. customData = append(customData, custom3)
  9216. custom4 := &CustomData{
  9217. MsgId: "H44022900158202103301730376224",
  9218. PsnNo: "44020000001101959155",
  9219. Info: "2207",
  9220. }
  9221. customData = append(customData, custom4)
  9222. custom5 := &CustomData{
  9223. MsgId: "H44022900158202103301748008725",
  9224. PsnNo: "44020000001104246641",
  9225. Info: "2207",
  9226. }
  9227. customData = append(customData, custom5)
  9228. custom6 := &CustomData{
  9229. MsgId: "H44022900158202103301718096755",
  9230. PsnNo: "44020000001102211860",
  9231. Info: "2207",
  9232. }
  9233. customData = append(customData, custom6)
  9234. custom7 := &CustomData{
  9235. MsgId: "H44022900158202103301736551640",
  9236. PsnNo: "44020000001102687718",
  9237. Info: "2207",
  9238. }
  9239. customData = append(customData, custom7)
  9240. custom8 := &CustomData{
  9241. MsgId: "H44022900158202103301743097676",
  9242. PsnNo: "44020000001102127785",
  9243. Info: "2207",
  9244. }
  9245. customData = append(customData, custom8)
  9246. custom9 := &CustomData{
  9247. MsgId: "H44022900158202103301712304203",
  9248. PsnNo: "44020000001101518097",
  9249. Info: "2207",
  9250. }
  9251. customData = append(customData, custom9)
  9252. custom10 := &CustomData{
  9253. MsgId: "H44022900158202103301738448785",
  9254. PsnNo: "44020000001100500813",
  9255. Info: "2207",
  9256. }
  9257. customData = append(customData, custom10)
  9258. custom11 := &CustomData{
  9259. MsgId: "H44022900158202103301732455843",
  9260. PsnNo: "44020000001102690557",
  9261. Info: "2207",
  9262. }
  9263. customData = append(customData, custom11)
  9264. custom12 := &CustomData{
  9265. MsgId: "H44022900158202103301745421708",
  9266. PsnNo: "44020000001102211928",
  9267. Info: "2207",
  9268. }
  9269. customData = append(customData, custom12)
  9270. custom1212 := &CustomData{
  9271. MsgId: "H440229001582021033017351627",
  9272. PsnNo: "44020000001102481733",
  9273. Info: "2207",
  9274. }
  9275. customData = append(customData, custom1212)
  9276. custom13 := &CustomData{
  9277. MsgId: "H44022900158202103301740327951",
  9278. PsnNo: "44020000001103174866",
  9279. Info: "2207",
  9280. }
  9281. customData = append(customData, custom13)
  9282. custom14 := &CustomData{
  9283. MsgId: "H4402290015820210330174922668",
  9284. PsnNo: "44020000001102927272",
  9285. Info: "2207",
  9286. }
  9287. customData = append(customData, custom14)
  9288. custom15 := &CustomData{
  9289. MsgId: "H44022900158202103301752362273",
  9290. PsnNo: "44020000001102942890",
  9291. Info: "2207",
  9292. }
  9293. customData = append(customData, custom15)
  9294. custom16 := &CustomData{
  9295. MsgId: "H44022900158202103301751082917",
  9296. PsnNo: "44020000001101662162",
  9297. Info: "2207",
  9298. }
  9299. customData = append(customData, custom16)
  9300. custom17 := &CustomData{
  9301. MsgId: "H44022900158202103301754147728",
  9302. PsnNo: "44020000000229014511",
  9303. Info: "2207",
  9304. }
  9305. customData = append(customData, custom17)
  9306. adminUser := c.GetAdminUserInfo()
  9307. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9308. for _, item := range customData {
  9309. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9310. fmt.Println(result)
  9311. }
  9312. }
  9313. func (c *HisApiController) GetAllopatry() {
  9314. year := c.GetString("year")
  9315. month := c.GetString("month")
  9316. admin_user_id, _ := c.GetInt64("admin_user_id")
  9317. adminUser := c.GetAdminUserInfo()
  9318. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9319. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9320. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9321. var dat map[string]interface{}
  9322. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9323. fmt.Println(dat)
  9324. } else {
  9325. fmt.Println(err)
  9326. }
  9327. userJSONBytes, _ := json.Marshal(dat)
  9328. var res models.Result9001
  9329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9330. utils.ErrorLog("解析失败:%v", err)
  9331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9332. return
  9333. }
  9334. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9335. var dat2 map[string]interface{}
  9336. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9337. fmt.Println(dat)
  9338. } else {
  9339. fmt.Println(err)
  9340. }
  9341. userJSONBytes2, _ := json.Marshal(dat2)
  9342. var res2 models.Result3260
  9343. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9344. utils.ErrorLog("解析失败:%v", err)
  9345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9346. return
  9347. }
  9348. if res2.Infcode == 0 {
  9349. c.ServeSuccessJSON(map[string]interface{}{
  9350. "list": res2.Output.Data,
  9351. })
  9352. return
  9353. } else {
  9354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9355. return
  9356. }
  9357. }
  9358. func (c *HisApiController) ComfirmAllopatry() {
  9359. year := c.GetString("year")
  9360. month := c.GetString("month")
  9361. admin_user_id, _ := c.GetInt64("admin_user_id")
  9362. adminUser := c.GetAdminUserInfo()
  9363. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9364. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9365. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9366. var dat map[string]interface{}
  9367. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9368. fmt.Println(dat)
  9369. } else {
  9370. fmt.Println(err)
  9371. }
  9372. userJSONBytes, _ := json.Marshal(dat)
  9373. var res models.Result9001
  9374. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9375. utils.ErrorLog("解析失败:%v", err)
  9376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9377. return
  9378. }
  9379. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9380. var dat2 map[string]interface{}
  9381. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9382. fmt.Println(dat)
  9383. } else {
  9384. fmt.Println(err)
  9385. }
  9386. userJSONBytes2, _ := json.Marshal(dat2)
  9387. var res2 models.Result3260
  9388. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9389. utils.ErrorLog("解析失败:%v", err)
  9390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9391. return
  9392. }
  9393. if res2.Infcode == 0 {
  9394. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9395. var dat map[string]interface{}
  9396. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9397. fmt.Println(dat)
  9398. } else {
  9399. fmt.Println(err)
  9400. }
  9401. userJSONBytes, _ := json.Marshal(dat)
  9402. var res3 models.Result3261
  9403. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9404. utils.ErrorLog("解析失败:%v", err)
  9405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9406. return
  9407. }
  9408. if res3.Infcode == 0 {
  9409. record := &models.HisYidiClearRecord{
  9410. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9411. Ctime: time.Now().Unix(),
  9412. Mtime: time.Now().Unix(),
  9413. Status: 1,
  9414. MsgId: msgId,
  9415. }
  9416. service.SaveClearRecord(record)
  9417. c.ServeSuccessJSON(map[string]interface{}{
  9418. "msg": "提取成功",
  9419. })
  9420. }
  9421. }
  9422. }
  9423. func (c *HisApiController) RefundAllopatry() {
  9424. year := c.GetString("year")
  9425. month := c.GetString("month")
  9426. id, _ := c.GetInt64("id")
  9427. admin_user_id, _ := c.GetInt64("admin_user_id")
  9428. adminUser := c.GetAdminUserInfo()
  9429. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9430. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9431. record, _ := service.GetClearRecordById(id)
  9432. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9433. var dat map[string]interface{}
  9434. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9435. fmt.Println(dat)
  9436. } else {
  9437. fmt.Println(err)
  9438. }
  9439. userJSONBytes, _ := json.Marshal(dat)
  9440. var empty ResultFourteen
  9441. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9442. utils.ErrorLog("解析失败:%v", err)
  9443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9444. return
  9445. }
  9446. if empty.Infcode == 0 {
  9447. c.ServeSuccessJSON(map[string]interface{}{
  9448. "msg": "撤销成功",
  9449. })
  9450. return
  9451. }
  9452. }
  9453. func (c *HisApiController) ReversalOtherData() {
  9454. var customData []*CustomData
  9455. custom := &CustomData{
  9456. MsgId: "H44022900158202103301714472004",
  9457. PsnNo: "44020000001101329945",
  9458. Info: "2208",
  9459. }
  9460. customData = append(customData, custom)
  9461. custom1 := &CustomData{
  9462. MsgId: "H4402290015820210330172057803",
  9463. PsnNo: "44020000001101161813",
  9464. Info: "2208",
  9465. }
  9466. customData = append(customData, custom1)
  9467. custom2 := &CustomData{
  9468. MsgId: "H44022900158202103301705198813",
  9469. PsnNo: "44190000133097375417",
  9470. Info: "2208",
  9471. }
  9472. customData = append(customData, custom2)
  9473. custom3 := &CustomData{
  9474. MsgId: "H44022900158202103301715524756",
  9475. PsnNo: "44020000001100187221",
  9476. Info: "2208",
  9477. }
  9478. customData = append(customData, custom3)
  9479. custom4 := &CustomData{
  9480. MsgId: "H44022900158202103301730376224",
  9481. PsnNo: "44020000001101959155",
  9482. Info: "2208",
  9483. }
  9484. customData = append(customData, custom4)
  9485. custom5 := &CustomData{
  9486. MsgId: "H44022900158202103301748008725",
  9487. PsnNo: "44020000001104246641",
  9488. Info: "2208",
  9489. }
  9490. customData = append(customData, custom5)
  9491. custom6 := &CustomData{
  9492. MsgId: "H44022900158202103301718096755",
  9493. PsnNo: "44020000001102211860",
  9494. Info: "2208",
  9495. }
  9496. customData = append(customData, custom6)
  9497. custom7 := &CustomData{
  9498. MsgId: "H44022900158202103301736551640",
  9499. PsnNo: "44020000001102687718",
  9500. Info: "2208",
  9501. }
  9502. customData = append(customData, custom7)
  9503. custom8 := &CustomData{
  9504. MsgId: "H44022900158202103301743097676",
  9505. PsnNo: "44020000001102127785",
  9506. Info: "2208",
  9507. }
  9508. customData = append(customData, custom8)
  9509. custom9 := &CustomData{
  9510. MsgId: "H44022900158202103301712304203",
  9511. PsnNo: "44020000001101518097",
  9512. Info: "2208",
  9513. }
  9514. customData = append(customData, custom9)
  9515. custom10 := &CustomData{
  9516. MsgId: "H44022900158202103301738448785",
  9517. PsnNo: "44020000001100500813",
  9518. Info: "2208",
  9519. }
  9520. customData = append(customData, custom10)
  9521. custom11 := &CustomData{
  9522. MsgId: "H44022900158202103301732455843",
  9523. PsnNo: "44020000001102690557",
  9524. Info: "2208",
  9525. }
  9526. customData = append(customData, custom11)
  9527. custom12 := &CustomData{
  9528. MsgId: "H44022900158202103301745421708",
  9529. PsnNo: "44020000001102211928",
  9530. Info: "2208",
  9531. }
  9532. customData = append(customData, custom12)
  9533. custom1212 := &CustomData{
  9534. MsgId: "H440229001582021033017351627",
  9535. PsnNo: "44020000001102481733",
  9536. Info: "2208",
  9537. }
  9538. customData = append(customData, custom1212)
  9539. custom13 := &CustomData{
  9540. MsgId: "H44022900158202103301740327951",
  9541. PsnNo: "44020000001103174866",
  9542. Info: "2208",
  9543. }
  9544. customData = append(customData, custom13)
  9545. custom14 := &CustomData{
  9546. MsgId: "H4402290015820210330174922668",
  9547. PsnNo: "44020000001102927272",
  9548. Info: "2208",
  9549. }
  9550. customData = append(customData, custom14)
  9551. custom15 := &CustomData{
  9552. MsgId: "H44022900158202103301752362273",
  9553. PsnNo: "44020000001102942890",
  9554. Info: "2208",
  9555. }
  9556. customData = append(customData, custom15)
  9557. custom16 := &CustomData{
  9558. MsgId: "H44022900158202103301751082917",
  9559. PsnNo: "44020000001101662162",
  9560. Info: "2208",
  9561. }
  9562. customData = append(customData, custom16)
  9563. custom17 := &CustomData{
  9564. MsgId: "H44022900158202103301754147728",
  9565. PsnNo: "44020000000229014511",
  9566. Info: "2208",
  9567. }
  9568. customData = append(customData, custom17)
  9569. adminUser := c.GetAdminUserInfo()
  9570. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9571. for _, item := range customData {
  9572. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9573. fmt.Println(result)
  9574. }
  9575. }
  9576. func PathExists(path string) (bool, error) {
  9577. _, err := os.Stat(path)
  9578. if err == nil {
  9579. return true, nil
  9580. }
  9581. if os.IsNotExist(err) {
  9582. return false, nil
  9583. }
  9584. return false, err
  9585. }
  9586. //创建文件夹
  9587. func Mkdir(dir string) {
  9588. // 创建文件夹
  9589. exist, err := PathExists(dir)
  9590. if err != nil {
  9591. fmt.Println(err.Error())
  9592. } else {
  9593. if exist {
  9594. fmt.Println(dir + "文件夹已存在!")
  9595. } else {
  9596. // 文件夹名称,权限
  9597. err := os.Mkdir(dir, os.ModePerm)
  9598. if err != nil {
  9599. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9600. } else {
  9601. fmt.Println(dir + "文件夹创建成功!")
  9602. }
  9603. }
  9604. }
  9605. }
  9606. //压缩文件
  9607. func Zip(srcFile string, destZip string) error {
  9608. zipfile, err := os.Create(destZip)
  9609. if err != nil {
  9610. return err
  9611. }
  9612. defer zipfile.Close()
  9613. archive := zip.NewWriter(zipfile)
  9614. defer archive.Close()
  9615. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9616. if err != nil {
  9617. return err
  9618. }
  9619. header, err := zip.FileInfoHeader(info)
  9620. if err != nil {
  9621. return err
  9622. }
  9623. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9624. // header.Name = path
  9625. if info.IsDir() {
  9626. header.Name += "/"
  9627. } else {
  9628. header.Method = zip.Deflate
  9629. }
  9630. writer, err := archive.CreateHeader(header)
  9631. if err != nil {
  9632. return err
  9633. }
  9634. if !info.IsDir() {
  9635. file, err := os.Open(path)
  9636. if err != nil {
  9637. return err
  9638. }
  9639. defer file.Close()
  9640. _, err = io.Copy(writer, file)
  9641. }
  9642. return err
  9643. })
  9644. return err
  9645. }
  9646. func ReadFile(filePath string) []byte {
  9647. f, err := os.Open(filePath)
  9648. if err != nil {
  9649. fmt.Println("read file fail", err)
  9650. return nil
  9651. }
  9652. defer f.Close()
  9653. fd, err := ioutil.ReadAll(f)
  9654. if err != nil {
  9655. fmt.Println("read to fd fail", err)
  9656. return nil
  9657. }
  9658. return fd
  9659. }
  9660. func saveLog(result string, request string, infno string, desc string) {
  9661. org_id, _ := beego.AppConfig.Int64("org_id")
  9662. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9663. dir := miConfig.OrgName + "日志"
  9664. utils.Mkdir(dir)
  9665. month := time.Unix(1557042972, 0).Format("1")
  9666. year := time.Now().Format("2006")
  9667. month = time.Now().Format("01")
  9668. day := time.Now().Format("02")
  9669. hour := time.Now().Format("15")
  9670. min := time.Now().Format("04")
  9671. sec := time.Now().Format("05")
  9672. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9673. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9674. file_name := file + ".txt"
  9675. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9676. exist, _ := utils.PathExists(file_path)
  9677. if exist { //存在
  9678. fmt.Println("存在")
  9679. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9680. if err != nil {
  9681. fmt.Println("read fail")
  9682. }
  9683. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9684. n, _ := f.Seek(0, 2)
  9685. _, err = f.WriteAt([]byte(content), n)
  9686. } else { //不存在
  9687. fmt.Println("文件不存在,创建文件")
  9688. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9689. defer f.Close()
  9690. if err != nil {
  9691. } else {
  9692. _, err = f.Write([]byte("记录日志"))
  9693. }
  9694. }
  9695. }
  9696. type Charset string
  9697. const (
  9698. UTF8 = Charset("UTF-8")
  9699. GB18030 = Charset("GB18030")
  9700. )
  9701. func ConvertToString(src string, srcCode string, tagCode string) string {
  9702. srcCoder := mahonia.NewDecoder(srcCode)
  9703. srcResult := srcCoder.ConvertString(src)
  9704. tagCoder := mahonia.NewDecoder(tagCode)
  9705. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9706. result := string(cdata)
  9707. return result
  9708. }