his_api_controller.go 433KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. }
  78. func (c *HisApiController) Get9001() {
  79. adminUser := c.GetAdminUserInfo()
  80. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  81. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  82. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  83. var dat map[string]interface{}
  84. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  85. fmt.Println(dat)
  86. } else {
  87. fmt.Println(err)
  88. }
  89. userJSONBytes, _ := json.Marshal(dat)
  90. var res models.Result9001
  91. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  92. utils.ErrorLog("解析失败:%v", err)
  93. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  94. return
  95. }
  96. }
  97. func (c *HisApiController) Check3101() {
  98. patient_id, _ := c.GetInt64("patient_id")
  99. his_patient_id, _ := c.GetInt64("his_patient_id")
  100. admin_user_id, _ := c.GetInt64("admin_user_id")
  101. adminUser := c.GetAdminUserInfo()
  102. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  103. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  104. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  105. record_time := c.GetString("record_time")
  106. trig_scen := c.GetString("trig_scen")
  107. timeLayout := "2006-01-02"
  108. loc, _ := time.LoadLocation("Local")
  109. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  110. if err != nil {
  111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  112. return
  113. }
  114. recordDateTime := theTime.Unix()
  115. var patientPrescription models.HisPrescriptionInfo
  116. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  117. if patientPrescription.ID == 0 {
  118. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  119. }
  120. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  121. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  122. //
  123. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  124. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  125. var pp models.PublicParams
  126. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  127. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  128. pp.FixmedinsName = miConfig.OrgName
  129. pp.FixmedinsCode = miConfig.Code
  130. pp.RequestUrl = miConfig.Url
  131. pp.Cainfo = miConfig.Cainfo
  132. pp.SecretKey = miConfig.SecretKey
  133. pp.AccessKey = miConfig.AccessKey
  134. pp.OpterName = roles.UserName
  135. var config []*models.HisXtDiagnoseConfig
  136. for _, item := range diagnosis_ids {
  137. id, _ := strconv.ParseInt(item, 10, 64)
  138. diagnosisConfig, _ := service.FindDiagnoseById(id)
  139. config = append(config, &diagnosisConfig)
  140. }
  141. var pd models.PatientDtos
  142. pd.PatnID = his.PsnNo
  143. pd.PatnName = his.Name
  144. pd.Gend = his.Gend
  145. pd.Brdy = his.Brdy
  146. pd.Poolarea = his.InsuplcAdmdvs
  147. pd.CurrMdtrtID = his.Number
  148. var fed models.FsiEncounterDtos
  149. fed.MdtrtID = his.Number
  150. fed.MedinsID = miConfig.Code
  151. fed.MedinsName = miConfig.OrgName
  152. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  153. fed.MedMdtrtType = "1"
  154. fed.MedinsType = "1"
  155. fed.MedinsLv = "11"
  156. tm := time.Unix(his.RecordDate, 0)
  157. s_tm := tm.Format("2006-01-02 15:04:05")
  158. fed.AdmDate = s_tm
  159. fed.DscgDate = s_tm
  160. fed.DscgMainDiseCodg = config[0].CountryCode
  161. fed.DscgMainDiseName = config[0].CountryContentName
  162. //诊断信息
  163. var fdds []*models.FsiDiagnoseDtos
  164. for index, item := range config {
  165. if index == 0 {
  166. var fdd models.FsiDiagnoseDtos
  167. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  168. fdd.InoutDiseType = "1"
  169. fdd.MaindiseFlag = "1"
  170. fdd.DiseDate = s_tm
  171. fdd.DiasSrtNo = "1"
  172. fdd.DiseName = item.CountryContentName
  173. fdd.DiseCodg = item.CountryCode
  174. fdds = append(fdds, &fdd)
  175. } else {
  176. var fdd models.FsiDiagnoseDtos
  177. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  178. fdd.InoutDiseType = "1"
  179. fdd.MaindiseFlag = "1"
  180. fdd.DiseDate = s_tm
  181. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  182. fdd.DiseName = item.CountryContentName
  183. fdd.DiseCodg = item.CountryCode
  184. fdds = append(fdds, &fdd)
  185. }
  186. }
  187. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  188. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  189. fed.AdmDeptName = department.Name
  190. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  191. fed.DscgDeptName = department.Name
  192. fed.MedMdtrtType = "1"
  193. fed.MedType = "11"
  194. //if his.Insutype == "390" {
  195. // fed.MedType = "1402"
  196. //} else {
  197. // fed.MedType = "9933"
  198. //}
  199. var orders []*models.FsiOrderDtos
  200. if trig_scen == "2" {
  201. //处方医嘱信息
  202. for _, item := range prescriptions {
  203. for _, subItem := range item.HisDoctorAdviceInfo {
  204. var order models.FsiOrderDtos
  205. order.RxID = strconv.FormatInt(item.ID, 10)
  206. order.Rxno = strconv.FormatInt(item.ID, 10)
  207. order.LongDrordFlag = "0"
  208. order.HilistType = "1"
  209. order.ChrgType = "1"
  210. order.DrordBhvr = "-"
  211. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  212. order.HosplistName = subItem.BaseDrugLib.DrugName
  213. order.HilistLv = "1"
  214. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  215. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  216. order.HosplistName = subItem.BaseDrugLib.DrugName
  217. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  218. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  219. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  220. order.OwnpayAmt = ""
  221. order.SelfpayAmt = ""
  222. order.Spec = ""
  223. order.SpecUnt = ""
  224. order.DrordBegnDate = s_tm
  225. order.DrordStopDate = ""
  226. order.DrordDrCodg = "1"
  227. order.DrordDeptName = department.Name
  228. order.DrordDrCodg = "1"
  229. order.DrordDrName = doctor_info.UserName
  230. order.DrordDrProfttl = ""
  231. order.CurrDrordFlag = "1"
  232. orders = append(orders, &order)
  233. }
  234. for _, subItem := range item.HisPrescriptionProject {
  235. if subItem.Type == 2 {
  236. var order models.FsiOrderDtos
  237. order.RxID = strconv.FormatInt(item.ID, 10)
  238. order.Rxno = strconv.FormatInt(item.ID, 10)
  239. order.LongDrordFlag = "0"
  240. order.HilistType = "1"
  241. order.ChrgType = "1"
  242. order.DrordBhvr = "-"
  243. order.HilistCode = subItem.HisProject.MedicalCode
  244. order.HosplistName = subItem.HisProject.ProjectName
  245. order.HilistLv = "1"
  246. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  247. order.HosplistCode = subItem.HisProject.MedicalCode
  248. order.HosplistName = subItem.HisProject.ProjectName
  249. order.Cnt = subItem.Count
  250. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  251. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  252. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  253. order.OwnpayAmt = ""
  254. order.SelfpayAmt = ""
  255. order.Spec = ""
  256. order.SpecUnt = ""
  257. order.DrordBegnDate = s_tm
  258. order.DrordStopDate = ""
  259. order.DrordDrCodg = "1"
  260. order.DrordDeptName = department.Name
  261. order.DrordDrCodg = "1"
  262. order.DrordDrName = doctor_info.UserName
  263. order.DrordDrProfttl = ""
  264. order.CurrDrordFlag = "1"
  265. orders = append(orders, &order)
  266. }
  267. if subItem.Type == 3 {
  268. var order models.FsiOrderDtos
  269. order.RxID = strconv.FormatInt(item.ID, 10)
  270. order.Rxno = strconv.FormatInt(item.ID, 10)
  271. order.LongDrordFlag = "0"
  272. order.HilistType = "1"
  273. order.ChrgType = "1"
  274. order.DrordBhvr = "-"
  275. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  276. order.HosplistName = subItem.GoodInfo.GoodName
  277. order.HilistLv = "1"
  278. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  279. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  280. order.HosplistName = subItem.GoodInfo.GoodName
  281. order.Cnt = subItem.Count
  282. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  283. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  284. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  285. order.OwnpayAmt = ""
  286. order.SelfpayAmt = ""
  287. order.Spec = ""
  288. order.SpecUnt = ""
  289. order.DrordBegnDate = s_tm
  290. order.DrordStopDate = ""
  291. order.DrordDrCodg = "1"
  292. order.DrordDeptName = department.Name
  293. order.DrordDrCodg = "1"
  294. order.DrordDrName = doctor_info.UserName
  295. order.DrordDrProfttl = ""
  296. order.CurrDrordFlag = "1"
  297. orders = append(orders, &order)
  298. }
  299. }
  300. }
  301. //处方医嘱信息
  302. }
  303. fed.MatnStas = "0"
  304. fed.MedfeeSumamt = "0"
  305. fed.OwnpayAmt = "0"
  306. fed.SelfpayAmt = "0"
  307. fed.AcctPayamt = "0"
  308. fed.MaAmt = "0"
  309. fed.HifpPayamt = "0"
  310. fed.SetlTotlnum = "1"
  311. fed.Insutype = his.Insutype
  312. fed.ReimFlag = "0"
  313. fed.OutSetlFlag = "0"
  314. var fopd []*models.FsiOperationDtosData
  315. data := make(map[string]interface{})
  316. data["fed"] = fed
  317. data["fdd"] = fdds
  318. data["fod"] = orders
  319. data["pd"] = pd
  320. data["pp"] = pp
  321. data["fopd"] = fopd
  322. data["trig_scen"] = trig_scen
  323. fmt.Println(data)
  324. fmt.Println(fed)
  325. fmt.Println(fdds)
  326. fmt.Println(orders)
  327. fmt.Println(pd)
  328. fmt.Println(pp)
  329. fmt.Println(fopd)
  330. client := &http.Client{}
  331. bytesData, _ := json.Marshal(data)
  332. var req *http.Request
  333. if miConfig.MdtrtareaAdmvs == "320921" {
  334. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  335. } else {
  336. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  337. }
  338. resp, _ := client.Do(req)
  339. defer resp.Body.Close()
  340. body, ioErr := ioutil.ReadAll(resp.Body)
  341. if ioErr != nil {
  342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  344. return
  345. }
  346. var respJSON map[string]interface{}
  347. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  350. return
  351. }
  352. //手术操作集合
  353. //手术操作集合
  354. }
  355. func (c *HisApiController) Check3102() {
  356. patient_id, _ := c.GetInt64("patient_id")
  357. order_id, _ := c.GetInt64("order_id")
  358. his_patient_id, _ := c.GetInt64("his_patient_id")
  359. admin_user_id, _ := c.GetInt64("admin_user_id")
  360. trig_scen := c.GetString("trig_scen")
  361. adminUser := c.GetAdminUserInfo()
  362. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  363. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  364. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  365. record_time := c.GetString("record_time")
  366. order, _ := service.GetHisOrderByID(order_id)
  367. timeLayout := "2006-01-02"
  368. loc, _ := time.LoadLocation("Local")
  369. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  370. if err != nil {
  371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  372. return
  373. }
  374. recordDateTime := theTime.Unix()
  375. var patientPrescription models.HisPrescriptionInfo
  376. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  377. if patientPrescription.ID == 0 {
  378. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  379. }
  380. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  381. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  382. //
  383. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  384. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  385. var pp models.PublicParams
  386. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  387. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  388. pp.FixmedinsName = miConfig.OrgName
  389. pp.FixmedinsCode = miConfig.Code
  390. pp.RequestUrl = miConfig.Url
  391. pp.Cainfo = miConfig.Cainfo
  392. pp.SecretKey = miConfig.SecretKey
  393. pp.AccessKey = miConfig.AccessKey
  394. pp.OpterName = roles.UserName
  395. var config []*models.HisXtDiagnoseConfig
  396. for _, item := range diagnosis_ids {
  397. id, _ := strconv.ParseInt(item, 10, 64)
  398. diagnosisConfig, _ := service.FindDiagnoseById(id)
  399. config = append(config, &diagnosisConfig)
  400. }
  401. var pd models.PatientDtos
  402. pd.PatnID = his.PsnNo
  403. pd.PatnName = his.Name
  404. pd.Gend = his.Gend
  405. pd.Brdy = his.Brdy
  406. pd.Poolarea = his.InsuplcAdmdvs
  407. pd.CurrMdtrtID = his.Number
  408. var fed models.FsiEncounterDtos
  409. fed.MdtrtID = his.Number
  410. fed.MedinsID = miConfig.Code
  411. fed.MedinsName = miConfig.OrgName
  412. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  413. fed.MedMdtrtType = "1"
  414. fed.MedinsType = "1"
  415. fed.MedinsLv = "11"
  416. tm := time.Unix(his.RecordDate, 0)
  417. s_tm := tm.Format("2006-01-02 15:04:05")
  418. fed.AdmDate = s_tm
  419. fed.DscgDate = s_tm
  420. fed.DscgMainDiseCodg = config[0].CountryCode
  421. fed.DscgMainDiseName = config[0].CountryContentName
  422. //诊断信息
  423. var fdds []*models.FsiDiagnoseDtos
  424. for index, item := range config {
  425. if index == 0 {
  426. var fdd models.FsiDiagnoseDtos
  427. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  428. fdd.InoutDiseType = "1"
  429. fdd.MaindiseFlag = "1"
  430. fdd.DiseDate = s_tm
  431. fdd.DiasSrtNo = "1"
  432. fdd.DiseName = item.CountryContentName
  433. fdd.DiseCodg = item.CountryCode
  434. fdds = append(fdds, &fdd)
  435. } else {
  436. var fdd models.FsiDiagnoseDtos
  437. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  438. fdd.InoutDiseType = "1"
  439. fdd.MaindiseFlag = "1"
  440. fdd.DiseDate = s_tm
  441. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  442. fdd.DiseName = item.CountryContentName
  443. fdd.DiseCodg = item.CountryCode
  444. fdds = append(fdds, &fdd)
  445. }
  446. }
  447. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  448. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  449. fed.AdmDeptName = department.Name
  450. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  451. fed.DscgDeptName = department.Name
  452. fed.MedType = order.MedType
  453. //处方医嘱信息
  454. var orders []*models.FsiOrderDtos
  455. //for _, item := range prescriptions {
  456. // for _, subItem := range item.HisDoctorAdviceInfo {
  457. // var order models.FsiOrderDtos
  458. // order.RxID = strconv.FormatInt(item.ID, 10)
  459. // order.Rxno = strconv.FormatInt(item.ID, 10)
  460. // order.LongDrordFlag = "0"
  461. // order.HilistType = "1"
  462. // order.ChrgType = "1"
  463. // order.DrordBhvr = "-"
  464. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  465. // order.HosplistName = subItem.BaseDrugLib.DrugName
  466. // order.HilistLv = "1"
  467. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  468. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  469. // order.HosplistName = subItem.BaseDrugLib.DrugName
  470. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  471. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  472. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  473. // order.OwnpayAmt = ""
  474. // order.SelfpayAmt = ""
  475. // order.Spec = ""
  476. // order.SpecUnt = ""
  477. // order.DrordBegnDate = s_tm
  478. // order.DrordStopDate = ""
  479. // order.DrordDrCodg = "1"
  480. // order.DrordDeptName = department.Name
  481. // order.DrordDrCodg = "1"
  482. // order.DrordDrName = doctor_info.UserName
  483. // order.DrordDrProfttl = ""
  484. // order.CurrDrordFlag = "1"
  485. // orders = append(orders, &order)
  486. // }
  487. // for _, subItem := range item.HisPrescriptionProject {
  488. // if subItem.Type == 2 {
  489. // var order models.FsiOrderDtos
  490. // order.RxID = strconv.FormatInt(item.ID, 10)
  491. // order.Rxno = strconv.FormatInt(item.ID, 10)
  492. // order.LongDrordFlag = "0"
  493. // order.HilistType = "1"
  494. // order.ChrgType = "1"
  495. // order.DrordBhvr = "-"
  496. // order.HilistCode = subItem.HisProject.MedicalCode
  497. // order.HosplistName = subItem.HisProject.ProjectName
  498. // order.HilistLv = "1"
  499. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  500. // order.HosplistCode = subItem.HisProject.MedicalCode
  501. // order.HosplistName = subItem.HisProject.ProjectName
  502. // order.Cnt = subItem.Count
  503. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  504. //
  505. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  506. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  507. // order.OwnpayAmt = ""
  508. // order.SelfpayAmt = ""
  509. // order.Spec = ""
  510. // order.SpecUnt = ""
  511. // order.DrordBegnDate = s_tm
  512. // order.DrordStopDate = ""
  513. // order.DrordDrCodg = "1"
  514. // order.DrordDeptName = department.Name
  515. // order.DrordDrCodg = "1"
  516. // order.DrordDrName = doctor_info.UserName
  517. // order.DrordDrProfttl = ""
  518. // order.CurrDrordFlag = "1"
  519. // orders = append(orders, &order)
  520. //
  521. // }
  522. // if subItem.Type == 3 {
  523. //
  524. // var order models.FsiOrderDtos
  525. // order.RxID = strconv.FormatInt(item.ID, 10)
  526. // order.Rxno = strconv.FormatInt(item.ID, 10)
  527. // order.LongDrordFlag = "0"
  528. // order.HilistType = "1"
  529. // order.ChrgType = "1"
  530. // order.DrordBhvr = "-"
  531. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  532. // order.HosplistName = subItem.GoodInfo.GoodName
  533. // order.HilistLv = "1"
  534. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  535. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  536. // order.HosplistName = subItem.GoodInfo.GoodName
  537. // order.Cnt = subItem.Count
  538. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  539. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  540. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  541. // order.OwnpayAmt = ""
  542. // order.SelfpayAmt = ""
  543. // order.Spec = ""
  544. // order.SpecUnt = ""
  545. // order.DrordBegnDate = s_tm
  546. // order.DrordStopDate = ""
  547. // order.DrordDrCodg = "1"
  548. // order.DrordDeptName = department.Name
  549. // order.DrordDrCodg = "1"
  550. // order.DrordDrName = doctor_info.UserName
  551. // order.DrordDrProfttl = ""
  552. // order.CurrDrordFlag = "1"
  553. // orders = append(orders, &order)
  554. //
  555. // }
  556. // }
  557. //}
  558. for _, item := range prescriptions {
  559. for _, subItem := range item.HisDoctorAdviceInfo {
  560. var order models.FsiOrderDtos
  561. order.RxID = strconv.FormatInt(item.ID, 10)
  562. order.Rxno = strconv.FormatInt(item.ID, 10)
  563. order.LongDrordFlag = "0"
  564. order.HilistType = "1"
  565. order.ChrgType = "1"
  566. order.DrordBhvr = "-"
  567. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  568. order.HosplistName = subItem.BaseDrugLib.DrugName
  569. order.HilistLv = "1"
  570. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  571. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  572. order.HosplistName = subItem.BaseDrugLib.DrugName
  573. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  574. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  575. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  576. order.OwnpayAmt = ""
  577. order.SelfpayAmt = ""
  578. order.Spec = ""
  579. order.SpecUnt = ""
  580. order.DrordBegnDate = s_tm
  581. order.DrordStopDate = ""
  582. order.DrordDrCodg = "1"
  583. order.DrordDeptName = department.Name
  584. order.DrordDrCodg = "1"
  585. order.DrordDrName = doctor_info.UserName
  586. order.DrordDrProfttl = ""
  587. order.CurrDrordFlag = "1"
  588. orders = append(orders, &order)
  589. }
  590. for _, subItem := range item.HisPrescriptionProject {
  591. if subItem.Type == 2 {
  592. var order models.FsiOrderDtos
  593. order.RxID = strconv.FormatInt(item.ID, 10)
  594. order.Rxno = strconv.FormatInt(item.ID, 10)
  595. order.LongDrordFlag = "0"
  596. order.HilistType = "1"
  597. order.ChrgType = "1"
  598. order.DrordBhvr = "-"
  599. order.HilistCode = subItem.HisProject.MedicalCode
  600. order.HosplistName = subItem.HisProject.ProjectName
  601. order.HilistLv = "1"
  602. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  603. order.HosplistCode = subItem.HisProject.MedicalCode
  604. order.HosplistName = subItem.HisProject.ProjectName
  605. order.Cnt = subItem.Count
  606. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  607. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  608. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  609. order.OwnpayAmt = ""
  610. order.SelfpayAmt = ""
  611. order.Spec = ""
  612. order.SpecUnt = ""
  613. order.DrordBegnDate = s_tm
  614. order.DrordStopDate = ""
  615. order.DrordDrCodg = "1"
  616. order.DrordDeptName = department.Name
  617. order.DrordDrCodg = "1"
  618. order.DrordDrName = doctor_info.UserName
  619. order.DrordDrProfttl = ""
  620. order.CurrDrordFlag = "1"
  621. orders = append(orders, &order)
  622. }
  623. if subItem.Type == 3 {
  624. var order models.FsiOrderDtos
  625. order.RxID = strconv.FormatInt(item.ID, 10)
  626. order.Rxno = strconv.FormatInt(item.ID, 10)
  627. order.LongDrordFlag = "0"
  628. order.HilistType = "1"
  629. order.ChrgType = "1"
  630. order.DrordBhvr = "-"
  631. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  632. order.HosplistName = subItem.GoodInfo.GoodName
  633. order.HilistLv = "1"
  634. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  635. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  636. order.HosplistName = subItem.GoodInfo.GoodName
  637. order.Cnt = subItem.Count
  638. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  639. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  640. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  641. order.OwnpayAmt = ""
  642. order.SelfpayAmt = ""
  643. order.Spec = ""
  644. order.SpecUnt = ""
  645. order.DrordBegnDate = s_tm
  646. order.DrordStopDate = ""
  647. order.DrordDrCodg = "1"
  648. order.DrordDeptName = department.Name
  649. order.DrordDrCodg = "1"
  650. order.DrordDrName = doctor_info.UserName
  651. order.DrordDrProfttl = ""
  652. order.CurrDrordFlag = "1"
  653. orders = append(orders, &order)
  654. }
  655. }
  656. }
  657. //处方医嘱信息
  658. fed.MatnStas = "0"
  659. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  660. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  661. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  662. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  663. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  664. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  665. fed.SetlTotlnum = "1"
  666. fed.Insutype = his.Insutype
  667. fed.ReimFlag = "0"
  668. fed.OutSetlFlag = "0"
  669. var fopd []*models.FsiOperationDtosData
  670. data := make(map[string]interface{})
  671. data["fed"] = fed
  672. data["fdd"] = fdds
  673. data["fod"] = orders
  674. data["pd"] = pd
  675. data["pp"] = pp
  676. data["fopd"] = fopd
  677. data["trig_scen"] = trig_scen
  678. client := &http.Client{}
  679. bytesData, _ := json.Marshal(data)
  680. var req *http.Request
  681. if miConfig.MdtrtareaAdmvs == "320921" {
  682. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  683. } else {
  684. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  685. }
  686. resp, _ := client.Do(req)
  687. defer resp.Body.Close()
  688. body, ioErr := ioutil.ReadAll(resp.Body)
  689. if ioErr != nil {
  690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  692. return
  693. }
  694. var respJSON map[string]interface{}
  695. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  698. return
  699. }
  700. //手术操作集合
  701. //手术操作集合
  702. }
  703. func (c *HisApiController) Check() {
  704. psn_no := c.GetString("psn_no")
  705. in := c.GetString("in")
  706. mt := c.GetString("mt")
  707. baseParams := models.BaseParams{
  708. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  709. FixmedinsCode: "H15049901371",
  710. InsuplcAdmdvs: "150499",
  711. MdtrtareaAdmvs: "150499",
  712. OrgName: "赤峰费森血液透析中心",
  713. Doctor: "1111",
  714. }
  715. service.Gdyb2001(baseParams, psn_no, in, mt)
  716. }
  717. func (c *HisApiController) GetPsnNcdsInfo() {
  718. admin_user_id, _ := c.GetInt64("admin_user_id")
  719. patient_id, _ := c.GetInt64("patient_id")
  720. id, _ := c.GetInt64("id")
  721. adminUser := c.GetAdminUserInfo()
  722. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  723. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  724. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  725. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  726. psn_record, _ := service.GetPsnNCDSRecordById(id)
  727. //
  728. //if psn_record.ID == 0 {
  729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  730. // return
  731. //}
  732. var res Result5301
  733. var res10265 Result5301For10265
  734. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  735. psn_info, _ := service.GetPsnByPatientId(patient_id)
  736. var api string
  737. if miConfig.MdtrtareaAdmvs == "320921" {
  738. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  739. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  740. } else {
  741. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  742. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  743. }
  744. resp, requestErr := http.Get(api)
  745. if requestErr != nil {
  746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  747. return
  748. }
  749. body, ioErr := ioutil.ReadAll(resp.Body)
  750. if ioErr != nil {
  751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  753. return
  754. }
  755. var respJSON map[string]interface{}
  756. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  759. return
  760. }
  761. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  762. result, _ := json.Marshal(respJSON)
  763. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  764. utils.ErrorLog("解析失败:%v", err)
  765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  766. return
  767. }
  768. res.ErrMsg = res10265.ErrMsg
  769. res.Output = res10265.Output
  770. res.InfRefmsgid = res10265.InfRefmsgid
  771. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  772. res.Infcode = infocode
  773. } else {
  774. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  775. var dat map[string]interface{}
  776. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  777. fmt.Println(dat)
  778. } else {
  779. fmt.Println(err)
  780. }
  781. userJSONBytes, _ := json.Marshal(dat)
  782. if miConfig.Code == "H15049901371" {
  783. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  784. utils.ErrorLog("解析失败:%v", err)
  785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  786. return
  787. }
  788. res.InfRefmsgid = res10265.InfRefmsgid
  789. res.Output = res10265.Output
  790. res.ErrMsg = res10265.ErrMsg
  791. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  792. res.Infcode = infocode
  793. } else {
  794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  795. utils.ErrorLog("解析失败:%v", err)
  796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  797. return
  798. }
  799. }
  800. }
  801. if res.Infcode == 0 {
  802. c.ServeSuccessJSON(map[string]interface{}{
  803. "result": res.Output.Result,
  804. })
  805. }
  806. }
  807. func (c *HisApiController) CheckInsutype() {
  808. his_patient_id, _ := c.GetInt64("his_patient_id")
  809. admin_user_id, _ := c.GetInt64("admin_user_id")
  810. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  811. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  812. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  813. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  814. var dat map[string]interface{}
  815. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  816. fmt.Println(dat)
  817. } else {
  818. fmt.Println(err)
  819. }
  820. userJSONBytes, _ := json.Marshal(dat)
  821. var res Result90100
  822. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  823. utils.ErrorLog("解析失败:%v", err)
  824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  825. return
  826. }
  827. if res.Infcode != 0 {
  828. c.ServeSuccessJSON(map[string]interface{}{
  829. "failed_code": -10,
  830. "msg": res.ErrMsg,
  831. })
  832. return
  833. } else {
  834. fmt.Println(res)
  835. }
  836. }
  837. func (c *HisApiController) CheckCardPWD() {
  838. card_pwd := c.GetString("card_pwd")
  839. his_patient_id, _ := c.GetInt64("his_patient_id")
  840. admin_user_id, _ := c.GetInt64("admin_user_id")
  841. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  842. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  843. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  844. psn, _ := service.GetPsnByPatientId(his.PatientId)
  845. bas := strings.Split(psn.CardInfo, "|")
  846. basNumber := bas[2]
  847. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  848. var dat map[string]interface{}
  849. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  850. fmt.Println(dat)
  851. } else {
  852. fmt.Println(err)
  853. }
  854. userJSONBytes, _ := json.Marshal(dat)
  855. var res Result90991
  856. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  857. utils.ErrorLog("解析失败:%v", err)
  858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  859. return
  860. }
  861. if res.Infcode != 0 {
  862. c.ServeSuccessJSON(map[string]interface{}{
  863. "failed_code": -10,
  864. "msg": res.ErrMsg,
  865. })
  866. return
  867. } else {
  868. if res.Output.Result.SscnoCheckStat == "0" {
  869. var msg string
  870. switch res.Output.Result.CardStat {
  871. case "00":
  872. msg = "未激活"
  873. break
  874. case "10":
  875. msg = "激活"
  876. break
  877. case "20":
  878. msg = "窗口挂失"
  879. break
  880. case "21":
  881. msg = "电话挂失"
  882. break
  883. case "22":
  884. msg = "单位网上申报挂失"
  885. break
  886. case "23":
  887. msg = "保健办挂失"
  888. break
  889. case "24":
  890. msg = "个人网上挂失"
  891. break
  892. case "25":
  893. msg = "网上服务大厅挂失"
  894. break
  895. case "30":
  896. msg = "注销"
  897. break
  898. case "40":
  899. msg = "回收"
  900. break
  901. case "99":
  902. msg = "制卡中(无效卡)"
  903. break
  904. }
  905. c.ServeSuccessJSON(map[string]interface{}{
  906. "failed_code": -10,
  907. "msg": msg,
  908. })
  909. return
  910. } else {
  911. c.ServeSuccessJSON(map[string]interface{}{
  912. "msg": "校验成功",
  913. })
  914. return
  915. }
  916. }
  917. }
  918. func (c *HisApiController) CheckCardPWDTwo() {
  919. //card_pwd := c.GetString("card_pwd")
  920. //his_patient_id, _ := c.GetInt64("his_patient_id")
  921. admin_user_id, _ := c.GetInt64("admin_user_id")
  922. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  923. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  924. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  925. var dat map[string]interface{}
  926. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  927. fmt.Println(dat)
  928. } else {
  929. fmt.Println(err)
  930. }
  931. userJSONBytes, _ := json.Marshal(dat)
  932. var res Result90991
  933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  934. utils.ErrorLog("解析失败:%v", err)
  935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  936. return
  937. }
  938. if res.Infcode != 0 {
  939. c.ServeSuccessJSON(map[string]interface{}{
  940. "failed_code": -10,
  941. "msg": res.ErrMsg,
  942. })
  943. return
  944. } else {
  945. if res.Output.Result.SscnoCheckStat == "0" {
  946. var msg string
  947. switch res.Output.Result.CardStat {
  948. case "00":
  949. msg = "未激活"
  950. break
  951. case "10":
  952. msg = "激活"
  953. break
  954. case "20":
  955. msg = "窗口挂失"
  956. break
  957. case "21":
  958. msg = "电话挂失"
  959. break
  960. case "22":
  961. msg = "单位网上申报挂失"
  962. break
  963. case "23":
  964. msg = "保健办挂失"
  965. break
  966. case "24":
  967. msg = "个人网上挂失"
  968. break
  969. case "25":
  970. msg = "网上服务大厅挂失"
  971. break
  972. case "30":
  973. msg = "注销"
  974. break
  975. case "40":
  976. msg = "回收"
  977. break
  978. case "99":
  979. msg = "制卡中(无效卡)"
  980. break
  981. }
  982. c.ServeSuccessJSON(map[string]interface{}{
  983. "failed_code": -10,
  984. "msg": msg,
  985. })
  986. return
  987. } else {
  988. c.ServeSuccessJSON(map[string]interface{}{
  989. "msg": "校验成功",
  990. })
  991. return
  992. }
  993. }
  994. }
  995. func (c *HisApiController) ReadCard() {
  996. id_card_type, _ := c.GetInt64("id_card_type")
  997. admin_user_id, _ := c.GetInt64("admin_user_id")
  998. certificates, _ := c.GetInt64("certificates")
  999. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1000. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1001. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1002. switch id_card_type {
  1003. case 1:
  1004. if miConfig.MdtrtareaAdmvs == "421300" {
  1005. var res ResultTwo
  1006. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1007. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1008. "&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)
  1009. resp, requestErr := http.Get(api)
  1010. if requestErr != nil {
  1011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1012. return
  1013. }
  1014. body, ioErr := ioutil.ReadAll(resp.Body)
  1015. if ioErr != nil {
  1016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1018. return
  1019. }
  1020. var respJSON map[string]interface{}
  1021. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1027. result, _ := json.Marshal(respJSON)
  1028. fmt.Println("log")
  1029. fmt.Println(string(result))
  1030. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1031. utils.ErrorLog("解析失败:%v", err)
  1032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1033. return
  1034. }
  1035. if res.Infcode == 0 {
  1036. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1037. if err == gorm.ErrRecordNotFound {
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1039. return
  1040. } else if err != nil {
  1041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1042. return
  1043. } else {
  1044. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1045. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1046. infoStr := string(Iinfos)
  1047. idetinfoStr := string(Idetinfos)
  1048. psn := &models.HisPsn{
  1049. PsnNo: res.Output.Baseinfo.PsnNo,
  1050. Age: res.Output.Baseinfo.Age,
  1051. PatientId: patient.ID,
  1052. Certno: res.Output.Baseinfo.Certno,
  1053. Brdy: res.Output.Baseinfo.Brdy,
  1054. Gend: res.Output.Baseinfo.Gend,
  1055. Naty: res.Output.Baseinfo.Naty,
  1056. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1057. PsnName: res.Output.Baseinfo.PsnName,
  1058. Idetinfo: idetinfoStr,
  1059. Insuinfo: infoStr,
  1060. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1061. }
  1062. service.CreateHisPsn(psn)
  1063. c.ServeSuccessJSON(map[string]interface{}{
  1064. "patient": patient,
  1065. "number": res.Output.Baseinfo.Certno,
  1066. })
  1067. }
  1068. } else {
  1069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1070. return
  1071. }
  1072. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1073. var api string
  1074. if miConfig.MdtrtareaAdmvs == "320921" {
  1075. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1076. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  1077. fmt.Println(api)
  1078. } else {
  1079. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1080. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1081. }
  1082. resp, requestErr := http.Get(api)
  1083. if requestErr != nil {
  1084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1085. return
  1086. }
  1087. body, ioErr := ioutil.ReadAll(resp.Body)
  1088. if ioErr != nil {
  1089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. var respJSON map[string]interface{}
  1094. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1097. return
  1098. }
  1099. var status string
  1100. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1101. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1102. //console.log()
  1103. fmt.Println("type===")
  1104. fmt.Println(card_type)
  1105. var token string
  1106. var res ResultTwo //1101结果
  1107. var res10265 ResultTwo10265 //1101结果
  1108. var card_info string //卡信息
  1109. var busi_card_info string
  1110. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1111. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1112. if status == "0" { //读卡成功
  1113. if card_type == "1" {
  1114. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1115. result, _ := json.Marshal(respJSON)
  1116. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1117. utils.ErrorLog("解析失败:%v", err)
  1118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1119. return
  1120. }
  1121. res.ErrMsg = res10265.ErrMsg
  1122. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1123. res.Infcode = infocode
  1124. res.Output = res10265.Output
  1125. res.InfRefmsgid = res10265.InfRefmsgid
  1126. } else {
  1127. //var card_info string //卡信息
  1128. //var busi_card_info string
  1129. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1130. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1131. //fmt.Println(card_info)
  1132. //fmt.Println(busi_card_info)
  1133. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1134. result, _ := json.Marshal(respJSON)
  1135. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1136. utils.ErrorLog("解析失败:%v", err)
  1137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1138. return
  1139. }
  1140. res.ErrMsg = res10265.ErrMsg
  1141. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1142. res.Infcode = infocode
  1143. res.Output = res10265.Output
  1144. res.InfRefmsgid = res10265.InfRefmsgid
  1145. }
  1146. if res.Infcode == 0 {
  1147. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1148. if err == gorm.ErrRecordNotFound {
  1149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1150. return
  1151. } else if err != nil {
  1152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1153. return
  1154. } else {
  1155. if card_type == "1" {
  1156. bas := strings.Split(card_info, "|")
  1157. basNumber := bas[2]
  1158. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1159. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1160. infoStr := string(Iinfos)
  1161. idetinfoStr := string(Idetinfos)
  1162. psn := &models.HisPsn{
  1163. PsnNo: res.Output.Baseinfo.PsnNo,
  1164. Age: res.Output.Baseinfo.Age,
  1165. PatientId: patient.ID,
  1166. Certno: res.Output.Baseinfo.Certno,
  1167. Brdy: res.Output.Baseinfo.Brdy,
  1168. Gend: res.Output.Baseinfo.Gend,
  1169. Naty: res.Output.Baseinfo.Naty,
  1170. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1171. PsnName: res.Output.Baseinfo.PsnName,
  1172. Idetinfo: idetinfoStr,
  1173. Insuinfo: infoStr,
  1174. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1175. CardInfo: card_info,
  1176. VerifyNumber: busi_card_info,
  1177. }
  1178. service.CreateHisPsn(psn)
  1179. c.ServeSuccessJSON(map[string]interface{}{
  1180. "patient": patient,
  1181. "number": basNumber,
  1182. })
  1183. } else {
  1184. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1185. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1186. infoStr := string(Iinfos)
  1187. idetinfoStr := string(Idetinfos)
  1188. psn := &models.HisPsn{
  1189. PsnNo: res.Output.Baseinfo.PsnNo,
  1190. Age: res.Output.Baseinfo.Age,
  1191. PatientId: patient.ID,
  1192. Certno: res.Output.Baseinfo.Certno,
  1193. Brdy: res.Output.Baseinfo.Brdy,
  1194. Gend: res.Output.Baseinfo.Gend,
  1195. Naty: res.Output.Baseinfo.Naty,
  1196. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1197. PsnName: res.Output.Baseinfo.PsnName,
  1198. Idetinfo: idetinfoStr,
  1199. Insuinfo: infoStr,
  1200. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1201. CardInfo: card_info,
  1202. VerifyNumber: token,
  1203. }
  1204. service.CreateHisPsn(psn)
  1205. c.ServeSuccessJSON(map[string]interface{}{
  1206. "patient": patient,
  1207. "number": token,
  1208. })
  1209. }
  1210. }
  1211. } else {
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1213. return
  1214. }
  1215. } else { //读卡失败
  1216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1217. return
  1218. }
  1219. } else {
  1220. if initFlag == 0 {
  1221. c.TestGetBasBaseInit()
  1222. }
  1223. basStr := c.GetBasBaseInfo()
  1224. if len(basStr) == 0 {
  1225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1226. return
  1227. }
  1228. fmt.Println(basStr)
  1229. bas := strings.Split(basStr, "|")
  1230. basNumber := bas[1]
  1231. fmt.Println(basNumber)
  1232. card_sn := bas[3]
  1233. fmt.Println(card_sn)
  1234. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1235. var dat map[string]interface{}
  1236. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1237. fmt.Println(dat)
  1238. } else {
  1239. fmt.Println(err)
  1240. }
  1241. userJSONBytes, _ := json.Marshal(dat)
  1242. var res ResultTwo
  1243. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1244. utils.ErrorLog("解析失败:%v", err)
  1245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1246. return
  1247. }
  1248. if res.Infcode == 0 {
  1249. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1250. if err == gorm.ErrRecordNotFound {
  1251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1252. return
  1253. } else if err != nil {
  1254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1255. return
  1256. } else {
  1257. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1258. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1259. infoStr := string(Iinfos)
  1260. idetinfoStr := string(Idetinfos)
  1261. psn := &models.HisPsn{
  1262. PsnNo: res.Output.Baseinfo.PsnNo,
  1263. Age: res.Output.Baseinfo.Age,
  1264. PatientId: patient.ID,
  1265. Certno: res.Output.Baseinfo.Certno,
  1266. Brdy: res.Output.Baseinfo.Brdy,
  1267. Gend: res.Output.Baseinfo.Gend,
  1268. Naty: res.Output.Baseinfo.Naty,
  1269. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1270. PsnName: res.Output.Baseinfo.PsnName,
  1271. Idetinfo: idetinfoStr,
  1272. Insuinfo: infoStr,
  1273. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1274. CardInfo: basStr,
  1275. VerifyNumber: "",
  1276. }
  1277. service.CreateHisPsn(psn)
  1278. c.ServeSuccessJSON(map[string]interface{}{
  1279. "patient": patient,
  1280. "number": basNumber,
  1281. })
  1282. }
  1283. } else {
  1284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1285. return
  1286. }
  1287. break
  1288. }
  1289. case 2:
  1290. SFZStr := c.GetSFZBaseInfo()
  1291. id_card_str := strings.Split(SFZStr, "^")
  1292. id_card_number := id_card_str[0]
  1293. card_sn := ""
  1294. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1295. var dat map[string]interface{}
  1296. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1297. fmt.Println(dat)
  1298. } else {
  1299. fmt.Println(err)
  1300. }
  1301. userJSONBytes, _ := json.Marshal(dat)
  1302. var res ResultTwo
  1303. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1304. utils.ErrorLog("解析失败:%v", err)
  1305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1306. return
  1307. }
  1308. if res.Infcode == 0 {
  1309. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1310. if err == gorm.ErrRecordNotFound {
  1311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1312. return
  1313. } else if err != nil {
  1314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1315. return
  1316. } else {
  1317. c.ServeSuccessJSON(map[string]interface{}{
  1318. "patient": patient,
  1319. "number": id_card_number,
  1320. })
  1321. }
  1322. } else {
  1323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1324. return
  1325. }
  1326. break
  1327. case 3:
  1328. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1329. var api string
  1330. if miConfig.MdtrtareaAdmvs == "320921" {
  1331. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1332. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  1333. fmt.Println(api)
  1334. } else {
  1335. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1336. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1337. }
  1338. resp, requestErr := http.Get(api)
  1339. if requestErr != nil {
  1340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1341. return
  1342. }
  1343. body, ioErr := ioutil.ReadAll(resp.Body)
  1344. if ioErr != nil {
  1345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1347. return
  1348. }
  1349. var respJSON map[string]interface{}
  1350. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1353. return
  1354. }
  1355. var status string
  1356. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1357. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1358. var token string
  1359. var res ResultTwo //1101结果
  1360. var res10265 ResultTwo10265 //1101结果
  1361. var card_info string //卡信息
  1362. var busi_card_info string
  1363. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1364. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1365. if status == "0" { //读卡成功
  1366. if card_type == "1" {
  1367. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1368. result, _ := json.Marshal(respJSON)
  1369. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1370. utils.ErrorLog("解析失败:%v", err)
  1371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1372. return
  1373. }
  1374. res.ErrMsg = res10265.ErrMsg
  1375. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1376. res.Infcode = infocode
  1377. res.Output = res10265.Output
  1378. res.InfRefmsgid = res10265.InfRefmsgid
  1379. } else {
  1380. //var card_info string //卡信息
  1381. //var busi_card_info string
  1382. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1383. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1384. //fmt.Println(card_info)
  1385. //fmt.Println(busi_card_info)
  1386. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1387. result, _ := json.Marshal(respJSON)
  1388. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1389. utils.ErrorLog("解析失败:%v", err)
  1390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1391. return
  1392. }
  1393. res.ErrMsg = res10265.ErrMsg
  1394. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1395. res.Infcode = infocode
  1396. res.Output = res10265.Output
  1397. res.InfRefmsgid = res10265.InfRefmsgid
  1398. }
  1399. if res.Infcode == 0 {
  1400. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1401. if err == gorm.ErrRecordNotFound {
  1402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1403. return
  1404. } else if err != nil {
  1405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1406. return
  1407. } else {
  1408. if card_type == "1" {
  1409. bas := strings.Split(card_info, "|")
  1410. basNumber := bas[2]
  1411. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1412. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1413. infoStr := string(Iinfos)
  1414. idetinfoStr := string(Idetinfos)
  1415. psn := &models.HisPsn{
  1416. PsnNo: res.Output.Baseinfo.PsnNo,
  1417. Age: res.Output.Baseinfo.Age,
  1418. PatientId: patient.ID,
  1419. Certno: res.Output.Baseinfo.Certno,
  1420. Brdy: res.Output.Baseinfo.Brdy,
  1421. Gend: res.Output.Baseinfo.Gend,
  1422. Naty: res.Output.Baseinfo.Naty,
  1423. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1424. PsnName: res.Output.Baseinfo.PsnName,
  1425. Idetinfo: idetinfoStr,
  1426. Insuinfo: infoStr,
  1427. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1428. CardInfo: card_info,
  1429. VerifyNumber: busi_card_info,
  1430. }
  1431. service.CreateHisPsn(psn)
  1432. c.ServeSuccessJSON(map[string]interface{}{
  1433. "patient": patient,
  1434. "number": basNumber,
  1435. })
  1436. } else {
  1437. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1438. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1439. infoStr := string(Iinfos)
  1440. idetinfoStr := string(Idetinfos)
  1441. psn := &models.HisPsn{
  1442. PsnNo: res.Output.Baseinfo.PsnNo,
  1443. Age: res.Output.Baseinfo.Age,
  1444. PatientId: patient.ID,
  1445. Certno: res.Output.Baseinfo.Certno,
  1446. Brdy: res.Output.Baseinfo.Brdy,
  1447. Gend: res.Output.Baseinfo.Gend,
  1448. Naty: res.Output.Baseinfo.Naty,
  1449. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1450. PsnName: res.Output.Baseinfo.PsnName,
  1451. Idetinfo: idetinfoStr,
  1452. Insuinfo: infoStr,
  1453. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1454. CardInfo: card_info,
  1455. VerifyNumber: token,
  1456. }
  1457. service.CreateHisPsn(psn)
  1458. c.ServeSuccessJSON(map[string]interface{}{
  1459. "patient": patient,
  1460. "number": token,
  1461. })
  1462. }
  1463. }
  1464. } else {
  1465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1466. return
  1467. }
  1468. } else { //读卡失败
  1469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1470. return
  1471. }
  1472. }
  1473. break
  1474. case 4:
  1475. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1476. var api string
  1477. if miConfig.MdtrtareaAdmvs == "320921" {
  1478. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1479. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  1480. fmt.Println(api)
  1481. } else {
  1482. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1483. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1484. }
  1485. resp, requestErr := http.Get(api)
  1486. if requestErr != nil {
  1487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1488. return
  1489. }
  1490. body, ioErr := ioutil.ReadAll(resp.Body)
  1491. if ioErr != nil {
  1492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1494. return
  1495. }
  1496. var respJSON map[string]interface{}
  1497. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1500. return
  1501. }
  1502. var status string
  1503. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1504. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1505. var token string
  1506. var res ResultTwo //1101结果
  1507. var res10265 ResultTwo10265 //1101结果
  1508. if status == "0" { //读卡成功
  1509. var card_info string //卡信息
  1510. var busi_card_info string
  1511. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1512. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1513. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1514. fmt.Println(card_info)
  1515. fmt.Println(busi_card_info)
  1516. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1517. result, _ := json.Marshal(respJSON)
  1518. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1519. utils.ErrorLog("解析失败:%v", err)
  1520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1521. return
  1522. }
  1523. res.ErrMsg = res10265.ErrMsg
  1524. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1525. res.Infcode = infocode
  1526. res.Output = res10265.Output
  1527. res.InfRefmsgid = res10265.InfRefmsgid
  1528. if res.Infcode == 0 {
  1529. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1530. if err == gorm.ErrRecordNotFound {
  1531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1532. return
  1533. } else if err != nil {
  1534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1535. return
  1536. } else {
  1537. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1538. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1539. infoStr := string(Iinfos)
  1540. idetinfoStr := string(Idetinfos)
  1541. psn := &models.HisPsn{
  1542. PsnNo: res.Output.Baseinfo.PsnNo,
  1543. Age: res.Output.Baseinfo.Age,
  1544. PatientId: patient.ID,
  1545. Certno: res.Output.Baseinfo.Certno,
  1546. Brdy: res.Output.Baseinfo.Brdy,
  1547. Gend: res.Output.Baseinfo.Gend,
  1548. Naty: res.Output.Baseinfo.Naty,
  1549. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1550. PsnName: res.Output.Baseinfo.PsnName,
  1551. Idetinfo: idetinfoStr,
  1552. Insuinfo: infoStr,
  1553. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1554. CardInfo: card_info,
  1555. VerifyNumber: token,
  1556. }
  1557. service.CreateHisPsn(psn)
  1558. c.ServeSuccessJSON(map[string]interface{}{
  1559. "patient": patient,
  1560. "number": token,
  1561. })
  1562. }
  1563. } else {
  1564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1565. return
  1566. }
  1567. } else { //读卡失败
  1568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1569. return
  1570. }
  1571. }
  1572. break
  1573. }
  1574. }
  1575. var initFlag int64 = 0
  1576. func (c *HisApiController) TestGetBasBaseInit() {
  1577. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1578. Iinit := DllDef.MustFindProc("Init")
  1579. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1580. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1581. if ret != 0 {
  1582. fmt.Println("SSCard的报错原因:", err)
  1583. fmt.Println("SSCard的运算结果为:", ret)
  1584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1585. return
  1586. }
  1587. result := int(ret)
  1588. fmt.Println("SSCard的运算结果为1:", result)
  1589. initFlag = 1
  1590. return
  1591. }
  1592. func (c *HisApiController) GetSFZBaseInfo() string {
  1593. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1594. readCard := DllDef.MustFindProc("ReadSFZ")
  1595. if readCard == nil {
  1596. fmt.Println("readcard is nil")
  1597. readCard = DllDef.MustFindProc("ReadSFZ")
  1598. }
  1599. str := make([]byte, 256)
  1600. str1 := make([]byte, 256)
  1601. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1602. fmt.Println(r)
  1603. return string(str)
  1604. }
  1605. func (c *HisApiController) GetBasBaseInfo() string {
  1606. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1607. readCard := DllDef.MustFindProc("ReadCardBas")
  1608. if readCard == nil {
  1609. fmt.Println("readcard is nil")
  1610. readCard = DllDef.MustFindProc("ReadCardBas")
  1611. }
  1612. str := make([]byte, 1024)
  1613. str1 := make([]byte, 1024)
  1614. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1615. fmt.Println(string(str1))
  1616. fmt.Println(string(str))
  1617. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1618. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1619. if ret2 != 0 {
  1620. return ""
  1621. }
  1622. return string(str)
  1623. }
  1624. type CustomFundPay struct {
  1625. FundPayType string `json:"fund_pay_type"`
  1626. FundPayamt float64 `json:"fund_payamt"`
  1627. }
  1628. func (c *HisApiController) GetSettleList() {
  1629. order_id, _ := c.GetInt64("order_id")
  1630. admin_user_id, _ := c.GetInt64("admin_user_id")
  1631. order, _ := service.GetHisOrderByIDTwo(order_id)
  1632. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1633. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1634. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1635. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1636. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1637. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1638. if order.ID == 0 {
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1640. return
  1641. }
  1642. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1643. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1644. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1645. fmt.Println(count)
  1646. var zero string
  1647. number := count + 1
  1648. if number >= 1000 {
  1649. zero = "0000" + strconv.FormatInt(number, 10)
  1650. } else if number >= 10000 {
  1651. zero = "000" + strconv.FormatInt(number, 10)
  1652. } else if number >= 100000 {
  1653. zero = "00" + strconv.FormatInt(number, 10)
  1654. } else if number >= 1000000 {
  1655. zero = "0" + strconv.FormatInt(number, 10)
  1656. } else {
  1657. zero = strconv.FormatInt(number, 10)
  1658. }
  1659. fmt.Println(zero)
  1660. struct4101 := service.Struct4101{
  1661. PsnNo: order.PsnNo,
  1662. MdtrtId: order.MdtrtId,
  1663. SetlId: order.SetlId,
  1664. PsnName: order.PsnName,
  1665. Gend: order.Gend,
  1666. Brdy: his.Brdy,
  1667. Age: his.Age,
  1668. Naty: order.Naty,
  1669. PatnCertType: "01",
  1670. Certno: order.Certno,
  1671. Prfs: "90",
  1672. ConerName: roles[0].UserName,
  1673. PatnRlts: "99",
  1674. ConerAddr: miConfig.OrgName,
  1675. ConerTel: admin.Mobile,
  1676. HiType: order.Insutype,
  1677. Insuplc: miConfig.InsuplcAdmdvs,
  1678. MaindiagFlag: "1",
  1679. BillCode: last_order.FaPiaoCode,
  1680. BillNo: zero,
  1681. BizSn: order.Number,
  1682. PsnSelfPay: order.PsnPartAmt,
  1683. PsnOwnPay: order.PsnPartAmt,
  1684. AcctPay: order.AcctPay,
  1685. PsnCashpay: order.PsnCashPay,
  1686. HiPaymtd: "1",
  1687. Hsorg: miConfig.InsuplcAdmdvs,
  1688. HsorgOpter: miConfig.InsuplcAdmdvs,
  1689. MedinsFillPsn: curRoles.UserName,
  1690. MedinsFillDept: depart.Name,
  1691. IptMedType: "2",
  1692. }
  1693. struct4101.SetlBegnDate = order.SetlTime
  1694. struct4101.SetlEndDate = order.SetlTime
  1695. time_arr := strings.Split(order.SetlTime, " ")
  1696. struct4101.AdmTime = time_arr[0]
  1697. struct4101.AdmEndTime = time_arr[0]
  1698. var rf []CustomFundPay
  1699. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1700. var tempFunPays []service.CustomStruct
  1701. for _, item := range rf {
  1702. var tempFunPay service.CustomStruct
  1703. tempFunPay.FundPayamt = item.FundPayamt
  1704. tempFunPay.FundPayType = item.FundPayType
  1705. tempFunPays = append(tempFunPays, tempFunPay)
  1706. }
  1707. struct4101.CustomStruct = tempFunPays
  1708. var tempDiaginfos []service.DiaginfoStructTwo
  1709. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1710. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1711. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1712. var config []*models.HisXtDiagnoseConfig
  1713. for _, item := range diagnosis_ids {
  1714. id, _ := strconv.ParseInt(item, 10, 64)
  1715. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1716. config = append(config, &diagnosisConfig)
  1717. }
  1718. for index, item := range config {
  1719. if index == 0 {
  1720. var tempDiaginfo service.DiaginfoStructTwo
  1721. tempDiaginfo.DiagCode = item.CountryCode
  1722. tempDiaginfo.DiagName = item.CountryContentName
  1723. tempDiaginfo.DiagType = "1"
  1724. tempDiaginfo.MaindiagFlag = "1"
  1725. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1726. } else {
  1727. var tempDiaginfo service.DiaginfoStructTwo
  1728. tempDiaginfo.DiagCode = item.CountryCode
  1729. tempDiaginfo.DiagName = item.CountryContentName
  1730. tempDiaginfo.DiagType = "2"
  1731. tempDiaginfo.MaindiagFlag = "0"
  1732. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1733. }
  1734. }
  1735. struct4101.Diseinfo = tempDiaginfos
  1736. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1737. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1738. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1739. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1740. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1741. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1742. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1743. var iteminfo service.IteminfoStruct
  1744. var bedCostTotal float64 = 0 //床位总费
  1745. var bedCostSelfTotal float64 = 0 //床位自费
  1746. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1747. var operationCostTotal float64 = 0 //手术费
  1748. var operationCostSelfTotal float64 = 0 //手术费
  1749. var operationCostPartSelfTotal float64 = 0 //手术费
  1750. var otherCostTotal float64 = 0 //其他费用
  1751. var otherCostSelfTotal float64 = 0 //其他费用
  1752. var otherCostPartSelfTotal float64 = 0 //其他费用
  1753. var materialCostTotal float64 = 0 //材料费
  1754. var materialCostSelfTotal float64 = 0 //材料费
  1755. var materialCostPartSelfTotal float64 = 0 //材料费
  1756. var westernMedicineCostTotal float64 = 0 //西药费
  1757. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1758. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1759. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1760. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1761. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1762. var checkCostTotal float64 = 0 //检查费
  1763. var checkCostSelfTotal float64 = 0 //检查费
  1764. var checkCostPartSelfTotal float64 = 0 //检查费
  1765. var laboratoryCostTotal float64 = 0 //化验费
  1766. var laboratoryCostSelfTotal float64 = 0 //化验费
  1767. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1768. var treatCostTotal float64 = 0 //治疗费用
  1769. var treatCostSelfTotal float64 = 0 //治疗费用
  1770. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1771. decimal.DivisionPrecision = 2
  1772. var bed_fulamt_ownpay_amt float64 = 0
  1773. var operation_fulamt_ownpay_amt float64 = 0
  1774. var other_fulamt_ownpay_amt float64 = 0
  1775. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1776. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1777. var check_fulamt_ownpay_amt float64 = 0
  1778. var material_fulamt_ownpay_amt float64 = 0
  1779. var laboratory_fulamt_ownpay_amt float64 = 0
  1780. var treat_fulamt_ownpay_amt float64 = 0
  1781. var bed_claa_sunmfee float64 = 0
  1782. var bed_clab_amt float64 = 0
  1783. var bed_other_amt float64 = 0
  1784. var operation_claa_sunmfee float64 = 0
  1785. var operation_clab_amt float64 = 0
  1786. var operation_other_amt float64 = 0
  1787. var other_claa_sunmfee float64 = 0
  1788. var other_clab_amt float64 = 0
  1789. var other_other_amt float64 = 0
  1790. var westernMedicine_claa_sunmfee float64 = 0
  1791. var westernMedicine_clab_amt float64 = 0
  1792. var westernMedicine_other_amt float64 = 0
  1793. var chineseTraditional_claa_sunmfee float64 = 0
  1794. var chineseTraditional_clab_amt float64 = 0
  1795. var chineseTraditional_other_amt float64 = 0
  1796. var check_claa_sunmfee float64 = 0
  1797. var check_clab_amt float64 = 0
  1798. var check_other_amt float64 = 0
  1799. var material_claa_sunmfee float64 = 0
  1800. var material_clab_amt float64 = 0
  1801. var material_other_amt float64 = 0
  1802. var laboratory_claa_sunmfee float64 = 0
  1803. var laboratory_clab_amt float64 = 0
  1804. var laboratory_other_amt float64 = 0
  1805. var treat_claa_sunmfee float64 = 0
  1806. var treat_clab_amt float64 = 0
  1807. var treat_other_amt float64 = 0
  1808. for _, item := range order.HisOrderInfo {
  1809. if item.MedChrgitmType == "01" { //床位费
  1810. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1811. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1812. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1813. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1814. if item.ChrgitmLv == "1" {
  1815. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1816. }
  1817. if item.ChrgitmLv == "2" {
  1818. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1819. }
  1820. if item.ChrgitmLv == "3" {
  1821. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1822. }
  1823. }
  1824. if item.MedChrgitmType == "03" { //检查费
  1825. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1826. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1827. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1828. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1829. if item.ChrgitmLv == "1" {
  1830. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1831. }
  1832. if item.ChrgitmLv == "2" {
  1833. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1834. }
  1835. if item.ChrgitmLv == "3" {
  1836. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1837. }
  1838. }
  1839. if item.MedChrgitmType == "04" { //化验费
  1840. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1841. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1842. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1843. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1844. if item.ChrgitmLv == "1" {
  1845. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1846. }
  1847. if item.ChrgitmLv == "2" {
  1848. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1849. }
  1850. if item.ChrgitmLv == "3" {
  1851. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1852. }
  1853. }
  1854. if item.MedChrgitmType == "05" { //治疗费
  1855. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1856. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1857. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1858. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1859. if item.ChrgitmLv == "1" {
  1860. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1861. }
  1862. if item.ChrgitmLv == "2" {
  1863. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1864. }
  1865. if item.ChrgitmLv == "3" {
  1866. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1867. }
  1868. }
  1869. if item.MedChrgitmType == "06" { //手术费
  1870. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1871. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1872. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1873. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1874. if item.ChrgitmLv == "1" {
  1875. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1876. }
  1877. if item.ChrgitmLv == "2" {
  1878. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1879. }
  1880. if item.ChrgitmLv == "3" {
  1881. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1882. }
  1883. }
  1884. if item.MedChrgitmType == "08" { //材料费
  1885. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1886. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1887. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1888. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1889. if item.ChrgitmLv == "1" {
  1890. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1891. }
  1892. if item.ChrgitmLv == "2" {
  1893. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1894. }
  1895. if item.ChrgitmLv == "3" {
  1896. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1897. }
  1898. }
  1899. if item.MedChrgitmType == "09" { //西药费
  1900. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1901. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1902. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1903. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1904. if item.ChrgitmLv == "1" {
  1905. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1906. }
  1907. if item.ChrgitmLv == "2" {
  1908. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1909. }
  1910. if item.ChrgitmLv == "3" {
  1911. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1912. }
  1913. }
  1914. if item.MedChrgitmType == "11" { //中成费
  1915. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1916. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1917. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1918. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1919. if item.ChrgitmLv == "1" {
  1920. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1921. }
  1922. if item.ChrgitmLv == "2" {
  1923. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1924. }
  1925. if item.ChrgitmLv == "3" {
  1926. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1927. }
  1928. }
  1929. if item.MedChrgitmType == "14" { //其他费
  1930. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1931. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1932. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1933. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1934. if item.ChrgitmLv == "1" {
  1935. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1936. }
  1937. if item.ChrgitmLv == "2" {
  1938. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1939. }
  1940. if item.ChrgitmLv == "3" {
  1941. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1942. }
  1943. }
  1944. }
  1945. var iteminfoStructs []service.IteminfoStruct
  1946. if bedCostTotal != 0 {
  1947. iteminfo.MedChrgitm = "01"
  1948. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1949. iteminfo.Amt = bedCostTotal
  1950. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1951. iteminfo.ClabAmt = bed_clab_amt
  1952. iteminfo.OthAmt = bed_other_amt
  1953. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1954. }
  1955. if checkCostTotal != 0 {
  1956. iteminfo.MedChrgitm = "03"
  1957. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1958. iteminfo.Amt = checkCostTotal
  1959. iteminfo.ClaaSumfee = check_claa_sunmfee
  1960. iteminfo.ClabAmt = check_clab_amt
  1961. iteminfo.OthAmt = check_other_amt
  1962. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1963. }
  1964. if laboratoryCostTotal != 0 {
  1965. iteminfo.MedChrgitm = "04"
  1966. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1967. iteminfo.Amt = laboratoryCostTotal
  1968. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1969. iteminfo.ClabAmt = laboratory_clab_amt
  1970. iteminfo.OthAmt = laboratory_other_amt
  1971. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1972. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1973. }
  1974. if treatCostTotal != 0 {
  1975. iteminfo.MedChrgitm = "05"
  1976. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1977. iteminfo.Amt = treatCostTotal
  1978. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1979. iteminfo.ClabAmt = treat_clab_amt
  1980. iteminfo.OthAmt = treat_other_amt
  1981. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1982. //(struct4101.IteminfoStruct, iteminfo)
  1983. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1984. }
  1985. if operationCostTotal != 0 {
  1986. iteminfo.MedChrgitm = "06"
  1987. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1988. iteminfo.Amt = operationCostTotal
  1989. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1990. iteminfo.ClabAmt = operation_clab_amt
  1991. iteminfo.OthAmt = operation_other_amt
  1992. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1993. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1994. }
  1995. if materialCostTotal != 0 {
  1996. iteminfo.MedChrgitm = "08"
  1997. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1998. iteminfo.Amt = materialCostTotal
  1999. iteminfo.ClaaSumfee = material_claa_sunmfee
  2000. iteminfo.ClabAmt = material_clab_amt
  2001. iteminfo.OthAmt = material_other_amt
  2002. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2003. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2004. }
  2005. if westernMedicineCostTotal != 0 {
  2006. iteminfo.MedChrgitm = "09"
  2007. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2008. iteminfo.Amt = westernMedicineCostTotal
  2009. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2010. iteminfo.ClabAmt = westernMedicine_clab_amt
  2011. iteminfo.OthAmt = westernMedicine_other_amt
  2012. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2013. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2014. }
  2015. if chineseTraditionalMedicineCostTotal != 0 {
  2016. iteminfo.MedChrgitm = "11"
  2017. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2018. iteminfo.Amt = westernMedicineCostTotal
  2019. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2020. iteminfo.ClabAmt = westernMedicine_clab_amt
  2021. iteminfo.OthAmt = westernMedicine_other_amt
  2022. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2023. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2024. }
  2025. if otherCostTotal != 0 {
  2026. iteminfo.MedChrgitm = "14"
  2027. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2028. iteminfo.Amt = otherCostTotal
  2029. iteminfo.ClaaSumfee = other_claa_sunmfee
  2030. iteminfo.ClabAmt = other_clab_amt
  2031. iteminfo.OthAmt = other_other_amt
  2032. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2033. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2034. }
  2035. struct4101.IteminfoStruct = iteminfoStructs
  2036. struct4101.Ntly = "中国"
  2037. struct4101.AdmCaty = "A03.06"
  2038. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2039. fmt.Println(result)
  2040. var dat map[string]interface{}
  2041. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2042. fmt.Println(dat)
  2043. } else {
  2044. fmt.Println(err)
  2045. }
  2046. userJSONBytes, _ := json.Marshal(dat)
  2047. var res ResultSeventeen
  2048. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2049. utils.ErrorLog("解析失败:%v", err)
  2050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2051. return
  2052. }
  2053. if res.Infcode != 0 {
  2054. c.ServeSuccessJSON(map[string]interface{}{
  2055. "failed_code": -10,
  2056. "msg": res.ErrMsg,
  2057. })
  2058. return
  2059. } else {
  2060. order.FaPiaoNumber = zero
  2061. order.FaPiaoCode = last_order.FaPiaoCode
  2062. service.UpdateOrder(order)
  2063. hisFundSettleListResult := &models.HisFundSettleListResult{
  2064. Number: res.Output.SetlListId,
  2065. Status: 1,
  2066. Ctime: time.Now().Unix(),
  2067. Mtime: time.Now().Unix(),
  2068. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2069. IsUpload: 1,
  2070. OrderId: order_id,
  2071. }
  2072. service.CreateUploadRecord(hisFundSettleListResult)
  2073. c.ServeSuccessJSON(map[string]interface{}{
  2074. "msg": "上传成功",
  2075. "result": hisFundSettleListResult,
  2076. })
  2077. return
  2078. }
  2079. }
  2080. func (c *HisApiController) GetSettleListHospital() {
  2081. order_id, _ := c.GetInt64("order_id")
  2082. admin_user_id, _ := c.GetInt64("admin_user_id")
  2083. order, _ := service.GetHisOrderByIDTwo(order_id)
  2084. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2085. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2086. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2087. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2088. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2089. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2090. if order.ID == 0 {
  2091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2092. return
  2093. }
  2094. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2095. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2096. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2097. fmt.Println(count)
  2098. var zero string
  2099. number := count + 1
  2100. if number >= 1000 {
  2101. zero = "0000" + strconv.FormatInt(number, 10)
  2102. } else if number >= 10000 {
  2103. zero = "000" + strconv.FormatInt(number, 10)
  2104. } else if number >= 100000 {
  2105. zero = "00" + strconv.FormatInt(number, 10)
  2106. } else if number >= 1000000 {
  2107. zero = "0" + strconv.FormatInt(number, 10)
  2108. } else {
  2109. zero = strconv.FormatInt(number, 10)
  2110. }
  2111. fmt.Println(zero)
  2112. struct4101 := service.Struct4101{
  2113. PsnNo: order.PsnNo,
  2114. MdtrtId: order.MdtrtId,
  2115. SetlId: order.SetlId,
  2116. PsnName: order.PsnName,
  2117. Gend: order.Gend,
  2118. Brdy: his.Brdy,
  2119. Age: int64(order.Age),
  2120. Naty: order.Naty,
  2121. PatnCertType: "01",
  2122. Certno: order.Certno,
  2123. Prfs: "90",
  2124. ConerName: roles[0].UserName,
  2125. PatnRlts: "99",
  2126. ConerAddr: miConfig.OrgName,
  2127. ConerTel: admin.Mobile,
  2128. HiType: order.Insutype,
  2129. Insuplc: miConfig.InsuplcAdmdvs,
  2130. MaindiagFlag: "1",
  2131. BillCode: last_order.FaPiaoCode,
  2132. BillNo: zero,
  2133. BizSn: order.Number,
  2134. PsnSelfPay: order.PsnPartAmt,
  2135. PsnOwnPay: order.PsnPartAmt,
  2136. AcctPay: order.AcctPay,
  2137. PsnCashpay: order.PsnCashPay,
  2138. HiPaymtd: "1",
  2139. Hsorg: miConfig.InsuplcAdmdvs,
  2140. HsorgOpter: miConfig.InsuplcAdmdvs,
  2141. MedinsFillPsn: curRoles.UserName,
  2142. MedinsFillDept: depart.Name,
  2143. IptMedType: "2",
  2144. AdmTime: his.InHosptialTime,
  2145. AdmEndTime: his.OutHosptialTime,
  2146. }
  2147. struct4101.SetlBegnDate = order.SetlTime
  2148. struct4101.SetlEndDate = order.SetlTime
  2149. var rf []CustomFundPay
  2150. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2151. var tempFunPays []service.CustomStruct
  2152. for _, item := range rf {
  2153. var tempFunPay service.CustomStruct
  2154. tempFunPay.FundPayamt = item.FundPayamt
  2155. tempFunPay.FundPayType = item.FundPayType
  2156. tempFunPays = append(tempFunPays, tempFunPay)
  2157. }
  2158. struct4101.CustomStruct = tempFunPays
  2159. var tempDiaginfos []service.DiaginfoStructTwo
  2160. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2161. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2162. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2163. var config []*models.HisXtDiagnoseConfig
  2164. for _, item := range diagnosis_ids {
  2165. id, _ := strconv.ParseInt(item, 10, 64)
  2166. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2167. config = append(config, &diagnosisConfig)
  2168. }
  2169. for index, item := range config {
  2170. if index == 0 {
  2171. var tempDiaginfo service.DiaginfoStructTwo
  2172. tempDiaginfo.DiagCode = item.CountryCode
  2173. tempDiaginfo.DiagName = item.CountryContentName
  2174. tempDiaginfo.DiagType = "1"
  2175. tempDiaginfo.MaindiagFlag = "1"
  2176. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2177. } else {
  2178. var tempDiaginfo service.DiaginfoStructTwo
  2179. tempDiaginfo.DiagCode = item.CountryCode
  2180. tempDiaginfo.DiagName = item.CountryContentName
  2181. tempDiaginfo.DiagType = "2"
  2182. tempDiaginfo.MaindiagFlag = "0"
  2183. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2184. }
  2185. }
  2186. struct4101.Diseinfo = tempDiaginfos
  2187. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2188. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2189. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2190. tempOpspdiseinfo2.OprnOprtCode = ""
  2191. tempOpspdiseinfo2.OprnOprtName = ""
  2192. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2193. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2194. var iteminfo service.IteminfoStruct
  2195. var bedCostTotal float64 = 0 //床位总费
  2196. var bedCostSelfTotal float64 = 0 //床位自费
  2197. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2198. var operationCostTotal float64 = 0 //手术费
  2199. var operationCostSelfTotal float64 = 0 //手术费
  2200. var operationCostPartSelfTotal float64 = 0 //手术费
  2201. var otherCostTotal float64 = 0 //其他费用
  2202. var otherCostSelfTotal float64 = 0 //其他费用
  2203. var otherCostPartSelfTotal float64 = 0 //其他费用
  2204. var materialCostTotal float64 = 0 //材料费
  2205. var materialCostSelfTotal float64 = 0 //材料费
  2206. var materialCostPartSelfTotal float64 = 0 //材料费
  2207. var westernMedicineCostTotal float64 = 0 //西药费
  2208. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2209. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2210. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2211. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2212. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2213. var checkCostTotal float64 = 0 //检查费
  2214. var checkCostSelfTotal float64 = 0 //检查费
  2215. var checkCostPartSelfTotal float64 = 0 //检查费
  2216. var laboratoryCostTotal float64 = 0 //化验费
  2217. var laboratoryCostSelfTotal float64 = 0 //化验费
  2218. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2219. var treatCostTotal float64 = 0 //治疗费用
  2220. var treatCostSelfTotal float64 = 0 //治疗费用
  2221. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2222. decimal.DivisionPrecision = 2
  2223. var bed_fulamt_ownpay_amt float64 = 0
  2224. var operation_fulamt_ownpay_amt float64 = 0
  2225. var other_fulamt_ownpay_amt float64 = 0
  2226. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2227. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2228. var check_fulamt_ownpay_amt float64 = 0
  2229. var material_fulamt_ownpay_amt float64 = 0
  2230. var laboratory_fulamt_ownpay_amt float64 = 0
  2231. var treat_fulamt_ownpay_amt float64 = 0
  2232. var bed_claa_sunmfee float64 = 0
  2233. var bed_clab_amt float64 = 0
  2234. var bed_other_amt float64 = 0
  2235. var operation_claa_sunmfee float64 = 0
  2236. var operation_clab_amt float64 = 0
  2237. var operation_other_amt float64 = 0
  2238. var other_claa_sunmfee float64 = 0
  2239. var other_clab_amt float64 = 0
  2240. var other_other_amt float64 = 0
  2241. var westernMedicine_claa_sunmfee float64 = 0
  2242. var westernMedicine_clab_amt float64 = 0
  2243. var westernMedicine_other_amt float64 = 0
  2244. var chineseTraditional_claa_sunmfee float64 = 0
  2245. var chineseTraditional_clab_amt float64 = 0
  2246. var chineseTraditional_other_amt float64 = 0
  2247. var check_claa_sunmfee float64 = 0
  2248. var check_clab_amt float64 = 0
  2249. var check_other_amt float64 = 0
  2250. var material_claa_sunmfee float64 = 0
  2251. var material_clab_amt float64 = 0
  2252. var material_other_amt float64 = 0
  2253. var laboratory_claa_sunmfee float64 = 0
  2254. var laboratory_clab_amt float64 = 0
  2255. var laboratory_other_amt float64 = 0
  2256. var treat_claa_sunmfee float64 = 0
  2257. var treat_clab_amt float64 = 0
  2258. var treat_other_amt float64 = 0
  2259. for _, item := range order.HisOrderInfo {
  2260. if item.MedChrgitmType == "01" { //床位费
  2261. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2262. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2263. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2264. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2265. if item.ChrgitmLv == "1" {
  2266. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2267. }
  2268. if item.ChrgitmLv == "2" {
  2269. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2270. }
  2271. if item.ChrgitmLv == "3" {
  2272. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2273. }
  2274. }
  2275. if item.MedChrgitmType == "03" { //检查费
  2276. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2277. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2278. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2279. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2280. if item.ChrgitmLv == "1" {
  2281. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2282. }
  2283. if item.ChrgitmLv == "2" {
  2284. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2285. }
  2286. if item.ChrgitmLv == "3" {
  2287. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2288. }
  2289. }
  2290. if item.MedChrgitmType == "04" { //化验费
  2291. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2292. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2293. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2294. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2295. if item.ChrgitmLv == "1" {
  2296. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2297. }
  2298. if item.ChrgitmLv == "2" {
  2299. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2300. }
  2301. if item.ChrgitmLv == "3" {
  2302. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2303. }
  2304. }
  2305. if item.MedChrgitmType == "05" { //治疗费
  2306. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2307. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2308. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2309. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2310. if item.ChrgitmLv == "1" {
  2311. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2312. }
  2313. if item.ChrgitmLv == "2" {
  2314. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2315. }
  2316. if item.ChrgitmLv == "3" {
  2317. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2318. }
  2319. }
  2320. if item.MedChrgitmType == "06" { //手术费
  2321. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2322. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2323. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2324. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2325. if item.ChrgitmLv == "1" {
  2326. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2327. }
  2328. if item.ChrgitmLv == "2" {
  2329. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2330. }
  2331. if item.ChrgitmLv == "3" {
  2332. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2333. }
  2334. }
  2335. if item.MedChrgitmType == "08" { //材料费
  2336. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2337. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2338. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2339. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2340. if item.ChrgitmLv == "1" {
  2341. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2342. }
  2343. if item.ChrgitmLv == "2" {
  2344. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2345. }
  2346. if item.ChrgitmLv == "3" {
  2347. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2348. }
  2349. }
  2350. if item.MedChrgitmType == "09" { //西药费
  2351. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2352. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2353. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2354. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2355. if item.ChrgitmLv == "1" {
  2356. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2357. }
  2358. if item.ChrgitmLv == "2" {
  2359. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2360. }
  2361. if item.ChrgitmLv == "3" {
  2362. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2363. }
  2364. }
  2365. if item.MedChrgitmType == "11" { //中成费
  2366. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2367. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2368. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2369. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2370. if item.ChrgitmLv == "1" {
  2371. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2372. }
  2373. if item.ChrgitmLv == "2" {
  2374. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2375. }
  2376. if item.ChrgitmLv == "3" {
  2377. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2378. }
  2379. }
  2380. if item.MedChrgitmType == "14" { //其他费
  2381. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2382. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2383. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2384. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2385. if item.ChrgitmLv == "1" {
  2386. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2387. }
  2388. if item.ChrgitmLv == "2" {
  2389. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2390. }
  2391. if item.ChrgitmLv == "3" {
  2392. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2393. }
  2394. }
  2395. }
  2396. var iteminfoStructs []service.IteminfoStruct
  2397. if bedCostTotal != 0 {
  2398. iteminfo.MedChrgitm = "01"
  2399. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2400. iteminfo.Amt = bedCostTotal
  2401. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2402. iteminfo.ClabAmt = bed_clab_amt
  2403. iteminfo.OthAmt = bed_other_amt
  2404. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2405. }
  2406. if checkCostTotal != 0 {
  2407. iteminfo.MedChrgitm = "03"
  2408. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2409. iteminfo.Amt = checkCostTotal
  2410. iteminfo.ClaaSumfee = check_claa_sunmfee
  2411. iteminfo.ClabAmt = check_clab_amt
  2412. iteminfo.OthAmt = check_other_amt
  2413. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2414. }
  2415. if laboratoryCostTotal != 0 {
  2416. iteminfo.MedChrgitm = "04"
  2417. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2418. iteminfo.Amt = laboratoryCostTotal
  2419. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2420. iteminfo.ClabAmt = laboratory_clab_amt
  2421. iteminfo.OthAmt = laboratory_other_amt
  2422. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2423. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2424. }
  2425. if treatCostTotal != 0 {
  2426. iteminfo.MedChrgitm = "05"
  2427. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2428. iteminfo.Amt = treatCostTotal
  2429. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2430. iteminfo.ClabAmt = treat_clab_amt
  2431. iteminfo.OthAmt = treat_other_amt
  2432. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2433. //(struct4101.IteminfoStruct, iteminfo)
  2434. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2435. }
  2436. if operationCostTotal != 0 {
  2437. iteminfo.MedChrgitm = "06"
  2438. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2439. iteminfo.Amt = operationCostTotal
  2440. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2441. iteminfo.ClabAmt = operation_clab_amt
  2442. iteminfo.OthAmt = operation_other_amt
  2443. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2444. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2445. }
  2446. if materialCostTotal != 0 {
  2447. iteminfo.MedChrgitm = "08"
  2448. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2449. iteminfo.Amt = materialCostTotal
  2450. iteminfo.ClaaSumfee = material_claa_sunmfee
  2451. iteminfo.ClabAmt = material_clab_amt
  2452. iteminfo.OthAmt = material_other_amt
  2453. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2454. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2455. }
  2456. if westernMedicineCostTotal != 0 {
  2457. iteminfo.MedChrgitm = "09"
  2458. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2459. iteminfo.Amt = westernMedicineCostTotal
  2460. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2461. iteminfo.ClabAmt = westernMedicine_clab_amt
  2462. iteminfo.OthAmt = westernMedicine_other_amt
  2463. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2464. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2465. }
  2466. if chineseTraditionalMedicineCostTotal != 0 {
  2467. iteminfo.MedChrgitm = "11"
  2468. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2469. iteminfo.Amt = westernMedicineCostTotal
  2470. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2471. iteminfo.ClabAmt = westernMedicine_clab_amt
  2472. iteminfo.OthAmt = westernMedicine_other_amt
  2473. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2474. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2475. }
  2476. if otherCostTotal != 0 {
  2477. iteminfo.MedChrgitm = "14"
  2478. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2479. iteminfo.Amt = otherCostTotal
  2480. iteminfo.ClaaSumfee = other_claa_sunmfee
  2481. iteminfo.ClabAmt = other_clab_amt
  2482. iteminfo.OthAmt = other_other_amt
  2483. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2484. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2485. }
  2486. struct4101.IteminfoStruct = iteminfoStructs
  2487. struct4101.Ntly = "中国"
  2488. struct4101.AdmCaty = "A03.06"
  2489. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2490. fmt.Println(result)
  2491. var dat map[string]interface{}
  2492. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2493. fmt.Println(dat)
  2494. } else {
  2495. fmt.Println(err)
  2496. }
  2497. userJSONBytes, _ := json.Marshal(dat)
  2498. var res ResultSeventeen
  2499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2500. utils.ErrorLog("解析失败:%v", err)
  2501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2502. return
  2503. }
  2504. if res.Infcode != 0 {
  2505. c.ServeSuccessJSON(map[string]interface{}{
  2506. "failed_code": -10,
  2507. "msg": res.ErrMsg,
  2508. })
  2509. return
  2510. } else {
  2511. order.FaPiaoNumber = zero
  2512. order.FaPiaoCode = last_order.FaPiaoCode
  2513. service.UpdateOrder(order)
  2514. hisFundSettleListResult := &models.HisFundSettleListResult{
  2515. Number: res.Output.SetlListId,
  2516. Status: 1,
  2517. Ctime: time.Now().Unix(),
  2518. Mtime: time.Now().Unix(),
  2519. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2520. IsUpload: 1,
  2521. OrderId: order_id,
  2522. }
  2523. service.CreateUploadRecord(hisFundSettleListResult)
  2524. c.ServeSuccessJSON(map[string]interface{}{
  2525. "msg": "上传成功",
  2526. "result": hisFundSettleListResult,
  2527. })
  2528. return
  2529. }
  2530. }
  2531. func (c *HisApiController) GetBatchSettleList() {
  2532. orders, _ := service.GetAllHisOrder(10106)
  2533. for _, item := range orders {
  2534. order_id := item.ID
  2535. order, _ := service.GetHisOrderByIDTwo(order_id)
  2536. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2537. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2538. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2539. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2540. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2541. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2542. if order.ID == 0 {
  2543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2544. return
  2545. }
  2546. if his.BalanceAccountsType == 2 {
  2547. continue
  2548. }
  2549. struct4101 := service.Struct4101{
  2550. PsnNo: order.PsnNo,
  2551. MdtrtId: order.MdtrtId,
  2552. SetlId: order.SetlId,
  2553. PsnName: order.PsnName,
  2554. Gend: order.Gend,
  2555. Brdy: his.Brdy,
  2556. Age: his.Age,
  2557. Naty: order.Naty,
  2558. PatnCertType: "01",
  2559. Certno: order.Certno,
  2560. Prfs: "90",
  2561. ConerName: roles[0].UserName,
  2562. PatnRlts: "99",
  2563. ConerAddr: miConfig.OrgName,
  2564. ConerTel: admin.Mobile,
  2565. HiType: order.Insutype,
  2566. Insuplc: his.InsuplcAdmdvs,
  2567. MaindiagFlag: "1",
  2568. BillCode: order.FaPiaoCode,
  2569. BillNo: order.FaPiaoNumber,
  2570. BizSn: order.Number,
  2571. PsnSelfPay: order.PsnPartAmt,
  2572. PsnOwnPay: order.PsnPartAmt,
  2573. AcctPay: order.AcctPay,
  2574. PsnCashpay: order.PsnCashPay,
  2575. HiPaymtd: "1",
  2576. Hsorg: his.InsuplcAdmdvs,
  2577. HsorgOpter: his.InsuplcAdmdvs,
  2578. MedinsFillPsn: curRoles.UserName,
  2579. MedinsFillDept: depart.Name,
  2580. IptMedType: "2",
  2581. }
  2582. struct4101.SetlBegnDate = order.SetlTime
  2583. struct4101.SetlEndDate = order.SetlTime
  2584. //if order.SettleType == 1 {
  2585. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2586. // dateStr := t.Format("2006-01-02")
  2587. // struct4101.SetlBegnDate = dateStr
  2588. // struct4101.SetlEndDate = dateStr
  2589. //} else {
  2590. // t := time.Unix(int64(order.SettleStartTime), 0)
  2591. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2592. // dateStartStr := t.Format("2006-01-02")
  2593. // dateEndStr := t2.Format("2006-01-02")
  2594. // struct4101.SetlBegnDate = dateStartStr
  2595. // struct4101.SetlEndDate = dateEndStr
  2596. //}
  2597. var rf []CustomFundPay
  2598. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2599. var tempFunPays []service.CustomStruct
  2600. var tempFunPay610100 service.CustomStruct
  2601. for _, item := range rf {
  2602. if item.FundPayType == "610100" {
  2603. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2604. tempFunPay610100.FundPayType = item.FundPayType
  2605. } else {
  2606. var tempFunPay service.CustomStruct
  2607. tempFunPay.FundPayamt = item.FundPayamt
  2608. tempFunPay.FundPayType = item.FundPayType
  2609. tempFunPays = append(tempFunPays, tempFunPay)
  2610. }
  2611. }
  2612. tempFunPays = append(tempFunPays, tempFunPay610100)
  2613. struct4101.CustomStruct = tempFunPays
  2614. var tempDiaginfos []service.DiaginfoStructTwo
  2615. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2616. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2617. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2618. var config []*models.HisXtDiagnoseConfig
  2619. for _, item := range diagnosis_ids {
  2620. id, _ := strconv.ParseInt(item, 10, 64)
  2621. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2622. config = append(config, &diagnosisConfig)
  2623. }
  2624. for index, item := range config {
  2625. if index == 0 {
  2626. var tempDiaginfo service.DiaginfoStructTwo
  2627. tempDiaginfo.DiagCode = item.CountryCode
  2628. tempDiaginfo.DiagName = item.CountryContentName
  2629. tempDiaginfo.DiagType = "1"
  2630. tempDiaginfo.MaindiagFlag = "1"
  2631. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2632. } else {
  2633. var tempDiaginfo service.DiaginfoStructTwo
  2634. tempDiaginfo.DiagCode = item.CountryCode
  2635. tempDiaginfo.DiagName = item.CountryContentName
  2636. tempDiaginfo.DiagType = "2"
  2637. tempDiaginfo.MaindiagFlag = "0"
  2638. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2639. }
  2640. }
  2641. struct4101.Diseinfo = tempDiaginfos
  2642. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2643. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2644. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2645. tempOpspdiseinfo2.OprnOprtCode = ""
  2646. tempOpspdiseinfo2.OprnOprtName = ""
  2647. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2648. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2649. var iteminfo service.IteminfoStruct
  2650. var bedCostTotal float64 = 0 //床位总费
  2651. var bedCostSelfTotal float64 = 0 //床位自费
  2652. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2653. var examineCostTotal float64 = 0 //诊查总费
  2654. var examineCostSelfTotal float64 = 0 //诊查自费
  2655. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2656. var nursingCostTotal float64 = 0 //护理总费
  2657. var nursingCostSelfTotal float64 = 0 //护理自费
  2658. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2659. var chineseMedicineCostTotal float64 = 0 //中成药
  2660. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2661. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2662. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2663. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2664. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2665. var registerCostTotal float64 = 0 //一般诊疗费
  2666. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2667. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2668. var operationCostTotal float64 = 0 //手术费
  2669. var operationCostSelfTotal float64 = 0 //手术费
  2670. var operationCostPartSelfTotal float64 = 0 //手术费
  2671. var otherCostTotal float64 = 0 //其他费用
  2672. var otherCostSelfTotal float64 = 0 //其他费用
  2673. var otherCostPartSelfTotal float64 = 0 //其他费用
  2674. var materialCostTotal float64 = 0 //材料费
  2675. var materialCostSelfTotal float64 = 0 //材料费
  2676. var materialCostPartSelfTotal float64 = 0 //材料费
  2677. var westernMedicineCostTotal float64 = 0 //西药费
  2678. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2679. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2680. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2681. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2682. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2683. var checkCostTotal float64 = 0 //检查费
  2684. var checkCostSelfTotal float64 = 0 //检查费
  2685. var checkCostPartSelfTotal float64 = 0 //检查费
  2686. var laboratoryCostTotal float64 = 0 //化验费
  2687. var laboratoryCostSelfTotal float64 = 0 //化验费
  2688. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2689. var treatCostTotal float64 = 0 //治疗费用
  2690. var treatCostSelfTotal float64 = 0 //治疗费用
  2691. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2692. decimal.DivisionPrecision = 2
  2693. var bed_fulamt_ownpay_amt float64 = 0
  2694. var examine_fulamt_ownpay_amt float64 = 0
  2695. var nursing_fulamt_ownpay_amt float64 = 0
  2696. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2697. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2698. var register_fulamt_ownpay_amt float64 = 0
  2699. var operation_fulamt_ownpay_amt float64 = 0
  2700. var other_fulamt_ownpay_amt float64 = 0
  2701. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2702. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2703. var check_fulamt_ownpay_amt float64 = 0
  2704. var material_fulamt_ownpay_amt float64 = 0
  2705. var laboratory_fulamt_ownpay_amt float64 = 0
  2706. var treat_fulamt_ownpay_amt float64 = 0
  2707. var bed_claa_sunmfee float64 = 0
  2708. var bed_clab_amt float64 = 0
  2709. var bed_other_amt float64 = 0
  2710. var examine_claa_sunmfee float64 = 0
  2711. var examine_clab_amt float64 = 0
  2712. var examine_other_amt float64 = 0
  2713. var nursing_claa_sunmfee float64 = 0
  2714. var nursing_clab_amt float64 = 0
  2715. var nursing_other_amt float64 = 0
  2716. var chinese_medicine_claa_sunmfee float64 = 0
  2717. var chinese_medicine_clab_amt float64 = 0
  2718. var chinese_medicine_other_amt float64 = 0
  2719. var commonly_treatment_claa_sunmfee float64 = 0
  2720. var commonly_treatment_clab_amt float64 = 0
  2721. var commonly_treatment_other_amt float64 = 0
  2722. var operation_claa_sunmfee float64 = 0
  2723. var operation_clab_amt float64 = 0
  2724. var operation_other_amt float64 = 0
  2725. var other_claa_sunmfee float64 = 0
  2726. var other_clab_amt float64 = 0
  2727. var other_other_amt float64 = 0
  2728. var westernMedicine_claa_sunmfee float64 = 0
  2729. var westernMedicine_clab_amt float64 = 0
  2730. var westernMedicine_other_amt float64 = 0
  2731. var chineseTraditional_claa_sunmfee float64 = 0
  2732. var chineseTraditional_clab_amt float64 = 0
  2733. var chineseTraditional_other_amt float64 = 0
  2734. var check_claa_sunmfee float64 = 0
  2735. var check_clab_amt float64 = 0
  2736. var check_other_amt float64 = 0
  2737. var material_claa_sunmfee float64 = 0
  2738. var material_clab_amt float64 = 0
  2739. var material_other_amt float64 = 0
  2740. var laboratory_claa_sunmfee float64 = 0
  2741. var laboratory_clab_amt float64 = 0
  2742. var laboratory_other_amt float64 = 0
  2743. var treat_claa_sunmfee float64 = 0
  2744. var treat_clab_amt float64 = 0
  2745. var treat_other_amt float64 = 0
  2746. var register_claa_sunmfee float64 = 0
  2747. var register_clab_amt float64 = 0
  2748. var register_other_amt float64 = 0
  2749. for _, item := range order.HisOrderInfo {
  2750. if item.MedChrgitmType == "01" { //床位费
  2751. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2752. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2753. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2754. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2755. if item.ChrgitmLv == "1" {
  2756. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2757. }
  2758. if item.ChrgitmLv == "2" {
  2759. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2760. }
  2761. if item.ChrgitmLv == "3" {
  2762. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2763. }
  2764. }
  2765. if item.MedChrgitmType == "02" { //诊查
  2766. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2767. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2768. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2769. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2770. if item.ChrgitmLv == "1" {
  2771. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2772. }
  2773. if item.ChrgitmLv == "2" {
  2774. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2775. }
  2776. if item.ChrgitmLv == "3" {
  2777. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2778. }
  2779. }
  2780. if item.MedChrgitmType == "03" { //检查费
  2781. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2782. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2783. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2784. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2785. if item.ChrgitmLv == "1" {
  2786. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2787. }
  2788. if item.ChrgitmLv == "2" {
  2789. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2790. }
  2791. if item.ChrgitmLv == "3" {
  2792. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2793. }
  2794. }
  2795. if item.MedChrgitmType == "04" { //化验费
  2796. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2797. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2798. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2799. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2800. if item.ChrgitmLv == "1" {
  2801. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2802. }
  2803. if item.ChrgitmLv == "2" {
  2804. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2805. }
  2806. if item.ChrgitmLv == "3" {
  2807. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2808. }
  2809. }
  2810. if item.MedChrgitmType == "05" { //治疗费
  2811. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2812. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2813. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2814. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2815. if item.ChrgitmLv == "1" {
  2816. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2817. }
  2818. if item.ChrgitmLv == "2" {
  2819. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2820. }
  2821. if item.ChrgitmLv == "3" {
  2822. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2823. }
  2824. }
  2825. if item.MedChrgitmType == "06" { //手术费
  2826. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2827. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2828. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2829. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2830. if item.ChrgitmLv == "1" {
  2831. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2832. }
  2833. if item.ChrgitmLv == "2" {
  2834. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2835. }
  2836. if item.ChrgitmLv == "3" {
  2837. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2838. }
  2839. }
  2840. if item.MedChrgitmType == "07" { //手术费
  2841. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2842. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2843. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2844. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2845. if item.ChrgitmLv == "1" {
  2846. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2847. }
  2848. if item.ChrgitmLv == "2" {
  2849. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2850. }
  2851. if item.ChrgitmLv == "3" {
  2852. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2853. }
  2854. }
  2855. if item.MedChrgitmType == "08" { //材料费
  2856. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2857. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2858. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2859. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2860. if item.ChrgitmLv == "1" {
  2861. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2862. }
  2863. if item.ChrgitmLv == "2" {
  2864. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2865. }
  2866. if item.ChrgitmLv == "3" {
  2867. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2868. }
  2869. }
  2870. if item.MedChrgitmType == "09" { //西药费
  2871. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2872. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2873. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2874. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2875. if item.ChrgitmLv == "1" {
  2876. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2877. }
  2878. if item.ChrgitmLv == "2" {
  2879. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2880. }
  2881. if item.ChrgitmLv == "3" {
  2882. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2883. }
  2884. }
  2885. if item.MedChrgitmType == "10" { //中药饮片
  2886. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2887. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2888. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2889. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2890. if item.ChrgitmLv == "1" {
  2891. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2892. }
  2893. if item.ChrgitmLv == "2" {
  2894. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2895. }
  2896. if item.ChrgitmLv == "3" {
  2897. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2898. }
  2899. }
  2900. if item.MedChrgitmType == "11" { //中成费
  2901. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2902. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2903. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2904. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2905. if item.ChrgitmLv == "1" {
  2906. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2907. }
  2908. if item.ChrgitmLv == "2" {
  2909. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2910. }
  2911. if item.ChrgitmLv == "3" {
  2912. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2913. }
  2914. }
  2915. if item.MedChrgitmType == "12" { //中成费
  2916. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2917. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2918. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2919. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2920. if item.ChrgitmLv == "1" {
  2921. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2922. }
  2923. if item.ChrgitmLv == "2" {
  2924. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2925. }
  2926. if item.ChrgitmLv == "3" {
  2927. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2928. }
  2929. }
  2930. if item.MedChrgitmType == "13" { //中成费
  2931. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2932. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2933. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2934. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2935. if item.ChrgitmLv == "1" {
  2936. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2937. }
  2938. if item.ChrgitmLv == "2" {
  2939. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2940. }
  2941. if item.ChrgitmLv == "3" {
  2942. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2943. }
  2944. }
  2945. if item.MedChrgitmType == "14" { //其他费
  2946. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2947. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2948. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2949. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2950. if item.ChrgitmLv == "1" {
  2951. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2952. }
  2953. if item.ChrgitmLv == "2" {
  2954. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2955. }
  2956. if item.ChrgitmLv == "3" {
  2957. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2958. }
  2959. }
  2960. }
  2961. var iteminfoStructs []service.IteminfoStruct
  2962. if bedCostTotal != 0 {
  2963. iteminfo.MedChrgitm = "01"
  2964. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2965. iteminfo.Amt = bedCostTotal
  2966. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2967. iteminfo.ClabAmt = bed_clab_amt
  2968. iteminfo.OthAmt = bed_other_amt
  2969. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2970. }
  2971. if examineCostTotal != 0 {
  2972. iteminfo.MedChrgitm = "02"
  2973. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2974. iteminfo.Amt = examineCostTotal
  2975. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2976. iteminfo.ClabAmt = examine_clab_amt
  2977. iteminfo.OthAmt = examine_other_amt
  2978. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2979. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2980. }
  2981. if checkCostTotal != 0 {
  2982. iteminfo.MedChrgitm = "03"
  2983. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2984. iteminfo.Amt = checkCostTotal
  2985. iteminfo.ClaaSumfee = check_claa_sunmfee
  2986. iteminfo.ClabAmt = check_clab_amt
  2987. iteminfo.OthAmt = check_other_amt
  2988. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2989. }
  2990. if laboratoryCostTotal != 0 {
  2991. iteminfo.MedChrgitm = "04"
  2992. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2993. iteminfo.Amt = laboratoryCostTotal
  2994. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2995. iteminfo.ClabAmt = laboratory_clab_amt
  2996. iteminfo.OthAmt = laboratory_other_amt
  2997. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2998. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2999. }
  3000. if treatCostTotal != 0 {
  3001. iteminfo.MedChrgitm = "05"
  3002. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3003. iteminfo.Amt = treatCostTotal
  3004. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3005. iteminfo.ClabAmt = treat_clab_amt
  3006. iteminfo.OthAmt = treat_other_amt
  3007. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3008. //(struct4101.IteminfoStruct, iteminfo)
  3009. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3010. }
  3011. if operationCostTotal != 0 {
  3012. iteminfo.MedChrgitm = "06"
  3013. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3014. iteminfo.Amt = operationCostTotal
  3015. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3016. iteminfo.ClabAmt = operation_clab_amt
  3017. iteminfo.OthAmt = operation_other_amt
  3018. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3019. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3020. }
  3021. if nursingCostTotal != 0 {
  3022. iteminfo.MedChrgitm = "07"
  3023. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3024. iteminfo.Amt = nursingCostTotal
  3025. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3026. iteminfo.ClabAmt = nursing_clab_amt
  3027. iteminfo.OthAmt = nursing_other_amt
  3028. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3029. }
  3030. if materialCostTotal != 0 {
  3031. iteminfo.MedChrgitm = "08"
  3032. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3033. iteminfo.Amt = materialCostTotal
  3034. iteminfo.ClaaSumfee = material_claa_sunmfee
  3035. iteminfo.ClabAmt = material_clab_amt
  3036. iteminfo.OthAmt = material_other_amt
  3037. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3038. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3039. }
  3040. if westernMedicineCostTotal != 0 {
  3041. iteminfo.MedChrgitm = "09"
  3042. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3043. iteminfo.Amt = westernMedicineCostTotal
  3044. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3045. iteminfo.ClabAmt = westernMedicine_clab_amt
  3046. iteminfo.OthAmt = westernMedicine_other_amt
  3047. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3048. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3049. }
  3050. if chineseMedicineCostTotal != 0 {
  3051. iteminfo.MedChrgitm = "10"
  3052. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3053. iteminfo.Amt = chineseMedicineCostTotal
  3054. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3055. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3056. iteminfo.OthAmt = chinese_medicine_other_amt
  3057. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3058. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3059. }
  3060. if chineseTraditionalMedicineCostTotal != 0 {
  3061. iteminfo.MedChrgitm = "11"
  3062. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3063. iteminfo.Amt = westernMedicineCostTotal
  3064. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3065. iteminfo.ClabAmt = westernMedicine_clab_amt
  3066. iteminfo.OthAmt = westernMedicine_other_amt
  3067. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3068. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3069. }
  3070. if commonlyTreatmentCostTotal != 0 {
  3071. iteminfo.MedChrgitm = "12"
  3072. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3073. iteminfo.Amt = commonlyTreatmentCostTotal
  3074. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3075. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3076. iteminfo.OthAmt = commonly_treatment_other_amt
  3077. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3078. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3079. }
  3080. if registerCostTotal != 0 {
  3081. iteminfo.MedChrgitm = "13"
  3082. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3083. iteminfo.Amt = registerCostTotal
  3084. iteminfo.ClaaSumfee = register_claa_sunmfee
  3085. iteminfo.ClabAmt = register_clab_amt
  3086. iteminfo.OthAmt = register_other_amt
  3087. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3088. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3089. }
  3090. if otherCostTotal != 0 {
  3091. iteminfo.MedChrgitm = "14"
  3092. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3093. iteminfo.Amt = otherCostTotal
  3094. iteminfo.ClaaSumfee = other_claa_sunmfee
  3095. iteminfo.ClabAmt = other_clab_amt
  3096. iteminfo.OthAmt = other_other_amt
  3097. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3098. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3099. }
  3100. struct4101.IteminfoStruct = iteminfoStructs
  3101. struct4101.Ntly = "中国"
  3102. struct4101.AdmCaty = "A03.06"
  3103. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3104. fmt.Println(result)
  3105. var dat map[string]interface{}
  3106. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3107. fmt.Println(dat)
  3108. } else {
  3109. fmt.Println(err)
  3110. }
  3111. userJSONBytes, _ := json.Marshal(dat)
  3112. var res ResultSeventeen
  3113. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3114. utils.ErrorLog("解析失败:%v", err)
  3115. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3116. adminUser := c.GetAdminUserInfo()
  3117. errlog := &models.HisOrderError{
  3118. UserOrgId: adminUser.CurrentOrgId,
  3119. Ctime: time.Now().Unix(),
  3120. Mtime: time.Now().Unix(),
  3121. ErrMsg: res.ErrMsg + "解析失败",
  3122. Status: 1,
  3123. PatientId: order_id,
  3124. Stage: 10106,
  3125. }
  3126. service.CreateErrMsgLog(errlog)
  3127. continue
  3128. }
  3129. if res.Infcode != 0 {
  3130. adminUser := c.GetAdminUserInfo()
  3131. errlog := &models.HisOrderError{
  3132. UserOrgId: adminUser.CurrentOrgId,
  3133. Ctime: time.Now().Unix(),
  3134. Mtime: time.Now().Unix(),
  3135. ErrMsg: res.ErrMsg,
  3136. Status: 1,
  3137. PatientId: order_id,
  3138. Stage: 10106,
  3139. }
  3140. service.CreateErrMsgLog(errlog)
  3141. continue
  3142. } else {
  3143. hisFundSettleListResult := &models.HisFundSettleListResult{
  3144. Number: res.Output.SetlListId,
  3145. Status: 1,
  3146. Ctime: time.Now().Unix(),
  3147. Mtime: time.Now().Unix(),
  3148. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3149. IsUpload: 1,
  3150. OrderId: order_id,
  3151. }
  3152. service.CreateUploadRecord(hisFundSettleListResult)
  3153. continue
  3154. }
  3155. }
  3156. }
  3157. func (c *HisApiController) GetOrgInfo() {
  3158. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3159. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3160. }
  3161. func (c *HisApiController) GetHisPatientInfo() {
  3162. medical_insurance_card := c.GetString("medical_insurance_card")
  3163. id_card_type, _ := c.GetInt64("id_card_type")
  3164. id_card := c.GetString("id_card")
  3165. adminInfo := c.GetAdminUserInfo()
  3166. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3167. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3168. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3169. IdCardNo := ""
  3170. if id_card_type == 1 {
  3171. IdCardNo = medical_insurance_card
  3172. } else if id_card_type == 2 {
  3173. IdCardNo = id_card
  3174. }
  3175. if config.IsOpen == 1 {
  3176. 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
  3177. resp, requestErr := http.Get(api)
  3178. if requestErr != nil {
  3179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3180. return
  3181. }
  3182. defer resp.Body.Close()
  3183. body, ioErr := ioutil.ReadAll(resp.Body)
  3184. if ioErr != nil {
  3185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3187. return
  3188. }
  3189. var respJSON map[string]interface{}
  3190. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3193. return
  3194. }
  3195. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3196. userJSONBytes, _ := json.Marshal(userJSON)
  3197. var res ResultTwo
  3198. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3199. utils.ErrorLog("解析失败:%v", err)
  3200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3201. return
  3202. }
  3203. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3204. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3205. infoStr := string(Iinfos)
  3206. idetinfoStr := string(Idetinfos)
  3207. if res.Infcode == 0 {
  3208. his := models.VMHisPatient{
  3209. Status: 1,
  3210. Ctime: time.Now().Unix(),
  3211. Mtime: time.Now().Unix(),
  3212. PsnNo: res.Output.Baseinfo.PsnNo,
  3213. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3214. Certno: res.Output.Baseinfo.Certno,
  3215. PsnName: res.Output.Baseinfo.PsnName,
  3216. Gend: res.Output.Baseinfo.Gend,
  3217. Naty: res.Output.Baseinfo.Naty,
  3218. Brdy: res.Output.Baseinfo.Brdy,
  3219. Age: res.Output.Baseinfo.Age,
  3220. Iinfo: infoStr,
  3221. Idetinfo: idetinfoStr,
  3222. UserOrgId: adminInfo.CurrentOrgId,
  3223. IsReturn: 1,
  3224. IdCardType: id_card_type,
  3225. }
  3226. c.ServeSuccessJSON(map[string]interface{}{
  3227. "info": his,
  3228. })
  3229. } else {
  3230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3231. return
  3232. }
  3233. }
  3234. }
  3235. //func GetBasBaseInfo() (jsonStr string, err error) {
  3236. //
  3237. // handle := syscall.NewLazyDLL("SSCard.dll")
  3238. // add := handle.NewProc("ReadCardBas")
  3239. // str := make([]byte, 1024)
  3240. // str1 := make([]byte, 1024)
  3241. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3242. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3243. //
  3244. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3245. //
  3246. // fmt.Println("> Add(4,5)的结果为:", ret)
  3247. // handle.Release()
  3248. //
  3249. // return "", nil
  3250. //
  3251. //}
  3252. //func GetQRBaseInfo() (jsonStr string, err error) {
  3253. // handle := syscall.LoadDLL("SSCard.dll")
  3254. // ReadCardBas := handle.FindProc("GetQRBase")
  3255. //
  3256. // str := make([]byte, 256)
  3257. // str1 := make([]byte, 256)
  3258. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3259. //
  3260. // fmt.Println(string(str))
  3261. // fmt.Println(r)
  3262. // return string(str), nil
  3263. //}
  3264. //func CardInit() int {
  3265. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3266. // add := DllTestDef.MustFindProc("Init")
  3267. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3268. // if err != nil {
  3269. // fmt.Println("SSCard的运算结果为:", ret)
  3270. // }
  3271. // result := int(ret)
  3272. // return result
  3273. //}
  3274. //func CardInit() int {
  3275. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3276. // if err != nil {
  3277. // fmt.Println("SSCard的运算结果为:", ret)
  3278. // }
  3279. // fmt.Println(err)
  3280. // result := int(ret)
  3281. // return result
  3282. //}
  3283. func IntPtr(n int) uintptr {
  3284. return uintptr(n)
  3285. }
  3286. func StrPtr(s string) uintptr {
  3287. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3288. }
  3289. type Result2001 struct {
  3290. Cainfo interface{} `json:"cainfo"`
  3291. ErrMsg string `json:"err_msg"`
  3292. InfRefmsgid string `json:"inf_refmsgid"`
  3293. Infcode int64 `json:"infcode"`
  3294. Output struct {
  3295. Trtinfo struct {
  3296. PsnNo string `json:"psn_no"`
  3297. TrtChkType string `json:"trt_chk_type"`
  3298. FundPayType string `json:"fund_pay_type"`
  3299. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3300. Begndate string `json:"begndate"`
  3301. Enddate string `json:"enddate"`
  3302. TrtChkRslt string `json:"trt_chk_rslt"`
  3303. } `json:"trtinfo"`
  3304. } `json:"output"`
  3305. RefmsgTime string `json:"refmsg_time"`
  3306. RespondTime string `json:"respond_time"`
  3307. Signtype interface{} `json:"signtype"`
  3308. WarnMsg interface{} `json:"warn_msg"`
  3309. }
  3310. type Result2001Org10265 struct {
  3311. Cainfo interface{} `json:"cainfo"`
  3312. ErrMsg string `json:"err_msg"`
  3313. InfRefmsgid string `json:"inf_refmsgid"`
  3314. Infcode string `json:"infcode"`
  3315. Output struct {
  3316. Trtinfo struct {
  3317. PsnNo string `json:"psn_no"`
  3318. TrtChkType string `json:"trt_chk_type"`
  3319. FundPayType string `json:"fund_pay_type"`
  3320. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3321. Begndate string `json:"begndate"`
  3322. Enddate string `json:"enddate"`
  3323. TrtChkRslt string `json:"trt_chk_rslt"`
  3324. } `json:"trtinfo"`
  3325. } `json:"output"`
  3326. RefmsgTime string `json:"refmsg_time"`
  3327. RespondTime string `json:"respond_time"`
  3328. Signtype interface{} `json:"signtype"`
  3329. WarnMsg interface{} `json:"warn_msg"`
  3330. }
  3331. type ResultTwo struct {
  3332. ErrMsg string `json:"err_msg"`
  3333. InfRefmsgid string `json:"inf_refmsgid"`
  3334. Infcode int64 `json:"infcode"`
  3335. Output struct {
  3336. Baseinfo struct {
  3337. Age float64 `json:"age"`
  3338. Brdy string `json:"brdy"`
  3339. Certno string `json:"certno"`
  3340. Gend string `json:"gend"`
  3341. Naty string `json:"naty"`
  3342. PsnCertType string `json:"psn_cert_type"`
  3343. PsnName string `json:"psn_name"`
  3344. PsnNo string `json:"psn_no"`
  3345. } `json:"baseinfo"`
  3346. Idetinfo []interface{} `json:"idetinfo"`
  3347. Iinfo []struct {
  3348. Balc float64 `json:"balc"`
  3349. CvlservFlag string `json:"cvlserv_flag"`
  3350. EmpName string `json:"emp_name"`
  3351. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3352. Insutype string `json:"insutype"`
  3353. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3354. PausInsuDate string `json:"paus_insu_date"`
  3355. PsnInsuDate string `json:"psn_insu_date"`
  3356. PsnInsuStas string `json:"psn_insu_stas"`
  3357. PsnType string `json:"psn_type"`
  3358. } `json:"insuinfo"`
  3359. } `json:"output"`
  3360. RefmsgTime string `json:"refmsg_time"`
  3361. RespondTime string `json:"respond_time"`
  3362. Signtype interface{} `json:"signtype"`
  3363. WarnInfo interface{} `json:"warn_info"`
  3364. }
  3365. type ResultTwo10265 struct {
  3366. ErrMsg string `json:"err_msg"`
  3367. InfRefmsgid string `json:"inf_refmsgid"`
  3368. Infcode string `json:"infcode"`
  3369. Output struct {
  3370. Baseinfo struct {
  3371. Age float64 `json:"age"`
  3372. Brdy string `json:"brdy"`
  3373. Certno string `json:"certno"`
  3374. Gend string `json:"gend"`
  3375. Naty string `json:"naty"`
  3376. PsnCertType string `json:"psn_cert_type"`
  3377. PsnName string `json:"psn_name"`
  3378. PsnNo string `json:"psn_no"`
  3379. } `json:"baseinfo"`
  3380. Idetinfo []interface{} `json:"idetinfo"`
  3381. Iinfo []struct {
  3382. Balc float64 `json:"balc"`
  3383. CvlservFlag string `json:"cvlserv_flag"`
  3384. EmpName string `json:"emp_name"`
  3385. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3386. Insutype string `json:"insutype"`
  3387. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3388. PausInsuDate string `json:"paus_insu_date"`
  3389. PsnInsuDate string `json:"psn_insu_date"`
  3390. PsnInsuStas string `json:"psn_insu_stas"`
  3391. PsnType string `json:"psn_type"`
  3392. } `json:"insuinfo"`
  3393. } `json:"output"`
  3394. RefmsgTime string `json:"refmsg_time"`
  3395. RespondTime string `json:"respond_time"`
  3396. Signtype interface{} `json:"signtype"`
  3397. WarnInfo interface{} `json:"warn_info"`
  3398. }
  3399. type ResultThree struct {
  3400. Cainfo interface{} `json:"cainfo"`
  3401. ErrMsg string `json:"err_msg"`
  3402. InfRefmsgid string `json:"inf_refmsgid"`
  3403. Infcode int64 `json:"infcode"`
  3404. Output struct {
  3405. Data struct {
  3406. IptOtpNo string `json:"ipt_otp_no"`
  3407. MdtrtID string `json:"mdtrt_id"`
  3408. PsnNo string `json:"psn_no"`
  3409. } `json:"data"`
  3410. } `json:"output"`
  3411. RefmsgTime string `json:"refmsg_time"`
  3412. RespondTime string `json:"respond_time"`
  3413. Signtype interface{} `json:"signtype"`
  3414. WarnMsg interface{} `json:"warn_msg"`
  3415. }
  3416. type ResultThree10265 struct {
  3417. Cainfo interface{} `json:"cainfo"`
  3418. ErrMsg string `json:"err_msg"`
  3419. InfRefmsgid string `json:"inf_refmsgid"`
  3420. Infcode string `json:"infcode"`
  3421. Output struct {
  3422. Data struct {
  3423. IptOtpNo string `json:"ipt_otp_no"`
  3424. MdtrtID string `json:"mdtrt_id"`
  3425. PsnNo string `json:"psn_no"`
  3426. } `json:"data"`
  3427. } `json:"output"`
  3428. RefmsgTime string `json:"refmsg_time"`
  3429. RespondTime string `json:"respond_time"`
  3430. Signtype interface{} `json:"signtype"`
  3431. WarnMsg interface{} `json:"warn_msg"`
  3432. }
  3433. type ResultFour struct {
  3434. Cainfo string `json:"cainfo"`
  3435. ErrMsg string `json:"err_msg"`
  3436. InfRefmsgid string `json:"inf_refmsgid"`
  3437. Infcode int64 `json:"infcode"`
  3438. Output struct {
  3439. Result []struct {
  3440. BasMednFlag string `json:"bas_medn_flag"`
  3441. ChldMedcFlag string `json:"chld_medc_flag"`
  3442. ChrgitmLv string `json:"chrgitm_lv"`
  3443. Cnt float64 `json:"cnt"`
  3444. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3445. DrtReimFlag string `json:"drt_reim_flag"`
  3446. FeedetlSn string `json:"feedetl_sn"`
  3447. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3448. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3449. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3450. ListSpItemFlag string `json:"list_sp_item_flag"`
  3451. LmtUsedFlag string `json:"lmt_used_flag"`
  3452. MedChrgitmType string `json:"med_chrgitm_type"`
  3453. Memo string `json:"memo"`
  3454. OverlmtAmt float64 `json:"overlmt_amt"`
  3455. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3456. Pric float64 `json:"pric"`
  3457. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3458. SelfpayProp float64 `json:"selfpay_prop"`
  3459. } `json:"result"`
  3460. } `json:"output"`
  3461. RefmsgTime string `json:"refmsg_time"`
  3462. RespondTime string `json:"respond_time"`
  3463. Signtype string `json:"signtype"`
  3464. WarnMsg string `json:"warn_msg"`
  3465. }
  3466. type ResultFour10265 struct {
  3467. Cainfo string `json:"cainfo"`
  3468. ErrMsg string `json:"err_msg"`
  3469. InfRefmsgid string `json:"inf_refmsgid"`
  3470. Infcode string `json:"infcode"`
  3471. Output struct {
  3472. Result []struct {
  3473. BasMednFlag string `json:"bas_medn_flag"`
  3474. ChldMedcFlag string `json:"chld_medc_flag"`
  3475. ChrgitmLv string `json:"chrgitm_lv"`
  3476. Cnt float64 `json:"cnt"`
  3477. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3478. DrtReimFlag string `json:"drt_reim_flag"`
  3479. FeedetlSn string `json:"feedetl_sn"`
  3480. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3481. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3482. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3483. ListSpItemFlag string `json:"list_sp_item_flag"`
  3484. LmtUsedFlag string `json:"lmt_used_flag"`
  3485. MedChrgitmType string `json:"med_chrgitm_type"`
  3486. Memo string `json:"memo"`
  3487. OverlmtAmt float64 `json:"overlmt_amt"`
  3488. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3489. Pric float64 `json:"pric"`
  3490. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3491. SelfpayProp float64 `json:"selfpay_prop"`
  3492. } `json:"result"`
  3493. } `json:"output"`
  3494. RefmsgTime string `json:"refmsg_time"`
  3495. RespondTime string `json:"respond_time"`
  3496. Signtype string `json:"signtype"`
  3497. WarnMsg string `json:"warn_msg"`
  3498. }
  3499. type ResultFive struct {
  3500. Balc float64 `json:"balc"`
  3501. CvlservFlag string `json:"cvlserv_flag"`
  3502. EmpName string `json:"emp_name"`
  3503. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3504. Insutype string `json:"insutype"`
  3505. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3506. PausInsuDate string `json:"paus_insu_date"`
  3507. PsnInsuDate string `json:"psn_insu_date"`
  3508. PsnInsuStas string `json:"psn_insu_stas"`
  3509. PsnType string `json:"psn_type"`
  3510. }
  3511. type ResultSix struct {
  3512. Cainfo interface{} `json:"cainfo"`
  3513. ErrMsg string `json:"err_msg"`
  3514. InfRefmsgid string `json:"inf_refmsgid"`
  3515. Infcode int64 `json:"infcode"`
  3516. Output struct {
  3517. } `json:"output"`
  3518. RefmsgTime string `json:"refmsg_time"`
  3519. RespondTime string `json:"respond_time"`
  3520. Signtype interface{} `json:"signtype"`
  3521. WarnMsg interface{} `json:"warn_msg"`
  3522. }
  3523. type ResultSix10265 struct {
  3524. Cainfo interface{} `json:"cainfo"`
  3525. ErrMsg string `json:"err_msg"`
  3526. InfRefmsgid string `json:"inf_refmsgid"`
  3527. Infcode string `json:"infcode"`
  3528. Output struct {
  3529. } `json:"output"`
  3530. RefmsgTime string `json:"refmsg_time"`
  3531. RespondTime string `json:"respond_time"`
  3532. Signtype interface{} `json:"signtype"`
  3533. WarnMsg interface{} `json:"warn_msg"`
  3534. }
  3535. type ResultSeven struct {
  3536. Cainfo string `json:"cainfo"`
  3537. ErrMsg string `json:"err_msg"`
  3538. InfRefmsgid string `json:"inf_refmsgid"`
  3539. Infcode int64 `json:"infcode"`
  3540. Output struct {
  3541. Setldetail []interface{} `json:"setldetail"`
  3542. Setlinfo struct {
  3543. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3544. AcctPay float64 `json:"acct_pay"`
  3545. ActPayDedc float64 `json:"act_pay_dedc"`
  3546. Age float64 `json:"age"`
  3547. Balc float64 `json:"balc"`
  3548. Brdy string `json:"brdy"`
  3549. Certno string `json:"certno"`
  3550. ClrOptins string `json:"clr_optins"`
  3551. ClrType string `json:"clr_type"`
  3552. ClrWay string `json:"clr_way"`
  3553. CvlservFlag string `json:"cvlserv_flag"`
  3554. CvlservPay float64 `json:"cvlserv_pay"`
  3555. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3556. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3557. Gend string `json:"gend"`
  3558. HifesPay float64 `json:"hifes_pay"`
  3559. HifmiPay float64 `json:"hifmi_pay"`
  3560. HifpPay float64 `json:"hifp_pay"`
  3561. HospPartAmt float64 `json:"hosp_part_amt"`
  3562. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3563. Insutype string `json:"insutype"`
  3564. MafPay float64 `json:"maf_pay"`
  3565. MdtrtCertType string `json:"mdtrt_cert_type"`
  3566. HifobPay float64 `json:"hifob_pay"`
  3567. MdtrtID string `json:"mdtrt_id"`
  3568. MedType string `json:"med_type"`
  3569. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3570. MedinsSetlID string `json:"medins_setl_id"`
  3571. Naty string `json:"naty"`
  3572. OthPay float64 `json:"oth_pay"`
  3573. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3574. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3575. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3576. PsnCashPay float64 `json:"psn_cash_pay"`
  3577. PsnCertType string `json:"psn_cert_type"`
  3578. PsnName string `json:"psn_name"`
  3579. PsnNo string `json:"psn_no"`
  3580. PsnPartAmt float64 `json:"psn_part_amt"`
  3581. PsnType string `json:"psn_type"`
  3582. SetlID string `json:"setl_id"`
  3583. SetlTime string `json:"setl_time"`
  3584. } `json:"setlinfo"`
  3585. } `json:"output"`
  3586. RefmsgTime string `json:"refmsg_time"`
  3587. RespondTime string `json:"respond_time"`
  3588. Signtype interface{} `json:"signtype"`
  3589. WarnMsg interface{} `json:"warn_msg"`
  3590. }
  3591. type ResultSeven10265 struct {
  3592. Cainfo string `json:"cainfo"`
  3593. ErrMsg string `json:"err_msg"`
  3594. InfRefmsgid string `json:"inf_refmsgid"`
  3595. Infcode string `json:"infcode"`
  3596. Output struct {
  3597. Setldetail []interface{} `json:"setldetail"`
  3598. Setlinfo struct {
  3599. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3600. AcctPay float64 `json:"acct_pay"`
  3601. ActPayDedc float64 `json:"act_pay_dedc"`
  3602. Age float64 `json:"age"`
  3603. Balc float64 `json:"balc"`
  3604. Brdy string `json:"brdy"`
  3605. Certno string `json:"certno"`
  3606. ClrOptins string `json:"clr_optins"`
  3607. ClrType string `json:"clr_type"`
  3608. ClrWay string `json:"clr_way"`
  3609. CvlservFlag string `json:"cvlserv_flag"`
  3610. CvlservPay float64 `json:"cvlserv_pay"`
  3611. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3612. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3613. Gend string `json:"gend"`
  3614. HifesPay float64 `json:"hifes_pay"`
  3615. HifmiPay float64 `json:"hifmi_pay"`
  3616. HifpPay float64 `json:"hifp_pay"`
  3617. HospPartAmt float64 `json:"hosp_part_amt"`
  3618. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3619. Insutype string `json:"insutype"`
  3620. MafPay float64 `json:"maf_pay"`
  3621. MdtrtCertType string `json:"mdtrt_cert_type"`
  3622. HifobPay float64 `json:"hifob_pay"`
  3623. MdtrtID string `json:"mdtrt_id"`
  3624. MedType string `json:"med_type"`
  3625. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3626. MedinsSetlID string `json:"medins_setl_id"`
  3627. Naty string `json:"naty"`
  3628. OthPay float64 `json:"oth_pay"`
  3629. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3630. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3631. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3632. PsnCashPay float64 `json:"psn_cash_pay"`
  3633. PsnCertType string `json:"psn_cert_type"`
  3634. PsnName string `json:"psn_name"`
  3635. PsnNo string `json:"psn_no"`
  3636. PsnPartAmt float64 `json:"psn_part_amt"`
  3637. PsnType string `json:"psn_type"`
  3638. SetlID string `json:"setl_id"`
  3639. SetlTime string `json:"setl_time"`
  3640. } `json:"setlinfo"`
  3641. } `json:"output"`
  3642. RefmsgTime string `json:"refmsg_time"`
  3643. RespondTime string `json:"respond_time"`
  3644. Signtype interface{} `json:"signtype"`
  3645. WarnMsg interface{} `json:"warn_msg"`
  3646. }
  3647. type ResultEight struct {
  3648. Cainfo string `json:"cainfo"`
  3649. ErrMsg string `json:"err_msg"`
  3650. InfRefmsgid string `json:"inf_refmsgid"`
  3651. Infcode int64 `json:"infcode"`
  3652. Output struct {
  3653. Stmtinfo struct {
  3654. SetlOptins string `json:"setl_optins"`
  3655. StmtRslt string `json:"stmt_rslt"`
  3656. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3657. } `json:"stmtinfo"`
  3658. } `json:"output"`
  3659. RefmsgTime string `json:"refmsg_time"`
  3660. RespondTime string `json:"respond_time"`
  3661. Signtype interface{} `json:"signtype"`
  3662. WarnMsg interface{} `json:"warn_msg"`
  3663. }
  3664. type ResultEightFor10188 struct {
  3665. Cainfo string `json:"cainfo"`
  3666. ErrMsg string `json:"err_msg"`
  3667. InfRefmsgid string `json:"inf_refmsgid"`
  3668. Infcode string `json:"infcode"`
  3669. Output struct {
  3670. Stmtinfo struct {
  3671. SetlOptins string `json:"setl_optins"`
  3672. StmtRslt string `json:"stmt_rslt"`
  3673. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3674. } `json:"stmtinfo"`
  3675. } `json:"output"`
  3676. RefmsgTime string `json:"refmsg_time"`
  3677. RespondTime string `json:"respond_time"`
  3678. Signtype interface{} `json:"signtype"`
  3679. WarnMsg interface{} `json:"warn_msg"`
  3680. }
  3681. type ResultNine struct {
  3682. Cainfo string `json:"cainfo"`
  3683. ErrMsg string `json:"err_msg"`
  3684. InfRefmsgid string `json:"inf_refmsgid"`
  3685. Infcode int64 `json:"infcode"`
  3686. Output struct {
  3687. FileQuryNo string `json:"file_qury_no"`
  3688. } `json:"output"`
  3689. RefmsgTime string `json:"refmsg_time"`
  3690. RespondTime string `json:"respond_time"`
  3691. Signtype interface{} `json:"signtype"`
  3692. WarnMsg interface{} `json:"warn_msg"`
  3693. }
  3694. type ResultTen struct {
  3695. Cainfo string `json:"cainfo"`
  3696. ErrMsg string `json:"err_msg"`
  3697. InfRefmsgid string `json:"inf_refmsgid"`
  3698. Infcode int64 `json:"infcode"`
  3699. Output struct {
  3700. DldEndtime string `json:"dld_endtime"`
  3701. FileQuryNo string `json:"file_qury_no"`
  3702. Filename string `json:"filename"`
  3703. } `json:"output"`
  3704. RefmsgTime string `json:"refmsg_time"`
  3705. RespondTime string `json:"respond_time"`
  3706. Signtype interface{} `json:"signtype"`
  3707. WarnMsg interface{} `json:"warn_msg"`
  3708. }
  3709. //type Autogenerated struct {
  3710. // Output struct {
  3711. // Setlinfo struct {
  3712. // SetlTime string `json:"setl_time"`
  3713. // CvlservPay float64 `json:"cvlserv_pay"`
  3714. // Year string `json:"year"`
  3715. // MedType string `json:"med_type"`
  3716. // PsnPay float64 `json:"psn_pay"`
  3717. // OpterID string `json:"opter_id"`
  3718. // Begndate string `json:"begndate"`
  3719. // FlxempeFlag string `json:"flxempe_flag"`
  3720. // HifmiPay float64 `json:"hifmi_pay"`
  3721. // PsnNo string `json:"psn_no"`
  3722. // ActPayDedc float64 `json:"act_pay_dedc"`
  3723. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3724. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3725. // ClrWay string `json:"clr_way"`
  3726. // OthPay float64 `json:"oth_pay"`
  3727. // Gend string `json:"gend"`
  3728. // MdtrtID string `json:"mdtrt_id"`
  3729. // AcctPay float64 `json:"acct_pay"`
  3730. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3731. // Insutype string `json:"insutype"`
  3732. // Invono interface{} `json:"invono"`
  3733. // Enddate string `json:"enddate"`
  3734. // CashPayamt float64 `json:"cash_payamt"`
  3735. // PsnType string `json:"psn_type"`
  3736. // FixmedinsName string `json:"fixmedins_name"`
  3737. // HifpPay float64 `json:"hifp_pay"`
  3738. // NewFlag interface{} `json:"new_flag"`
  3739. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3740. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3741. // PayLoc string `json:"pay_loc"`
  3742. // ClrType string `json:"clr_type"`
  3743. // RefdSetlFlag string `json:"refd_setl_flag"`
  3744. // CvlservFlag string `json:"cvlserv_flag"`
  3745. // EmpName string `json:"emp_name"`
  3746. // Brdy string `json:"brdy"`
  3747. // Naty string `json:"naty"`
  3748. // Certno string `json:"certno"`
  3749. // DiseCode string `json:"dise_code"`
  3750. // FixmedinsCode string `json:"fixmedins_code"`
  3751. // DedcHospLv string `json:"dedc_hosp_lv"`
  3752. // OpterName string `json:"opter_name"`
  3753. // Balc float64 `json:"balc"`
  3754. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3755. // PsnCertType string `json:"psn_cert_type"`
  3756. // HifobPay float64 `json:"hifob_pay"`
  3757. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3758. // HifesPay float64 `json:"hifes_pay"`
  3759. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3760. // OptTime string `json:"opt_time"`
  3761. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3762. // SetlID string `json:"setl_id"`
  3763. // MafPay float64 `json:"maf_pay"`
  3764. // PsnName string `json:"psn_name"`
  3765. // InsuOptins interface{} `json:"insu_optins"`
  3766. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3767. // ClrOptins string `json:"clr_optins"`
  3768. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3769. // DiseName string `json:"dise_name"`
  3770. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3771. // Age float64 `json:"age"`
  3772. // DtrtCertType string `json:"dtrt_cert_type"`
  3773. // HospLv string `json:"hosp_lv"`
  3774. // } `json:"setlinfo"`
  3775. // Setldetail []struct {
  3776. // FundPayType string `json:"fund_pay_type"`
  3777. // FundPayamt float64 `json:"fund_payamt"`
  3778. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3779. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3780. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3781. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3782. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3783. // } `json:"setldetail"`
  3784. // } `json:"output"`
  3785. // Infcode int `json:"infcode"`
  3786. // WarnMsg interface{} `json:"warn_msg"`
  3787. // Cainfo interface{} `json:"cainfo"`
  3788. // ErrMsg interface{} `json:"err_msg"`
  3789. // RefmsgTime string `json:"refmsg_time"`
  3790. // Signtype interface{} `json:"signtype"`
  3791. // RespondTime string `json:"respond_time"`
  3792. // InfRefmsgid string `json:"inf_refmsgid"`
  3793. //}
  3794. type ResultEleven struct {
  3795. Cainfo string `json:"cainfo"`
  3796. ErrMsg string `json:"err_msg"`
  3797. InfRefmsgid string `json:"inf_refmsgid"`
  3798. Infcode int64 `json:"infcode"`
  3799. Output struct {
  3800. Setlinfo struct {
  3801. SetlTime string `json:"setl_time"`
  3802. CvlservPay float64 `json:"cvlserv_pay"`
  3803. Year string `json:"year"`
  3804. MedType string `json:"med_type"`
  3805. PsnPay float64 `json:"psn_pay"`
  3806. OpterID string `json:"opter_id"`
  3807. Begndate string `json:"begndate"`
  3808. FlxempeFlag string `json:"flxempe_flag"`
  3809. HifmiPay float64 `json:"hifmi_pay"`
  3810. PsnNo string `json:"psn_no"`
  3811. ActPayDedc float64 `json:"act_pay_dedc"`
  3812. MedinsSetlID interface{} `json:"medins_setl_id"`
  3813. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3814. ClrWay string `json:"clr_way"`
  3815. OthPay float64 `json:"oth_pay"`
  3816. Gend string `json:"gend"`
  3817. MdtrtID string `json:"mdtrt_id"`
  3818. AcctPay float64 `json:"acct_pay"`
  3819. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3820. Insutype string `json:"insutype"`
  3821. Invono interface{} `json:"invono"`
  3822. Enddate string `json:"enddate"`
  3823. CashPayamt float64 `json:"cash_payamt"`
  3824. PsnType string `json:"psn_type"`
  3825. FixmedinsName string `json:"fixmedins_name"`
  3826. HifpPay float64 `json:"hifp_pay"`
  3827. NewFlag interface{} `json:"new_flag"`
  3828. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3829. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3830. PayLoc string `json:"pay_loc"`
  3831. ClrType string `json:"clr_type"`
  3832. RefdSetlFlag string `json:"refd_setl_flag"`
  3833. CvlservFlag string `json:"cvlserv_flag"`
  3834. EmpName string `json:"emp_name"`
  3835. Brdy string `json:"brdy"`
  3836. Naty string `json:"naty"`
  3837. Certno string `json:"certno"`
  3838. DiseCode string `json:"dise_code"`
  3839. FixmedinsCode string `json:"fixmedins_code"`
  3840. DedcHospLv string `json:"dedc_hosp_lv"`
  3841. OpterName string `json:"opter_name"`
  3842. Balc float64 `json:"balc"`
  3843. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3844. PsnCertType string `json:"psn_cert_type"`
  3845. HifobPay float64 `json:"hifob_pay"`
  3846. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3847. HifesPay float64 `json:"hifes_pay"`
  3848. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3849. OptTime string `json:"opt_time"`
  3850. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3851. SetlID string `json:"setl_id"`
  3852. MafPay float64 `json:"maf_pay"`
  3853. PsnName string `json:"psn_name"`
  3854. InsuOptins interface{} `json:"insu_optins"`
  3855. PrefFundPay interface{} `json:"pref_fund_pay"`
  3856. ClrOptins string `json:"clr_optins"`
  3857. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3858. DiseName string `json:"dise_name"`
  3859. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3860. Age float64 `json:"age"`
  3861. DtrtCertType string `json:"dtrt_cert_type"`
  3862. HospLv string `json:"hosp_lv"`
  3863. } `json:"setlinfo"`
  3864. } `json:"output"`
  3865. RefmsgTime string `json:"refmsg_time"`
  3866. RespondTime string `json:"respond_time"`
  3867. Signtype interface{} `json:"signtype"`
  3868. WarnMsg interface{} `json:"warn_msg"`
  3869. }
  3870. type ResultEleven10265 struct {
  3871. Cainfo string `json:"cainfo"`
  3872. ErrMsg string `json:"err_msg"`
  3873. InfRefmsgid string `json:"inf_refmsgid"`
  3874. Infcode string `json:"infcode"`
  3875. Output struct {
  3876. Setlinfo struct {
  3877. SetlTime string `json:"setl_time"`
  3878. CvlservPay float64 `json:"cvlserv_pay"`
  3879. Year string `json:"year"`
  3880. MedType string `json:"med_type"`
  3881. PsnPay float64 `json:"psn_pay"`
  3882. OpterID string `json:"opter_id"`
  3883. Begndate string `json:"begndate"`
  3884. FlxempeFlag string `json:"flxempe_flag"`
  3885. HifmiPay float64 `json:"hifmi_pay"`
  3886. PsnNo string `json:"psn_no"`
  3887. ActPayDedc float64 `json:"act_pay_dedc"`
  3888. MedinsSetlID interface{} `json:"medins_setl_id"`
  3889. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3890. ClrWay string `json:"clr_way"`
  3891. OthPay float64 `json:"oth_pay"`
  3892. Gend string `json:"gend"`
  3893. MdtrtID string `json:"mdtrt_id"`
  3894. AcctPay float64 `json:"acct_pay"`
  3895. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3896. Insutype string `json:"insutype"`
  3897. Invono interface{} `json:"invono"`
  3898. Enddate string `json:"enddate"`
  3899. CashPayamt float64 `json:"cash_payamt"`
  3900. PsnType string `json:"psn_type"`
  3901. FixmedinsName string `json:"fixmedins_name"`
  3902. HifpPay float64 `json:"hifp_pay"`
  3903. NewFlag interface{} `json:"new_flag"`
  3904. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3905. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3906. PayLoc string `json:"pay_loc"`
  3907. ClrType string `json:"clr_type"`
  3908. RefdSetlFlag string `json:"refd_setl_flag"`
  3909. CvlservFlag string `json:"cvlserv_flag"`
  3910. EmpName string `json:"emp_name"`
  3911. Brdy string `json:"brdy"`
  3912. Naty string `json:"naty"`
  3913. Certno string `json:"certno"`
  3914. DiseCode string `json:"dise_code"`
  3915. FixmedinsCode string `json:"fixmedins_code"`
  3916. DedcHospLv string `json:"dedc_hosp_lv"`
  3917. OpterName string `json:"opter_name"`
  3918. Balc float64 `json:"balc"`
  3919. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3920. PsnCertType string `json:"psn_cert_type"`
  3921. HifobPay float64 `json:"hifob_pay"`
  3922. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3923. HifesPay float64 `json:"hifes_pay"`
  3924. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3925. OptTime string `json:"opt_time"`
  3926. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3927. SetlID string `json:"setl_id"`
  3928. MafPay float64 `json:"maf_pay"`
  3929. PsnName string `json:"psn_name"`
  3930. InsuOptins interface{} `json:"insu_optins"`
  3931. PrefFundPay interface{} `json:"pref_fund_pay"`
  3932. ClrOptins string `json:"clr_optins"`
  3933. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3934. DiseName string `json:"dise_name"`
  3935. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3936. Age float64 `json:"age"`
  3937. DtrtCertType string `json:"dtrt_cert_type"`
  3938. HospLv string `json:"hosp_lv"`
  3939. } `json:"setlinfo"`
  3940. } `json:"output"`
  3941. RefmsgTime string `json:"refmsg_time"`
  3942. RespondTime string `json:"respond_time"`
  3943. Signtype interface{} `json:"signtype"`
  3944. WarnMsg interface{} `json:"warn_msg"`
  3945. }
  3946. type ResultTwelve struct {
  3947. Cainfo string `json:"cainfo"`
  3948. ErrMsg string `json:"err_msg"`
  3949. InfRefmsgid string `json:"inf_refmsgid"`
  3950. Infcode int64 `json:"infcode"`
  3951. Output struct {
  3952. MdtrtId string `json:"mdtrt_id"`
  3953. ChrgBchno string `json:"chrg_bchno"`
  3954. PsnNo string `json:"psn_no"`
  3955. } `json:"output"`
  3956. RefmsgTime string `json:"refmsg_time"`
  3957. RespondTime string `json:"respond_time"`
  3958. Signtype interface{} `json:"signtype"`
  3959. WarnMsg interface{} `json:"warn_msg"`
  3960. }
  3961. type ResultThirteen struct {
  3962. ErrMsg string `json:"err_msg"`
  3963. InfRefmsgid string `json:"inf_refmsgid"`
  3964. Infcode int64 `json:"infcode"`
  3965. Output struct {
  3966. Result struct {
  3967. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3968. } `json:"result"`
  3969. } `json:"output"`
  3970. RefmsgTime string `json:"refmsg_time"`
  3971. RespondTime string `json:"respond_time"`
  3972. Signtype interface{} `json:"signtype"`
  3973. WarnInfo interface{} `json:"warn_info"`
  3974. }
  3975. type ResultThirteen10265 struct {
  3976. ErrMsg string `json:"err_msg"`
  3977. InfRefmsgid string `json:"inf_refmsgid"`
  3978. Infcode string `json:"infcode"`
  3979. Output struct {
  3980. Result struct {
  3981. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3982. } `json:"result"`
  3983. } `json:"output"`
  3984. RefmsgTime string `json:"refmsg_time"`
  3985. RespondTime string `json:"respond_time"`
  3986. Signtype interface{} `json:"signtype"`
  3987. WarnInfo interface{} `json:"warn_info"`
  3988. }
  3989. type ResultFourteen struct {
  3990. ErrMsg string `json:"err_msg"`
  3991. InfRefmsgid string `json:"inf_refmsgid"`
  3992. Infcode int64 `json:"infcode"`
  3993. Output struct {
  3994. } `json:"output"`
  3995. RefmsgTime string `json:"refmsg_time"`
  3996. RespondTime string `json:"respond_time"`
  3997. Signtype interface{} `json:"signtype"`
  3998. WarnInfo interface{} `json:"warn_info"`
  3999. }
  4000. type ResultFourteen10265 struct {
  4001. ErrMsg string `json:"err_msg"`
  4002. InfRefmsgid string `json:"inf_refmsgid"`
  4003. Infcode string `json:"infcode"`
  4004. Output struct {
  4005. } `json:"output"`
  4006. RefmsgTime string `json:"refmsg_time"`
  4007. RespondTime string `json:"respond_time"`
  4008. Signtype interface{} `json:"signtype"`
  4009. WarnInfo interface{} `json:"warn_info"`
  4010. }
  4011. type ResultSixteen struct {
  4012. Cainfo string `json:"cainfo"`
  4013. ErrMsg string `json:"err_msg"`
  4014. InfRefmsgid string `json:"inf_refmsgid"`
  4015. Infcode int64 `json:"infcode"`
  4016. Output struct {
  4017. Setldetail []interface{} `json:"setldetail"`
  4018. Setlinfo struct {
  4019. MdtrtID string `json:"mdtrt_id"`
  4020. SetlID string `json:"setl_id"`
  4021. ClrOptins string `json:"clr_optins"`
  4022. SetlTime string `json:"setl_time"`
  4023. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4024. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4025. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4026. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4027. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4028. ActPayDedc float64 `json:"act_pay_dedc"`
  4029. HifpPay float64 `json:"hifp_pay"`
  4030. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4031. Lfpay float64 `json:"selfpay"`
  4032. CvlservPay float64 `json:"cvlserv_pay"`
  4033. HifesPay float64 `json:"hifes_pay"`
  4034. HifmiPay float64 `json:"hifmi_pay"`
  4035. HifobPay float64 `json:"hifob_pay"`
  4036. MafPay float64 `json:"maf_pay"`
  4037. OthPay float64 `json:"oth_pay"`
  4038. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4039. PsnPartAmt float64 `json:"psn_part_amt"`
  4040. AcctPay float64 `json:"acct_pay"`
  4041. Balc float64 `json:"balc"`
  4042. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4043. HospPartAmt float64 `json:"hosp_part_amt"`
  4044. MedinsSetlID string `json:"medins_setl_id"`
  4045. PdnCashPay string `json:"pdn_cash_pay"`
  4046. } `json:"setlinfo"`
  4047. } `json:"output"`
  4048. RefmsgTime string `json:"refmsg_time"`
  4049. RespondTime string `json:"respond_time"`
  4050. Signtype interface{} `json:"signtype"`
  4051. WarnMsg interface{} `json:"warn_msg"`
  4052. }
  4053. type ResultSixteen10265 struct {
  4054. Cainfo string `json:"cainfo"`
  4055. ErrMsg string `json:"err_msg"`
  4056. InfRefmsgid string `json:"inf_refmsgid"`
  4057. Infcode string `json:"infcode"`
  4058. Output struct {
  4059. Setldetail []interface{} `json:"setldetail"`
  4060. Setlinfo struct {
  4061. MdtrtID string `json:"mdtrt_id"`
  4062. SetlID string `json:"setl_id"`
  4063. ClrOptins string `json:"clr_optins"`
  4064. SetlTime string `json:"setl_time"`
  4065. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4066. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4067. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4068. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4069. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4070. ActPayDedc float64 `json:"act_pay_dedc"`
  4071. HifpPay float64 `json:"hifp_pay"`
  4072. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4073. Lfpay float64 `json:"selfpay"`
  4074. CvlservPay float64 `json:"cvlserv_pay"`
  4075. HifesPay float64 `json:"hifes_pay"`
  4076. HifmiPay float64 `json:"hifmi_pay"`
  4077. HifobPay float64 `json:"hifob_pay"`
  4078. MafPay float64 `json:"maf_pay"`
  4079. OthPay float64 `json:"oth_pay"`
  4080. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4081. PsnPartAmt float64 `json:"psn_part_amt"`
  4082. AcctPay float64 `json:"acct_pay"`
  4083. Balc float64 `json:"balc"`
  4084. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4085. HospPartAmt float64 `json:"hosp_part_amt"`
  4086. MedinsSetlID string `json:"medins_setl_id"`
  4087. PdnCashPay string `json:"pdn_cash_pay"`
  4088. } `json:"setlinfo"`
  4089. } `json:"output"`
  4090. RefmsgTime string `json:"refmsg_time"`
  4091. RespondTime string `json:"respond_time"`
  4092. Signtype interface{} `json:"signtype"`
  4093. WarnMsg interface{} `json:"warn_msg"`
  4094. }
  4095. type ResultSeventeen struct {
  4096. ErrMsg string `json:"err_msg"`
  4097. InfRefmsgid string `json:"inf_refmsgid"`
  4098. Infcode int64 `json:"infcode"`
  4099. Output struct {
  4100. SetlListId string `json:"setl_list_id"`
  4101. } `json:"output"`
  4102. RefmsgTime string `json:"refmsg_time"`
  4103. RespondTime string `json:"respond_time"`
  4104. Signtype string `json:"signtype"`
  4105. WarnInfo string `json:"warn_info"`
  4106. }
  4107. type Result90991 struct {
  4108. ErrMsg string `json:"err_msg"`
  4109. InfRefmsgid string `json:"inf_refmsgid"`
  4110. Infcode int64 `json:"infcode"`
  4111. Output struct {
  4112. Result struct {
  4113. PsnNo string `json:"psn_no"`
  4114. CardStat string `json:"card_stat"`
  4115. Certno string `json:"certno"`
  4116. PsnName string `json:"psn_name"`
  4117. CheckStat string `json:"check_stat"`
  4118. SscnoCheckStat string `json:"sscno_check_stat"`
  4119. } `json:"result"`
  4120. } `json:"output"`
  4121. RefmsgTime string `json:"refmsg_time"`
  4122. RespondTime string `json:"respond_time"`
  4123. Signtype interface{} `json:"signtype"`
  4124. WarnInfo interface{} `json:"warn_info"`
  4125. }
  4126. type Result90100 struct {
  4127. ErrMsg string `json:"err_msg"`
  4128. InfRefmsgid string `json:"inf_refmsgid"`
  4129. Infcode int64 `json:"infcode"`
  4130. Output struct {
  4131. PoolareaNo string `json:"poolarea_no"`
  4132. PoolareaNoName string `json:"poolarea_no_name"`
  4133. Insutype string `json:"insutype"`
  4134. InsutypeName string `json:"insutype_name"`
  4135. ClctType string `json:"clct_type"`
  4136. ClctTypeName string `json:"clct_type_name"`
  4137. ClctFlag string `json:"clct_flag"`
  4138. ClctFlagName string `json:"clct_flag_name"`
  4139. AccrymBegn string `json:"accrym_begn"`
  4140. AccrymEnd string `json:"accrym_end"`
  4141. ClctTime string `json:"clct_time"`
  4142. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4143. } `json:"output"`
  4144. RefmsgTime string `json:"refmsg_time"`
  4145. RespondTime string `json:"respond_time"`
  4146. Signtype interface{} `json:"signtype"`
  4147. WarnInfo interface{} `json:"warn_info"`
  4148. }
  4149. type Custom struct {
  4150. DetItemFeeSumamt string
  4151. Cut string
  4152. FeedetlSn string
  4153. Price string
  4154. MedListCodg string
  4155. Type int64
  4156. AdviceId int64
  4157. ProjectId int64
  4158. ItemId int64
  4159. }
  4160. type Result5301 struct {
  4161. ErrMsg string `json:"err_msg"`
  4162. InfRefmsgid string `json:"inf_refmsgid"`
  4163. Infcode int64 `json:"infcode"`
  4164. Output struct {
  4165. Result []struct {
  4166. OpspDiseCode string `json:"opsp_dise_code"`
  4167. OpspDiseName string `json:"opsp_dise_name"`
  4168. Begndate string `json:"begndate"`
  4169. Enddate string `json:"enddate"`
  4170. } `json:"feedetail"`
  4171. } `json:"output"`
  4172. RefmsgTime string `json:"refmsg_time"`
  4173. RespondTime string `json:"respond_time"`
  4174. Signtype interface{} `json:"signtype"`
  4175. WarnInfo interface{} `json:"warn_info"`
  4176. }
  4177. type Result5301For10265 struct {
  4178. ErrMsg string `json:"err_msg"`
  4179. InfRefmsgid string `json:"inf_refmsgid"`
  4180. Infcode string `json:"infcode"`
  4181. Output struct {
  4182. Result []struct {
  4183. OpspDiseCode string `json:"opsp_dise_code"`
  4184. OpspDiseName string `json:"opsp_dise_name"`
  4185. Begndate string `json:"begndate"`
  4186. Enddate string `json:"enddate"`
  4187. } `json:"feedetail"`
  4188. } `json:"output"`
  4189. RefmsgTime string `json:"refmsg_time"`
  4190. RespondTime string `json:"respond_time"`
  4191. Signtype interface{} `json:"signtype"`
  4192. WarnInfo interface{} `json:"warn_info"`
  4193. }
  4194. //获取个人信息----挂号-----上传就诊信息
  4195. func (c *HisApiController) GetRegisterInfo() {
  4196. id, _ := c.GetInt64("id")
  4197. record_time := c.GetString("record_time")
  4198. settlementValue, _ := c.GetInt64("settlement_value")
  4199. medical_insurance_card := c.GetString("medical_insurance_card")
  4200. name := c.GetString("name")
  4201. id_card_type, _ := c.GetInt64("id_card_type")
  4202. certificates, _ := c.GetInt64("certificates")
  4203. medical_care, _ := c.GetInt64("medical_care")
  4204. birthday := c.GetString("birthday")
  4205. id_card := c.GetString("id_card")
  4206. register_type, _ := c.GetInt64("register")
  4207. doctor, _ := c.GetInt64("doctor")
  4208. department, _ := c.GetInt64("department")
  4209. gender, _ := c.GetInt64("sex")
  4210. registration_fee, _ := c.GetFloat("registration_fee")
  4211. medical_expenses, _ := c.GetFloat("medical_expenses")
  4212. social_type, _ := c.GetInt64("social_type")
  4213. med_type := c.GetString("social_type")
  4214. admin_user_id, _ := c.GetInt64("admin_user_id")
  4215. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4216. timeLayout := "2006-01-02"
  4217. loc, _ := time.LoadLocation("Local")
  4218. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4219. birthUnix := birthdays.Unix()
  4220. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4221. if err != nil {
  4222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4223. return
  4224. }
  4225. recordDateTime := theTime.Unix()
  4226. adminInfo := c.GetAdminUserInfo()
  4227. var patient service.Patients
  4228. if id == 0 {
  4229. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4230. } else {
  4231. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4232. }
  4233. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4234. if patientPrescription.ID == 0 {
  4235. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4236. }
  4237. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4238. if patient.ID == 0 {
  4239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4240. return
  4241. }
  4242. if len(patient.IdCardNo) == 0 {
  4243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4244. return
  4245. }
  4246. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4247. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4248. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4249. //就诊结算未完成,不能进行二次挂号
  4250. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4251. if len(his) >= 1 {
  4252. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4253. if len(his) >= 1 && order.ID == 0 {
  4254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4255. return
  4256. }
  4257. }
  4258. //var register_log string
  4259. if config.IsOpen == 1 {
  4260. var res ResultTwo
  4261. var res10265 ResultTwo10265
  4262. var PsnNo string
  4263. var PsnCertType string
  4264. var Certno string
  4265. var PsnName string
  4266. var Gend string
  4267. var Naty string
  4268. var Brdy string
  4269. var Age float64
  4270. var infoStr string
  4271. var idetinfoStr string
  4272. var infocode int64
  4273. var verify_number string
  4274. fmt.Println(verify_number)
  4275. if miConfig.MdtrtareaAdmvs == "421300" {
  4276. psn_info, _ := service.GetPsnByPatientId(id)
  4277. PsnNo = psn_info.PsnNo
  4278. PsnCertType = psn_info.PsnCertType
  4279. Certno = psn_info.Certno
  4280. PsnName = psn_info.PsnName
  4281. Gend = psn_info.Gend
  4282. Naty = psn_info.Naty
  4283. Brdy = psn_info.Brdy
  4284. Age = psn_info.Age
  4285. infoStr = psn_info.Insuinfo
  4286. idetinfoStr = psn_info.Idetinfo
  4287. infocode = 0
  4288. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4289. psn_info, _ := service.GetPsnByPatientId(id)
  4290. PsnNo = psn_info.PsnNo
  4291. PsnCertType = psn_info.PsnCertType
  4292. Certno = psn_info.Certno
  4293. PsnName = psn_info.PsnName
  4294. Gend = psn_info.Gend
  4295. Naty = psn_info.Naty
  4296. Brdy = psn_info.Brdy
  4297. Age = psn_info.Age
  4298. infoStr = psn_info.Insuinfo
  4299. idetinfoStr = psn_info.Idetinfo
  4300. infocode = 0
  4301. verify_number = psn_info.VerifyNumber
  4302. } else {
  4303. var result string
  4304. var requestLog string
  4305. if miConfig.UserOrgId == 10138 {
  4306. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  4307. } else {
  4308. 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)
  4309. }
  4310. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4311. if miConfig.Code == "H15049901371" {
  4312. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4313. utils.ErrorLog("解析失败:%v", err)
  4314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4315. return
  4316. }
  4317. res.ErrMsg = res10265.ErrMsg
  4318. res.Output = res10265.Output
  4319. res.InfRefmsgid = res10265.InfRefmsgid
  4320. } else {
  4321. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4322. utils.ErrorLog("解析失败:%v", err)
  4323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4324. return
  4325. }
  4326. }
  4327. PsnNo = res.Output.Baseinfo.PsnNo
  4328. PsnCertType = res.Output.Baseinfo.PsnCertType
  4329. Certno = res.Output.Baseinfo.Certno
  4330. PsnName = res.Output.Baseinfo.PsnName
  4331. Gend = res.Output.Baseinfo.Gend
  4332. Naty = res.Output.Baseinfo.Naty
  4333. Brdy = res.Output.Baseinfo.Brdy
  4334. Age = res.Output.Baseinfo.Age
  4335. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4336. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4337. infoStr = string(Iinfos)
  4338. idetinfoStr = string(Idetinfos)
  4339. if miConfig.Code == "H15049901371" {
  4340. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4341. } else {
  4342. infocode = res.Infcode
  4343. }
  4344. }
  4345. if infocode == 0 {
  4346. his := models.VMHisPatient{
  4347. Name: name,
  4348. Gender: gender,
  4349. Birthday: birthUnix,
  4350. MedicalTreatmentType: medical_care,
  4351. IdType: certificates,
  4352. IdCardNo: id_card,
  4353. BalanceAccountsType: settlementValue,
  4354. SocialType: social_type,
  4355. MedicalInsuranceNumber: medical_insurance_card,
  4356. RegisterType: register_type,
  4357. RegisterCost: registration_fee,
  4358. TreatmentCost: medical_expenses,
  4359. Status: 1,
  4360. Ctime: time.Now().Unix(),
  4361. Mtime: time.Now().Unix(),
  4362. PsnNo: PsnNo,
  4363. PsnCertType: PsnCertType,
  4364. Certno: Certno,
  4365. PsnName: PsnName,
  4366. Gend: Gend,
  4367. Naty: Naty,
  4368. Brdy: Brdy,
  4369. Age: Age,
  4370. Iinfo: infoStr,
  4371. Idetinfo: idetinfoStr,
  4372. PatientId: patient.ID,
  4373. RecordDate: theTime.Unix(),
  4374. UserOrgId: adminInfo.CurrentOrgId,
  4375. AdminUserId: admin_user_id,
  4376. IsReturn: 1,
  4377. IdCardType: id_card_type,
  4378. Doctor: doctor,
  4379. Departments: department,
  4380. }
  4381. timestamp := time.Now().Unix()
  4382. tempTime := time.Unix(timestamp, 0)
  4383. timeFormat := tempTime.Format("20060102150405")
  4384. chrgBchno := rand.Intn(100000) + 10000
  4385. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4386. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4387. department, _ := service.GetDepartMentDetail(department)
  4388. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4389. IdCardNo := ""
  4390. if id_card_type == 1 {
  4391. // IdCardNo = medical_insurance_card
  4392. IdCardNo = patient.IdCardNo
  4393. } else {
  4394. IdCardNo = patient.IdCardNo
  4395. }
  4396. var rf []*ResultFive
  4397. json.Unmarshal([]byte(his.Iinfo), &rf)
  4398. var insutypes []*ResultFive
  4399. var insutype string
  4400. var insuplc_admdvs_temp string
  4401. var is390 int = 0
  4402. var is310 int = 0
  4403. for _, item := range rf {
  4404. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4405. insutypes = append(insutypes, item)
  4406. }
  4407. }
  4408. if len(insutypes) == 1 {
  4409. insutype = insutypes[0].Insutype
  4410. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4411. } else {
  4412. for _, i := range insutypes {
  4413. if i.Insutype == "390" {
  4414. is390 = 1
  4415. }
  4416. if i.Insutype == "310" {
  4417. is310 = 1
  4418. }
  4419. }
  4420. }
  4421. if is390 == 1 {
  4422. insutype = "390"
  4423. }
  4424. if is310 == 1 {
  4425. insutype = "310"
  4426. }
  4427. if len(insutypes) == 0 {
  4428. insutype = "310"
  4429. }
  4430. if len(insutypes) == 2 {
  4431. insutype = med_type
  4432. }
  4433. if len(med_type) > 0 {
  4434. insutype = med_type
  4435. }
  4436. //for _, item := range rf {
  4437. // if item.Insutype == insutype {
  4438. // insuplc_admdvs = item.InsuplcAdmdvs
  4439. // }
  4440. //}
  4441. var infocode int64
  4442. var resThree ResultThree
  4443. var resThree10265 ResultThree10265
  4444. if len(insuplc_admdvs) == 0 {
  4445. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4446. } else {
  4447. insuplc_admdvs_temp = insuplc_admdvs
  4448. }
  4449. if miConfig.MdtrtareaAdmvs == "421300" {
  4450. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4451. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4452. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&doctor_name=" + doctor_info.UserName
  4453. resp, requestErr := http.Get(api)
  4454. if requestErr != nil {
  4455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4456. return
  4457. }
  4458. body, ioErr := ioutil.ReadAll(resp.Body)
  4459. if ioErr != nil {
  4460. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4462. return
  4463. }
  4464. var respJSON map[string]interface{}
  4465. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4468. return
  4469. }
  4470. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4471. result, _ := json.Marshal(respJSON)
  4472. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4473. utils.ErrorLog("解析失败:%v", err)
  4474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4475. return
  4476. }
  4477. infocode = resThree.Infcode
  4478. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4479. psn_info, _ := service.GetPsnByPatientId(id)
  4480. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4481. var cert_no string
  4482. if id_card_type == 3 {
  4483. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4484. cert_no = IdCardNo
  4485. } else {
  4486. bas := strings.Split(psn_info.CardInfo, "|")
  4487. cert_no = bas[2]
  4488. }
  4489. var api string
  4490. if miConfig.MdtrtareaAdmvs == "320921" {
  4491. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4492. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4493. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4494. } else {
  4495. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4496. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4497. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4498. }
  4499. resp, requestErr := http.Get(api)
  4500. if requestErr != nil {
  4501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4502. return
  4503. }
  4504. body, ioErr := ioutil.ReadAll(resp.Body)
  4505. if ioErr != nil {
  4506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4508. return
  4509. }
  4510. var respJSON map[string]interface{}
  4511. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4514. return
  4515. }
  4516. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4517. result, _ := json.Marshal(respJSON)
  4518. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4519. utils.ErrorLog("解析失败:%v", err)
  4520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4521. return
  4522. }
  4523. resThree.ErrMsg = resThree10265.ErrMsg
  4524. resThree.Output = resThree10265.Output
  4525. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4526. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4527. } else {
  4528. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time)
  4529. saveLog(result, requestLog, "2201A", "挂号")
  4530. if miConfig.Code == "H15049901371" {
  4531. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4532. utils.ErrorLog("解析失败:%v", err)
  4533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4534. return
  4535. }
  4536. resThree.ErrMsg = resThree10265.ErrMsg
  4537. resThree.Output = resThree10265.Output
  4538. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4539. } else {
  4540. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4541. utils.ErrorLog("解析失败:%v", err)
  4542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4543. return
  4544. }
  4545. }
  4546. if miConfig.Code == "H15049901371" {
  4547. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4548. } else {
  4549. infocode = resThree.Infcode
  4550. }
  4551. }
  4552. if infocode != 0 {
  4553. adminUser := c.GetAdminUserInfo()
  4554. errlog := &models.HisOrderError{
  4555. UserOrgId: adminUser.CurrentOrgId,
  4556. Ctime: time.Now().Unix(),
  4557. Mtime: time.Now().Unix(),
  4558. ErrMsg: resThree.ErrMsg,
  4559. Status: 1,
  4560. PatientId: id,
  4561. RecordTime: recordDateTime,
  4562. Stage: 2,
  4563. }
  4564. service.CreateErrMsgLog(errlog)
  4565. c.ServeSuccessJSON(map[string]interface{}{
  4566. "failed_code": -10,
  4567. "msg": resThree.ErrMsg,
  4568. })
  4569. return
  4570. }
  4571. his.Number = resThree.Output.Data.MdtrtID
  4572. his.PsnNo = resThree.Output.Data.PsnNo
  4573. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4574. his.IdCardNo = patient.IdCardNo
  4575. his.PhoneNumber = patient.Phone
  4576. his.UserOrgId = adminInfo.CurrentOrgId
  4577. his.Insutype = insutype
  4578. his.Ctime = time.Now().Unix()
  4579. his.Mtime = time.Now().Unix()
  4580. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4581. his.Status = 1
  4582. service.UpdateHisPatientStatus(&his)
  4583. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4584. c.ServeSuccessJSON(map[string]interface{}{
  4585. "his_info": his,
  4586. })
  4587. } else {
  4588. adminUser := c.GetAdminUserInfo()
  4589. errlog := &models.HisOrderError{
  4590. UserOrgId: adminUser.CurrentOrgId,
  4591. Ctime: time.Now().Unix(),
  4592. Mtime: time.Now().Unix(),
  4593. ErrMsg: res.ErrMsg,
  4594. Status: 1,
  4595. PatientId: id,
  4596. RecordTime: recordDateTime,
  4597. Stage: 1,
  4598. }
  4599. service.CreateErrMsgLog(errlog)
  4600. c.ServeSuccessJSON(map[string]interface{}{
  4601. "failed_code": -10,
  4602. "msg": res.ErrMsg,
  4603. })
  4604. return
  4605. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4606. }
  4607. }
  4608. }
  4609. //上传明细----预结算----确认订单
  4610. func (c *HisApiController) GetUploadInfo() {
  4611. id, _ := c.GetInt64("id")
  4612. record_time := c.GetString("record_time")
  4613. his_patient_id, _ := c.GetInt64("his_patient_id")
  4614. order_id, _ := c.GetInt64("order_id")
  4615. pay_way, _ := c.GetInt64("pay_way")
  4616. pay_price, _ := c.GetFloat("pay_price")
  4617. pay_card_no := c.GetString("pay_card_no")
  4618. discount_price, _ := c.GetFloat("discount_price")
  4619. preferential_price, _ := c.GetFloat("preferential_price")
  4620. reality_price, _ := c.GetFloat("reality_price")
  4621. found_price, _ := c.GetFloat("found_price")
  4622. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4623. private_price, _ := c.GetFloat("private_price")
  4624. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4625. admin_user_id, _ := c.GetInt64("admin_user_id")
  4626. fapiao_code := c.GetString("fapiao_code")
  4627. fapiao_number := c.GetString("fapiao_number")
  4628. diagnosis_id := c.GetString("diagnosis")
  4629. sick_type, _ := c.GetInt64("sick_type")
  4630. reg_type, _ := c.GetInt64("p_type")
  4631. begin_time := c.GetString("begin_time")
  4632. id_str := c.GetString("ids")
  4633. ids_arr := strings.Split(id_str, ",")
  4634. timeLayout := "2006-01-02"
  4635. loc, _ := time.LoadLocation("Local")
  4636. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4637. if err != nil {
  4638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4639. return
  4640. }
  4641. recordDateTime := theTime.Unix()
  4642. adminUser := c.GetAdminUserInfo()
  4643. var tempOrder models.HisOrder
  4644. tempOrder, _ = service.GetHisOrderByID(order_id)
  4645. var prescriptions []*models.HisPrescription
  4646. var start_time int64
  4647. var end_time int64
  4648. //if adminUser.CurrentOrgId == 10106{
  4649. // if len(fapiao_code) == 0{
  4650. // fapiao_code = "144072080589"
  4651. // }
  4652. // if len(fapiao_number) == 0{
  4653. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4654. // if order.ID == 0{
  4655. // fapiao_number = "00001520"
  4656. // }else{
  4657. // //fapiao_code = "00001520"
  4658. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4659. // var zero string
  4660. // if fpNumber >= 1000{
  4661. // zero = "0000" + strconv.Itoa(fpNumber)
  4662. // }else if fpNumber >= 10000{
  4663. // zero = "000" + strconv.Itoa(fpNumber)
  4664. // } else if fpNumber >= 100000{
  4665. // zero = "00" + strconv.Itoa(fpNumber)
  4666. // } else if fpNumber >= 1000000{
  4667. // zero = "0" + strconv.Itoa(fpNumber)
  4668. // }else {
  4669. // zero = strconv.Itoa(fpNumber)
  4670. // }
  4671. // fapiao_number = zero
  4672. // }
  4673. // }
  4674. //}
  4675. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4676. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4677. var patientPrescription models.HisPrescriptionInfo
  4678. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4679. if patientPrescription.ID == 0 {
  4680. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4681. }
  4682. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4683. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4684. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4685. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4686. var config []*models.HisXtDiagnoseConfig
  4687. for _, item := range diagnosis_ids {
  4688. id, _ := strconv.ParseInt(item, 10, 64)
  4689. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4690. config = append(config, &diagnosisConfig)
  4691. }
  4692. sickConfig, _ := service.FindSickById(sick_type)
  4693. //if tempOrder.ID == 0 {
  4694. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4695. //}
  4696. if tempOrder.ID == 0 {
  4697. var result string
  4698. var requestLog string
  4699. var res2 ResultSix
  4700. var ressix10265 ResultSix10265
  4701. if miConfig.MdtrtareaAdmvs == "421300" {
  4702. data := make(map[string]interface{})
  4703. client := &http.Client{}
  4704. data["psn_no"] = his.PsnNo
  4705. data["mdtrt_id"] = his.Number
  4706. data["doctor"] = roles.UserName
  4707. data["department"] = department.Name
  4708. data["org_name"] = miConfig.OrgName
  4709. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4710. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4711. data["fixmedins_code"] = miConfig.Code
  4712. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4713. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4714. data["secret_key"] = miConfig.SecretKey
  4715. data["sick_code"] = sickConfig.CountryCode
  4716. data["sick_name"] = sickConfig.ClassName
  4717. data["dept"] = strconv.FormatInt(department.ID, 10)
  4718. data["config"] = config
  4719. data["begin_time"] = begin_time
  4720. bytesData, _ := json.Marshal(data)
  4721. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4722. resp, _ := client.Do(req)
  4723. defer resp.Body.Close()
  4724. body, ioErr := ioutil.ReadAll(resp.Body)
  4725. if ioErr != nil {
  4726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4728. return
  4729. }
  4730. var respJSON map[string]interface{}
  4731. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4734. return
  4735. }
  4736. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4737. userJSONBytes, _ := json.Marshal(respJSON)
  4738. fmt.Println("log")
  4739. fmt.Println(string(userJSONBytes))
  4740. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4741. utils.ErrorLog("解析失败:%v", err)
  4742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4743. return
  4744. }
  4745. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4746. //江苏地区国家医保医疗类别
  4747. //职工透析:医疗类别选特殊情况门诊9933
  4748. //居民血透门慢: 医疗类别选门诊慢病1402
  4749. //var med_type string
  4750. //if his.Insutype == "310" {
  4751. // if reg_type == 14 {
  4752. // med_type = "9933"
  4753. // } else if reg_type == 11 {
  4754. // med_type = "11"
  4755. //
  4756. // }
  4757. //} else if his.Insutype == "390" {
  4758. // if reg_type == 14 {
  4759. // med_type = "1402"
  4760. // } else if reg_type == 11 {
  4761. // med_type = "11"
  4762. // }
  4763. //}
  4764. data := make(map[string]interface{})
  4765. client := &http.Client{}
  4766. data["psn_no"] = his.PsnNo
  4767. data["mdtrt_id"] = his.Number
  4768. data["doctor"] = roles.UserName
  4769. data["department"] = department.Name
  4770. data["org_name"] = miConfig.OrgName
  4771. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4772. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4773. data["fixmedins_code"] = miConfig.Code
  4774. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4775. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4776. data["secret_key"] = miConfig.SecretKey
  4777. data["sick_code"] = sickConfig.CountryCode
  4778. data["sick_name"] = sickConfig.ClassName
  4779. data["url"] = miConfig.Url
  4780. data["ak"] = miConfig.AccessKey
  4781. data["begin_time"] = begin_time
  4782. data["cainfo"] = miConfig.Cainfo
  4783. data["dept"] = strconv.FormatInt(department.ID, 10)
  4784. data["config"] = config
  4785. bytesData, _ := json.Marshal(data)
  4786. var req *http.Request
  4787. if miConfig.MdtrtareaAdmvs == "320921" {
  4788. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4789. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4790. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4791. } else {
  4792. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4793. }
  4794. resp, _ := client.Do(req)
  4795. defer resp.Body.Close()
  4796. body, ioErr := ioutil.ReadAll(resp.Body)
  4797. if ioErr != nil {
  4798. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4800. return
  4801. }
  4802. var respJSON map[string]interface{}
  4803. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4806. return
  4807. }
  4808. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4809. userJSONBytes, _ := json.Marshal(respJSON)
  4810. fmt.Println("log")
  4811. fmt.Println(string(userJSONBytes))
  4812. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4813. utils.ErrorLog("解析失败:%v", err)
  4814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4815. return
  4816. }
  4817. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4818. res2.Output = ressix10265.Output
  4819. res2.ErrMsg = ressix10265.ErrMsg
  4820. res2.Cainfo = ressix10265.Cainfo
  4821. res2.WarnMsg = ressix10265.WarnMsg
  4822. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4823. res2.Infcode = infocode
  4824. } else {
  4825. if miConfig.MdtrtareaAdmvs == "440781" { //
  4826. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  4827. } else {
  4828. if miConfig.Code == "H15049901371" {
  4829. //赤峰地区国家医保医疗类别
  4830. //职工透析:医疗类别选特殊情况门诊990502
  4831. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4832. var med_type string
  4833. if his.Insutype == "390" {
  4834. if reg_type == 14 {
  4835. med_type = "9933"
  4836. } else if reg_type == 11 {
  4837. med_type = "11"
  4838. }
  4839. } else if his.Insutype == "310" {
  4840. if reg_type == 14 {
  4841. med_type = "990502"
  4842. } else if reg_type == 11 {
  4843. med_type = "11"
  4844. }
  4845. }
  4846. 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)
  4847. } else {
  4848. 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)
  4849. }
  4850. }
  4851. saveLog(result, requestLog, "2203", "上传就诊信息")
  4852. var respJSON2 map[string]interface{}
  4853. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4856. return
  4857. }
  4858. userJSONBytes2, _ := json.Marshal(respJSON2)
  4859. if miConfig.Code == "H15049901371" {
  4860. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4861. utils.ErrorLog("解析失败:%v", err)
  4862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4863. return
  4864. }
  4865. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4866. res2.Output = ressix10265.Output
  4867. res2.ErrMsg = ressix10265.ErrMsg
  4868. res2.Cainfo = ressix10265.Cainfo
  4869. res2.WarnMsg = ressix10265.WarnMsg
  4870. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4871. res2.Infcode = infocode
  4872. } else {
  4873. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4874. utils.ErrorLog("解析失败:%v", err)
  4875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4876. return
  4877. }
  4878. }
  4879. }
  4880. if res2.Infcode != 0 {
  4881. adminUser := c.GetAdminUserInfo()
  4882. errlog := &models.HisOrderError{
  4883. UserOrgId: adminUser.CurrentOrgId,
  4884. Ctime: time.Now().Unix(),
  4885. Mtime: time.Now().Unix(),
  4886. ErrMsg: res2.ErrMsg,
  4887. Status: 1,
  4888. PatientId: id,
  4889. RecordTime: recordDateTime,
  4890. Stage: 3,
  4891. }
  4892. service.CreateErrMsgLog(errlog)
  4893. c.ServeSuccessJSON(map[string]interface{}{
  4894. "failed_code": -10,
  4895. "msg": res2.ErrMsg,
  4896. })
  4897. return
  4898. } else {
  4899. his.Diagnosis = diagnosis_id
  4900. his.SickType = sickConfig.ID
  4901. //var p_type int64
  4902. //if reg_type == 1111 || reg_type == 1112 {
  4903. // p_type = 11
  4904. //
  4905. //}
  4906. his.PType = fmt.Sprintf("%d", reg_type)
  4907. service.UpdateHisPatientThree(&his)
  4908. data := make(map[string]interface{})
  4909. if settle_accounts_type == 1 { //日结
  4910. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4911. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4912. } else {
  4913. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4914. }
  4915. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4916. data["pre"] = prescriptions
  4917. } else { //月结
  4918. start_time_str := c.GetString("start_time")
  4919. end_time_str := c.GetString("end_time")
  4920. timeLayout := "2006-01-02"
  4921. loc, _ := time.LoadLocation("Local")
  4922. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4923. if err != nil {
  4924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4925. return
  4926. }
  4927. recordStartTime := theStartTime.Unix()
  4928. start_time = recordStartTime
  4929. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4930. if err != nil {
  4931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4932. return
  4933. }
  4934. recordEndTime := theEndTime.Unix()
  4935. end_time = recordEndTime
  4936. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4937. data["pre"] = prescriptions
  4938. }
  4939. timestamp := time.Now().Unix()
  4940. tempTime := time.Unix(timestamp, 0)
  4941. timeFormat := tempTime.Format("20060102150405")
  4942. chrgBchno := rand.Intn(100000) + 10000
  4943. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4944. strconv.FormatInt(his.PatientId, 10)
  4945. client := &http.Client{}
  4946. data["psn_no"] = his.PsnNo
  4947. data["mdtrt_id"] = his.Number
  4948. data["chrg_bchno"] = chrg_bchno
  4949. data["org_name"] = miConfig.OrgName
  4950. data["doctor"] = roles.UserName
  4951. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4952. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4953. data["fixmedins_code"] = miConfig.Code
  4954. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4955. // data["dept_code"] = "15"
  4956. //} else {
  4957. data["dept_code"] = department.Number
  4958. //}
  4959. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4960. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4961. data["secret_key"] = miConfig.SecretKey
  4962. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4963. data["url"] = miConfig.Url
  4964. data["ak"] = miConfig.AccessKey
  4965. data["new_doctor_name"] = patientPrescription.Doctor
  4966. data["diag_code"] = sickConfig.CountryCode
  4967. data["cainfo"] = miConfig.Cainfo
  4968. var ids []int64
  4969. for _, item := range prescriptions {
  4970. ids = append(ids, item.ID)
  4971. }
  4972. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4973. if config.IsOpen == 1 { //对接了医保,走医保流程
  4974. var res ResultFour
  4975. var resFour10265 ResultFour10265
  4976. if miConfig.MdtrtareaAdmvs == "421300" {
  4977. bytesData, _ := json.Marshal(data)
  4978. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4979. resp, _ := client.Do(req)
  4980. defer resp.Body.Close()
  4981. body, ioErr := ioutil.ReadAll(resp.Body)
  4982. if ioErr != nil {
  4983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4985. return
  4986. }
  4987. var respJSON map[string]interface{}
  4988. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4991. return
  4992. }
  4993. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4994. userJSONBytes, _ := json.Marshal(respJSON)
  4995. fmt.Println("log")
  4996. fmt.Println(string(userJSONBytes))
  4997. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4998. utils.ErrorLog("解析失败:%v", err)
  4999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5000. return
  5001. }
  5002. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5003. bytesData, _ := json.Marshal(data)
  5004. var req *http.Request
  5005. if miConfig.MdtrtareaAdmvs == "320921" {
  5006. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5007. } else {
  5008. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5009. }
  5010. resp, _ := client.Do(req)
  5011. defer resp.Body.Close()
  5012. body, ioErr := ioutil.ReadAll(resp.Body)
  5013. if ioErr != nil {
  5014. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5016. return
  5017. }
  5018. var respJSON map[string]interface{}
  5019. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5022. return
  5023. }
  5024. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5025. userJSONBytes, _ := json.Marshal(respJSON)
  5026. fmt.Println("log")
  5027. fmt.Println(string(userJSONBytes))
  5028. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5029. utils.ErrorLog("解析失败:%v", err)
  5030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5031. return
  5032. }
  5033. res.InfRefmsgid = resFour10265.InfRefmsgid
  5034. res.Output = resFour10265.Output
  5035. res.ErrMsg = resFour10265.ErrMsg
  5036. res.Cainfo = resFour10265.Cainfo
  5037. res.WarnMsg = resFour10265.WarnMsg
  5038. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5039. res.Infcode = infocode
  5040. } else {
  5041. if miConfig.Code == "H15049901371" {
  5042. 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)
  5043. var dat map[string]interface{}
  5044. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5045. fmt.Println(dat)
  5046. } else {
  5047. fmt.Println(err)
  5048. }
  5049. saveLog(result, request_log, "2204", "上传费用明细")
  5050. userJSONBytes, _ := json.Marshal(dat)
  5051. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5052. utils.ErrorLog("解析失败:%v", err)
  5053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5054. return
  5055. }
  5056. res.InfRefmsgid = resFour10265.InfRefmsgid
  5057. res.Output = resFour10265.Output
  5058. res.ErrMsg = resFour10265.ErrMsg
  5059. res.Cainfo = resFour10265.Cainfo
  5060. res.WarnMsg = resFour10265.WarnMsg
  5061. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5062. res.Infcode = infocode
  5063. } else {
  5064. 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)
  5065. var dat map[string]interface{}
  5066. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5067. fmt.Println(dat)
  5068. } else {
  5069. fmt.Println(err)
  5070. }
  5071. saveLog(result, request_log, "2204", "上传费用明细")
  5072. userJSONBytes, _ := json.Marshal(dat)
  5073. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5074. utils.ErrorLog("解析失败:%v", err)
  5075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5076. return
  5077. }
  5078. }
  5079. }
  5080. if res.Infcode == 0 {
  5081. order := &models.HisOrder{
  5082. UserOrgId: adminUser.CurrentOrgId,
  5083. HisPatientId: his.ID,
  5084. PatientId: his.PatientId,
  5085. SettleAccountsDate: recordDateTime,
  5086. MdtrtId: his.Number,
  5087. PsnNo: his.PsnNo,
  5088. MedType: strconv.FormatInt(reg_type, 10),
  5089. Ctime: time.Now().Unix(),
  5090. Mtime: time.Now().Unix(),
  5091. Status: 1,
  5092. Number: chrg_bchno,
  5093. Infcode: res.Infcode,
  5094. WarnMsg: res.WarnMsg,
  5095. Cainfo: res.Cainfo,
  5096. ErrMsg: res.ErrMsg,
  5097. RespondTime: res.RefmsgTime,
  5098. InfRefmsgid: res.InfRefmsgid,
  5099. OrderStatus: 1,
  5100. PayWay: pay_way,
  5101. PayPrice: pay_price,
  5102. PayCardNo: pay_card_no,
  5103. DiscountPrice: discount_price,
  5104. PreferentialPrice: preferential_price,
  5105. RealityPrice: reality_price,
  5106. FoundPrice: found_price,
  5107. MedicalInsurancePrice: medical_insurance_price,
  5108. PrivatePrice: private_price,
  5109. IsMedicineInsurance: 1,
  5110. SettleType: settle_accounts_type,
  5111. SettleStartTime: start_time,
  5112. SettleEndTime: end_time,
  5113. Creator: roles.AdminUserId,
  5114. Modify: roles.AdminUserId,
  5115. FaPiaoNumber: fapiao_number,
  5116. FaPiaoCode: fapiao_code,
  5117. PType: 2,
  5118. Diagnosis: diagnosis_id,
  5119. }
  5120. err = service.CreateOrder(order)
  5121. if err != nil {
  5122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5123. return
  5124. }
  5125. for _, item := range res.Output.Result {
  5126. temp := strings.Split(item.FeedetlSn, "-")
  5127. var advice_id int64 = 0
  5128. var project_id int64 = 0
  5129. var types int64 = 0
  5130. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5131. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5132. if temp[1] == "1" {
  5133. advice_id = id
  5134. project_id = 0
  5135. } else if temp[1] == "2" {
  5136. advice_id = 0
  5137. project_id = id
  5138. }
  5139. info := &models.HisOrderInfo{
  5140. OrderNumber: order.Number,
  5141. FeedetlSn: item.FeedetlSn,
  5142. UploadDate: time.Now().Unix(),
  5143. AdviceId: advice_id,
  5144. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5145. Cnt: item.Cnt,
  5146. Pric: float64(item.Pric),
  5147. PatientId: his.PatientId,
  5148. PricUplmtAmt: item.PricUplmtAmt,
  5149. SelfpayProp: item.SelfpayProp,
  5150. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5151. OverlmtAmt: item.OverlmtAmt,
  5152. PreselfpayAmt: item.PreselfpayAmt,
  5153. BasMednFlag: item.BasMednFlag,
  5154. MedChrgitmType: item.MedChrgitmType,
  5155. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5156. Status: 1,
  5157. Memo: item.Memo,
  5158. Mtime: time.Now().Unix(),
  5159. InscpScpAmt: item.InscpScpAmt,
  5160. DrtReimFlag: item.DrtReimFlag,
  5161. Ctime: time.Now().Unix(),
  5162. ListSpItemFlag: item.ListSpItemFlag,
  5163. ChldMedcFlag: item.ChldMedcFlag,
  5164. LmtUsedFlag: item.LmtUsedFlag,
  5165. ChrgitmLv: item.ChrgitmLv,
  5166. UserOrgId: adminUser.CurrentOrgId,
  5167. HisPatientId: his.ID,
  5168. OrderId: order.ID,
  5169. ProjectId: project_id,
  5170. Type: types,
  5171. }
  5172. service.CreateOrderInfo(info)
  5173. }
  5174. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5175. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5176. var total float64
  5177. for _, item := range prescriptions {
  5178. if item.Type == 1 { //药品
  5179. for _, subItem := range item.HisDoctorAdviceInfo {
  5180. total = total + (subItem.Price * subItem.PrescribingNumber)
  5181. }
  5182. }
  5183. if item.Type == 2 { //项目
  5184. for _, subItem := range item.HisPrescriptionProject {
  5185. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5186. total = total + (subItem.Price * cnt)
  5187. }
  5188. }
  5189. }
  5190. for _, item := range prescriptions {
  5191. for _, subItem := range item.HisAdditionalCharge {
  5192. total = total + (subItem.Price * float64(subItem.Count))
  5193. }
  5194. }
  5195. var allTotal string
  5196. if adminUser.CurrentOrgId == 9919 {
  5197. allTotal = fmt.Sprintf("%.4f", total)
  5198. } else {
  5199. allTotal = fmt.Sprintf("%.4f", total)
  5200. }
  5201. if res.Infcode == 0 {
  5202. var rf []*ResultFive
  5203. json.Unmarshal([]byte(his.Iinfo), &rf)
  5204. chrg_bchno := chrg_bchno
  5205. cert_no := his.Certno
  5206. var insutypes []string
  5207. var insutype string
  5208. var is390 int = 0
  5209. var is310 int = 0
  5210. for _, item := range rf {
  5211. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5212. insutypes = append(insutypes, item.Insutype)
  5213. }
  5214. }
  5215. if len(insutypes) == 1 {
  5216. insutype = insutypes[0]
  5217. } else {
  5218. for _, i := range insutypes {
  5219. if i == "390" {
  5220. is390 = 1
  5221. }
  5222. if i == "310" {
  5223. is310 = 1
  5224. }
  5225. }
  5226. }
  5227. if is390 == 1 {
  5228. insutype = "390"
  5229. }
  5230. if is310 == 1 {
  5231. insutype = "310"
  5232. }
  5233. if len(insutypes) == 0 {
  5234. insutype = "310"
  5235. }
  5236. if len(insutypes) == 2 {
  5237. insutype = strconv.FormatInt(his.SocialType, 10)
  5238. }
  5239. insutype = strconv.FormatInt(his.SocialType, 10)
  5240. //insutype = "390"
  5241. if his.IdCardType == 1 {
  5242. // cert_no = his.MedicalInsuranceNumber
  5243. cert_no = his.Certno
  5244. } else {
  5245. cert_no = his.Certno
  5246. }
  5247. var res ResultSeven
  5248. var resSeven10265 ResultSeven10265
  5249. var src_resquest string
  5250. var result2 string
  5251. var acct_used_flag string
  5252. fmt.Println("pay_way")
  5253. fmt.Println(pay_way)
  5254. fmt.Println("pay_way")
  5255. if pay_way == 4 {
  5256. acct_used_flag = "1"
  5257. } else {
  5258. acct_used_flag = "0"
  5259. }
  5260. if miConfig.MdtrtareaAdmvs == "421300" {
  5261. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5262. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5263. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5264. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5265. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5266. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5267. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5268. resp, requestErr := http.Get(api)
  5269. if requestErr != nil {
  5270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5271. return
  5272. }
  5273. body, ioErr := ioutil.ReadAll(resp.Body)
  5274. if ioErr != nil {
  5275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5277. return
  5278. }
  5279. var respJSON map[string]interface{}
  5280. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5283. return
  5284. }
  5285. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5286. result, _ := json.Marshal(respJSON)
  5287. if miConfig.Code == "H15049901371" {
  5288. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5289. utils.ErrorLog("解析失败:%v", err)
  5290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5291. return
  5292. }
  5293. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5294. res.Output = resSeven10265.Output
  5295. res.ErrMsg = resSeven10265.ErrMsg
  5296. res.Cainfo = resSeven10265.Cainfo
  5297. res.WarnMsg = resSeven10265.WarnMsg
  5298. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5299. res.Infcode = infocode
  5300. } else {
  5301. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5302. utils.ErrorLog("解析失败:%v", err)
  5303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5304. return
  5305. }
  5306. }
  5307. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5308. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5309. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5310. //psn_info, _ := service.GetPsnByPatientId(id)
  5311. bas := strings.Split(psn_info.CardInfo, "|")
  5312. if his.IdCardType == 1 {
  5313. cert_no = bas[2]
  5314. } else if his.IdCardType == 3 {
  5315. cert_no = his.Certno
  5316. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5317. } else {
  5318. cert_no = bas[1]
  5319. }
  5320. //江苏地区国家医保医疗类别
  5321. //职工透析:医疗类别选特殊情况门诊9933
  5322. //居民血透门慢: 医疗类别选门诊慢病1402
  5323. //var med_type string
  5324. //if his.Insutype == "310" {
  5325. // if reg_type == 14 {
  5326. // med_type = "9933"
  5327. // } else if reg_type == 11 {
  5328. // med_type = "11"
  5329. //
  5330. // }
  5331. //} else if his.Insutype == "390" {
  5332. // if reg_type == 14 {
  5333. // med_type = "1402"
  5334. // } else if reg_type == 11 {
  5335. // med_type = "11"
  5336. // }
  5337. //}
  5338. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5339. var api string
  5340. if miConfig.MdtrtareaAdmvs == "320921" {
  5341. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5342. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5343. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5344. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5345. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5346. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5347. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5348. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5349. } else {
  5350. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5351. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5352. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5353. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5354. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5355. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5356. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5357. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5358. }
  5359. resp, requestErr := http.Get(api)
  5360. if requestErr != nil {
  5361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5362. return
  5363. }
  5364. body, ioErr := ioutil.ReadAll(resp.Body)
  5365. if ioErr != nil {
  5366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5368. return
  5369. }
  5370. var respJSON map[string]interface{}
  5371. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5374. return
  5375. }
  5376. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5377. result, _ := json.Marshal(respJSON)
  5378. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5379. utils.ErrorLog("解析失败:%v", err)
  5380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5381. return
  5382. }
  5383. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5384. res.Output = resSeven10265.Output
  5385. res.ErrMsg = resSeven10265.ErrMsg
  5386. res.Cainfo = resSeven10265.Cainfo
  5387. res.WarnMsg = resSeven10265.WarnMsg
  5388. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5389. res.Infcode = infocode
  5390. } else {
  5391. if miConfig.Code == "H15049901371" {
  5392. //赤峰地区国家医保医疗类别
  5393. //职工透析:医疗类别选特殊情况门诊990502
  5394. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5395. var med_type string
  5396. if his.Insutype == "390" {
  5397. if reg_type == 14 {
  5398. med_type = "9933"
  5399. } else if reg_type == 11 {
  5400. med_type = "11"
  5401. }
  5402. } else if his.Insutype == "310" {
  5403. if reg_type == 14 {
  5404. med_type = "990502"
  5405. } else if reg_type == 11 {
  5406. med_type = "11"
  5407. }
  5408. }
  5409. 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)
  5410. } else {
  5411. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  5412. }
  5413. //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)
  5414. var dat map[string]interface{}
  5415. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5416. fmt.Println(dat)
  5417. } else {
  5418. fmt.Println(err)
  5419. }
  5420. saveLog(result2, src_resquest, "2207", "结算")
  5421. userJSONBytes, _ := json.Marshal(dat)
  5422. if miConfig.Code == "H15049901371" {
  5423. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5424. utils.ErrorLog("解析失败:%v", err)
  5425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5426. return
  5427. }
  5428. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5429. res.Output = resSeven10265.Output
  5430. res.ErrMsg = resSeven10265.ErrMsg
  5431. res.Cainfo = resSeven10265.Cainfo
  5432. res.WarnMsg = resSeven10265.WarnMsg
  5433. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5434. res.Infcode = infocode
  5435. } else {
  5436. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5437. utils.ErrorLog("解析失败:%v", err)
  5438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5439. return
  5440. }
  5441. }
  5442. }
  5443. if res.Infcode != 0 {
  5444. errlog := &models.HisOrderError{
  5445. UserOrgId: adminUser.CurrentOrgId,
  5446. Ctime: time.Now().Unix(),
  5447. Mtime: time.Now().Unix(),
  5448. Number: chrg_bchno,
  5449. ErrMsg: res.ErrMsg,
  5450. Status: 1,
  5451. PatientId: id,
  5452. RecordTime: recordDateTime,
  5453. Stage: 6,
  5454. }
  5455. service.CreateErrMsgLog(errlog)
  5456. c.ServeSuccessJSON(map[string]interface{}{
  5457. "failed_code": -10,
  5458. "msg": res.ErrMsg,
  5459. })
  5460. return
  5461. } else {
  5462. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5463. order.OrderStatus = 2
  5464. order.Status = 1
  5465. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5466. order.SetlId = res.Output.Setlinfo.SetlID
  5467. order.PsnNo = res.Output.Setlinfo.PsnNo
  5468. order.PsnName = res.Output.Setlinfo.PsnName
  5469. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5470. order.Certno = res.Output.Setlinfo.Certno
  5471. order.Gend = res.Output.Setlinfo.Gend
  5472. order.Naty = res.Output.Setlinfo.Naty
  5473. order.Age = res.Output.Setlinfo.Age
  5474. order.Insutype = res.Output.Setlinfo.Insutype
  5475. order.PsnType = res.Output.Setlinfo.PsnType
  5476. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5477. order.SetlTime = res.Output.Setlinfo.SetlTime
  5478. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5479. if res.Output.Setlinfo.MedType == "140101" {
  5480. order.MedType = "14"
  5481. } else {
  5482. order.MedType = res.Output.Setlinfo.MedType
  5483. }
  5484. if reg_type == 1112 {
  5485. order.MedType = "1112"
  5486. }
  5487. if reg_type == 1111 {
  5488. order.MedType = "1111"
  5489. }
  5490. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5491. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5492. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5493. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5494. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5495. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5496. order.HifpPay = res.Output.Setlinfo.HifpPay
  5497. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5498. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5499. order.HifesPay = res.Output.Setlinfo.HifesPay
  5500. order.HifobPay = res.Output.Setlinfo.HifobPay
  5501. order.MafPay = res.Output.Setlinfo.MafPay
  5502. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5503. order.OthPay = res.Output.Setlinfo.OthPay
  5504. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5505. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5506. order.AcctPay = res.Output.Setlinfo.AcctPay
  5507. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5508. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5509. order.Balc = res.Output.Setlinfo.Balc
  5510. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5511. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5512. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5513. order.ClrType = res.Output.Setlinfo.ClrType
  5514. order.ClrWay = res.Output.Setlinfo.ClrWay
  5515. order.Creator = order.Creator
  5516. order.Modify = roles.AdminUserId
  5517. order.RequestLog = src_resquest
  5518. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5519. detailStr := string(setlDetail)
  5520. order.SetlDetail = detailStr
  5521. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5522. err = service.UpDateOrder(order)
  5523. if err == nil {
  5524. c.ServeSuccessJSON(map[string]interface{}{
  5525. "msg": "结算成功",
  5526. })
  5527. } else {
  5528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5529. return
  5530. }
  5531. }
  5532. } else {
  5533. adminUser := c.GetAdminUserInfo()
  5534. errlog := &models.HisOrderError{
  5535. UserOrgId: adminUser.CurrentOrgId,
  5536. Ctime: time.Now().Unix(),
  5537. Mtime: time.Now().Unix(),
  5538. ErrMsg: res.ErrMsg,
  5539. Status: 1,
  5540. PatientId: id,
  5541. RecordTime: recordDateTime,
  5542. Stage: 4,
  5543. }
  5544. service.CreateErrMsgLog(errlog)
  5545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5546. return
  5547. }
  5548. } else {
  5549. adminUser := c.GetAdminUserInfo()
  5550. errlog := &models.HisOrderError{
  5551. UserOrgId: adminUser.CurrentOrgId,
  5552. Ctime: time.Now().Unix(),
  5553. Mtime: time.Now().Unix(),
  5554. ErrMsg: res.ErrMsg,
  5555. Status: 1,
  5556. PatientId: id,
  5557. RecordTime: recordDateTime,
  5558. Stage: 4,
  5559. }
  5560. service.CreateErrMsgLog(errlog)
  5561. c.ServeSuccessJSON(map[string]interface{}{
  5562. "failed_code": -10,
  5563. "msg": res.ErrMsg,
  5564. })
  5565. return
  5566. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5567. //return
  5568. }
  5569. }
  5570. }
  5571. } else if tempOrder.ID > 0 {
  5572. if tempOrder.IsPre == 1 {
  5573. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5574. var rf []*ResultFive
  5575. json.Unmarshal([]byte(his.Iinfo), &rf)
  5576. chrg_bchno := tempOrder.Number
  5577. cert_no := his.Certno
  5578. var insutypes []string
  5579. var insutype string
  5580. var is390 int = 0
  5581. var is310 int = 0
  5582. for _, item := range rf {
  5583. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5584. insutypes = append(insutypes, item.Insutype)
  5585. }
  5586. }
  5587. if len(insutypes) == 1 {
  5588. insutype = insutypes[0]
  5589. } else {
  5590. for _, i := range insutypes {
  5591. if i == "390" {
  5592. is390 = 1
  5593. }
  5594. if i == "310" {
  5595. is310 = 1
  5596. }
  5597. }
  5598. }
  5599. if is390 == 1 {
  5600. insutype = "390"
  5601. }
  5602. if is310 == 1 {
  5603. insutype = "310"
  5604. }
  5605. if len(insutypes) == 0 {
  5606. insutype = "310"
  5607. }
  5608. if len(insutypes) == 2 {
  5609. insutype = strconv.FormatInt(his.SocialType, 64)
  5610. }
  5611. //insutype = "390"
  5612. if his.IdCardType == 1 {
  5613. // cert_no = his.MedicalInsuranceNumber
  5614. cert_no = his.Certno
  5615. } else {
  5616. cert_no = his.Certno
  5617. }
  5618. var res ResultSeven
  5619. var resSeven10265 ResultSeven10265
  5620. var src_resquest string
  5621. var result2 string
  5622. var acct_used_flag string
  5623. fmt.Println("pay_way")
  5624. fmt.Println(pay_way)
  5625. fmt.Println("pay_way")
  5626. if pay_way == 4 {
  5627. acct_used_flag = "1"
  5628. } else {
  5629. acct_used_flag = "0"
  5630. }
  5631. if miConfig.MdtrtareaAdmvs == "421300" {
  5632. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5633. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5634. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5635. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5636. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5637. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5638. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5639. resp, requestErr := http.Get(api)
  5640. if requestErr != nil {
  5641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5642. return
  5643. }
  5644. body, ioErr := ioutil.ReadAll(resp.Body)
  5645. if ioErr != nil {
  5646. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5648. return
  5649. }
  5650. var respJSON map[string]interface{}
  5651. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5654. return
  5655. }
  5656. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5657. result, _ := json.Marshal(respJSON)
  5658. fmt.Println("log")
  5659. fmt.Println(string(result))
  5660. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5661. utils.ErrorLog("解析失败:%v", err)
  5662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5663. return
  5664. }
  5665. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5666. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5667. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5668. //psn_info, _ := service.GetPsnByPatientId(id)
  5669. bas := strings.Split(psn_info.CardInfo, "|")
  5670. if his.IdCardType == 1 {
  5671. cert_no = bas[2]
  5672. } else {
  5673. cert_no = bas[1]
  5674. }
  5675. //江苏地区国家医保医疗类别
  5676. //职工透析:医疗类别选特殊情况门诊9933
  5677. //居民血透门慢: 医疗类别选门诊慢病1402
  5678. //var med_type string
  5679. //if his.Insutype == "310" {
  5680. // if reg_type == 14 {
  5681. // med_type = "9933"
  5682. // } else if reg_type == 11 {
  5683. // med_type = "11"
  5684. //
  5685. // }
  5686. //} else if his.Insutype == "390" {
  5687. // if reg_type == 14 {
  5688. // med_type = "1402"
  5689. // } else if reg_type == 11 {
  5690. // med_type = "11"
  5691. // }
  5692. //}
  5693. var api string
  5694. if miConfig.MdtrtareaAdmvs == "320921" {
  5695. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5696. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5697. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5698. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5699. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5700. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5701. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5702. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5703. } else {
  5704. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5705. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5706. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5707. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5708. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5709. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5710. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5711. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  5712. }
  5713. resp, requestErr := http.Get(api)
  5714. if requestErr != nil {
  5715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5716. return
  5717. }
  5718. body, ioErr := ioutil.ReadAll(resp.Body)
  5719. if ioErr != nil {
  5720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5722. return
  5723. }
  5724. var respJSON map[string]interface{}
  5725. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5728. return
  5729. }
  5730. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5731. result, _ := json.Marshal(respJSON)
  5732. fmt.Println("log")
  5733. fmt.Println(string(result))
  5734. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5735. utils.ErrorLog("解析失败:%v", err)
  5736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5737. return
  5738. }
  5739. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5740. res.Output = resSeven10265.Output
  5741. res.ErrMsg = resSeven10265.ErrMsg
  5742. res.Cainfo = resSeven10265.Cainfo
  5743. res.WarnMsg = resSeven10265.WarnMsg
  5744. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5745. res.Infcode = infocode
  5746. } else {
  5747. var src_resquest string
  5748. if miConfig.Code == "H15049901371" {
  5749. //赤峰地区国家医保医疗类别
  5750. //职工透析:医疗类别选特殊情况门诊990502
  5751. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5752. var med_type string
  5753. if his.Insutype == "390" {
  5754. if reg_type == 14 {
  5755. med_type = "9933"
  5756. } else if reg_type == 11 {
  5757. med_type = "11"
  5758. }
  5759. } else if his.Insutype == "310" {
  5760. if reg_type == 14 {
  5761. med_type = "990502"
  5762. } else if reg_type == 11 {
  5763. med_type = "11"
  5764. }
  5765. }
  5766. 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)
  5767. } else {
  5768. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  5769. }
  5770. var dat map[string]interface{}
  5771. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5772. fmt.Println(dat)
  5773. } else {
  5774. fmt.Println(err)
  5775. }
  5776. saveLog(result2, src_resquest, "2207", "结算")
  5777. userJSONBytes, _ := json.Marshal(dat)
  5778. if miConfig.Code == "H15049901371" {
  5779. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5780. utils.ErrorLog("解析失败:%v", err)
  5781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5782. return
  5783. }
  5784. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5785. res.Output = resSeven10265.Output
  5786. res.ErrMsg = resSeven10265.ErrMsg
  5787. res.Cainfo = resSeven10265.Cainfo
  5788. res.WarnMsg = resSeven10265.WarnMsg
  5789. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5790. res.Infcode = infocode
  5791. } else {
  5792. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5793. utils.ErrorLog("解析失败:%v", err)
  5794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5795. return
  5796. }
  5797. }
  5798. }
  5799. if res.Infcode != 0 {
  5800. errlog := &models.HisOrderError{
  5801. UserOrgId: adminUser.CurrentOrgId,
  5802. Ctime: time.Now().Unix(),
  5803. Mtime: time.Now().Unix(),
  5804. Number: chrg_bchno,
  5805. ErrMsg: res.ErrMsg,
  5806. Status: 1,
  5807. PatientId: id,
  5808. RecordTime: recordDateTime,
  5809. Stage: 6,
  5810. }
  5811. service.CreateErrMsgLog(errlog)
  5812. c.ServeSuccessJSON(map[string]interface{}{
  5813. "failed_code": -10,
  5814. "msg": res.ErrMsg,
  5815. })
  5816. return
  5817. } else {
  5818. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5819. order.OrderStatus = 2
  5820. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5821. order.SetlId = res.Output.Setlinfo.SetlID
  5822. order.PsnNo = res.Output.Setlinfo.PsnNo
  5823. order.PsnName = res.Output.Setlinfo.PsnName
  5824. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5825. order.Certno = res.Output.Setlinfo.Certno
  5826. order.Gend = res.Output.Setlinfo.Gend
  5827. order.Naty = res.Output.Setlinfo.Naty
  5828. order.Age = res.Output.Setlinfo.Age
  5829. order.Insutype = res.Output.Setlinfo.Insutype
  5830. order.PsnType = res.Output.Setlinfo.PsnType
  5831. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5832. order.SetlTime = res.Output.Setlinfo.SetlTime
  5833. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5834. //order.MedType = res.Output.Setlinfo.MedType
  5835. if reg_type == 1112 {
  5836. order.MedType = "1112"
  5837. }
  5838. if reg_type == 1111 {
  5839. order.MedType = "1111"
  5840. }
  5841. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5842. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5843. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5844. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5845. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5846. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5847. order.HifpPay = res.Output.Setlinfo.HifpPay
  5848. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5849. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5850. order.HifesPay = res.Output.Setlinfo.HifesPay
  5851. order.HifobPay = res.Output.Setlinfo.HifobPay
  5852. order.MafPay = res.Output.Setlinfo.MafPay
  5853. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5854. order.OthPay = res.Output.Setlinfo.OthPay
  5855. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5856. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5857. order.AcctPay = res.Output.Setlinfo.AcctPay
  5858. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5859. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5860. order.Balc = res.Output.Setlinfo.Balc
  5861. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5862. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5863. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5864. order.ClrWay = res.Output.Setlinfo.ClrWay
  5865. order.Creator = order.Creator
  5866. order.Modify = roles.AdminUserId
  5867. order.RequestLog = src_resquest
  5868. order.Diagnosis = diagnosis_id
  5869. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5870. detailStr := string(setlDetail)
  5871. order.SetlDetail = detailStr
  5872. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5873. err = service.UpDateOrder(order)
  5874. if err == nil {
  5875. c.ServeSuccessJSON(map[string]interface{}{
  5876. "msg": "结算成功",
  5877. })
  5878. } else {
  5879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5880. return
  5881. }
  5882. }
  5883. }
  5884. }
  5885. }
  5886. //func (c *HisApiController) GetPreUploadInfo() {
  5887. // id, _ := c.GetInt64("id")
  5888. // record_time := c.GetString("record_time")
  5889. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5890. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5891. //
  5892. // timeLayout := "2006-01-02"
  5893. // loc, _ := time.LoadLocation("Local")
  5894. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5895. // if err != nil {
  5896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5897. // return
  5898. // }
  5899. // recordDateTime := theTime.Unix()
  5900. // adminUser := c.GetAdminUserInfo()
  5901. //
  5902. // var prescriptions []*models.HisPrescription
  5903. //
  5904. // var start_time int64
  5905. // var end_time int64
  5906. //
  5907. // data := make(map[string]interface{})
  5908. // if settle_accounts_type == 1 { //日结
  5909. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5910. // data["pre"] = prescriptions
  5911. //
  5912. // } else { //月结
  5913. // start_time_str := c.GetString("start_time")
  5914. // end_time_str := c.GetString("end_time")
  5915. // timeLayout := "2006-01-02"
  5916. // loc, _ := time.LoadLocation("Local")
  5917. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5918. // if err != nil {
  5919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5920. // return
  5921. // }
  5922. // recordStartTime := theStartTime.Unix()
  5923. // start_time = recordStartTime
  5924. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5925. // if err != nil {
  5926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5927. // return
  5928. // }
  5929. // recordEndTime := theEndTime.Unix()
  5930. // end_time = recordEndTime
  5931. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5932. // data["pre"] = prescriptions
  5933. //
  5934. // }
  5935. //
  5936. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5937. //
  5938. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5939. // timestamp := time.Now().Unix()
  5940. // tempTime := time.Unix(timestamp, 0)
  5941. // timeFormat := tempTime.Format("20060102150405")
  5942. // chrgBchno := rand.Intn(100000) + 10000
  5943. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5944. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5945. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5946. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5947. // strconv.FormatInt(his.PatientId, 10)
  5948. // client := &http.Client{}
  5949. // data["psn_no"] = his.PsnNo
  5950. // data["mdtrt_id"] = his.Number
  5951. // data["chrg_bchno"] = chrg_bchno
  5952. // data["org_name"] = miConfig.OrgName
  5953. // data["doctor"] = roles.UserName
  5954. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5955. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5956. // data["fixmedins_code"] = miConfig.Code
  5957. // data["dept_code"] = department.Number
  5958. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5959. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5960. // data["secret_key"] = miConfig.SecretKey
  5961. // var ids []int64
  5962. //
  5963. // for _, item := range prescriptions {
  5964. // ids = append(ids, item.ID)
  5965. // }
  5966. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5967. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5968. // bytesData, _ := json.Marshal(data)
  5969. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5970. // resp, _ := client.Do(req)
  5971. // defer resp.Body.Close()
  5972. // body, ioErr := ioutil.ReadAll(resp.Body)
  5973. // if ioErr != nil {
  5974. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5975. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5976. // return
  5977. // }
  5978. // var respJSON map[string]interface{}
  5979. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5980. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5981. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5982. // return
  5983. // }
  5984. //
  5985. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5986. // userJSONBytes, _ := json.Marshal(respJSON)
  5987. // var res ResultFour
  5988. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5989. // utils.ErrorLog("解析失败:%v", err)
  5990. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5991. // return
  5992. // }
  5993. //
  5994. // if res.Infcode == 0 {
  5995. // order := &models.HisOrder{
  5996. // UserOrgId: adminUser.CurrentOrgId,
  5997. // HisPatientId: his.ID,
  5998. // PatientId: his.PatientId,
  5999. // SettleAccountsDate: recordDateTime,
  6000. // Ctime: time.Now().Unix(),
  6001. // Mtime: time.Now().Unix(),
  6002. // Status: 1,
  6003. // Number: chrg_bchno,
  6004. // Infcode: res.Infcode,
  6005. // WarnMsg: res.WarnMsg,
  6006. // Cainfo: res.Cainfo,
  6007. // ErrMsg: res.ErrMsg,
  6008. // RespondTime: res.RefmsgTime,
  6009. // InfRefmsgid: res.InfRefmsgid,
  6010. // OrderStatus: 1,
  6011. // IsMedicineInsurance: 1,
  6012. // SettleType: settle_accounts_type,
  6013. // SettleStartTime: start_time,
  6014. // SettleEndTime: end_time,
  6015. // Creator: roles.ID,
  6016. // Modify: roles.ID,
  6017. // PType: 2,
  6018. // }
  6019. // err = service.CreateOrder(order)
  6020. // if err != nil {
  6021. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6022. // return
  6023. // }
  6024. //
  6025. // for _, item := range res.Output.Result {
  6026. // temp := strings.Split(item.FeedetlSn, "-")
  6027. // var advice_id int64 = 0
  6028. // var project_id int64 = 0
  6029. // var types int64 = 0
  6030. //
  6031. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6032. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6033. //
  6034. // if temp[1] == "1" {
  6035. // advice_id = id
  6036. // project_id = 0
  6037. // } else if temp[1] == "2" {
  6038. // advice_id = 0
  6039. // project_id = id
  6040. // }
  6041. //
  6042. // info := &models.HisOrderInfo{
  6043. // OrderNumber: order.Number,
  6044. // FeedetlSn: item.FeedetlSn,
  6045. // UploadDate: time.Now().Unix(),
  6046. // AdviceId: advice_id,
  6047. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6048. // Cnt: item.Cnt,
  6049. // Pric: float64(item.Pric),
  6050. // PatientId: his.PatientId,
  6051. // PricUplmtAmt: item.PricUplmtAmt,
  6052. // SelfpayProp: item.SelfpayProp,
  6053. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6054. // OverlmtAmt: item.OverlmtAmt,
  6055. // PreselfpayAmt: item.PreselfpayAmt,
  6056. // BasMednFlag: item.BasMednFlag,
  6057. // MedChrgitmType: item.MedChrgitmType,
  6058. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6059. // Status: 1,
  6060. // Memo: item.Memo,
  6061. // Mtime: time.Now().Unix(),
  6062. // InscpScpAmt: item.InscpScpAmt,
  6063. // DrtReimFlag: item.DrtReimFlag,
  6064. // Ctime: time.Now().Unix(),
  6065. // ListSpItemFlag: item.ListSpItemFlag,
  6066. // ChldMedcFlag: item.ChldMedcFlag,
  6067. // LmtUsedFlag: item.LmtUsedFlag,
  6068. // ChrgitmLv: item.ChrgitmLv,
  6069. // UserOrgId: adminUser.CurrentOrgId,
  6070. // HisPatientId: his.ID,
  6071. // OrderId: order.ID,
  6072. // ProjectId: project_id,
  6073. // Type: types,
  6074. // }
  6075. // service.CreateOrderInfo(info)
  6076. //
  6077. // }
  6078. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6079. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6080. //
  6081. // var total float64
  6082. // for _, item := range prescriptions {
  6083. // if item.Type == 1 { //药品
  6084. // for _, subItem := range item.HisDoctorAdviceInfo {
  6085. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6086. // }
  6087. // }
  6088. // if item.Type == 2 { //项目
  6089. // for _, subItem := range item.HisPrescriptionProject {
  6090. // total = total + (subItem.Price * float64(subItem.Count))
  6091. // }
  6092. // }
  6093. // }
  6094. //
  6095. // for _, item := range prescriptions {
  6096. // for _, subItem := range item.HisAdditionalCharge {
  6097. // total = total + (subItem.Price * float64(subItem.Count))
  6098. // }
  6099. // }
  6100. //
  6101. // allTotal := fmt.Sprintf("%.2f", total)
  6102. // if res.Infcode == 0 {
  6103. // var rf []*ResultFive
  6104. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6105. // psn_no := his.PsnNo
  6106. // mdtrt_id := his.Number
  6107. // chrg_bchno := chrg_bchno
  6108. // cert_no := his.Certno
  6109. // insutype := rf[0].Insutype
  6110. //
  6111. // if his.IdCardType == 1 {
  6112. // cert_no = his.MedicalInsuranceNumber
  6113. //
  6114. // } else {
  6115. //
  6116. // cert_no = his.Certno
  6117. //
  6118. // }
  6119. //
  6120. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6121. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6122. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6123. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6124. // resp, requestErr := http.Get(api)
  6125. // if requestErr != nil {
  6126. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6127. // return
  6128. // }
  6129. // defer resp.Body.Close()
  6130. // body, ioErr := ioutil.ReadAll(resp.Body)
  6131. // if ioErr != nil {
  6132. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6133. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6134. // return
  6135. // }
  6136. // var respJSON map[string]interface{}
  6137. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6138. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6139. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6140. // return
  6141. // }
  6142. // fmt.Println(respJSON)
  6143. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6144. // userJSONBytes, _ := json.Marshal(respJSON)
  6145. // var res ResultSeven
  6146. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6147. // utils.ErrorLog("解析失败:%v", err)
  6148. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6149. // return
  6150. // }
  6151. // if res.Infcode != 0 {
  6152. // errlog := &models.HisOrderError{
  6153. // UserOrgId: adminUser.CurrentOrgId,
  6154. // Ctime: time.Now().Unix(),
  6155. // Mtime: time.Now().Unix(),
  6156. // Number: chrg_bchno,
  6157. // ErrMsg: res.ErrMsg,
  6158. // Status: 1,
  6159. // PatientId: id,
  6160. // RecordTime: recordDateTime,
  6161. // Stage: 7,
  6162. // }
  6163. // service.CreateErrMsgLog(errlog)
  6164. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6165. // return
  6166. // } else {
  6167. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6168. // order.OrderStatus = 1
  6169. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6170. // order.SetlId = res.Output.Setlinfo.SetlID
  6171. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6172. // order.PsnName = res.Output.Setlinfo.PsnName
  6173. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6174. // order.Certno = res.Output.Setlinfo.Certno
  6175. // order.Gend = res.Output.Setlinfo.Gend
  6176. // order.Naty = res.Output.Setlinfo.Naty
  6177. // order.Age = res.Output.Setlinfo.Age
  6178. // order.Insutype = res.Output.Setlinfo.Insutype
  6179. // order.PsnType = res.Output.Setlinfo.PsnType
  6180. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6181. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6182. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6183. // order.MedType = res.Output.Setlinfo.MedType
  6184. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6185. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6186. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6187. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6188. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6189. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6190. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6191. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6192. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6193. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6194. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6195. // order.MafPay = res.Output.Setlinfo.MafPay
  6196. // order.OthPay = res.Output.Setlinfo.OthPay
  6197. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6198. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6199. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6200. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6201. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6202. // order.Balc = res.Output.Setlinfo.Balc
  6203. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6204. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6205. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6206. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6207. // order.Creator = order.Creator
  6208. // order.Modify = roles.ID
  6209. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6210. // detailStr := string(setlDetail)
  6211. // order.SetlDetail = detailStr
  6212. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6213. // err = service.UpDateOrder(order)
  6214. // if err == nil {
  6215. // c.ServeSuccessJSON(map[string]interface{}{
  6216. // "msg": "预结算成功",
  6217. // })
  6218. // } else {
  6219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6220. // return
  6221. // }
  6222. // }
  6223. // } else {
  6224. // adminUser := c.GetAdminUserInfo()
  6225. // errlog := &models.HisOrderError{
  6226. // UserOrgId: adminUser.CurrentOrgId,
  6227. // Ctime: time.Now().Unix(),
  6228. // Mtime: time.Now().Unix(),
  6229. // ErrMsg: res.ErrMsg,
  6230. // Status: 1,
  6231. // PatientId: id,
  6232. // RecordTime: recordDateTime,
  6233. // Stage: 4,
  6234. // }
  6235. // service.CreateErrMsgLog(errlog)
  6236. //
  6237. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6238. // return
  6239. // }
  6240. // } else {
  6241. // adminUser := c.GetAdminUserInfo()
  6242. // errlog := &models.HisOrderError{
  6243. // UserOrgId: adminUser.CurrentOrgId,
  6244. // Ctime: time.Now().Unix(),
  6245. // Mtime: time.Now().Unix(),
  6246. // ErrMsg: res.ErrMsg,
  6247. // Status: 1,
  6248. // PatientId: id,
  6249. // RecordTime: recordDateTime,
  6250. // Stage: 4,
  6251. // }
  6252. // service.CreateErrMsgLog(errlog)
  6253. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6254. // return
  6255. // }
  6256. //
  6257. // } else {
  6258. // var total float64
  6259. // for _, item := range prescriptions {
  6260. // if item.Type == 1 { //药品
  6261. // for _, subItem := range item.HisDoctorAdviceInfo {
  6262. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6263. // }
  6264. // }
  6265. // if item.Type == 2 { //项目
  6266. // for _, subItem := range item.HisPrescriptionProject {
  6267. // total = total + (subItem.Price * float64(subItem.Count))
  6268. // }
  6269. // }
  6270. //
  6271. // for _, subItem := range item.HisAdditionalCharge {
  6272. // total = total + (subItem.Price * float64(subItem.Count))
  6273. // }
  6274. // }
  6275. //
  6276. // allTotal := fmt.Sprintf("%.2f", total)
  6277. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6278. // order := &models.HisOrder{
  6279. // UserOrgId: adminUser.CurrentOrgId,
  6280. // HisPatientId: his.ID,
  6281. // PatientId: id,
  6282. // SettleAccountsDate: recordDateTime,
  6283. // Ctime: time.Now().Unix(),
  6284. // Mtime: time.Now().Unix(),
  6285. // Status: 1,
  6286. // OrderStatus: 2,
  6287. // Number: chrg_bchno,
  6288. // MedfeeSumamt: totals,
  6289. // }
  6290. // err = service.CreateOrder(order)
  6291. // if err != nil {
  6292. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6293. // return
  6294. // }
  6295. //
  6296. // var customs []*Custom
  6297. // for _, item := range prescriptions {
  6298. //
  6299. // if item.Type == 1 { //药品
  6300. // for _, subItem := range item.HisDoctorAdviceInfo {
  6301. // cus := &Custom{
  6302. // AdviceId: subItem.ID,
  6303. // ProjectId: 0,
  6304. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6305. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6306. // FeedetlSn: subItem.FeedetlSn,
  6307. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6308. // MedListCodg: subItem.MedListCodg,
  6309. // Type: 1,
  6310. // }
  6311. // customs = append(customs, cus)
  6312. // }
  6313. // }
  6314. //
  6315. // if item.Type == 2 { //项目
  6316. // for _, subItem := range item.HisPrescriptionProject {
  6317. //
  6318. // cus := &Custom{
  6319. // AdviceId: 0,
  6320. // ProjectId: subItem.ID,
  6321. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6322. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6323. // FeedetlSn: subItem.FeedetlSn,
  6324. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6325. // MedListCodg: subItem.MedListCodg,
  6326. // Type: 2,
  6327. // }
  6328. //
  6329. // customs = append(customs, cus)
  6330. // }
  6331. // }
  6332. //
  6333. // for _, item := range item.HisAdditionalCharge {
  6334. // cus := &Custom{
  6335. // ItemId: item.ID,
  6336. // AdviceId: 0,
  6337. // ProjectId: 0,
  6338. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6339. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6340. // FeedetlSn: item.FeedetlSn,
  6341. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6342. // MedListCodg: item.XtHisAddtionConfig.Code,
  6343. // Type: 3,
  6344. // }
  6345. //
  6346. // customs = append(customs, cus)
  6347. // }
  6348. //
  6349. // }
  6350. //
  6351. // for _, item := range customs {
  6352. // var advice_id int64 = 0
  6353. // var project_id int64 = 0
  6354. // var item_id int64 = 0
  6355. //
  6356. // var types int64 = 0
  6357. //
  6358. // if item.Type == 1 {
  6359. // advice_id = item.AdviceId
  6360. // project_id = 0
  6361. // item_id = 0
  6362. // } else if item.Type == 2 {
  6363. // advice_id = 0
  6364. // item_id = 0
  6365. //
  6366. // project_id = item.ProjectId
  6367. // } else if item.Type == 3 {
  6368. // advice_id = 0
  6369. // item_id = item.ItemId
  6370. // project_id = 0
  6371. // }
  6372. //
  6373. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6374. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6375. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6376. //
  6377. // info := &models.HisOrderInfo{
  6378. // OrderNumber: order.Number,
  6379. // UploadDate: time.Now().Unix(),
  6380. // AdviceId: advice_id,
  6381. // DetItemFeeSumamt: detItemFeeSumamt,
  6382. // Cnt: cut,
  6383. // Pric: pric,
  6384. // PatientId: id,
  6385. // Status: 1,
  6386. // Mtime: time.Now().Unix(),
  6387. // Ctime: time.Now().Unix(),
  6388. // UserOrgId: adminUser.CurrentOrgId,
  6389. // HisPatientId: his.ID,
  6390. // OrderId: order.ID,
  6391. // ProjectId: project_id,
  6392. // Type: types,
  6393. // ItemId: item_id,
  6394. // }
  6395. // service.CreateOrderInfo(info)
  6396. // }
  6397. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6398. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6399. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6400. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6401. // if err == nil {
  6402. // c.ServeSuccessJSON(map[string]interface{}{
  6403. // "msg": "结算成功",
  6404. // })
  6405. // } else {
  6406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6407. // return
  6408. // }
  6409. // }
  6410. //}
  6411. //上传明细-预结算-
  6412. func (c *HisApiController) GetPreUploadInfo() {
  6413. id, _ := c.GetInt64("id")
  6414. record_time := c.GetString("record_time")
  6415. his_patient_id, _ := c.GetInt64("his_patient_id")
  6416. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6417. admin_user_id, _ := c.GetInt64("admin_user_id")
  6418. diagnosis_id := c.GetString("diagnosis")
  6419. sick_type, _ := c.GetInt64("sick_type")
  6420. reg_type, _ := c.GetInt64("p_type")
  6421. begin_time := c.GetString("begin_time")
  6422. id_str := c.GetString("ids")
  6423. ids_arr := strings.Split(id_str, ",")
  6424. timeLayout := "2006-01-02"
  6425. loc, _ := time.LoadLocation("Local")
  6426. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6427. if err != nil {
  6428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6429. return
  6430. }
  6431. recordDateTime := theTime.Unix()
  6432. adminUser := c.GetAdminUserInfo()
  6433. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6434. var config []*models.HisXtDiagnoseConfig
  6435. for _, item := range diagnosis_ids {
  6436. id, _ := strconv.ParseInt(item, 10, 64)
  6437. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6438. config = append(config, &diagnosisConfig)
  6439. }
  6440. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6441. sickConfig, _ := service.FindSickById(sick_type)
  6442. var prescriptions []*models.HisPrescription
  6443. var start_time int64
  6444. var end_time int64
  6445. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6446. fmt.Println(his_patient_id)
  6447. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6448. timestamp := time.Now().Unix()
  6449. tempTime := time.Unix(timestamp, 0)
  6450. timeFormat := tempTime.Format("20060102150405")
  6451. chrgBchno := rand.Intn(100000) + 10000
  6452. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6453. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6454. var patientPrescription models.HisPrescriptionInfo
  6455. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6456. if patientPrescription.ID == 0 {
  6457. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6458. }
  6459. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6460. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6461. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6462. strconv.FormatInt(his.PatientId, 10)
  6463. var res2 ResultSix
  6464. var resSix10265 ResultSix10265
  6465. var time_stamp string
  6466. if miConfig.MdtrtareaAdmvs == "421300" {
  6467. data := make(map[string]interface{})
  6468. client := &http.Client{}
  6469. data["psn_no"] = his.PsnNo
  6470. data["mdtrt_id"] = his.Number
  6471. data["doctor"] = roles.UserName
  6472. data["department"] = department.Name
  6473. data["org_name"] = miConfig.OrgName
  6474. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6475. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6476. data["fixmedins_code"] = miConfig.Code
  6477. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6478. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6479. data["secret_key"] = miConfig.SecretKey
  6480. data["sick_code"] = sickConfig.CountryCode
  6481. data["sick_name"] = sickConfig.ClassName
  6482. data["begin_time"] = begin_time
  6483. data["dept"] = strconv.FormatInt(department.ID, 10)
  6484. data["config"] = config
  6485. fmt.Println(data)
  6486. bytesData, _ := json.Marshal(data)
  6487. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6488. resp, _ := client.Do(req)
  6489. defer resp.Body.Close()
  6490. body, ioErr := ioutil.ReadAll(resp.Body)
  6491. if ioErr != nil {
  6492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6494. return
  6495. }
  6496. var respJSON map[string]interface{}
  6497. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6500. return
  6501. }
  6502. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6503. userJSONBytes, _ := json.Marshal(respJSON)
  6504. fmt.Println("log")
  6505. fmt.Println(string(userJSONBytes))
  6506. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6507. utils.ErrorLog("解析失败:%v", err)
  6508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6509. return
  6510. }
  6511. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6512. //江苏地区国家医保医疗类别
  6513. //职工透析:医疗类别选特殊情况门诊9933
  6514. //居民血透门慢: 医疗类别选门诊慢病1402
  6515. //var med_type string
  6516. //if his.Insutype == "310" {
  6517. // if reg_type == 14 {
  6518. // med_type = "9933"
  6519. // } else if reg_type == 11 {
  6520. // med_type = "11"
  6521. //
  6522. // }
  6523. //} else if his.Insutype == "390" {
  6524. // if reg_type == 14 {
  6525. // med_type = "1402"
  6526. // } else if reg_type == 11 {
  6527. // med_type = "11"
  6528. // }
  6529. //}
  6530. data := make(map[string]interface{})
  6531. client := &http.Client{}
  6532. data["psn_no"] = his.PsnNo
  6533. data["mdtrt_id"] = his.Number
  6534. data["doctor"] = roles.UserName
  6535. data["department"] = department.Name
  6536. data["org_name"] = miConfig.OrgName
  6537. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6538. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6539. data["fixmedins_code"] = miConfig.Code
  6540. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6541. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6542. data["secret_key"] = miConfig.SecretKey
  6543. data["sick_code"] = sickConfig.CountryCode
  6544. data["sick_name"] = sickConfig.ClassName
  6545. data["begin_time"] = begin_time
  6546. data["dept"] = strconv.FormatInt(department.ID, 10)
  6547. data["config"] = config
  6548. data["url"] = miConfig.Url
  6549. data["ak"] = miConfig.AccessKey
  6550. data["cainfo"] = miConfig.Cainfo
  6551. bytesData, _ := json.Marshal(data)
  6552. var req *http.Request
  6553. if miConfig.MdtrtareaAdmvs == "320921" {
  6554. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6555. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6556. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6557. } else {
  6558. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6559. }
  6560. resp, _ := client.Do(req)
  6561. defer resp.Body.Close()
  6562. body, ioErr := ioutil.ReadAll(resp.Body)
  6563. if ioErr != nil {
  6564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6566. return
  6567. }
  6568. var respJSON map[string]interface{}
  6569. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6572. return
  6573. }
  6574. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6575. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6576. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6578. userJSONBytes, _ := json.Marshal(respJSON)
  6579. fmt.Println("log")
  6580. fmt.Println(string(userJSONBytes))
  6581. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6582. utils.ErrorLog("解析失败:%v", err)
  6583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6584. return
  6585. }
  6586. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6587. res2.Output = resSix10265.Output
  6588. res2.ErrMsg = resSix10265.ErrMsg
  6589. res2.Cainfo = resSix10265.Cainfo
  6590. res2.WarnMsg = resSix10265.WarnMsg
  6591. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6592. res2.Infcode = infocode
  6593. } else {
  6594. var result string
  6595. var requestLog string
  6596. if miConfig.MdtrtareaAdmvs == "440781" { //
  6597. 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)
  6598. } else {
  6599. if miConfig.Code == "H15049901371" {
  6600. //赤峰地区国家医保医疗类别
  6601. //职工透析:医疗类别选特殊情况门诊990502
  6602. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6603. var med_type string
  6604. if his.Insutype == "390" {
  6605. if reg_type == 14 {
  6606. med_type = "9933"
  6607. } else if reg_type == 11 {
  6608. med_type = "11"
  6609. }
  6610. } else if his.Insutype == "310" {
  6611. if reg_type == 14 {
  6612. med_type = "990502"
  6613. } else if reg_type == 11 {
  6614. med_type = "11"
  6615. }
  6616. }
  6617. 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)
  6618. } else {
  6619. 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)
  6620. }
  6621. saveLog(result, requestLog, "2203", "上传就诊信息")
  6622. var respJSON2 map[string]interface{}
  6623. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6626. return
  6627. }
  6628. userJSONBytes2, _ := json.Marshal(respJSON2)
  6629. if miConfig.Code == "H15049901371" {
  6630. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6631. utils.ErrorLog("解析失败:%v", err)
  6632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6633. return
  6634. }
  6635. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6636. res2.Output = resSix10265.Output
  6637. res2.ErrMsg = resSix10265.ErrMsg
  6638. res2.Cainfo = resSix10265.Cainfo
  6639. res2.WarnMsg = resSix10265.WarnMsg
  6640. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6641. res2.Infcode = infocode
  6642. } else {
  6643. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6644. utils.ErrorLog("解析失败:%v", err)
  6645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6646. return
  6647. }
  6648. }
  6649. }
  6650. }
  6651. if res2.Infcode != 0 {
  6652. adminUser := c.GetAdminUserInfo()
  6653. errlog := &models.HisOrderError{
  6654. UserOrgId: adminUser.CurrentOrgId,
  6655. Ctime: time.Now().Unix(),
  6656. Mtime: time.Now().Unix(),
  6657. ErrMsg: res2.ErrMsg,
  6658. Status: 1,
  6659. PatientId: id,
  6660. RecordTime: recordDateTime,
  6661. Stage: 3,
  6662. }
  6663. service.CreateErrMsgLog(errlog)
  6664. c.ServeSuccessJSON(map[string]interface{}{
  6665. "failed_code": -10,
  6666. "msg": res2.ErrMsg,
  6667. })
  6668. return
  6669. } else {
  6670. his.Diagnosis = diagnosis_id
  6671. his.SickType = sickConfig.ID
  6672. his.PType = fmt.Sprintf("%d", reg_type)
  6673. service.UpdateHisPatientThree(&his)
  6674. data := make(map[string]interface{})
  6675. if settle_accounts_type == 1 { //日结
  6676. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6677. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6678. } else {
  6679. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6680. }
  6681. data["pre"] = prescriptions
  6682. } else { //月结
  6683. start_time_str := c.GetString("start_time")
  6684. end_time_str := c.GetString("end_time")
  6685. timeLayout := "2006-01-02"
  6686. loc, _ := time.LoadLocation("Local")
  6687. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6688. if err != nil {
  6689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6690. return
  6691. }
  6692. recordStartTime := theStartTime.Unix()
  6693. start_time = recordStartTime
  6694. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6695. if err != nil {
  6696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6697. return
  6698. }
  6699. recordEndTime := theEndTime.Unix()
  6700. end_time = recordEndTime
  6701. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6702. data["pre"] = prescriptions
  6703. }
  6704. client := &http.Client{}
  6705. data["psn_no"] = his.PsnNo
  6706. data["mdtrt_id"] = his.Number
  6707. data["chrg_bchno"] = chrg_bchno
  6708. data["org_name"] = miConfig.OrgName
  6709. data["doctor"] = roles.UserName
  6710. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6711. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6712. data["fixmedins_code"] = miConfig.Code
  6713. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6714. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6715. data["dept_code"] = "15"
  6716. } else {
  6717. data["dept_code"] = department.Number
  6718. }
  6719. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6720. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6721. data["secret_key"] = miConfig.SecretKey
  6722. data["url"] = miConfig.Url
  6723. data["ak"] = miConfig.AccessKey
  6724. data["new_doctor_name"] = patientPrescription.Doctor
  6725. data["diag_code"] = sickConfig.CountryCode
  6726. data["time_stamp"] = time_stamp
  6727. data["cainfo"] = miConfig.Cainfo
  6728. var ids []int64
  6729. for _, item := range prescriptions {
  6730. ids = append(ids, item.ID)
  6731. }
  6732. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6733. if config.IsOpen == 1 { //对接了医保,走医保流程
  6734. var res ResultFour
  6735. var resFour10265 ResultFour10265
  6736. if miConfig.MdtrtareaAdmvs == "421300" {
  6737. bytesData, _ := json.Marshal(data)
  6738. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6739. resp, _ := client.Do(req)
  6740. defer resp.Body.Close()
  6741. body, ioErr := ioutil.ReadAll(resp.Body)
  6742. if ioErr != nil {
  6743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6745. return
  6746. }
  6747. var respJSON map[string]interface{}
  6748. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6751. return
  6752. }
  6753. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6754. userJSONBytes, _ := json.Marshal(respJSON)
  6755. fmt.Println("log")
  6756. fmt.Println(string(userJSONBytes))
  6757. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6758. utils.ErrorLog("解析失败:%v", err)
  6759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6760. return
  6761. }
  6762. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6763. bytesData, _ := json.Marshal(data)
  6764. var req *http.Request
  6765. if miConfig.MdtrtareaAdmvs == "320921" {
  6766. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6767. } else {
  6768. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6769. }
  6770. resp, _ := client.Do(req)
  6771. defer resp.Body.Close()
  6772. body, ioErr := ioutil.ReadAll(resp.Body)
  6773. if ioErr != nil {
  6774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6776. return
  6777. }
  6778. var respJSON map[string]interface{}
  6779. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6782. return
  6783. }
  6784. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6785. userJSONBytes, _ := json.Marshal(respJSON)
  6786. fmt.Println("log")
  6787. fmt.Println(string(userJSONBytes))
  6788. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6789. utils.ErrorLog("解析失败:%v", err)
  6790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6791. return
  6792. }
  6793. res.InfRefmsgid = resFour10265.InfRefmsgid
  6794. res.Output = resFour10265.Output
  6795. res.ErrMsg = resFour10265.ErrMsg
  6796. res.Cainfo = resFour10265.Cainfo
  6797. res.WarnMsg = resFour10265.WarnMsg
  6798. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6799. res.Infcode = infocode
  6800. } else {
  6801. if miConfig.Code == "H15049901371" {
  6802. 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)
  6803. var dat map[string]interface{}
  6804. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6805. fmt.Println(dat)
  6806. } else {
  6807. fmt.Println(err)
  6808. }
  6809. saveLog(result, request_log, "2204", "上传费用明细")
  6810. userJSONBytes, _ := json.Marshal(dat)
  6811. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6812. utils.ErrorLog("解析失败:%v", err)
  6813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6814. return
  6815. }
  6816. res.InfRefmsgid = resFour10265.InfRefmsgid
  6817. res.Output = resFour10265.Output
  6818. res.ErrMsg = resFour10265.ErrMsg
  6819. res.Cainfo = resFour10265.Cainfo
  6820. res.WarnMsg = resFour10265.WarnMsg
  6821. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6822. res.Infcode = infocode
  6823. } else {
  6824. 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)
  6825. var dat map[string]interface{}
  6826. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6827. fmt.Println(dat)
  6828. } else {
  6829. fmt.Println(err)
  6830. }
  6831. saveLog(result, request_log, "2204", "上传费用明细")
  6832. userJSONBytes, _ := json.Marshal(dat)
  6833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6834. utils.ErrorLog("解析失败:%v", err)
  6835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6836. return
  6837. }
  6838. }
  6839. }
  6840. if res.Infcode == 0 {
  6841. order := &models.HisOrder{
  6842. UserOrgId: adminUser.CurrentOrgId,
  6843. HisPatientId: his.ID,
  6844. PatientId: his.PatientId,
  6845. SettleAccountsDate: recordDateTime,
  6846. Ctime: time.Now().Unix(),
  6847. Mtime: time.Now().Unix(),
  6848. MdtrtId: his.Number,
  6849. PsnNo: his.PsnNo,
  6850. MedType: strconv.FormatInt(reg_type, 10),
  6851. Status: 1,
  6852. Number: chrg_bchno,
  6853. Infcode: res.Infcode,
  6854. WarnMsg: res.WarnMsg,
  6855. Cainfo: res.Cainfo,
  6856. ErrMsg: res.ErrMsg,
  6857. RespondTime: res.RefmsgTime,
  6858. InfRefmsgid: res.InfRefmsgid,
  6859. OrderStatus: 1,
  6860. IsMedicineInsurance: 1,
  6861. SettleType: settle_accounts_type,
  6862. SettleStartTime: start_time,
  6863. SettleEndTime: end_time,
  6864. Creator: roles.AdminUserId,
  6865. Modify: roles.AdminUserId,
  6866. PType: 2,
  6867. Diagnosis: diagnosis_id,
  6868. }
  6869. err = service.CreateOrder(order)
  6870. if err != nil {
  6871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6872. return
  6873. }
  6874. for _, item := range res.Output.Result {
  6875. temp := strings.Split(item.FeedetlSn, "-")
  6876. var advice_id int64 = 0
  6877. var project_id int64 = 0
  6878. var types int64 = 0
  6879. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6880. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6881. if temp[1] == "1" {
  6882. advice_id = id
  6883. project_id = 0
  6884. } else if temp[1] == "2" {
  6885. advice_id = 0
  6886. project_id = id
  6887. }
  6888. info := &models.HisOrderInfo{
  6889. OrderNumber: order.Number,
  6890. FeedetlSn: item.FeedetlSn,
  6891. UploadDate: time.Now().Unix(),
  6892. AdviceId: advice_id,
  6893. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6894. Cnt: item.Cnt,
  6895. Pric: float64(item.Pric),
  6896. PatientId: his.PatientId,
  6897. PricUplmtAmt: item.PricUplmtAmt,
  6898. SelfpayProp: item.SelfpayProp,
  6899. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6900. OverlmtAmt: item.OverlmtAmt,
  6901. PreselfpayAmt: item.PreselfpayAmt,
  6902. BasMednFlag: item.BasMednFlag,
  6903. MedChrgitmType: item.MedChrgitmType,
  6904. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6905. Status: 1,
  6906. Memo: item.Memo,
  6907. Mtime: time.Now().Unix(),
  6908. InscpScpAmt: item.InscpScpAmt,
  6909. DrtReimFlag: item.DrtReimFlag,
  6910. Ctime: time.Now().Unix(),
  6911. ListSpItemFlag: item.ListSpItemFlag,
  6912. ChldMedcFlag: item.ChldMedcFlag,
  6913. LmtUsedFlag: item.LmtUsedFlag,
  6914. ChrgitmLv: item.ChrgitmLv,
  6915. UserOrgId: adminUser.CurrentOrgId,
  6916. HisPatientId: his.ID,
  6917. OrderId: order.ID,
  6918. ProjectId: project_id,
  6919. Type: types,
  6920. }
  6921. service.CreateOrderInfo(info)
  6922. }
  6923. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6924. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6925. var total float64
  6926. for _, item := range prescriptions {
  6927. if item.Type == 1 { //药品
  6928. for _, subItem := range item.HisDoctorAdviceInfo {
  6929. total = total + (subItem.Price * subItem.PrescribingNumber)
  6930. }
  6931. }
  6932. if item.Type == 2 { //项目
  6933. for _, subItem := range item.HisPrescriptionProject {
  6934. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6935. total = total + (subItem.Price * cnt)
  6936. }
  6937. }
  6938. }
  6939. for _, item := range prescriptions {
  6940. for _, subItem := range item.HisAdditionalCharge {
  6941. total = total + (subItem.Price * float64(subItem.Count))
  6942. }
  6943. }
  6944. allTotal := fmt.Sprintf("%.4f", total)
  6945. if res.Infcode == 0 {
  6946. var rf []*ResultFive
  6947. json.Unmarshal([]byte(his.Iinfo), &rf)
  6948. chrg_bchno := chrg_bchno
  6949. cert_no := his.Certno
  6950. var insutypes []string
  6951. var insutype string
  6952. var is390 int = 0
  6953. var is310 int = 0
  6954. for _, item := range rf {
  6955. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6956. insutypes = append(insutypes, item.Insutype)
  6957. }
  6958. }
  6959. if len(insutypes) == 1 {
  6960. insutype = insutypes[0]
  6961. } else {
  6962. for _, i := range insutypes {
  6963. if i == "390" {
  6964. is390 = 1
  6965. }
  6966. if i == "310" {
  6967. is310 = 1
  6968. }
  6969. }
  6970. }
  6971. if is390 == 1 {
  6972. insutype = "390"
  6973. }
  6974. if is310 == 1 {
  6975. insutype = "310"
  6976. }
  6977. if len(insutypes) == 0 {
  6978. insutype = "310"
  6979. }
  6980. if len(insutypes) == 2 {
  6981. insutype = strconv.FormatInt(his.SocialType, 64)
  6982. }
  6983. //insutype = "390"
  6984. if his.IdCardType == 1 {
  6985. cert_no = his.MedicalInsuranceNumber
  6986. } else {
  6987. cert_no = his.Certno
  6988. }
  6989. var res ResultSeven
  6990. var resSeven10265 ResultSeven10265
  6991. if miConfig.MdtrtareaAdmvs == "421300" {
  6992. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6993. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6994. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6995. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6996. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6997. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6998. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6999. resp, requestErr := http.Get(api)
  7000. if requestErr != nil {
  7001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7002. return
  7003. }
  7004. body, ioErr := ioutil.ReadAll(resp.Body)
  7005. if ioErr != nil {
  7006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7008. return
  7009. }
  7010. var respJSON map[string]interface{}
  7011. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7014. return
  7015. }
  7016. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7017. result, _ := json.Marshal(respJSON)
  7018. fmt.Println("log")
  7019. fmt.Println(string(result))
  7020. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7021. utils.ErrorLog("解析失败:%v", err)
  7022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7023. return
  7024. }
  7025. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7026. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7027. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7028. bas := strings.Split(psn_info.CardInfo, "|")
  7029. if his.IdCardType == 1 {
  7030. cert_no = bas[2]
  7031. } else {
  7032. cert_no = bas[1]
  7033. }
  7034. //江苏地区国家医保医疗类别
  7035. //职工透析:医疗类别选特殊情况门诊9933
  7036. //居民血透门慢: 医疗类别选门诊慢病1402
  7037. //var med_type string
  7038. //if his.Insutype == "310" {
  7039. // if reg_type == 14 {
  7040. // med_type = "9933"
  7041. // } else if reg_type == 11 {
  7042. // med_type = "11"
  7043. //
  7044. // }
  7045. //} else if his.Insutype == "390" {
  7046. // if reg_type == 14 {
  7047. // med_type = "1402"
  7048. // } else if reg_type == 11 {
  7049. // med_type = "11"
  7050. // }
  7051. //}
  7052. var api string
  7053. if miConfig.MdtrtareaAdmvs == "320921" {
  7054. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7055. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7056. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7057. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7058. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7059. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7060. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7061. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7062. } else {
  7063. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7064. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7065. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7066. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7067. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7068. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7069. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7070. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7071. }
  7072. resp, requestErr := http.Get(api)
  7073. if requestErr != nil {
  7074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7075. return
  7076. }
  7077. body, ioErr := ioutil.ReadAll(resp.Body)
  7078. if ioErr != nil {
  7079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7081. return
  7082. }
  7083. var respJSON map[string]interface{}
  7084. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7087. return
  7088. }
  7089. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7090. result, _ := json.Marshal(respJSON)
  7091. fmt.Println("log")
  7092. fmt.Println(string(result))
  7093. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7094. utils.ErrorLog("解析失败:%v", err)
  7095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7096. return
  7097. }
  7098. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7099. res.Output = resSeven10265.Output
  7100. res.ErrMsg = resSeven10265.ErrMsg
  7101. res.Cainfo = resSeven10265.Cainfo
  7102. res.WarnMsg = resSeven10265.WarnMsg
  7103. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7104. res.Infcode = infocode
  7105. } else {
  7106. var result string
  7107. var request_log string
  7108. if miConfig.Code == "H15049901371" {
  7109. //赤峰地区国家医保医疗类别
  7110. //职工透析:医疗类别选特殊情况门诊990502
  7111. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7112. var med_type string
  7113. if his.Insutype == "390" {
  7114. if reg_type == 14 {
  7115. med_type = "9933"
  7116. } else if reg_type == 11 {
  7117. med_type = "11"
  7118. }
  7119. } else if his.Insutype == "310" {
  7120. if reg_type == 14 {
  7121. med_type = "990502"
  7122. } else if reg_type == 11 {
  7123. med_type = "11"
  7124. }
  7125. }
  7126. 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)
  7127. } else {
  7128. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  7129. }
  7130. var dat map[string]interface{}
  7131. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7132. fmt.Println(dat)
  7133. } else {
  7134. fmt.Println(err)
  7135. }
  7136. saveLog(result, request_log, "2206", "预结算")
  7137. //userJSONBytes, _ := json.Marshal(dat)
  7138. //
  7139. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7140. // utils.ErrorLog("解析失败:%v", err)
  7141. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7142. // return
  7143. //}
  7144. userJSONBytes, _ := json.Marshal(dat)
  7145. if miConfig.Code == "H15049901371" {
  7146. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7147. utils.ErrorLog("解析失败:%v", err)
  7148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7149. return
  7150. }
  7151. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7152. res.Output = resSeven10265.Output
  7153. res.ErrMsg = resSeven10265.ErrMsg
  7154. res.Cainfo = resSeven10265.Cainfo
  7155. res.WarnMsg = resSeven10265.WarnMsg
  7156. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7157. res.Infcode = infocode
  7158. } else {
  7159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7160. utils.ErrorLog("解析失败:%v", err)
  7161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7162. return
  7163. }
  7164. }
  7165. }
  7166. if res.Infcode != 0 {
  7167. errlog := &models.HisOrderError{
  7168. UserOrgId: adminUser.CurrentOrgId,
  7169. Ctime: time.Now().Unix(),
  7170. Mtime: time.Now().Unix(),
  7171. Number: chrg_bchno,
  7172. ErrMsg: res.ErrMsg,
  7173. Status: 1,
  7174. PatientId: id,
  7175. RecordTime: recordDateTime,
  7176. Stage: 20,
  7177. }
  7178. service.CreateErrMsgLog(errlog)
  7179. c.ServeSuccessJSON(map[string]interface{}{
  7180. "failed_code": -10,
  7181. "msg": res.ErrMsg,
  7182. })
  7183. return
  7184. } else {
  7185. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7186. order.OrderStatus = 1
  7187. order.IsPre = 1
  7188. order.Status = 1
  7189. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7190. order.SetlId = res.Output.Setlinfo.SetlID
  7191. order.PsnNo = res.Output.Setlinfo.PsnNo
  7192. order.PsnName = res.Output.Setlinfo.PsnName
  7193. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7194. order.Certno = res.Output.Setlinfo.Certno
  7195. order.Gend = res.Output.Setlinfo.Gend
  7196. order.Naty = res.Output.Setlinfo.Naty
  7197. order.Age = res.Output.Setlinfo.Age
  7198. order.Insutype = res.Output.Setlinfo.Insutype
  7199. order.PsnType = res.Output.Setlinfo.PsnType
  7200. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7201. order.SetlTime = res.Output.Setlinfo.SetlTime
  7202. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7203. if res.Output.Setlinfo.MedType == "140101" {
  7204. order.MedType = "14"
  7205. } else {
  7206. order.MedType = res.Output.Setlinfo.MedType
  7207. }
  7208. if reg_type == 1112 {
  7209. order.MedType = "1112"
  7210. }
  7211. if reg_type == 1111 {
  7212. order.MedType = "1111"
  7213. }
  7214. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7215. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7216. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7217. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7218. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7219. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7220. order.HifpPay = res.Output.Setlinfo.HifpPay
  7221. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7222. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7223. order.HifesPay = res.Output.Setlinfo.HifesPay
  7224. order.HifobPay = res.Output.Setlinfo.HifobPay
  7225. order.MafPay = res.Output.Setlinfo.MafPay
  7226. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7227. order.OthPay = res.Output.Setlinfo.OthPay
  7228. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7229. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7230. order.AcctPay = res.Output.Setlinfo.AcctPay
  7231. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7232. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7233. order.Balc = res.Output.Setlinfo.Balc
  7234. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7235. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7236. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7237. order.ClrWay = res.Output.Setlinfo.ClrWay
  7238. order.Creator = order.Creator
  7239. order.Modify = roles.AdminUserId
  7240. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7241. detailStr := string(setlDetail)
  7242. order.SetlDetail = detailStr
  7243. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7244. err = service.UpDateOrder(order)
  7245. if err == nil {
  7246. c.ServeSuccessJSON(map[string]interface{}{
  7247. "msg": "预结算成功",
  7248. })
  7249. } else {
  7250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7251. return
  7252. }
  7253. }
  7254. } else {
  7255. adminUser := c.GetAdminUserInfo()
  7256. errlog := &models.HisOrderError{
  7257. UserOrgId: adminUser.CurrentOrgId,
  7258. Ctime: time.Now().Unix(),
  7259. Mtime: time.Now().Unix(),
  7260. ErrMsg: res.ErrMsg,
  7261. Status: 1,
  7262. PatientId: id,
  7263. RecordTime: recordDateTime,
  7264. Stage: 4,
  7265. }
  7266. service.CreateErrMsgLog(errlog)
  7267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7268. return
  7269. }
  7270. } else {
  7271. adminUser := c.GetAdminUserInfo()
  7272. errlog := &models.HisOrderError{
  7273. UserOrgId: adminUser.CurrentOrgId,
  7274. Ctime: time.Now().Unix(),
  7275. Mtime: time.Now().Unix(),
  7276. ErrMsg: res.ErrMsg,
  7277. Status: 1,
  7278. PatientId: id,
  7279. RecordTime: recordDateTime,
  7280. Stage: 4,
  7281. }
  7282. service.CreateErrMsgLog(errlog)
  7283. c.ServeSuccessJSON(map[string]interface{}{
  7284. "failed_code": -10,
  7285. "msg": res.ErrMsg,
  7286. })
  7287. return
  7288. }
  7289. }
  7290. }
  7291. }
  7292. //func (c *HisApiController) GetSettleInfo() {
  7293. // id, _ := c.GetInt64("id")
  7294. // order_id, _ := c.GetInt64("order_id")
  7295. //
  7296. // record_time := c.GetString("record_time")
  7297. // pay_way, _ := c.GetInt64("pay_way")
  7298. // pay_price, _ := c.GetFloat("pay_price")
  7299. // pay_card_no := c.GetString("pay_card_no")
  7300. // discount_price, _ := c.GetFloat("discount_price")
  7301. // preferential_price, _ := c.GetFloat("preferential_price")
  7302. // reality_price, _ := c.GetFloat("reality_price")
  7303. // found_price, _ := c.GetFloat("found_price")
  7304. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7305. // private_price, _ := c.GetFloat("private_price")
  7306. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7307. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7308. //
  7309. // timeLayout := "2006-01-02"
  7310. // loc, _ := time.LoadLocation("Local")
  7311. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7312. // if err != nil {
  7313. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7314. // return
  7315. // }
  7316. // recordDateTime := theTime.Unix()
  7317. // adminUser := c.GetAdminUserInfo()
  7318. //
  7319. // var prescriptions []*models.HisPrescription
  7320. //
  7321. // data := make(map[string]interface{})
  7322. // if settle_accounts_type == 1 { //日结
  7323. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7324. // data["pre"] = prescriptions
  7325. //
  7326. // } else { //月结
  7327. // start_time_str := c.GetString("start_time")
  7328. // end_time_str := c.GetString("end_time")
  7329. // timeLayout := "2006-01-02"
  7330. // loc, _ := time.LoadLocation("Local")
  7331. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7332. // if err != nil {
  7333. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7334. // return
  7335. // }
  7336. // recordStartTime := theStartTime.Unix()
  7337. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7338. // if err != nil {
  7339. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7340. // return
  7341. // }
  7342. // recordEndTime := theEndTime.Unix()
  7343. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7344. // data["pre"] = prescriptions
  7345. //
  7346. // }
  7347. //
  7348. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7349. //
  7350. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7351. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7352. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7353. // strconv.FormatInt(his.PatientId, 10)
  7354. //
  7355. // order_src, _ := service.GetHisOrderByID(order_id)
  7356. //
  7357. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7358. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7359. //
  7360. // var total float64
  7361. // for _, item := range prescriptions {
  7362. // if item.Type == 1 { //药品
  7363. // for _, subItem := range item.HisDoctorAdviceInfo {
  7364. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7365. // }
  7366. // }
  7367. // if item.Type == 2 { //项目
  7368. // for _, subItem := range item.HisPrescriptionProject {
  7369. // total = total + (subItem.Price * float64(subItem.Count))
  7370. // }
  7371. // }
  7372. // }
  7373. //
  7374. // for _, item := range prescriptions {
  7375. // for _, subItem := range item.HisAdditionalCharge {
  7376. // total = total + (subItem.Price * float64(subItem.Count))
  7377. // }
  7378. // }
  7379. //
  7380. // allTotal := fmt.Sprintf("%.2f", total)
  7381. // var rf []*ResultFive
  7382. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7383. // psn_no := order_src.PsnNo
  7384. // mdtrt_id := order_src.MdtrtId
  7385. // chrg_bchno := order_src.Number
  7386. // cert_no := order_src.Certno
  7387. // insutype := rf[0].Insutype
  7388. //
  7389. // if his.IdCardType == 1 {
  7390. // cert_no = his.MedicalInsuranceNumber
  7391. // } else {
  7392. // cert_no = his.Certno
  7393. // }
  7394. //
  7395. // 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)
  7396. // var dat map[string]interface{}
  7397. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7398. // fmt.Println(dat)
  7399. // } else {
  7400. // fmt.Println(err)
  7401. // }
  7402. //
  7403. // userJSONBytes, _ := json.Marshal(dat)
  7404. //
  7405. //
  7406. //
  7407. // var res ResultSeven
  7408. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7409. // utils.ErrorLog("解析失败:%v", err)
  7410. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7411. // return
  7412. // }
  7413. // if res.Infcode == -1 {
  7414. // errlog := &models.HisOrderError{
  7415. // UserOrgId: adminUser.CurrentOrgId,
  7416. // Ctime: time.Now().Unix(),
  7417. // Mtime: time.Now().Unix(),
  7418. // Number: chrg_bchno,
  7419. // ErrMsg: res.ErrMsg,
  7420. // Status: 1,
  7421. // PatientId: id,
  7422. // RecordTime: recordDateTime,
  7423. // Stage: 6,
  7424. // }
  7425. // service.CreateErrMsgLog(errlog)
  7426. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7427. // return
  7428. // } else {
  7429. // order_src.OrderStatus = 2
  7430. // order_src.PayWay = pay_way
  7431. // order_src.PayPrice = pay_price
  7432. // order_src.PayCardNo = pay_card_no
  7433. // order_src.DiscountPrice = discount_price
  7434. // order_src.PreferentialPrice = preferential_price
  7435. // order_src.RealityPrice = reality_price
  7436. // order_src.FoundPrice = found_price
  7437. // order_src.MedicalInsurancePrice = medical_insurance_price
  7438. // order_src.PrivatePrice = private_price
  7439. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7440. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7441. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7442. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7443. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7444. // order_src.Certno = res.Output.Setlinfo.Certno
  7445. // order_src.Gend = res.Output.Setlinfo.Gend
  7446. // order_src.Naty = res.Output.Setlinfo.Naty
  7447. // order_src.Age = res.Output.Setlinfo.Age
  7448. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7449. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7450. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7451. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7452. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7453. // order_src.MedType = res.Output.Setlinfo.MedType
  7454. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7455. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7456. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7457. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7458. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7459. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7460. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7461. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7462. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7463. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7464. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7465. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7466. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7467. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7468. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7469. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7470. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7471. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7472. // order_src.Balc = res.Output.Setlinfo.Balc
  7473. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7474. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7475. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7476. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7477. // order_src.Creator = order_src.Creator
  7478. // order_src.Modify = roles.ID
  7479. // order_src.RequestLog = src_resquest
  7480. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7481. // detailStr := string(setlDetail)
  7482. // order_src.SetlDetail = detailStr
  7483. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7484. // err = service.UpDateOrder(order_src)
  7485. //
  7486. // if err == nil {
  7487. // c.ServeSuccessJSON(map[string]interface{}{
  7488. // "msg": "结算成功",
  7489. // })
  7490. // } else {
  7491. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7492. // return
  7493. // }
  7494. // }
  7495. // }
  7496. //}
  7497. //退款
  7498. func (c *HisApiController) Refund() {
  7499. order_id, _ := c.GetInt64("order_id")
  7500. admin_user_id, _ := c.GetInt64("admin_user_id")
  7501. adminUser := c.GetAdminUserInfo()
  7502. var order models.HisOrder
  7503. order, _ = service.GetHisOrderByID(order_id)
  7504. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7505. if order.ID == 0 {
  7506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7507. return
  7508. }
  7509. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7510. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7511. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7512. if config.IsOpen == 1 { //对接了医保,走医保流程
  7513. var res ResultSixteen
  7514. var resSixteen10265 ResultSixteen10265
  7515. var src_resquest string
  7516. var result string
  7517. if miConfig.MdtrtareaAdmvs == "421300" {
  7518. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7519. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7520. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7521. resp3, requestErr3 := http.Get(api3)
  7522. if requestErr3 != nil {
  7523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7524. return
  7525. }
  7526. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7527. if ioErr3 != nil {
  7528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7530. return
  7531. }
  7532. var respJSON3 map[string]interface{}
  7533. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7536. return
  7537. }
  7538. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7539. userJSONBytes3, _ := json.Marshal(respJSON3)
  7540. fmt.Println("log")
  7541. fmt.Println(string(userJSONBytes3))
  7542. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7543. utils.ErrorLog("解析失败:%v", err)
  7544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7545. return
  7546. }
  7547. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7548. var api3 string
  7549. if miConfig.MdtrtareaAdmvs == "320921" {
  7550. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7551. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7552. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7553. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7554. } else {
  7555. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7556. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7557. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7558. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7559. }
  7560. resp3, requestErr3 := http.Get(api3)
  7561. if requestErr3 != nil {
  7562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7563. return
  7564. }
  7565. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7566. if ioErr3 != nil {
  7567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7569. return
  7570. }
  7571. var respJSON3 map[string]interface{}
  7572. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7575. return
  7576. }
  7577. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7578. userJSONBytes3, _ := json.Marshal(respJSON3)
  7579. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7580. utils.ErrorLog("解析失败:%v", err)
  7581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7582. return
  7583. }
  7584. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7585. res.Output = resSixteen10265.Output
  7586. res.ErrMsg = resSixteen10265.ErrMsg
  7587. res.Cainfo = resSixteen10265.Cainfo
  7588. res.WarnMsg = resSixteen10265.WarnMsg
  7589. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7590. res.Infcode = infocode
  7591. } else {
  7592. if miConfig.Code == "H15049901371" {
  7593. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7594. var dat map[string]interface{}
  7595. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7596. fmt.Println(dat)
  7597. } else {
  7598. fmt.Println(err)
  7599. }
  7600. saveLog(result, src_resquest, "2208", "退费")
  7601. userJSONBytes, _ := json.Marshal(dat)
  7602. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7603. utils.ErrorLog("解析失败:%v", err)
  7604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7605. return
  7606. }
  7607. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7608. res.Output = resSixteen10265.Output
  7609. res.ErrMsg = resSixteen10265.ErrMsg
  7610. res.Cainfo = resSixteen10265.Cainfo
  7611. res.WarnMsg = resSixteen10265.WarnMsg
  7612. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7613. res.Infcode = infocode
  7614. } else {
  7615. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7616. var dat map[string]interface{}
  7617. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7618. fmt.Println(dat)
  7619. } else {
  7620. fmt.Println(err)
  7621. }
  7622. saveLog(result, src_resquest, "2208", "退费")
  7623. userJSONBytes, _ := json.Marshal(dat)
  7624. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7625. utils.ErrorLog("解析失败:%v", err)
  7626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7627. return
  7628. }
  7629. }
  7630. }
  7631. if res.Infcode == 0 {
  7632. var res2 ResultSix
  7633. var resSix10265 ResultSix10265
  7634. if miConfig.MdtrtareaAdmvs == "421300" {
  7635. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7636. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7637. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7638. resp3, requestErr3 := http.Get(api3)
  7639. if requestErr3 != nil {
  7640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7641. return
  7642. }
  7643. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7644. if ioErr3 != nil {
  7645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7647. return
  7648. }
  7649. var respJSON3 map[string]interface{}
  7650. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7653. return
  7654. }
  7655. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7656. userJSONBytes3, _ := json.Marshal(respJSON3)
  7657. fmt.Println("log")
  7658. fmt.Println(string(userJSONBytes3))
  7659. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7660. utils.ErrorLog("解析失败:%v", err)
  7661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7662. return
  7663. }
  7664. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7665. var api3 string
  7666. if miConfig.MdtrtareaAdmvs == "320921" {
  7667. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7668. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7669. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7670. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7671. } else {
  7672. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7673. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7674. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7675. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7676. }
  7677. resp3, requestErr3 := http.Get(api3)
  7678. if requestErr3 != nil {
  7679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7680. return
  7681. }
  7682. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7683. if ioErr3 != nil {
  7684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7686. return
  7687. }
  7688. var respJSON3 map[string]interface{}
  7689. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7692. return
  7693. }
  7694. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7695. userJSONBytes3, _ := json.Marshal(respJSON3)
  7696. fmt.Println("log")
  7697. fmt.Println(string(userJSONBytes3))
  7698. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7699. utils.ErrorLog("解析失败:%v", err)
  7700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7701. return
  7702. }
  7703. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7704. res2.Output = resSix10265.Output
  7705. res2.ErrMsg = resSix10265.ErrMsg
  7706. res2.Cainfo = resSix10265.Cainfo
  7707. res2.WarnMsg = resSix10265.WarnMsg
  7708. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7709. res2.Infcode = infocode
  7710. } else {
  7711. if miConfig.Code == "H15049901371" {
  7712. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7713. var dat map[string]interface{}
  7714. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7715. fmt.Println(dat)
  7716. } else {
  7717. fmt.Println(err)
  7718. }
  7719. saveLog(result2, src_request, "2205", "撤销明细")
  7720. userJSONBytes, _ := json.Marshal(dat)
  7721. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7722. utils.ErrorLog("解析失败:%v", err)
  7723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7724. return
  7725. }
  7726. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7727. res2.Output = resSix10265.Output
  7728. res2.ErrMsg = resSix10265.ErrMsg
  7729. res2.Cainfo = resSix10265.Cainfo
  7730. res2.WarnMsg = resSix10265.WarnMsg
  7731. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7732. res2.Infcode = infocode
  7733. } else {
  7734. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7735. var dat map[string]interface{}
  7736. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7737. fmt.Println(dat)
  7738. } else {
  7739. fmt.Println(err)
  7740. }
  7741. saveLog(result2, src_request, "2205", "撤销明细")
  7742. userJSONBytes, _ := json.Marshal(dat)
  7743. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7744. utils.ErrorLog("解析失败:%v", err)
  7745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7746. return
  7747. }
  7748. }
  7749. }
  7750. if res2.Infcode == 0 {
  7751. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7752. if err == nil {
  7753. //当押金不为零时产生退费记录
  7754. if order.Decimal != 0 {
  7755. tmp := strconv.FormatInt(order.ID, 10)
  7756. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  7757. if err != nil {
  7758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7759. return
  7760. }
  7761. }
  7762. c.ServeSuccessJSON(map[string]interface{}{
  7763. "msg": "退费成功",
  7764. })
  7765. } else {
  7766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7767. return
  7768. }
  7769. } else {
  7770. c.ServeSuccessJSON(map[string]interface{}{
  7771. "code": -10,
  7772. "msg": res2.ErrMsg,
  7773. })
  7774. }
  7775. } else {
  7776. c.ServeSuccessJSON(map[string]interface{}{
  7777. "code": -10,
  7778. "msg": res.ErrMsg,
  7779. })
  7780. }
  7781. }
  7782. }
  7783. func (c *HisApiController) RefundNumber() {
  7784. record_time := c.GetString("record_time")
  7785. //patient_id, _ := c.GetInt64("patient_id")
  7786. admin_user_id, _ := c.GetInt64("admin_user_id")
  7787. his_patient_id, _ := c.GetInt64("id")
  7788. timeLayout := "2006-01-02"
  7789. loc, _ := time.LoadLocation("Local")
  7790. adminUser := c.GetAdminUserInfo()
  7791. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7792. fmt.Println(err)
  7793. if err != nil {
  7794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7795. return
  7796. }
  7797. recordDateTime := theTime.Unix()
  7798. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7799. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7800. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7801. //order, _ := service.GetHisOrderByID(order_id)
  7802. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7803. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7804. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7805. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7806. if count > 0 {
  7807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7808. return
  7809. }
  7810. if config.IsOpen == 1 { //对接了医保,走医保流程
  7811. var res2 ResultSix
  7812. var resSix10265 ResultSix10265
  7813. if miConfig.MdtrtareaAdmvs == "421300" {
  7814. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7815. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7816. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7817. resp3, requestErr3 := http.Get(api3)
  7818. if requestErr3 != nil {
  7819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7820. return
  7821. }
  7822. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7823. if ioErr3 != nil {
  7824. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7826. return
  7827. }
  7828. var respJSON3 map[string]interface{}
  7829. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7832. return
  7833. }
  7834. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7835. userJSONBytes3, _ := json.Marshal(respJSON3)
  7836. fmt.Println("log")
  7837. fmt.Println(string(userJSONBytes3))
  7838. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7839. utils.ErrorLog("解析失败:%v", err)
  7840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7841. return
  7842. }
  7843. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7844. var api3 string
  7845. if miConfig.MdtrtareaAdmvs == "320921" {
  7846. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7847. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7848. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7849. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7850. } else {
  7851. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7852. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7853. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7854. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7855. }
  7856. resp3, requestErr3 := http.Get(api3)
  7857. if requestErr3 != nil {
  7858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7859. return
  7860. }
  7861. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7862. if ioErr3 != nil {
  7863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7865. return
  7866. }
  7867. var respJSON3 map[string]interface{}
  7868. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7871. return
  7872. }
  7873. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7874. userJSONBytes3, _ := json.Marshal(respJSON3)
  7875. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7876. utils.ErrorLog("解析失败:%v", err)
  7877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7878. return
  7879. }
  7880. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7881. res2.Output = resSix10265.Output
  7882. res2.ErrMsg = resSix10265.ErrMsg
  7883. res2.Cainfo = resSix10265.Cainfo
  7884. res2.WarnMsg = resSix10265.WarnMsg
  7885. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7886. res2.Infcode = infocode
  7887. } else {
  7888. var api3 string
  7889. if miConfig.Code == "H15049901371" {
  7890. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7891. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7892. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7893. } else {
  7894. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7895. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7896. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7897. }
  7898. resp3, requestErr3 := http.Get(api3)
  7899. if requestErr3 != nil {
  7900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7901. return
  7902. }
  7903. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7904. if ioErr3 != nil {
  7905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7907. return
  7908. }
  7909. var respJSON3 map[string]interface{}
  7910. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7913. return
  7914. }
  7915. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7916. userJSONBytes3, _ := json.Marshal(respJSON3)
  7917. if miConfig.Code == "H15049901371" {
  7918. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7919. utils.ErrorLog("解析失败:%v", err)
  7920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7921. return
  7922. }
  7923. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7924. res2.Output = resSix10265.Output
  7925. res2.ErrMsg = resSix10265.ErrMsg
  7926. res2.Cainfo = resSix10265.Cainfo
  7927. res2.WarnMsg = resSix10265.WarnMsg
  7928. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7929. res2.Infcode = infocode
  7930. } else {
  7931. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7932. utils.ErrorLog("解析失败:%v", err)
  7933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7934. return
  7935. }
  7936. }
  7937. }
  7938. if res2.Infcode == 0 {
  7939. if err == nil {
  7940. c.ServeSuccessJSON(map[string]interface{}{
  7941. "msg": "退号成功",
  7942. })
  7943. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7944. } else {
  7945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7946. return
  7947. }
  7948. } else {
  7949. c.ServeSuccessJSON(map[string]interface{}{
  7950. "code": -10,
  7951. "msg": res2.ErrMsg,
  7952. })
  7953. }
  7954. } else {
  7955. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7956. //if err == nil {
  7957. // c.ServeSuccessJSON(map[string]interface{}{
  7958. // "msg": "退费成功",
  7959. // })
  7960. //} else {
  7961. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7962. // return
  7963. //}
  7964. }
  7965. }
  7966. func (c *HisApiController) RefundDetail() {
  7967. order_id, _ := c.GetInt64("order_id")
  7968. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7969. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7970. number := c.GetString("number")
  7971. record_time := c.GetString("record_time")
  7972. patient_id, _ := c.GetInt64("patient_id")
  7973. //med_type, _ := c.GetInt64("med_type")
  7974. timeLayout := "2006-01-02"
  7975. loc, _ := time.LoadLocation("Local")
  7976. adminUser := c.GetAdminUserInfo()
  7977. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7978. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7979. fmt.Println(err)
  7980. if err != nil {
  7981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7982. return
  7983. }
  7984. recordDateTime := theTime.Unix()
  7985. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7986. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7987. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7988. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7989. var order models.HisOrder
  7990. order, _ = service.GetHisOrderByID(order_id)
  7991. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7992. if config.IsOpen == 1 { //对接了医保,走医保流程
  7993. var res2 ResultSix
  7994. if miConfig.MdtrtareaAdmvs == "421300" {
  7995. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7996. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7997. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7998. resp3, requestErr3 := http.Get(api3)
  7999. if requestErr3 != nil {
  8000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8001. return
  8002. }
  8003. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8004. if ioErr3 != nil {
  8005. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8007. return
  8008. }
  8009. var respJSON3 map[string]interface{}
  8010. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8013. return
  8014. }
  8015. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8016. userJSONBytes3, _ := json.Marshal(respJSON3)
  8017. fmt.Println("log")
  8018. fmt.Println(string(userJSONBytes3))
  8019. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8020. utils.ErrorLog("解析失败:%v", err)
  8021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8022. return
  8023. }
  8024. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8025. if err == nil {
  8026. c.ServeSuccessJSON(map[string]interface{}{
  8027. "msg": "撤销明细成功",
  8028. })
  8029. return
  8030. } else {
  8031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8032. return
  8033. }
  8034. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8035. var resSix10265 ResultSix10265
  8036. var api3 string
  8037. if miConfig.MdtrtareaAdmvs == "320921" {
  8038. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8039. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8040. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8041. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8042. } else {
  8043. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8044. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8045. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8046. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8047. }
  8048. resp3, requestErr3 := http.Get(api3)
  8049. if requestErr3 != nil {
  8050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8051. return
  8052. }
  8053. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8054. if ioErr3 != nil {
  8055. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8057. return
  8058. }
  8059. var respJSON3 map[string]interface{}
  8060. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8061. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8063. return
  8064. }
  8065. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8066. userJSONBytes3, _ := json.Marshal(respJSON3)
  8067. fmt.Println("log")
  8068. fmt.Println(string(userJSONBytes3))
  8069. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8070. utils.ErrorLog("解析失败:%v", err)
  8071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8072. return
  8073. }
  8074. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8075. res2.Output = resSix10265.Output
  8076. res2.ErrMsg = resSix10265.ErrMsg
  8077. res2.Cainfo = resSix10265.Cainfo
  8078. res2.WarnMsg = resSix10265.WarnMsg
  8079. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8080. res2.Infcode = infocode
  8081. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8082. if err == nil {
  8083. c.ServeSuccessJSON(map[string]interface{}{
  8084. "msg": "撤销明细成功",
  8085. })
  8086. return
  8087. } else {
  8088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8089. return
  8090. }
  8091. } else {
  8092. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8093. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8094. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8095. resp2, requestErr2 := http.Get(api2)
  8096. if requestErr2 != nil {
  8097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8098. return
  8099. }
  8100. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8101. if ioErr2 != nil {
  8102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8104. return
  8105. }
  8106. var respJSON2 map[string]interface{}
  8107. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8110. return
  8111. }
  8112. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8113. if err == nil {
  8114. c.ServeSuccessJSON(map[string]interface{}{
  8115. "msg": "撤销明细成功",
  8116. })
  8117. return
  8118. } else {
  8119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8120. return
  8121. }
  8122. }
  8123. } else {
  8124. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8125. if err == nil {
  8126. c.ServeSuccessJSON(map[string]interface{}{
  8127. "msg": "退费成功",
  8128. })
  8129. } else {
  8130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8131. return
  8132. }
  8133. }
  8134. }
  8135. //对账
  8136. func (c *HisApiController) GetCheckAccount() {
  8137. start_time := c.GetString("start_time")
  8138. end_time := c.GetString("end_time")
  8139. insutype := c.GetString("insutype")
  8140. clr_type := c.GetString("clr_type")
  8141. clr_org := c.GetString("clr_optins")
  8142. admin_user_id, _ := c.GetInt64("admin_user_id")
  8143. adminUser := c.GetAdminUserInfo()
  8144. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8145. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8146. if len(clr_org) == 0 {
  8147. clr_org = miConfig.MdtrtareaAdmvs
  8148. }
  8149. timeLayout := "2006-01-02"
  8150. loc, _ := time.LoadLocation("Local")
  8151. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8152. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8153. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8154. fixmedins_setl_cnt := int64(len(orders))
  8155. var medfee_sumamt float64
  8156. var acct_pay float64
  8157. var fund_pay_sumamt float64
  8158. for _, item := range orders {
  8159. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8160. acct_pay = acct_pay + item.AcctPay
  8161. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8162. }
  8163. var user_name string
  8164. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8165. if role.ID == 0 {
  8166. user_name = "xxx"
  8167. } else {
  8168. user_name = role.UserName
  8169. }
  8170. var res ResultEight
  8171. var res10188 ResultEightFor10188
  8172. if config.IsOpen == 1 {
  8173. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8174. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8175. "insutype=" + insutype +
  8176. "&clr_type=" + "11" +
  8177. "&setl_optins=" + clr_org +
  8178. "&stmt_begndate=" + start_time +
  8179. "&stm_enddate=" + end_time +
  8180. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8181. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8182. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8183. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8184. "&fixmedins_code=" + miConfig.Code +
  8185. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8186. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8187. "&secret_key=" + miConfig.SecretKey +
  8188. "&org_name=" + miConfig.OrgName +
  8189. "&doctor=" + user_name +
  8190. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8191. fmt.Println(api)
  8192. resp, requestErr := http.Get(api)
  8193. if requestErr != nil {
  8194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8195. return
  8196. }
  8197. body, ioErr := ioutil.ReadAll(resp.Body)
  8198. fmt.Println(body)
  8199. if ioErr != nil {
  8200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8202. return
  8203. }
  8204. var respJSON map[string]interface{}
  8205. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8208. return
  8209. }
  8210. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8211. userJSONBytes, _ := json.Marshal(respJSON)
  8212. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8213. utils.ErrorLog("解析失败:%v", err)
  8214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8215. return
  8216. }
  8217. res.InfRefmsgid = res10188.InfRefmsgid
  8218. res.Output = res10188.Output
  8219. res.ErrMsg = res10188.ErrMsg
  8220. res.Cainfo = res10188.Cainfo
  8221. res.WarnMsg = res10188.WarnMsg
  8222. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8223. res.Infcode = infocode
  8224. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8225. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8226. "insutype=" + insutype +
  8227. "&clr_type=" + "11" +
  8228. "&setl_optins=" + clr_org +
  8229. "&stmt_begndate=" + start_time +
  8230. "&stm_enddate=" + end_time +
  8231. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8232. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8233. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8234. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8235. "&fixmedins_code=" + miConfig.Code +
  8236. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8237. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8238. "&secret_key=" + miConfig.SecretKey +
  8239. "&org_name=" + miConfig.OrgName +
  8240. "&doctor=" + user_name
  8241. resp, requestErr := http.Get(api)
  8242. if requestErr != nil {
  8243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8244. return
  8245. }
  8246. body, ioErr := ioutil.ReadAll(resp.Body)
  8247. if ioErr != nil {
  8248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8250. return
  8251. }
  8252. var respJSON map[string]interface{}
  8253. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8256. return
  8257. }
  8258. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8259. result, _ := json.Marshal(respJSON)
  8260. fmt.Println("log")
  8261. fmt.Println(string(result))
  8262. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8263. utils.ErrorLog("解析失败:%v", err)
  8264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8265. return
  8266. }
  8267. res.InfRefmsgid = res10188.InfRefmsgid
  8268. res.Output = res10188.Output
  8269. res.ErrMsg = res10188.ErrMsg
  8270. res.Cainfo = res10188.Cainfo
  8271. res.WarnMsg = res10188.WarnMsg
  8272. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8273. res.Infcode = infocode
  8274. } else {
  8275. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8276. "insutype=" + insutype +
  8277. "&clr_type=" + clr_type +
  8278. "&setl_optins=" + clr_org +
  8279. "&stmt_begndate=" + start_time +
  8280. "&stm_enddate=" + end_time +
  8281. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8282. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8283. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8284. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8285. "&fixmedins_code=" + miConfig.Code +
  8286. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8287. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8288. "&secret_key=" + miConfig.SecretKey +
  8289. "&org_name=" + miConfig.OrgName +
  8290. "&doctor=" + user_name
  8291. fmt.Println(api)
  8292. resp, requestErr := http.Get(api)
  8293. if requestErr != nil {
  8294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8295. return
  8296. }
  8297. body, ioErr := ioutil.ReadAll(resp.Body)
  8298. fmt.Println(body)
  8299. if ioErr != nil {
  8300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8302. return
  8303. }
  8304. var respJSON map[string]interface{}
  8305. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8308. return
  8309. }
  8310. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8311. userJSONBytes, _ := json.Marshal(respJSON)
  8312. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8313. utils.ErrorLog("解析失败:%v", err)
  8314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8315. return
  8316. }
  8317. }
  8318. if res.Infcode == 0 {
  8319. if res.Output.Stmtinfo.StmtRslt == "0" {
  8320. micc := &models.MedicalInsuranceCostCompare{
  8321. StartTime: startime.Unix(),
  8322. EndTime: endtime.Unix(),
  8323. Insutype: insutype,
  8324. CheckType: 1,
  8325. Num: fixmedins_setl_cnt,
  8326. Mtime: time.Now().Unix(),
  8327. Status: 1,
  8328. UserOrgId: adminUser.CurrentOrgId,
  8329. CostTotal: medfee_sumamt,
  8330. FuncTotal: fund_pay_sumamt,
  8331. PsnPay: acct_pay,
  8332. Creator: admin_user_id,
  8333. Ctime: time.Now().Unix(),
  8334. ClrType: clr_type,
  8335. }
  8336. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8337. if err == nil {
  8338. c.ServeSuccessJSON(map[string]interface{}{
  8339. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8340. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8341. })
  8342. } else {
  8343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8344. }
  8345. } else {
  8346. c.ServeSuccessJSON(map[string]interface{}{
  8347. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8348. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8349. })
  8350. }
  8351. } else {
  8352. c.ServeSuccessJSON(map[string]interface{}{
  8353. "code": -10,
  8354. "msg": res.ErrMsg,
  8355. })
  8356. }
  8357. }
  8358. }
  8359. func (c *HisApiController) Check310() {
  8360. adminUser := c.GetAdminUserInfo()
  8361. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8362. var user_name string
  8363. user_name = "高慧裕"
  8364. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8365. "insutype=" + "310" +
  8366. "&clr_type=" + "" +
  8367. "&setl_optins=" + "441202" +
  8368. "&stmt_begndate=" + "2022-03-01" +
  8369. "&stm_enddate=" + "2022-03-31" +
  8370. "&medfee_sumamt=" + "194930.12" +
  8371. "&fund_pay_sumamt=" + "188741.46" +
  8372. "&acct_pay=" + "0" +
  8373. "&fixmedins_setl_cnt=" + "452" +
  8374. "&fixmedins_code=" + miConfig.Code +
  8375. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8376. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8377. "&secret_key=" + miConfig.SecretKey +
  8378. "&org_name=" + miConfig.OrgName +
  8379. "&doctor=" + user_name
  8380. fmt.Println(api)
  8381. resp, requestErr := http.Get(api)
  8382. if requestErr != nil {
  8383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8384. return
  8385. }
  8386. body, ioErr := ioutil.ReadAll(resp.Body)
  8387. fmt.Println(body)
  8388. if ioErr != nil {
  8389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8391. return
  8392. }
  8393. var respJSON map[string]interface{}
  8394. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8397. return
  8398. }
  8399. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8400. userJSONBytes, _ := json.Marshal(respJSON)
  8401. var res ResultEight
  8402. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8403. utils.ErrorLog("解析失败:%v", err)
  8404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8405. return
  8406. }
  8407. }
  8408. func (c *HisApiController) Check390() {
  8409. adminUser := c.GetAdminUserInfo()
  8410. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8411. var user_name string
  8412. user_name = "高慧裕"
  8413. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8414. "insutype=" + "390" +
  8415. "&clr_type=" + "" +
  8416. "&setl_optins=" + "441202" +
  8417. "&stmt_begndate=" + "2022-03-01" +
  8418. "&stm_enddate=" + "2022-03-31" +
  8419. "&medfee_sumamt=" + "1068448.89" +
  8420. "&fund_pay_sumamt=" + "1014677.62" +
  8421. "&acct_pay=" + "0" +
  8422. "&fixmedins_setl_cnt=" + "1950" +
  8423. "&fixmedins_code=" + miConfig.Code +
  8424. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8425. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8426. "&secret_key=" + miConfig.SecretKey +
  8427. "&org_name=" + miConfig.OrgName +
  8428. "&doctor=" + user_name
  8429. fmt.Println(api)
  8430. resp, requestErr := http.Get(api)
  8431. if requestErr != nil {
  8432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8433. return
  8434. }
  8435. body, ioErr := ioutil.ReadAll(resp.Body)
  8436. fmt.Println(body)
  8437. if ioErr != nil {
  8438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8440. return
  8441. }
  8442. var respJSON map[string]interface{}
  8443. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8446. return
  8447. }
  8448. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8449. userJSONBytes, _ := json.Marshal(respJSON)
  8450. var res ResultEight
  8451. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8452. utils.ErrorLog("解析失败:%v", err)
  8453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8454. return
  8455. }
  8456. }
  8457. //对账明细
  8458. func (c *HisApiController) GetCheckDetailAccount() {
  8459. start_time := c.GetString("start_time")
  8460. end_time := c.GetString("end_time")
  8461. admin_user_id, _ := c.GetInt64("admin_user_id")
  8462. adminUser := c.GetAdminUserInfo()
  8463. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8464. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8465. timeLayout := "2006-01-02"
  8466. loc, _ := time.LoadLocation("Local")
  8467. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8468. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8469. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8470. rand.Seed(time.Now().UnixNano())
  8471. num := rand.Intn(30000)
  8472. Mkdir(miConfig.OrgName)
  8473. file := strconv.FormatInt(int64(num), 10)
  8474. file_name := file + ".txt"
  8475. zip_name := file + ".zip"
  8476. zip_path := miConfig.OrgName + "/" + zip_name
  8477. file_path := miConfig.OrgName + "/" + file_name
  8478. decimal.DivisionPrecision = 2
  8479. var medfee_sumamt float64
  8480. var psn_cash_pay float64
  8481. var fund_pay_sumamt float64
  8482. fixmedins_setl_cnt := int64(len(orders))
  8483. for _, item := range orders {
  8484. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8485. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8486. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8487. }
  8488. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8489. defer f.Close()
  8490. if err != nil {
  8491. fmt.Println(err.Error())
  8492. } else {
  8493. for _, item := range orders {
  8494. var refd_setl_flag string
  8495. if item.OrderStatus == 2 {
  8496. refd_setl_flag = "0"
  8497. var str string
  8498. str = item.SetlId + " " +
  8499. item.MdtrtId + " " +
  8500. item.PsnNo + " " +
  8501. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8502. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8503. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8504. _, err = f.Write([]byte(str))
  8505. }
  8506. if item.OrderStatus == 3 {
  8507. var str string
  8508. str = item.SetlId + " " +
  8509. item.MdtrtId + " " +
  8510. item.PsnNo + " " +
  8511. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8512. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8513. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8514. _, err = f.Write([]byte(str))
  8515. var str2 string
  8516. str2 = item.SetlId + " " +
  8517. item.MdtrtId + " " +
  8518. item.PsnNo + " " +
  8519. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8520. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8521. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8522. _, err = f.Write([]byte(str2))
  8523. }
  8524. }
  8525. }
  8526. Zip(file_path, zip_path)
  8527. fmt.Println(ReadFile(zip_path))
  8528. fmt.Println(string(ReadFile(zip_path)))
  8529. if config.IsOpen == 1 {
  8530. var user_name string
  8531. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8532. if role.ID == 0 {
  8533. user_name = "管理员"
  8534. } else {
  8535. user_name = role.UserName
  8536. }
  8537. baseParams := models.BaseParams{
  8538. SecretKey: miConfig.SecretKey,
  8539. FixmedinsCode: miConfig.Code,
  8540. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8541. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8542. OrgName: miConfig.OrgName,
  8543. Doctor: user_name,
  8544. }
  8545. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8546. var dat map[string]interface{}
  8547. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8548. fmt.Println(dat)
  8549. } else {
  8550. fmt.Println(err)
  8551. }
  8552. userJSONBytes, _ := json.Marshal(dat)
  8553. var res ResultNine
  8554. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8555. utils.ErrorLog("解析失败:%v", err)
  8556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8557. return
  8558. }
  8559. if res.Infcode == 0 {
  8560. fileNo := res.Output.FileQuryNo
  8561. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8562. "file_qury_no=" + fileNo +
  8563. "&setl_optins=" + "定点医保中心" +
  8564. "&stmt_begndate=" + start_time +
  8565. "&stm_enddate=" + end_time +
  8566. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8567. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8568. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8569. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8570. "&fixmedins_code=" + miConfig.Code +
  8571. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8572. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8573. "&secret_key=" + miConfig.SecretKey +
  8574. "&org_name=" + miConfig.OrgName +
  8575. "&doctor=" + user_name
  8576. resp, requestErr := http.Get(api)
  8577. if requestErr != nil {
  8578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8579. return
  8580. }
  8581. body, ioErr := ioutil.ReadAll(resp.Body)
  8582. if ioErr != nil {
  8583. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8585. return
  8586. }
  8587. var respJSON map[string]interface{}
  8588. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8591. return
  8592. }
  8593. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8594. userJSONBytes, _ := json.Marshal(respJSON)
  8595. var res ResultTen
  8596. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8597. utils.ErrorLog("解析失败:%v", err)
  8598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8599. return
  8600. }
  8601. if res.Infcode == 0 {
  8602. service.Gdyb9102(baseParams, zip_name, fileNo)
  8603. micc := &models.MedicalInsuranceCostCompare{
  8604. StartTime: startime.Unix(),
  8605. EndTime: endtime.Unix(),
  8606. Insutype: "0",
  8607. CheckType: 2,
  8608. Num: fixmedins_setl_cnt,
  8609. Mtime: time.Now().Unix(),
  8610. Status: 1,
  8611. UserOrgId: adminUser.CurrentOrgId,
  8612. CostTotal: medfee_sumamt,
  8613. FuncTotal: fund_pay_sumamt,
  8614. PsnPay: psn_cash_pay,
  8615. Creator: admin_user_id,
  8616. Ctime: time.Now().Unix(),
  8617. }
  8618. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8619. c.ServeSuccessJSON(map[string]interface{}{
  8620. "msg": "明细对账成功",
  8621. })
  8622. }
  8623. } else {
  8624. }
  8625. }
  8626. }
  8627. type CustomOrderInfo struct {
  8628. Name string
  8629. Spec string
  8630. Unit string
  8631. Count float64
  8632. Price float64
  8633. Total float64
  8634. }
  8635. func (c *HisApiController) GetSettleAccounts() {
  8636. //id, _ := c.GetInt64("id")
  8637. //record_time := c.GetString("record_time")
  8638. order_id, _ := c.GetInt64("order_id")
  8639. admin_user_id, _ := c.GetInt64("admin_user_id")
  8640. //timeLayout := "2006-01-02"
  8641. //loc, _ := time.LoadLocation("Local")
  8642. //
  8643. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8644. //if err != nil {
  8645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8646. // return
  8647. //}
  8648. //recordDateTime := theTime.Unix()
  8649. adminUser := c.GetAdminUserInfo()
  8650. order, _ := service.GetHisOrderByID(order_id)
  8651. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8652. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8653. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8654. orderInfos = append(orderInfos, orderInfos_two...)
  8655. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8656. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8657. var diagnosis_ids []string
  8658. if his.ID > 0 {
  8659. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8660. } else {
  8661. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8662. }
  8663. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8664. var dia_config []*models.HisXtDiagnoseConfig
  8665. var name string
  8666. for _, item := range diagnosis_ids {
  8667. id, _ := strconv.ParseInt(item, 10, 64)
  8668. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8669. dia_config = append(dia_config, &diagnosisConfig)
  8670. if len(name) == 0 {
  8671. name = diagnosisConfig.ClassName
  8672. } else {
  8673. name = name + "," + diagnosisConfig.ClassName
  8674. }
  8675. }
  8676. var bedCostTotal float64 = 0 //床位总费
  8677. var bedCostSelfTotal float64 = 0 //床位自费
  8678. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8679. var operationCostTotal float64 = 0 //手术费
  8680. var operationCostSelfTotal float64 = 0 //手术费
  8681. var operationCostPartSelfTotal float64 = 0 //手术费
  8682. var otherCostTotal float64 = 0 //其他费用
  8683. var otherCostSelfTotal float64 = 0 //其他费用
  8684. var otherCostPartSelfTotal float64 = 0 //其他费用
  8685. var materialCostTotal float64 = 0 //材料费
  8686. var materialCostSelfTotal float64 = 0 //材料费
  8687. var materialCostPartSelfTotal float64 = 0 //材料费
  8688. var westernMedicineCostTotal float64 = 0 //西药费
  8689. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8690. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8691. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8692. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8693. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8694. var checkCostTotal float64 = 0 //检查费
  8695. var checkCostSelfTotal float64 = 0 //检查费
  8696. var checkCostPartSelfTotal float64 = 0 //检查费
  8697. var laboratoryCostTotal float64 = 0 //化验费
  8698. var laboratoryCostSelfTotal float64 = 0 //化验费
  8699. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8700. var treatCostTotal float64 = 0 //治疗费用
  8701. var treatCostSelfTotal float64 = 0 //治疗费用
  8702. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8703. decimal.DivisionPrecision = 2
  8704. for _, item := range orderInfos {
  8705. if item.MedChrgitmType == "01" { //床位费
  8706. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8707. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8708. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8709. }
  8710. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8711. if item.MedChrgitmType == "03" { //检查费
  8712. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8713. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8714. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8715. }
  8716. } else {
  8717. if item.MedChrgitmType == "03" { //检查费
  8718. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8719. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8720. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8721. }
  8722. }
  8723. if item.MedChrgitmType == "04" { //化验费
  8724. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8725. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8726. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8727. }
  8728. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8729. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8730. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8731. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8732. }
  8733. if item.MedChrgitmType == "06" { //手术费
  8734. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8735. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8736. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8737. }
  8738. if item.MedChrgitmType == "08" { //材料费
  8739. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8740. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8741. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8742. }
  8743. if item.MedChrgitmType == "09" { //西药费
  8744. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8745. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8746. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8747. }
  8748. if item.MedChrgitmType == "11" { //中成费
  8749. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8750. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8751. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8752. }
  8753. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8754. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8755. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8756. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8757. }
  8758. }
  8759. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8760. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8761. var user_name string
  8762. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8763. if role.ID == 0 {
  8764. user_name = "管理员"
  8765. } else {
  8766. user_name = role.UserName
  8767. }
  8768. baseParams := models.BaseParams{
  8769. SecretKey: miConfig.SecretKey,
  8770. FixmedinsCode: miConfig.Code,
  8771. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8772. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8773. OrgName: miConfig.OrgName,
  8774. Doctor: user_name,
  8775. }
  8776. businessParams := models.BusinessParams{
  8777. PsnNo: order.PsnNo,
  8778. MdtrtId: order.MdtrtId,
  8779. SetlId: order.SetlId,
  8780. }
  8781. var res ResultEleven
  8782. var resEleven10265 ResultEleven10265
  8783. if config.IsOpen == 1 {
  8784. if miConfig.MdtrtareaAdmvs == "421300" {
  8785. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8786. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8787. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8788. resp, requestErr := http.Get(api)
  8789. if requestErr != nil {
  8790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8791. return
  8792. }
  8793. body, ioErr := ioutil.ReadAll(resp.Body)
  8794. if ioErr != nil {
  8795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8797. return
  8798. }
  8799. var respJSON map[string]interface{}
  8800. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8803. return
  8804. }
  8805. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8806. result, _ := json.Marshal(respJSON)
  8807. fmt.Println("log")
  8808. fmt.Println(string(result))
  8809. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8810. utils.ErrorLog("解析失败:%v", err)
  8811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8812. return
  8813. }
  8814. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8815. var api string
  8816. if miConfig.MdtrtareaAdmvs == "320921" {
  8817. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8818. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8819. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8820. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8821. } else {
  8822. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8823. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8824. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8825. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8826. }
  8827. resp, requestErr := http.Get(api)
  8828. if requestErr != nil {
  8829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8830. return
  8831. }
  8832. body, ioErr := ioutil.ReadAll(resp.Body)
  8833. if ioErr != nil {
  8834. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8836. return
  8837. }
  8838. var respJSON map[string]interface{}
  8839. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8842. return
  8843. }
  8844. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8845. result, _ := json.Marshal(respJSON)
  8846. fmt.Println("log")
  8847. fmt.Println(string(result))
  8848. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8849. utils.ErrorLog("解析失败:%v", err)
  8850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8851. return
  8852. }
  8853. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8854. res.Output = resEleven10265.Output
  8855. res.ErrMsg = resEleven10265.ErrMsg
  8856. res.Cainfo = resEleven10265.Cainfo
  8857. res.WarnMsg = resEleven10265.WarnMsg
  8858. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8859. res.Infcode = infocode
  8860. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8861. fmt.Println("~~~~~~~")
  8862. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8863. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8864. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8865. resp, requestErr := http.Get(api)
  8866. if requestErr != nil {
  8867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8868. return
  8869. }
  8870. body, ioErr := ioutil.ReadAll(resp.Body)
  8871. if ioErr != nil {
  8872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8874. return
  8875. }
  8876. var respJSON map[string]interface{}
  8877. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8880. return
  8881. }
  8882. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8883. result, _ := json.Marshal(respJSON)
  8884. fmt.Println("log")
  8885. fmt.Println(string(result))
  8886. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8887. utils.ErrorLog("解析失败:%v", err)
  8888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8889. return
  8890. }
  8891. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8892. res.Output = resEleven10265.Output
  8893. res.ErrMsg = resEleven10265.ErrMsg
  8894. res.Cainfo = resEleven10265.Cainfo
  8895. res.WarnMsg = resEleven10265.WarnMsg
  8896. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8897. res.Infcode = infocode
  8898. } else {
  8899. result := service.Gdyb5203(baseParams, businessParams)
  8900. //service.Gdyb5204(baseParams, businessParams)
  8901. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  8902. var dat map[string]interface{}
  8903. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8904. fmt.Println(dat)
  8905. } else {
  8906. fmt.Println(err)
  8907. }
  8908. userJSONBytes, _ := json.Marshal(dat)
  8909. if miConfig.Code == "H15049901371" {
  8910. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8911. utils.ErrorLog("解析失败:%v", err)
  8912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8913. return
  8914. }
  8915. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8916. res.Output = resEleven10265.Output
  8917. res.ErrMsg = resEleven10265.ErrMsg
  8918. res.Cainfo = resEleven10265.Cainfo
  8919. res.WarnMsg = resEleven10265.WarnMsg
  8920. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8921. res.Infcode = infocode
  8922. } else {
  8923. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8924. utils.ErrorLog("解析失败:%v", err)
  8925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8926. return
  8927. }
  8928. }
  8929. }
  8930. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8931. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8932. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8933. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8934. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8935. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8936. var doctor_name string
  8937. if roles.ID == 0 {
  8938. doctor_name = "管理员"
  8939. } else {
  8940. doctor_name = roles.UserName
  8941. }
  8942. yiliao_leibie := ""
  8943. switch order.MedType {
  8944. case "11":
  8945. yiliao_leibie = "普通门诊"
  8946. break
  8947. case "12":
  8948. yiliao_leibie = "门诊挂号"
  8949. break
  8950. case "13":
  8951. yiliao_leibie = "急诊"
  8952. break
  8953. case "14":
  8954. yiliao_leibie = "门诊特殊病"
  8955. break
  8956. case "15":
  8957. yiliao_leibie = "门诊统筹"
  8958. break
  8959. case "16":
  8960. yiliao_leibie = "门诊慢性病"
  8961. break
  8962. case "21":
  8963. yiliao_leibie = "普通住院"
  8964. break
  8965. }
  8966. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8967. if res.Infcode == 0 {
  8968. c.ServeSuccessJSON(map[string]interface{}{
  8969. "diagnosis": name,
  8970. "order_infos": orderInfos,
  8971. "number": order.MdtrtId,
  8972. "date": order.SettleAccountsDate,
  8973. "charge_admin": charge_admin,
  8974. "printor_admin": printor_admin,
  8975. "info": res.Output.Setlinfo,
  8976. "order": order,
  8977. "bedCostTotal": bedCostTotal,
  8978. "bedCostSelfTotal": bedCostSelfTotal,
  8979. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8980. "operationCostTotal": operationCostTotal,
  8981. "operationCostSelfTotal": operationCostSelfTotal,
  8982. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8983. "otherCostTotal": otherCostTotal,
  8984. "otherCostSelfTotal": otherCostSelfTotal,
  8985. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8986. "materialCostTotal": materialCostTotal,
  8987. "materialCostSelfTotal": materialCostSelfTotal,
  8988. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8989. "westernMedicineCostTotal": westernMedicineCostTotal,
  8990. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8991. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8992. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8993. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8994. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8995. "checkCostTotal": checkCostTotal,
  8996. "checkCostSelfTotal": checkCostSelfTotal,
  8997. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8998. "laboratoryCostTotal": laboratoryCostTotal,
  8999. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9000. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9001. "treatCostTotal": treatCostTotal,
  9002. "treatCostSelfTotal": treatCostSelfTotal,
  9003. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9004. "doctor_info": doctor_info,
  9005. "doctor_code": adminRole_two.DoctorCode,
  9006. "doctor_name": doctor_name,
  9007. "health_card_no": order.PsnNo,
  9008. "department": departments.Name,
  9009. "yiliao_leibie": yiliao_leibie,
  9010. "after_money": order.AccountPrice,
  9011. "patient": patient,
  9012. "org_name": miConfig.OrgName,
  9013. "org_code": miConfig.Code,
  9014. "order_number": order.Number,
  9015. "his_hospital": his_hospital,
  9016. "his": his,
  9017. "dia_config": dia_config,
  9018. //"check_order_info": cus_slice,
  9019. })
  9020. }
  9021. }
  9022. }
  9023. func (c *HisApiController) CheckTreatment() {
  9024. patient_id, _ := c.GetInt64("patient_id")
  9025. id_card_no := c.GetString("id_card_no")
  9026. insutype := c.GetString("insutype")
  9027. med_type := c.GetString("med_type")
  9028. admin_user_id, _ := c.GetInt64("admin_user_id")
  9029. adminUser := c.GetAdminUserInfo()
  9030. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9031. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9032. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9033. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9034. if miConfig.MdtrtareaAdmvs == "421300" {
  9035. var res ResultTwo
  9036. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9037. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9038. "&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)
  9039. resp, requestErr := http.Get(api)
  9040. if requestErr != nil {
  9041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9042. return
  9043. }
  9044. body, ioErr := ioutil.ReadAll(resp.Body)
  9045. if ioErr != nil {
  9046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9048. return
  9049. }
  9050. var respJSON map[string]interface{}
  9051. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9054. return
  9055. }
  9056. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9057. result, _ := json.Marshal(respJSON)
  9058. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9059. utils.ErrorLog("解析失败:%v", err)
  9060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9061. return
  9062. }
  9063. if res.Infcode == 0 {
  9064. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9065. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9066. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9067. resp, requestErr := http.Get(api)
  9068. if requestErr != nil {
  9069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9070. return
  9071. }
  9072. body, ioErr := ioutil.ReadAll(resp.Body)
  9073. if ioErr != nil {
  9074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9076. return
  9077. }
  9078. var respJSON map[string]interface{}
  9079. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9082. return
  9083. }
  9084. var res Result2001
  9085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9086. result2, _ := json.Marshal(respJSON)
  9087. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9088. utils.ErrorLog("解析失败:%v", err)
  9089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9090. return
  9091. }
  9092. if res.Infcode == 0 {
  9093. c.ServeSuccessJSON(map[string]interface{}{
  9094. "msg": res.Output.Trtinfo,
  9095. })
  9096. }
  9097. } else {
  9098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9099. return
  9100. }
  9101. } else {
  9102. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9103. var dat map[string]interface{}
  9104. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9105. fmt.Println(dat)
  9106. } else {
  9107. fmt.Println(err)
  9108. }
  9109. userJSONBytes, _ := json.Marshal(dat)
  9110. var res ResultTwo
  9111. var res10265 ResultTwo10265
  9112. if miConfig.Code == "H15049901371" {
  9113. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9114. utils.ErrorLog("解析失败:%v", err)
  9115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9116. return
  9117. }
  9118. res.ErrMsg = res10265.ErrMsg
  9119. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9120. res.Infcode = infocode
  9121. res.Output = res10265.Output
  9122. res.InfRefmsgid = res10265.InfRefmsgid
  9123. } else {
  9124. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9125. utils.ErrorLog("解析失败:%v", err)
  9126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9127. return
  9128. }
  9129. }
  9130. var user_name string
  9131. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9132. if role.ID == 0 {
  9133. user_name = "xxx"
  9134. } else {
  9135. user_name = role.UserName
  9136. }
  9137. baseParams := models.BaseParams{
  9138. SecretKey: miConfig.SecretKey,
  9139. FixmedinsCode: miConfig.Code,
  9140. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9141. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9142. OrgName: miConfig.OrgName,
  9143. Doctor: user_name,
  9144. }
  9145. if config.IsOpen == 1 {
  9146. if miConfig.Code == "H15049901371" {
  9147. if med_type == "14" {
  9148. if insutype == "390" {
  9149. med_type = "9933"
  9150. } else if insutype == "310" {
  9151. med_type = "990502"
  9152. }
  9153. } else if med_type == "11" {
  9154. med_type = "11"
  9155. }
  9156. }
  9157. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9158. var dat map[string]interface{}
  9159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9160. fmt.Println(dat)
  9161. } else {
  9162. fmt.Println(err)
  9163. }
  9164. var res Result2001
  9165. var res10265 Result2001Org10265
  9166. if miConfig.Code == "H15049901371" {
  9167. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9168. utils.ErrorLog("解析失败:%v", err)
  9169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9170. return
  9171. }
  9172. res.ErrMsg = res10265.ErrMsg
  9173. res.Output = res10265.Output
  9174. res.InfRefmsgid = res10265.InfRefmsgid
  9175. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9176. res.Infcode = infocode
  9177. } else {
  9178. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9179. utils.ErrorLog("解析失败:%v", err)
  9180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9181. return
  9182. }
  9183. }
  9184. if res.Infcode == 0 {
  9185. c.ServeSuccessJSON(map[string]interface{}{
  9186. "msg": res.Output.Trtinfo,
  9187. })
  9188. }
  9189. }
  9190. }
  9191. }
  9192. //func (c *HisApiController) PutRecord() {
  9193. // id, _ := c.GetInt64("id")
  9194. // record_time := c.GetString("record_time")
  9195. // timeLayout := "2006-01-02"
  9196. // loc, _ := time.LoadLocation("Local")
  9197. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9198. // if err != nil {
  9199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9200. // return
  9201. // }
  9202. // recordDateTime := theTime.Unix()
  9203. //
  9204. // adminInfo := c.GetAdminUserInfo()
  9205. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9206. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9207. //
  9208. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9209. //
  9210. // fmt.Println(miConfig.SecretKey)
  9211. //
  9212. // if patient == nil {
  9213. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9214. // return
  9215. // }
  9216. // if len(patient.IdCardNo) == 0 {
  9217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9218. // return
  9219. // }
  9220. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9221. // if config.IsOpen == 1 {
  9222. // 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
  9223. // resp, requestErr := http.Get(api)
  9224. // if requestErr != nil {
  9225. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9226. // return
  9227. // }
  9228. // defer resp.Body.Close()
  9229. // body, ioErr := ioutil.ReadAll(resp.Body)
  9230. // if ioErr != nil {
  9231. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9233. // return
  9234. // }
  9235. // var respJSON map[string]interface{}
  9236. //
  9237. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9238. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9239. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9240. // return
  9241. // }
  9242. //
  9243. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9244. // userJSONBytes, _ := json.Marshal(userJSON)
  9245. // var res ResultTwo
  9246. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9247. // utils.ErrorLog("解析失败:%v", err)
  9248. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9249. // return
  9250. // }
  9251. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9252. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9253. // infoStr := string(Iinfos)
  9254. // idetinfoStr := string(Idetinfos)
  9255. //
  9256. // if res.Infcode == 0 {
  9257. // his := models.VMHisPatient{
  9258. // Status: 1,
  9259. // Ctime: time.Now().Unix(),
  9260. // Mtime: time.Now().Unix(),
  9261. // PsnNo: res.Output.Baseinfo.PsnNo,
  9262. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9263. // Certno: res.Output.Baseinfo.Certno,
  9264. // PsnName: res.Output.Baseinfo.PsnName,
  9265. // Gend: res.Output.Baseinfo.Gend,
  9266. // Naty: res.Output.Baseinfo.Naty,
  9267. // Brdy: res.Output.Baseinfo.Brdy,
  9268. // Age: res.Output.Baseinfo.Age,
  9269. // Iinfo: infoStr,
  9270. // Idetinfo: idetinfoStr,
  9271. // PatientId: patient.ID,
  9272. // RecordDate: theTime.Unix(),
  9273. // UserOrgId: adminInfo.CurrentOrgId,
  9274. // AdminUserId: adminInfo.AdminUser.Id,
  9275. // IsReturn: 1,
  9276. // }
  9277. //
  9278. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9279. // //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")
  9280. // //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")
  9281. //
  9282. // //var dat map[string]interface{}
  9283. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9284. // // fmt.Println(dat)
  9285. // //} else {
  9286. // // fmt.Println(err)
  9287. // //}
  9288. //
  9289. // var dat2 map[string]interface{}
  9290. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9291. // fmt.Println(dat2)
  9292. // } else {
  9293. // fmt.Println(err)
  9294. // }
  9295. //
  9296. // } else {
  9297. // adminUser := c.GetAdminUserInfo()
  9298. // errlog := &models.HisOrderError{
  9299. // UserOrgId: adminUser.CurrentOrgId,
  9300. // Ctime: time.Now().Unix(),
  9301. // Mtime: time.Now().Unix(),
  9302. // ErrMsg: res.ErrMsg,
  9303. // Status: 1,
  9304. // PatientId: id,
  9305. // RecordTime: recordDateTime,
  9306. // Stage: 1,
  9307. // }
  9308. // service.CreateErrMsgLog(errlog)
  9309. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9310. // return
  9311. // }
  9312. // }
  9313. //
  9314. //}
  9315. //func (c *HisApiController) GetUploadDiag() {
  9316. // id, _ := c.GetInt64("id")
  9317. // record_time := c.GetString("record_time")
  9318. //
  9319. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9320. // sick_type, _ := c.GetInt64("sick_type")
  9321. // reg_type, _ := c.GetInt64("reg_type")
  9322. //
  9323. // timeLayout := "2006-01-02"
  9324. // loc, _ := time.LoadLocation("Local")
  9325. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9326. // if err != nil {
  9327. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9328. // return
  9329. // }
  9330. //
  9331. // var patientPrescription models.HisPrescriptionInfo
  9332. // recordDateTime := theTime.Unix()
  9333. // adminInfo := c.GetAdminUserInfo()
  9334. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9335. //
  9336. // if patientPrescription.ID == 0 {
  9337. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9338. // }
  9339. //
  9340. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9341. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9342. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9343. // sickConfig, _ := service.FindSickById(sick_type)
  9344. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9345. //
  9346. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9347. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9348. // "&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 +
  9349. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9350. // resp2, requestErr2 := http.Get(api2)
  9351. // if requestErr2 != nil {
  9352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9353. // return
  9354. // }
  9355. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9356. // if ioErr2 != nil {
  9357. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9358. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9359. // return
  9360. // }
  9361. // var respJSON2 map[string]interface{}
  9362. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9363. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9364. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9365. // return
  9366. // }
  9367. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9368. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9369. //
  9370. // var res2 ResultSix
  9371. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9372. // utils.ErrorLog("解析失败:%v", err)
  9373. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9374. // return
  9375. // }
  9376. // if res2.Infcode != 0 {
  9377. // adminUser := c.GetAdminUserInfo()
  9378. // errlog := &models.HisOrderError{
  9379. // UserOrgId: adminUser.CurrentOrgId,
  9380. // Ctime: time.Now().Unix(),
  9381. // Mtime: time.Now().Unix(),
  9382. // ErrMsg: res2.ErrMsg,
  9383. // Status: 1,
  9384. // PatientId: id,
  9385. // RecordTime: recordDateTime,
  9386. // Stage: 3,
  9387. // }
  9388. // service.CreateErrMsgLog(errlog)
  9389. //
  9390. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9391. // return
  9392. // }
  9393. //
  9394. // c.ServeSuccessJSON(map[string]interface{}{
  9395. // "msg": "上传成功",
  9396. // })
  9397. //
  9398. //}
  9399. type QueryResult struct {
  9400. ID int64
  9401. Name string
  9402. Code string
  9403. List_type_code string
  9404. }
  9405. func (c *HisApiController) GetCheckCode() {
  9406. ids_str := c.GetString("ids")
  9407. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9408. ids_arr := strings.Split(ids_str, ",")
  9409. var queryResult []QueryResult
  9410. ids := make([]int64, 0)
  9411. for _, item := range ids_arr {
  9412. id, _ := strconv.ParseInt(item, 10, 64)
  9413. ids = append(ids, id)
  9414. }
  9415. if record_type == 1 {
  9416. drugs, _ := service.GetBatchDrugList(ids)
  9417. for _, item := range drugs {
  9418. result := QueryResult{
  9419. ID: item.ID,
  9420. Name: item.DrugName,
  9421. Code: item.MedicalInsuranceNumber,
  9422. List_type_code: "101",
  9423. }
  9424. queryResult = append(queryResult, result)
  9425. }
  9426. } else if record_type == 2 {
  9427. goods, _ := service.GetBatchGoodInformationList(ids)
  9428. for _, item := range goods {
  9429. result := QueryResult{
  9430. ID: item.ID,
  9431. Name: item.GoodName,
  9432. Code: item.MedicalInsuranceNumber,
  9433. List_type_code: "301",
  9434. }
  9435. queryResult = append(queryResult, result)
  9436. }
  9437. } else if record_type == 3 {
  9438. projects, _ := service.GetBathchMyPorjecgList(ids)
  9439. for _, item := range projects {
  9440. result := QueryResult{
  9441. ID: item.ID,
  9442. Name: item.ProjectName,
  9443. Code: item.MedicalCode,
  9444. List_type_code: "201",
  9445. }
  9446. queryResult = append(queryResult, result)
  9447. }
  9448. }
  9449. admin_user_id, _ := c.GetInt64("admin_user_id")
  9450. adminUser := c.GetAdminUserInfo()
  9451. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9452. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9453. var user_name string
  9454. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9455. if role.ID == 0 {
  9456. user_name = "xxx"
  9457. } else {
  9458. user_name = role.UserName
  9459. }
  9460. baseParams := &models.BaseParams{
  9461. SecretKey: miConfig.SecretKey,
  9462. FixmedinsCode: miConfig.Code,
  9463. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9464. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9465. OrgName: miConfig.OrgName,
  9466. Doctor: user_name,
  9467. }
  9468. if config.IsOpen == 1 {
  9469. for _, item := range queryResult {
  9470. var result string
  9471. if record_type == 1 {
  9472. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9473. } else if record_type == 2 {
  9474. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9475. } else if record_type == 3 {
  9476. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9477. }
  9478. var dat map[string]interface{}
  9479. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9480. fmt.Println(dat)
  9481. } else {
  9482. fmt.Println(err)
  9483. }
  9484. userJSONBytes, _ := json.Marshal(dat)
  9485. var res ResultSix
  9486. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9487. utils.ErrorLog("解析失败:%v", err)
  9488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9489. return
  9490. }
  9491. if res.Infcode == 0 {
  9492. if record_type == 1 {
  9493. service.UpdateBaseDrugById(item.ID)
  9494. } else if record_type == 2 {
  9495. service.UpdateGoodInformaitonByDetail(item.ID)
  9496. } else if record_type == 3 {
  9497. service.UpdateProjectById(item.ID)
  9498. }
  9499. c.ServeSuccessJSON(map[string]interface{}{
  9500. "failed_code": 0,
  9501. "msg": "目录对照成功",
  9502. })
  9503. } else {
  9504. c.ServeSuccessJSON(map[string]interface{}{
  9505. "failed_code": -10,
  9506. "msg": res.ErrMsg,
  9507. })
  9508. }
  9509. }
  9510. }
  9511. }
  9512. func (c *HisApiController) UnCheckCode() {
  9513. ids_str := c.GetString("ids")
  9514. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9515. admin_user_id, _ := c.GetInt64("admin_user_id")
  9516. ids_arr := strings.Split(ids_str, ",")
  9517. var queryResult []QueryResult
  9518. ids := make([]int64, 0)
  9519. for _, item := range ids_arr {
  9520. id, _ := strconv.ParseInt(item, 10, 64)
  9521. ids = append(ids, id)
  9522. }
  9523. if record_type == 1 {
  9524. drugs, _ := service.GetBatchDrugList(ids)
  9525. for _, item := range drugs {
  9526. result := QueryResult{
  9527. ID: item.ID,
  9528. Name: item.DrugName,
  9529. Code: item.MedicalInsuranceNumber,
  9530. List_type_code: "101",
  9531. }
  9532. queryResult = append(queryResult, result)
  9533. }
  9534. } else if record_type == 2 {
  9535. goods, _ := service.GetBatchGoodInformationList(ids)
  9536. for _, item := range goods {
  9537. result := QueryResult{
  9538. ID: item.ID,
  9539. Name: item.GoodName,
  9540. Code: item.MedicalInsuranceNumber,
  9541. List_type_code: "301",
  9542. }
  9543. queryResult = append(queryResult, result)
  9544. }
  9545. } else if record_type == 3 {
  9546. projects, _ := service.GetBathchMyPorjecgList(ids)
  9547. for _, item := range projects {
  9548. result := QueryResult{
  9549. ID: item.ID,
  9550. Name: item.ProjectName,
  9551. Code: item.MedicalCode,
  9552. List_type_code: "201",
  9553. }
  9554. queryResult = append(queryResult, result)
  9555. }
  9556. }
  9557. adminUser := c.GetAdminUserInfo()
  9558. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9559. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9560. var user_name string
  9561. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9562. if role.ID == 0 {
  9563. user_name = "xxx"
  9564. } else {
  9565. user_name = role.UserName
  9566. }
  9567. baseParams := &models.BaseParams{
  9568. SecretKey: miConfig.SecretKey,
  9569. FixmedinsCode: miConfig.Code,
  9570. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9571. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9572. OrgName: miConfig.OrgName,
  9573. Doctor: user_name,
  9574. }
  9575. if config.IsOpen == 1 {
  9576. for _, item := range queryResult {
  9577. var result string
  9578. if record_type == 1 {
  9579. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9580. } else if record_type == 2 {
  9581. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9582. } else if record_type == 3 {
  9583. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9584. }
  9585. var dat2 map[string]interface{}
  9586. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9587. fmt.Println(dat2)
  9588. } else {
  9589. fmt.Println(err)
  9590. }
  9591. userJSONBytes, _ := json.Marshal(dat2)
  9592. var res ResultSix
  9593. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9594. utils.ErrorLog("解析失败:%v", err)
  9595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9596. return
  9597. }
  9598. if res.Infcode == 0 {
  9599. if record_type == 1 {
  9600. service.UpdateDrugByIdDetail(item.ID)
  9601. } else if record_type == 2 {
  9602. service.UpdateGoodInfoById(item.ID)
  9603. } else if record_type == 3 {
  9604. service.UpdateMyProjectById(item.ID)
  9605. }
  9606. c.ServeSuccessJSON(map[string]interface{}{
  9607. "failed_code": 0,
  9608. "msg": "撤销目录对照成功",
  9609. })
  9610. } else {
  9611. c.ServeSuccessJSON(map[string]interface{}{
  9612. "failed_code": -10,
  9613. "msg": res.ErrMsg,
  9614. })
  9615. }
  9616. }
  9617. }
  9618. }
  9619. func (c *HisApiController) GetPatientInfo() {
  9620. id_card_no := c.GetString("id_card_no")
  9621. admin_user_id, _ := c.GetInt64("admin_user_id")
  9622. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9623. if patient.ID == 0 {
  9624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9625. return
  9626. }
  9627. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9628. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9629. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9630. if config.IsOpen == 1 {
  9631. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9632. var dat map[string]interface{}
  9633. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9634. fmt.Println(dat)
  9635. } else {
  9636. fmt.Println(err)
  9637. }
  9638. userJSONBytes, _ := json.Marshal(dat)
  9639. var res ResultTwo
  9640. var res10265 ResultTwo10265
  9641. if miConfig.Code == "H15049901371" {
  9642. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9643. utils.ErrorLog("解析失败:%v", err)
  9644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9645. return
  9646. }
  9647. res.ErrMsg = res10265.ErrMsg
  9648. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9649. res.Infcode = infocode
  9650. res.Output = res10265.Output
  9651. res.InfRefmsgid = res10265.InfRefmsgid
  9652. } else {
  9653. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9654. utils.ErrorLog("解析失败:%v", err)
  9655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9656. return
  9657. }
  9658. }
  9659. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9660. // utils.ErrorLog("解析失败:%v", err)
  9661. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9662. // return
  9663. //}
  9664. if res.Infcode != 0 {
  9665. c.ServeSuccessJSON(map[string]interface{}{
  9666. "failed_code": -10,
  9667. "msg": res.ErrMsg,
  9668. })
  9669. } else {
  9670. c.ServeSuccessJSON(map[string]interface{}{
  9671. "failed_code": 0,
  9672. "info": res,
  9673. })
  9674. }
  9675. }
  9676. }
  9677. func (c *HisApiController) PsnPutOnRecord() {
  9678. record_type, _ := c.GetInt64("type")
  9679. patient_id, _ := c.GetInt64("patient_id")
  9680. admin_user_id, _ := c.GetInt64("admin_user_id")
  9681. start_time := c.GetString("start_time")
  9682. end_time := c.GetString("end_time")
  9683. adminUser := c.GetAdminUserInfo()
  9684. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9685. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9686. var patients []*models.Patients
  9687. if record_type == 1 { //全部备案
  9688. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9689. patients = append(patients, patient...)
  9690. } else { //单个备案
  9691. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9692. patients = append(patients, patient)
  9693. }
  9694. var user_name string
  9695. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9696. if role.ID == 0 {
  9697. user_name = "xxx"
  9698. } else {
  9699. user_name = role.UserName
  9700. }
  9701. if config.IsOpen == 1 {
  9702. for _, item := range patients {
  9703. 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
  9704. resp, requestErr := http.Get(api)
  9705. if requestErr != nil {
  9706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9707. return
  9708. }
  9709. defer resp.Body.Close()
  9710. body, ioErr := ioutil.ReadAll(resp.Body)
  9711. if ioErr != nil {
  9712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9714. return
  9715. }
  9716. var respJSON map[string]interface{}
  9717. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9720. return
  9721. }
  9722. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9723. userJSONBytes, _ := json.Marshal(userJSON)
  9724. var res ResultTwo
  9725. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9726. utils.ErrorLog("解析失败:%v", err)
  9727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9728. return
  9729. }
  9730. if res.Infcode == 0 {
  9731. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9732. var dat map[string]interface{}
  9733. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9734. fmt.Println(dat)
  9735. } else {
  9736. fmt.Println(err)
  9737. }
  9738. userJSONBytes, _ := json.Marshal(dat)
  9739. var res2 ResultThirteen
  9740. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9741. utils.ErrorLog("解析失败:%v", err)
  9742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9743. return
  9744. }
  9745. if res2.Infcode == 0 {
  9746. psnResult := &models.GdybPsnRecord{
  9747. UserOrgId: adminUser.CurrentOrgId,
  9748. PatientId: item.ID,
  9749. PsnNo: res.Output.Baseinfo.PsnNo,
  9750. Ctime: time.Now().Unix(),
  9751. Mtime: time.Now().Unix(),
  9752. Status: 1,
  9753. IsCancel: 1,
  9754. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9755. }
  9756. service.CreatePsnRecord(psnResult)
  9757. } else {
  9758. c.ServeSuccessJSON(map[string]interface{}{
  9759. "failed_code": -10,
  9760. "msg": res2.ErrMsg,
  9761. })
  9762. return
  9763. }
  9764. }
  9765. }
  9766. }
  9767. }
  9768. func (c *HisApiController) PsnUnPutOnRecord() {
  9769. id, _ := c.GetInt64("id")
  9770. //record_type, _ := c.GetInt64("type")
  9771. admin_user_id, _ := c.GetInt64("admin_user_id")
  9772. adminUser := c.GetAdminUserInfo()
  9773. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9774. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9775. var user_name string
  9776. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9777. if role.ID == 0 {
  9778. user_name = "xxx"
  9779. } else {
  9780. user_name = role.UserName
  9781. }
  9782. psn_record, _ := service.GetPsnRecordById(id)
  9783. if psn_record.ID == 0 {
  9784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9785. return
  9786. }
  9787. if config.IsOpen == 1 {
  9788. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9789. var dat map[string]interface{}
  9790. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9791. fmt.Println(dat)
  9792. } else {
  9793. fmt.Println(err)
  9794. }
  9795. userJSONBytes, _ := json.Marshal(dat)
  9796. var res ResultFourteen
  9797. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9798. utils.ErrorLog("解析失败:%v", err)
  9799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9800. return
  9801. }
  9802. if res.Infcode == 0 {
  9803. psn_record.IsCancel = 2
  9804. service.CreatePsnRecord(&psn_record)
  9805. } else {
  9806. c.ServeSuccessJSON(map[string]interface{}{
  9807. "failed_code": -10,
  9808. "msg": res.ErrMsg,
  9809. })
  9810. return
  9811. }
  9812. }
  9813. }
  9814. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9815. patient_id, _ := c.GetInt64("patient_id")
  9816. insutype_two := c.GetString("insutype")
  9817. psn_no := c.GetString("psn_no")
  9818. doctor_id, _ := c.GetInt64("doctor_id")
  9819. sick_id, _ := c.GetInt64("sick_id")
  9820. department_id, _ := c.GetInt64("department_id")
  9821. start_time := c.GetString("start_time")
  9822. end_time := c.GetString("end_time")
  9823. check_time := c.GetString("check_time")
  9824. adminUser := c.GetAdminUserInfo()
  9825. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9826. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9827. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9828. sick, _ := service.FindSickById(sick_id)
  9829. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9830. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9831. var res ResultTwo
  9832. var res10265 ResultTwo10265
  9833. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9834. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9835. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9836. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9837. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(3, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  9838. resp, requestErr := http.Get(api)
  9839. if requestErr != nil {
  9840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9841. return
  9842. }
  9843. body, ioErr := ioutil.ReadAll(resp.Body)
  9844. if ioErr != nil {
  9845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9847. return
  9848. }
  9849. var respJSON map[string]interface{}
  9850. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9853. return
  9854. }
  9855. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9856. result, _ := json.Marshal(respJSON)
  9857. fmt.Println("log")
  9858. fmt.Println(string(result))
  9859. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9860. utils.ErrorLog("解析失败:%v", err)
  9861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9862. return
  9863. }
  9864. res.ErrMsg = res10265.ErrMsg
  9865. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9866. res.Infcode = infocode
  9867. res.Output = res10265.Output
  9868. res.InfRefmsgid = res10265.InfRefmsgid
  9869. } else {
  9870. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9871. if miConfig.Code == "H15049901371" {
  9872. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9873. utils.ErrorLog("解析失败:%v", err)
  9874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9875. return
  9876. }
  9877. res.ErrMsg = res10265.ErrMsg
  9878. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9879. res.Infcode = infocode
  9880. res.Output = res10265.Output
  9881. res.InfRefmsgid = res10265.InfRefmsgid
  9882. } else {
  9883. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9884. utils.ErrorLog("解析失败:%v", err)
  9885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9886. return
  9887. }
  9888. }
  9889. }
  9890. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9891. infoStr := string(Iinfos)
  9892. var rf []*ResultFive
  9893. json.Unmarshal([]byte(infoStr), &rf)
  9894. var insuplc_admdvs string
  9895. var insutype string
  9896. var is390 int = 0
  9897. var is310 int = 0
  9898. var insutypes []*ResultFive
  9899. for _, item := range rf {
  9900. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9901. insutypes = append(insutypes, item)
  9902. }
  9903. }
  9904. if len(insutypes) == 1 {
  9905. insutype = insutypes[0].Insutype
  9906. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9907. } else {
  9908. for _, i := range insutypes {
  9909. if i.Insutype == "390" {
  9910. is390 = 1
  9911. }
  9912. if i.Insutype == "310" {
  9913. is310 = 1
  9914. }
  9915. }
  9916. }
  9917. if is390 == 1 {
  9918. insutype = "390"
  9919. }
  9920. if is310 == 1 {
  9921. insutype = "310"
  9922. }
  9923. if len(insutypes) == 2 {
  9924. insutype = insutype_two
  9925. }
  9926. if len(insutypes) == 0 {
  9927. insutype = "310"
  9928. }
  9929. insutype = insutype_two
  9930. fmt.Println(insutype)
  9931. for _, item := range rf {
  9932. fmt.Println(item.Insutype)
  9933. fmt.Println(insutype)
  9934. if item.Insutype == insutype {
  9935. fmt.Println(item.Insutype)
  9936. fmt.Println(insutype)
  9937. insuplc_admdvs = item.InsuplcAdmdvs
  9938. }
  9939. }
  9940. fmt.Println(insuplc_admdvs)
  9941. var res2 ResultThirteen
  9942. var res10265_2 ResultThirteen10265
  9943. if config.IsOpen == 1 {
  9944. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9945. } else {
  9946. 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)
  9947. var dat map[string]interface{}
  9948. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9949. fmt.Println(dat)
  9950. } else {
  9951. fmt.Println(err)
  9952. }
  9953. userJSONBytes, _ := json.Marshal(dat)
  9954. if miConfig.Code == "H15049901371" {
  9955. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9956. utils.ErrorLog("解析失败:%v", err)
  9957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9958. return
  9959. }
  9960. res2.ErrMsg = res10265_2.ErrMsg
  9961. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9962. res2.Infcode = infocode
  9963. res2.Output = res10265_2.Output
  9964. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9965. } else {
  9966. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9967. utils.ErrorLog("解析失败:%v", err)
  9968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9969. return
  9970. }
  9971. }
  9972. }
  9973. if res2.Infcode == 0 {
  9974. psnResult := &models.GdybPsnNcdsRecord{
  9975. UserOrgId: adminUser.CurrentOrgId,
  9976. PatientId: patient.ID,
  9977. PsnNo: psn_no,
  9978. DoctorId: doctor.AdminUserId,
  9979. DepartmentId: department_id,
  9980. SickType: sick_id,
  9981. Insutype: insutype,
  9982. Ctime: time.Now().Unix(),
  9983. Mtime: time.Now().Unix(),
  9984. Status: 1,
  9985. IsCancel: 1,
  9986. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9987. }
  9988. service.CreatePsnNCDSRecord(psnResult)
  9989. c.ServeSuccessJSON(map[string]interface{}{
  9990. "failed_code": 0,
  9991. "msg": "备案成功",
  9992. "result": psnResult,
  9993. })
  9994. } else {
  9995. c.ServeSuccessJSON(map[string]interface{}{
  9996. "failed_code": -10,
  9997. "msg": res2.ErrMsg,
  9998. })
  9999. return
  10000. }
  10001. }
  10002. }
  10003. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10004. id, _ := c.GetInt64("id")
  10005. admin_user_id, _ := c.GetInt64("admin_user_id")
  10006. adminUser := c.GetAdminUserInfo()
  10007. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10008. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10009. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10010. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10011. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10012. //var user_name string
  10013. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10014. //if role.ID == 0 {
  10015. // user_name = "xxx"
  10016. //} else {
  10017. // user_name = role.UserName
  10018. //}
  10019. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10020. if psn_record.ID == 0 {
  10021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10022. return
  10023. }
  10024. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10025. var res ResultTwo
  10026. var res10265 ResultTwo10265
  10027. if miConfig.Code == "H15049901371" {
  10028. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10029. utils.ErrorLog("解析失败:%v", err)
  10030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10031. return
  10032. }
  10033. res.ErrMsg = res10265.ErrMsg
  10034. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10035. res.Infcode = infocode
  10036. res.Output = res10265.Output
  10037. res.InfRefmsgid = res10265.InfRefmsgid
  10038. } else {
  10039. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10040. utils.ErrorLog("解析失败:%v", err)
  10041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10042. return
  10043. }
  10044. }
  10045. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10046. infoStr := string(Iinfos)
  10047. var rf []*ResultFive
  10048. json.Unmarshal([]byte(infoStr), &rf)
  10049. var insuplc_admdvs string
  10050. var insutype string
  10051. var is390 int = 0
  10052. var is310 int = 0
  10053. var insutypes []*ResultFive
  10054. for _, item := range rf {
  10055. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10056. insutypes = append(insutypes, item)
  10057. }
  10058. }
  10059. if len(insutypes) == 1 {
  10060. insutype = insutypes[0].Insutype
  10061. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10062. } else {
  10063. for _, i := range insutypes {
  10064. if i.Insutype == "390" {
  10065. is390 = 1
  10066. }
  10067. if i.Insutype == "310" {
  10068. is310 = 1
  10069. }
  10070. }
  10071. }
  10072. if is390 == 1 {
  10073. insutype = "390"
  10074. }
  10075. if is310 == 1 {
  10076. insutype = "310"
  10077. }
  10078. if len(insutypes) == 0 {
  10079. insutype = "310"
  10080. }
  10081. insutype = psn_record.Insutype
  10082. for _, item := range rf {
  10083. if item.Insutype == insutype {
  10084. insuplc_admdvs = item.InsuplcAdmdvs
  10085. }
  10086. }
  10087. if config.IsOpen == 1 {
  10088. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10089. var dat map[string]interface{}
  10090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10091. fmt.Println(dat)
  10092. } else {
  10093. fmt.Println(err)
  10094. }
  10095. userJSONBytes, _ := json.Marshal(dat)
  10096. var res ResultFourteen
  10097. var res10265 ResultFourteen10265
  10098. if miConfig.Code == "H15049901371" {
  10099. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10100. utils.ErrorLog("解析失败:%v", err)
  10101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10102. return
  10103. }
  10104. res.ErrMsg = res10265.ErrMsg
  10105. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10106. res.Infcode = infocode
  10107. res.Output = res10265.Output
  10108. res.InfRefmsgid = res10265.InfRefmsgid
  10109. } else {
  10110. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10111. utils.ErrorLog("解析失败:%v", err)
  10112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10113. return
  10114. }
  10115. }
  10116. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10117. // utils.ErrorLog("解析失败:%v", err)
  10118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10119. // return
  10120. //}
  10121. if res.Infcode == 0 {
  10122. psn_record.IsCancel = 2
  10123. service.CreatePsnNCDSRecord(&psn_record)
  10124. c.ServeSuccessJSON(map[string]interface{}{
  10125. "failed_code": 0,
  10126. "msg": "撤销备案成功",
  10127. })
  10128. } else {
  10129. c.ServeSuccessJSON(map[string]interface{}{
  10130. "failed_code": -10,
  10131. "msg": res.ErrMsg,
  10132. })
  10133. return
  10134. }
  10135. }
  10136. }
  10137. func (c *HisApiController) TestTest() {
  10138. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10139. fmt.Println(patient.Iinfo)
  10140. }
  10141. type CustomData struct {
  10142. MsgId string
  10143. PsnNo string
  10144. Info string
  10145. }
  10146. func (c *HisApiController) ReversalData() {
  10147. var customData []*CustomData
  10148. custom := &CustomData{
  10149. MsgId: "H44022900158202103301714472004",
  10150. PsnNo: "44020000001101329945",
  10151. Info: "2207",
  10152. }
  10153. customData = append(customData, custom)
  10154. custom1 := &CustomData{
  10155. MsgId: "H4402290015820210330172057803",
  10156. PsnNo: "44020000001101161813",
  10157. Info: "2207",
  10158. }
  10159. customData = append(customData, custom1)
  10160. custom2 := &CustomData{
  10161. MsgId: "H44022900158202103301705198813",
  10162. PsnNo: "44190000133097375417",
  10163. Info: "2207",
  10164. }
  10165. customData = append(customData, custom2)
  10166. custom3 := &CustomData{
  10167. MsgId: "H44022900158202103301715524756",
  10168. PsnNo: "44020000001100187221",
  10169. Info: "2207",
  10170. }
  10171. customData = append(customData, custom3)
  10172. custom4 := &CustomData{
  10173. MsgId: "H44022900158202103301730376224",
  10174. PsnNo: "44020000001101959155",
  10175. Info: "2207",
  10176. }
  10177. customData = append(customData, custom4)
  10178. custom5 := &CustomData{
  10179. MsgId: "H44022900158202103301748008725",
  10180. PsnNo: "44020000001104246641",
  10181. Info: "2207",
  10182. }
  10183. customData = append(customData, custom5)
  10184. custom6 := &CustomData{
  10185. MsgId: "H44022900158202103301718096755",
  10186. PsnNo: "44020000001102211860",
  10187. Info: "2207",
  10188. }
  10189. customData = append(customData, custom6)
  10190. custom7 := &CustomData{
  10191. MsgId: "H44022900158202103301736551640",
  10192. PsnNo: "44020000001102687718",
  10193. Info: "2207",
  10194. }
  10195. customData = append(customData, custom7)
  10196. custom8 := &CustomData{
  10197. MsgId: "H44022900158202103301743097676",
  10198. PsnNo: "44020000001102127785",
  10199. Info: "2207",
  10200. }
  10201. customData = append(customData, custom8)
  10202. custom9 := &CustomData{
  10203. MsgId: "H44022900158202103301712304203",
  10204. PsnNo: "44020000001101518097",
  10205. Info: "2207",
  10206. }
  10207. customData = append(customData, custom9)
  10208. custom10 := &CustomData{
  10209. MsgId: "H44022900158202103301738448785",
  10210. PsnNo: "44020000001100500813",
  10211. Info: "2207",
  10212. }
  10213. customData = append(customData, custom10)
  10214. custom11 := &CustomData{
  10215. MsgId: "H44022900158202103301732455843",
  10216. PsnNo: "44020000001102690557",
  10217. Info: "2207",
  10218. }
  10219. customData = append(customData, custom11)
  10220. custom12 := &CustomData{
  10221. MsgId: "H44022900158202103301745421708",
  10222. PsnNo: "44020000001102211928",
  10223. Info: "2207",
  10224. }
  10225. customData = append(customData, custom12)
  10226. custom1212 := &CustomData{
  10227. MsgId: "H440229001582021033017351627",
  10228. PsnNo: "44020000001102481733",
  10229. Info: "2207",
  10230. }
  10231. customData = append(customData, custom1212)
  10232. custom13 := &CustomData{
  10233. MsgId: "H44022900158202103301740327951",
  10234. PsnNo: "44020000001103174866",
  10235. Info: "2207",
  10236. }
  10237. customData = append(customData, custom13)
  10238. custom14 := &CustomData{
  10239. MsgId: "H4402290015820210330174922668",
  10240. PsnNo: "44020000001102927272",
  10241. Info: "2207",
  10242. }
  10243. customData = append(customData, custom14)
  10244. custom15 := &CustomData{
  10245. MsgId: "H44022900158202103301752362273",
  10246. PsnNo: "44020000001102942890",
  10247. Info: "2207",
  10248. }
  10249. customData = append(customData, custom15)
  10250. custom16 := &CustomData{
  10251. MsgId: "H44022900158202103301751082917",
  10252. PsnNo: "44020000001101662162",
  10253. Info: "2207",
  10254. }
  10255. customData = append(customData, custom16)
  10256. custom17 := &CustomData{
  10257. MsgId: "H44022900158202103301754147728",
  10258. PsnNo: "44020000000229014511",
  10259. Info: "2207",
  10260. }
  10261. customData = append(customData, custom17)
  10262. adminUser := c.GetAdminUserInfo()
  10263. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10264. for _, item := range customData {
  10265. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10266. fmt.Println(result)
  10267. }
  10268. }
  10269. func (c *HisApiController) GetAllopatry() {
  10270. year := c.GetString("year")
  10271. month := c.GetString("month")
  10272. admin_user_id, _ := c.GetInt64("admin_user_id")
  10273. adminUser := c.GetAdminUserInfo()
  10274. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10275. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10276. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10277. var dat map[string]interface{}
  10278. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10279. fmt.Println(dat)
  10280. } else {
  10281. fmt.Println(err)
  10282. }
  10283. userJSONBytes, _ := json.Marshal(dat)
  10284. var res models.Result9001
  10285. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10286. utils.ErrorLog("解析失败:%v", err)
  10287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10288. return
  10289. }
  10290. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10291. var dat2 map[string]interface{}
  10292. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10293. fmt.Println(dat)
  10294. } else {
  10295. fmt.Println(err)
  10296. }
  10297. userJSONBytes2, _ := json.Marshal(dat2)
  10298. var res2 models.Result3260
  10299. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10300. utils.ErrorLog("解析失败:%v", err)
  10301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10302. return
  10303. }
  10304. if res2.Infcode == 0 {
  10305. c.ServeSuccessJSON(map[string]interface{}{
  10306. "list": res2.Output.Data,
  10307. })
  10308. return
  10309. } else {
  10310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10311. return
  10312. }
  10313. }
  10314. func (c *HisApiController) ComfirmAllopatry() {
  10315. year := c.GetString("year")
  10316. month := c.GetString("month")
  10317. admin_user_id, _ := c.GetInt64("admin_user_id")
  10318. adminUser := c.GetAdminUserInfo()
  10319. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10320. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10321. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10322. var dat map[string]interface{}
  10323. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10324. fmt.Println(dat)
  10325. } else {
  10326. fmt.Println(err)
  10327. }
  10328. userJSONBytes, _ := json.Marshal(dat)
  10329. var res models.Result9001
  10330. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10331. utils.ErrorLog("解析失败:%v", err)
  10332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10333. return
  10334. }
  10335. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10336. var dat2 map[string]interface{}
  10337. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10338. fmt.Println(dat)
  10339. } else {
  10340. fmt.Println(err)
  10341. }
  10342. userJSONBytes2, _ := json.Marshal(dat2)
  10343. var res2 models.Result3260
  10344. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10345. utils.ErrorLog("解析失败:%v", err)
  10346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10347. return
  10348. }
  10349. if res2.Infcode == 0 {
  10350. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10351. var dat map[string]interface{}
  10352. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10353. fmt.Println(dat)
  10354. } else {
  10355. fmt.Println(err)
  10356. }
  10357. userJSONBytes, _ := json.Marshal(dat)
  10358. var res3 models.Result3261
  10359. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10360. utils.ErrorLog("解析失败:%v", err)
  10361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10362. return
  10363. }
  10364. if res3.Infcode == 0 {
  10365. record := &models.HisYidiClearRecord{
  10366. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10367. Ctime: time.Now().Unix(),
  10368. Mtime: time.Now().Unix(),
  10369. Status: 1,
  10370. MsgId: msgId,
  10371. }
  10372. service.SaveClearRecord(record)
  10373. c.ServeSuccessJSON(map[string]interface{}{
  10374. "msg": "提取成功",
  10375. })
  10376. }
  10377. }
  10378. }
  10379. func (c *HisApiController) RefundAllopatry() {
  10380. year := c.GetString("year")
  10381. month := c.GetString("month")
  10382. id, _ := c.GetInt64("id")
  10383. admin_user_id, _ := c.GetInt64("admin_user_id")
  10384. adminUser := c.GetAdminUserInfo()
  10385. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10386. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10387. record, _ := service.GetClearRecordById(id)
  10388. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10389. var dat map[string]interface{}
  10390. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10391. fmt.Println(dat)
  10392. } else {
  10393. fmt.Println(err)
  10394. }
  10395. userJSONBytes, _ := json.Marshal(dat)
  10396. var empty ResultFourteen
  10397. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10398. utils.ErrorLog("解析失败:%v", err)
  10399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10400. return
  10401. }
  10402. if empty.Infcode == 0 {
  10403. c.ServeSuccessJSON(map[string]interface{}{
  10404. "msg": "撤销成功",
  10405. })
  10406. return
  10407. }
  10408. }
  10409. func (c *HisApiController) ReversalOtherData() {
  10410. var customData []*CustomData
  10411. custom := &CustomData{
  10412. MsgId: "H44022900158202103301714472004",
  10413. PsnNo: "44020000001101329945",
  10414. Info: "2208",
  10415. }
  10416. customData = append(customData, custom)
  10417. custom1 := &CustomData{
  10418. MsgId: "H4402290015820210330172057803",
  10419. PsnNo: "44020000001101161813",
  10420. Info: "2208",
  10421. }
  10422. customData = append(customData, custom1)
  10423. custom2 := &CustomData{
  10424. MsgId: "H44022900158202103301705198813",
  10425. PsnNo: "44190000133097375417",
  10426. Info: "2208",
  10427. }
  10428. customData = append(customData, custom2)
  10429. custom3 := &CustomData{
  10430. MsgId: "H44022900158202103301715524756",
  10431. PsnNo: "44020000001100187221",
  10432. Info: "2208",
  10433. }
  10434. customData = append(customData, custom3)
  10435. custom4 := &CustomData{
  10436. MsgId: "H44022900158202103301730376224",
  10437. PsnNo: "44020000001101959155",
  10438. Info: "2208",
  10439. }
  10440. customData = append(customData, custom4)
  10441. custom5 := &CustomData{
  10442. MsgId: "H44022900158202103301748008725",
  10443. PsnNo: "44020000001104246641",
  10444. Info: "2208",
  10445. }
  10446. customData = append(customData, custom5)
  10447. custom6 := &CustomData{
  10448. MsgId: "H44022900158202103301718096755",
  10449. PsnNo: "44020000001102211860",
  10450. Info: "2208",
  10451. }
  10452. customData = append(customData, custom6)
  10453. custom7 := &CustomData{
  10454. MsgId: "H44022900158202103301736551640",
  10455. PsnNo: "44020000001102687718",
  10456. Info: "2208",
  10457. }
  10458. customData = append(customData, custom7)
  10459. custom8 := &CustomData{
  10460. MsgId: "H44022900158202103301743097676",
  10461. PsnNo: "44020000001102127785",
  10462. Info: "2208",
  10463. }
  10464. customData = append(customData, custom8)
  10465. custom9 := &CustomData{
  10466. MsgId: "H44022900158202103301712304203",
  10467. PsnNo: "44020000001101518097",
  10468. Info: "2208",
  10469. }
  10470. customData = append(customData, custom9)
  10471. custom10 := &CustomData{
  10472. MsgId: "H44022900158202103301738448785",
  10473. PsnNo: "44020000001100500813",
  10474. Info: "2208",
  10475. }
  10476. customData = append(customData, custom10)
  10477. custom11 := &CustomData{
  10478. MsgId: "H44022900158202103301732455843",
  10479. PsnNo: "44020000001102690557",
  10480. Info: "2208",
  10481. }
  10482. customData = append(customData, custom11)
  10483. custom12 := &CustomData{
  10484. MsgId: "H44022900158202103301745421708",
  10485. PsnNo: "44020000001102211928",
  10486. Info: "2208",
  10487. }
  10488. customData = append(customData, custom12)
  10489. custom1212 := &CustomData{
  10490. MsgId: "H440229001582021033017351627",
  10491. PsnNo: "44020000001102481733",
  10492. Info: "2208",
  10493. }
  10494. customData = append(customData, custom1212)
  10495. custom13 := &CustomData{
  10496. MsgId: "H44022900158202103301740327951",
  10497. PsnNo: "44020000001103174866",
  10498. Info: "2208",
  10499. }
  10500. customData = append(customData, custom13)
  10501. custom14 := &CustomData{
  10502. MsgId: "H4402290015820210330174922668",
  10503. PsnNo: "44020000001102927272",
  10504. Info: "2208",
  10505. }
  10506. customData = append(customData, custom14)
  10507. custom15 := &CustomData{
  10508. MsgId: "H44022900158202103301752362273",
  10509. PsnNo: "44020000001102942890",
  10510. Info: "2208",
  10511. }
  10512. customData = append(customData, custom15)
  10513. custom16 := &CustomData{
  10514. MsgId: "H44022900158202103301751082917",
  10515. PsnNo: "44020000001101662162",
  10516. Info: "2208",
  10517. }
  10518. customData = append(customData, custom16)
  10519. custom17 := &CustomData{
  10520. MsgId: "H44022900158202103301754147728",
  10521. PsnNo: "44020000000229014511",
  10522. Info: "2208",
  10523. }
  10524. customData = append(customData, custom17)
  10525. adminUser := c.GetAdminUserInfo()
  10526. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10527. for _, item := range customData {
  10528. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10529. fmt.Println(result)
  10530. }
  10531. }
  10532. func PathExists(path string) (bool, error) {
  10533. _, err := os.Stat(path)
  10534. if err == nil {
  10535. return true, nil
  10536. }
  10537. if os.IsNotExist(err) {
  10538. return false, nil
  10539. }
  10540. return false, err
  10541. }
  10542. //创建文件夹
  10543. func Mkdir(dir string) {
  10544. // 创建文件夹
  10545. exist, err := PathExists(dir)
  10546. if err != nil {
  10547. fmt.Println(err.Error())
  10548. } else {
  10549. if exist {
  10550. fmt.Println(dir + "文件夹已存在!")
  10551. } else {
  10552. // 文件夹名称,权限
  10553. err := os.Mkdir(dir, os.ModePerm)
  10554. if err != nil {
  10555. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10556. } else {
  10557. fmt.Println(dir + "文件夹创建成功!")
  10558. }
  10559. }
  10560. }
  10561. }
  10562. //压缩文件
  10563. func Zip(srcFile string, destZip string) error {
  10564. zipfile, err := os.Create(destZip)
  10565. if err != nil {
  10566. return err
  10567. }
  10568. defer zipfile.Close()
  10569. archive := zip.NewWriter(zipfile)
  10570. defer archive.Close()
  10571. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10572. if err != nil {
  10573. return err
  10574. }
  10575. header, err := zip.FileInfoHeader(info)
  10576. if err != nil {
  10577. return err
  10578. }
  10579. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10580. // header.Name = path
  10581. if info.IsDir() {
  10582. header.Name += "/"
  10583. } else {
  10584. header.Method = zip.Deflate
  10585. }
  10586. writer, err := archive.CreateHeader(header)
  10587. if err != nil {
  10588. return err
  10589. }
  10590. if !info.IsDir() {
  10591. file, err := os.Open(path)
  10592. if err != nil {
  10593. return err
  10594. }
  10595. defer file.Close()
  10596. _, err = io.Copy(writer, file)
  10597. }
  10598. return err
  10599. })
  10600. return err
  10601. }
  10602. func ReadFile(filePath string) []byte {
  10603. f, err := os.Open(filePath)
  10604. if err != nil {
  10605. fmt.Println("read file fail", err)
  10606. return nil
  10607. }
  10608. defer f.Close()
  10609. fd, err := ioutil.ReadAll(f)
  10610. if err != nil {
  10611. fmt.Println("read to fd fail", err)
  10612. return nil
  10613. }
  10614. return fd
  10615. }
  10616. func saveLog(result string, request string, infno string, desc string) {
  10617. org_id, _ := beego.AppConfig.Int64("org_id")
  10618. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10619. dir := miConfig.OrgName + "日志"
  10620. utils.Mkdir(dir)
  10621. month := time.Unix(1557042972, 0).Format("1")
  10622. year := time.Now().Format("2006")
  10623. month = time.Now().Format("01")
  10624. day := time.Now().Format("02")
  10625. hour := time.Now().Format("15")
  10626. min := time.Now().Format("04")
  10627. sec := time.Now().Format("05")
  10628. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10629. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10630. file_name := file + ".txt"
  10631. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10632. exist, _ := utils.PathExists(file_path)
  10633. if exist { //存在
  10634. fmt.Println("存在")
  10635. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10636. if err != nil {
  10637. fmt.Println("read fail")
  10638. }
  10639. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10640. n, _ := f.Seek(0, 2)
  10641. _, err = f.WriteAt([]byte(content), n)
  10642. } else { //不存在
  10643. fmt.Println("文件不存在,创建文件")
  10644. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10645. defer f.Close()
  10646. if err != nil {
  10647. } else {
  10648. _, err = f.Write([]byte("记录日志"))
  10649. }
  10650. }
  10651. }
  10652. type Charset string
  10653. const (
  10654. UTF8 = Charset("UTF-8")
  10655. GB18030 = Charset("GB18030")
  10656. )
  10657. func ConvertToString(src string, srcCode string, tagCode string) string {
  10658. srcCoder := mahonia.NewDecoder(srcCode)
  10659. srcResult := srcCoder.ConvertString(src)
  10660. tagCoder := mahonia.NewDecoder(tagCode)
  10661. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10662. result := string(cdata)
  10663. return result
  10664. }