his_api_controller.go 341KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455
  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. data["diag_code"] = sickConfig.CountryCode
  3328. var ids []int64
  3329. for _, item := range prescriptions {
  3330. ids = append(ids, item.ID)
  3331. }
  3332. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3333. if config.IsOpen == 1 { //对接了医保,走医保流程
  3334. var res ResultFour
  3335. var resFour10265 ResultFour10265
  3336. if miConfig.MdtrtareaAdmvs == "421300" {
  3337. bytesData, _ := json.Marshal(data)
  3338. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3339. resp, _ := client.Do(req)
  3340. defer resp.Body.Close()
  3341. body, ioErr := ioutil.ReadAll(resp.Body)
  3342. if ioErr != nil {
  3343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3345. return
  3346. }
  3347. var respJSON map[string]interface{}
  3348. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3351. return
  3352. }
  3353. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3354. userJSONBytes, _ := json.Marshal(respJSON)
  3355. fmt.Println("log")
  3356. fmt.Println(string(userJSONBytes))
  3357. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3358. utils.ErrorLog("解析失败:%v", err)
  3359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3360. return
  3361. }
  3362. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3363. bytesData, _ := json.Marshal(data)
  3364. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3365. resp, _ := client.Do(req)
  3366. defer resp.Body.Close()
  3367. body, ioErr := ioutil.ReadAll(resp.Body)
  3368. if ioErr != nil {
  3369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3371. return
  3372. }
  3373. var respJSON map[string]interface{}
  3374. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3377. return
  3378. }
  3379. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3380. userJSONBytes, _ := json.Marshal(respJSON)
  3381. fmt.Println("log")
  3382. fmt.Println(string(userJSONBytes))
  3383. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3384. utils.ErrorLog("解析失败:%v", err)
  3385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3386. return
  3387. }
  3388. res.InfRefmsgid = resFour10265.InfRefmsgid
  3389. res.Output = resFour10265.Output
  3390. res.ErrMsg = resFour10265.ErrMsg
  3391. res.Cainfo = resFour10265.Cainfo
  3392. res.WarnMsg = resFour10265.WarnMsg
  3393. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3394. res.Infcode = infocode
  3395. } else {
  3396. if miConfig.Code == "H15049901371" {
  3397. 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)
  3398. var dat map[string]interface{}
  3399. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3400. fmt.Println(dat)
  3401. } else {
  3402. fmt.Println(err)
  3403. }
  3404. saveLog(result, request_log, "2204", "上传费用明细")
  3405. userJSONBytes, _ := json.Marshal(dat)
  3406. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3407. utils.ErrorLog("解析失败:%v", err)
  3408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3409. return
  3410. }
  3411. res.InfRefmsgid = resFour10265.InfRefmsgid
  3412. res.Output = resFour10265.Output
  3413. res.ErrMsg = resFour10265.ErrMsg
  3414. res.Cainfo = resFour10265.Cainfo
  3415. res.WarnMsg = resFour10265.WarnMsg
  3416. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3417. res.Infcode = infocode
  3418. } else {
  3419. 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)
  3420. var dat map[string]interface{}
  3421. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3422. fmt.Println(dat)
  3423. } else {
  3424. fmt.Println(err)
  3425. }
  3426. saveLog(result, request_log, "2204", "上传费用明细")
  3427. userJSONBytes, _ := json.Marshal(dat)
  3428. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3429. utils.ErrorLog("解析失败:%v", err)
  3430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3431. return
  3432. }
  3433. }
  3434. }
  3435. if res.Infcode == 0 {
  3436. order := &models.HisOrder{
  3437. UserOrgId: adminUser.CurrentOrgId,
  3438. HisPatientId: his.ID,
  3439. PatientId: his.PatientId,
  3440. SettleAccountsDate: recordDateTime,
  3441. Ctime: time.Now().Unix(),
  3442. Mtime: time.Now().Unix(),
  3443. Status: 1,
  3444. Number: chrg_bchno,
  3445. Infcode: res.Infcode,
  3446. WarnMsg: res.WarnMsg,
  3447. Cainfo: res.Cainfo,
  3448. ErrMsg: res.ErrMsg,
  3449. RespondTime: res.RefmsgTime,
  3450. InfRefmsgid: res.InfRefmsgid,
  3451. OrderStatus: 1,
  3452. PayWay: pay_way,
  3453. PayPrice: pay_price,
  3454. PayCardNo: pay_card_no,
  3455. DiscountPrice: discount_price,
  3456. PreferentialPrice: preferential_price,
  3457. RealityPrice: reality_price,
  3458. FoundPrice: found_price,
  3459. MedicalInsurancePrice: medical_insurance_price,
  3460. PrivatePrice: private_price,
  3461. IsMedicineInsurance: 1,
  3462. SettleType: settle_accounts_type,
  3463. SettleStartTime: start_time,
  3464. SettleEndTime: end_time,
  3465. Creator: roles.AdminUserId,
  3466. Modify: roles.AdminUserId,
  3467. FaPiaoNumber: fapiao_number,
  3468. FaPiaoCode: fapiao_code,
  3469. PType: 2,
  3470. Diagnosis: diagnosis_id,
  3471. }
  3472. err = service.CreateOrder(order)
  3473. if err != nil {
  3474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3475. return
  3476. }
  3477. for _, item := range res.Output.Result {
  3478. temp := strings.Split(item.FeedetlSn, "-")
  3479. var advice_id int64 = 0
  3480. var project_id int64 = 0
  3481. var types int64 = 0
  3482. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3483. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3484. if temp[1] == "1" {
  3485. advice_id = id
  3486. project_id = 0
  3487. } else if temp[1] == "2" {
  3488. advice_id = 0
  3489. project_id = id
  3490. }
  3491. info := &models.HisOrderInfo{
  3492. OrderNumber: order.Number,
  3493. FeedetlSn: item.FeedetlSn,
  3494. UploadDate: time.Now().Unix(),
  3495. AdviceId: advice_id,
  3496. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3497. Cnt: item.Cnt,
  3498. Pric: float64(item.Pric),
  3499. PatientId: his.PatientId,
  3500. PricUplmtAmt: item.PricUplmtAmt,
  3501. SelfpayProp: item.SelfpayProp,
  3502. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3503. OverlmtAmt: item.OverlmtAmt,
  3504. PreselfpayAmt: item.PreselfpayAmt,
  3505. BasMednFlag: item.BasMednFlag,
  3506. MedChrgitmType: item.MedChrgitmType,
  3507. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3508. Status: 1,
  3509. Memo: item.Memo,
  3510. Mtime: time.Now().Unix(),
  3511. InscpScpAmt: item.InscpScpAmt,
  3512. DrtReimFlag: item.DrtReimFlag,
  3513. Ctime: time.Now().Unix(),
  3514. ListSpItemFlag: item.ListSpItemFlag,
  3515. ChldMedcFlag: item.ChldMedcFlag,
  3516. LmtUsedFlag: item.LmtUsedFlag,
  3517. ChrgitmLv: item.ChrgitmLv,
  3518. UserOrgId: adminUser.CurrentOrgId,
  3519. HisPatientId: his.ID,
  3520. OrderId: order.ID,
  3521. ProjectId: project_id,
  3522. Type: types,
  3523. }
  3524. service.CreateOrderInfo(info)
  3525. }
  3526. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3527. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3528. var total float64
  3529. for _, item := range prescriptions {
  3530. if item.Type == 1 { //药品
  3531. for _, subItem := range item.HisDoctorAdviceInfo {
  3532. total = total + (subItem.Price * subItem.PrescribingNumber)
  3533. }
  3534. }
  3535. if item.Type == 2 { //项目
  3536. for _, subItem := range item.HisPrescriptionProject {
  3537. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3538. total = total + (subItem.Price * cnt)
  3539. }
  3540. }
  3541. }
  3542. for _, item := range prescriptions {
  3543. for _, subItem := range item.HisAdditionalCharge {
  3544. total = total + (subItem.Price * float64(subItem.Count))
  3545. }
  3546. }
  3547. var allTotal string
  3548. if adminUser.CurrentOrgId == 9919 {
  3549. allTotal = fmt.Sprintf("%.4f", total)
  3550. } else {
  3551. allTotal = fmt.Sprintf("%.4f", total)
  3552. }
  3553. if res.Infcode == 0 {
  3554. var rf []*ResultFive
  3555. json.Unmarshal([]byte(his.Iinfo), &rf)
  3556. chrg_bchno := chrg_bchno
  3557. cert_no := his.Certno
  3558. var insutypes []string
  3559. var insutype string
  3560. var is390 int = 0
  3561. var is310 int = 0
  3562. for _, item := range rf {
  3563. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3564. insutypes = append(insutypes, item.Insutype)
  3565. }
  3566. }
  3567. if len(insutypes) == 1 {
  3568. insutype = insutypes[0]
  3569. } else {
  3570. for _, i := range insutypes {
  3571. if i == "390" {
  3572. is390 = 1
  3573. }
  3574. if i == "310" {
  3575. is310 = 1
  3576. }
  3577. }
  3578. }
  3579. if is390 == 1 {
  3580. insutype = "390"
  3581. }
  3582. if is310 == 1 {
  3583. insutype = "310"
  3584. }
  3585. if len(insutypes) == 0 {
  3586. insutype = "310"
  3587. }
  3588. if len(insutypes) == 2 {
  3589. insutype = strconv.FormatInt(his.SocialType, 10)
  3590. }
  3591. insutype = strconv.FormatInt(his.SocialType, 10)
  3592. //insutype = "390"
  3593. if his.IdCardType == 1 {
  3594. // cert_no = his.MedicalInsuranceNumber
  3595. cert_no = his.Certno
  3596. } else {
  3597. cert_no = his.Certno
  3598. }
  3599. var res ResultSeven
  3600. var resSeven10265 ResultSeven10265
  3601. var src_resquest string
  3602. var result2 string
  3603. var acct_used_flag string
  3604. fmt.Println("pay_way")
  3605. fmt.Println(pay_way)
  3606. fmt.Println("pay_way")
  3607. if pay_way == 4 {
  3608. acct_used_flag = "1"
  3609. } else {
  3610. acct_used_flag = "0"
  3611. }
  3612. if miConfig.MdtrtareaAdmvs == "421300" {
  3613. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3614. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3615. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3616. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3617. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3618. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3619. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3620. resp, requestErr := http.Get(api)
  3621. if requestErr != nil {
  3622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3623. return
  3624. }
  3625. body, ioErr := ioutil.ReadAll(resp.Body)
  3626. if ioErr != nil {
  3627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3629. return
  3630. }
  3631. var respJSON map[string]interface{}
  3632. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3635. return
  3636. }
  3637. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3638. result, _ := json.Marshal(respJSON)
  3639. if miConfig.Code == "H15049901371" {
  3640. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3641. utils.ErrorLog("解析失败:%v", err)
  3642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3643. return
  3644. }
  3645. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3646. res.Output = resSeven10265.Output
  3647. res.ErrMsg = resSeven10265.ErrMsg
  3648. res.Cainfo = resSeven10265.Cainfo
  3649. res.WarnMsg = resSeven10265.WarnMsg
  3650. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3651. res.Infcode = infocode
  3652. } else {
  3653. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3654. utils.ErrorLog("解析失败:%v", err)
  3655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3656. return
  3657. }
  3658. }
  3659. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3660. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  3661. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3662. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3663. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3664. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3665. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3666. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3667. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3668. "&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
  3669. resp, requestErr := http.Get(api)
  3670. if requestErr != nil {
  3671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3672. return
  3673. }
  3674. body, ioErr := ioutil.ReadAll(resp.Body)
  3675. if ioErr != nil {
  3676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3678. return
  3679. }
  3680. var respJSON map[string]interface{}
  3681. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3684. return
  3685. }
  3686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3687. result, _ := json.Marshal(respJSON)
  3688. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  3689. utils.ErrorLog("解析失败:%v", err)
  3690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3691. return
  3692. }
  3693. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3694. res.Output = resSeven10265.Output
  3695. res.ErrMsg = resSeven10265.ErrMsg
  3696. res.Cainfo = resSeven10265.Cainfo
  3697. res.WarnMsg = resSeven10265.WarnMsg
  3698. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3699. res.Infcode = infocode
  3700. } else {
  3701. if miConfig.Code == "H15049901371" {
  3702. //赤峰地区国家医保医疗类别
  3703. //职工透析:医疗类别选特殊情况门诊990502
  3704. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3705. var med_type string
  3706. if his.Insutype == "390" {
  3707. if reg_type == 14 {
  3708. med_type = "9933"
  3709. } else if reg_type == 11 {
  3710. med_type = "11"
  3711. }
  3712. } else if his.Insutype == "310" {
  3713. if reg_type == 14 {
  3714. med_type = "990502"
  3715. } else if reg_type == 11 {
  3716. med_type = "11"
  3717. }
  3718. }
  3719. 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)
  3720. } else {
  3721. 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)
  3722. }
  3723. //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)
  3724. var dat map[string]interface{}
  3725. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3726. fmt.Println(dat)
  3727. } else {
  3728. fmt.Println(err)
  3729. }
  3730. saveLog(result2, src_resquest, "2207", "结算")
  3731. userJSONBytes, _ := json.Marshal(dat)
  3732. if miConfig.Code == "H15049901371" {
  3733. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  3734. utils.ErrorLog("解析失败:%v", err)
  3735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3736. return
  3737. }
  3738. res.InfRefmsgid = resSeven10265.InfRefmsgid
  3739. res.Output = resSeven10265.Output
  3740. res.ErrMsg = resSeven10265.ErrMsg
  3741. res.Cainfo = resSeven10265.Cainfo
  3742. res.WarnMsg = resSeven10265.WarnMsg
  3743. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  3744. res.Infcode = infocode
  3745. } else {
  3746. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3747. utils.ErrorLog("解析失败:%v", err)
  3748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3749. return
  3750. }
  3751. }
  3752. }
  3753. if res.Infcode != 0 {
  3754. errlog := &models.HisOrderError{
  3755. UserOrgId: adminUser.CurrentOrgId,
  3756. Ctime: time.Now().Unix(),
  3757. Mtime: time.Now().Unix(),
  3758. Number: chrg_bchno,
  3759. ErrMsg: res.ErrMsg,
  3760. Status: 1,
  3761. PatientId: id,
  3762. RecordTime: recordDateTime,
  3763. Stage: 6,
  3764. }
  3765. service.CreateErrMsgLog(errlog)
  3766. c.ServeSuccessJSON(map[string]interface{}{
  3767. "failed_code": -10,
  3768. "msg": res.ErrMsg,
  3769. })
  3770. return
  3771. } else {
  3772. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3773. order.OrderStatus = 2
  3774. order.Status = 1
  3775. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3776. order.SetlId = res.Output.Setlinfo.SetlID
  3777. order.PsnNo = res.Output.Setlinfo.PsnNo
  3778. order.PsnName = res.Output.Setlinfo.PsnName
  3779. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3780. order.Certno = res.Output.Setlinfo.Certno
  3781. order.Gend = res.Output.Setlinfo.Gend
  3782. order.Naty = res.Output.Setlinfo.Naty
  3783. order.Age = res.Output.Setlinfo.Age
  3784. order.Insutype = res.Output.Setlinfo.Insutype
  3785. order.PsnType = res.Output.Setlinfo.PsnType
  3786. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3787. order.SetlTime = res.Output.Setlinfo.SetlTime
  3788. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3789. if res.Output.Setlinfo.MedType == "140101" {
  3790. order.MedType = "14"
  3791. } else {
  3792. order.MedType = res.Output.Setlinfo.MedType
  3793. }
  3794. if reg_type == 1112 {
  3795. order.MedType = "1112"
  3796. }
  3797. if reg_type == 1111 {
  3798. order.MedType = "1111"
  3799. }
  3800. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3801. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3802. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3803. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3804. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3805. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3806. order.HifpPay = res.Output.Setlinfo.HifpPay
  3807. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3808. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3809. order.HifesPay = res.Output.Setlinfo.HifesPay
  3810. order.HifobPay = res.Output.Setlinfo.HifobPay
  3811. order.MafPay = res.Output.Setlinfo.MafPay
  3812. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3813. order.OthPay = res.Output.Setlinfo.OthPay
  3814. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3815. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3816. order.AcctPay = res.Output.Setlinfo.AcctPay
  3817. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3818. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3819. order.Balc = res.Output.Setlinfo.Balc
  3820. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3821. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3822. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3823. order.ClrType = res.Output.Setlinfo.ClrType
  3824. order.ClrWay = res.Output.Setlinfo.ClrWay
  3825. order.Creator = order.Creator
  3826. order.Modify = roles.AdminUserId
  3827. order.RequestLog = src_resquest
  3828. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3829. detailStr := string(setlDetail)
  3830. order.SetlDetail = detailStr
  3831. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3832. err = service.UpDateOrder(order)
  3833. if err == nil {
  3834. c.ServeSuccessJSON(map[string]interface{}{
  3835. "msg": "结算成功",
  3836. })
  3837. } else {
  3838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3839. return
  3840. }
  3841. }
  3842. } else {
  3843. adminUser := c.GetAdminUserInfo()
  3844. errlog := &models.HisOrderError{
  3845. UserOrgId: adminUser.CurrentOrgId,
  3846. Ctime: time.Now().Unix(),
  3847. Mtime: time.Now().Unix(),
  3848. ErrMsg: res.ErrMsg,
  3849. Status: 1,
  3850. PatientId: id,
  3851. RecordTime: recordDateTime,
  3852. Stage: 4,
  3853. }
  3854. service.CreateErrMsgLog(errlog)
  3855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3856. return
  3857. }
  3858. } else {
  3859. adminUser := c.GetAdminUserInfo()
  3860. errlog := &models.HisOrderError{
  3861. UserOrgId: adminUser.CurrentOrgId,
  3862. Ctime: time.Now().Unix(),
  3863. Mtime: time.Now().Unix(),
  3864. ErrMsg: res.ErrMsg,
  3865. Status: 1,
  3866. PatientId: id,
  3867. RecordTime: recordDateTime,
  3868. Stage: 4,
  3869. }
  3870. service.CreateErrMsgLog(errlog)
  3871. c.ServeSuccessJSON(map[string]interface{}{
  3872. "failed_code": -10,
  3873. "msg": res.ErrMsg,
  3874. })
  3875. return
  3876. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3877. //return
  3878. }
  3879. }
  3880. }
  3881. } else if tempOrder.ID > 0 {
  3882. if tempOrder.IsPre == 1 {
  3883. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  3884. var rf []*ResultFive
  3885. json.Unmarshal([]byte(his.Iinfo), &rf)
  3886. chrg_bchno := tempOrder.Number
  3887. cert_no := his.Certno
  3888. var insutypes []string
  3889. var insutype string
  3890. var is390 int = 0
  3891. var is310 int = 0
  3892. for _, item := range rf {
  3893. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3894. insutypes = append(insutypes, item.Insutype)
  3895. }
  3896. }
  3897. if len(insutypes) == 1 {
  3898. insutype = insutypes[0]
  3899. } else {
  3900. for _, i := range insutypes {
  3901. if i == "390" {
  3902. is390 = 1
  3903. }
  3904. if i == "310" {
  3905. is310 = 1
  3906. }
  3907. }
  3908. }
  3909. if is390 == 1 {
  3910. insutype = "390"
  3911. }
  3912. if is310 == 1 {
  3913. insutype = "310"
  3914. }
  3915. if len(insutypes) == 0 {
  3916. insutype = "310"
  3917. }
  3918. if len(insutypes) == 2 {
  3919. insutype = strconv.FormatInt(his.SocialType, 64)
  3920. }
  3921. //insutype = "390"
  3922. if his.IdCardType == 1 {
  3923. // cert_no = his.MedicalInsuranceNumber
  3924. cert_no = his.Certno
  3925. } else {
  3926. cert_no = his.Certno
  3927. }
  3928. var res ResultSeven
  3929. var resSeven10265 ResultSeven10265
  3930. var src_resquest string
  3931. var result2 string
  3932. var acct_used_flag string
  3933. fmt.Println("pay_way")
  3934. fmt.Println(pay_way)
  3935. fmt.Println("pay_way")
  3936. if pay_way == 4 {
  3937. acct_used_flag = "1"
  3938. } else {
  3939. acct_used_flag = "0"
  3940. }
  3941. if miConfig.MdtrtareaAdmvs == "421300" {
  3942. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3943. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3944. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3945. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3946. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3947. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3948. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3949. resp, requestErr := http.Get(api)
  3950. if requestErr != nil {
  3951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3952. return
  3953. }
  3954. body, ioErr := ioutil.ReadAll(resp.Body)
  3955. if ioErr != nil {
  3956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3958. return
  3959. }
  3960. var respJSON map[string]interface{}
  3961. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3964. return
  3965. }
  3966. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3967. result, _ := json.Marshal(respJSON)
  3968. fmt.Println("log")
  3969. fmt.Println(string(result))
  3970. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3971. utils.ErrorLog("解析失败:%v", err)
  3972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3973. return
  3974. }
  3975. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3976. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  3977. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3978. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3979. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3980. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3981. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3982. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3983. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3984. "&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
  3985. resp, requestErr := http.Get(api)
  3986. if requestErr != nil {
  3987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3988. return
  3989. }
  3990. body, ioErr := ioutil.ReadAll(resp.Body)
  3991. if ioErr != nil {
  3992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3994. return
  3995. }
  3996. var respJSON map[string]interface{}
  3997. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4000. return
  4001. }
  4002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4003. result, _ := json.Marshal(respJSON)
  4004. fmt.Println("log")
  4005. fmt.Println(string(result))
  4006. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4007. utils.ErrorLog("解析失败:%v", err)
  4008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4009. return
  4010. }
  4011. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4012. res.Output = resSeven10265.Output
  4013. res.ErrMsg = resSeven10265.ErrMsg
  4014. res.Cainfo = resSeven10265.Cainfo
  4015. res.WarnMsg = resSeven10265.WarnMsg
  4016. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4017. res.Infcode = infocode
  4018. } else {
  4019. var src_resquest string
  4020. if miConfig.Code == "H15049901371" {
  4021. //赤峰地区国家医保医疗类别
  4022. //职工透析:医疗类别选特殊情况门诊990502
  4023. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4024. var med_type string
  4025. if his.Insutype == "390" {
  4026. if reg_type == 14 {
  4027. med_type = "9933"
  4028. } else if reg_type == 11 {
  4029. med_type = "11"
  4030. }
  4031. } else if his.Insutype == "310" {
  4032. if reg_type == 14 {
  4033. med_type = "990502"
  4034. } else if reg_type == 11 {
  4035. med_type = "11"
  4036. }
  4037. }
  4038. 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)
  4039. } else {
  4040. 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)
  4041. }
  4042. var dat map[string]interface{}
  4043. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4044. fmt.Println(dat)
  4045. } else {
  4046. fmt.Println(err)
  4047. }
  4048. saveLog(result2, src_resquest, "2207", "结算")
  4049. userJSONBytes, _ := json.Marshal(dat)
  4050. if miConfig.Code == "H15049901371" {
  4051. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4052. utils.ErrorLog("解析失败:%v", err)
  4053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4054. return
  4055. }
  4056. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4057. res.Output = resSeven10265.Output
  4058. res.ErrMsg = resSeven10265.ErrMsg
  4059. res.Cainfo = resSeven10265.Cainfo
  4060. res.WarnMsg = resSeven10265.WarnMsg
  4061. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4062. res.Infcode = infocode
  4063. } else {
  4064. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4065. utils.ErrorLog("解析失败:%v", err)
  4066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4067. return
  4068. }
  4069. }
  4070. }
  4071. if res.Infcode != 0 {
  4072. errlog := &models.HisOrderError{
  4073. UserOrgId: adminUser.CurrentOrgId,
  4074. Ctime: time.Now().Unix(),
  4075. Mtime: time.Now().Unix(),
  4076. Number: chrg_bchno,
  4077. ErrMsg: res.ErrMsg,
  4078. Status: 1,
  4079. PatientId: id,
  4080. RecordTime: recordDateTime,
  4081. Stage: 6,
  4082. }
  4083. service.CreateErrMsgLog(errlog)
  4084. c.ServeSuccessJSON(map[string]interface{}{
  4085. "failed_code": -10,
  4086. "msg": res.ErrMsg,
  4087. })
  4088. return
  4089. } else {
  4090. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4091. order.OrderStatus = 2
  4092. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4093. order.SetlId = res.Output.Setlinfo.SetlID
  4094. order.PsnNo = res.Output.Setlinfo.PsnNo
  4095. order.PsnName = res.Output.Setlinfo.PsnName
  4096. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4097. order.Certno = res.Output.Setlinfo.Certno
  4098. order.Gend = res.Output.Setlinfo.Gend
  4099. order.Naty = res.Output.Setlinfo.Naty
  4100. order.Age = res.Output.Setlinfo.Age
  4101. order.Insutype = res.Output.Setlinfo.Insutype
  4102. order.PsnType = res.Output.Setlinfo.PsnType
  4103. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4104. order.SetlTime = res.Output.Setlinfo.SetlTime
  4105. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4106. //order.MedType = res.Output.Setlinfo.MedType
  4107. if reg_type == 1112 {
  4108. order.MedType = "1112"
  4109. }
  4110. if reg_type == 1111 {
  4111. order.MedType = "1111"
  4112. }
  4113. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4114. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4115. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4116. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4117. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4118. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4119. order.HifpPay = res.Output.Setlinfo.HifpPay
  4120. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4121. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4122. order.HifesPay = res.Output.Setlinfo.HifesPay
  4123. order.HifobPay = res.Output.Setlinfo.HifobPay
  4124. order.MafPay = res.Output.Setlinfo.MafPay
  4125. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4126. order.OthPay = res.Output.Setlinfo.OthPay
  4127. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4128. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4129. order.AcctPay = res.Output.Setlinfo.AcctPay
  4130. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4131. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4132. order.Balc = res.Output.Setlinfo.Balc
  4133. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4134. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4135. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4136. order.ClrWay = res.Output.Setlinfo.ClrWay
  4137. order.Creator = order.Creator
  4138. order.Modify = roles.AdminUserId
  4139. order.RequestLog = src_resquest
  4140. order.Diagnosis = diagnosis_id
  4141. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4142. detailStr := string(setlDetail)
  4143. order.SetlDetail = detailStr
  4144. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4145. err = service.UpDateOrder(order)
  4146. if err == nil {
  4147. c.ServeSuccessJSON(map[string]interface{}{
  4148. "msg": "结算成功",
  4149. })
  4150. } else {
  4151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4152. return
  4153. }
  4154. }
  4155. }
  4156. }
  4157. }
  4158. //func (c *HisApiController) GetPreUploadInfo() {
  4159. // id, _ := c.GetInt64("id")
  4160. // record_time := c.GetString("record_time")
  4161. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4162. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4163. //
  4164. // timeLayout := "2006-01-02"
  4165. // loc, _ := time.LoadLocation("Local")
  4166. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4167. // if err != nil {
  4168. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4169. // return
  4170. // }
  4171. // recordDateTime := theTime.Unix()
  4172. // adminUser := c.GetAdminUserInfo()
  4173. //
  4174. // var prescriptions []*models.HisPrescription
  4175. //
  4176. // var start_time int64
  4177. // var end_time int64
  4178. //
  4179. // data := make(map[string]interface{})
  4180. // if settle_accounts_type == 1 { //日结
  4181. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4182. // data["pre"] = prescriptions
  4183. //
  4184. // } else { //月结
  4185. // start_time_str := c.GetString("start_time")
  4186. // end_time_str := c.GetString("end_time")
  4187. // timeLayout := "2006-01-02"
  4188. // loc, _ := time.LoadLocation("Local")
  4189. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4190. // if err != nil {
  4191. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4192. // return
  4193. // }
  4194. // recordStartTime := theStartTime.Unix()
  4195. // start_time = recordStartTime
  4196. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4197. // if err != nil {
  4198. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4199. // return
  4200. // }
  4201. // recordEndTime := theEndTime.Unix()
  4202. // end_time = recordEndTime
  4203. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4204. // data["pre"] = prescriptions
  4205. //
  4206. // }
  4207. //
  4208. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4209. //
  4210. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4211. // timestamp := time.Now().Unix()
  4212. // tempTime := time.Unix(timestamp, 0)
  4213. // timeFormat := tempTime.Format("20060102150405")
  4214. // chrgBchno := rand.Intn(100000) + 10000
  4215. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4216. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4217. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4218. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4219. // strconv.FormatInt(his.PatientId, 10)
  4220. // client := &http.Client{}
  4221. // data["psn_no"] = his.PsnNo
  4222. // data["mdtrt_id"] = his.Number
  4223. // data["chrg_bchno"] = chrg_bchno
  4224. // data["org_name"] = miConfig.OrgName
  4225. // data["doctor"] = roles.UserName
  4226. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4227. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4228. // data["fixmedins_code"] = miConfig.Code
  4229. // data["dept_code"] = department.Number
  4230. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4231. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4232. // data["secret_key"] = miConfig.SecretKey
  4233. // var ids []int64
  4234. //
  4235. // for _, item := range prescriptions {
  4236. // ids = append(ids, item.ID)
  4237. // }
  4238. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4239. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4240. // bytesData, _ := json.Marshal(data)
  4241. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4242. // resp, _ := client.Do(req)
  4243. // defer resp.Body.Close()
  4244. // body, ioErr := ioutil.ReadAll(resp.Body)
  4245. // if ioErr != nil {
  4246. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4247. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4248. // return
  4249. // }
  4250. // var respJSON map[string]interface{}
  4251. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4252. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4253. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4254. // return
  4255. // }
  4256. //
  4257. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4258. // userJSONBytes, _ := json.Marshal(respJSON)
  4259. // var res ResultFour
  4260. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4261. // utils.ErrorLog("解析失败:%v", err)
  4262. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4263. // return
  4264. // }
  4265. //
  4266. // if res.Infcode == 0 {
  4267. // order := &models.HisOrder{
  4268. // UserOrgId: adminUser.CurrentOrgId,
  4269. // HisPatientId: his.ID,
  4270. // PatientId: his.PatientId,
  4271. // SettleAccountsDate: recordDateTime,
  4272. // Ctime: time.Now().Unix(),
  4273. // Mtime: time.Now().Unix(),
  4274. // Status: 1,
  4275. // Number: chrg_bchno,
  4276. // Infcode: res.Infcode,
  4277. // WarnMsg: res.WarnMsg,
  4278. // Cainfo: res.Cainfo,
  4279. // ErrMsg: res.ErrMsg,
  4280. // RespondTime: res.RefmsgTime,
  4281. // InfRefmsgid: res.InfRefmsgid,
  4282. // OrderStatus: 1,
  4283. // IsMedicineInsurance: 1,
  4284. // SettleType: settle_accounts_type,
  4285. // SettleStartTime: start_time,
  4286. // SettleEndTime: end_time,
  4287. // Creator: roles.ID,
  4288. // Modify: roles.ID,
  4289. // PType: 2,
  4290. // }
  4291. // err = service.CreateOrder(order)
  4292. // if err != nil {
  4293. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4294. // return
  4295. // }
  4296. //
  4297. // for _, item := range res.Output.Result {
  4298. // temp := strings.Split(item.FeedetlSn, "-")
  4299. // var advice_id int64 = 0
  4300. // var project_id int64 = 0
  4301. // var types int64 = 0
  4302. //
  4303. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4304. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4305. //
  4306. // if temp[1] == "1" {
  4307. // advice_id = id
  4308. // project_id = 0
  4309. // } else if temp[1] == "2" {
  4310. // advice_id = 0
  4311. // project_id = id
  4312. // }
  4313. //
  4314. // info := &models.HisOrderInfo{
  4315. // OrderNumber: order.Number,
  4316. // FeedetlSn: item.FeedetlSn,
  4317. // UploadDate: time.Now().Unix(),
  4318. // AdviceId: advice_id,
  4319. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4320. // Cnt: item.Cnt,
  4321. // Pric: float64(item.Pric),
  4322. // PatientId: his.PatientId,
  4323. // PricUplmtAmt: item.PricUplmtAmt,
  4324. // SelfpayProp: item.SelfpayProp,
  4325. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4326. // OverlmtAmt: item.OverlmtAmt,
  4327. // PreselfpayAmt: item.PreselfpayAmt,
  4328. // BasMednFlag: item.BasMednFlag,
  4329. // MedChrgitmType: item.MedChrgitmType,
  4330. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4331. // Status: 1,
  4332. // Memo: item.Memo,
  4333. // Mtime: time.Now().Unix(),
  4334. // InscpScpAmt: item.InscpScpAmt,
  4335. // DrtReimFlag: item.DrtReimFlag,
  4336. // Ctime: time.Now().Unix(),
  4337. // ListSpItemFlag: item.ListSpItemFlag,
  4338. // ChldMedcFlag: item.ChldMedcFlag,
  4339. // LmtUsedFlag: item.LmtUsedFlag,
  4340. // ChrgitmLv: item.ChrgitmLv,
  4341. // UserOrgId: adminUser.CurrentOrgId,
  4342. // HisPatientId: his.ID,
  4343. // OrderId: order.ID,
  4344. // ProjectId: project_id,
  4345. // Type: types,
  4346. // }
  4347. // service.CreateOrderInfo(info)
  4348. //
  4349. // }
  4350. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4351. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4352. //
  4353. // var total float64
  4354. // for _, item := range prescriptions {
  4355. // if item.Type == 1 { //药品
  4356. // for _, subItem := range item.HisDoctorAdviceInfo {
  4357. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4358. // }
  4359. // }
  4360. // if item.Type == 2 { //项目
  4361. // for _, subItem := range item.HisPrescriptionProject {
  4362. // total = total + (subItem.Price * float64(subItem.Count))
  4363. // }
  4364. // }
  4365. // }
  4366. //
  4367. // for _, item := range prescriptions {
  4368. // for _, subItem := range item.HisAdditionalCharge {
  4369. // total = total + (subItem.Price * float64(subItem.Count))
  4370. // }
  4371. // }
  4372. //
  4373. // allTotal := fmt.Sprintf("%.2f", total)
  4374. // if res.Infcode == 0 {
  4375. // var rf []*ResultFive
  4376. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4377. // psn_no := his.PsnNo
  4378. // mdtrt_id := his.Number
  4379. // chrg_bchno := chrg_bchno
  4380. // cert_no := his.Certno
  4381. // insutype := rf[0].Insutype
  4382. //
  4383. // if his.IdCardType == 1 {
  4384. // cert_no = his.MedicalInsuranceNumber
  4385. //
  4386. // } else {
  4387. //
  4388. // cert_no = his.Certno
  4389. //
  4390. // }
  4391. //
  4392. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  4393. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  4394. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  4395. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  4396. // resp, requestErr := http.Get(api)
  4397. // if requestErr != nil {
  4398. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4399. // return
  4400. // }
  4401. // defer resp.Body.Close()
  4402. // body, ioErr := ioutil.ReadAll(resp.Body)
  4403. // if ioErr != nil {
  4404. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4406. // return
  4407. // }
  4408. // var respJSON map[string]interface{}
  4409. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4410. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4411. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4412. // return
  4413. // }
  4414. // fmt.Println(respJSON)
  4415. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4416. // userJSONBytes, _ := json.Marshal(respJSON)
  4417. // var res ResultSeven
  4418. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4419. // utils.ErrorLog("解析失败:%v", err)
  4420. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4421. // return
  4422. // }
  4423. // if res.Infcode != 0 {
  4424. // errlog := &models.HisOrderError{
  4425. // UserOrgId: adminUser.CurrentOrgId,
  4426. // Ctime: time.Now().Unix(),
  4427. // Mtime: time.Now().Unix(),
  4428. // Number: chrg_bchno,
  4429. // ErrMsg: res.ErrMsg,
  4430. // Status: 1,
  4431. // PatientId: id,
  4432. // RecordTime: recordDateTime,
  4433. // Stage: 7,
  4434. // }
  4435. // service.CreateErrMsgLog(errlog)
  4436. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4437. // return
  4438. // } else {
  4439. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4440. // order.OrderStatus = 1
  4441. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4442. // order.SetlId = res.Output.Setlinfo.SetlID
  4443. // order.PsnNo = res.Output.Setlinfo.PsnNo
  4444. // order.PsnName = res.Output.Setlinfo.PsnName
  4445. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4446. // order.Certno = res.Output.Setlinfo.Certno
  4447. // order.Gend = res.Output.Setlinfo.Gend
  4448. // order.Naty = res.Output.Setlinfo.Naty
  4449. // order.Age = res.Output.Setlinfo.Age
  4450. // order.Insutype = res.Output.Setlinfo.Insutype
  4451. // order.PsnType = res.Output.Setlinfo.PsnType
  4452. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4453. // order.SetlTime = res.Output.Setlinfo.SetlTime
  4454. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4455. // order.MedType = res.Output.Setlinfo.MedType
  4456. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4457. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4458. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4459. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4460. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4461. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4462. // order.HifpPay = res.Output.Setlinfo.HifpPay
  4463. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4464. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4465. // order.HifesPay = res.Output.Setlinfo.HifesPay
  4466. // order.HifobPay = res.Output.Setlinfo.HifobPay
  4467. // order.MafPay = res.Output.Setlinfo.MafPay
  4468. // order.OthPay = res.Output.Setlinfo.OthPay
  4469. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4470. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4471. // order.AcctPay = res.Output.Setlinfo.AcctPay
  4472. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4473. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4474. // order.Balc = res.Output.Setlinfo.Balc
  4475. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4476. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4477. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4478. // order.ClrWay = res.Output.Setlinfo.ClrWay
  4479. // order.Creator = order.Creator
  4480. // order.Modify = roles.ID
  4481. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4482. // detailStr := string(setlDetail)
  4483. // order.SetlDetail = detailStr
  4484. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4485. // err = service.UpDateOrder(order)
  4486. // if err == nil {
  4487. // c.ServeSuccessJSON(map[string]interface{}{
  4488. // "msg": "预结算成功",
  4489. // })
  4490. // } else {
  4491. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4492. // return
  4493. // }
  4494. // }
  4495. // } else {
  4496. // adminUser := c.GetAdminUserInfo()
  4497. // errlog := &models.HisOrderError{
  4498. // UserOrgId: adminUser.CurrentOrgId,
  4499. // Ctime: time.Now().Unix(),
  4500. // Mtime: time.Now().Unix(),
  4501. // ErrMsg: res.ErrMsg,
  4502. // Status: 1,
  4503. // PatientId: id,
  4504. // RecordTime: recordDateTime,
  4505. // Stage: 4,
  4506. // }
  4507. // service.CreateErrMsgLog(errlog)
  4508. //
  4509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4510. // return
  4511. // }
  4512. // } else {
  4513. // adminUser := c.GetAdminUserInfo()
  4514. // errlog := &models.HisOrderError{
  4515. // UserOrgId: adminUser.CurrentOrgId,
  4516. // Ctime: time.Now().Unix(),
  4517. // Mtime: time.Now().Unix(),
  4518. // ErrMsg: res.ErrMsg,
  4519. // Status: 1,
  4520. // PatientId: id,
  4521. // RecordTime: recordDateTime,
  4522. // Stage: 4,
  4523. // }
  4524. // service.CreateErrMsgLog(errlog)
  4525. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4526. // return
  4527. // }
  4528. //
  4529. // } else {
  4530. // var total float64
  4531. // for _, item := range prescriptions {
  4532. // if item.Type == 1 { //药品
  4533. // for _, subItem := range item.HisDoctorAdviceInfo {
  4534. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4535. // }
  4536. // }
  4537. // if item.Type == 2 { //项目
  4538. // for _, subItem := range item.HisPrescriptionProject {
  4539. // total = total + (subItem.Price * float64(subItem.Count))
  4540. // }
  4541. // }
  4542. //
  4543. // for _, subItem := range item.HisAdditionalCharge {
  4544. // total = total + (subItem.Price * float64(subItem.Count))
  4545. // }
  4546. // }
  4547. //
  4548. // allTotal := fmt.Sprintf("%.2f", total)
  4549. // totals, _ := strconv.ParseFloat(allTotal, 64)
  4550. // order := &models.HisOrder{
  4551. // UserOrgId: adminUser.CurrentOrgId,
  4552. // HisPatientId: his.ID,
  4553. // PatientId: id,
  4554. // SettleAccountsDate: recordDateTime,
  4555. // Ctime: time.Now().Unix(),
  4556. // Mtime: time.Now().Unix(),
  4557. // Status: 1,
  4558. // OrderStatus: 2,
  4559. // Number: chrg_bchno,
  4560. // MedfeeSumamt: totals,
  4561. // }
  4562. // err = service.CreateOrder(order)
  4563. // if err != nil {
  4564. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4565. // return
  4566. // }
  4567. //
  4568. // var customs []*Custom
  4569. // for _, item := range prescriptions {
  4570. //
  4571. // if item.Type == 1 { //药品
  4572. // for _, subItem := range item.HisDoctorAdviceInfo {
  4573. // cus := &Custom{
  4574. // AdviceId: subItem.ID,
  4575. // ProjectId: 0,
  4576. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  4577. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  4578. // FeedetlSn: subItem.FeedetlSn,
  4579. // Price: fmt.Sprintf("%.2f", subItem.Price),
  4580. // MedListCodg: subItem.MedListCodg,
  4581. // Type: 1,
  4582. // }
  4583. // customs = append(customs, cus)
  4584. // }
  4585. // }
  4586. //
  4587. // if item.Type == 2 { //项目
  4588. // for _, subItem := range item.HisPrescriptionProject {
  4589. //
  4590. // cus := &Custom{
  4591. // AdviceId: 0,
  4592. // ProjectId: subItem.ID,
  4593. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  4594. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  4595. // FeedetlSn: subItem.FeedetlSn,
  4596. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  4597. // MedListCodg: subItem.MedListCodg,
  4598. // Type: 2,
  4599. // }
  4600. //
  4601. // customs = append(customs, cus)
  4602. // }
  4603. // }
  4604. //
  4605. // for _, item := range item.HisAdditionalCharge {
  4606. // cus := &Custom{
  4607. // ItemId: item.ID,
  4608. // AdviceId: 0,
  4609. // ProjectId: 0,
  4610. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  4611. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  4612. // FeedetlSn: item.FeedetlSn,
  4613. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  4614. // MedListCodg: item.XtHisAddtionConfig.Code,
  4615. // Type: 3,
  4616. // }
  4617. //
  4618. // customs = append(customs, cus)
  4619. // }
  4620. //
  4621. // }
  4622. //
  4623. // for _, item := range customs {
  4624. // var advice_id int64 = 0
  4625. // var project_id int64 = 0
  4626. // var item_id int64 = 0
  4627. //
  4628. // var types int64 = 0
  4629. //
  4630. // if item.Type == 1 {
  4631. // advice_id = item.AdviceId
  4632. // project_id = 0
  4633. // item_id = 0
  4634. // } else if item.Type == 2 {
  4635. // advice_id = 0
  4636. // item_id = 0
  4637. //
  4638. // project_id = item.ProjectId
  4639. // } else if item.Type == 3 {
  4640. // advice_id = 0
  4641. // item_id = item.ItemId
  4642. // project_id = 0
  4643. // }
  4644. //
  4645. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  4646. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  4647. // pric, _ := strconv.ParseFloat(item.Price, 32)
  4648. //
  4649. // info := &models.HisOrderInfo{
  4650. // OrderNumber: order.Number,
  4651. // UploadDate: time.Now().Unix(),
  4652. // AdviceId: advice_id,
  4653. // DetItemFeeSumamt: detItemFeeSumamt,
  4654. // Cnt: cut,
  4655. // Pric: pric,
  4656. // PatientId: id,
  4657. // Status: 1,
  4658. // Mtime: time.Now().Unix(),
  4659. // Ctime: time.Now().Unix(),
  4660. // UserOrgId: adminUser.CurrentOrgId,
  4661. // HisPatientId: his.ID,
  4662. // OrderId: order.ID,
  4663. // ProjectId: project_id,
  4664. // Type: types,
  4665. // ItemId: item_id,
  4666. // }
  4667. // service.CreateOrderInfo(info)
  4668. // }
  4669. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4670. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4671. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  4672. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4673. // if err == nil {
  4674. // c.ServeSuccessJSON(map[string]interface{}{
  4675. // "msg": "结算成功",
  4676. // })
  4677. // } else {
  4678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4679. // return
  4680. // }
  4681. // }
  4682. //}
  4683. //上传明细-预结算-
  4684. func (c *HisApiController) GetPreUploadInfo() {
  4685. id, _ := c.GetInt64("id")
  4686. record_time := c.GetString("record_time")
  4687. his_patient_id, _ := c.GetInt64("his_patient_id")
  4688. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4689. admin_user_id, _ := c.GetInt64("admin_user_id")
  4690. diagnosis_id := c.GetString("diagnosis")
  4691. sick_type, _ := c.GetInt64("sick_type")
  4692. reg_type, _ := c.GetInt64("p_type")
  4693. begin_time := c.GetString("begin_time")
  4694. id_str := c.GetString("ids")
  4695. ids_arr := strings.Split(id_str, ",")
  4696. timeLayout := "2006-01-02"
  4697. loc, _ := time.LoadLocation("Local")
  4698. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4699. if err != nil {
  4700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4701. return
  4702. }
  4703. recordDateTime := theTime.Unix()
  4704. adminUser := c.GetAdminUserInfo()
  4705. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4706. var config []*models.HisXtDiagnoseConfig
  4707. for _, item := range diagnosis_ids {
  4708. id, _ := strconv.ParseInt(item, 10, 64)
  4709. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4710. config = append(config, &diagnosisConfig)
  4711. }
  4712. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4713. sickConfig, _ := service.FindSickById(sick_type)
  4714. var prescriptions []*models.HisPrescription
  4715. var start_time int64
  4716. var end_time int64
  4717. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4718. fmt.Println(his_patient_id)
  4719. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4720. timestamp := time.Now().Unix()
  4721. tempTime := time.Unix(timestamp, 0)
  4722. timeFormat := tempTime.Format("20060102150405")
  4723. chrgBchno := rand.Intn(100000) + 10000
  4724. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4725. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4726. var patientPrescription models.HisPrescriptionInfo
  4727. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4728. if patientPrescription.ID == 0 {
  4729. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4730. }
  4731. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4732. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4733. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4734. strconv.FormatInt(his.PatientId, 10)
  4735. var res2 ResultSix
  4736. var resSix10265 ResultSix10265
  4737. var time_stamp string
  4738. if miConfig.InsuplcAdmdvs == "421300" {
  4739. data := make(map[string]interface{})
  4740. client := &http.Client{}
  4741. data["psn_no"] = his.PsnNo
  4742. data["mdtrt_id"] = his.Number
  4743. data["doctor"] = roles.UserName
  4744. data["department"] = department.Name
  4745. data["org_name"] = miConfig.OrgName
  4746. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4747. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4748. data["fixmedins_code"] = miConfig.Code
  4749. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4750. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4751. data["secret_key"] = miConfig.SecretKey
  4752. data["sick_code"] = sickConfig.CountryCode
  4753. data["sick_name"] = sickConfig.ClassName
  4754. data["begin_time"] = begin_time
  4755. data["dept"] = strconv.FormatInt(department.ID, 10)
  4756. data["config"] = config
  4757. fmt.Println(data)
  4758. bytesData, _ := json.Marshal(data)
  4759. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4760. resp, _ := client.Do(req)
  4761. defer resp.Body.Close()
  4762. body, ioErr := ioutil.ReadAll(resp.Body)
  4763. if ioErr != nil {
  4764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4766. return
  4767. }
  4768. var respJSON map[string]interface{}
  4769. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4772. return
  4773. }
  4774. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4775. userJSONBytes, _ := json.Marshal(respJSON)
  4776. fmt.Println("log")
  4777. fmt.Println(string(userJSONBytes))
  4778. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4779. utils.ErrorLog("解析失败:%v", err)
  4780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4781. return
  4782. }
  4783. } else if miConfig.InsuplcAdmdvs == "320921" {
  4784. data := make(map[string]interface{})
  4785. client := &http.Client{}
  4786. data["psn_no"] = his.PsnNo
  4787. data["mdtrt_id"] = his.Number
  4788. data["doctor"] = roles.UserName
  4789. data["department"] = department.Name
  4790. data["org_name"] = miConfig.OrgName
  4791. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4792. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4793. data["fixmedins_code"] = miConfig.Code
  4794. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4795. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4796. data["secret_key"] = miConfig.SecretKey
  4797. data["sick_code"] = sickConfig.CountryCode
  4798. data["sick_name"] = sickConfig.ClassName
  4799. data["begin_time"] = begin_time
  4800. data["dept"] = strconv.FormatInt(department.ID, 10)
  4801. data["config"] = config
  4802. data["url"] = miConfig.Url
  4803. data["ak"] = miConfig.ChannelNumber
  4804. fmt.Println(data)
  4805. bytesData, _ := json.Marshal(data)
  4806. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4807. resp, _ := client.Do(req)
  4808. defer resp.Body.Close()
  4809. body, ioErr := ioutil.ReadAll(resp.Body)
  4810. if ioErr != nil {
  4811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4813. return
  4814. }
  4815. var respJSON map[string]interface{}
  4816. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4819. return
  4820. }
  4821. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  4822. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  4823. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  4824. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4825. userJSONBytes, _ := json.Marshal(respJSON)
  4826. fmt.Println("log")
  4827. fmt.Println(string(userJSONBytes))
  4828. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  4829. utils.ErrorLog("解析失败:%v", err)
  4830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4831. return
  4832. }
  4833. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4834. res2.Output = resSix10265.Output
  4835. res2.ErrMsg = resSix10265.ErrMsg
  4836. res2.Cainfo = resSix10265.Cainfo
  4837. res2.WarnMsg = resSix10265.WarnMsg
  4838. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  4839. res2.Infcode = infocode
  4840. } else {
  4841. var result string
  4842. var requestLog string
  4843. if miConfig.InsuplcAdmdvs == "440781" { //
  4844. 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)
  4845. } else {
  4846. if miConfig.Code == "H15049901371" {
  4847. //赤峰地区国家医保医疗类别
  4848. //职工透析:医疗类别选特殊情况门诊990502
  4849. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4850. var med_type string
  4851. if his.Insutype == "390" {
  4852. if reg_type == 14 {
  4853. med_type = "9933"
  4854. } else if reg_type == 11 {
  4855. med_type = "11"
  4856. }
  4857. } else if his.Insutype == "310" {
  4858. if reg_type == 14 {
  4859. med_type = "990502"
  4860. } else if reg_type == 11 {
  4861. med_type = "11"
  4862. }
  4863. }
  4864. 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)
  4865. } else {
  4866. 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)
  4867. }
  4868. saveLog(result, requestLog, "2203", "上传就诊信息")
  4869. var respJSON2 map[string]interface{}
  4870. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4873. return
  4874. }
  4875. userJSONBytes2, _ := json.Marshal(respJSON2)
  4876. if miConfig.Code == "H15049901371" {
  4877. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  4878. utils.ErrorLog("解析失败:%v", err)
  4879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4880. return
  4881. }
  4882. res2.InfRefmsgid = resSix10265.InfRefmsgid
  4883. res2.Output = resSix10265.Output
  4884. res2.ErrMsg = resSix10265.ErrMsg
  4885. res2.Cainfo = resSix10265.Cainfo
  4886. res2.WarnMsg = resSix10265.WarnMsg
  4887. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  4888. res2.Infcode = infocode
  4889. } else {
  4890. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4891. utils.ErrorLog("解析失败:%v", err)
  4892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4893. return
  4894. }
  4895. }
  4896. }
  4897. }
  4898. if res2.Infcode != 0 {
  4899. adminUser := c.GetAdminUserInfo()
  4900. errlog := &models.HisOrderError{
  4901. UserOrgId: adminUser.CurrentOrgId,
  4902. Ctime: time.Now().Unix(),
  4903. Mtime: time.Now().Unix(),
  4904. ErrMsg: res2.ErrMsg,
  4905. Status: 1,
  4906. PatientId: id,
  4907. RecordTime: recordDateTime,
  4908. Stage: 3,
  4909. }
  4910. service.CreateErrMsgLog(errlog)
  4911. c.ServeSuccessJSON(map[string]interface{}{
  4912. "failed_code": -10,
  4913. "msg": res2.ErrMsg,
  4914. })
  4915. return
  4916. } else {
  4917. his.Diagnosis = diagnosis_id
  4918. his.SickType = sickConfig.ID
  4919. his.PType = fmt.Sprintf("%d", reg_type)
  4920. service.UpdateHisPatientThree(&his)
  4921. data := make(map[string]interface{})
  4922. if settle_accounts_type == 1 { //日结
  4923. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4924. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4925. } else {
  4926. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4927. }
  4928. data["pre"] = prescriptions
  4929. } else { //月结
  4930. start_time_str := c.GetString("start_time")
  4931. end_time_str := c.GetString("end_time")
  4932. timeLayout := "2006-01-02"
  4933. loc, _ := time.LoadLocation("Local")
  4934. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4935. if err != nil {
  4936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4937. return
  4938. }
  4939. recordStartTime := theStartTime.Unix()
  4940. start_time = recordStartTime
  4941. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4942. if err != nil {
  4943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4944. return
  4945. }
  4946. recordEndTime := theEndTime.Unix()
  4947. end_time = recordEndTime
  4948. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4949. data["pre"] = prescriptions
  4950. }
  4951. client := &http.Client{}
  4952. data["psn_no"] = his.PsnNo
  4953. data["mdtrt_id"] = his.Number
  4954. data["chrg_bchno"] = chrg_bchno
  4955. data["org_name"] = miConfig.OrgName
  4956. data["doctor"] = roles.UserName
  4957. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4958. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4959. data["fixmedins_code"] = miConfig.Code
  4960. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4961. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4962. data["dept_code"] = "15"
  4963. } else {
  4964. data["dept_code"] = department.Number
  4965. }
  4966. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4967. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4968. data["secret_key"] = miConfig.SecretKey
  4969. data["url"] = miConfig.Url
  4970. data["ak"] = miConfig.ChannelNumber
  4971. data["new_doctor_name"] = patientPrescription.Doctor
  4972. data["diag_code"] = sickConfig.CountryCode
  4973. data["time_stamp"] = time_stamp
  4974. var ids []int64
  4975. for _, item := range prescriptions {
  4976. ids = append(ids, item.ID)
  4977. }
  4978. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4979. if config.IsOpen == 1 { //对接了医保,走医保流程
  4980. var res ResultFour
  4981. var resFour10265 ResultFour10265
  4982. if miConfig.MdtrtareaAdmvs == "421300" {
  4983. bytesData, _ := json.Marshal(data)
  4984. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4985. resp, _ := client.Do(req)
  4986. defer resp.Body.Close()
  4987. body, ioErr := ioutil.ReadAll(resp.Body)
  4988. if ioErr != nil {
  4989. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4991. return
  4992. }
  4993. var respJSON map[string]interface{}
  4994. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4997. return
  4998. }
  4999. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5000. userJSONBytes, _ := json.Marshal(respJSON)
  5001. fmt.Println("log")
  5002. fmt.Println(string(userJSONBytes))
  5003. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5004. utils.ErrorLog("解析失败:%v", err)
  5005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5006. return
  5007. }
  5008. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5009. bytesData, _ := json.Marshal(data)
  5010. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5011. resp, _ := client.Do(req)
  5012. defer resp.Body.Close()
  5013. body, ioErr := ioutil.ReadAll(resp.Body)
  5014. if ioErr != nil {
  5015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5017. return
  5018. }
  5019. var respJSON map[string]interface{}
  5020. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5023. return
  5024. }
  5025. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5026. userJSONBytes, _ := json.Marshal(respJSON)
  5027. fmt.Println("log")
  5028. fmt.Println(string(userJSONBytes))
  5029. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5030. utils.ErrorLog("解析失败:%v", err)
  5031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5032. return
  5033. }
  5034. res.InfRefmsgid = resFour10265.InfRefmsgid
  5035. res.Output = resFour10265.Output
  5036. res.ErrMsg = resFour10265.ErrMsg
  5037. res.Cainfo = resFour10265.Cainfo
  5038. res.WarnMsg = resFour10265.WarnMsg
  5039. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5040. res.Infcode = infocode
  5041. } else {
  5042. if miConfig.Code == "H15049901371" {
  5043. 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)
  5044. var dat map[string]interface{}
  5045. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5046. fmt.Println(dat)
  5047. } else {
  5048. fmt.Println(err)
  5049. }
  5050. saveLog(result, request_log, "2204", "上传费用明细")
  5051. userJSONBytes, _ := json.Marshal(dat)
  5052. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5053. utils.ErrorLog("解析失败:%v", err)
  5054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5055. return
  5056. }
  5057. res.InfRefmsgid = resFour10265.InfRefmsgid
  5058. res.Output = resFour10265.Output
  5059. res.ErrMsg = resFour10265.ErrMsg
  5060. res.Cainfo = resFour10265.Cainfo
  5061. res.WarnMsg = resFour10265.WarnMsg
  5062. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5063. res.Infcode = infocode
  5064. } else {
  5065. 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)
  5066. var dat map[string]interface{}
  5067. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5068. fmt.Println(dat)
  5069. } else {
  5070. fmt.Println(err)
  5071. }
  5072. saveLog(result, request_log, "2204", "上传费用明细")
  5073. userJSONBytes, _ := json.Marshal(dat)
  5074. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5075. utils.ErrorLog("解析失败:%v", err)
  5076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5077. return
  5078. }
  5079. }
  5080. }
  5081. if res.Infcode == 0 {
  5082. order := &models.HisOrder{
  5083. UserOrgId: adminUser.CurrentOrgId,
  5084. HisPatientId: his.ID,
  5085. PatientId: his.PatientId,
  5086. SettleAccountsDate: recordDateTime,
  5087. Ctime: time.Now().Unix(),
  5088. Mtime: time.Now().Unix(),
  5089. Status: 1,
  5090. Number: chrg_bchno,
  5091. Infcode: res.Infcode,
  5092. WarnMsg: res.WarnMsg,
  5093. Cainfo: res.Cainfo,
  5094. ErrMsg: res.ErrMsg,
  5095. RespondTime: res.RefmsgTime,
  5096. InfRefmsgid: res.InfRefmsgid,
  5097. OrderStatus: 1,
  5098. IsMedicineInsurance: 1,
  5099. SettleType: settle_accounts_type,
  5100. SettleStartTime: start_time,
  5101. SettleEndTime: end_time,
  5102. Creator: roles.AdminUserId,
  5103. Modify: roles.AdminUserId,
  5104. PType: 2,
  5105. Diagnosis: diagnosis_id,
  5106. }
  5107. err = service.CreateOrder(order)
  5108. if err != nil {
  5109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5110. return
  5111. }
  5112. for _, item := range res.Output.Result {
  5113. temp := strings.Split(item.FeedetlSn, "-")
  5114. var advice_id int64 = 0
  5115. var project_id int64 = 0
  5116. var types int64 = 0
  5117. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5118. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5119. if temp[1] == "1" {
  5120. advice_id = id
  5121. project_id = 0
  5122. } else if temp[1] == "2" {
  5123. advice_id = 0
  5124. project_id = id
  5125. }
  5126. info := &models.HisOrderInfo{
  5127. OrderNumber: order.Number,
  5128. FeedetlSn: item.FeedetlSn,
  5129. UploadDate: time.Now().Unix(),
  5130. AdviceId: advice_id,
  5131. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5132. Cnt: item.Cnt,
  5133. Pric: float64(item.Pric),
  5134. PatientId: his.PatientId,
  5135. PricUplmtAmt: item.PricUplmtAmt,
  5136. SelfpayProp: item.SelfpayProp,
  5137. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5138. OverlmtAmt: item.OverlmtAmt,
  5139. PreselfpayAmt: item.PreselfpayAmt,
  5140. BasMednFlag: item.BasMednFlag,
  5141. MedChrgitmType: item.MedChrgitmType,
  5142. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5143. Status: 1,
  5144. Memo: item.Memo,
  5145. Mtime: time.Now().Unix(),
  5146. InscpScpAmt: item.InscpScpAmt,
  5147. DrtReimFlag: item.DrtReimFlag,
  5148. Ctime: time.Now().Unix(),
  5149. ListSpItemFlag: item.ListSpItemFlag,
  5150. ChldMedcFlag: item.ChldMedcFlag,
  5151. LmtUsedFlag: item.LmtUsedFlag,
  5152. ChrgitmLv: item.ChrgitmLv,
  5153. UserOrgId: adminUser.CurrentOrgId,
  5154. HisPatientId: his.ID,
  5155. OrderId: order.ID,
  5156. ProjectId: project_id,
  5157. Type: types,
  5158. }
  5159. service.CreateOrderInfo(info)
  5160. }
  5161. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5162. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5163. var total float64
  5164. for _, item := range prescriptions {
  5165. if item.Type == 1 { //药品
  5166. for _, subItem := range item.HisDoctorAdviceInfo {
  5167. total = total + (subItem.Price * subItem.PrescribingNumber)
  5168. }
  5169. }
  5170. if item.Type == 2 { //项目
  5171. for _, subItem := range item.HisPrescriptionProject {
  5172. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5173. total = total + (subItem.Price * cnt)
  5174. }
  5175. }
  5176. }
  5177. for _, item := range prescriptions {
  5178. for _, subItem := range item.HisAdditionalCharge {
  5179. total = total + (subItem.Price * float64(subItem.Count))
  5180. }
  5181. }
  5182. allTotal := fmt.Sprintf("%.4f", total)
  5183. if res.Infcode == 0 {
  5184. var rf []*ResultFive
  5185. json.Unmarshal([]byte(his.Iinfo), &rf)
  5186. chrg_bchno := chrg_bchno
  5187. cert_no := his.Certno
  5188. var insutypes []string
  5189. var insutype string
  5190. var is390 int = 0
  5191. var is310 int = 0
  5192. for _, item := range rf {
  5193. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5194. insutypes = append(insutypes, item.Insutype)
  5195. }
  5196. }
  5197. if len(insutypes) == 1 {
  5198. insutype = insutypes[0]
  5199. } else {
  5200. for _, i := range insutypes {
  5201. if i == "390" {
  5202. is390 = 1
  5203. }
  5204. if i == "310" {
  5205. is310 = 1
  5206. }
  5207. }
  5208. }
  5209. if is390 == 1 {
  5210. insutype = "390"
  5211. }
  5212. if is310 == 1 {
  5213. insutype = "310"
  5214. }
  5215. if len(insutypes) == 0 {
  5216. insutype = "310"
  5217. }
  5218. if len(insutypes) == 2 {
  5219. insutype = strconv.FormatInt(his.SocialType, 64)
  5220. }
  5221. //insutype = "390"
  5222. if his.IdCardType == 1 {
  5223. cert_no = his.MedicalInsuranceNumber
  5224. } else {
  5225. cert_no = his.Certno
  5226. }
  5227. var res ResultSeven
  5228. var resSeven10265 ResultSeven10265
  5229. if miConfig.MdtrtareaAdmvs == "421300" {
  5230. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5231. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5232. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5233. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5234. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5235. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5236. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5237. resp, requestErr := http.Get(api)
  5238. if requestErr != nil {
  5239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5240. return
  5241. }
  5242. body, ioErr := ioutil.ReadAll(resp.Body)
  5243. if ioErr != nil {
  5244. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5246. return
  5247. }
  5248. var respJSON map[string]interface{}
  5249. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5252. return
  5253. }
  5254. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5255. result, _ := json.Marshal(respJSON)
  5256. fmt.Println("log")
  5257. fmt.Println(string(result))
  5258. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5259. utils.ErrorLog("解析失败:%v", err)
  5260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5261. return
  5262. }
  5263. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5264. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5265. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5266. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5267. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5268. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5269. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5270. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5271. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5272. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber
  5273. resp, requestErr := http.Get(api)
  5274. if requestErr != nil {
  5275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5276. return
  5277. }
  5278. body, ioErr := ioutil.ReadAll(resp.Body)
  5279. if ioErr != nil {
  5280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5282. return
  5283. }
  5284. var respJSON map[string]interface{}
  5285. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5288. return
  5289. }
  5290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5291. result, _ := json.Marshal(respJSON)
  5292. fmt.Println("log")
  5293. fmt.Println(string(result))
  5294. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5295. utils.ErrorLog("解析失败:%v", err)
  5296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5297. return
  5298. }
  5299. } else {
  5300. var result string
  5301. var request_log string
  5302. if miConfig.Code == "H15049901371" {
  5303. //赤峰地区国家医保医疗类别
  5304. //职工透析:医疗类别选特殊情况门诊990502
  5305. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5306. var med_type string
  5307. if his.Insutype == "390" {
  5308. if reg_type == 14 {
  5309. med_type = "9933"
  5310. } else if reg_type == 11 {
  5311. med_type = "11"
  5312. }
  5313. } else if his.Insutype == "310" {
  5314. if reg_type == 14 {
  5315. med_type = "990502"
  5316. } else if reg_type == 11 {
  5317. med_type = "11"
  5318. }
  5319. }
  5320. 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)
  5321. } else {
  5322. 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)
  5323. }
  5324. var dat map[string]interface{}
  5325. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5326. fmt.Println(dat)
  5327. } else {
  5328. fmt.Println(err)
  5329. }
  5330. saveLog(result, request_log, "2206", "预结算")
  5331. //userJSONBytes, _ := json.Marshal(dat)
  5332. //
  5333. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5334. // utils.ErrorLog("解析失败:%v", err)
  5335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5336. // return
  5337. //}
  5338. userJSONBytes, _ := json.Marshal(dat)
  5339. if miConfig.Code == "H15049901371" {
  5340. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5341. utils.ErrorLog("解析失败:%v", err)
  5342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5343. return
  5344. }
  5345. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5346. res.Output = resSeven10265.Output
  5347. res.ErrMsg = resSeven10265.ErrMsg
  5348. res.Cainfo = resSeven10265.Cainfo
  5349. res.WarnMsg = resSeven10265.WarnMsg
  5350. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5351. res.Infcode = infocode
  5352. } else {
  5353. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5354. utils.ErrorLog("解析失败:%v", err)
  5355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5356. return
  5357. }
  5358. }
  5359. }
  5360. if res.Infcode != 0 {
  5361. errlog := &models.HisOrderError{
  5362. UserOrgId: adminUser.CurrentOrgId,
  5363. Ctime: time.Now().Unix(),
  5364. Mtime: time.Now().Unix(),
  5365. Number: chrg_bchno,
  5366. ErrMsg: res.ErrMsg,
  5367. Status: 1,
  5368. PatientId: id,
  5369. RecordTime: recordDateTime,
  5370. Stage: 20,
  5371. }
  5372. service.CreateErrMsgLog(errlog)
  5373. c.ServeSuccessJSON(map[string]interface{}{
  5374. "failed_code": -10,
  5375. "msg": res.ErrMsg,
  5376. })
  5377. return
  5378. } else {
  5379. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5380. order.OrderStatus = 1
  5381. order.IsPre = 1
  5382. order.Status = 1
  5383. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5384. order.SetlId = res.Output.Setlinfo.SetlID
  5385. order.PsnNo = res.Output.Setlinfo.PsnNo
  5386. order.PsnName = res.Output.Setlinfo.PsnName
  5387. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5388. order.Certno = res.Output.Setlinfo.Certno
  5389. order.Gend = res.Output.Setlinfo.Gend
  5390. order.Naty = res.Output.Setlinfo.Naty
  5391. order.Age = res.Output.Setlinfo.Age
  5392. order.Insutype = res.Output.Setlinfo.Insutype
  5393. order.PsnType = res.Output.Setlinfo.PsnType
  5394. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5395. order.SetlTime = res.Output.Setlinfo.SetlTime
  5396. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5397. if res.Output.Setlinfo.MedType == "140101" {
  5398. order.MedType = "14"
  5399. } else {
  5400. order.MedType = res.Output.Setlinfo.MedType
  5401. }
  5402. if reg_type == 1112 {
  5403. order.MedType = "1112"
  5404. }
  5405. if reg_type == 1111 {
  5406. order.MedType = "1111"
  5407. }
  5408. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5409. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5410. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5411. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5412. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5413. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5414. order.HifpPay = res.Output.Setlinfo.HifpPay
  5415. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5416. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5417. order.HifesPay = res.Output.Setlinfo.HifesPay
  5418. order.HifobPay = res.Output.Setlinfo.HifobPay
  5419. order.MafPay = res.Output.Setlinfo.MafPay
  5420. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5421. order.OthPay = res.Output.Setlinfo.OthPay
  5422. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5423. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5424. order.AcctPay = res.Output.Setlinfo.AcctPay
  5425. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5426. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5427. order.Balc = res.Output.Setlinfo.Balc
  5428. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5429. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5430. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5431. order.ClrWay = res.Output.Setlinfo.ClrWay
  5432. order.Creator = order.Creator
  5433. order.Modify = roles.AdminUserId
  5434. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5435. detailStr := string(setlDetail)
  5436. order.SetlDetail = detailStr
  5437. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5438. err = service.UpDateOrder(order)
  5439. if err == nil {
  5440. c.ServeSuccessJSON(map[string]interface{}{
  5441. "msg": "预结算成功",
  5442. })
  5443. } else {
  5444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5445. return
  5446. }
  5447. }
  5448. } else {
  5449. adminUser := c.GetAdminUserInfo()
  5450. errlog := &models.HisOrderError{
  5451. UserOrgId: adminUser.CurrentOrgId,
  5452. Ctime: time.Now().Unix(),
  5453. Mtime: time.Now().Unix(),
  5454. ErrMsg: res.ErrMsg,
  5455. Status: 1,
  5456. PatientId: id,
  5457. RecordTime: recordDateTime,
  5458. Stage: 4,
  5459. }
  5460. service.CreateErrMsgLog(errlog)
  5461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5462. return
  5463. }
  5464. } else {
  5465. adminUser := c.GetAdminUserInfo()
  5466. errlog := &models.HisOrderError{
  5467. UserOrgId: adminUser.CurrentOrgId,
  5468. Ctime: time.Now().Unix(),
  5469. Mtime: time.Now().Unix(),
  5470. ErrMsg: res.ErrMsg,
  5471. Status: 1,
  5472. PatientId: id,
  5473. RecordTime: recordDateTime,
  5474. Stage: 4,
  5475. }
  5476. service.CreateErrMsgLog(errlog)
  5477. c.ServeSuccessJSON(map[string]interface{}{
  5478. "failed_code": -10,
  5479. "msg": res.ErrMsg,
  5480. })
  5481. return
  5482. }
  5483. }
  5484. }
  5485. }
  5486. //func (c *HisApiController) GetSettleInfo() {
  5487. // id, _ := c.GetInt64("id")
  5488. // order_id, _ := c.GetInt64("order_id")
  5489. //
  5490. // record_time := c.GetString("record_time")
  5491. // pay_way, _ := c.GetInt64("pay_way")
  5492. // pay_price, _ := c.GetFloat("pay_price")
  5493. // pay_card_no := c.GetString("pay_card_no")
  5494. // discount_price, _ := c.GetFloat("discount_price")
  5495. // preferential_price, _ := c.GetFloat("preferential_price")
  5496. // reality_price, _ := c.GetFloat("reality_price")
  5497. // found_price, _ := c.GetFloat("found_price")
  5498. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5499. // private_price, _ := c.GetFloat("private_price")
  5500. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5501. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5502. //
  5503. // timeLayout := "2006-01-02"
  5504. // loc, _ := time.LoadLocation("Local")
  5505. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5506. // if err != nil {
  5507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5508. // return
  5509. // }
  5510. // recordDateTime := theTime.Unix()
  5511. // adminUser := c.GetAdminUserInfo()
  5512. //
  5513. // var prescriptions []*models.HisPrescription
  5514. //
  5515. // data := make(map[string]interface{})
  5516. // if settle_accounts_type == 1 { //日结
  5517. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5518. // data["pre"] = prescriptions
  5519. //
  5520. // } else { //月结
  5521. // start_time_str := c.GetString("start_time")
  5522. // end_time_str := c.GetString("end_time")
  5523. // timeLayout := "2006-01-02"
  5524. // loc, _ := time.LoadLocation("Local")
  5525. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5526. // if err != nil {
  5527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5528. // return
  5529. // }
  5530. // recordStartTime := theStartTime.Unix()
  5531. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5532. // if err != nil {
  5533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5534. // return
  5535. // }
  5536. // recordEndTime := theEndTime.Unix()
  5537. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5538. // data["pre"] = prescriptions
  5539. //
  5540. // }
  5541. //
  5542. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5543. //
  5544. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5545. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5546. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5547. // strconv.FormatInt(his.PatientId, 10)
  5548. //
  5549. // order_src, _ := service.GetHisOrderByID(order_id)
  5550. //
  5551. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5552. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5553. //
  5554. // var total float64
  5555. // for _, item := range prescriptions {
  5556. // if item.Type == 1 { //药品
  5557. // for _, subItem := range item.HisDoctorAdviceInfo {
  5558. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5559. // }
  5560. // }
  5561. // if item.Type == 2 { //项目
  5562. // for _, subItem := range item.HisPrescriptionProject {
  5563. // total = total + (subItem.Price * float64(subItem.Count))
  5564. // }
  5565. // }
  5566. // }
  5567. //
  5568. // for _, item := range prescriptions {
  5569. // for _, subItem := range item.HisAdditionalCharge {
  5570. // total = total + (subItem.Price * float64(subItem.Count))
  5571. // }
  5572. // }
  5573. //
  5574. // allTotal := fmt.Sprintf("%.2f", total)
  5575. // var rf []*ResultFive
  5576. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5577. // psn_no := order_src.PsnNo
  5578. // mdtrt_id := order_src.MdtrtId
  5579. // chrg_bchno := order_src.Number
  5580. // cert_no := order_src.Certno
  5581. // insutype := rf[0].Insutype
  5582. //
  5583. // if his.IdCardType == 1 {
  5584. // cert_no = his.MedicalInsuranceNumber
  5585. // } else {
  5586. // cert_no = his.Certno
  5587. // }
  5588. //
  5589. // 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)
  5590. // var dat map[string]interface{}
  5591. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5592. // fmt.Println(dat)
  5593. // } else {
  5594. // fmt.Println(err)
  5595. // }
  5596. //
  5597. // userJSONBytes, _ := json.Marshal(dat)
  5598. //
  5599. //
  5600. //
  5601. // var res ResultSeven
  5602. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5603. // utils.ErrorLog("解析失败:%v", err)
  5604. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5605. // return
  5606. // }
  5607. // if res.Infcode == -1 {
  5608. // errlog := &models.HisOrderError{
  5609. // UserOrgId: adminUser.CurrentOrgId,
  5610. // Ctime: time.Now().Unix(),
  5611. // Mtime: time.Now().Unix(),
  5612. // Number: chrg_bchno,
  5613. // ErrMsg: res.ErrMsg,
  5614. // Status: 1,
  5615. // PatientId: id,
  5616. // RecordTime: recordDateTime,
  5617. // Stage: 6,
  5618. // }
  5619. // service.CreateErrMsgLog(errlog)
  5620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5621. // return
  5622. // } else {
  5623. // order_src.OrderStatus = 2
  5624. // order_src.PayWay = pay_way
  5625. // order_src.PayPrice = pay_price
  5626. // order_src.PayCardNo = pay_card_no
  5627. // order_src.DiscountPrice = discount_price
  5628. // order_src.PreferentialPrice = preferential_price
  5629. // order_src.RealityPrice = reality_price
  5630. // order_src.FoundPrice = found_price
  5631. // order_src.MedicalInsurancePrice = medical_insurance_price
  5632. // order_src.PrivatePrice = private_price
  5633. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  5634. // order_src.SetlId = res.Output.Setlinfo.SetlID
  5635. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  5636. // order_src.PsnName = res.Output.Setlinfo.PsnName
  5637. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  5638. // order_src.Certno = res.Output.Setlinfo.Certno
  5639. // order_src.Gend = res.Output.Setlinfo.Gend
  5640. // order_src.Naty = res.Output.Setlinfo.Naty
  5641. // order_src.Age = res.Output.Setlinfo.Age
  5642. // order_src.Insutype = res.Output.Setlinfo.Insutype
  5643. // order_src.PsnType = res.Output.Setlinfo.PsnType
  5644. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5645. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  5646. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5647. // order_src.MedType = res.Output.Setlinfo.MedType
  5648. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5649. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5650. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5651. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5652. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5653. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5654. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  5655. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  5656. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5657. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  5658. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  5659. // order_src.MafPay = res.Output.Setlinfo.MafPay
  5660. // order_src.OthPay = res.Output.Setlinfo.OthPay
  5661. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5662. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5663. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  5664. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5665. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5666. // order_src.Balc = res.Output.Setlinfo.Balc
  5667. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5668. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5669. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  5670. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  5671. // order_src.Creator = order_src.Creator
  5672. // order_src.Modify = roles.ID
  5673. // order_src.RequestLog = src_resquest
  5674. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5675. // detailStr := string(setlDetail)
  5676. // order_src.SetlDetail = detailStr
  5677. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5678. // err = service.UpDateOrder(order_src)
  5679. //
  5680. // if err == nil {
  5681. // c.ServeSuccessJSON(map[string]interface{}{
  5682. // "msg": "结算成功",
  5683. // })
  5684. // } else {
  5685. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5686. // return
  5687. // }
  5688. // }
  5689. // }
  5690. //}
  5691. //退款
  5692. func (c *HisApiController) Refund() {
  5693. order_id, _ := c.GetInt64("order_id")
  5694. admin_user_id, _ := c.GetInt64("admin_user_id")
  5695. adminUser := c.GetAdminUserInfo()
  5696. var order models.HisOrder
  5697. order, _ = service.GetHisOrderByID(order_id)
  5698. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5699. if order.ID == 0 {
  5700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5701. return
  5702. }
  5703. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5704. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5705. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5706. if config.IsOpen == 1 { //对接了医保,走医保流程
  5707. var res ResultSixteen
  5708. var resSixteen10265 ResultSixteen10265
  5709. var src_resquest string
  5710. var result string
  5711. if miConfig.MdtrtareaAdmvs == "421300" {
  5712. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  5713. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5714. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5715. resp3, requestErr3 := http.Get(api3)
  5716. if requestErr3 != nil {
  5717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5718. return
  5719. }
  5720. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5721. if ioErr3 != nil {
  5722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5724. return
  5725. }
  5726. var respJSON3 map[string]interface{}
  5727. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5730. return
  5731. }
  5732. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5733. userJSONBytes3, _ := json.Marshal(respJSON3)
  5734. fmt.Println("log")
  5735. fmt.Println(string(userJSONBytes3))
  5736. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  5737. utils.ErrorLog("解析失败:%v", err)
  5738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5739. return
  5740. }
  5741. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5742. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  5743. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5744. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5745. resp3, requestErr3 := http.Get(api3)
  5746. if requestErr3 != nil {
  5747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5748. return
  5749. }
  5750. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5751. if ioErr3 != nil {
  5752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5754. return
  5755. }
  5756. var respJSON3 map[string]interface{}
  5757. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5760. return
  5761. }
  5762. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5763. userJSONBytes3, _ := json.Marshal(respJSON3)
  5764. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  5765. utils.ErrorLog("解析失败:%v", err)
  5766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5767. return
  5768. }
  5769. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5770. res.Output = resSixteen10265.Output
  5771. res.ErrMsg = resSixteen10265.ErrMsg
  5772. res.Cainfo = resSixteen10265.Cainfo
  5773. res.WarnMsg = resSixteen10265.WarnMsg
  5774. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5775. res.Infcode = infocode
  5776. } else {
  5777. if miConfig.Code == "H15049901371" {
  5778. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5779. var dat map[string]interface{}
  5780. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5781. fmt.Println(dat)
  5782. } else {
  5783. fmt.Println(err)
  5784. }
  5785. saveLog(result, src_resquest, "2208", "退费")
  5786. userJSONBytes, _ := json.Marshal(dat)
  5787. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  5788. utils.ErrorLog("解析失败:%v", err)
  5789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5790. return
  5791. }
  5792. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  5793. res.Output = resSixteen10265.Output
  5794. res.ErrMsg = resSixteen10265.ErrMsg
  5795. res.Cainfo = resSixteen10265.Cainfo
  5796. res.WarnMsg = resSixteen10265.WarnMsg
  5797. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  5798. res.Infcode = infocode
  5799. } else {
  5800. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  5801. var dat map[string]interface{}
  5802. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5803. fmt.Println(dat)
  5804. } else {
  5805. fmt.Println(err)
  5806. }
  5807. saveLog(result, src_resquest, "2208", "退费")
  5808. userJSONBytes, _ := json.Marshal(dat)
  5809. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5810. utils.ErrorLog("解析失败:%v", err)
  5811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5812. return
  5813. }
  5814. }
  5815. }
  5816. if res.Infcode == 0 {
  5817. var res2 ResultSix
  5818. var resSix10265 ResultSix10265
  5819. if miConfig.MdtrtareaAdmvs == "421300" {
  5820. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  5821. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5822. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5823. resp3, requestErr3 := http.Get(api3)
  5824. if requestErr3 != nil {
  5825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5826. return
  5827. }
  5828. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5829. if ioErr3 != nil {
  5830. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5832. return
  5833. }
  5834. var respJSON3 map[string]interface{}
  5835. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5838. return
  5839. }
  5840. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5841. userJSONBytes3, _ := json.Marshal(respJSON3)
  5842. fmt.Println("log")
  5843. fmt.Println(string(userJSONBytes3))
  5844. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  5845. utils.ErrorLog("解析失败:%v", err)
  5846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5847. return
  5848. }
  5849. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5850. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  5851. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5852. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  5853. resp3, requestErr3 := http.Get(api3)
  5854. if requestErr3 != nil {
  5855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5856. return
  5857. }
  5858. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5859. if ioErr3 != nil {
  5860. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5862. return
  5863. }
  5864. var respJSON3 map[string]interface{}
  5865. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5866. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5868. return
  5869. }
  5870. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5871. userJSONBytes3, _ := json.Marshal(respJSON3)
  5872. fmt.Println("log")
  5873. fmt.Println(string(userJSONBytes3))
  5874. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  5875. utils.ErrorLog("解析失败:%v", err)
  5876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5877. return
  5878. }
  5879. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5880. res2.Output = resSix10265.Output
  5881. res2.ErrMsg = resSix10265.ErrMsg
  5882. res2.Cainfo = resSix10265.Cainfo
  5883. res2.WarnMsg = resSix10265.WarnMsg
  5884. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5885. res2.Infcode = infocode
  5886. } else {
  5887. if miConfig.Code == "H15049901371" {
  5888. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5889. var dat map[string]interface{}
  5890. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5891. fmt.Println(dat)
  5892. } else {
  5893. fmt.Println(err)
  5894. }
  5895. saveLog(result2, src_request, "2205", "撤销明细")
  5896. userJSONBytes, _ := json.Marshal(dat)
  5897. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5898. utils.ErrorLog("解析失败:%v", err)
  5899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5900. return
  5901. }
  5902. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5903. res2.Output = resSix10265.Output
  5904. res2.ErrMsg = resSix10265.ErrMsg
  5905. res2.Cainfo = resSix10265.Cainfo
  5906. res2.WarnMsg = resSix10265.WarnMsg
  5907. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5908. res2.Infcode = infocode
  5909. } else {
  5910. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  5911. var dat map[string]interface{}
  5912. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5913. fmt.Println(dat)
  5914. } else {
  5915. fmt.Println(err)
  5916. }
  5917. saveLog(result2, src_request, "2205", "撤销明细")
  5918. userJSONBytes, _ := json.Marshal(dat)
  5919. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5920. utils.ErrorLog("解析失败:%v", err)
  5921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5922. return
  5923. }
  5924. }
  5925. }
  5926. if res2.Infcode == 0 {
  5927. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  5928. if err == nil {
  5929. c.ServeSuccessJSON(map[string]interface{}{
  5930. "msg": "退费成功",
  5931. })
  5932. } else {
  5933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5934. return
  5935. }
  5936. } else {
  5937. c.ServeSuccessJSON(map[string]interface{}{
  5938. "code": -10,
  5939. "msg": res2.ErrMsg,
  5940. })
  5941. }
  5942. } else {
  5943. c.ServeSuccessJSON(map[string]interface{}{
  5944. "code": -10,
  5945. "msg": res.ErrMsg,
  5946. })
  5947. }
  5948. }
  5949. }
  5950. func (c *HisApiController) RefundNumber() {
  5951. record_time := c.GetString("record_time")
  5952. //patient_id, _ := c.GetInt64("patient_id")
  5953. admin_user_id, _ := c.GetInt64("admin_user_id")
  5954. his_patient_id, _ := c.GetInt64("id")
  5955. timeLayout := "2006-01-02"
  5956. loc, _ := time.LoadLocation("Local")
  5957. adminUser := c.GetAdminUserInfo()
  5958. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5959. fmt.Println(err)
  5960. if err != nil {
  5961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5962. return
  5963. }
  5964. recordDateTime := theTime.Unix()
  5965. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5966. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  5967. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5968. //order, _ := service.GetHisOrderByID(order_id)
  5969. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5970. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5971. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5972. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  5973. if count > 0 {
  5974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  5975. return
  5976. }
  5977. if config.IsOpen == 1 { //对接了医保,走医保流程
  5978. var res2 ResultSix
  5979. var resSix10265 ResultSix10265
  5980. if miConfig.MdtrtareaAdmvs == "421300" {
  5981. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  5982. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5983. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5984. resp3, requestErr3 := http.Get(api3)
  5985. if requestErr3 != nil {
  5986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5987. return
  5988. }
  5989. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5990. if ioErr3 != nil {
  5991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5993. return
  5994. }
  5995. var respJSON3 map[string]interface{}
  5996. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5999. return
  6000. }
  6001. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6002. userJSONBytes3, _ := json.Marshal(respJSON3)
  6003. fmt.Println("log")
  6004. fmt.Println(string(userJSONBytes3))
  6005. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6006. utils.ErrorLog("解析失败:%v", err)
  6007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6008. return
  6009. }
  6010. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6011. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6012. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6013. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6014. resp3, requestErr3 := http.Get(api3)
  6015. if requestErr3 != nil {
  6016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6017. return
  6018. }
  6019. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6020. if ioErr3 != nil {
  6021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6023. return
  6024. }
  6025. var respJSON3 map[string]interface{}
  6026. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6029. return
  6030. }
  6031. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6032. userJSONBytes3, _ := json.Marshal(respJSON3)
  6033. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6034. utils.ErrorLog("解析失败:%v", err)
  6035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6036. return
  6037. }
  6038. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6039. res2.Output = resSix10265.Output
  6040. res2.ErrMsg = resSix10265.ErrMsg
  6041. res2.Cainfo = resSix10265.Cainfo
  6042. res2.WarnMsg = resSix10265.WarnMsg
  6043. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6044. res2.Infcode = infocode
  6045. } else {
  6046. var api3 string
  6047. if miConfig.Code == "H15049901371" {
  6048. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6049. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6050. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6051. } else {
  6052. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6053. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6054. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6055. }
  6056. resp3, requestErr3 := http.Get(api3)
  6057. if requestErr3 != nil {
  6058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6059. return
  6060. }
  6061. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6062. if ioErr3 != nil {
  6063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6065. return
  6066. }
  6067. var respJSON3 map[string]interface{}
  6068. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6071. return
  6072. }
  6073. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6074. userJSONBytes3, _ := json.Marshal(respJSON3)
  6075. if miConfig.Code == "H15049901371" {
  6076. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6077. utils.ErrorLog("解析失败:%v", err)
  6078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6079. return
  6080. }
  6081. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6082. res2.Output = resSix10265.Output
  6083. res2.ErrMsg = resSix10265.ErrMsg
  6084. res2.Cainfo = resSix10265.Cainfo
  6085. res2.WarnMsg = resSix10265.WarnMsg
  6086. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6087. res2.Infcode = infocode
  6088. } else {
  6089. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6090. utils.ErrorLog("解析失败:%v", err)
  6091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6092. return
  6093. }
  6094. }
  6095. }
  6096. if res2.Infcode == 0 {
  6097. if err == nil {
  6098. c.ServeSuccessJSON(map[string]interface{}{
  6099. "msg": "退号成功",
  6100. })
  6101. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6102. } else {
  6103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6104. return
  6105. }
  6106. } else {
  6107. c.ServeSuccessJSON(map[string]interface{}{
  6108. "code": -10,
  6109. "msg": res2.ErrMsg,
  6110. })
  6111. }
  6112. } else {
  6113. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6114. //if err == nil {
  6115. // c.ServeSuccessJSON(map[string]interface{}{
  6116. // "msg": "退费成功",
  6117. // })
  6118. //} else {
  6119. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6120. // return
  6121. //}
  6122. }
  6123. }
  6124. func (c *HisApiController) RefundDetail() {
  6125. order_id, _ := c.GetInt64("order_id")
  6126. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6127. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6128. number := c.GetString("number")
  6129. record_time := c.GetString("record_time")
  6130. patient_id, _ := c.GetInt64("patient_id")
  6131. timeLayout := "2006-01-02"
  6132. loc, _ := time.LoadLocation("Local")
  6133. adminUser := c.GetAdminUserInfo()
  6134. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6135. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6136. fmt.Println(err)
  6137. if err != nil {
  6138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6139. return
  6140. }
  6141. recordDateTime := theTime.Unix()
  6142. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6143. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6144. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6145. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6146. var order models.HisOrder
  6147. order, _ = service.GetHisOrderByID(order_id)
  6148. if order.ID == 0 {
  6149. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6150. }
  6151. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6152. if config.IsOpen == 1 { //对接了医保,走医保流程
  6153. var res2 ResultSix
  6154. if miConfig.MdtrtareaAdmvs == "421300" {
  6155. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6156. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6157. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6158. resp3, requestErr3 := http.Get(api3)
  6159. if requestErr3 != nil {
  6160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6161. return
  6162. }
  6163. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6164. if ioErr3 != nil {
  6165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6167. return
  6168. }
  6169. var respJSON3 map[string]interface{}
  6170. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6173. return
  6174. }
  6175. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6176. userJSONBytes3, _ := json.Marshal(respJSON3)
  6177. fmt.Println("log")
  6178. fmt.Println(string(userJSONBytes3))
  6179. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6180. utils.ErrorLog("解析失败:%v", err)
  6181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6182. return
  6183. }
  6184. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6185. if err == nil {
  6186. c.ServeSuccessJSON(map[string]interface{}{
  6187. "msg": "撤销明细成功",
  6188. })
  6189. return
  6190. } else {
  6191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6192. return
  6193. }
  6194. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6195. var resSix10265 ResultSix10265
  6196. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6197. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6198. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6199. resp3, requestErr3 := http.Get(api3)
  6200. if requestErr3 != nil {
  6201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6202. return
  6203. }
  6204. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6205. if ioErr3 != nil {
  6206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6208. return
  6209. }
  6210. var respJSON3 map[string]interface{}
  6211. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6214. return
  6215. }
  6216. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6217. userJSONBytes3, _ := json.Marshal(respJSON3)
  6218. fmt.Println("log")
  6219. fmt.Println(string(userJSONBytes3))
  6220. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6221. utils.ErrorLog("解析失败:%v", err)
  6222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6223. return
  6224. }
  6225. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6226. res2.Output = resSix10265.Output
  6227. res2.ErrMsg = resSix10265.ErrMsg
  6228. res2.Cainfo = resSix10265.Cainfo
  6229. res2.WarnMsg = resSix10265.WarnMsg
  6230. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6231. res2.Infcode = infocode
  6232. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6233. if err == nil {
  6234. c.ServeSuccessJSON(map[string]interface{}{
  6235. "msg": "撤销明细成功",
  6236. })
  6237. return
  6238. } else {
  6239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6240. return
  6241. }
  6242. } else {
  6243. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6244. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6245. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6246. resp2, requestErr2 := http.Get(api2)
  6247. if requestErr2 != nil {
  6248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6249. return
  6250. }
  6251. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6252. if ioErr2 != nil {
  6253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6255. return
  6256. }
  6257. var respJSON2 map[string]interface{}
  6258. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6261. return
  6262. }
  6263. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6264. if err == nil {
  6265. c.ServeSuccessJSON(map[string]interface{}{
  6266. "msg": "撤销明细成功",
  6267. })
  6268. return
  6269. } else {
  6270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6271. return
  6272. }
  6273. }
  6274. } else {
  6275. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6276. if err == nil {
  6277. c.ServeSuccessJSON(map[string]interface{}{
  6278. "msg": "退费成功",
  6279. })
  6280. } else {
  6281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6282. return
  6283. }
  6284. }
  6285. }
  6286. //对账
  6287. func (c *HisApiController) GetCheckAccount() {
  6288. start_time := c.GetString("start_time")
  6289. end_time := c.GetString("end_time")
  6290. insutype := c.GetString("insutype")
  6291. clr_type := c.GetString("clr_type")
  6292. clr_org := c.GetString("clr_optins")
  6293. admin_user_id, _ := c.GetInt64("admin_user_id")
  6294. adminUser := c.GetAdminUserInfo()
  6295. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6296. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6297. if len(clr_org) == 0 {
  6298. clr_org = miConfig.MdtrtareaAdmvs
  6299. }
  6300. timeLayout := "2006-01-02"
  6301. loc, _ := time.LoadLocation("Local")
  6302. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6303. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6304. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6305. fixmedins_setl_cnt := int64(len(orders))
  6306. var medfee_sumamt float64
  6307. var acct_pay float64
  6308. var fund_pay_sumamt float64
  6309. for _, item := range orders {
  6310. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6311. acct_pay = acct_pay + item.AcctPay
  6312. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6313. }
  6314. var user_name string
  6315. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6316. if role.ID == 0 {
  6317. user_name = "xxx"
  6318. } else {
  6319. user_name = role.UserName
  6320. }
  6321. if config.IsOpen == 1 {
  6322. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6323. "insutype=" + insutype +
  6324. "&clr_type=" + clr_type +
  6325. "&setl_optins=" + clr_org +
  6326. "&stmt_begndate=" + start_time +
  6327. "&stm_enddate=" + end_time +
  6328. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6329. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6330. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  6331. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6332. "&fixmedins_code=" + miConfig.Code +
  6333. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6334. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6335. "&secret_key=" + miConfig.SecretKey +
  6336. "&org_name=" + miConfig.OrgName +
  6337. "&doctor=" + user_name
  6338. fmt.Println(api)
  6339. resp, requestErr := http.Get(api)
  6340. if requestErr != nil {
  6341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6342. return
  6343. }
  6344. body, ioErr := ioutil.ReadAll(resp.Body)
  6345. fmt.Println(body)
  6346. if ioErr != nil {
  6347. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6349. return
  6350. }
  6351. var respJSON map[string]interface{}
  6352. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6355. return
  6356. }
  6357. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6358. userJSONBytes, _ := json.Marshal(respJSON)
  6359. var res ResultEight
  6360. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6361. utils.ErrorLog("解析失败:%v", err)
  6362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6363. return
  6364. }
  6365. if res.Infcode == 0 {
  6366. if res.Output.Stmtinfo.StmtRslt == "0" {
  6367. micc := &models.MedicalInsuranceCostCompare{
  6368. StartTime: startime.Unix(),
  6369. EndTime: endtime.Unix(),
  6370. Insutype: insutype,
  6371. CheckType: 1,
  6372. Num: fixmedins_setl_cnt,
  6373. Mtime: time.Now().Unix(),
  6374. Status: 1,
  6375. UserOrgId: adminUser.CurrentOrgId,
  6376. CostTotal: medfee_sumamt,
  6377. FuncTotal: fund_pay_sumamt,
  6378. PsnPay: acct_pay,
  6379. Creator: admin_user_id,
  6380. Ctime: time.Now().Unix(),
  6381. }
  6382. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  6383. if err == nil {
  6384. c.ServeSuccessJSON(map[string]interface{}{
  6385. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6386. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6387. })
  6388. } else {
  6389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6390. }
  6391. } else {
  6392. c.ServeSuccessJSON(map[string]interface{}{
  6393. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  6394. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  6395. })
  6396. }
  6397. } else {
  6398. c.ServeSuccessJSON(map[string]interface{}{
  6399. "code": -10,
  6400. "msg": res.ErrMsg,
  6401. })
  6402. }
  6403. }
  6404. }
  6405. func (c *HisApiController) Check310() {
  6406. adminUser := c.GetAdminUserInfo()
  6407. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6408. var user_name string
  6409. user_name = "高慧裕"
  6410. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6411. "insutype=" + "310" +
  6412. "&clr_type=" + "11" +
  6413. "&setl_optins=" + "441202" +
  6414. "&stmt_begndate=" + "2022-02-01" +
  6415. "&stm_enddate=" + "2022-02-28" +
  6416. "&medfee_sumamt=" + "155812.88" +
  6417. "&fund_pay_sumamt=" + "151026.15" +
  6418. "&acct_pay=" + "0" +
  6419. "&fixmedins_setl_cnt=" + "73" +
  6420. "&fixmedins_code=" + miConfig.Code +
  6421. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6422. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6423. "&secret_key=" + miConfig.SecretKey +
  6424. "&org_name=" + miConfig.OrgName +
  6425. "&doctor=" + user_name
  6426. fmt.Println(api)
  6427. resp, requestErr := http.Get(api)
  6428. if requestErr != nil {
  6429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6430. return
  6431. }
  6432. body, ioErr := ioutil.ReadAll(resp.Body)
  6433. fmt.Println(body)
  6434. if ioErr != nil {
  6435. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6437. return
  6438. }
  6439. var respJSON map[string]interface{}
  6440. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6441. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6443. return
  6444. }
  6445. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6446. userJSONBytes, _ := json.Marshal(respJSON)
  6447. var res ResultEight
  6448. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6449. utils.ErrorLog("解析失败:%v", err)
  6450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6451. return
  6452. }
  6453. }
  6454. func (c *HisApiController) Check390() {
  6455. adminUser := c.GetAdminUserInfo()
  6456. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6457. var user_name string
  6458. user_name = "高慧裕"
  6459. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  6460. "insutype=" + "390" +
  6461. "&clr_type=" + "11" +
  6462. "&setl_optins=" + "441202" +
  6463. "&stmt_begndate=" + "2022-02-01" +
  6464. "&stm_enddate=" + "2022-02-28" +
  6465. "&medfee_sumamt=" + "933920.08" +
  6466. "&fund_pay_sumamt=" + "887153.34" +
  6467. "&acct_pay=" + "0" +
  6468. "&fixmedins_setl_cnt=" + "396" +
  6469. "&fixmedins_code=" + miConfig.Code +
  6470. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6471. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6472. "&secret_key=" + miConfig.SecretKey +
  6473. "&org_name=" + miConfig.OrgName +
  6474. "&doctor=" + user_name
  6475. fmt.Println(api)
  6476. resp, requestErr := http.Get(api)
  6477. if requestErr != nil {
  6478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6479. return
  6480. }
  6481. body, ioErr := ioutil.ReadAll(resp.Body)
  6482. fmt.Println(body)
  6483. if ioErr != nil {
  6484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6486. return
  6487. }
  6488. var respJSON map[string]interface{}
  6489. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6492. return
  6493. }
  6494. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6495. userJSONBytes, _ := json.Marshal(respJSON)
  6496. var res ResultEight
  6497. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6498. utils.ErrorLog("解析失败:%v", err)
  6499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6500. return
  6501. }
  6502. }
  6503. //对账明细
  6504. func (c *HisApiController) GetCheckDetailAccount() {
  6505. start_time := c.GetString("start_time")
  6506. end_time := c.GetString("end_time")
  6507. admin_user_id, _ := c.GetInt64("admin_user_id")
  6508. adminUser := c.GetAdminUserInfo()
  6509. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6510. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6511. timeLayout := "2006-01-02"
  6512. loc, _ := time.LoadLocation("Local")
  6513. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6514. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6515. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  6516. Mkdir(miConfig.OrgName)
  6517. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  6518. file_name := file + ".txt"
  6519. zip_name := file + ".zip"
  6520. zip_path := miConfig.OrgName + "/" + zip_name
  6521. file_path := miConfig.OrgName + "/" + file_name
  6522. decimal.DivisionPrecision = 2
  6523. var medfee_sumamt float64
  6524. var psn_cash_pay float64
  6525. var fund_pay_sumamt float64
  6526. fixmedins_setl_cnt := int64(len(orders))
  6527. for _, item := range orders {
  6528. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6529. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  6530. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6531. }
  6532. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  6533. defer f.Close()
  6534. if err != nil {
  6535. fmt.Println(err.Error())
  6536. } else {
  6537. for _, item := range orders {
  6538. var refd_setl_flag string
  6539. if item.OrderStatus == 2 {
  6540. refd_setl_flag = "0"
  6541. var str string
  6542. str = item.SetlId + " " +
  6543. item.MdtrtId + " " +
  6544. item.PsnNo + " " +
  6545. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6546. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6547. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  6548. _, err = f.Write([]byte(str))
  6549. }
  6550. if item.OrderStatus == 3 {
  6551. var str string
  6552. str = item.SetlId + " " +
  6553. item.MdtrtId + " " +
  6554. item.PsnNo + " " +
  6555. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  6556. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  6557. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  6558. _, err = f.Write([]byte(str))
  6559. var str2 string
  6560. str2 = item.SetlId + " " +
  6561. item.MdtrtId + " " +
  6562. item.PsnNo + " " +
  6563. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  6564. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  6565. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  6566. _, err = f.Write([]byte(str2))
  6567. }
  6568. }
  6569. }
  6570. Zip(file_path, zip_path)
  6571. fmt.Println(ReadFile(zip_path))
  6572. fmt.Println(string(ReadFile(zip_path)))
  6573. if config.IsOpen == 1 {
  6574. var user_name string
  6575. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6576. if role.ID == 0 {
  6577. user_name = "管理员"
  6578. } else {
  6579. user_name = role.UserName
  6580. }
  6581. baseParams := models.BaseParams{
  6582. SecretKey: miConfig.SecretKey,
  6583. FixmedinsCode: miConfig.Code,
  6584. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6585. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6586. OrgName: miConfig.OrgName,
  6587. Doctor: user_name,
  6588. }
  6589. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  6590. var dat map[string]interface{}
  6591. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6592. fmt.Println(dat)
  6593. } else {
  6594. fmt.Println(err)
  6595. }
  6596. userJSONBytes, _ := json.Marshal(dat)
  6597. var res ResultNine
  6598. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6599. utils.ErrorLog("解析失败:%v", err)
  6600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6601. return
  6602. }
  6603. if res.Infcode == 0 {
  6604. fileNo := res.Output.FileQuryNo
  6605. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  6606. "file_qury_no=" + fileNo +
  6607. "&setl_optins=" + "定点医保中心" +
  6608. "&stmt_begndate=" + start_time +
  6609. "&stm_enddate=" + end_time +
  6610. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  6611. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  6612. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  6613. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  6614. "&fixmedins_code=" + miConfig.Code +
  6615. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  6616. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6617. "&secret_key=" + miConfig.SecretKey +
  6618. "&org_name=" + miConfig.OrgName +
  6619. "&doctor=" + user_name
  6620. resp, requestErr := http.Get(api)
  6621. if requestErr != nil {
  6622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6623. return
  6624. }
  6625. body, ioErr := ioutil.ReadAll(resp.Body)
  6626. if ioErr != nil {
  6627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6629. return
  6630. }
  6631. var respJSON map[string]interface{}
  6632. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6635. return
  6636. }
  6637. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6638. userJSONBytes, _ := json.Marshal(respJSON)
  6639. var res ResultTen
  6640. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6641. utils.ErrorLog("解析失败:%v", err)
  6642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6643. return
  6644. }
  6645. if res.Infcode == 0 {
  6646. service.Gdyb9102(baseParams, zip_name, fileNo)
  6647. micc := &models.MedicalInsuranceCostCompare{
  6648. StartTime: startime.Unix(),
  6649. EndTime: endtime.Unix(),
  6650. Insutype: "0",
  6651. CheckType: 2,
  6652. Num: fixmedins_setl_cnt,
  6653. Mtime: time.Now().Unix(),
  6654. Status: 1,
  6655. UserOrgId: adminUser.CurrentOrgId,
  6656. CostTotal: medfee_sumamt,
  6657. FuncTotal: fund_pay_sumamt,
  6658. PsnPay: psn_cash_pay,
  6659. Creator: admin_user_id,
  6660. Ctime: time.Now().Unix(),
  6661. }
  6662. service.CreateMedicalInsuranceCostCompareRecord(micc)
  6663. c.ServeSuccessJSON(map[string]interface{}{
  6664. "msg": "明细对账成功",
  6665. })
  6666. }
  6667. } else {
  6668. }
  6669. }
  6670. }
  6671. type CustomOrderInfo struct {
  6672. Name string
  6673. Spec string
  6674. Unit string
  6675. Count float64
  6676. Price float64
  6677. Total float64
  6678. }
  6679. func (c *HisApiController) GetSettleAccounts() {
  6680. //id, _ := c.GetInt64("id")
  6681. //record_time := c.GetString("record_time")
  6682. order_id, _ := c.GetInt64("order_id")
  6683. admin_user_id, _ := c.GetInt64("admin_user_id")
  6684. //timeLayout := "2006-01-02"
  6685. //loc, _ := time.LoadLocation("Local")
  6686. //
  6687. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6688. //if err != nil {
  6689. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6690. // return
  6691. //}
  6692. //recordDateTime := theTime.Unix()
  6693. adminUser := c.GetAdminUserInfo()
  6694. order, _ := service.GetHisOrderByID(order_id)
  6695. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6696. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  6697. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  6698. orderInfos = append(orderInfos, orderInfos_two...)
  6699. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  6700. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6701. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  6702. //var config []*models.HisXtDiagnoseConfig
  6703. var name string
  6704. for _, item := range diagnosis_ids {
  6705. id, _ := strconv.ParseInt(item, 10, 64)
  6706. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6707. if len(name) == 0 {
  6708. name = diagnosisConfig.ClassName
  6709. } else {
  6710. name = name + "," + diagnosisConfig.ClassName
  6711. }
  6712. }
  6713. var bedCostTotal float64 = 0 //床位总费
  6714. var bedCostSelfTotal float64 = 0 //床位自费
  6715. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6716. var operationCostTotal float64 = 0 //手术费
  6717. var operationCostSelfTotal float64 = 0 //手术费
  6718. var operationCostPartSelfTotal float64 = 0 //手术费
  6719. var otherCostTotal float64 = 0 //其他费用
  6720. var otherCostSelfTotal float64 = 0 //其他费用
  6721. var otherCostPartSelfTotal float64 = 0 //其他费用
  6722. var materialCostTotal float64 = 0 //材料费
  6723. var materialCostSelfTotal float64 = 0 //材料费
  6724. var materialCostPartSelfTotal float64 = 0 //材料费
  6725. var westernMedicineCostTotal float64 = 0 //西药费
  6726. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6727. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6728. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6729. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6730. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6731. var checkCostTotal float64 = 0 //检查费
  6732. var checkCostSelfTotal float64 = 0 //检查费
  6733. var checkCostPartSelfTotal float64 = 0 //检查费
  6734. var laboratoryCostTotal float64 = 0 //化验费
  6735. var laboratoryCostSelfTotal float64 = 0 //化验费
  6736. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6737. var treatCostTotal float64 = 0 //治疗费用
  6738. var treatCostSelfTotal float64 = 0 //治疗费用
  6739. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6740. decimal.DivisionPrecision = 2
  6741. for _, item := range orderInfos {
  6742. if item.MedChrgitmType == "01" { //床位费
  6743. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6744. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6745. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6746. }
  6747. if item.MedChrgitmType == "03" { //检查费
  6748. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6749. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6750. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6751. }
  6752. if item.MedChrgitmType == "04" { //化验费
  6753. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6754. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6755. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6756. }
  6757. if item.MedChrgitmType == "05" { //治疗费
  6758. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6759. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6760. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6761. }
  6762. if item.MedChrgitmType == "06" { //手术费
  6763. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6764. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6765. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6766. }
  6767. if item.MedChrgitmType == "08" { //材料费
  6768. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6769. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6770. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6771. }
  6772. if item.MedChrgitmType == "09" { //西药费
  6773. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6774. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6775. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6776. }
  6777. if item.MedChrgitmType == "11" { //中成费
  6778. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6779. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6780. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6781. }
  6782. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  6783. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6784. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6785. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6786. }
  6787. }
  6788. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6789. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6790. var user_name string
  6791. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6792. if role.ID == 0 {
  6793. user_name = "管理员"
  6794. } else {
  6795. user_name = role.UserName
  6796. }
  6797. baseParams := models.BaseParams{
  6798. SecretKey: miConfig.SecretKey,
  6799. FixmedinsCode: miConfig.Code,
  6800. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6801. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6802. OrgName: miConfig.OrgName,
  6803. Doctor: user_name,
  6804. }
  6805. businessParams := models.BusinessParams{
  6806. PsnNo: order.PsnNo,
  6807. MdtrtId: order.MdtrtId,
  6808. SetlId: order.SetlId,
  6809. }
  6810. var res ResultEleven
  6811. var resEleven10265 ResultEleven10265
  6812. if config.IsOpen == 1 {
  6813. if miConfig.MdtrtareaAdmvs == "421300" {
  6814. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6815. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6816. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6817. resp, requestErr := http.Get(api)
  6818. if requestErr != nil {
  6819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6820. return
  6821. }
  6822. body, ioErr := ioutil.ReadAll(resp.Body)
  6823. if ioErr != nil {
  6824. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6826. return
  6827. }
  6828. var respJSON map[string]interface{}
  6829. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6832. return
  6833. }
  6834. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6835. result, _ := json.Marshal(respJSON)
  6836. fmt.Println("log")
  6837. fmt.Println(string(result))
  6838. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6839. utils.ErrorLog("解析失败:%v", err)
  6840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6841. return
  6842. }
  6843. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6844. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  6845. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  6846. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.ChannelNumber
  6847. resp, requestErr := http.Get(api)
  6848. if requestErr != nil {
  6849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6850. return
  6851. }
  6852. body, ioErr := ioutil.ReadAll(resp.Body)
  6853. if ioErr != nil {
  6854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6856. return
  6857. }
  6858. var respJSON map[string]interface{}
  6859. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6862. return
  6863. }
  6864. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6865. result, _ := json.Marshal(respJSON)
  6866. fmt.Println("log")
  6867. fmt.Println(string(result))
  6868. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  6869. utils.ErrorLog("解析失败:%v", err)
  6870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6871. return
  6872. }
  6873. res.InfRefmsgid = resEleven10265.InfRefmsgid
  6874. res.Output = resEleven10265.Output
  6875. res.ErrMsg = resEleven10265.ErrMsg
  6876. res.Cainfo = resEleven10265.Cainfo
  6877. res.WarnMsg = resEleven10265.WarnMsg
  6878. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  6879. res.Infcode = infocode
  6880. } else {
  6881. result2 := service.Gdyb5204(baseParams, businessParams)
  6882. saveLog(result2, "", "5204", "查询")
  6883. result := service.Gdyb5203(baseParams, businessParams)
  6884. var dat map[string]interface{}
  6885. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6886. fmt.Println(dat)
  6887. } else {
  6888. fmt.Println(err)
  6889. }
  6890. userJSONBytes, _ := json.Marshal(dat)
  6891. if miConfig.Code == "H15049901371" {
  6892. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  6893. utils.ErrorLog("解析失败:%v", err)
  6894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6895. return
  6896. }
  6897. res.InfRefmsgid = resEleven10265.InfRefmsgid
  6898. res.Output = resEleven10265.Output
  6899. res.ErrMsg = resEleven10265.ErrMsg
  6900. res.Cainfo = resEleven10265.Cainfo
  6901. res.WarnMsg = resEleven10265.WarnMsg
  6902. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  6903. res.Infcode = infocode
  6904. } else {
  6905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6906. utils.ErrorLog("解析失败:%v", err)
  6907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6908. return
  6909. }
  6910. }
  6911. }
  6912. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6913. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  6914. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  6915. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6916. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6917. var doctor_name string
  6918. if roles.ID == 0 {
  6919. doctor_name = "管理员"
  6920. } else {
  6921. doctor_name = roles.UserName
  6922. }
  6923. yiliao_leibie := ""
  6924. switch order.MedType {
  6925. case "11":
  6926. yiliao_leibie = "普通门诊"
  6927. break
  6928. case "12":
  6929. yiliao_leibie = "门诊挂号"
  6930. break
  6931. case "13":
  6932. yiliao_leibie = "急诊"
  6933. break
  6934. case "14":
  6935. yiliao_leibie = "门诊特殊病"
  6936. break
  6937. case "15":
  6938. yiliao_leibie = "门诊统筹"
  6939. break
  6940. case "16":
  6941. yiliao_leibie = "门诊慢性病"
  6942. break
  6943. case "21":
  6944. yiliao_leibie = "普通住院"
  6945. break
  6946. }
  6947. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6948. if res.Infcode == 0 {
  6949. c.ServeSuccessJSON(map[string]interface{}{
  6950. "diagnosis": name,
  6951. "order_infos": orderInfos,
  6952. "number": order.MdtrtId,
  6953. "date": order.SettleAccountsDate,
  6954. "charge_admin": charge_admin,
  6955. "printor_admin": printor_admin,
  6956. "info": res.Output.Setlinfo,
  6957. "bedCostTotal": bedCostTotal,
  6958. "bedCostSelfTotal": bedCostSelfTotal,
  6959. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  6960. "operationCostTotal": operationCostTotal,
  6961. "operationCostSelfTotal": operationCostSelfTotal,
  6962. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  6963. "otherCostTotal": otherCostTotal,
  6964. "otherCostSelfTotal": otherCostSelfTotal,
  6965. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  6966. "materialCostTotal": materialCostTotal,
  6967. "materialCostSelfTotal": materialCostSelfTotal,
  6968. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  6969. "westernMedicineCostTotal": westernMedicineCostTotal,
  6970. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  6971. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  6972. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  6973. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  6974. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  6975. "checkCostTotal": checkCostTotal,
  6976. "checkCostSelfTotal": checkCostSelfTotal,
  6977. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  6978. "laboratoryCostTotal": laboratoryCostTotal,
  6979. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  6980. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  6981. "treatCostTotal": treatCostTotal,
  6982. "treatCostSelfTotal": treatCostSelfTotal,
  6983. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  6984. "doctor_code": adminRole_two.DoctorCode,
  6985. "doctor_name": doctor_name,
  6986. "health_card_no": order.PsnNo,
  6987. "department": departments.Name,
  6988. "yiliao_leibie": yiliao_leibie,
  6989. "after_money": order.AccountPrice,
  6990. "patient": patient,
  6991. "org_name": miConfig.OrgName,
  6992. "org_code": miConfig.Code,
  6993. "order_number": order.Number,
  6994. //"check_order_info": cus_slice,
  6995. })
  6996. }
  6997. }
  6998. }
  6999. func (c *HisApiController) CheckTreatment() {
  7000. patient_id, _ := c.GetInt64("patient_id")
  7001. id_card_no := c.GetString("id_card_no")
  7002. insutype := c.GetString("insutype")
  7003. med_type := c.GetString("med_type")
  7004. admin_user_id, _ := c.GetInt64("admin_user_id")
  7005. adminUser := c.GetAdminUserInfo()
  7006. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7007. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7008. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7009. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7010. if miConfig.MdtrtareaAdmvs == "421300" {
  7011. var res ResultTwo
  7012. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7013. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7014. "&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)
  7015. resp, requestErr := http.Get(api)
  7016. if requestErr != nil {
  7017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7018. return
  7019. }
  7020. body, ioErr := ioutil.ReadAll(resp.Body)
  7021. if ioErr != nil {
  7022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7024. return
  7025. }
  7026. var respJSON map[string]interface{}
  7027. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7030. return
  7031. }
  7032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7033. result, _ := json.Marshal(respJSON)
  7034. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7035. utils.ErrorLog("解析失败:%v", err)
  7036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7037. return
  7038. }
  7039. if res.Infcode == 0 {
  7040. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7041. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7042. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7043. resp, requestErr := http.Get(api)
  7044. if requestErr != nil {
  7045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7046. return
  7047. }
  7048. body, ioErr := ioutil.ReadAll(resp.Body)
  7049. if ioErr != nil {
  7050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7052. return
  7053. }
  7054. var respJSON map[string]interface{}
  7055. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7058. return
  7059. }
  7060. var res Result2001
  7061. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7062. result2, _ := json.Marshal(respJSON)
  7063. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7064. utils.ErrorLog("解析失败:%v", err)
  7065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7066. return
  7067. }
  7068. if res.Infcode == 0 {
  7069. c.ServeSuccessJSON(map[string]interface{}{
  7070. "msg": res.Output.Trtinfo,
  7071. })
  7072. }
  7073. } else {
  7074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7075. return
  7076. }
  7077. } else {
  7078. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7079. var dat map[string]interface{}
  7080. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7081. fmt.Println(dat)
  7082. } else {
  7083. fmt.Println(err)
  7084. }
  7085. userJSONBytes, _ := json.Marshal(dat)
  7086. var res ResultTwo
  7087. var res10265 ResultTwo10265
  7088. if miConfig.Code == "H15049901371" {
  7089. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7090. utils.ErrorLog("解析失败:%v", err)
  7091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7092. return
  7093. }
  7094. res.ErrMsg = res10265.ErrMsg
  7095. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7096. res.Infcode = infocode
  7097. res.Output = res10265.Output
  7098. res.InfRefmsgid = res10265.InfRefmsgid
  7099. } else {
  7100. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7101. utils.ErrorLog("解析失败:%v", err)
  7102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7103. return
  7104. }
  7105. }
  7106. var user_name string
  7107. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7108. if role.ID == 0 {
  7109. user_name = "xxx"
  7110. } else {
  7111. user_name = role.UserName
  7112. }
  7113. baseParams := models.BaseParams{
  7114. SecretKey: miConfig.SecretKey,
  7115. FixmedinsCode: miConfig.Code,
  7116. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7117. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7118. OrgName: miConfig.OrgName,
  7119. Doctor: user_name,
  7120. }
  7121. if config.IsOpen == 1 {
  7122. if miConfig.Code == "H15049901371" {
  7123. if med_type == "14" {
  7124. if insutype == "390" {
  7125. med_type = "9933"
  7126. } else if insutype == "310" {
  7127. med_type = "990502"
  7128. }
  7129. } else if med_type == "11" {
  7130. med_type = "11"
  7131. }
  7132. }
  7133. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7134. var dat map[string]interface{}
  7135. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7136. fmt.Println(dat)
  7137. } else {
  7138. fmt.Println(err)
  7139. }
  7140. var res Result2001
  7141. var res10265 Result2001Org10265
  7142. if miConfig.Code == "H15049901371" {
  7143. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7144. utils.ErrorLog("解析失败:%v", err)
  7145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7146. return
  7147. }
  7148. res.ErrMsg = res10265.ErrMsg
  7149. res.Output = res10265.Output
  7150. res.InfRefmsgid = res10265.InfRefmsgid
  7151. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7152. res.Infcode = infocode
  7153. } else {
  7154. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7155. utils.ErrorLog("解析失败:%v", err)
  7156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7157. return
  7158. }
  7159. }
  7160. if res.Infcode == 0 {
  7161. c.ServeSuccessJSON(map[string]interface{}{
  7162. "msg": res.Output.Trtinfo,
  7163. })
  7164. }
  7165. }
  7166. }
  7167. }
  7168. //func (c *HisApiController) PutRecord() {
  7169. // id, _ := c.GetInt64("id")
  7170. // record_time := c.GetString("record_time")
  7171. // timeLayout := "2006-01-02"
  7172. // loc, _ := time.LoadLocation("Local")
  7173. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7174. // if err != nil {
  7175. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7176. // return
  7177. // }
  7178. // recordDateTime := theTime.Unix()
  7179. //
  7180. // adminInfo := c.GetAdminUserInfo()
  7181. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7182. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7183. //
  7184. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7185. //
  7186. // fmt.Println(miConfig.SecretKey)
  7187. //
  7188. // if patient == nil {
  7189. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7190. // return
  7191. // }
  7192. // if len(patient.IdCardNo) == 0 {
  7193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7194. // return
  7195. // }
  7196. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7197. // if config.IsOpen == 1 {
  7198. // 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
  7199. // resp, requestErr := http.Get(api)
  7200. // if requestErr != nil {
  7201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7202. // return
  7203. // }
  7204. // defer resp.Body.Close()
  7205. // body, ioErr := ioutil.ReadAll(resp.Body)
  7206. // if ioErr != nil {
  7207. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7208. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7209. // return
  7210. // }
  7211. // var respJSON map[string]interface{}
  7212. //
  7213. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7214. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7215. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7216. // return
  7217. // }
  7218. //
  7219. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7220. // userJSONBytes, _ := json.Marshal(userJSON)
  7221. // var res ResultTwo
  7222. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7223. // utils.ErrorLog("解析失败:%v", err)
  7224. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7225. // return
  7226. // }
  7227. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7228. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7229. // infoStr := string(Iinfos)
  7230. // idetinfoStr := string(Idetinfos)
  7231. //
  7232. // if res.Infcode == 0 {
  7233. // his := models.VMHisPatient{
  7234. // Status: 1,
  7235. // Ctime: time.Now().Unix(),
  7236. // Mtime: time.Now().Unix(),
  7237. // PsnNo: res.Output.Baseinfo.PsnNo,
  7238. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7239. // Certno: res.Output.Baseinfo.Certno,
  7240. // PsnName: res.Output.Baseinfo.PsnName,
  7241. // Gend: res.Output.Baseinfo.Gend,
  7242. // Naty: res.Output.Baseinfo.Naty,
  7243. // Brdy: res.Output.Baseinfo.Brdy,
  7244. // Age: res.Output.Baseinfo.Age,
  7245. // Iinfo: infoStr,
  7246. // Idetinfo: idetinfoStr,
  7247. // PatientId: patient.ID,
  7248. // RecordDate: theTime.Unix(),
  7249. // UserOrgId: adminInfo.CurrentOrgId,
  7250. // AdminUserId: adminInfo.AdminUser.Id,
  7251. // IsReturn: 1,
  7252. // }
  7253. //
  7254. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  7255. // //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")
  7256. // //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")
  7257. //
  7258. // //var dat map[string]interface{}
  7259. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7260. // // fmt.Println(dat)
  7261. // //} else {
  7262. // // fmt.Println(err)
  7263. // //}
  7264. //
  7265. // var dat2 map[string]interface{}
  7266. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  7267. // fmt.Println(dat2)
  7268. // } else {
  7269. // fmt.Println(err)
  7270. // }
  7271. //
  7272. // } else {
  7273. // adminUser := c.GetAdminUserInfo()
  7274. // errlog := &models.HisOrderError{
  7275. // UserOrgId: adminUser.CurrentOrgId,
  7276. // Ctime: time.Now().Unix(),
  7277. // Mtime: time.Now().Unix(),
  7278. // ErrMsg: res.ErrMsg,
  7279. // Status: 1,
  7280. // PatientId: id,
  7281. // RecordTime: recordDateTime,
  7282. // Stage: 1,
  7283. // }
  7284. // service.CreateErrMsgLog(errlog)
  7285. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  7286. // return
  7287. // }
  7288. // }
  7289. //
  7290. //}
  7291. //func (c *HisApiController) GetUploadDiag() {
  7292. // id, _ := c.GetInt64("id")
  7293. // record_time := c.GetString("record_time")
  7294. //
  7295. // diagnosis_id, _ := c.GetInt64("diagnosis")
  7296. // sick_type, _ := c.GetInt64("sick_type")
  7297. // reg_type, _ := c.GetInt64("reg_type")
  7298. //
  7299. // timeLayout := "2006-01-02"
  7300. // loc, _ := time.LoadLocation("Local")
  7301. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7302. // if err != nil {
  7303. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7304. // return
  7305. // }
  7306. //
  7307. // var patientPrescription models.HisPrescriptionInfo
  7308. // recordDateTime := theTime.Unix()
  7309. // adminInfo := c.GetAdminUserInfo()
  7310. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7311. //
  7312. // if patientPrescription.ID == 0 {
  7313. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7314. // }
  7315. //
  7316. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7317. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7318. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7319. // sickConfig, _ := service.FindSickById(sick_type)
  7320. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7321. //
  7322. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  7323. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  7324. // "&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 +
  7325. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  7326. // resp2, requestErr2 := http.Get(api2)
  7327. // if requestErr2 != nil {
  7328. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7329. // return
  7330. // }
  7331. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7332. // if ioErr2 != nil {
  7333. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7334. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7335. // return
  7336. // }
  7337. // var respJSON2 map[string]interface{}
  7338. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7339. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7340. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7341. // return
  7342. // }
  7343. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7344. // userJSONBytes2, _ := json.Marshal(respJSON2)
  7345. //
  7346. // var res2 ResultSix
  7347. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7348. // utils.ErrorLog("解析失败:%v", err)
  7349. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7350. // return
  7351. // }
  7352. // if res2.Infcode != 0 {
  7353. // adminUser := c.GetAdminUserInfo()
  7354. // errlog := &models.HisOrderError{
  7355. // UserOrgId: adminUser.CurrentOrgId,
  7356. // Ctime: time.Now().Unix(),
  7357. // Mtime: time.Now().Unix(),
  7358. // ErrMsg: res2.ErrMsg,
  7359. // Status: 1,
  7360. // PatientId: id,
  7361. // RecordTime: recordDateTime,
  7362. // Stage: 3,
  7363. // }
  7364. // service.CreateErrMsgLog(errlog)
  7365. //
  7366. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  7367. // return
  7368. // }
  7369. //
  7370. // c.ServeSuccessJSON(map[string]interface{}{
  7371. // "msg": "上传成功",
  7372. // })
  7373. //
  7374. //}
  7375. type QueryResult struct {
  7376. ID int64
  7377. Name string
  7378. Code string
  7379. List_type_code string
  7380. }
  7381. func (c *HisApiController) GetCheckCode() {
  7382. ids_str := c.GetString("ids")
  7383. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7384. ids_arr := strings.Split(ids_str, ",")
  7385. var queryResult []QueryResult
  7386. ids := make([]int64, 0)
  7387. for _, item := range ids_arr {
  7388. id, _ := strconv.ParseInt(item, 10, 64)
  7389. ids = append(ids, id)
  7390. }
  7391. if record_type == 1 {
  7392. drugs, _ := service.GetBatchDrugList(ids)
  7393. for _, item := range drugs {
  7394. result := QueryResult{
  7395. ID: item.ID,
  7396. Name: item.DrugName,
  7397. Code: item.MedicalInsuranceNumber,
  7398. List_type_code: "101",
  7399. }
  7400. queryResult = append(queryResult, result)
  7401. }
  7402. } else if record_type == 2 {
  7403. goods, _ := service.GetBatchGoodInformationList(ids)
  7404. for _, item := range goods {
  7405. result := QueryResult{
  7406. ID: item.ID,
  7407. Name: item.GoodName,
  7408. Code: item.MedicalInsuranceNumber,
  7409. List_type_code: "301",
  7410. }
  7411. queryResult = append(queryResult, result)
  7412. }
  7413. } else if record_type == 3 {
  7414. projects, _ := service.GetBathchMyPorjecgList(ids)
  7415. for _, item := range projects {
  7416. result := QueryResult{
  7417. ID: item.ID,
  7418. Name: item.ProjectName,
  7419. Code: item.MedicalCode,
  7420. List_type_code: "201",
  7421. }
  7422. queryResult = append(queryResult, result)
  7423. }
  7424. }
  7425. admin_user_id, _ := c.GetInt64("admin_user_id")
  7426. adminUser := c.GetAdminUserInfo()
  7427. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7428. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7429. var user_name string
  7430. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7431. if role.ID == 0 {
  7432. user_name = "xxx"
  7433. } else {
  7434. user_name = role.UserName
  7435. }
  7436. baseParams := &models.BaseParams{
  7437. SecretKey: miConfig.SecretKey,
  7438. FixmedinsCode: miConfig.Code,
  7439. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7440. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7441. OrgName: miConfig.OrgName,
  7442. Doctor: user_name,
  7443. }
  7444. if config.IsOpen == 1 {
  7445. for _, item := range queryResult {
  7446. var result string
  7447. if record_type == 1 {
  7448. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7449. } else if record_type == 2 {
  7450. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7451. } else if record_type == 3 {
  7452. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  7453. }
  7454. var dat map[string]interface{}
  7455. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7456. fmt.Println(dat)
  7457. } else {
  7458. fmt.Println(err)
  7459. }
  7460. userJSONBytes, _ := json.Marshal(dat)
  7461. var res ResultSix
  7462. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7463. utils.ErrorLog("解析失败:%v", err)
  7464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7465. return
  7466. }
  7467. if res.Infcode == 0 {
  7468. if record_type == 1 {
  7469. service.UpdateBaseDrugById(item.ID)
  7470. } else if record_type == 2 {
  7471. service.UpdateGoodInformaitonByDetail(item.ID)
  7472. } else if record_type == 3 {
  7473. service.UpdateProjectById(item.ID)
  7474. }
  7475. c.ServeSuccessJSON(map[string]interface{}{
  7476. "failed_code": 0,
  7477. "msg": "目录对照成功",
  7478. })
  7479. } else {
  7480. c.ServeSuccessJSON(map[string]interface{}{
  7481. "failed_code": -10,
  7482. "msg": res.ErrMsg,
  7483. })
  7484. }
  7485. }
  7486. }
  7487. }
  7488. func (c *HisApiController) UnCheckCode() {
  7489. ids_str := c.GetString("ids")
  7490. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  7491. admin_user_id, _ := c.GetInt64("admin_user_id")
  7492. ids_arr := strings.Split(ids_str, ",")
  7493. var queryResult []QueryResult
  7494. ids := make([]int64, 0)
  7495. for _, item := range ids_arr {
  7496. id, _ := strconv.ParseInt(item, 10, 64)
  7497. ids = append(ids, id)
  7498. }
  7499. if record_type == 1 {
  7500. drugs, _ := service.GetBatchDrugList(ids)
  7501. for _, item := range drugs {
  7502. result := QueryResult{
  7503. ID: item.ID,
  7504. Name: item.DrugName,
  7505. Code: item.MedicalInsuranceNumber,
  7506. List_type_code: "101",
  7507. }
  7508. queryResult = append(queryResult, result)
  7509. }
  7510. } else if record_type == 2 {
  7511. goods, _ := service.GetBatchGoodInformationList(ids)
  7512. for _, item := range goods {
  7513. result := QueryResult{
  7514. ID: item.ID,
  7515. Name: item.GoodName,
  7516. Code: item.MedicalInsuranceNumber,
  7517. List_type_code: "301",
  7518. }
  7519. queryResult = append(queryResult, result)
  7520. }
  7521. } else if record_type == 3 {
  7522. projects, _ := service.GetBathchMyPorjecgList(ids)
  7523. for _, item := range projects {
  7524. result := QueryResult{
  7525. ID: item.ID,
  7526. Name: item.ProjectName,
  7527. Code: item.MedicalCode,
  7528. List_type_code: "201",
  7529. }
  7530. queryResult = append(queryResult, result)
  7531. }
  7532. }
  7533. adminUser := c.GetAdminUserInfo()
  7534. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7535. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7536. var user_name string
  7537. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7538. if role.ID == 0 {
  7539. user_name = "xxx"
  7540. } else {
  7541. user_name = role.UserName
  7542. }
  7543. baseParams := &models.BaseParams{
  7544. SecretKey: miConfig.SecretKey,
  7545. FixmedinsCode: miConfig.Code,
  7546. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7547. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7548. OrgName: miConfig.OrgName,
  7549. Doctor: user_name,
  7550. }
  7551. if config.IsOpen == 1 {
  7552. for _, item := range queryResult {
  7553. var result string
  7554. if record_type == 1 {
  7555. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7556. } else if record_type == 2 {
  7557. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7558. } else if record_type == 3 {
  7559. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  7560. }
  7561. var dat2 map[string]interface{}
  7562. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  7563. fmt.Println(dat2)
  7564. } else {
  7565. fmt.Println(err)
  7566. }
  7567. userJSONBytes, _ := json.Marshal(dat2)
  7568. var res ResultSix
  7569. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7570. utils.ErrorLog("解析失败:%v", err)
  7571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7572. return
  7573. }
  7574. if res.Infcode == 0 {
  7575. if record_type == 1 {
  7576. service.UpdateDrugByIdDetail(item.ID)
  7577. } else if record_type == 2 {
  7578. service.UpdateGoodInfoById(item.ID)
  7579. } else if record_type == 3 {
  7580. service.UpdateMyProjectById(item.ID)
  7581. }
  7582. c.ServeSuccessJSON(map[string]interface{}{
  7583. "failed_code": 0,
  7584. "msg": "撤销目录对照成功",
  7585. })
  7586. } else {
  7587. c.ServeSuccessJSON(map[string]interface{}{
  7588. "failed_code": -10,
  7589. "msg": res.ErrMsg,
  7590. })
  7591. }
  7592. }
  7593. }
  7594. }
  7595. func (c *HisApiController) GetPatientInfo() {
  7596. id_card_no := c.GetString("id_card_no")
  7597. admin_user_id, _ := c.GetInt64("admin_user_id")
  7598. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  7599. if patient.ID == 0 {
  7600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7601. return
  7602. }
  7603. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7604. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7605. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  7606. if config.IsOpen == 1 {
  7607. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7608. var dat map[string]interface{}
  7609. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7610. fmt.Println(dat)
  7611. } else {
  7612. fmt.Println(err)
  7613. }
  7614. userJSONBytes, _ := json.Marshal(dat)
  7615. var res ResultTwo
  7616. var res10265 ResultTwo10265
  7617. if miConfig.Code == "H15049901371" {
  7618. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7619. utils.ErrorLog("解析失败:%v", err)
  7620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7621. return
  7622. }
  7623. res.ErrMsg = res10265.ErrMsg
  7624. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7625. res.Infcode = infocode
  7626. res.Output = res10265.Output
  7627. res.InfRefmsgid = res10265.InfRefmsgid
  7628. } else {
  7629. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7630. utils.ErrorLog("解析失败:%v", err)
  7631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7632. return
  7633. }
  7634. }
  7635. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7636. // utils.ErrorLog("解析失败:%v", err)
  7637. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7638. // return
  7639. //}
  7640. if res.Infcode != 0 {
  7641. c.ServeSuccessJSON(map[string]interface{}{
  7642. "failed_code": -10,
  7643. "msg": res.ErrMsg,
  7644. })
  7645. } else {
  7646. c.ServeSuccessJSON(map[string]interface{}{
  7647. "failed_code": 0,
  7648. "info": res,
  7649. })
  7650. }
  7651. }
  7652. }
  7653. func (c *HisApiController) PsnPutOnRecord() {
  7654. record_type, _ := c.GetInt64("type")
  7655. patient_id, _ := c.GetInt64("patient_id")
  7656. admin_user_id, _ := c.GetInt64("admin_user_id")
  7657. start_time := c.GetString("start_time")
  7658. end_time := c.GetString("end_time")
  7659. adminUser := c.GetAdminUserInfo()
  7660. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7661. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7662. var patients []*models.Patients
  7663. if record_type == 1 { //全部备案
  7664. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  7665. patients = append(patients, patient...)
  7666. } else { //单个备案
  7667. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7668. patients = append(patients, patient)
  7669. }
  7670. var user_name string
  7671. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7672. if role.ID == 0 {
  7673. user_name = "xxx"
  7674. } else {
  7675. user_name = role.UserName
  7676. }
  7677. if config.IsOpen == 1 {
  7678. for _, item := range patients {
  7679. 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
  7680. resp, requestErr := http.Get(api)
  7681. if requestErr != nil {
  7682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7683. return
  7684. }
  7685. defer resp.Body.Close()
  7686. body, ioErr := ioutil.ReadAll(resp.Body)
  7687. if ioErr != nil {
  7688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7690. return
  7691. }
  7692. var respJSON map[string]interface{}
  7693. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7696. return
  7697. }
  7698. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7699. userJSONBytes, _ := json.Marshal(userJSON)
  7700. var res ResultTwo
  7701. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7702. utils.ErrorLog("解析失败:%v", err)
  7703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7704. return
  7705. }
  7706. if res.Infcode == 0 {
  7707. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  7708. var dat map[string]interface{}
  7709. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7710. fmt.Println(dat)
  7711. } else {
  7712. fmt.Println(err)
  7713. }
  7714. userJSONBytes, _ := json.Marshal(dat)
  7715. var res2 ResultThirteen
  7716. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7717. utils.ErrorLog("解析失败:%v", err)
  7718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7719. return
  7720. }
  7721. if res2.Infcode == 0 {
  7722. psnResult := &models.GdybPsnRecord{
  7723. UserOrgId: adminUser.CurrentOrgId,
  7724. PatientId: item.ID,
  7725. PsnNo: res.Output.Baseinfo.PsnNo,
  7726. Ctime: time.Now().Unix(),
  7727. Mtime: time.Now().Unix(),
  7728. Status: 1,
  7729. IsCancel: 1,
  7730. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7731. }
  7732. service.CreatePsnRecord(psnResult)
  7733. } else {
  7734. c.ServeSuccessJSON(map[string]interface{}{
  7735. "failed_code": -10,
  7736. "msg": res2.ErrMsg,
  7737. })
  7738. return
  7739. }
  7740. }
  7741. }
  7742. }
  7743. }
  7744. func (c *HisApiController) PsnUnPutOnRecord() {
  7745. id, _ := c.GetInt64("id")
  7746. //record_type, _ := c.GetInt64("type")
  7747. admin_user_id, _ := c.GetInt64("admin_user_id")
  7748. adminUser := c.GetAdminUserInfo()
  7749. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7750. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7751. var user_name string
  7752. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7753. if role.ID == 0 {
  7754. user_name = "xxx"
  7755. } else {
  7756. user_name = role.UserName
  7757. }
  7758. psn_record, _ := service.GetPsnRecordById(id)
  7759. if psn_record.ID == 0 {
  7760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7761. return
  7762. }
  7763. if config.IsOpen == 1 {
  7764. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  7765. var dat map[string]interface{}
  7766. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7767. fmt.Println(dat)
  7768. } else {
  7769. fmt.Println(err)
  7770. }
  7771. userJSONBytes, _ := json.Marshal(dat)
  7772. var res ResultFourteen
  7773. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7774. utils.ErrorLog("解析失败:%v", err)
  7775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7776. return
  7777. }
  7778. if res.Infcode == 0 {
  7779. psn_record.IsCancel = 2
  7780. service.CreatePsnRecord(&psn_record)
  7781. } else {
  7782. c.ServeSuccessJSON(map[string]interface{}{
  7783. "failed_code": -10,
  7784. "msg": res.ErrMsg,
  7785. })
  7786. return
  7787. }
  7788. }
  7789. }
  7790. func (c *HisApiController) PsnPutNCDSOnRecord() {
  7791. patient_id, _ := c.GetInt64("patient_id")
  7792. insutype_two := c.GetString("insutype")
  7793. psn_no := c.GetString("psn_no")
  7794. doctor_id, _ := c.GetInt64("doctor_id")
  7795. sick_id, _ := c.GetInt64("sick_id")
  7796. department_id, _ := c.GetInt64("department_id")
  7797. start_time := c.GetString("start_time")
  7798. end_time := c.GetString("end_time")
  7799. check_time := c.GetString("check_time")
  7800. adminUser := c.GetAdminUserInfo()
  7801. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7802. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7803. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7804. sick, _ := service.FindSickById(sick_id)
  7805. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7806. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  7807. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7808. var res ResultTwo
  7809. var res10265 ResultTwo10265
  7810. if miConfig.Code == "H15049901371" {
  7811. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7812. utils.ErrorLog("解析失败:%v", err)
  7813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7814. return
  7815. }
  7816. res.ErrMsg = res10265.ErrMsg
  7817. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7818. res.Infcode = infocode
  7819. res.Output = res10265.Output
  7820. res.InfRefmsgid = res10265.InfRefmsgid
  7821. } else {
  7822. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7823. utils.ErrorLog("解析失败:%v", err)
  7824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7825. return
  7826. }
  7827. }
  7828. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7829. infoStr := string(Iinfos)
  7830. var rf []*ResultFive
  7831. json.Unmarshal([]byte(infoStr), &rf)
  7832. var insuplc_admdvs string
  7833. var insutype string
  7834. var is390 int = 0
  7835. var is310 int = 0
  7836. var insutypes []*ResultFive
  7837. for _, item := range rf {
  7838. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7839. insutypes = append(insutypes, item)
  7840. }
  7841. }
  7842. if len(insutypes) == 1 {
  7843. insutype = insutypes[0].Insutype
  7844. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7845. } else {
  7846. for _, i := range insutypes {
  7847. if i.Insutype == "390" {
  7848. is390 = 1
  7849. }
  7850. if i.Insutype == "310" {
  7851. is310 = 1
  7852. }
  7853. }
  7854. }
  7855. if is390 == 1 {
  7856. insutype = "390"
  7857. }
  7858. if is310 == 1 {
  7859. insutype = "310"
  7860. }
  7861. if len(insutypes) == 2 {
  7862. insutype = insutype_two
  7863. }
  7864. if len(insutypes) == 0 {
  7865. insutype = "310"
  7866. }
  7867. insutype = insutype_two
  7868. fmt.Println(insutype)
  7869. for _, item := range rf {
  7870. fmt.Println(item.Insutype)
  7871. fmt.Println(insutype)
  7872. if item.Insutype == insutype {
  7873. fmt.Println(item.Insutype)
  7874. fmt.Println(insutype)
  7875. insuplc_admdvs = item.InsuplcAdmdvs
  7876. }
  7877. }
  7878. fmt.Println(insuplc_admdvs)
  7879. if config.IsOpen == 1 {
  7880. 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)
  7881. var dat map[string]interface{}
  7882. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7883. fmt.Println(dat)
  7884. } else {
  7885. fmt.Println(err)
  7886. }
  7887. userJSONBytes, _ := json.Marshal(dat)
  7888. var res2 ResultThirteen
  7889. var res10265 ResultThirteen10265
  7890. if miConfig.Code == "H15049901371" {
  7891. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7892. utils.ErrorLog("解析失败:%v", err)
  7893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7894. return
  7895. }
  7896. res2.ErrMsg = res10265.ErrMsg
  7897. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7898. res2.Infcode = infocode
  7899. res2.Output = res10265.Output
  7900. res2.InfRefmsgid = res10265.InfRefmsgid
  7901. } else {
  7902. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7903. utils.ErrorLog("解析失败:%v", err)
  7904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7905. return
  7906. }
  7907. }
  7908. if res2.Infcode == 0 {
  7909. psnResult := &models.GdybPsnNcdsRecord{
  7910. UserOrgId: adminUser.CurrentOrgId,
  7911. PatientId: patient.ID,
  7912. PsnNo: psn_no,
  7913. DoctorId: doctor.AdminUserId,
  7914. DepartmentId: department_id,
  7915. SickType: sick_id,
  7916. Insutype: insutype,
  7917. Ctime: time.Now().Unix(),
  7918. Mtime: time.Now().Unix(),
  7919. Status: 1,
  7920. IsCancel: 1,
  7921. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  7922. }
  7923. service.CreatePsnNCDSRecord(psnResult)
  7924. c.ServeSuccessJSON(map[string]interface{}{
  7925. "failed_code": 0,
  7926. "msg": "备案成功",
  7927. "result": psnResult,
  7928. })
  7929. } else {
  7930. c.ServeSuccessJSON(map[string]interface{}{
  7931. "failed_code": -10,
  7932. "msg": res2.ErrMsg,
  7933. })
  7934. return
  7935. }
  7936. }
  7937. }
  7938. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  7939. id, _ := c.GetInt64("id")
  7940. admin_user_id, _ := c.GetInt64("admin_user_id")
  7941. adminUser := c.GetAdminUserInfo()
  7942. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7943. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7944. //config, _ := service.Ge(adminUser.CurrentOrgId)
  7945. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  7946. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7947. //var user_name string
  7948. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7949. //if role.ID == 0 {
  7950. // user_name = "xxx"
  7951. //} else {
  7952. // user_name = role.UserName
  7953. //}
  7954. psn_record, _ := service.GetPsnNCDSRecordById(id)
  7955. if psn_record.ID == 0 {
  7956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7957. return
  7958. }
  7959. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  7960. var res ResultTwo
  7961. var res10265 ResultTwo10265
  7962. if miConfig.Code == "H15049901371" {
  7963. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7964. utils.ErrorLog("解析失败:%v", err)
  7965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7966. return
  7967. }
  7968. res.ErrMsg = res10265.ErrMsg
  7969. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7970. res.Infcode = infocode
  7971. res.Output = res10265.Output
  7972. res.InfRefmsgid = res10265.InfRefmsgid
  7973. } else {
  7974. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7975. utils.ErrorLog("解析失败:%v", err)
  7976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7977. return
  7978. }
  7979. }
  7980. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7981. infoStr := string(Iinfos)
  7982. var rf []*ResultFive
  7983. json.Unmarshal([]byte(infoStr), &rf)
  7984. var insuplc_admdvs string
  7985. var insutype string
  7986. var is390 int = 0
  7987. var is310 int = 0
  7988. var insutypes []*ResultFive
  7989. for _, item := range rf {
  7990. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7991. insutypes = append(insutypes, item)
  7992. }
  7993. }
  7994. if len(insutypes) == 1 {
  7995. insutype = insutypes[0].Insutype
  7996. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7997. } else {
  7998. for _, i := range insutypes {
  7999. if i.Insutype == "390" {
  8000. is390 = 1
  8001. }
  8002. if i.Insutype == "310" {
  8003. is310 = 1
  8004. }
  8005. }
  8006. }
  8007. if is390 == 1 {
  8008. insutype = "390"
  8009. }
  8010. if is310 == 1 {
  8011. insutype = "310"
  8012. }
  8013. if len(insutypes) == 0 {
  8014. insutype = "310"
  8015. }
  8016. insutype = psn_record.Insutype
  8017. for _, item := range rf {
  8018. if item.Insutype == insutype {
  8019. insuplc_admdvs = item.InsuplcAdmdvs
  8020. }
  8021. }
  8022. if config.IsOpen == 1 {
  8023. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8024. var dat map[string]interface{}
  8025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8026. fmt.Println(dat)
  8027. } else {
  8028. fmt.Println(err)
  8029. }
  8030. userJSONBytes, _ := json.Marshal(dat)
  8031. var res ResultFourteen
  8032. var res10265 ResultFourteen10265
  8033. if miConfig.Code == "H15049901371" {
  8034. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8035. utils.ErrorLog("解析失败:%v", err)
  8036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8037. return
  8038. }
  8039. res.ErrMsg = res10265.ErrMsg
  8040. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8041. res.Infcode = infocode
  8042. res.Output = res10265.Output
  8043. res.InfRefmsgid = res10265.InfRefmsgid
  8044. } else {
  8045. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8046. utils.ErrorLog("解析失败:%v", err)
  8047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8048. return
  8049. }
  8050. }
  8051. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8052. // utils.ErrorLog("解析失败:%v", err)
  8053. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8054. // return
  8055. //}
  8056. if res.Infcode == 0 {
  8057. psn_record.IsCancel = 2
  8058. service.CreatePsnNCDSRecord(&psn_record)
  8059. c.ServeSuccessJSON(map[string]interface{}{
  8060. "failed_code": 0,
  8061. "msg": "撤销备案成功",
  8062. })
  8063. } else {
  8064. c.ServeSuccessJSON(map[string]interface{}{
  8065. "failed_code": -10,
  8066. "msg": res.ErrMsg,
  8067. })
  8068. return
  8069. }
  8070. }
  8071. }
  8072. func (c *HisApiController) TestTest() {
  8073. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8074. fmt.Println(patient.Iinfo)
  8075. }
  8076. type CustomData struct {
  8077. MsgId string
  8078. PsnNo string
  8079. Info string
  8080. }
  8081. func (c *HisApiController) ReversalData() {
  8082. var customData []*CustomData
  8083. custom := &CustomData{
  8084. MsgId: "H44022900158202103301714472004",
  8085. PsnNo: "44020000001101329945",
  8086. Info: "2207",
  8087. }
  8088. customData = append(customData, custom)
  8089. custom1 := &CustomData{
  8090. MsgId: "H4402290015820210330172057803",
  8091. PsnNo: "44020000001101161813",
  8092. Info: "2207",
  8093. }
  8094. customData = append(customData, custom1)
  8095. custom2 := &CustomData{
  8096. MsgId: "H44022900158202103301705198813",
  8097. PsnNo: "44190000133097375417",
  8098. Info: "2207",
  8099. }
  8100. customData = append(customData, custom2)
  8101. custom3 := &CustomData{
  8102. MsgId: "H44022900158202103301715524756",
  8103. PsnNo: "44020000001100187221",
  8104. Info: "2207",
  8105. }
  8106. customData = append(customData, custom3)
  8107. custom4 := &CustomData{
  8108. MsgId: "H44022900158202103301730376224",
  8109. PsnNo: "44020000001101959155",
  8110. Info: "2207",
  8111. }
  8112. customData = append(customData, custom4)
  8113. custom5 := &CustomData{
  8114. MsgId: "H44022900158202103301748008725",
  8115. PsnNo: "44020000001104246641",
  8116. Info: "2207",
  8117. }
  8118. customData = append(customData, custom5)
  8119. custom6 := &CustomData{
  8120. MsgId: "H44022900158202103301718096755",
  8121. PsnNo: "44020000001102211860",
  8122. Info: "2207",
  8123. }
  8124. customData = append(customData, custom6)
  8125. custom7 := &CustomData{
  8126. MsgId: "H44022900158202103301736551640",
  8127. PsnNo: "44020000001102687718",
  8128. Info: "2207",
  8129. }
  8130. customData = append(customData, custom7)
  8131. custom8 := &CustomData{
  8132. MsgId: "H44022900158202103301743097676",
  8133. PsnNo: "44020000001102127785",
  8134. Info: "2207",
  8135. }
  8136. customData = append(customData, custom8)
  8137. custom9 := &CustomData{
  8138. MsgId: "H44022900158202103301712304203",
  8139. PsnNo: "44020000001101518097",
  8140. Info: "2207",
  8141. }
  8142. customData = append(customData, custom9)
  8143. custom10 := &CustomData{
  8144. MsgId: "H44022900158202103301738448785",
  8145. PsnNo: "44020000001100500813",
  8146. Info: "2207",
  8147. }
  8148. customData = append(customData, custom10)
  8149. custom11 := &CustomData{
  8150. MsgId: "H44022900158202103301732455843",
  8151. PsnNo: "44020000001102690557",
  8152. Info: "2207",
  8153. }
  8154. customData = append(customData, custom11)
  8155. custom12 := &CustomData{
  8156. MsgId: "H44022900158202103301745421708",
  8157. PsnNo: "44020000001102211928",
  8158. Info: "2207",
  8159. }
  8160. customData = append(customData, custom12)
  8161. custom1212 := &CustomData{
  8162. MsgId: "H440229001582021033017351627",
  8163. PsnNo: "44020000001102481733",
  8164. Info: "2207",
  8165. }
  8166. customData = append(customData, custom1212)
  8167. custom13 := &CustomData{
  8168. MsgId: "H44022900158202103301740327951",
  8169. PsnNo: "44020000001103174866",
  8170. Info: "2207",
  8171. }
  8172. customData = append(customData, custom13)
  8173. custom14 := &CustomData{
  8174. MsgId: "H4402290015820210330174922668",
  8175. PsnNo: "44020000001102927272",
  8176. Info: "2207",
  8177. }
  8178. customData = append(customData, custom14)
  8179. custom15 := &CustomData{
  8180. MsgId: "H44022900158202103301752362273",
  8181. PsnNo: "44020000001102942890",
  8182. Info: "2207",
  8183. }
  8184. customData = append(customData, custom15)
  8185. custom16 := &CustomData{
  8186. MsgId: "H44022900158202103301751082917",
  8187. PsnNo: "44020000001101662162",
  8188. Info: "2207",
  8189. }
  8190. customData = append(customData, custom16)
  8191. custom17 := &CustomData{
  8192. MsgId: "H44022900158202103301754147728",
  8193. PsnNo: "44020000000229014511",
  8194. Info: "2207",
  8195. }
  8196. customData = append(customData, custom17)
  8197. adminUser := c.GetAdminUserInfo()
  8198. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8199. for _, item := range customData {
  8200. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8201. fmt.Println(result)
  8202. }
  8203. }
  8204. func (c *HisApiController) GetAllopatry() {
  8205. year := c.GetString("year")
  8206. month := c.GetString("month")
  8207. admin_user_id, _ := c.GetInt64("admin_user_id")
  8208. adminUser := c.GetAdminUserInfo()
  8209. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8210. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8211. result, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month)
  8212. var dat map[string]interface{}
  8213. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8214. fmt.Println(dat)
  8215. } else {
  8216. fmt.Println(err)
  8217. }
  8218. userJSONBytes, _ := json.Marshal(dat)
  8219. var res2 models.Result3260
  8220. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8221. utils.ErrorLog("解析失败:%v", err)
  8222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8223. return
  8224. }
  8225. c.ServeSuccessJSON(map[string]interface{}{
  8226. "result": res2,
  8227. })
  8228. }
  8229. func (c *HisApiController) ComfirmAllopatry() {
  8230. year := c.GetString("year")
  8231. month := c.GetString("month")
  8232. admin_user_id, _ := c.GetInt64("admin_user_id")
  8233. adminUser := c.GetAdminUserInfo()
  8234. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8235. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8236. result, _ := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month)
  8237. var dat map[string]interface{}
  8238. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8239. fmt.Println(dat)
  8240. } else {
  8241. fmt.Println(err)
  8242. }
  8243. userJSONBytes, _ := json.Marshal(dat)
  8244. var res2 models.Result3261
  8245. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8246. utils.ErrorLog("解析失败:%v", err)
  8247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8248. return
  8249. }
  8250. c.ServeSuccessJSON(map[string]interface{}{
  8251. "result": res2,
  8252. })
  8253. }
  8254. func (c *HisApiController) RefundAllopatry() {
  8255. //year := c.GetString("year")
  8256. //month := c.GetString("month")
  8257. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8258. //adminUser := c.GetAdminUserInfo()
  8259. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8260. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8261. }
  8262. func (c *HisApiController) ReversalOtherData() {
  8263. var customData []*CustomData
  8264. custom := &CustomData{
  8265. MsgId: "H44022900158202103301714472004",
  8266. PsnNo: "44020000001101329945",
  8267. Info: "2208",
  8268. }
  8269. customData = append(customData, custom)
  8270. custom1 := &CustomData{
  8271. MsgId: "H4402290015820210330172057803",
  8272. PsnNo: "44020000001101161813",
  8273. Info: "2208",
  8274. }
  8275. customData = append(customData, custom1)
  8276. custom2 := &CustomData{
  8277. MsgId: "H44022900158202103301705198813",
  8278. PsnNo: "44190000133097375417",
  8279. Info: "2208",
  8280. }
  8281. customData = append(customData, custom2)
  8282. custom3 := &CustomData{
  8283. MsgId: "H44022900158202103301715524756",
  8284. PsnNo: "44020000001100187221",
  8285. Info: "2208",
  8286. }
  8287. customData = append(customData, custom3)
  8288. custom4 := &CustomData{
  8289. MsgId: "H44022900158202103301730376224",
  8290. PsnNo: "44020000001101959155",
  8291. Info: "2208",
  8292. }
  8293. customData = append(customData, custom4)
  8294. custom5 := &CustomData{
  8295. MsgId: "H44022900158202103301748008725",
  8296. PsnNo: "44020000001104246641",
  8297. Info: "2208",
  8298. }
  8299. customData = append(customData, custom5)
  8300. custom6 := &CustomData{
  8301. MsgId: "H44022900158202103301718096755",
  8302. PsnNo: "44020000001102211860",
  8303. Info: "2208",
  8304. }
  8305. customData = append(customData, custom6)
  8306. custom7 := &CustomData{
  8307. MsgId: "H44022900158202103301736551640",
  8308. PsnNo: "44020000001102687718",
  8309. Info: "2208",
  8310. }
  8311. customData = append(customData, custom7)
  8312. custom8 := &CustomData{
  8313. MsgId: "H44022900158202103301743097676",
  8314. PsnNo: "44020000001102127785",
  8315. Info: "2208",
  8316. }
  8317. customData = append(customData, custom8)
  8318. custom9 := &CustomData{
  8319. MsgId: "H44022900158202103301712304203",
  8320. PsnNo: "44020000001101518097",
  8321. Info: "2208",
  8322. }
  8323. customData = append(customData, custom9)
  8324. custom10 := &CustomData{
  8325. MsgId: "H44022900158202103301738448785",
  8326. PsnNo: "44020000001100500813",
  8327. Info: "2208",
  8328. }
  8329. customData = append(customData, custom10)
  8330. custom11 := &CustomData{
  8331. MsgId: "H44022900158202103301732455843",
  8332. PsnNo: "44020000001102690557",
  8333. Info: "2208",
  8334. }
  8335. customData = append(customData, custom11)
  8336. custom12 := &CustomData{
  8337. MsgId: "H44022900158202103301745421708",
  8338. PsnNo: "44020000001102211928",
  8339. Info: "2208",
  8340. }
  8341. customData = append(customData, custom12)
  8342. custom1212 := &CustomData{
  8343. MsgId: "H440229001582021033017351627",
  8344. PsnNo: "44020000001102481733",
  8345. Info: "2208",
  8346. }
  8347. customData = append(customData, custom1212)
  8348. custom13 := &CustomData{
  8349. MsgId: "H44022900158202103301740327951",
  8350. PsnNo: "44020000001103174866",
  8351. Info: "2208",
  8352. }
  8353. customData = append(customData, custom13)
  8354. custom14 := &CustomData{
  8355. MsgId: "H4402290015820210330174922668",
  8356. PsnNo: "44020000001102927272",
  8357. Info: "2208",
  8358. }
  8359. customData = append(customData, custom14)
  8360. custom15 := &CustomData{
  8361. MsgId: "H44022900158202103301752362273",
  8362. PsnNo: "44020000001102942890",
  8363. Info: "2208",
  8364. }
  8365. customData = append(customData, custom15)
  8366. custom16 := &CustomData{
  8367. MsgId: "H44022900158202103301751082917",
  8368. PsnNo: "44020000001101662162",
  8369. Info: "2208",
  8370. }
  8371. customData = append(customData, custom16)
  8372. custom17 := &CustomData{
  8373. MsgId: "H44022900158202103301754147728",
  8374. PsnNo: "44020000000229014511",
  8375. Info: "2208",
  8376. }
  8377. customData = append(customData, custom17)
  8378. adminUser := c.GetAdminUserInfo()
  8379. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8380. for _, item := range customData {
  8381. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8382. fmt.Println(result)
  8383. }
  8384. }
  8385. func PathExists(path string) (bool, error) {
  8386. _, err := os.Stat(path)
  8387. if err == nil {
  8388. return true, nil
  8389. }
  8390. if os.IsNotExist(err) {
  8391. return false, nil
  8392. }
  8393. return false, err
  8394. }
  8395. //创建文件夹
  8396. func Mkdir(dir string) {
  8397. // 创建文件夹
  8398. exist, err := PathExists(dir)
  8399. if err != nil {
  8400. fmt.Println(err.Error())
  8401. } else {
  8402. if exist {
  8403. fmt.Println(dir + "文件夹已存在!")
  8404. } else {
  8405. // 文件夹名称,权限
  8406. err := os.Mkdir(dir, os.ModePerm)
  8407. if err != nil {
  8408. fmt.Println(dir+"文件夹创建失败:", err.Error())
  8409. } else {
  8410. fmt.Println(dir + "文件夹创建成功!")
  8411. }
  8412. }
  8413. }
  8414. }
  8415. //压缩文件
  8416. func Zip(srcFile string, destZip string) error {
  8417. zipfile, err := os.Create(destZip)
  8418. if err != nil {
  8419. return err
  8420. }
  8421. defer zipfile.Close()
  8422. archive := zip.NewWriter(zipfile)
  8423. defer archive.Close()
  8424. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  8425. if err != nil {
  8426. return err
  8427. }
  8428. header, err := zip.FileInfoHeader(info)
  8429. if err != nil {
  8430. return err
  8431. }
  8432. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  8433. // header.Name = path
  8434. if info.IsDir() {
  8435. header.Name += "/"
  8436. } else {
  8437. header.Method = zip.Deflate
  8438. }
  8439. writer, err := archive.CreateHeader(header)
  8440. if err != nil {
  8441. return err
  8442. }
  8443. if !info.IsDir() {
  8444. file, err := os.Open(path)
  8445. if err != nil {
  8446. return err
  8447. }
  8448. defer file.Close()
  8449. _, err = io.Copy(writer, file)
  8450. }
  8451. return err
  8452. })
  8453. return err
  8454. }
  8455. func ReadFile(filePath string) []byte {
  8456. f, err := os.Open(filePath)
  8457. if err != nil {
  8458. fmt.Println("read file fail", err)
  8459. return nil
  8460. }
  8461. defer f.Close()
  8462. fd, err := ioutil.ReadAll(f)
  8463. if err != nil {
  8464. fmt.Println("read to fd fail", err)
  8465. return nil
  8466. }
  8467. return fd
  8468. }
  8469. func saveLog(result string, request string, infno string, desc string) {
  8470. org_id, _ := beego.AppConfig.Int64("org_id")
  8471. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  8472. dir := miConfig.OrgName + "日志"
  8473. utils.Mkdir(dir)
  8474. month := time.Unix(1557042972, 0).Format("1")
  8475. year := time.Now().Format("2006")
  8476. month = time.Now().Format("01")
  8477. day := time.Now().Format("02")
  8478. hour := time.Now().Format("15")
  8479. min := time.Now().Format("04")
  8480. sec := time.Now().Format("05")
  8481. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  8482. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  8483. file_name := file + ".txt"
  8484. file_path := miConfig.OrgName + "日志" + "/" + file_name
  8485. exist, _ := utils.PathExists(file_path)
  8486. if exist { //存在
  8487. fmt.Println("存在")
  8488. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  8489. if err != nil {
  8490. fmt.Println("read fail")
  8491. }
  8492. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  8493. n, _ := f.Seek(0, 2)
  8494. _, err = f.WriteAt([]byte(content), n)
  8495. } else { //不存在
  8496. fmt.Println("文件不存在,创建文件")
  8497. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  8498. defer f.Close()
  8499. if err != nil {
  8500. } else {
  8501. _, err = f.Write([]byte("记录日志"))
  8502. }
  8503. }
  8504. }
  8505. type Charset string
  8506. const (
  8507. UTF8 = Charset("UTF-8")
  8508. GB18030 = Charset("GB18030")
  8509. )
  8510. func ConvertToString(src string, srcCode string, tagCode string) string {
  8511. srcCoder := mahonia.NewDecoder(srcCode)
  8512. srcResult := srcCoder.ConvertString(src)
  8513. tagCoder := mahonia.NewDecoder(tagCode)
  8514. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  8515. result := string(cdata)
  8516. return result
  8517. }