his_api_controller.go 341KB

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