his_api_controller.go 427KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686
  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. }
  76. func (c *HisApiController) Check3101() {
  77. patient_id, _ := c.GetInt64("patient_id")
  78. his_patient_id, _ := c.GetInt64("his_patient_id")
  79. admin_user_id, _ := c.GetInt64("admin_user_id")
  80. adminUser := c.GetAdminUserInfo()
  81. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  82. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  83. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  84. record_time := c.GetString("record_time")
  85. trig_scen := c.GetString("trig_scen")
  86. timeLayout := "2006-01-02"
  87. loc, _ := time.LoadLocation("Local")
  88. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  89. if err != nil {
  90. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  91. return
  92. }
  93. recordDateTime := theTime.Unix()
  94. var patientPrescription models.HisPrescriptionInfo
  95. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  96. if patientPrescription.ID == 0 {
  97. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  98. }
  99. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  100. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  101. //
  102. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  103. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  104. var pp models.PublicParams
  105. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  106. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  107. pp.FixmedinsName = miConfig.OrgName
  108. pp.FixmedinsCode = miConfig.Code
  109. pp.RequestUrl = miConfig.Url
  110. pp.Cainfo = miConfig.Cainfo
  111. pp.SecretKey = miConfig.SecretKey
  112. pp.AccessKey = miConfig.AccessKey
  113. pp.OpterName = roles.UserName
  114. var config []*models.HisXtDiagnoseConfig
  115. for _, item := range diagnosis_ids {
  116. id, _ := strconv.ParseInt(item, 10, 64)
  117. diagnosisConfig, _ := service.FindDiagnoseById(id)
  118. config = append(config, &diagnosisConfig)
  119. }
  120. var pd models.PatientDtos
  121. pd.PatnID = his.PsnNo
  122. pd.PatnName = his.Name
  123. pd.Gend = his.Gend
  124. pd.Brdy = his.Brdy
  125. pd.Poolarea = his.InsuplcAdmdvs
  126. pd.CurrMdtrtID = his.Number
  127. var fed models.FsiEncounterDtos
  128. fed.MdtrtID = his.Number
  129. fed.MedinsID = miConfig.Code
  130. fed.MedinsName = miConfig.OrgName
  131. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  132. fed.MedMdtrtType = "1"
  133. fed.MedinsType = "1"
  134. fed.MedinsLv = "11"
  135. tm := time.Unix(his.RecordDate, 0)
  136. s_tm := tm.Format("2006-01-02 15:04:05")
  137. fed.AdmDate = s_tm
  138. fed.DscgDate = s_tm
  139. fed.DscgMainDiseCodg = config[0].CountryCode
  140. fed.DscgMainDiseName = config[0].CountryContentName
  141. //诊断信息
  142. var fdds []*models.FsiDiagnoseDtos
  143. for index, item := range config {
  144. if index == 0 {
  145. var fdd models.FsiDiagnoseDtos
  146. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  147. fdd.InoutDiseType = "1"
  148. fdd.MaindiseFlag = "1"
  149. fdd.DiseDate = s_tm
  150. fdd.DiasSrtNo = "1"
  151. fdd.DiseName = item.CountryContentName
  152. fdd.DiseCodg = item.CountryCode
  153. fdds = append(fdds, &fdd)
  154. } else {
  155. var fdd models.FsiDiagnoseDtos
  156. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  157. fdd.InoutDiseType = "1"
  158. fdd.MaindiseFlag = "1"
  159. fdd.DiseDate = s_tm
  160. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  161. fdd.DiseName = item.CountryContentName
  162. fdd.DiseCodg = item.CountryCode
  163. fdds = append(fdds, &fdd)
  164. }
  165. }
  166. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  167. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  168. fed.AdmDeptName = department.Name
  169. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  170. fed.DscgDeptName = department.Name
  171. fed.MedMdtrtType = "1"
  172. if his.Insutype == "390" {
  173. fed.MedType = "1402"
  174. } else {
  175. fed.MedType = "9933"
  176. }
  177. var orders []*models.FsiOrderDtos
  178. if trig_scen == "2" {
  179. //处方医嘱信息
  180. for _, item := range prescriptions {
  181. for _, subItem := range item.HisDoctorAdviceInfo {
  182. var order models.FsiOrderDtos
  183. order.RxID = strconv.FormatInt(item.ID, 10)
  184. order.Rxno = strconv.FormatInt(item.ID, 10)
  185. order.LongDrordFlag = "0"
  186. order.HilistType = "1"
  187. order.ChrgType = "1"
  188. order.DrordBhvr = "-"
  189. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  190. order.HosplistName = subItem.BaseDrugLib.DrugName
  191. order.HilistLv = "1"
  192. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  193. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  194. order.HosplistName = subItem.BaseDrugLib.DrugName
  195. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  196. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  197. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  198. order.OwnpayAmt = ""
  199. order.SelfpayAmt = ""
  200. order.Spec = ""
  201. order.SpecUnt = ""
  202. order.DrordBegnDate = s_tm
  203. order.DrordStopDate = ""
  204. order.DrordDrCodg = "1"
  205. order.DrordDeptName = department.Name
  206. order.DrordDrCodg = "1"
  207. order.DrordDrName = doctor_info.UserName
  208. order.DrordDrProfttl = ""
  209. order.CurrDrordFlag = "1"
  210. orders = append(orders, &order)
  211. }
  212. for _, subItem := range item.HisPrescriptionProject {
  213. if subItem.Type == 2 {
  214. var order models.FsiOrderDtos
  215. order.RxID = strconv.FormatInt(item.ID, 10)
  216. order.Rxno = strconv.FormatInt(item.ID, 10)
  217. order.LongDrordFlag = "0"
  218. order.HilistType = "1"
  219. order.ChrgType = "1"
  220. order.DrordBhvr = "-"
  221. order.HilistCode = subItem.HisProject.MedicalCode
  222. order.HosplistName = subItem.HisProject.ProjectName
  223. order.HilistLv = "1"
  224. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  225. order.HosplistCode = subItem.HisProject.MedicalCode
  226. order.HosplistName = subItem.HisProject.ProjectName
  227. order.Cnt = subItem.Count
  228. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  229. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  230. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  231. order.OwnpayAmt = ""
  232. order.SelfpayAmt = ""
  233. order.Spec = ""
  234. order.SpecUnt = ""
  235. order.DrordBegnDate = s_tm
  236. order.DrordStopDate = ""
  237. order.DrordDrCodg = "1"
  238. order.DrordDeptName = department.Name
  239. order.DrordDrCodg = "1"
  240. order.DrordDrName = doctor_info.UserName
  241. order.DrordDrProfttl = ""
  242. order.CurrDrordFlag = "1"
  243. orders = append(orders, &order)
  244. }
  245. if subItem.Type == 3 {
  246. var order models.FsiOrderDtos
  247. order.RxID = strconv.FormatInt(item.ID, 10)
  248. order.Rxno = strconv.FormatInt(item.ID, 10)
  249. order.LongDrordFlag = "0"
  250. order.HilistType = "1"
  251. order.ChrgType = "1"
  252. order.DrordBhvr = "-"
  253. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  254. order.HosplistName = subItem.GoodInfo.GoodName
  255. order.HilistLv = "1"
  256. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  257. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  258. order.HosplistName = subItem.GoodInfo.GoodName
  259. order.Cnt = subItem.Count
  260. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  261. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  262. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  263. order.OwnpayAmt = ""
  264. order.SelfpayAmt = ""
  265. order.Spec = ""
  266. order.SpecUnt = ""
  267. order.DrordBegnDate = s_tm
  268. order.DrordStopDate = ""
  269. order.DrordDrCodg = "1"
  270. order.DrordDeptName = department.Name
  271. order.DrordDrCodg = "1"
  272. order.DrordDrName = doctor_info.UserName
  273. order.DrordDrProfttl = ""
  274. order.CurrDrordFlag = "1"
  275. orders = append(orders, &order)
  276. }
  277. }
  278. }
  279. //处方医嘱信息
  280. }
  281. fed.MatnStas = "0"
  282. fed.MedfeeSumamt = "0"
  283. fed.OwnpayAmt = "0"
  284. fed.SelfpayAmt = "0"
  285. fed.AcctPayamt = "0"
  286. fed.MaAmt = "0"
  287. fed.HifpPayamt = "0"
  288. fed.SetlTotlnum = "1"
  289. fed.Insutype = his.Insutype
  290. fed.ReimFlag = "0"
  291. fed.OutSetlFlag = "0"
  292. var fopd []*models.FsiOperationDtosData
  293. data := make(map[string]interface{})
  294. data["fed"] = fed
  295. data["fdd"] = fdds
  296. data["fod"] = orders
  297. data["pd"] = pd
  298. data["pp"] = pp
  299. data["fopd"] = fopd
  300. data["trig_scen"] = trig_scen
  301. fmt.Println(data)
  302. fmt.Println(fed)
  303. fmt.Println(fdds)
  304. fmt.Println(orders)
  305. fmt.Println(pd)
  306. fmt.Println(pp)
  307. fmt.Println(fopd)
  308. client := &http.Client{}
  309. bytesData, _ := json.Marshal(data)
  310. var req *http.Request
  311. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  312. resp, _ := client.Do(req)
  313. defer resp.Body.Close()
  314. body, ioErr := ioutil.ReadAll(resp.Body)
  315. if ioErr != nil {
  316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  318. return
  319. }
  320. var respJSON map[string]interface{}
  321. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  324. return
  325. }
  326. //手术操作集合
  327. //手术操作集合
  328. }
  329. func (c *HisApiController) Check3102() {
  330. patient_id, _ := c.GetInt64("patient_id")
  331. order_id, _ := c.GetInt64("order_id")
  332. his_patient_id, _ := c.GetInt64("his_patient_id")
  333. admin_user_id, _ := c.GetInt64("admin_user_id")
  334. trig_scen := c.GetString("trig_scen")
  335. adminUser := c.GetAdminUserInfo()
  336. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  337. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  338. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  339. record_time := c.GetString("record_time")
  340. order, _ := service.GetHisOrderByID(order_id)
  341. timeLayout := "2006-01-02"
  342. loc, _ := time.LoadLocation("Local")
  343. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  344. if err != nil {
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  346. return
  347. }
  348. recordDateTime := theTime.Unix()
  349. var patientPrescription models.HisPrescriptionInfo
  350. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  351. if patientPrescription.ID == 0 {
  352. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  353. }
  354. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  355. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  356. //
  357. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  358. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  359. var pp models.PublicParams
  360. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  361. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  362. pp.FixmedinsName = miConfig.OrgName
  363. pp.FixmedinsCode = miConfig.Code
  364. pp.RequestUrl = miConfig.Url
  365. pp.Cainfo = miConfig.Cainfo
  366. pp.SecretKey = miConfig.SecretKey
  367. pp.AccessKey = miConfig.AccessKey
  368. pp.OpterName = roles.UserName
  369. var config []*models.HisXtDiagnoseConfig
  370. for _, item := range diagnosis_ids {
  371. id, _ := strconv.ParseInt(item, 10, 64)
  372. diagnosisConfig, _ := service.FindDiagnoseById(id)
  373. config = append(config, &diagnosisConfig)
  374. }
  375. var pd models.PatientDtos
  376. pd.PatnID = his.PsnNo
  377. pd.PatnName = his.Name
  378. pd.Gend = his.Gend
  379. pd.Brdy = his.Brdy
  380. pd.Poolarea = his.InsuplcAdmdvs
  381. pd.CurrMdtrtID = his.Number
  382. var fed models.FsiEncounterDtos
  383. fed.MdtrtID = his.Number
  384. fed.MedinsID = miConfig.Code
  385. fed.MedinsName = miConfig.OrgName
  386. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  387. fed.MedMdtrtType = "1"
  388. fed.MedinsType = "1"
  389. fed.MedinsLv = "11"
  390. tm := time.Unix(his.RecordDate, 0)
  391. s_tm := tm.Format("2006-01-02 15:04:05")
  392. fed.AdmDate = s_tm
  393. fed.DscgDate = s_tm
  394. fed.DscgMainDiseCodg = config[0].CountryCode
  395. fed.DscgMainDiseName = config[0].CountryContentName
  396. //诊断信息
  397. var fdds []*models.FsiDiagnoseDtos
  398. for index, item := range config {
  399. if index == 0 {
  400. var fdd models.FsiDiagnoseDtos
  401. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  402. fdd.InoutDiseType = "1"
  403. fdd.MaindiseFlag = "1"
  404. fdd.DiseDate = s_tm
  405. fdd.DiasSrtNo = "1"
  406. fdd.DiseName = item.CountryContentName
  407. fdd.DiseCodg = item.CountryCode
  408. fdds = append(fdds, &fdd)
  409. } else {
  410. var fdd models.FsiDiagnoseDtos
  411. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  412. fdd.InoutDiseType = "1"
  413. fdd.MaindiseFlag = "1"
  414. fdd.DiseDate = s_tm
  415. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  416. fdd.DiseName = item.CountryContentName
  417. fdd.DiseCodg = item.CountryCode
  418. fdds = append(fdds, &fdd)
  419. }
  420. }
  421. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  422. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  423. fed.AdmDeptName = department.Name
  424. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  425. fed.DscgDeptName = department.Name
  426. fed.MedType = order.MedType
  427. //处方医嘱信息
  428. var orders []*models.FsiOrderDtos
  429. //for _, item := range prescriptions {
  430. // for _, subItem := range item.HisDoctorAdviceInfo {
  431. // var order models.FsiOrderDtos
  432. // order.RxID = strconv.FormatInt(item.ID, 10)
  433. // order.Rxno = strconv.FormatInt(item.ID, 10)
  434. // order.LongDrordFlag = "0"
  435. // order.HilistType = "1"
  436. // order.ChrgType = "1"
  437. // order.DrordBhvr = "-"
  438. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  439. // order.HosplistName = subItem.BaseDrugLib.DrugName
  440. // order.HilistLv = "1"
  441. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  442. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  443. // order.HosplistName = subItem.BaseDrugLib.DrugName
  444. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  445. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  446. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  447. // order.OwnpayAmt = ""
  448. // order.SelfpayAmt = ""
  449. // order.Spec = ""
  450. // order.SpecUnt = ""
  451. // order.DrordBegnDate = s_tm
  452. // order.DrordStopDate = ""
  453. // order.DrordDrCodg = "1"
  454. // order.DrordDeptName = department.Name
  455. // order.DrordDrCodg = "1"
  456. // order.DrordDrName = doctor_info.UserName
  457. // order.DrordDrProfttl = ""
  458. // order.CurrDrordFlag = "1"
  459. // orders = append(orders, &order)
  460. // }
  461. // for _, subItem := range item.HisPrescriptionProject {
  462. // if subItem.Type == 2 {
  463. // var order models.FsiOrderDtos
  464. // order.RxID = strconv.FormatInt(item.ID, 10)
  465. // order.Rxno = strconv.FormatInt(item.ID, 10)
  466. // order.LongDrordFlag = "0"
  467. // order.HilistType = "1"
  468. // order.ChrgType = "1"
  469. // order.DrordBhvr = "-"
  470. // order.HilistCode = subItem.HisProject.MedicalCode
  471. // order.HosplistName = subItem.HisProject.ProjectName
  472. // order.HilistLv = "1"
  473. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  474. // order.HosplistCode = subItem.HisProject.MedicalCode
  475. // order.HosplistName = subItem.HisProject.ProjectName
  476. // order.Cnt = subItem.Count
  477. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  478. //
  479. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  480. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  481. // order.OwnpayAmt = ""
  482. // order.SelfpayAmt = ""
  483. // order.Spec = ""
  484. // order.SpecUnt = ""
  485. // order.DrordBegnDate = s_tm
  486. // order.DrordStopDate = ""
  487. // order.DrordDrCodg = "1"
  488. // order.DrordDeptName = department.Name
  489. // order.DrordDrCodg = "1"
  490. // order.DrordDrName = doctor_info.UserName
  491. // order.DrordDrProfttl = ""
  492. // order.CurrDrordFlag = "1"
  493. // orders = append(orders, &order)
  494. //
  495. // }
  496. // if subItem.Type == 3 {
  497. //
  498. // var order models.FsiOrderDtos
  499. // order.RxID = strconv.FormatInt(item.ID, 10)
  500. // order.Rxno = strconv.FormatInt(item.ID, 10)
  501. // order.LongDrordFlag = "0"
  502. // order.HilistType = "1"
  503. // order.ChrgType = "1"
  504. // order.DrordBhvr = "-"
  505. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  506. // order.HosplistName = subItem.GoodInfo.GoodName
  507. // order.HilistLv = "1"
  508. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  509. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  510. // order.HosplistName = subItem.GoodInfo.GoodName
  511. // order.Cnt = subItem.Count
  512. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  513. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  514. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  515. // order.OwnpayAmt = ""
  516. // order.SelfpayAmt = ""
  517. // order.Spec = ""
  518. // order.SpecUnt = ""
  519. // order.DrordBegnDate = s_tm
  520. // order.DrordStopDate = ""
  521. // order.DrordDrCodg = "1"
  522. // order.DrordDeptName = department.Name
  523. // order.DrordDrCodg = "1"
  524. // order.DrordDrName = doctor_info.UserName
  525. // order.DrordDrProfttl = ""
  526. // order.CurrDrordFlag = "1"
  527. // orders = append(orders, &order)
  528. //
  529. // }
  530. // }
  531. //}
  532. for _, item := range prescriptions {
  533. for _, subItem := range item.HisDoctorAdviceInfo {
  534. var order models.FsiOrderDtos
  535. order.RxID = strconv.FormatInt(item.ID, 10)
  536. order.Rxno = strconv.FormatInt(item.ID, 10)
  537. order.LongDrordFlag = "0"
  538. order.HilistType = "1"
  539. order.ChrgType = "1"
  540. order.DrordBhvr = "-"
  541. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  542. order.HosplistName = subItem.BaseDrugLib.DrugName
  543. order.HilistLv = "1"
  544. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  545. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  546. order.HosplistName = subItem.BaseDrugLib.DrugName
  547. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  548. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  549. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  550. order.OwnpayAmt = ""
  551. order.SelfpayAmt = ""
  552. order.Spec = ""
  553. order.SpecUnt = ""
  554. order.DrordBegnDate = s_tm
  555. order.DrordStopDate = ""
  556. order.DrordDrCodg = "1"
  557. order.DrordDeptName = department.Name
  558. order.DrordDrCodg = "1"
  559. order.DrordDrName = doctor_info.UserName
  560. order.DrordDrProfttl = ""
  561. order.CurrDrordFlag = "1"
  562. orders = append(orders, &order)
  563. }
  564. for _, subItem := range item.HisPrescriptionProject {
  565. if subItem.Type == 2 {
  566. var order models.FsiOrderDtos
  567. order.RxID = strconv.FormatInt(item.ID, 10)
  568. order.Rxno = strconv.FormatInt(item.ID, 10)
  569. order.LongDrordFlag = "0"
  570. order.HilistType = "1"
  571. order.ChrgType = "1"
  572. order.DrordBhvr = "-"
  573. order.HilistCode = subItem.HisProject.MedicalCode
  574. order.HosplistName = subItem.HisProject.ProjectName
  575. order.HilistLv = "1"
  576. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  577. order.HosplistCode = subItem.HisProject.MedicalCode
  578. order.HosplistName = subItem.HisProject.ProjectName
  579. order.Cnt = subItem.Count
  580. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  581. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  582. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  583. order.OwnpayAmt = ""
  584. order.SelfpayAmt = ""
  585. order.Spec = ""
  586. order.SpecUnt = ""
  587. order.DrordBegnDate = s_tm
  588. order.DrordStopDate = ""
  589. order.DrordDrCodg = "1"
  590. order.DrordDeptName = department.Name
  591. order.DrordDrCodg = "1"
  592. order.DrordDrName = doctor_info.UserName
  593. order.DrordDrProfttl = ""
  594. order.CurrDrordFlag = "1"
  595. orders = append(orders, &order)
  596. }
  597. if subItem.Type == 3 {
  598. var order models.FsiOrderDtos
  599. order.RxID = strconv.FormatInt(item.ID, 10)
  600. order.Rxno = strconv.FormatInt(item.ID, 10)
  601. order.LongDrordFlag = "0"
  602. order.HilistType = "1"
  603. order.ChrgType = "1"
  604. order.DrordBhvr = "-"
  605. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  606. order.HosplistName = subItem.GoodInfo.GoodName
  607. order.HilistLv = "1"
  608. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  609. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  610. order.HosplistName = subItem.GoodInfo.GoodName
  611. order.Cnt = subItem.Count
  612. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  613. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  614. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  615. order.OwnpayAmt = ""
  616. order.SelfpayAmt = ""
  617. order.Spec = ""
  618. order.SpecUnt = ""
  619. order.DrordBegnDate = s_tm
  620. order.DrordStopDate = ""
  621. order.DrordDrCodg = "1"
  622. order.DrordDeptName = department.Name
  623. order.DrordDrCodg = "1"
  624. order.DrordDrName = doctor_info.UserName
  625. order.DrordDrProfttl = ""
  626. order.CurrDrordFlag = "1"
  627. orders = append(orders, &order)
  628. }
  629. }
  630. }
  631. //处方医嘱信息
  632. fed.MatnStas = "0"
  633. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  634. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  635. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  636. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  637. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  638. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  639. fed.SetlTotlnum = "1"
  640. fed.Insutype = his.Insutype
  641. fed.ReimFlag = "0"
  642. fed.OutSetlFlag = "0"
  643. var fopd []*models.FsiOperationDtosData
  644. data := make(map[string]interface{})
  645. data["fed"] = fed
  646. data["fdd"] = fdds
  647. data["fod"] = orders
  648. data["pd"] = pd
  649. data["pp"] = pp
  650. data["fopd"] = fopd
  651. data["trig_scen"] = trig_scen
  652. client := &http.Client{}
  653. bytesData, _ := json.Marshal(data)
  654. var req *http.Request
  655. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  656. resp, _ := client.Do(req)
  657. defer resp.Body.Close()
  658. body, ioErr := ioutil.ReadAll(resp.Body)
  659. if ioErr != nil {
  660. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  662. return
  663. }
  664. var respJSON map[string]interface{}
  665. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  668. return
  669. }
  670. //手术操作集合
  671. //手术操作集合
  672. }
  673. func (c *HisApiController) Check() {
  674. psn_no := c.GetString("psn_no")
  675. in := c.GetString("in")
  676. mt := c.GetString("mt")
  677. baseParams := models.BaseParams{
  678. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  679. FixmedinsCode: "H15049901371",
  680. InsuplcAdmdvs: "150499",
  681. MdtrtareaAdmvs: "150499",
  682. OrgName: "赤峰费森血液透析中心",
  683. Doctor: "1111",
  684. }
  685. service.Gdyb2001(baseParams, psn_no, in, mt)
  686. }
  687. func (c *HisApiController) GetPsnNcdsInfo() {
  688. admin_user_id, _ := c.GetInt64("admin_user_id")
  689. patient_id, _ := c.GetInt64("patient_id")
  690. id, _ := c.GetInt64("id")
  691. adminUser := c.GetAdminUserInfo()
  692. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  693. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  694. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  695. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  696. psn_record, _ := service.GetPsnNCDSRecordById(id)
  697. //
  698. //if psn_record.ID == 0 {
  699. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  700. // return
  701. //}
  702. var res Result5301
  703. var res10265 Result5301For10265
  704. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  705. psn_info, _ := service.GetPsnByPatientId(patient_id)
  706. var api string
  707. if miConfig.MdtrtareaAdmvs == "320921" {
  708. 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 +
  709. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  710. } else {
  711. 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 +
  712. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  713. }
  714. resp, requestErr := http.Get(api)
  715. if requestErr != nil {
  716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  717. return
  718. }
  719. body, ioErr := ioutil.ReadAll(resp.Body)
  720. if ioErr != nil {
  721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  723. return
  724. }
  725. var respJSON map[string]interface{}
  726. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  729. return
  730. }
  731. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  732. result, _ := json.Marshal(respJSON)
  733. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  734. utils.ErrorLog("解析失败:%v", err)
  735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  736. return
  737. }
  738. res.ErrMsg = res10265.ErrMsg
  739. res.Output = res10265.Output
  740. res.InfRefmsgid = res10265.InfRefmsgid
  741. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  742. res.Infcode = infocode
  743. } else {
  744. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  745. var dat map[string]interface{}
  746. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  747. fmt.Println(dat)
  748. } else {
  749. fmt.Println(err)
  750. }
  751. userJSONBytes, _ := json.Marshal(dat)
  752. if miConfig.Code == "H15049901371" {
  753. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  754. utils.ErrorLog("解析失败:%v", err)
  755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  756. return
  757. }
  758. res.InfRefmsgid = res10265.InfRefmsgid
  759. res.Output = res10265.Output
  760. res.ErrMsg = res10265.ErrMsg
  761. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  762. res.Infcode = infocode
  763. } else {
  764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  765. utils.ErrorLog("解析失败:%v", err)
  766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  767. return
  768. }
  769. }
  770. }
  771. if res.Infcode == 0 {
  772. c.ServeSuccessJSON(map[string]interface{}{
  773. "result": res.Output.Result,
  774. })
  775. }
  776. }
  777. func (c *HisApiController) CheckInsutype() {
  778. his_patient_id, _ := c.GetInt64("his_patient_id")
  779. admin_user_id, _ := c.GetInt64("admin_user_id")
  780. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  781. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  782. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  783. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  784. var dat map[string]interface{}
  785. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  786. fmt.Println(dat)
  787. } else {
  788. fmt.Println(err)
  789. }
  790. userJSONBytes, _ := json.Marshal(dat)
  791. var res Result90100
  792. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  793. utils.ErrorLog("解析失败:%v", err)
  794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  795. return
  796. }
  797. if res.Infcode != 0 {
  798. c.ServeSuccessJSON(map[string]interface{}{
  799. "failed_code": -10,
  800. "msg": res.ErrMsg,
  801. })
  802. return
  803. } else {
  804. fmt.Println(res)
  805. }
  806. }
  807. func (c *HisApiController) CheckCardPWD() {
  808. card_pwd := c.GetString("card_pwd")
  809. his_patient_id, _ := c.GetInt64("his_patient_id")
  810. admin_user_id, _ := c.GetInt64("admin_user_id")
  811. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  812. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  813. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  814. psn, _ := service.GetPsnByPatientId(his.PatientId)
  815. bas := strings.Split(psn.CardInfo, "|")
  816. basNumber := bas[2]
  817. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  818. var dat map[string]interface{}
  819. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  820. fmt.Println(dat)
  821. } else {
  822. fmt.Println(err)
  823. }
  824. userJSONBytes, _ := json.Marshal(dat)
  825. var res Result90991
  826. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  827. utils.ErrorLog("解析失败:%v", err)
  828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  829. return
  830. }
  831. if res.Infcode != 0 {
  832. c.ServeSuccessJSON(map[string]interface{}{
  833. "failed_code": -10,
  834. "msg": res.ErrMsg,
  835. })
  836. return
  837. } else {
  838. if res.Output.Result.SscnoCheckStat == "0" {
  839. var msg string
  840. switch res.Output.Result.CardStat {
  841. case "00":
  842. msg = "未激活"
  843. break
  844. case "10":
  845. msg = "激活"
  846. break
  847. case "20":
  848. msg = "窗口挂失"
  849. break
  850. case "21":
  851. msg = "电话挂失"
  852. break
  853. case "22":
  854. msg = "单位网上申报挂失"
  855. break
  856. case "23":
  857. msg = "保健办挂失"
  858. break
  859. case "24":
  860. msg = "个人网上挂失"
  861. break
  862. case "25":
  863. msg = "网上服务大厅挂失"
  864. break
  865. case "30":
  866. msg = "注销"
  867. break
  868. case "40":
  869. msg = "回收"
  870. break
  871. case "99":
  872. msg = "制卡中(无效卡)"
  873. break
  874. }
  875. c.ServeSuccessJSON(map[string]interface{}{
  876. "failed_code": -10,
  877. "msg": msg,
  878. })
  879. return
  880. } else {
  881. c.ServeSuccessJSON(map[string]interface{}{
  882. "msg": "校验成功",
  883. })
  884. return
  885. }
  886. }
  887. }
  888. func (c *HisApiController) ReadCard() {
  889. id_card_type, _ := c.GetInt64("id_card_type")
  890. admin_user_id, _ := c.GetInt64("admin_user_id")
  891. certificates, _ := c.GetInt64("certificates")
  892. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  893. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  894. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  895. switch id_card_type {
  896. case 1:
  897. if miConfig.MdtrtareaAdmvs == "421300" {
  898. var res ResultTwo
  899. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  900. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  901. "&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)
  902. resp, requestErr := http.Get(api)
  903. if requestErr != nil {
  904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  905. return
  906. }
  907. body, ioErr := ioutil.ReadAll(resp.Body)
  908. if ioErr != nil {
  909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  911. return
  912. }
  913. var respJSON map[string]interface{}
  914. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  917. return
  918. }
  919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  920. result, _ := json.Marshal(respJSON)
  921. fmt.Println("log")
  922. fmt.Println(string(result))
  923. if err := json.Unmarshal([]byte(result), &res); err != nil {
  924. utils.ErrorLog("解析失败:%v", err)
  925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  926. return
  927. }
  928. if res.Infcode == 0 {
  929. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  930. if err == gorm.ErrRecordNotFound {
  931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  932. return
  933. } else if err != nil {
  934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  935. return
  936. } else {
  937. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  938. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  939. infoStr := string(Iinfos)
  940. idetinfoStr := string(Idetinfos)
  941. psn := &models.HisPsn{
  942. PsnNo: res.Output.Baseinfo.PsnNo,
  943. Age: res.Output.Baseinfo.Age,
  944. PatientId: patient.ID,
  945. Certno: res.Output.Baseinfo.Certno,
  946. Brdy: res.Output.Baseinfo.Brdy,
  947. Gend: res.Output.Baseinfo.Gend,
  948. Naty: res.Output.Baseinfo.Naty,
  949. PsnCertType: res.Output.Baseinfo.PsnCertType,
  950. PsnName: res.Output.Baseinfo.PsnName,
  951. Idetinfo: idetinfoStr,
  952. Insuinfo: infoStr,
  953. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  954. }
  955. service.CreateHisPsn(psn)
  956. c.ServeSuccessJSON(map[string]interface{}{
  957. "patient": patient,
  958. "number": res.Output.Baseinfo.Certno,
  959. })
  960. }
  961. } else {
  962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  963. return
  964. }
  965. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  966. var api string
  967. if miConfig.MdtrtareaAdmvs == "320921" {
  968. 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 +
  969. "&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
  970. fmt.Println(api)
  971. } else {
  972. 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 +
  973. "&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)
  974. }
  975. resp, requestErr := http.Get(api)
  976. if requestErr != nil {
  977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  978. return
  979. }
  980. body, ioErr := ioutil.ReadAll(resp.Body)
  981. if ioErr != nil {
  982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  984. return
  985. }
  986. var respJSON map[string]interface{}
  987. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  990. return
  991. }
  992. var status string
  993. status = respJSON["data"].(map[string]interface{})["status"].(string)
  994. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  995. //console.log()
  996. fmt.Println("type===")
  997. fmt.Println(card_type)
  998. var token string
  999. var res ResultTwo //1101结果
  1000. var res10265 ResultTwo10265 //1101结果
  1001. var card_info string //卡信息
  1002. var busi_card_info string
  1003. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1004. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1005. if status == "0" { //读卡成功
  1006. if card_type == "1" {
  1007. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1008. result, _ := json.Marshal(respJSON)
  1009. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1010. utils.ErrorLog("解析失败:%v", err)
  1011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1012. return
  1013. }
  1014. res.ErrMsg = res10265.ErrMsg
  1015. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1016. res.Infcode = infocode
  1017. res.Output = res10265.Output
  1018. res.InfRefmsgid = res10265.InfRefmsgid
  1019. } else {
  1020. //var card_info string //卡信息
  1021. //var busi_card_info string
  1022. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1023. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1024. //fmt.Println(card_info)
  1025. //fmt.Println(busi_card_info)
  1026. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1027. result, _ := json.Marshal(respJSON)
  1028. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1029. utils.ErrorLog("解析失败:%v", err)
  1030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1031. return
  1032. }
  1033. res.ErrMsg = res10265.ErrMsg
  1034. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1035. res.Infcode = infocode
  1036. res.Output = res10265.Output
  1037. res.InfRefmsgid = res10265.InfRefmsgid
  1038. }
  1039. if res.Infcode == 0 {
  1040. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1041. if err == gorm.ErrRecordNotFound {
  1042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1043. return
  1044. } else if err != nil {
  1045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1046. return
  1047. } else {
  1048. if card_type == "1" {
  1049. bas := strings.Split(card_info, "|")
  1050. basNumber := bas[2]
  1051. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1052. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1053. infoStr := string(Iinfos)
  1054. idetinfoStr := string(Idetinfos)
  1055. psn := &models.HisPsn{
  1056. PsnNo: res.Output.Baseinfo.PsnNo,
  1057. Age: res.Output.Baseinfo.Age,
  1058. PatientId: patient.ID,
  1059. Certno: res.Output.Baseinfo.Certno,
  1060. Brdy: res.Output.Baseinfo.Brdy,
  1061. Gend: res.Output.Baseinfo.Gend,
  1062. Naty: res.Output.Baseinfo.Naty,
  1063. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1064. PsnName: res.Output.Baseinfo.PsnName,
  1065. Idetinfo: idetinfoStr,
  1066. Insuinfo: infoStr,
  1067. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1068. CardInfo: card_info,
  1069. VerifyNumber: busi_card_info,
  1070. }
  1071. service.CreateHisPsn(psn)
  1072. c.ServeSuccessJSON(map[string]interface{}{
  1073. "patient": patient,
  1074. "number": basNumber,
  1075. })
  1076. } else {
  1077. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1078. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1079. infoStr := string(Iinfos)
  1080. idetinfoStr := string(Idetinfos)
  1081. psn := &models.HisPsn{
  1082. PsnNo: res.Output.Baseinfo.PsnNo,
  1083. Age: res.Output.Baseinfo.Age,
  1084. PatientId: patient.ID,
  1085. Certno: res.Output.Baseinfo.Certno,
  1086. Brdy: res.Output.Baseinfo.Brdy,
  1087. Gend: res.Output.Baseinfo.Gend,
  1088. Naty: res.Output.Baseinfo.Naty,
  1089. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1090. PsnName: res.Output.Baseinfo.PsnName,
  1091. Idetinfo: idetinfoStr,
  1092. Insuinfo: infoStr,
  1093. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1094. CardInfo: card_info,
  1095. VerifyNumber: token,
  1096. }
  1097. service.CreateHisPsn(psn)
  1098. c.ServeSuccessJSON(map[string]interface{}{
  1099. "patient": patient,
  1100. "number": token,
  1101. })
  1102. }
  1103. }
  1104. } else {
  1105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1106. return
  1107. }
  1108. } else { //读卡失败
  1109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1110. return
  1111. }
  1112. } else {
  1113. if initFlag == 0 {
  1114. c.TestGetBasBaseInit()
  1115. }
  1116. basStr := c.GetBasBaseInfo()
  1117. if len(basStr) == 0 {
  1118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1119. return
  1120. }
  1121. fmt.Println(basStr)
  1122. bas := strings.Split(basStr, "|")
  1123. basNumber := bas[1]
  1124. fmt.Println(basNumber)
  1125. card_sn := bas[3]
  1126. fmt.Println(card_sn)
  1127. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1128. var dat map[string]interface{}
  1129. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1130. fmt.Println(dat)
  1131. } else {
  1132. fmt.Println(err)
  1133. }
  1134. userJSONBytes, _ := json.Marshal(dat)
  1135. var res ResultTwo
  1136. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1137. utils.ErrorLog("解析失败:%v", err)
  1138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1139. return
  1140. }
  1141. if res.Infcode == 0 {
  1142. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1143. if err == gorm.ErrRecordNotFound {
  1144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1145. return
  1146. } else if err != nil {
  1147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1148. return
  1149. } else {
  1150. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1151. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1152. infoStr := string(Iinfos)
  1153. idetinfoStr := string(Idetinfos)
  1154. psn := &models.HisPsn{
  1155. PsnNo: res.Output.Baseinfo.PsnNo,
  1156. Age: res.Output.Baseinfo.Age,
  1157. PatientId: patient.ID,
  1158. Certno: res.Output.Baseinfo.Certno,
  1159. Brdy: res.Output.Baseinfo.Brdy,
  1160. Gend: res.Output.Baseinfo.Gend,
  1161. Naty: res.Output.Baseinfo.Naty,
  1162. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1163. PsnName: res.Output.Baseinfo.PsnName,
  1164. Idetinfo: idetinfoStr,
  1165. Insuinfo: infoStr,
  1166. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1167. CardInfo: basStr,
  1168. VerifyNumber: "",
  1169. }
  1170. service.CreateHisPsn(psn)
  1171. c.ServeSuccessJSON(map[string]interface{}{
  1172. "patient": patient,
  1173. "number": basNumber,
  1174. })
  1175. }
  1176. } else {
  1177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1178. return
  1179. }
  1180. break
  1181. }
  1182. case 2:
  1183. SFZStr := c.GetSFZBaseInfo()
  1184. id_card_str := strings.Split(SFZStr, "^")
  1185. id_card_number := id_card_str[0]
  1186. card_sn := ""
  1187. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1188. var dat map[string]interface{}
  1189. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1190. fmt.Println(dat)
  1191. } else {
  1192. fmt.Println(err)
  1193. }
  1194. userJSONBytes, _ := json.Marshal(dat)
  1195. var res ResultTwo
  1196. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1197. utils.ErrorLog("解析失败:%v", err)
  1198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1199. return
  1200. }
  1201. if res.Infcode == 0 {
  1202. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1203. if err == gorm.ErrRecordNotFound {
  1204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1205. return
  1206. } else if err != nil {
  1207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1208. return
  1209. } else {
  1210. c.ServeSuccessJSON(map[string]interface{}{
  1211. "patient": patient,
  1212. "number": id_card_number,
  1213. })
  1214. }
  1215. } else {
  1216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1217. return
  1218. }
  1219. break
  1220. case 3:
  1221. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1222. var api string
  1223. if miConfig.MdtrtareaAdmvs == "320921" {
  1224. 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 +
  1225. "&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
  1226. fmt.Println(api)
  1227. } else {
  1228. 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 +
  1229. "&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)
  1230. }
  1231. resp, requestErr := http.Get(api)
  1232. if requestErr != nil {
  1233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1234. return
  1235. }
  1236. body, ioErr := ioutil.ReadAll(resp.Body)
  1237. if ioErr != nil {
  1238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1240. return
  1241. }
  1242. var respJSON map[string]interface{}
  1243. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1246. return
  1247. }
  1248. var status string
  1249. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1250. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1251. var token string
  1252. var res ResultTwo //1101结果
  1253. var res10265 ResultTwo10265 //1101结果
  1254. var card_info string //卡信息
  1255. var busi_card_info string
  1256. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1257. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1258. if status == "0" { //读卡成功
  1259. if card_type == "1" {
  1260. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1261. result, _ := json.Marshal(respJSON)
  1262. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1263. utils.ErrorLog("解析失败:%v", err)
  1264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1265. return
  1266. }
  1267. res.ErrMsg = res10265.ErrMsg
  1268. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1269. res.Infcode = infocode
  1270. res.Output = res10265.Output
  1271. res.InfRefmsgid = res10265.InfRefmsgid
  1272. } else {
  1273. //var card_info string //卡信息
  1274. //var busi_card_info string
  1275. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1276. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1277. //fmt.Println(card_info)
  1278. //fmt.Println(busi_card_info)
  1279. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1280. result, _ := json.Marshal(respJSON)
  1281. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1282. utils.ErrorLog("解析失败:%v", err)
  1283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1284. return
  1285. }
  1286. res.ErrMsg = res10265.ErrMsg
  1287. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1288. res.Infcode = infocode
  1289. res.Output = res10265.Output
  1290. res.InfRefmsgid = res10265.InfRefmsgid
  1291. }
  1292. if res.Infcode == 0 {
  1293. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1294. if err == gorm.ErrRecordNotFound {
  1295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1296. return
  1297. } else if err != nil {
  1298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1299. return
  1300. } else {
  1301. if card_type == "1" {
  1302. bas := strings.Split(card_info, "|")
  1303. basNumber := bas[2]
  1304. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1305. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1306. infoStr := string(Iinfos)
  1307. idetinfoStr := string(Idetinfos)
  1308. psn := &models.HisPsn{
  1309. PsnNo: res.Output.Baseinfo.PsnNo,
  1310. Age: res.Output.Baseinfo.Age,
  1311. PatientId: patient.ID,
  1312. Certno: res.Output.Baseinfo.Certno,
  1313. Brdy: res.Output.Baseinfo.Brdy,
  1314. Gend: res.Output.Baseinfo.Gend,
  1315. Naty: res.Output.Baseinfo.Naty,
  1316. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1317. PsnName: res.Output.Baseinfo.PsnName,
  1318. Idetinfo: idetinfoStr,
  1319. Insuinfo: infoStr,
  1320. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1321. CardInfo: card_info,
  1322. VerifyNumber: busi_card_info,
  1323. }
  1324. service.CreateHisPsn(psn)
  1325. c.ServeSuccessJSON(map[string]interface{}{
  1326. "patient": patient,
  1327. "number": basNumber,
  1328. })
  1329. } else {
  1330. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1331. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1332. infoStr := string(Iinfos)
  1333. idetinfoStr := string(Idetinfos)
  1334. psn := &models.HisPsn{
  1335. PsnNo: res.Output.Baseinfo.PsnNo,
  1336. Age: res.Output.Baseinfo.Age,
  1337. PatientId: patient.ID,
  1338. Certno: res.Output.Baseinfo.Certno,
  1339. Brdy: res.Output.Baseinfo.Brdy,
  1340. Gend: res.Output.Baseinfo.Gend,
  1341. Naty: res.Output.Baseinfo.Naty,
  1342. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1343. PsnName: res.Output.Baseinfo.PsnName,
  1344. Idetinfo: idetinfoStr,
  1345. Insuinfo: infoStr,
  1346. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1347. CardInfo: card_info,
  1348. VerifyNumber: token,
  1349. }
  1350. service.CreateHisPsn(psn)
  1351. c.ServeSuccessJSON(map[string]interface{}{
  1352. "patient": patient,
  1353. "number": token,
  1354. })
  1355. }
  1356. }
  1357. } else {
  1358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1359. return
  1360. }
  1361. } else { //读卡失败
  1362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1363. return
  1364. }
  1365. }
  1366. break
  1367. case 4:
  1368. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1369. var api string
  1370. if miConfig.MdtrtareaAdmvs == "320921" {
  1371. 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 +
  1372. "&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
  1373. fmt.Println(api)
  1374. } else {
  1375. 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 +
  1376. "&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)
  1377. }
  1378. resp, requestErr := http.Get(api)
  1379. if requestErr != nil {
  1380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1381. return
  1382. }
  1383. body, ioErr := ioutil.ReadAll(resp.Body)
  1384. if ioErr != nil {
  1385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1387. return
  1388. }
  1389. var respJSON map[string]interface{}
  1390. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1393. return
  1394. }
  1395. var status string
  1396. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1397. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1398. var token string
  1399. var res ResultTwo //1101结果
  1400. var res10265 ResultTwo10265 //1101结果
  1401. if status == "0" { //读卡成功
  1402. var card_info string //卡信息
  1403. var busi_card_info string
  1404. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1405. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1406. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1407. fmt.Println(card_info)
  1408. fmt.Println(busi_card_info)
  1409. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1410. result, _ := json.Marshal(respJSON)
  1411. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1412. utils.ErrorLog("解析失败:%v", err)
  1413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1414. return
  1415. }
  1416. res.ErrMsg = res10265.ErrMsg
  1417. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1418. res.Infcode = infocode
  1419. res.Output = res10265.Output
  1420. res.InfRefmsgid = res10265.InfRefmsgid
  1421. if res.Infcode == 0 {
  1422. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1423. if err == gorm.ErrRecordNotFound {
  1424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1425. return
  1426. } else if err != nil {
  1427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1428. return
  1429. } else {
  1430. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1431. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1432. infoStr := string(Iinfos)
  1433. idetinfoStr := string(Idetinfos)
  1434. psn := &models.HisPsn{
  1435. PsnNo: res.Output.Baseinfo.PsnNo,
  1436. Age: res.Output.Baseinfo.Age,
  1437. PatientId: patient.ID,
  1438. Certno: res.Output.Baseinfo.Certno,
  1439. Brdy: res.Output.Baseinfo.Brdy,
  1440. Gend: res.Output.Baseinfo.Gend,
  1441. Naty: res.Output.Baseinfo.Naty,
  1442. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1443. PsnName: res.Output.Baseinfo.PsnName,
  1444. Idetinfo: idetinfoStr,
  1445. Insuinfo: infoStr,
  1446. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1447. CardInfo: card_info,
  1448. VerifyNumber: token,
  1449. }
  1450. service.CreateHisPsn(psn)
  1451. c.ServeSuccessJSON(map[string]interface{}{
  1452. "patient": patient,
  1453. "number": token,
  1454. })
  1455. }
  1456. } else {
  1457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1458. return
  1459. }
  1460. } else { //读卡失败
  1461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1462. return
  1463. }
  1464. }
  1465. break
  1466. }
  1467. }
  1468. var initFlag int64 = 0
  1469. func (c *HisApiController) TestGetBasBaseInit() {
  1470. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1471. Iinit := DllDef.MustFindProc("Init")
  1472. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1473. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1474. if ret != 0 {
  1475. fmt.Println("SSCard的报错原因:", err)
  1476. fmt.Println("SSCard的运算结果为:", ret)
  1477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1478. return
  1479. }
  1480. result := int(ret)
  1481. fmt.Println("SSCard的运算结果为1:", result)
  1482. initFlag = 1
  1483. return
  1484. }
  1485. func (c *HisApiController) GetSFZBaseInfo() string {
  1486. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1487. readCard := DllDef.MustFindProc("ReadSFZ")
  1488. if readCard == nil {
  1489. fmt.Println("readcard is nil")
  1490. readCard = DllDef.MustFindProc("ReadSFZ")
  1491. }
  1492. str := make([]byte, 256)
  1493. str1 := make([]byte, 256)
  1494. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1495. fmt.Println(r)
  1496. return string(str)
  1497. }
  1498. func (c *HisApiController) GetBasBaseInfo() string {
  1499. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1500. readCard := DllDef.MustFindProc("ReadCardBas")
  1501. if readCard == nil {
  1502. fmt.Println("readcard is nil")
  1503. readCard = DllDef.MustFindProc("ReadCardBas")
  1504. }
  1505. str := make([]byte, 1024)
  1506. str1 := make([]byte, 1024)
  1507. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1508. fmt.Println(string(str1))
  1509. fmt.Println(string(str))
  1510. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1511. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1512. if ret2 != 0 {
  1513. return ""
  1514. }
  1515. return string(str)
  1516. }
  1517. type CustomFundPay struct {
  1518. FundPayType string `json:"fund_pay_type"`
  1519. FundPayamt float64 `json:"fund_payamt"`
  1520. }
  1521. func (c *HisApiController) GetSettleList() {
  1522. order_id, _ := c.GetInt64("order_id")
  1523. admin_user_id, _ := c.GetInt64("admin_user_id")
  1524. order, _ := service.GetHisOrderByIDTwo(order_id)
  1525. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1526. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1527. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1528. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1529. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1530. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1531. if order.ID == 0 {
  1532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1533. return
  1534. }
  1535. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1536. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1537. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1538. fmt.Println(count)
  1539. var zero string
  1540. number := count + 1
  1541. if number >= 1000 {
  1542. zero = "0000" + strconv.FormatInt(number, 10)
  1543. } else if number >= 10000 {
  1544. zero = "000" + strconv.FormatInt(number, 10)
  1545. } else if number >= 100000 {
  1546. zero = "00" + strconv.FormatInt(number, 10)
  1547. } else if number >= 1000000 {
  1548. zero = "0" + strconv.FormatInt(number, 10)
  1549. } else {
  1550. zero = strconv.FormatInt(number, 10)
  1551. }
  1552. fmt.Println(zero)
  1553. struct4101 := service.Struct4101{
  1554. PsnNo: order.PsnNo,
  1555. MdtrtId: order.MdtrtId,
  1556. SetlId: order.SetlId,
  1557. PsnName: order.PsnName,
  1558. Gend: order.Gend,
  1559. Brdy: his.Brdy,
  1560. Age: his.Age,
  1561. Naty: order.Naty,
  1562. PatnCertType: "01",
  1563. Certno: order.Certno,
  1564. Prfs: "90",
  1565. ConerName: roles[0].UserName,
  1566. PatnRlts: "99",
  1567. ConerAddr: miConfig.OrgName,
  1568. ConerTel: admin.Mobile,
  1569. HiType: order.Insutype,
  1570. Insuplc: miConfig.InsuplcAdmdvs,
  1571. MaindiagFlag: "1",
  1572. BillCode: last_order.FaPiaoCode,
  1573. BillNo: zero,
  1574. BizSn: order.Number,
  1575. PsnSelfPay: order.PsnPartAmt,
  1576. PsnOwnPay: order.PsnPartAmt,
  1577. AcctPay: order.AcctPay,
  1578. PsnCashpay: order.PsnCashPay,
  1579. HiPaymtd: "1",
  1580. Hsorg: miConfig.InsuplcAdmdvs,
  1581. HsorgOpter: miConfig.InsuplcAdmdvs,
  1582. MedinsFillPsn: curRoles.UserName,
  1583. MedinsFillDept: depart.Name,
  1584. IptMedType: "2",
  1585. }
  1586. struct4101.SetlBegnDate = order.SetlTime
  1587. struct4101.SetlEndDate = order.SetlTime
  1588. time_arr := strings.Split(order.SetlTime, " ")
  1589. struct4101.AdmTime = time_arr[0]
  1590. struct4101.AdmEndTime = time_arr[0]
  1591. var rf []CustomFundPay
  1592. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1593. var tempFunPays []service.CustomStruct
  1594. for _, item := range rf {
  1595. var tempFunPay service.CustomStruct
  1596. tempFunPay.FundPayamt = item.FundPayamt
  1597. tempFunPay.FundPayType = item.FundPayType
  1598. tempFunPays = append(tempFunPays, tempFunPay)
  1599. }
  1600. struct4101.CustomStruct = tempFunPays
  1601. var tempDiaginfos []service.DiaginfoStructTwo
  1602. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1603. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1604. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1605. var config []*models.HisXtDiagnoseConfig
  1606. for _, item := range diagnosis_ids {
  1607. id, _ := strconv.ParseInt(item, 10, 64)
  1608. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1609. config = append(config, &diagnosisConfig)
  1610. }
  1611. for index, item := range config {
  1612. if index == 0 {
  1613. var tempDiaginfo service.DiaginfoStructTwo
  1614. tempDiaginfo.DiagCode = item.CountryCode
  1615. tempDiaginfo.DiagName = item.CountryContentName
  1616. tempDiaginfo.DiagType = "1"
  1617. tempDiaginfo.MaindiagFlag = "1"
  1618. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1619. } else {
  1620. var tempDiaginfo service.DiaginfoStructTwo
  1621. tempDiaginfo.DiagCode = item.CountryCode
  1622. tempDiaginfo.DiagName = item.CountryContentName
  1623. tempDiaginfo.DiagType = "2"
  1624. tempDiaginfo.MaindiagFlag = "0"
  1625. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1626. }
  1627. }
  1628. struct4101.Diseinfo = tempDiaginfos
  1629. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1630. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1631. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1632. tempOpspdiseinfo2.OprnOprtCode = ""
  1633. tempOpspdiseinfo2.OprnOprtName = ""
  1634. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1635. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1636. var iteminfo service.IteminfoStruct
  1637. var bedCostTotal float64 = 0 //床位总费
  1638. var bedCostSelfTotal float64 = 0 //床位自费
  1639. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1640. var operationCostTotal float64 = 0 //手术费
  1641. var operationCostSelfTotal float64 = 0 //手术费
  1642. var operationCostPartSelfTotal float64 = 0 //手术费
  1643. var otherCostTotal float64 = 0 //其他费用
  1644. var otherCostSelfTotal float64 = 0 //其他费用
  1645. var otherCostPartSelfTotal float64 = 0 //其他费用
  1646. var materialCostTotal float64 = 0 //材料费
  1647. var materialCostSelfTotal float64 = 0 //材料费
  1648. var materialCostPartSelfTotal float64 = 0 //材料费
  1649. var westernMedicineCostTotal float64 = 0 //西药费
  1650. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1651. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1652. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1653. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1654. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1655. var checkCostTotal float64 = 0 //检查费
  1656. var checkCostSelfTotal float64 = 0 //检查费
  1657. var checkCostPartSelfTotal float64 = 0 //检查费
  1658. var laboratoryCostTotal float64 = 0 //化验费
  1659. var laboratoryCostSelfTotal float64 = 0 //化验费
  1660. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1661. var treatCostTotal float64 = 0 //治疗费用
  1662. var treatCostSelfTotal float64 = 0 //治疗费用
  1663. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1664. decimal.DivisionPrecision = 2
  1665. var bed_fulamt_ownpay_amt float64 = 0
  1666. var operation_fulamt_ownpay_amt float64 = 0
  1667. var other_fulamt_ownpay_amt float64 = 0
  1668. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1669. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1670. var check_fulamt_ownpay_amt float64 = 0
  1671. var material_fulamt_ownpay_amt float64 = 0
  1672. var laboratory_fulamt_ownpay_amt float64 = 0
  1673. var treat_fulamt_ownpay_amt float64 = 0
  1674. var bed_claa_sunmfee float64 = 0
  1675. var bed_clab_amt float64 = 0
  1676. var bed_other_amt float64 = 0
  1677. var operation_claa_sunmfee float64 = 0
  1678. var operation_clab_amt float64 = 0
  1679. var operation_other_amt float64 = 0
  1680. var other_claa_sunmfee float64 = 0
  1681. var other_clab_amt float64 = 0
  1682. var other_other_amt float64 = 0
  1683. var westernMedicine_claa_sunmfee float64 = 0
  1684. var westernMedicine_clab_amt float64 = 0
  1685. var westernMedicine_other_amt float64 = 0
  1686. var chineseTraditional_claa_sunmfee float64 = 0
  1687. var chineseTraditional_clab_amt float64 = 0
  1688. var chineseTraditional_other_amt float64 = 0
  1689. var check_claa_sunmfee float64 = 0
  1690. var check_clab_amt float64 = 0
  1691. var check_other_amt float64 = 0
  1692. var material_claa_sunmfee float64 = 0
  1693. var material_clab_amt float64 = 0
  1694. var material_other_amt float64 = 0
  1695. var laboratory_claa_sunmfee float64 = 0
  1696. var laboratory_clab_amt float64 = 0
  1697. var laboratory_other_amt float64 = 0
  1698. var treat_claa_sunmfee float64 = 0
  1699. var treat_clab_amt float64 = 0
  1700. var treat_other_amt float64 = 0
  1701. for _, item := range order.HisOrderInfo {
  1702. if item.MedChrgitmType == "01" { //床位费
  1703. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1704. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1705. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1706. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1707. if item.ChrgitmLv == "1" {
  1708. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1709. }
  1710. if item.ChrgitmLv == "2" {
  1711. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1712. }
  1713. if item.ChrgitmLv == "3" {
  1714. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1715. }
  1716. }
  1717. if item.MedChrgitmType == "03" { //检查费
  1718. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1719. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1720. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1721. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1722. if item.ChrgitmLv == "1" {
  1723. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1724. }
  1725. if item.ChrgitmLv == "2" {
  1726. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1727. }
  1728. if item.ChrgitmLv == "3" {
  1729. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1730. }
  1731. }
  1732. if item.MedChrgitmType == "04" { //化验费
  1733. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1734. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1735. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1736. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1737. if item.ChrgitmLv == "1" {
  1738. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1739. }
  1740. if item.ChrgitmLv == "2" {
  1741. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1742. }
  1743. if item.ChrgitmLv == "3" {
  1744. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1745. }
  1746. }
  1747. if item.MedChrgitmType == "05" { //治疗费
  1748. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1749. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1750. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1751. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1752. if item.ChrgitmLv == "1" {
  1753. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1754. }
  1755. if item.ChrgitmLv == "2" {
  1756. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1757. }
  1758. if item.ChrgitmLv == "3" {
  1759. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1760. }
  1761. }
  1762. if item.MedChrgitmType == "06" { //手术费
  1763. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1764. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1765. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1766. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1767. if item.ChrgitmLv == "1" {
  1768. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1769. }
  1770. if item.ChrgitmLv == "2" {
  1771. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1772. }
  1773. if item.ChrgitmLv == "3" {
  1774. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1775. }
  1776. }
  1777. if item.MedChrgitmType == "08" { //材料费
  1778. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1779. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1780. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1781. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1782. if item.ChrgitmLv == "1" {
  1783. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1784. }
  1785. if item.ChrgitmLv == "2" {
  1786. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1787. }
  1788. if item.ChrgitmLv == "3" {
  1789. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1790. }
  1791. }
  1792. if item.MedChrgitmType == "09" { //西药费
  1793. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1794. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1795. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1796. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1797. if item.ChrgitmLv == "1" {
  1798. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1799. }
  1800. if item.ChrgitmLv == "2" {
  1801. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1802. }
  1803. if item.ChrgitmLv == "3" {
  1804. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1805. }
  1806. }
  1807. if item.MedChrgitmType == "11" { //中成费
  1808. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1809. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1810. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1811. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1812. if item.ChrgitmLv == "1" {
  1813. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1814. }
  1815. if item.ChrgitmLv == "2" {
  1816. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1817. }
  1818. if item.ChrgitmLv == "3" {
  1819. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1820. }
  1821. }
  1822. if item.MedChrgitmType == "14" { //其他费
  1823. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1824. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1825. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1826. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1827. if item.ChrgitmLv == "1" {
  1828. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1829. }
  1830. if item.ChrgitmLv == "2" {
  1831. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1832. }
  1833. if item.ChrgitmLv == "3" {
  1834. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1835. }
  1836. }
  1837. }
  1838. var iteminfoStructs []service.IteminfoStruct
  1839. if bedCostTotal != 0 {
  1840. iteminfo.MedChrgitm = "01"
  1841. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1842. iteminfo.Amt = bedCostTotal
  1843. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1844. iteminfo.ClabAmt = bed_clab_amt
  1845. iteminfo.OthAmt = bed_other_amt
  1846. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1847. }
  1848. if checkCostTotal != 0 {
  1849. iteminfo.MedChrgitm = "03"
  1850. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1851. iteminfo.Amt = checkCostTotal
  1852. iteminfo.ClaaSumfee = check_claa_sunmfee
  1853. iteminfo.ClabAmt = check_clab_amt
  1854. iteminfo.OthAmt = check_other_amt
  1855. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1856. }
  1857. if laboratoryCostTotal != 0 {
  1858. iteminfo.MedChrgitm = "04"
  1859. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1860. iteminfo.Amt = laboratoryCostTotal
  1861. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1862. iteminfo.ClabAmt = laboratory_clab_amt
  1863. iteminfo.OthAmt = laboratory_other_amt
  1864. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1865. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1866. }
  1867. if treatCostTotal != 0 {
  1868. iteminfo.MedChrgitm = "05"
  1869. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1870. iteminfo.Amt = treatCostTotal
  1871. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1872. iteminfo.ClabAmt = treat_clab_amt
  1873. iteminfo.OthAmt = treat_other_amt
  1874. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1875. //(struct4101.IteminfoStruct, iteminfo)
  1876. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1877. }
  1878. if operationCostTotal != 0 {
  1879. iteminfo.MedChrgitm = "06"
  1880. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1881. iteminfo.Amt = operationCostTotal
  1882. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1883. iteminfo.ClabAmt = operation_clab_amt
  1884. iteminfo.OthAmt = operation_other_amt
  1885. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1886. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1887. }
  1888. if materialCostTotal != 0 {
  1889. iteminfo.MedChrgitm = "08"
  1890. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1891. iteminfo.Amt = materialCostTotal
  1892. iteminfo.ClaaSumfee = material_claa_sunmfee
  1893. iteminfo.ClabAmt = material_clab_amt
  1894. iteminfo.OthAmt = material_other_amt
  1895. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1896. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1897. }
  1898. if westernMedicineCostTotal != 0 {
  1899. iteminfo.MedChrgitm = "09"
  1900. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1901. iteminfo.Amt = westernMedicineCostTotal
  1902. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1903. iteminfo.ClabAmt = westernMedicine_clab_amt
  1904. iteminfo.OthAmt = westernMedicine_other_amt
  1905. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1906. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1907. }
  1908. if chineseTraditionalMedicineCostTotal != 0 {
  1909. iteminfo.MedChrgitm = "11"
  1910. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1911. iteminfo.Amt = westernMedicineCostTotal
  1912. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1913. iteminfo.ClabAmt = westernMedicine_clab_amt
  1914. iteminfo.OthAmt = westernMedicine_other_amt
  1915. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1916. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1917. }
  1918. if otherCostTotal != 0 {
  1919. iteminfo.MedChrgitm = "14"
  1920. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1921. iteminfo.Amt = otherCostTotal
  1922. iteminfo.ClaaSumfee = other_claa_sunmfee
  1923. iteminfo.ClabAmt = other_clab_amt
  1924. iteminfo.OthAmt = other_other_amt
  1925. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1926. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1927. }
  1928. struct4101.IteminfoStruct = iteminfoStructs
  1929. struct4101.Ntly = "中国"
  1930. struct4101.AdmCaty = "A03.06"
  1931. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1932. fmt.Println(result)
  1933. var dat map[string]interface{}
  1934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1935. fmt.Println(dat)
  1936. } else {
  1937. fmt.Println(err)
  1938. }
  1939. userJSONBytes, _ := json.Marshal(dat)
  1940. var res ResultSeventeen
  1941. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1942. utils.ErrorLog("解析失败:%v", err)
  1943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1944. return
  1945. }
  1946. if res.Infcode != 0 {
  1947. c.ServeSuccessJSON(map[string]interface{}{
  1948. "failed_code": -10,
  1949. "msg": res.ErrMsg,
  1950. })
  1951. return
  1952. } else {
  1953. order.FaPiaoNumber = zero
  1954. order.FaPiaoCode = last_order.FaPiaoCode
  1955. service.UpdateOrder(order)
  1956. hisFundSettleListResult := &models.HisFundSettleListResult{
  1957. Number: res.Output.SetlListId,
  1958. Status: 1,
  1959. Ctime: time.Now().Unix(),
  1960. Mtime: time.Now().Unix(),
  1961. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1962. IsUpload: 1,
  1963. OrderId: order_id,
  1964. }
  1965. service.CreateUploadRecord(hisFundSettleListResult)
  1966. c.ServeSuccessJSON(map[string]interface{}{
  1967. "msg": "上传成功",
  1968. "result": hisFundSettleListResult,
  1969. })
  1970. return
  1971. }
  1972. }
  1973. func (c *HisApiController) GetSettleListHospital() {
  1974. order_id, _ := c.GetInt64("order_id")
  1975. admin_user_id, _ := c.GetInt64("admin_user_id")
  1976. order, _ := service.GetHisOrderByIDTwo(order_id)
  1977. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1978. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1979. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1980. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1981. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1982. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1983. if order.ID == 0 {
  1984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1985. return
  1986. }
  1987. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1988. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1989. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1990. fmt.Println(count)
  1991. var zero string
  1992. number := count + 1
  1993. if number >= 1000 {
  1994. zero = "0000" + strconv.FormatInt(number, 10)
  1995. } else if number >= 10000 {
  1996. zero = "000" + strconv.FormatInt(number, 10)
  1997. } else if number >= 100000 {
  1998. zero = "00" + strconv.FormatInt(number, 10)
  1999. } else if number >= 1000000 {
  2000. zero = "0" + strconv.FormatInt(number, 10)
  2001. } else {
  2002. zero = strconv.FormatInt(number, 10)
  2003. }
  2004. fmt.Println(zero)
  2005. struct4101 := service.Struct4101{
  2006. PsnNo: order.PsnNo,
  2007. MdtrtId: order.MdtrtId,
  2008. SetlId: order.SetlId,
  2009. PsnName: order.PsnName,
  2010. Gend: order.Gend,
  2011. Brdy: his.Brdy,
  2012. Age: int64(order.Age),
  2013. Naty: order.Naty,
  2014. PatnCertType: "01",
  2015. Certno: order.Certno,
  2016. Prfs: "90",
  2017. ConerName: roles[0].UserName,
  2018. PatnRlts: "99",
  2019. ConerAddr: miConfig.OrgName,
  2020. ConerTel: admin.Mobile,
  2021. HiType: order.Insutype,
  2022. Insuplc: miConfig.InsuplcAdmdvs,
  2023. MaindiagFlag: "1",
  2024. BillCode: last_order.FaPiaoCode,
  2025. BillNo: zero,
  2026. BizSn: order.Number,
  2027. PsnSelfPay: order.PsnPartAmt,
  2028. PsnOwnPay: order.PsnPartAmt,
  2029. AcctPay: order.AcctPay,
  2030. PsnCashpay: order.PsnCashPay,
  2031. HiPaymtd: "1",
  2032. Hsorg: miConfig.InsuplcAdmdvs,
  2033. HsorgOpter: miConfig.InsuplcAdmdvs,
  2034. MedinsFillPsn: curRoles.UserName,
  2035. MedinsFillDept: depart.Name,
  2036. IptMedType: "2",
  2037. AdmTime: his.InHosptialTime,
  2038. AdmEndTime: his.OutHosptialTime,
  2039. }
  2040. struct4101.SetlBegnDate = order.SetlTime
  2041. struct4101.SetlEndDate = order.SetlTime
  2042. var rf []CustomFundPay
  2043. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2044. var tempFunPays []service.CustomStruct
  2045. for _, item := range rf {
  2046. var tempFunPay service.CustomStruct
  2047. tempFunPay.FundPayamt = item.FundPayamt
  2048. tempFunPay.FundPayType = item.FundPayType
  2049. tempFunPays = append(tempFunPays, tempFunPay)
  2050. }
  2051. struct4101.CustomStruct = tempFunPays
  2052. var tempDiaginfos []service.DiaginfoStructTwo
  2053. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2054. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2055. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2056. var config []*models.HisXtDiagnoseConfig
  2057. for _, item := range diagnosis_ids {
  2058. id, _ := strconv.ParseInt(item, 10, 64)
  2059. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2060. config = append(config, &diagnosisConfig)
  2061. }
  2062. for index, item := range config {
  2063. if index == 0 {
  2064. var tempDiaginfo service.DiaginfoStructTwo
  2065. tempDiaginfo.DiagCode = item.CountryCode
  2066. tempDiaginfo.DiagName = item.CountryContentName
  2067. tempDiaginfo.DiagType = "1"
  2068. tempDiaginfo.MaindiagFlag = "1"
  2069. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2070. } else {
  2071. var tempDiaginfo service.DiaginfoStructTwo
  2072. tempDiaginfo.DiagCode = item.CountryCode
  2073. tempDiaginfo.DiagName = item.CountryContentName
  2074. tempDiaginfo.DiagType = "2"
  2075. tempDiaginfo.MaindiagFlag = "0"
  2076. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2077. }
  2078. }
  2079. struct4101.Diseinfo = tempDiaginfos
  2080. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2081. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2082. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2083. tempOpspdiseinfo2.OprnOprtCode = ""
  2084. tempOpspdiseinfo2.OprnOprtName = ""
  2085. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2086. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2087. var iteminfo service.IteminfoStruct
  2088. var bedCostTotal float64 = 0 //床位总费
  2089. var bedCostSelfTotal float64 = 0 //床位自费
  2090. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2091. var operationCostTotal float64 = 0 //手术费
  2092. var operationCostSelfTotal float64 = 0 //手术费
  2093. var operationCostPartSelfTotal float64 = 0 //手术费
  2094. var otherCostTotal float64 = 0 //其他费用
  2095. var otherCostSelfTotal float64 = 0 //其他费用
  2096. var otherCostPartSelfTotal float64 = 0 //其他费用
  2097. var materialCostTotal float64 = 0 //材料费
  2098. var materialCostSelfTotal float64 = 0 //材料费
  2099. var materialCostPartSelfTotal float64 = 0 //材料费
  2100. var westernMedicineCostTotal float64 = 0 //西药费
  2101. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2102. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2103. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2104. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2105. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2106. var checkCostTotal float64 = 0 //检查费
  2107. var checkCostSelfTotal float64 = 0 //检查费
  2108. var checkCostPartSelfTotal float64 = 0 //检查费
  2109. var laboratoryCostTotal float64 = 0 //化验费
  2110. var laboratoryCostSelfTotal float64 = 0 //化验费
  2111. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2112. var treatCostTotal float64 = 0 //治疗费用
  2113. var treatCostSelfTotal float64 = 0 //治疗费用
  2114. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2115. decimal.DivisionPrecision = 2
  2116. var bed_fulamt_ownpay_amt float64 = 0
  2117. var operation_fulamt_ownpay_amt float64 = 0
  2118. var other_fulamt_ownpay_amt float64 = 0
  2119. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2120. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2121. var check_fulamt_ownpay_amt float64 = 0
  2122. var material_fulamt_ownpay_amt float64 = 0
  2123. var laboratory_fulamt_ownpay_amt float64 = 0
  2124. var treat_fulamt_ownpay_amt float64 = 0
  2125. var bed_claa_sunmfee float64 = 0
  2126. var bed_clab_amt float64 = 0
  2127. var bed_other_amt float64 = 0
  2128. var operation_claa_sunmfee float64 = 0
  2129. var operation_clab_amt float64 = 0
  2130. var operation_other_amt float64 = 0
  2131. var other_claa_sunmfee float64 = 0
  2132. var other_clab_amt float64 = 0
  2133. var other_other_amt float64 = 0
  2134. var westernMedicine_claa_sunmfee float64 = 0
  2135. var westernMedicine_clab_amt float64 = 0
  2136. var westernMedicine_other_amt float64 = 0
  2137. var chineseTraditional_claa_sunmfee float64 = 0
  2138. var chineseTraditional_clab_amt float64 = 0
  2139. var chineseTraditional_other_amt float64 = 0
  2140. var check_claa_sunmfee float64 = 0
  2141. var check_clab_amt float64 = 0
  2142. var check_other_amt float64 = 0
  2143. var material_claa_sunmfee float64 = 0
  2144. var material_clab_amt float64 = 0
  2145. var material_other_amt float64 = 0
  2146. var laboratory_claa_sunmfee float64 = 0
  2147. var laboratory_clab_amt float64 = 0
  2148. var laboratory_other_amt float64 = 0
  2149. var treat_claa_sunmfee float64 = 0
  2150. var treat_clab_amt float64 = 0
  2151. var treat_other_amt float64 = 0
  2152. for _, item := range order.HisOrderInfo {
  2153. if item.MedChrgitmType == "01" { //床位费
  2154. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2155. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2156. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2157. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2158. if item.ChrgitmLv == "1" {
  2159. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2160. }
  2161. if item.ChrgitmLv == "2" {
  2162. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2163. }
  2164. if item.ChrgitmLv == "3" {
  2165. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2166. }
  2167. }
  2168. if item.MedChrgitmType == "03" { //检查费
  2169. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2170. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2171. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2172. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2173. if item.ChrgitmLv == "1" {
  2174. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2175. }
  2176. if item.ChrgitmLv == "2" {
  2177. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2178. }
  2179. if item.ChrgitmLv == "3" {
  2180. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2181. }
  2182. }
  2183. if item.MedChrgitmType == "04" { //化验费
  2184. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2185. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2186. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2187. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2188. if item.ChrgitmLv == "1" {
  2189. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2190. }
  2191. if item.ChrgitmLv == "2" {
  2192. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2193. }
  2194. if item.ChrgitmLv == "3" {
  2195. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2196. }
  2197. }
  2198. if item.MedChrgitmType == "05" { //治疗费
  2199. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2200. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2201. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2202. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2203. if item.ChrgitmLv == "1" {
  2204. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2205. }
  2206. if item.ChrgitmLv == "2" {
  2207. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2208. }
  2209. if item.ChrgitmLv == "3" {
  2210. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2211. }
  2212. }
  2213. if item.MedChrgitmType == "06" { //手术费
  2214. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2215. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2216. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2217. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2218. if item.ChrgitmLv == "1" {
  2219. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2220. }
  2221. if item.ChrgitmLv == "2" {
  2222. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2223. }
  2224. if item.ChrgitmLv == "3" {
  2225. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2226. }
  2227. }
  2228. if item.MedChrgitmType == "08" { //材料费
  2229. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2230. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2231. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2232. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2233. if item.ChrgitmLv == "1" {
  2234. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2235. }
  2236. if item.ChrgitmLv == "2" {
  2237. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2238. }
  2239. if item.ChrgitmLv == "3" {
  2240. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2241. }
  2242. }
  2243. if item.MedChrgitmType == "09" { //西药费
  2244. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2245. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2246. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2247. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2248. if item.ChrgitmLv == "1" {
  2249. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2250. }
  2251. if item.ChrgitmLv == "2" {
  2252. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2253. }
  2254. if item.ChrgitmLv == "3" {
  2255. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2256. }
  2257. }
  2258. if item.MedChrgitmType == "11" { //中成费
  2259. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2260. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2261. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2262. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2263. if item.ChrgitmLv == "1" {
  2264. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2265. }
  2266. if item.ChrgitmLv == "2" {
  2267. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2268. }
  2269. if item.ChrgitmLv == "3" {
  2270. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2271. }
  2272. }
  2273. if item.MedChrgitmType == "14" { //其他费
  2274. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2275. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2276. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2277. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2278. if item.ChrgitmLv == "1" {
  2279. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2280. }
  2281. if item.ChrgitmLv == "2" {
  2282. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2283. }
  2284. if item.ChrgitmLv == "3" {
  2285. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2286. }
  2287. }
  2288. }
  2289. var iteminfoStructs []service.IteminfoStruct
  2290. if bedCostTotal != 0 {
  2291. iteminfo.MedChrgitm = "01"
  2292. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2293. iteminfo.Amt = bedCostTotal
  2294. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2295. iteminfo.ClabAmt = bed_clab_amt
  2296. iteminfo.OthAmt = bed_other_amt
  2297. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2298. }
  2299. if checkCostTotal != 0 {
  2300. iteminfo.MedChrgitm = "03"
  2301. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2302. iteminfo.Amt = checkCostTotal
  2303. iteminfo.ClaaSumfee = check_claa_sunmfee
  2304. iteminfo.ClabAmt = check_clab_amt
  2305. iteminfo.OthAmt = check_other_amt
  2306. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2307. }
  2308. if laboratoryCostTotal != 0 {
  2309. iteminfo.MedChrgitm = "04"
  2310. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2311. iteminfo.Amt = laboratoryCostTotal
  2312. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2313. iteminfo.ClabAmt = laboratory_clab_amt
  2314. iteminfo.OthAmt = laboratory_other_amt
  2315. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2316. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2317. }
  2318. if treatCostTotal != 0 {
  2319. iteminfo.MedChrgitm = "05"
  2320. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2321. iteminfo.Amt = treatCostTotal
  2322. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2323. iteminfo.ClabAmt = treat_clab_amt
  2324. iteminfo.OthAmt = treat_other_amt
  2325. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2326. //(struct4101.IteminfoStruct, iteminfo)
  2327. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2328. }
  2329. if operationCostTotal != 0 {
  2330. iteminfo.MedChrgitm = "06"
  2331. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2332. iteminfo.Amt = operationCostTotal
  2333. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2334. iteminfo.ClabAmt = operation_clab_amt
  2335. iteminfo.OthAmt = operation_other_amt
  2336. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2337. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2338. }
  2339. if materialCostTotal != 0 {
  2340. iteminfo.MedChrgitm = "08"
  2341. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2342. iteminfo.Amt = materialCostTotal
  2343. iteminfo.ClaaSumfee = material_claa_sunmfee
  2344. iteminfo.ClabAmt = material_clab_amt
  2345. iteminfo.OthAmt = material_other_amt
  2346. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2347. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2348. }
  2349. if westernMedicineCostTotal != 0 {
  2350. iteminfo.MedChrgitm = "09"
  2351. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2352. iteminfo.Amt = westernMedicineCostTotal
  2353. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2354. iteminfo.ClabAmt = westernMedicine_clab_amt
  2355. iteminfo.OthAmt = westernMedicine_other_amt
  2356. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2357. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2358. }
  2359. if chineseTraditionalMedicineCostTotal != 0 {
  2360. iteminfo.MedChrgitm = "11"
  2361. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2362. iteminfo.Amt = westernMedicineCostTotal
  2363. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2364. iteminfo.ClabAmt = westernMedicine_clab_amt
  2365. iteminfo.OthAmt = westernMedicine_other_amt
  2366. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2367. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2368. }
  2369. if otherCostTotal != 0 {
  2370. iteminfo.MedChrgitm = "14"
  2371. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2372. iteminfo.Amt = otherCostTotal
  2373. iteminfo.ClaaSumfee = other_claa_sunmfee
  2374. iteminfo.ClabAmt = other_clab_amt
  2375. iteminfo.OthAmt = other_other_amt
  2376. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2377. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2378. }
  2379. struct4101.IteminfoStruct = iteminfoStructs
  2380. struct4101.Ntly = "中国"
  2381. struct4101.AdmCaty = "A03.06"
  2382. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2383. fmt.Println(result)
  2384. var dat map[string]interface{}
  2385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2386. fmt.Println(dat)
  2387. } else {
  2388. fmt.Println(err)
  2389. }
  2390. userJSONBytes, _ := json.Marshal(dat)
  2391. var res ResultSeventeen
  2392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2393. utils.ErrorLog("解析失败:%v", err)
  2394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2395. return
  2396. }
  2397. if res.Infcode != 0 {
  2398. c.ServeSuccessJSON(map[string]interface{}{
  2399. "failed_code": -10,
  2400. "msg": res.ErrMsg,
  2401. })
  2402. return
  2403. } else {
  2404. order.FaPiaoNumber = zero
  2405. order.FaPiaoCode = last_order.FaPiaoCode
  2406. service.UpdateOrder(order)
  2407. hisFundSettleListResult := &models.HisFundSettleListResult{
  2408. Number: res.Output.SetlListId,
  2409. Status: 1,
  2410. Ctime: time.Now().Unix(),
  2411. Mtime: time.Now().Unix(),
  2412. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2413. IsUpload: 1,
  2414. OrderId: order_id,
  2415. }
  2416. service.CreateUploadRecord(hisFundSettleListResult)
  2417. c.ServeSuccessJSON(map[string]interface{}{
  2418. "msg": "上传成功",
  2419. "result": hisFundSettleListResult,
  2420. })
  2421. return
  2422. }
  2423. }
  2424. func (c *HisApiController) GetBatchSettleList() {
  2425. orders, _ := service.GetAllHisOrder(10106)
  2426. for _, item := range orders {
  2427. order_id := item.ID
  2428. order, _ := service.GetHisOrderByIDTwo(order_id)
  2429. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2430. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2431. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2432. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2433. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2434. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2435. if order.ID == 0 {
  2436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2437. return
  2438. }
  2439. if his.BalanceAccountsType == 2 {
  2440. continue
  2441. }
  2442. struct4101 := service.Struct4101{
  2443. PsnNo: order.PsnNo,
  2444. MdtrtId: order.MdtrtId,
  2445. SetlId: order.SetlId,
  2446. PsnName: order.PsnName,
  2447. Gend: order.Gend,
  2448. Brdy: his.Brdy,
  2449. Age: his.Age,
  2450. Naty: order.Naty,
  2451. PatnCertType: "01",
  2452. Certno: order.Certno,
  2453. Prfs: "90",
  2454. ConerName: roles[0].UserName,
  2455. PatnRlts: "99",
  2456. ConerAddr: miConfig.OrgName,
  2457. ConerTel: admin.Mobile,
  2458. HiType: order.Insutype,
  2459. Insuplc: his.InsuplcAdmdvs,
  2460. MaindiagFlag: "1",
  2461. BillCode: order.FaPiaoCode,
  2462. BillNo: order.FaPiaoNumber,
  2463. BizSn: order.Number,
  2464. PsnSelfPay: order.PsnPartAmt,
  2465. PsnOwnPay: order.PsnPartAmt,
  2466. AcctPay: order.AcctPay,
  2467. PsnCashpay: order.PsnCashPay,
  2468. HiPaymtd: "1",
  2469. Hsorg: his.InsuplcAdmdvs,
  2470. HsorgOpter: his.InsuplcAdmdvs,
  2471. MedinsFillPsn: curRoles.UserName,
  2472. MedinsFillDept: depart.Name,
  2473. IptMedType: "2",
  2474. }
  2475. struct4101.SetlBegnDate = order.SetlTime
  2476. struct4101.SetlEndDate = order.SetlTime
  2477. //if order.SettleType == 1 {
  2478. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2479. // dateStr := t.Format("2006-01-02")
  2480. // struct4101.SetlBegnDate = dateStr
  2481. // struct4101.SetlEndDate = dateStr
  2482. //} else {
  2483. // t := time.Unix(int64(order.SettleStartTime), 0)
  2484. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2485. // dateStartStr := t.Format("2006-01-02")
  2486. // dateEndStr := t2.Format("2006-01-02")
  2487. // struct4101.SetlBegnDate = dateStartStr
  2488. // struct4101.SetlEndDate = dateEndStr
  2489. //}
  2490. var rf []CustomFundPay
  2491. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2492. var tempFunPays []service.CustomStruct
  2493. var tempFunPay610100 service.CustomStruct
  2494. for _, item := range rf {
  2495. if item.FundPayType == "610100" {
  2496. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2497. tempFunPay610100.FundPayType = item.FundPayType
  2498. } else {
  2499. var tempFunPay service.CustomStruct
  2500. tempFunPay.FundPayamt = item.FundPayamt
  2501. tempFunPay.FundPayType = item.FundPayType
  2502. tempFunPays = append(tempFunPays, tempFunPay)
  2503. }
  2504. }
  2505. tempFunPays = append(tempFunPays, tempFunPay610100)
  2506. struct4101.CustomStruct = tempFunPays
  2507. var tempDiaginfos []service.DiaginfoStructTwo
  2508. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2509. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2510. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2511. var config []*models.HisXtDiagnoseConfig
  2512. for _, item := range diagnosis_ids {
  2513. id, _ := strconv.ParseInt(item, 10, 64)
  2514. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2515. config = append(config, &diagnosisConfig)
  2516. }
  2517. for index, item := range config {
  2518. if index == 0 {
  2519. var tempDiaginfo service.DiaginfoStructTwo
  2520. tempDiaginfo.DiagCode = item.CountryCode
  2521. tempDiaginfo.DiagName = item.CountryContentName
  2522. tempDiaginfo.DiagType = "1"
  2523. tempDiaginfo.MaindiagFlag = "1"
  2524. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2525. } else {
  2526. var tempDiaginfo service.DiaginfoStructTwo
  2527. tempDiaginfo.DiagCode = item.CountryCode
  2528. tempDiaginfo.DiagName = item.CountryContentName
  2529. tempDiaginfo.DiagType = "2"
  2530. tempDiaginfo.MaindiagFlag = "0"
  2531. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2532. }
  2533. }
  2534. struct4101.Diseinfo = tempDiaginfos
  2535. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2536. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2537. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2538. tempOpspdiseinfo2.OprnOprtCode = ""
  2539. tempOpspdiseinfo2.OprnOprtName = ""
  2540. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2541. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2542. var iteminfo service.IteminfoStruct
  2543. var bedCostTotal float64 = 0 //床位总费
  2544. var bedCostSelfTotal float64 = 0 //床位自费
  2545. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2546. var examineCostTotal float64 = 0 //诊查总费
  2547. var examineCostSelfTotal float64 = 0 //诊查自费
  2548. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2549. var nursingCostTotal float64 = 0 //护理总费
  2550. var nursingCostSelfTotal float64 = 0 //护理自费
  2551. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2552. var chineseMedicineCostTotal float64 = 0 //中成药
  2553. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2554. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2555. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2556. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2557. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2558. var registerCostTotal float64 = 0 //一般诊疗费
  2559. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2560. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2561. var operationCostTotal float64 = 0 //手术费
  2562. var operationCostSelfTotal float64 = 0 //手术费
  2563. var operationCostPartSelfTotal float64 = 0 //手术费
  2564. var otherCostTotal float64 = 0 //其他费用
  2565. var otherCostSelfTotal float64 = 0 //其他费用
  2566. var otherCostPartSelfTotal float64 = 0 //其他费用
  2567. var materialCostTotal float64 = 0 //材料费
  2568. var materialCostSelfTotal float64 = 0 //材料费
  2569. var materialCostPartSelfTotal float64 = 0 //材料费
  2570. var westernMedicineCostTotal float64 = 0 //西药费
  2571. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2572. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2573. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2574. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2575. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2576. var checkCostTotal float64 = 0 //检查费
  2577. var checkCostSelfTotal float64 = 0 //检查费
  2578. var checkCostPartSelfTotal float64 = 0 //检查费
  2579. var laboratoryCostTotal float64 = 0 //化验费
  2580. var laboratoryCostSelfTotal float64 = 0 //化验费
  2581. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2582. var treatCostTotal float64 = 0 //治疗费用
  2583. var treatCostSelfTotal float64 = 0 //治疗费用
  2584. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2585. decimal.DivisionPrecision = 2
  2586. var bed_fulamt_ownpay_amt float64 = 0
  2587. var examine_fulamt_ownpay_amt float64 = 0
  2588. var nursing_fulamt_ownpay_amt float64 = 0
  2589. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2590. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2591. var register_fulamt_ownpay_amt float64 = 0
  2592. var operation_fulamt_ownpay_amt float64 = 0
  2593. var other_fulamt_ownpay_amt float64 = 0
  2594. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2595. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2596. var check_fulamt_ownpay_amt float64 = 0
  2597. var material_fulamt_ownpay_amt float64 = 0
  2598. var laboratory_fulamt_ownpay_amt float64 = 0
  2599. var treat_fulamt_ownpay_amt float64 = 0
  2600. var bed_claa_sunmfee float64 = 0
  2601. var bed_clab_amt float64 = 0
  2602. var bed_other_amt float64 = 0
  2603. var examine_claa_sunmfee float64 = 0
  2604. var examine_clab_amt float64 = 0
  2605. var examine_other_amt float64 = 0
  2606. var nursing_claa_sunmfee float64 = 0
  2607. var nursing_clab_amt float64 = 0
  2608. var nursing_other_amt float64 = 0
  2609. var chinese_medicine_claa_sunmfee float64 = 0
  2610. var chinese_medicine_clab_amt float64 = 0
  2611. var chinese_medicine_other_amt float64 = 0
  2612. var commonly_treatment_claa_sunmfee float64 = 0
  2613. var commonly_treatment_clab_amt float64 = 0
  2614. var commonly_treatment_other_amt float64 = 0
  2615. var operation_claa_sunmfee float64 = 0
  2616. var operation_clab_amt float64 = 0
  2617. var operation_other_amt float64 = 0
  2618. var other_claa_sunmfee float64 = 0
  2619. var other_clab_amt float64 = 0
  2620. var other_other_amt float64 = 0
  2621. var westernMedicine_claa_sunmfee float64 = 0
  2622. var westernMedicine_clab_amt float64 = 0
  2623. var westernMedicine_other_amt float64 = 0
  2624. var chineseTraditional_claa_sunmfee float64 = 0
  2625. var chineseTraditional_clab_amt float64 = 0
  2626. var chineseTraditional_other_amt float64 = 0
  2627. var check_claa_sunmfee float64 = 0
  2628. var check_clab_amt float64 = 0
  2629. var check_other_amt float64 = 0
  2630. var material_claa_sunmfee float64 = 0
  2631. var material_clab_amt float64 = 0
  2632. var material_other_amt float64 = 0
  2633. var laboratory_claa_sunmfee float64 = 0
  2634. var laboratory_clab_amt float64 = 0
  2635. var laboratory_other_amt float64 = 0
  2636. var treat_claa_sunmfee float64 = 0
  2637. var treat_clab_amt float64 = 0
  2638. var treat_other_amt float64 = 0
  2639. var register_claa_sunmfee float64 = 0
  2640. var register_clab_amt float64 = 0
  2641. var register_other_amt float64 = 0
  2642. for _, item := range order.HisOrderInfo {
  2643. if item.MedChrgitmType == "01" { //床位费
  2644. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2645. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2646. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2647. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2648. if item.ChrgitmLv == "1" {
  2649. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2650. }
  2651. if item.ChrgitmLv == "2" {
  2652. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2653. }
  2654. if item.ChrgitmLv == "3" {
  2655. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2656. }
  2657. }
  2658. if item.MedChrgitmType == "02" { //诊查
  2659. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2660. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2661. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2662. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2663. if item.ChrgitmLv == "1" {
  2664. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2665. }
  2666. if item.ChrgitmLv == "2" {
  2667. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2668. }
  2669. if item.ChrgitmLv == "3" {
  2670. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2671. }
  2672. }
  2673. if item.MedChrgitmType == "03" { //检查费
  2674. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2675. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2676. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2677. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2678. if item.ChrgitmLv == "1" {
  2679. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2680. }
  2681. if item.ChrgitmLv == "2" {
  2682. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2683. }
  2684. if item.ChrgitmLv == "3" {
  2685. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2686. }
  2687. }
  2688. if item.MedChrgitmType == "04" { //化验费
  2689. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2690. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2691. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2692. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2693. if item.ChrgitmLv == "1" {
  2694. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2695. }
  2696. if item.ChrgitmLv == "2" {
  2697. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2698. }
  2699. if item.ChrgitmLv == "3" {
  2700. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2701. }
  2702. }
  2703. if item.MedChrgitmType == "05" { //治疗费
  2704. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2705. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2706. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2707. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2708. if item.ChrgitmLv == "1" {
  2709. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2710. }
  2711. if item.ChrgitmLv == "2" {
  2712. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2713. }
  2714. if item.ChrgitmLv == "3" {
  2715. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2716. }
  2717. }
  2718. if item.MedChrgitmType == "06" { //手术费
  2719. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2720. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2721. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2722. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2723. if item.ChrgitmLv == "1" {
  2724. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2725. }
  2726. if item.ChrgitmLv == "2" {
  2727. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2728. }
  2729. if item.ChrgitmLv == "3" {
  2730. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2731. }
  2732. }
  2733. if item.MedChrgitmType == "07" { //手术费
  2734. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2735. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2736. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2737. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2738. if item.ChrgitmLv == "1" {
  2739. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2740. }
  2741. if item.ChrgitmLv == "2" {
  2742. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2743. }
  2744. if item.ChrgitmLv == "3" {
  2745. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2746. }
  2747. }
  2748. if item.MedChrgitmType == "08" { //材料费
  2749. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2750. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2751. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2752. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2753. if item.ChrgitmLv == "1" {
  2754. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2755. }
  2756. if item.ChrgitmLv == "2" {
  2757. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2758. }
  2759. if item.ChrgitmLv == "3" {
  2760. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2761. }
  2762. }
  2763. if item.MedChrgitmType == "09" { //西药费
  2764. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2765. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2766. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2767. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2768. if item.ChrgitmLv == "1" {
  2769. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2770. }
  2771. if item.ChrgitmLv == "2" {
  2772. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2773. }
  2774. if item.ChrgitmLv == "3" {
  2775. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2776. }
  2777. }
  2778. if item.MedChrgitmType == "10" { //中药饮片
  2779. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2780. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2781. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2782. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2783. if item.ChrgitmLv == "1" {
  2784. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2785. }
  2786. if item.ChrgitmLv == "2" {
  2787. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2788. }
  2789. if item.ChrgitmLv == "3" {
  2790. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2791. }
  2792. }
  2793. if item.MedChrgitmType == "11" { //中成费
  2794. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2795. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2796. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2797. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2798. if item.ChrgitmLv == "1" {
  2799. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2800. }
  2801. if item.ChrgitmLv == "2" {
  2802. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2803. }
  2804. if item.ChrgitmLv == "3" {
  2805. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2806. }
  2807. }
  2808. if item.MedChrgitmType == "12" { //中成费
  2809. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2810. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2811. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2812. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2813. if item.ChrgitmLv == "1" {
  2814. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2815. }
  2816. if item.ChrgitmLv == "2" {
  2817. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2818. }
  2819. if item.ChrgitmLv == "3" {
  2820. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2821. }
  2822. }
  2823. if item.MedChrgitmType == "13" { //中成费
  2824. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2825. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2826. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2827. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2828. if item.ChrgitmLv == "1" {
  2829. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2830. }
  2831. if item.ChrgitmLv == "2" {
  2832. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2833. }
  2834. if item.ChrgitmLv == "3" {
  2835. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2836. }
  2837. }
  2838. if item.MedChrgitmType == "14" { //其他费
  2839. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2840. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2841. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2842. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2843. if item.ChrgitmLv == "1" {
  2844. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2845. }
  2846. if item.ChrgitmLv == "2" {
  2847. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2848. }
  2849. if item.ChrgitmLv == "3" {
  2850. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2851. }
  2852. }
  2853. }
  2854. var iteminfoStructs []service.IteminfoStruct
  2855. if bedCostTotal != 0 {
  2856. iteminfo.MedChrgitm = "01"
  2857. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2858. iteminfo.Amt = bedCostTotal
  2859. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2860. iteminfo.ClabAmt = bed_clab_amt
  2861. iteminfo.OthAmt = bed_other_amt
  2862. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2863. }
  2864. if examineCostTotal != 0 {
  2865. iteminfo.MedChrgitm = "02"
  2866. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2867. iteminfo.Amt = examineCostTotal
  2868. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2869. iteminfo.ClabAmt = examine_clab_amt
  2870. iteminfo.OthAmt = examine_other_amt
  2871. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2872. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2873. }
  2874. if checkCostTotal != 0 {
  2875. iteminfo.MedChrgitm = "03"
  2876. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2877. iteminfo.Amt = checkCostTotal
  2878. iteminfo.ClaaSumfee = check_claa_sunmfee
  2879. iteminfo.ClabAmt = check_clab_amt
  2880. iteminfo.OthAmt = check_other_amt
  2881. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2882. }
  2883. if laboratoryCostTotal != 0 {
  2884. iteminfo.MedChrgitm = "04"
  2885. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2886. iteminfo.Amt = laboratoryCostTotal
  2887. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2888. iteminfo.ClabAmt = laboratory_clab_amt
  2889. iteminfo.OthAmt = laboratory_other_amt
  2890. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2891. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2892. }
  2893. if treatCostTotal != 0 {
  2894. iteminfo.MedChrgitm = "05"
  2895. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2896. iteminfo.Amt = treatCostTotal
  2897. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2898. iteminfo.ClabAmt = treat_clab_amt
  2899. iteminfo.OthAmt = treat_other_amt
  2900. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2901. //(struct4101.IteminfoStruct, iteminfo)
  2902. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2903. }
  2904. if operationCostTotal != 0 {
  2905. iteminfo.MedChrgitm = "06"
  2906. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2907. iteminfo.Amt = operationCostTotal
  2908. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2909. iteminfo.ClabAmt = operation_clab_amt
  2910. iteminfo.OthAmt = operation_other_amt
  2911. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2912. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2913. }
  2914. if nursingCostTotal != 0 {
  2915. iteminfo.MedChrgitm = "07"
  2916. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2917. iteminfo.Amt = nursingCostTotal
  2918. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2919. iteminfo.ClabAmt = nursing_clab_amt
  2920. iteminfo.OthAmt = nursing_other_amt
  2921. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2922. }
  2923. if materialCostTotal != 0 {
  2924. iteminfo.MedChrgitm = "08"
  2925. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2926. iteminfo.Amt = materialCostTotal
  2927. iteminfo.ClaaSumfee = material_claa_sunmfee
  2928. iteminfo.ClabAmt = material_clab_amt
  2929. iteminfo.OthAmt = material_other_amt
  2930. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2931. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2932. }
  2933. if westernMedicineCostTotal != 0 {
  2934. iteminfo.MedChrgitm = "09"
  2935. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2936. iteminfo.Amt = westernMedicineCostTotal
  2937. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2938. iteminfo.ClabAmt = westernMedicine_clab_amt
  2939. iteminfo.OthAmt = westernMedicine_other_amt
  2940. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2941. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2942. }
  2943. if chineseMedicineCostTotal != 0 {
  2944. iteminfo.MedChrgitm = "10"
  2945. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2946. iteminfo.Amt = chineseMedicineCostTotal
  2947. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2948. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2949. iteminfo.OthAmt = chinese_medicine_other_amt
  2950. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2951. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2952. }
  2953. if chineseTraditionalMedicineCostTotal != 0 {
  2954. iteminfo.MedChrgitm = "11"
  2955. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2956. iteminfo.Amt = westernMedicineCostTotal
  2957. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2958. iteminfo.ClabAmt = westernMedicine_clab_amt
  2959. iteminfo.OthAmt = westernMedicine_other_amt
  2960. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2961. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2962. }
  2963. if commonlyTreatmentCostTotal != 0 {
  2964. iteminfo.MedChrgitm = "12"
  2965. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2966. iteminfo.Amt = commonlyTreatmentCostTotal
  2967. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2968. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2969. iteminfo.OthAmt = commonly_treatment_other_amt
  2970. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2971. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2972. }
  2973. if registerCostTotal != 0 {
  2974. iteminfo.MedChrgitm = "13"
  2975. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2976. iteminfo.Amt = registerCostTotal
  2977. iteminfo.ClaaSumfee = register_claa_sunmfee
  2978. iteminfo.ClabAmt = register_clab_amt
  2979. iteminfo.OthAmt = register_other_amt
  2980. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2981. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2982. }
  2983. if otherCostTotal != 0 {
  2984. iteminfo.MedChrgitm = "14"
  2985. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2986. iteminfo.Amt = otherCostTotal
  2987. iteminfo.ClaaSumfee = other_claa_sunmfee
  2988. iteminfo.ClabAmt = other_clab_amt
  2989. iteminfo.OthAmt = other_other_amt
  2990. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2991. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2992. }
  2993. struct4101.IteminfoStruct = iteminfoStructs
  2994. struct4101.Ntly = "中国"
  2995. struct4101.AdmCaty = "A03.06"
  2996. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2997. fmt.Println(result)
  2998. var dat map[string]interface{}
  2999. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3000. fmt.Println(dat)
  3001. } else {
  3002. fmt.Println(err)
  3003. }
  3004. userJSONBytes, _ := json.Marshal(dat)
  3005. var res ResultSeventeen
  3006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3007. utils.ErrorLog("解析失败:%v", err)
  3008. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3009. adminUser := c.GetAdminUserInfo()
  3010. errlog := &models.HisOrderError{
  3011. UserOrgId: adminUser.CurrentOrgId,
  3012. Ctime: time.Now().Unix(),
  3013. Mtime: time.Now().Unix(),
  3014. ErrMsg: res.ErrMsg + "解析失败",
  3015. Status: 1,
  3016. PatientId: order_id,
  3017. Stage: 10106,
  3018. }
  3019. service.CreateErrMsgLog(errlog)
  3020. continue
  3021. }
  3022. if res.Infcode != 0 {
  3023. adminUser := c.GetAdminUserInfo()
  3024. errlog := &models.HisOrderError{
  3025. UserOrgId: adminUser.CurrentOrgId,
  3026. Ctime: time.Now().Unix(),
  3027. Mtime: time.Now().Unix(),
  3028. ErrMsg: res.ErrMsg,
  3029. Status: 1,
  3030. PatientId: order_id,
  3031. Stage: 10106,
  3032. }
  3033. service.CreateErrMsgLog(errlog)
  3034. continue
  3035. } else {
  3036. hisFundSettleListResult := &models.HisFundSettleListResult{
  3037. Number: res.Output.SetlListId,
  3038. Status: 1,
  3039. Ctime: time.Now().Unix(),
  3040. Mtime: time.Now().Unix(),
  3041. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3042. IsUpload: 1,
  3043. OrderId: order_id,
  3044. }
  3045. service.CreateUploadRecord(hisFundSettleListResult)
  3046. continue
  3047. }
  3048. }
  3049. }
  3050. func (c *HisApiController) GetOrgInfo() {
  3051. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3052. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3053. }
  3054. func (c *HisApiController) GetHisPatientInfo() {
  3055. medical_insurance_card := c.GetString("medical_insurance_card")
  3056. id_card_type, _ := c.GetInt64("id_card_type")
  3057. id_card := c.GetString("id_card")
  3058. adminInfo := c.GetAdminUserInfo()
  3059. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3060. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3061. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3062. IdCardNo := ""
  3063. if id_card_type == 1 {
  3064. IdCardNo = medical_insurance_card
  3065. } else if id_card_type == 2 {
  3066. IdCardNo = id_card
  3067. }
  3068. if config.IsOpen == 1 {
  3069. 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
  3070. resp, requestErr := http.Get(api)
  3071. if requestErr != nil {
  3072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3073. return
  3074. }
  3075. defer resp.Body.Close()
  3076. body, ioErr := ioutil.ReadAll(resp.Body)
  3077. if ioErr != nil {
  3078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3080. return
  3081. }
  3082. var respJSON map[string]interface{}
  3083. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3086. return
  3087. }
  3088. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3089. userJSONBytes, _ := json.Marshal(userJSON)
  3090. var res ResultTwo
  3091. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3092. utils.ErrorLog("解析失败:%v", err)
  3093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3094. return
  3095. }
  3096. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3097. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3098. infoStr := string(Iinfos)
  3099. idetinfoStr := string(Idetinfos)
  3100. if res.Infcode == 0 {
  3101. his := models.VMHisPatient{
  3102. Status: 1,
  3103. Ctime: time.Now().Unix(),
  3104. Mtime: time.Now().Unix(),
  3105. PsnNo: res.Output.Baseinfo.PsnNo,
  3106. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3107. Certno: res.Output.Baseinfo.Certno,
  3108. PsnName: res.Output.Baseinfo.PsnName,
  3109. Gend: res.Output.Baseinfo.Gend,
  3110. Naty: res.Output.Baseinfo.Naty,
  3111. Brdy: res.Output.Baseinfo.Brdy,
  3112. Age: res.Output.Baseinfo.Age,
  3113. Iinfo: infoStr,
  3114. Idetinfo: idetinfoStr,
  3115. UserOrgId: adminInfo.CurrentOrgId,
  3116. IsReturn: 1,
  3117. IdCardType: id_card_type,
  3118. }
  3119. c.ServeSuccessJSON(map[string]interface{}{
  3120. "info": his,
  3121. })
  3122. } else {
  3123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3124. return
  3125. }
  3126. }
  3127. }
  3128. //func GetBasBaseInfo() (jsonStr string, err error) {
  3129. //
  3130. // handle := syscall.NewLazyDLL("SSCard.dll")
  3131. // add := handle.NewProc("ReadCardBas")
  3132. // str := make([]byte, 1024)
  3133. // str1 := make([]byte, 1024)
  3134. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3135. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3136. //
  3137. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3138. //
  3139. // fmt.Println("> Add(4,5)的结果为:", ret)
  3140. // handle.Release()
  3141. //
  3142. // return "", nil
  3143. //
  3144. //}
  3145. //func GetQRBaseInfo() (jsonStr string, err error) {
  3146. // handle := syscall.LoadDLL("SSCard.dll")
  3147. // ReadCardBas := handle.FindProc("GetQRBase")
  3148. //
  3149. // str := make([]byte, 256)
  3150. // str1 := make([]byte, 256)
  3151. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3152. //
  3153. // fmt.Println(string(str))
  3154. // fmt.Println(r)
  3155. // return string(str), nil
  3156. //}
  3157. //func CardInit() int {
  3158. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3159. // add := DllTestDef.MustFindProc("Init")
  3160. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3161. // if err != nil {
  3162. // fmt.Println("SSCard的运算结果为:", ret)
  3163. // }
  3164. // result := int(ret)
  3165. // return result
  3166. //}
  3167. //func CardInit() int {
  3168. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3169. // if err != nil {
  3170. // fmt.Println("SSCard的运算结果为:", ret)
  3171. // }
  3172. // fmt.Println(err)
  3173. // result := int(ret)
  3174. // return result
  3175. //}
  3176. func IntPtr(n int) uintptr {
  3177. return uintptr(n)
  3178. }
  3179. func StrPtr(s string) uintptr {
  3180. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3181. }
  3182. type Result2001 struct {
  3183. Cainfo interface{} `json:"cainfo"`
  3184. ErrMsg string `json:"err_msg"`
  3185. InfRefmsgid string `json:"inf_refmsgid"`
  3186. Infcode int64 `json:"infcode"`
  3187. Output struct {
  3188. Trtinfo struct {
  3189. PsnNo string `json:"psn_no"`
  3190. TrtChkType string `json:"trt_chk_type"`
  3191. FundPayType string `json:"fund_pay_type"`
  3192. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3193. Begndate string `json:"begndate"`
  3194. Enddate string `json:"enddate"`
  3195. TrtChkRslt string `json:"trt_chk_rslt"`
  3196. } `json:"trtinfo"`
  3197. } `json:"output"`
  3198. RefmsgTime string `json:"refmsg_time"`
  3199. RespondTime string `json:"respond_time"`
  3200. Signtype interface{} `json:"signtype"`
  3201. WarnMsg interface{} `json:"warn_msg"`
  3202. }
  3203. type Result2001Org10265 struct {
  3204. Cainfo interface{} `json:"cainfo"`
  3205. ErrMsg string `json:"err_msg"`
  3206. InfRefmsgid string `json:"inf_refmsgid"`
  3207. Infcode string `json:"infcode"`
  3208. Output struct {
  3209. Trtinfo struct {
  3210. PsnNo string `json:"psn_no"`
  3211. TrtChkType string `json:"trt_chk_type"`
  3212. FundPayType string `json:"fund_pay_type"`
  3213. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3214. Begndate string `json:"begndate"`
  3215. Enddate string `json:"enddate"`
  3216. TrtChkRslt string `json:"trt_chk_rslt"`
  3217. } `json:"trtinfo"`
  3218. } `json:"output"`
  3219. RefmsgTime string `json:"refmsg_time"`
  3220. RespondTime string `json:"respond_time"`
  3221. Signtype interface{} `json:"signtype"`
  3222. WarnMsg interface{} `json:"warn_msg"`
  3223. }
  3224. type ResultTwo struct {
  3225. ErrMsg string `json:"err_msg"`
  3226. InfRefmsgid string `json:"inf_refmsgid"`
  3227. Infcode int64 `json:"infcode"`
  3228. Output struct {
  3229. Baseinfo struct {
  3230. Age float64 `json:"age"`
  3231. Brdy string `json:"brdy"`
  3232. Certno string `json:"certno"`
  3233. Gend string `json:"gend"`
  3234. Naty string `json:"naty"`
  3235. PsnCertType string `json:"psn_cert_type"`
  3236. PsnName string `json:"psn_name"`
  3237. PsnNo string `json:"psn_no"`
  3238. } `json:"baseinfo"`
  3239. Idetinfo []interface{} `json:"idetinfo"`
  3240. Iinfo []struct {
  3241. Balc float64 `json:"balc"`
  3242. CvlservFlag string `json:"cvlserv_flag"`
  3243. EmpName string `json:"emp_name"`
  3244. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3245. Insutype string `json:"insutype"`
  3246. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3247. PausInsuDate string `json:"paus_insu_date"`
  3248. PsnInsuDate string `json:"psn_insu_date"`
  3249. PsnInsuStas string `json:"psn_insu_stas"`
  3250. PsnType string `json:"psn_type"`
  3251. } `json:"insuinfo"`
  3252. } `json:"output"`
  3253. RefmsgTime string `json:"refmsg_time"`
  3254. RespondTime string `json:"respond_time"`
  3255. Signtype interface{} `json:"signtype"`
  3256. WarnInfo interface{} `json:"warn_info"`
  3257. }
  3258. type ResultTwo10265 struct {
  3259. ErrMsg string `json:"err_msg"`
  3260. InfRefmsgid string `json:"inf_refmsgid"`
  3261. Infcode string `json:"infcode"`
  3262. Output struct {
  3263. Baseinfo struct {
  3264. Age float64 `json:"age"`
  3265. Brdy string `json:"brdy"`
  3266. Certno string `json:"certno"`
  3267. Gend string `json:"gend"`
  3268. Naty string `json:"naty"`
  3269. PsnCertType string `json:"psn_cert_type"`
  3270. PsnName string `json:"psn_name"`
  3271. PsnNo string `json:"psn_no"`
  3272. } `json:"baseinfo"`
  3273. Idetinfo []interface{} `json:"idetinfo"`
  3274. Iinfo []struct {
  3275. Balc float64 `json:"balc"`
  3276. CvlservFlag string `json:"cvlserv_flag"`
  3277. EmpName string `json:"emp_name"`
  3278. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3279. Insutype string `json:"insutype"`
  3280. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3281. PausInsuDate string `json:"paus_insu_date"`
  3282. PsnInsuDate string `json:"psn_insu_date"`
  3283. PsnInsuStas string `json:"psn_insu_stas"`
  3284. PsnType string `json:"psn_type"`
  3285. } `json:"insuinfo"`
  3286. } `json:"output"`
  3287. RefmsgTime string `json:"refmsg_time"`
  3288. RespondTime string `json:"respond_time"`
  3289. Signtype interface{} `json:"signtype"`
  3290. WarnInfo interface{} `json:"warn_info"`
  3291. }
  3292. type ResultThree struct {
  3293. Cainfo interface{} `json:"cainfo"`
  3294. ErrMsg string `json:"err_msg"`
  3295. InfRefmsgid string `json:"inf_refmsgid"`
  3296. Infcode int64 `json:"infcode"`
  3297. Output struct {
  3298. Data struct {
  3299. IptOtpNo string `json:"ipt_otp_no"`
  3300. MdtrtID string `json:"mdtrt_id"`
  3301. PsnNo string `json:"psn_no"`
  3302. } `json:"data"`
  3303. } `json:"output"`
  3304. RefmsgTime string `json:"refmsg_time"`
  3305. RespondTime string `json:"respond_time"`
  3306. Signtype interface{} `json:"signtype"`
  3307. WarnMsg interface{} `json:"warn_msg"`
  3308. }
  3309. type ResultThree10265 struct {
  3310. Cainfo interface{} `json:"cainfo"`
  3311. ErrMsg string `json:"err_msg"`
  3312. InfRefmsgid string `json:"inf_refmsgid"`
  3313. Infcode string `json:"infcode"`
  3314. Output struct {
  3315. Data struct {
  3316. IptOtpNo string `json:"ipt_otp_no"`
  3317. MdtrtID string `json:"mdtrt_id"`
  3318. PsnNo string `json:"psn_no"`
  3319. } `json:"data"`
  3320. } `json:"output"`
  3321. RefmsgTime string `json:"refmsg_time"`
  3322. RespondTime string `json:"respond_time"`
  3323. Signtype interface{} `json:"signtype"`
  3324. WarnMsg interface{} `json:"warn_msg"`
  3325. }
  3326. type ResultFour struct {
  3327. Cainfo string `json:"cainfo"`
  3328. ErrMsg string `json:"err_msg"`
  3329. InfRefmsgid string `json:"inf_refmsgid"`
  3330. Infcode int64 `json:"infcode"`
  3331. Output struct {
  3332. Result []struct {
  3333. BasMednFlag string `json:"bas_medn_flag"`
  3334. ChldMedcFlag string `json:"chld_medc_flag"`
  3335. ChrgitmLv string `json:"chrgitm_lv"`
  3336. Cnt float64 `json:"cnt"`
  3337. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3338. DrtReimFlag string `json:"drt_reim_flag"`
  3339. FeedetlSn string `json:"feedetl_sn"`
  3340. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3341. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3342. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3343. ListSpItemFlag string `json:"list_sp_item_flag"`
  3344. LmtUsedFlag string `json:"lmt_used_flag"`
  3345. MedChrgitmType string `json:"med_chrgitm_type"`
  3346. Memo string `json:"memo"`
  3347. OverlmtAmt float64 `json:"overlmt_amt"`
  3348. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3349. Pric float64 `json:"pric"`
  3350. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3351. SelfpayProp float64 `json:"selfpay_prop"`
  3352. } `json:"result"`
  3353. } `json:"output"`
  3354. RefmsgTime string `json:"refmsg_time"`
  3355. RespondTime string `json:"respond_time"`
  3356. Signtype string `json:"signtype"`
  3357. WarnMsg string `json:"warn_msg"`
  3358. }
  3359. type ResultFour10265 struct {
  3360. Cainfo string `json:"cainfo"`
  3361. ErrMsg string `json:"err_msg"`
  3362. InfRefmsgid string `json:"inf_refmsgid"`
  3363. Infcode string `json:"infcode"`
  3364. Output struct {
  3365. Result []struct {
  3366. BasMednFlag string `json:"bas_medn_flag"`
  3367. ChldMedcFlag string `json:"chld_medc_flag"`
  3368. ChrgitmLv string `json:"chrgitm_lv"`
  3369. Cnt float64 `json:"cnt"`
  3370. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3371. DrtReimFlag string `json:"drt_reim_flag"`
  3372. FeedetlSn string `json:"feedetl_sn"`
  3373. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3374. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3375. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3376. ListSpItemFlag string `json:"list_sp_item_flag"`
  3377. LmtUsedFlag string `json:"lmt_used_flag"`
  3378. MedChrgitmType string `json:"med_chrgitm_type"`
  3379. Memo string `json:"memo"`
  3380. OverlmtAmt float64 `json:"overlmt_amt"`
  3381. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3382. Pric float64 `json:"pric"`
  3383. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3384. SelfpayProp float64 `json:"selfpay_prop"`
  3385. } `json:"result"`
  3386. } `json:"output"`
  3387. RefmsgTime string `json:"refmsg_time"`
  3388. RespondTime string `json:"respond_time"`
  3389. Signtype string `json:"signtype"`
  3390. WarnMsg string `json:"warn_msg"`
  3391. }
  3392. type ResultFive struct {
  3393. Balc float64 `json:"balc"`
  3394. CvlservFlag string `json:"cvlserv_flag"`
  3395. EmpName string `json:"emp_name"`
  3396. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3397. Insutype string `json:"insutype"`
  3398. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3399. PausInsuDate string `json:"paus_insu_date"`
  3400. PsnInsuDate string `json:"psn_insu_date"`
  3401. PsnInsuStas string `json:"psn_insu_stas"`
  3402. PsnType string `json:"psn_type"`
  3403. }
  3404. type ResultSix struct {
  3405. Cainfo interface{} `json:"cainfo"`
  3406. ErrMsg string `json:"err_msg"`
  3407. InfRefmsgid string `json:"inf_refmsgid"`
  3408. Infcode int64 `json:"infcode"`
  3409. Output struct {
  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 ResultSix10265 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. } `json:"output"`
  3423. RefmsgTime string `json:"refmsg_time"`
  3424. RespondTime string `json:"respond_time"`
  3425. Signtype interface{} `json:"signtype"`
  3426. WarnMsg interface{} `json:"warn_msg"`
  3427. }
  3428. type ResultSeven struct {
  3429. Cainfo string `json:"cainfo"`
  3430. ErrMsg string `json:"err_msg"`
  3431. InfRefmsgid string `json:"inf_refmsgid"`
  3432. Infcode int64 `json:"infcode"`
  3433. Output struct {
  3434. Setldetail []interface{} `json:"setldetail"`
  3435. Setlinfo struct {
  3436. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3437. AcctPay float64 `json:"acct_pay"`
  3438. ActPayDedc float64 `json:"act_pay_dedc"`
  3439. Age float64 `json:"age"`
  3440. Balc float64 `json:"balc"`
  3441. Brdy string `json:"brdy"`
  3442. Certno string `json:"certno"`
  3443. ClrOptins string `json:"clr_optins"`
  3444. ClrType string `json:"clr_type"`
  3445. ClrWay string `json:"clr_way"`
  3446. CvlservFlag string `json:"cvlserv_flag"`
  3447. CvlservPay float64 `json:"cvlserv_pay"`
  3448. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3449. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3450. Gend string `json:"gend"`
  3451. HifesPay float64 `json:"hifes_pay"`
  3452. HifmiPay float64 `json:"hifmi_pay"`
  3453. HifpPay float64 `json:"hifp_pay"`
  3454. HospPartAmt float64 `json:"hosp_part_amt"`
  3455. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3456. Insutype string `json:"insutype"`
  3457. MafPay float64 `json:"maf_pay"`
  3458. MdtrtCertType string `json:"mdtrt_cert_type"`
  3459. HifobPay float64 `json:"hifob_pay"`
  3460. MdtrtID string `json:"mdtrt_id"`
  3461. MedType string `json:"med_type"`
  3462. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3463. MedinsSetlID string `json:"medins_setl_id"`
  3464. Naty string `json:"naty"`
  3465. OthPay float64 `json:"oth_pay"`
  3466. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3467. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3468. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3469. PsnCashPay float64 `json:"psn_cash_pay"`
  3470. PsnCertType string `json:"psn_cert_type"`
  3471. PsnName string `json:"psn_name"`
  3472. PsnNo string `json:"psn_no"`
  3473. PsnPartAmt float64 `json:"psn_part_amt"`
  3474. PsnType string `json:"psn_type"`
  3475. SetlID string `json:"setl_id"`
  3476. SetlTime string `json:"setl_time"`
  3477. } `json:"setlinfo"`
  3478. } `json:"output"`
  3479. RefmsgTime string `json:"refmsg_time"`
  3480. RespondTime string `json:"respond_time"`
  3481. Signtype interface{} `json:"signtype"`
  3482. WarnMsg interface{} `json:"warn_msg"`
  3483. }
  3484. type ResultSeven10265 struct {
  3485. Cainfo string `json:"cainfo"`
  3486. ErrMsg string `json:"err_msg"`
  3487. InfRefmsgid string `json:"inf_refmsgid"`
  3488. Infcode string `json:"infcode"`
  3489. Output struct {
  3490. Setldetail []interface{} `json:"setldetail"`
  3491. Setlinfo struct {
  3492. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3493. AcctPay float64 `json:"acct_pay"`
  3494. ActPayDedc float64 `json:"act_pay_dedc"`
  3495. Age float64 `json:"age"`
  3496. Balc float64 `json:"balc"`
  3497. Brdy string `json:"brdy"`
  3498. Certno string `json:"certno"`
  3499. ClrOptins string `json:"clr_optins"`
  3500. ClrType string `json:"clr_type"`
  3501. ClrWay string `json:"clr_way"`
  3502. CvlservFlag string `json:"cvlserv_flag"`
  3503. CvlservPay float64 `json:"cvlserv_pay"`
  3504. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3505. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3506. Gend string `json:"gend"`
  3507. HifesPay float64 `json:"hifes_pay"`
  3508. HifmiPay float64 `json:"hifmi_pay"`
  3509. HifpPay float64 `json:"hifp_pay"`
  3510. HospPartAmt float64 `json:"hosp_part_amt"`
  3511. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3512. Insutype string `json:"insutype"`
  3513. MafPay float64 `json:"maf_pay"`
  3514. MdtrtCertType string `json:"mdtrt_cert_type"`
  3515. HifobPay float64 `json:"hifob_pay"`
  3516. MdtrtID string `json:"mdtrt_id"`
  3517. MedType string `json:"med_type"`
  3518. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3519. MedinsSetlID string `json:"medins_setl_id"`
  3520. Naty string `json:"naty"`
  3521. OthPay float64 `json:"oth_pay"`
  3522. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3523. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3524. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3525. PsnCashPay float64 `json:"psn_cash_pay"`
  3526. PsnCertType string `json:"psn_cert_type"`
  3527. PsnName string `json:"psn_name"`
  3528. PsnNo string `json:"psn_no"`
  3529. PsnPartAmt float64 `json:"psn_part_amt"`
  3530. PsnType string `json:"psn_type"`
  3531. SetlID string `json:"setl_id"`
  3532. SetlTime string `json:"setl_time"`
  3533. } `json:"setlinfo"`
  3534. } `json:"output"`
  3535. RefmsgTime string `json:"refmsg_time"`
  3536. RespondTime string `json:"respond_time"`
  3537. Signtype interface{} `json:"signtype"`
  3538. WarnMsg interface{} `json:"warn_msg"`
  3539. }
  3540. type ResultEight struct {
  3541. Cainfo string `json:"cainfo"`
  3542. ErrMsg string `json:"err_msg"`
  3543. InfRefmsgid string `json:"inf_refmsgid"`
  3544. Infcode int64 `json:"infcode"`
  3545. Output struct {
  3546. Stmtinfo struct {
  3547. SetlOptins string `json:"setl_optins"`
  3548. StmtRslt string `json:"stmt_rslt"`
  3549. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3550. } `json:"stmtinfo"`
  3551. } `json:"output"`
  3552. RefmsgTime string `json:"refmsg_time"`
  3553. RespondTime string `json:"respond_time"`
  3554. Signtype interface{} `json:"signtype"`
  3555. WarnMsg interface{} `json:"warn_msg"`
  3556. }
  3557. type ResultEightFor10188 struct {
  3558. Cainfo string `json:"cainfo"`
  3559. ErrMsg string `json:"err_msg"`
  3560. InfRefmsgid string `json:"inf_refmsgid"`
  3561. Infcode string `json:"infcode"`
  3562. Output struct {
  3563. Stmtinfo struct {
  3564. SetlOptins string `json:"setl_optins"`
  3565. StmtRslt string `json:"stmt_rslt"`
  3566. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3567. } `json:"stmtinfo"`
  3568. } `json:"output"`
  3569. RefmsgTime string `json:"refmsg_time"`
  3570. RespondTime string `json:"respond_time"`
  3571. Signtype interface{} `json:"signtype"`
  3572. WarnMsg interface{} `json:"warn_msg"`
  3573. }
  3574. type ResultNine struct {
  3575. Cainfo string `json:"cainfo"`
  3576. ErrMsg string `json:"err_msg"`
  3577. InfRefmsgid string `json:"inf_refmsgid"`
  3578. Infcode int64 `json:"infcode"`
  3579. Output struct {
  3580. FileQuryNo string `json:"file_qury_no"`
  3581. } `json:"output"`
  3582. RefmsgTime string `json:"refmsg_time"`
  3583. RespondTime string `json:"respond_time"`
  3584. Signtype interface{} `json:"signtype"`
  3585. WarnMsg interface{} `json:"warn_msg"`
  3586. }
  3587. type ResultTen struct {
  3588. Cainfo string `json:"cainfo"`
  3589. ErrMsg string `json:"err_msg"`
  3590. InfRefmsgid string `json:"inf_refmsgid"`
  3591. Infcode int64 `json:"infcode"`
  3592. Output struct {
  3593. DldEndtime string `json:"dld_endtime"`
  3594. FileQuryNo string `json:"file_qury_no"`
  3595. Filename string `json:"filename"`
  3596. } `json:"output"`
  3597. RefmsgTime string `json:"refmsg_time"`
  3598. RespondTime string `json:"respond_time"`
  3599. Signtype interface{} `json:"signtype"`
  3600. WarnMsg interface{} `json:"warn_msg"`
  3601. }
  3602. //type Autogenerated struct {
  3603. // Output struct {
  3604. // Setlinfo struct {
  3605. // SetlTime string `json:"setl_time"`
  3606. // CvlservPay float64 `json:"cvlserv_pay"`
  3607. // Year string `json:"year"`
  3608. // MedType string `json:"med_type"`
  3609. // PsnPay float64 `json:"psn_pay"`
  3610. // OpterID string `json:"opter_id"`
  3611. // Begndate string `json:"begndate"`
  3612. // FlxempeFlag string `json:"flxempe_flag"`
  3613. // HifmiPay float64 `json:"hifmi_pay"`
  3614. // PsnNo string `json:"psn_no"`
  3615. // ActPayDedc float64 `json:"act_pay_dedc"`
  3616. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3617. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3618. // ClrWay string `json:"clr_way"`
  3619. // OthPay float64 `json:"oth_pay"`
  3620. // Gend string `json:"gend"`
  3621. // MdtrtID string `json:"mdtrt_id"`
  3622. // AcctPay float64 `json:"acct_pay"`
  3623. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3624. // Insutype string `json:"insutype"`
  3625. // Invono interface{} `json:"invono"`
  3626. // Enddate string `json:"enddate"`
  3627. // CashPayamt float64 `json:"cash_payamt"`
  3628. // PsnType string `json:"psn_type"`
  3629. // FixmedinsName string `json:"fixmedins_name"`
  3630. // HifpPay float64 `json:"hifp_pay"`
  3631. // NewFlag interface{} `json:"new_flag"`
  3632. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3633. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3634. // PayLoc string `json:"pay_loc"`
  3635. // ClrType string `json:"clr_type"`
  3636. // RefdSetlFlag string `json:"refd_setl_flag"`
  3637. // CvlservFlag string `json:"cvlserv_flag"`
  3638. // EmpName string `json:"emp_name"`
  3639. // Brdy string `json:"brdy"`
  3640. // Naty string `json:"naty"`
  3641. // Certno string `json:"certno"`
  3642. // DiseCode string `json:"dise_code"`
  3643. // FixmedinsCode string `json:"fixmedins_code"`
  3644. // DedcHospLv string `json:"dedc_hosp_lv"`
  3645. // OpterName string `json:"opter_name"`
  3646. // Balc float64 `json:"balc"`
  3647. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3648. // PsnCertType string `json:"psn_cert_type"`
  3649. // HifobPay float64 `json:"hifob_pay"`
  3650. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3651. // HifesPay float64 `json:"hifes_pay"`
  3652. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3653. // OptTime string `json:"opt_time"`
  3654. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3655. // SetlID string `json:"setl_id"`
  3656. // MafPay float64 `json:"maf_pay"`
  3657. // PsnName string `json:"psn_name"`
  3658. // InsuOptins interface{} `json:"insu_optins"`
  3659. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3660. // ClrOptins string `json:"clr_optins"`
  3661. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3662. // DiseName string `json:"dise_name"`
  3663. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3664. // Age float64 `json:"age"`
  3665. // DtrtCertType string `json:"dtrt_cert_type"`
  3666. // HospLv string `json:"hosp_lv"`
  3667. // } `json:"setlinfo"`
  3668. // Setldetail []struct {
  3669. // FundPayType string `json:"fund_pay_type"`
  3670. // FundPayamt float64 `json:"fund_payamt"`
  3671. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3672. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3673. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3674. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3675. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3676. // } `json:"setldetail"`
  3677. // } `json:"output"`
  3678. // Infcode int `json:"infcode"`
  3679. // WarnMsg interface{} `json:"warn_msg"`
  3680. // Cainfo interface{} `json:"cainfo"`
  3681. // ErrMsg interface{} `json:"err_msg"`
  3682. // RefmsgTime string `json:"refmsg_time"`
  3683. // Signtype interface{} `json:"signtype"`
  3684. // RespondTime string `json:"respond_time"`
  3685. // InfRefmsgid string `json:"inf_refmsgid"`
  3686. //}
  3687. type ResultEleven struct {
  3688. Cainfo string `json:"cainfo"`
  3689. ErrMsg string `json:"err_msg"`
  3690. InfRefmsgid string `json:"inf_refmsgid"`
  3691. Infcode int64 `json:"infcode"`
  3692. Output struct {
  3693. Setlinfo struct {
  3694. SetlTime string `json:"setl_time"`
  3695. CvlservPay float64 `json:"cvlserv_pay"`
  3696. Year string `json:"year"`
  3697. MedType string `json:"med_type"`
  3698. PsnPay float64 `json:"psn_pay"`
  3699. OpterID string `json:"opter_id"`
  3700. Begndate string `json:"begndate"`
  3701. FlxempeFlag string `json:"flxempe_flag"`
  3702. HifmiPay float64 `json:"hifmi_pay"`
  3703. PsnNo string `json:"psn_no"`
  3704. ActPayDedc float64 `json:"act_pay_dedc"`
  3705. MedinsSetlID interface{} `json:"medins_setl_id"`
  3706. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3707. ClrWay string `json:"clr_way"`
  3708. OthPay float64 `json:"oth_pay"`
  3709. Gend string `json:"gend"`
  3710. MdtrtID string `json:"mdtrt_id"`
  3711. AcctPay float64 `json:"acct_pay"`
  3712. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3713. Insutype string `json:"insutype"`
  3714. Invono interface{} `json:"invono"`
  3715. Enddate string `json:"enddate"`
  3716. CashPayamt float64 `json:"cash_payamt"`
  3717. PsnType string `json:"psn_type"`
  3718. FixmedinsName string `json:"fixmedins_name"`
  3719. HifpPay float64 `json:"hifp_pay"`
  3720. NewFlag interface{} `json:"new_flag"`
  3721. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3722. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3723. PayLoc string `json:"pay_loc"`
  3724. ClrType string `json:"clr_type"`
  3725. RefdSetlFlag string `json:"refd_setl_flag"`
  3726. CvlservFlag string `json:"cvlserv_flag"`
  3727. EmpName string `json:"emp_name"`
  3728. Brdy string `json:"brdy"`
  3729. Naty string `json:"naty"`
  3730. Certno string `json:"certno"`
  3731. DiseCode string `json:"dise_code"`
  3732. FixmedinsCode string `json:"fixmedins_code"`
  3733. DedcHospLv string `json:"dedc_hosp_lv"`
  3734. OpterName string `json:"opter_name"`
  3735. Balc float64 `json:"balc"`
  3736. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3737. PsnCertType string `json:"psn_cert_type"`
  3738. HifobPay float64 `json:"hifob_pay"`
  3739. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3740. HifesPay float64 `json:"hifes_pay"`
  3741. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3742. OptTime string `json:"opt_time"`
  3743. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3744. SetlID string `json:"setl_id"`
  3745. MafPay float64 `json:"maf_pay"`
  3746. PsnName string `json:"psn_name"`
  3747. InsuOptins interface{} `json:"insu_optins"`
  3748. PrefFundPay interface{} `json:"pref_fund_pay"`
  3749. ClrOptins string `json:"clr_optins"`
  3750. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3751. DiseName string `json:"dise_name"`
  3752. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3753. Age float64 `json:"age"`
  3754. DtrtCertType string `json:"dtrt_cert_type"`
  3755. HospLv string `json:"hosp_lv"`
  3756. } `json:"setlinfo"`
  3757. } `json:"output"`
  3758. RefmsgTime string `json:"refmsg_time"`
  3759. RespondTime string `json:"respond_time"`
  3760. Signtype interface{} `json:"signtype"`
  3761. WarnMsg interface{} `json:"warn_msg"`
  3762. }
  3763. type ResultEleven10265 struct {
  3764. Cainfo string `json:"cainfo"`
  3765. ErrMsg string `json:"err_msg"`
  3766. InfRefmsgid string `json:"inf_refmsgid"`
  3767. Infcode string `json:"infcode"`
  3768. Output struct {
  3769. Setlinfo struct {
  3770. SetlTime string `json:"setl_time"`
  3771. CvlservPay float64 `json:"cvlserv_pay"`
  3772. Year string `json:"year"`
  3773. MedType string `json:"med_type"`
  3774. PsnPay float64 `json:"psn_pay"`
  3775. OpterID string `json:"opter_id"`
  3776. Begndate string `json:"begndate"`
  3777. FlxempeFlag string `json:"flxempe_flag"`
  3778. HifmiPay float64 `json:"hifmi_pay"`
  3779. PsnNo string `json:"psn_no"`
  3780. ActPayDedc float64 `json:"act_pay_dedc"`
  3781. MedinsSetlID interface{} `json:"medins_setl_id"`
  3782. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3783. ClrWay string `json:"clr_way"`
  3784. OthPay float64 `json:"oth_pay"`
  3785. Gend string `json:"gend"`
  3786. MdtrtID string `json:"mdtrt_id"`
  3787. AcctPay float64 `json:"acct_pay"`
  3788. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3789. Insutype string `json:"insutype"`
  3790. Invono interface{} `json:"invono"`
  3791. Enddate string `json:"enddate"`
  3792. CashPayamt float64 `json:"cash_payamt"`
  3793. PsnType string `json:"psn_type"`
  3794. FixmedinsName string `json:"fixmedins_name"`
  3795. HifpPay float64 `json:"hifp_pay"`
  3796. NewFlag interface{} `json:"new_flag"`
  3797. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3798. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3799. PayLoc string `json:"pay_loc"`
  3800. ClrType string `json:"clr_type"`
  3801. RefdSetlFlag string `json:"refd_setl_flag"`
  3802. CvlservFlag string `json:"cvlserv_flag"`
  3803. EmpName string `json:"emp_name"`
  3804. Brdy string `json:"brdy"`
  3805. Naty string `json:"naty"`
  3806. Certno string `json:"certno"`
  3807. DiseCode string `json:"dise_code"`
  3808. FixmedinsCode string `json:"fixmedins_code"`
  3809. DedcHospLv string `json:"dedc_hosp_lv"`
  3810. OpterName string `json:"opter_name"`
  3811. Balc float64 `json:"balc"`
  3812. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3813. PsnCertType string `json:"psn_cert_type"`
  3814. HifobPay float64 `json:"hifob_pay"`
  3815. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3816. HifesPay float64 `json:"hifes_pay"`
  3817. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3818. OptTime string `json:"opt_time"`
  3819. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3820. SetlID string `json:"setl_id"`
  3821. MafPay float64 `json:"maf_pay"`
  3822. PsnName string `json:"psn_name"`
  3823. InsuOptins interface{} `json:"insu_optins"`
  3824. PrefFundPay interface{} `json:"pref_fund_pay"`
  3825. ClrOptins string `json:"clr_optins"`
  3826. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3827. DiseName string `json:"dise_name"`
  3828. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3829. Age float64 `json:"age"`
  3830. DtrtCertType string `json:"dtrt_cert_type"`
  3831. HospLv string `json:"hosp_lv"`
  3832. } `json:"setlinfo"`
  3833. } `json:"output"`
  3834. RefmsgTime string `json:"refmsg_time"`
  3835. RespondTime string `json:"respond_time"`
  3836. Signtype interface{} `json:"signtype"`
  3837. WarnMsg interface{} `json:"warn_msg"`
  3838. }
  3839. type ResultTwelve struct {
  3840. Cainfo string `json:"cainfo"`
  3841. ErrMsg string `json:"err_msg"`
  3842. InfRefmsgid string `json:"inf_refmsgid"`
  3843. Infcode int64 `json:"infcode"`
  3844. Output struct {
  3845. MdtrtId string `json:"mdtrt_id"`
  3846. ChrgBchno string `json:"chrg_bchno"`
  3847. PsnNo string `json:"psn_no"`
  3848. } `json:"output"`
  3849. RefmsgTime string `json:"refmsg_time"`
  3850. RespondTime string `json:"respond_time"`
  3851. Signtype interface{} `json:"signtype"`
  3852. WarnMsg interface{} `json:"warn_msg"`
  3853. }
  3854. type ResultThirteen struct {
  3855. ErrMsg string `json:"err_msg"`
  3856. InfRefmsgid string `json:"inf_refmsgid"`
  3857. Infcode int64 `json:"infcode"`
  3858. Output struct {
  3859. Result struct {
  3860. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3861. } `json:"result"`
  3862. } `json:"output"`
  3863. RefmsgTime string `json:"refmsg_time"`
  3864. RespondTime string `json:"respond_time"`
  3865. Signtype interface{} `json:"signtype"`
  3866. WarnInfo interface{} `json:"warn_info"`
  3867. }
  3868. type ResultThirteen10265 struct {
  3869. ErrMsg string `json:"err_msg"`
  3870. InfRefmsgid string `json:"inf_refmsgid"`
  3871. Infcode string `json:"infcode"`
  3872. Output struct {
  3873. Result struct {
  3874. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3875. } `json:"result"`
  3876. } `json:"output"`
  3877. RefmsgTime string `json:"refmsg_time"`
  3878. RespondTime string `json:"respond_time"`
  3879. Signtype interface{} `json:"signtype"`
  3880. WarnInfo interface{} `json:"warn_info"`
  3881. }
  3882. type ResultFourteen struct {
  3883. ErrMsg string `json:"err_msg"`
  3884. InfRefmsgid string `json:"inf_refmsgid"`
  3885. Infcode int64 `json:"infcode"`
  3886. Output struct {
  3887. } `json:"output"`
  3888. RefmsgTime string `json:"refmsg_time"`
  3889. RespondTime string `json:"respond_time"`
  3890. Signtype interface{} `json:"signtype"`
  3891. WarnInfo interface{} `json:"warn_info"`
  3892. }
  3893. type ResultFourteen10265 struct {
  3894. ErrMsg string `json:"err_msg"`
  3895. InfRefmsgid string `json:"inf_refmsgid"`
  3896. Infcode string `json:"infcode"`
  3897. Output struct {
  3898. } `json:"output"`
  3899. RefmsgTime string `json:"refmsg_time"`
  3900. RespondTime string `json:"respond_time"`
  3901. Signtype interface{} `json:"signtype"`
  3902. WarnInfo interface{} `json:"warn_info"`
  3903. }
  3904. type ResultSixteen struct {
  3905. Cainfo string `json:"cainfo"`
  3906. ErrMsg string `json:"err_msg"`
  3907. InfRefmsgid string `json:"inf_refmsgid"`
  3908. Infcode int64 `json:"infcode"`
  3909. Output struct {
  3910. Setldetail []interface{} `json:"setldetail"`
  3911. Setlinfo struct {
  3912. MdtrtID string `json:"mdtrt_id"`
  3913. SetlID string `json:"setl_id"`
  3914. ClrOptins string `json:"clr_optins"`
  3915. SetlTime string `json:"setl_time"`
  3916. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3917. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3918. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3919. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3920. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3921. ActPayDedc float64 `json:"act_pay_dedc"`
  3922. HifpPay float64 `json:"hifp_pay"`
  3923. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3924. Lfpay float64 `json:"selfpay"`
  3925. CvlservPay float64 `json:"cvlserv_pay"`
  3926. HifesPay float64 `json:"hifes_pay"`
  3927. HifmiPay float64 `json:"hifmi_pay"`
  3928. HifobPay float64 `json:"hifob_pay"`
  3929. MafPay float64 `json:"maf_pay"`
  3930. OthPay float64 `json:"oth_pay"`
  3931. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3932. PsnPartAmt float64 `json:"psn_part_amt"`
  3933. AcctPay float64 `json:"acct_pay"`
  3934. Balc float64 `json:"balc"`
  3935. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3936. HospPartAmt float64 `json:"hosp_part_amt"`
  3937. MedinsSetlID string `json:"medins_setl_id"`
  3938. PdnCashPay string `json:"pdn_cash_pay"`
  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 ResultSixteen10265 struct {
  3947. Cainfo string `json:"cainfo"`
  3948. ErrMsg string `json:"err_msg"`
  3949. InfRefmsgid string `json:"inf_refmsgid"`
  3950. Infcode string `json:"infcode"`
  3951. Output struct {
  3952. Setldetail []interface{} `json:"setldetail"`
  3953. Setlinfo struct {
  3954. MdtrtID string `json:"mdtrt_id"`
  3955. SetlID string `json:"setl_id"`
  3956. ClrOptins string `json:"clr_optins"`
  3957. SetlTime string `json:"setl_time"`
  3958. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3959. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3960. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3961. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3962. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3963. ActPayDedc float64 `json:"act_pay_dedc"`
  3964. HifpPay float64 `json:"hifp_pay"`
  3965. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3966. Lfpay float64 `json:"selfpay"`
  3967. CvlservPay float64 `json:"cvlserv_pay"`
  3968. HifesPay float64 `json:"hifes_pay"`
  3969. HifmiPay float64 `json:"hifmi_pay"`
  3970. HifobPay float64 `json:"hifob_pay"`
  3971. MafPay float64 `json:"maf_pay"`
  3972. OthPay float64 `json:"oth_pay"`
  3973. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3974. PsnPartAmt float64 `json:"psn_part_amt"`
  3975. AcctPay float64 `json:"acct_pay"`
  3976. Balc float64 `json:"balc"`
  3977. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3978. HospPartAmt float64 `json:"hosp_part_amt"`
  3979. MedinsSetlID string `json:"medins_setl_id"`
  3980. PdnCashPay string `json:"pdn_cash_pay"`
  3981. } `json:"setlinfo"`
  3982. } `json:"output"`
  3983. RefmsgTime string `json:"refmsg_time"`
  3984. RespondTime string `json:"respond_time"`
  3985. Signtype interface{} `json:"signtype"`
  3986. WarnMsg interface{} `json:"warn_msg"`
  3987. }
  3988. type ResultSeventeen struct {
  3989. ErrMsg string `json:"err_msg"`
  3990. InfRefmsgid string `json:"inf_refmsgid"`
  3991. Infcode int64 `json:"infcode"`
  3992. Output struct {
  3993. SetlListId string `json:"setl_list_id"`
  3994. } `json:"output"`
  3995. RefmsgTime string `json:"refmsg_time"`
  3996. RespondTime string `json:"respond_time"`
  3997. Signtype string `json:"signtype"`
  3998. WarnInfo string `json:"warn_info"`
  3999. }
  4000. type Result90991 struct {
  4001. ErrMsg string `json:"err_msg"`
  4002. InfRefmsgid string `json:"inf_refmsgid"`
  4003. Infcode int64 `json:"infcode"`
  4004. Output struct {
  4005. Result struct {
  4006. PsnNo string `json:"psn_no"`
  4007. CardStat string `json:"card_stat"`
  4008. Certno string `json:"certno"`
  4009. PsnName string `json:"psn_name"`
  4010. CheckStat string `json:"check_stat"`
  4011. SscnoCheckStat string `json:"sscno_check_stat"`
  4012. } `json:"result"`
  4013. } `json:"output"`
  4014. RefmsgTime string `json:"refmsg_time"`
  4015. RespondTime string `json:"respond_time"`
  4016. Signtype interface{} `json:"signtype"`
  4017. WarnInfo interface{} `json:"warn_info"`
  4018. }
  4019. type Result90100 struct {
  4020. ErrMsg string `json:"err_msg"`
  4021. InfRefmsgid string `json:"inf_refmsgid"`
  4022. Infcode int64 `json:"infcode"`
  4023. Output struct {
  4024. PoolareaNo string `json:"poolarea_no"`
  4025. PoolareaNoName string `json:"poolarea_no_name"`
  4026. Insutype string `json:"insutype"`
  4027. InsutypeName string `json:"insutype_name"`
  4028. ClctType string `json:"clct_type"`
  4029. ClctTypeName string `json:"clct_type_name"`
  4030. ClctFlag string `json:"clct_flag"`
  4031. ClctFlagName string `json:"clct_flag_name"`
  4032. AccrymBegn string `json:"accrym_begn"`
  4033. AccrymEnd string `json:"accrym_end"`
  4034. ClctTime string `json:"clct_time"`
  4035. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4036. } `json:"output"`
  4037. RefmsgTime string `json:"refmsg_time"`
  4038. RespondTime string `json:"respond_time"`
  4039. Signtype interface{} `json:"signtype"`
  4040. WarnInfo interface{} `json:"warn_info"`
  4041. }
  4042. type Custom struct {
  4043. DetItemFeeSumamt string
  4044. Cut string
  4045. FeedetlSn string
  4046. Price string
  4047. MedListCodg string
  4048. Type int64
  4049. AdviceId int64
  4050. ProjectId int64
  4051. ItemId int64
  4052. }
  4053. type Result5301 struct {
  4054. ErrMsg string `json:"err_msg"`
  4055. InfRefmsgid string `json:"inf_refmsgid"`
  4056. Infcode int64 `json:"infcode"`
  4057. Output struct {
  4058. Result []struct {
  4059. OpspDiseCode string `json:"opsp_dise_code"`
  4060. OpspDiseName string `json:"opsp_dise_name"`
  4061. Begndate string `json:"begndate"`
  4062. Enddate string `json:"enddate"`
  4063. } `json:"feedetail"`
  4064. } `json:"output"`
  4065. RefmsgTime string `json:"refmsg_time"`
  4066. RespondTime string `json:"respond_time"`
  4067. Signtype interface{} `json:"signtype"`
  4068. WarnInfo interface{} `json:"warn_info"`
  4069. }
  4070. type Result5301For10265 struct {
  4071. ErrMsg string `json:"err_msg"`
  4072. InfRefmsgid string `json:"inf_refmsgid"`
  4073. Infcode string `json:"infcode"`
  4074. Output struct {
  4075. Result []struct {
  4076. OpspDiseCode string `json:"opsp_dise_code"`
  4077. OpspDiseName string `json:"opsp_dise_name"`
  4078. Begndate string `json:"begndate"`
  4079. Enddate string `json:"enddate"`
  4080. } `json:"feedetail"`
  4081. } `json:"output"`
  4082. RefmsgTime string `json:"refmsg_time"`
  4083. RespondTime string `json:"respond_time"`
  4084. Signtype interface{} `json:"signtype"`
  4085. WarnInfo interface{} `json:"warn_info"`
  4086. }
  4087. //获取个人信息----挂号-----上传就诊信息
  4088. func (c *HisApiController) GetRegisterInfo() {
  4089. id, _ := c.GetInt64("id")
  4090. record_time := c.GetString("record_time")
  4091. settlementValue, _ := c.GetInt64("settlement_value")
  4092. medical_insurance_card := c.GetString("medical_insurance_card")
  4093. name := c.GetString("name")
  4094. id_card_type, _ := c.GetInt64("id_card_type")
  4095. certificates, _ := c.GetInt64("certificates")
  4096. medical_care, _ := c.GetInt64("medical_care")
  4097. birthday := c.GetString("birthday")
  4098. id_card := c.GetString("id_card")
  4099. register_type, _ := c.GetInt64("register")
  4100. doctor, _ := c.GetInt64("doctor")
  4101. department, _ := c.GetInt64("department")
  4102. gender, _ := c.GetInt64("sex")
  4103. registration_fee, _ := c.GetFloat("registration_fee")
  4104. medical_expenses, _ := c.GetFloat("medical_expenses")
  4105. social_type, _ := c.GetInt64("social_type")
  4106. med_type := c.GetString("social_type")
  4107. admin_user_id, _ := c.GetInt64("admin_user_id")
  4108. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4109. timeLayout := "2006-01-02"
  4110. loc, _ := time.LoadLocation("Local")
  4111. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4112. birthUnix := birthdays.Unix()
  4113. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4114. if err != nil {
  4115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4116. return
  4117. }
  4118. recordDateTime := theTime.Unix()
  4119. adminInfo := c.GetAdminUserInfo()
  4120. var patient service.Patients
  4121. if id == 0 {
  4122. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4123. } else {
  4124. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4125. }
  4126. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4127. if patientPrescription.ID == 0 {
  4128. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4129. }
  4130. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4131. if patient.ID == 0 {
  4132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4133. return
  4134. }
  4135. if len(patient.IdCardNo) == 0 {
  4136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4137. return
  4138. }
  4139. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4140. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4141. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4142. //就诊结算未完成,不能进行二次挂号
  4143. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4144. if len(his) >= 1 {
  4145. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4146. if len(his) >= 1 && order.ID == 0 {
  4147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4148. return
  4149. }
  4150. }
  4151. //var register_log string
  4152. if config.IsOpen == 1 {
  4153. var res ResultTwo
  4154. var res10265 ResultTwo10265
  4155. var PsnNo string
  4156. var PsnCertType string
  4157. var Certno string
  4158. var PsnName string
  4159. var Gend string
  4160. var Naty string
  4161. var Brdy string
  4162. var Age float64
  4163. var infoStr string
  4164. var idetinfoStr string
  4165. var infocode int64
  4166. var verify_number string
  4167. fmt.Println(verify_number)
  4168. if miConfig.MdtrtareaAdmvs == "421300" {
  4169. psn_info, _ := service.GetPsnByPatientId(id)
  4170. PsnNo = psn_info.PsnNo
  4171. PsnCertType = psn_info.PsnCertType
  4172. Certno = psn_info.Certno
  4173. PsnName = psn_info.PsnName
  4174. Gend = psn_info.Gend
  4175. Naty = psn_info.Naty
  4176. Brdy = psn_info.Brdy
  4177. Age = psn_info.Age
  4178. infoStr = psn_info.Insuinfo
  4179. idetinfoStr = psn_info.Idetinfo
  4180. infocode = 0
  4181. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4182. psn_info, _ := service.GetPsnByPatientId(id)
  4183. PsnNo = psn_info.PsnNo
  4184. PsnCertType = psn_info.PsnCertType
  4185. Certno = psn_info.Certno
  4186. PsnName = psn_info.PsnName
  4187. Gend = psn_info.Gend
  4188. Naty = psn_info.Naty
  4189. Brdy = psn_info.Brdy
  4190. Age = psn_info.Age
  4191. infoStr = psn_info.Insuinfo
  4192. idetinfoStr = psn_info.Idetinfo
  4193. infocode = 0
  4194. verify_number = psn_info.VerifyNumber
  4195. } else {
  4196. var result string
  4197. var requestLog string
  4198. if miConfig.UserOrgId == 10138 {
  4199. 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)
  4200. } else {
  4201. 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)
  4202. }
  4203. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4204. if miConfig.Code == "H15049901371" {
  4205. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4206. utils.ErrorLog("解析失败:%v", err)
  4207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4208. return
  4209. }
  4210. res.ErrMsg = res10265.ErrMsg
  4211. res.Output = res10265.Output
  4212. res.InfRefmsgid = res10265.InfRefmsgid
  4213. } else {
  4214. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4215. utils.ErrorLog("解析失败:%v", err)
  4216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4217. return
  4218. }
  4219. }
  4220. PsnNo = res.Output.Baseinfo.PsnNo
  4221. PsnCertType = res.Output.Baseinfo.PsnCertType
  4222. Certno = res.Output.Baseinfo.Certno
  4223. PsnName = res.Output.Baseinfo.PsnName
  4224. Gend = res.Output.Baseinfo.Gend
  4225. Naty = res.Output.Baseinfo.Naty
  4226. Brdy = res.Output.Baseinfo.Brdy
  4227. Age = res.Output.Baseinfo.Age
  4228. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4229. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4230. infoStr = string(Iinfos)
  4231. idetinfoStr = string(Idetinfos)
  4232. if miConfig.Code == "H15049901371" {
  4233. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4234. } else {
  4235. infocode = res.Infcode
  4236. }
  4237. }
  4238. if infocode == 0 {
  4239. his := models.VMHisPatient{
  4240. Name: name,
  4241. Gender: gender,
  4242. Birthday: birthUnix,
  4243. MedicalTreatmentType: medical_care,
  4244. IdType: certificates,
  4245. IdCardNo: id_card,
  4246. BalanceAccountsType: settlementValue,
  4247. SocialType: social_type,
  4248. MedicalInsuranceNumber: medical_insurance_card,
  4249. RegisterType: register_type,
  4250. RegisterCost: registration_fee,
  4251. TreatmentCost: medical_expenses,
  4252. Status: 1,
  4253. Ctime: time.Now().Unix(),
  4254. Mtime: time.Now().Unix(),
  4255. PsnNo: PsnNo,
  4256. PsnCertType: PsnCertType,
  4257. Certno: Certno,
  4258. PsnName: PsnName,
  4259. Gend: Gend,
  4260. Naty: Naty,
  4261. Brdy: Brdy,
  4262. Age: Age,
  4263. Iinfo: infoStr,
  4264. Idetinfo: idetinfoStr,
  4265. PatientId: patient.ID,
  4266. RecordDate: theTime.Unix(),
  4267. UserOrgId: adminInfo.CurrentOrgId,
  4268. AdminUserId: admin_user_id,
  4269. IsReturn: 1,
  4270. IdCardType: id_card_type,
  4271. Doctor: doctor,
  4272. Departments: department,
  4273. }
  4274. timestamp := time.Now().Unix()
  4275. tempTime := time.Unix(timestamp, 0)
  4276. timeFormat := tempTime.Format("20060102150405")
  4277. chrgBchno := rand.Intn(100000) + 10000
  4278. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4279. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4280. department, _ := service.GetDepartMentDetail(department)
  4281. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4282. IdCardNo := ""
  4283. if id_card_type == 1 {
  4284. // IdCardNo = medical_insurance_card
  4285. IdCardNo = patient.IdCardNo
  4286. } else {
  4287. IdCardNo = patient.IdCardNo
  4288. }
  4289. var rf []*ResultFive
  4290. json.Unmarshal([]byte(his.Iinfo), &rf)
  4291. var insutypes []*ResultFive
  4292. var insutype string
  4293. var insuplc_admdvs_temp string
  4294. var is390 int = 0
  4295. var is310 int = 0
  4296. for _, item := range rf {
  4297. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4298. insutypes = append(insutypes, item)
  4299. }
  4300. }
  4301. if len(insutypes) == 1 {
  4302. insutype = insutypes[0].Insutype
  4303. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4304. } else {
  4305. for _, i := range insutypes {
  4306. if i.Insutype == "390" {
  4307. is390 = 1
  4308. }
  4309. if i.Insutype == "310" {
  4310. is310 = 1
  4311. }
  4312. }
  4313. }
  4314. if is390 == 1 {
  4315. insutype = "390"
  4316. }
  4317. if is310 == 1 {
  4318. insutype = "310"
  4319. }
  4320. if len(insutypes) == 0 {
  4321. insutype = "310"
  4322. }
  4323. if len(insutypes) == 2 {
  4324. insutype = med_type
  4325. }
  4326. if len(med_type) > 0 {
  4327. insutype = med_type
  4328. }
  4329. //for _, item := range rf {
  4330. // if item.Insutype == insutype {
  4331. // insuplc_admdvs = item.InsuplcAdmdvs
  4332. // }
  4333. //}
  4334. var infocode int64
  4335. var resThree ResultThree
  4336. var resThree10265 ResultThree10265
  4337. if len(insuplc_admdvs) == 0 {
  4338. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4339. } else {
  4340. insuplc_admdvs_temp = insuplc_admdvs
  4341. }
  4342. if miConfig.MdtrtareaAdmvs == "421300" {
  4343. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4344. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4345. "&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
  4346. resp, requestErr := http.Get(api)
  4347. if requestErr != nil {
  4348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4349. return
  4350. }
  4351. body, ioErr := ioutil.ReadAll(resp.Body)
  4352. if ioErr != nil {
  4353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4355. return
  4356. }
  4357. var respJSON map[string]interface{}
  4358. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4361. return
  4362. }
  4363. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4364. result, _ := json.Marshal(respJSON)
  4365. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4366. utils.ErrorLog("解析失败:%v", err)
  4367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4368. return
  4369. }
  4370. infocode = resThree.Infcode
  4371. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4372. psn_info, _ := service.GetPsnByPatientId(id)
  4373. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4374. var cert_no string
  4375. if id_card_type == 3 {
  4376. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4377. cert_no = IdCardNo
  4378. } else {
  4379. bas := strings.Split(psn_info.CardInfo, "|")
  4380. cert_no = bas[2]
  4381. }
  4382. var api string
  4383. if miConfig.MdtrtareaAdmvs == "320921" {
  4384. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4385. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4386. "&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
  4387. } else {
  4388. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4389. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4390. "&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
  4391. }
  4392. resp, requestErr := http.Get(api)
  4393. if requestErr != nil {
  4394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4395. return
  4396. }
  4397. body, ioErr := ioutil.ReadAll(resp.Body)
  4398. if ioErr != nil {
  4399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4401. return
  4402. }
  4403. var respJSON map[string]interface{}
  4404. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4407. return
  4408. }
  4409. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4410. result, _ := json.Marshal(respJSON)
  4411. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4412. utils.ErrorLog("解析失败:%v", err)
  4413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4414. return
  4415. }
  4416. resThree.ErrMsg = resThree10265.ErrMsg
  4417. resThree.Output = resThree10265.Output
  4418. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4419. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4420. } else {
  4421. 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)
  4422. saveLog(result, requestLog, "2201A", "挂号")
  4423. if miConfig.Code == "H15049901371" {
  4424. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4425. utils.ErrorLog("解析失败:%v", err)
  4426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4427. return
  4428. }
  4429. resThree.ErrMsg = resThree10265.ErrMsg
  4430. resThree.Output = resThree10265.Output
  4431. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4432. } else {
  4433. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4434. utils.ErrorLog("解析失败:%v", err)
  4435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4436. return
  4437. }
  4438. }
  4439. if miConfig.Code == "H15049901371" {
  4440. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4441. } else {
  4442. infocode = resThree.Infcode
  4443. }
  4444. }
  4445. if infocode != 0 {
  4446. adminUser := c.GetAdminUserInfo()
  4447. errlog := &models.HisOrderError{
  4448. UserOrgId: adminUser.CurrentOrgId,
  4449. Ctime: time.Now().Unix(),
  4450. Mtime: time.Now().Unix(),
  4451. ErrMsg: resThree.ErrMsg,
  4452. Status: 1,
  4453. PatientId: id,
  4454. RecordTime: recordDateTime,
  4455. Stage: 2,
  4456. }
  4457. service.CreateErrMsgLog(errlog)
  4458. c.ServeSuccessJSON(map[string]interface{}{
  4459. "failed_code": -10,
  4460. "msg": resThree.ErrMsg,
  4461. })
  4462. return
  4463. }
  4464. his.Number = resThree.Output.Data.MdtrtID
  4465. his.PsnNo = resThree.Output.Data.PsnNo
  4466. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4467. his.IdCardNo = patient.IdCardNo
  4468. his.PhoneNumber = patient.Phone
  4469. his.UserOrgId = adminInfo.CurrentOrgId
  4470. his.Insutype = insutype
  4471. his.Ctime = time.Now().Unix()
  4472. his.Mtime = time.Now().Unix()
  4473. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4474. his.Status = 1
  4475. service.UpdateHisPatientStatus(&his)
  4476. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4477. c.ServeSuccessJSON(map[string]interface{}{
  4478. "his_info": his,
  4479. })
  4480. } else {
  4481. adminUser := c.GetAdminUserInfo()
  4482. errlog := &models.HisOrderError{
  4483. UserOrgId: adminUser.CurrentOrgId,
  4484. Ctime: time.Now().Unix(),
  4485. Mtime: time.Now().Unix(),
  4486. ErrMsg: res.ErrMsg,
  4487. Status: 1,
  4488. PatientId: id,
  4489. RecordTime: recordDateTime,
  4490. Stage: 1,
  4491. }
  4492. service.CreateErrMsgLog(errlog)
  4493. c.ServeSuccessJSON(map[string]interface{}{
  4494. "failed_code": -10,
  4495. "msg": res.ErrMsg,
  4496. })
  4497. return
  4498. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4499. }
  4500. }
  4501. }
  4502. //上传明细----预结算----确认订单
  4503. func (c *HisApiController) GetUploadInfo() {
  4504. id, _ := c.GetInt64("id")
  4505. record_time := c.GetString("record_time")
  4506. his_patient_id, _ := c.GetInt64("his_patient_id")
  4507. order_id, _ := c.GetInt64("order_id")
  4508. pay_way, _ := c.GetInt64("pay_way")
  4509. pay_price, _ := c.GetFloat("pay_price")
  4510. pay_card_no := c.GetString("pay_card_no")
  4511. discount_price, _ := c.GetFloat("discount_price")
  4512. preferential_price, _ := c.GetFloat("preferential_price")
  4513. reality_price, _ := c.GetFloat("reality_price")
  4514. found_price, _ := c.GetFloat("found_price")
  4515. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4516. private_price, _ := c.GetFloat("private_price")
  4517. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4518. admin_user_id, _ := c.GetInt64("admin_user_id")
  4519. fapiao_code := c.GetString("fapiao_code")
  4520. fapiao_number := c.GetString("fapiao_number")
  4521. diagnosis_id := c.GetString("diagnosis")
  4522. sick_type, _ := c.GetInt64("sick_type")
  4523. reg_type, _ := c.GetInt64("p_type")
  4524. begin_time := c.GetString("begin_time")
  4525. id_str := c.GetString("ids")
  4526. ids_arr := strings.Split(id_str, ",")
  4527. timeLayout := "2006-01-02"
  4528. loc, _ := time.LoadLocation("Local")
  4529. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4530. if err != nil {
  4531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4532. return
  4533. }
  4534. recordDateTime := theTime.Unix()
  4535. adminUser := c.GetAdminUserInfo()
  4536. var tempOrder models.HisOrder
  4537. tempOrder, _ = service.GetHisOrderByID(order_id)
  4538. var prescriptions []*models.HisPrescription
  4539. var start_time int64
  4540. var end_time int64
  4541. //if adminUser.CurrentOrgId == 10106{
  4542. // if len(fapiao_code) == 0{
  4543. // fapiao_code = "144072080589"
  4544. // }
  4545. // if len(fapiao_number) == 0{
  4546. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4547. // if order.ID == 0{
  4548. // fapiao_number = "00001520"
  4549. // }else{
  4550. // //fapiao_code = "00001520"
  4551. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4552. // var zero string
  4553. // if fpNumber >= 1000{
  4554. // zero = "0000" + strconv.Itoa(fpNumber)
  4555. // }else if fpNumber >= 10000{
  4556. // zero = "000" + strconv.Itoa(fpNumber)
  4557. // } else if fpNumber >= 100000{
  4558. // zero = "00" + strconv.Itoa(fpNumber)
  4559. // } else if fpNumber >= 1000000{
  4560. // zero = "0" + strconv.Itoa(fpNumber)
  4561. // }else {
  4562. // zero = strconv.Itoa(fpNumber)
  4563. // }
  4564. // fapiao_number = zero
  4565. // }
  4566. // }
  4567. //}
  4568. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4569. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4570. var patientPrescription models.HisPrescriptionInfo
  4571. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4572. if patientPrescription.ID == 0 {
  4573. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4574. }
  4575. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4576. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4577. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4578. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4579. var config []*models.HisXtDiagnoseConfig
  4580. for _, item := range diagnosis_ids {
  4581. id, _ := strconv.ParseInt(item, 10, 64)
  4582. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4583. config = append(config, &diagnosisConfig)
  4584. }
  4585. sickConfig, _ := service.FindSickById(sick_type)
  4586. //if tempOrder.ID == 0 {
  4587. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4588. //}
  4589. if tempOrder.ID == 0 {
  4590. var result string
  4591. var requestLog string
  4592. var res2 ResultSix
  4593. var ressix10265 ResultSix10265
  4594. if miConfig.MdtrtareaAdmvs == "421300" {
  4595. data := make(map[string]interface{})
  4596. client := &http.Client{}
  4597. data["psn_no"] = his.PsnNo
  4598. data["mdtrt_id"] = his.Number
  4599. data["doctor"] = roles.UserName
  4600. data["department"] = department.Name
  4601. data["org_name"] = miConfig.OrgName
  4602. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4603. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4604. data["fixmedins_code"] = miConfig.Code
  4605. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4606. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4607. data["secret_key"] = miConfig.SecretKey
  4608. data["sick_code"] = sickConfig.CountryCode
  4609. data["sick_name"] = sickConfig.ClassName
  4610. data["dept"] = strconv.FormatInt(department.ID, 10)
  4611. data["config"] = config
  4612. data["begin_time"] = begin_time
  4613. bytesData, _ := json.Marshal(data)
  4614. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4615. resp, _ := client.Do(req)
  4616. defer resp.Body.Close()
  4617. body, ioErr := ioutil.ReadAll(resp.Body)
  4618. if ioErr != nil {
  4619. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4621. return
  4622. }
  4623. var respJSON map[string]interface{}
  4624. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4627. return
  4628. }
  4629. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4630. userJSONBytes, _ := json.Marshal(respJSON)
  4631. fmt.Println("log")
  4632. fmt.Println(string(userJSONBytes))
  4633. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4634. utils.ErrorLog("解析失败:%v", err)
  4635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4636. return
  4637. }
  4638. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4639. //江苏地区国家医保医疗类别
  4640. //职工透析:医疗类别选特殊情况门诊9933
  4641. //居民血透门慢: 医疗类别选门诊慢病1402
  4642. //var med_type string
  4643. //if his.Insutype == "310" {
  4644. // if reg_type == 14 {
  4645. // med_type = "9933"
  4646. // } else if reg_type == 11 {
  4647. // med_type = "11"
  4648. //
  4649. // }
  4650. //} else if his.Insutype == "390" {
  4651. // if reg_type == 14 {
  4652. // med_type = "1402"
  4653. // } else if reg_type == 11 {
  4654. // med_type = "11"
  4655. // }
  4656. //}
  4657. data := make(map[string]interface{})
  4658. client := &http.Client{}
  4659. data["psn_no"] = his.PsnNo
  4660. data["mdtrt_id"] = his.Number
  4661. data["doctor"] = roles.UserName
  4662. data["department"] = department.Name
  4663. data["org_name"] = miConfig.OrgName
  4664. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4665. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4666. data["fixmedins_code"] = miConfig.Code
  4667. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4668. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4669. data["secret_key"] = miConfig.SecretKey
  4670. data["sick_code"] = sickConfig.CountryCode
  4671. data["sick_name"] = sickConfig.ClassName
  4672. data["url"] = miConfig.Url
  4673. data["ak"] = miConfig.AccessKey
  4674. data["begin_time"] = begin_time
  4675. data["cainfo"] = miConfig.Cainfo
  4676. data["dept"] = strconv.FormatInt(department.ID, 10)
  4677. data["config"] = config
  4678. bytesData, _ := json.Marshal(data)
  4679. var req *http.Request
  4680. if miConfig.MdtrtareaAdmvs == "320921" {
  4681. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4682. //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 +
  4683. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4684. } else {
  4685. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4686. }
  4687. resp, _ := client.Do(req)
  4688. defer resp.Body.Close()
  4689. body, ioErr := ioutil.ReadAll(resp.Body)
  4690. if ioErr != nil {
  4691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4693. return
  4694. }
  4695. var respJSON map[string]interface{}
  4696. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4699. return
  4700. }
  4701. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4702. userJSONBytes, _ := json.Marshal(respJSON)
  4703. fmt.Println("log")
  4704. fmt.Println(string(userJSONBytes))
  4705. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4706. utils.ErrorLog("解析失败:%v", err)
  4707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4708. return
  4709. }
  4710. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4711. res2.Output = ressix10265.Output
  4712. res2.ErrMsg = ressix10265.ErrMsg
  4713. res2.Cainfo = ressix10265.Cainfo
  4714. res2.WarnMsg = ressix10265.WarnMsg
  4715. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4716. res2.Infcode = infocode
  4717. } else {
  4718. if miConfig.MdtrtareaAdmvs == "440781" { //
  4719. 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)
  4720. } else {
  4721. if miConfig.Code == "H15049901371" {
  4722. //赤峰地区国家医保医疗类别
  4723. //职工透析:医疗类别选特殊情况门诊990502
  4724. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4725. var med_type string
  4726. if his.Insutype == "390" {
  4727. if reg_type == 14 {
  4728. med_type = "9933"
  4729. } else if reg_type == 11 {
  4730. med_type = "11"
  4731. }
  4732. } else if his.Insutype == "310" {
  4733. if reg_type == 14 {
  4734. med_type = "990502"
  4735. } else if reg_type == 11 {
  4736. med_type = "11"
  4737. }
  4738. }
  4739. 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)
  4740. } else {
  4741. 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)
  4742. }
  4743. }
  4744. saveLog(result, requestLog, "2203", "上传就诊信息")
  4745. var respJSON2 map[string]interface{}
  4746. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4749. return
  4750. }
  4751. userJSONBytes2, _ := json.Marshal(respJSON2)
  4752. if miConfig.Code == "H15049901371" {
  4753. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4754. utils.ErrorLog("解析失败:%v", err)
  4755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4756. return
  4757. }
  4758. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4759. res2.Output = ressix10265.Output
  4760. res2.ErrMsg = ressix10265.ErrMsg
  4761. res2.Cainfo = ressix10265.Cainfo
  4762. res2.WarnMsg = ressix10265.WarnMsg
  4763. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4764. res2.Infcode = infocode
  4765. } else {
  4766. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4767. utils.ErrorLog("解析失败:%v", err)
  4768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4769. return
  4770. }
  4771. }
  4772. }
  4773. if res2.Infcode != 0 {
  4774. adminUser := c.GetAdminUserInfo()
  4775. errlog := &models.HisOrderError{
  4776. UserOrgId: adminUser.CurrentOrgId,
  4777. Ctime: time.Now().Unix(),
  4778. Mtime: time.Now().Unix(),
  4779. ErrMsg: res2.ErrMsg,
  4780. Status: 1,
  4781. PatientId: id,
  4782. RecordTime: recordDateTime,
  4783. Stage: 3,
  4784. }
  4785. service.CreateErrMsgLog(errlog)
  4786. c.ServeSuccessJSON(map[string]interface{}{
  4787. "failed_code": -10,
  4788. "msg": res2.ErrMsg,
  4789. })
  4790. return
  4791. } else {
  4792. his.Diagnosis = diagnosis_id
  4793. his.SickType = sickConfig.ID
  4794. //var p_type int64
  4795. //if reg_type == 1111 || reg_type == 1112 {
  4796. // p_type = 11
  4797. //
  4798. //}
  4799. his.PType = fmt.Sprintf("%d", reg_type)
  4800. service.UpdateHisPatientThree(&his)
  4801. data := make(map[string]interface{})
  4802. if settle_accounts_type == 1 { //日结
  4803. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4804. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4805. } else {
  4806. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4807. }
  4808. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4809. data["pre"] = prescriptions
  4810. } else { //月结
  4811. start_time_str := c.GetString("start_time")
  4812. end_time_str := c.GetString("end_time")
  4813. timeLayout := "2006-01-02"
  4814. loc, _ := time.LoadLocation("Local")
  4815. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4816. if err != nil {
  4817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4818. return
  4819. }
  4820. recordStartTime := theStartTime.Unix()
  4821. start_time = recordStartTime
  4822. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4823. if err != nil {
  4824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4825. return
  4826. }
  4827. recordEndTime := theEndTime.Unix()
  4828. end_time = recordEndTime
  4829. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4830. data["pre"] = prescriptions
  4831. }
  4832. timestamp := time.Now().Unix()
  4833. tempTime := time.Unix(timestamp, 0)
  4834. timeFormat := tempTime.Format("20060102150405")
  4835. chrgBchno := rand.Intn(100000) + 10000
  4836. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4837. strconv.FormatInt(his.PatientId, 10)
  4838. client := &http.Client{}
  4839. data["psn_no"] = his.PsnNo
  4840. data["mdtrt_id"] = his.Number
  4841. data["chrg_bchno"] = chrg_bchno
  4842. data["org_name"] = miConfig.OrgName
  4843. data["doctor"] = roles.UserName
  4844. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4845. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4846. data["fixmedins_code"] = miConfig.Code
  4847. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4848. // data["dept_code"] = "15"
  4849. //} else {
  4850. data["dept_code"] = department.Number
  4851. //}
  4852. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4853. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4854. data["secret_key"] = miConfig.SecretKey
  4855. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4856. data["url"] = miConfig.Url
  4857. data["ak"] = miConfig.AccessKey
  4858. data["new_doctor_name"] = patientPrescription.Doctor
  4859. data["diag_code"] = sickConfig.CountryCode
  4860. data["cainfo"] = miConfig.Cainfo
  4861. var ids []int64
  4862. for _, item := range prescriptions {
  4863. ids = append(ids, item.ID)
  4864. }
  4865. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4866. if config.IsOpen == 1 { //对接了医保,走医保流程
  4867. var res ResultFour
  4868. var resFour10265 ResultFour10265
  4869. if miConfig.MdtrtareaAdmvs == "421300" {
  4870. bytesData, _ := json.Marshal(data)
  4871. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4872. resp, _ := client.Do(req)
  4873. defer resp.Body.Close()
  4874. body, ioErr := ioutil.ReadAll(resp.Body)
  4875. if ioErr != nil {
  4876. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4878. return
  4879. }
  4880. var respJSON map[string]interface{}
  4881. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4884. return
  4885. }
  4886. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4887. userJSONBytes, _ := json.Marshal(respJSON)
  4888. fmt.Println("log")
  4889. fmt.Println(string(userJSONBytes))
  4890. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4891. utils.ErrorLog("解析失败:%v", err)
  4892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4893. return
  4894. }
  4895. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4896. bytesData, _ := json.Marshal(data)
  4897. var req *http.Request
  4898. if miConfig.MdtrtareaAdmvs == "320921" {
  4899. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4900. } else {
  4901. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4902. }
  4903. resp, _ := client.Do(req)
  4904. defer resp.Body.Close()
  4905. body, ioErr := ioutil.ReadAll(resp.Body)
  4906. if ioErr != nil {
  4907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4909. return
  4910. }
  4911. var respJSON map[string]interface{}
  4912. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4915. return
  4916. }
  4917. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4918. userJSONBytes, _ := json.Marshal(respJSON)
  4919. fmt.Println("log")
  4920. fmt.Println(string(userJSONBytes))
  4921. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4922. utils.ErrorLog("解析失败:%v", err)
  4923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4924. return
  4925. }
  4926. res.InfRefmsgid = resFour10265.InfRefmsgid
  4927. res.Output = resFour10265.Output
  4928. res.ErrMsg = resFour10265.ErrMsg
  4929. res.Cainfo = resFour10265.Cainfo
  4930. res.WarnMsg = resFour10265.WarnMsg
  4931. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4932. res.Infcode = infocode
  4933. } else {
  4934. if miConfig.Code == "H15049901371" {
  4935. 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)
  4936. var dat map[string]interface{}
  4937. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4938. fmt.Println(dat)
  4939. } else {
  4940. fmt.Println(err)
  4941. }
  4942. saveLog(result, request_log, "2204", "上传费用明细")
  4943. userJSONBytes, _ := json.Marshal(dat)
  4944. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4945. utils.ErrorLog("解析失败:%v", err)
  4946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4947. return
  4948. }
  4949. res.InfRefmsgid = resFour10265.InfRefmsgid
  4950. res.Output = resFour10265.Output
  4951. res.ErrMsg = resFour10265.ErrMsg
  4952. res.Cainfo = resFour10265.Cainfo
  4953. res.WarnMsg = resFour10265.WarnMsg
  4954. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4955. res.Infcode = infocode
  4956. } else {
  4957. 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)
  4958. var dat map[string]interface{}
  4959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4960. fmt.Println(dat)
  4961. } else {
  4962. fmt.Println(err)
  4963. }
  4964. saveLog(result, request_log, "2204", "上传费用明细")
  4965. userJSONBytes, _ := json.Marshal(dat)
  4966. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4967. utils.ErrorLog("解析失败:%v", err)
  4968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4969. return
  4970. }
  4971. }
  4972. }
  4973. if res.Infcode == 0 {
  4974. order := &models.HisOrder{
  4975. UserOrgId: adminUser.CurrentOrgId,
  4976. HisPatientId: his.ID,
  4977. PatientId: his.PatientId,
  4978. SettleAccountsDate: recordDateTime,
  4979. MdtrtId: his.Number,
  4980. PsnNo: his.PsnNo,
  4981. MedType: strconv.FormatInt(reg_type, 10),
  4982. Ctime: time.Now().Unix(),
  4983. Mtime: time.Now().Unix(),
  4984. Status: 1,
  4985. Number: chrg_bchno,
  4986. Infcode: res.Infcode,
  4987. WarnMsg: res.WarnMsg,
  4988. Cainfo: res.Cainfo,
  4989. ErrMsg: res.ErrMsg,
  4990. RespondTime: res.RefmsgTime,
  4991. InfRefmsgid: res.InfRefmsgid,
  4992. OrderStatus: 1,
  4993. PayWay: pay_way,
  4994. PayPrice: pay_price,
  4995. PayCardNo: pay_card_no,
  4996. DiscountPrice: discount_price,
  4997. PreferentialPrice: preferential_price,
  4998. RealityPrice: reality_price,
  4999. FoundPrice: found_price,
  5000. MedicalInsurancePrice: medical_insurance_price,
  5001. PrivatePrice: private_price,
  5002. IsMedicineInsurance: 1,
  5003. SettleType: settle_accounts_type,
  5004. SettleStartTime: start_time,
  5005. SettleEndTime: end_time,
  5006. Creator: roles.AdminUserId,
  5007. Modify: roles.AdminUserId,
  5008. FaPiaoNumber: fapiao_number,
  5009. FaPiaoCode: fapiao_code,
  5010. PType: 2,
  5011. Diagnosis: diagnosis_id,
  5012. }
  5013. err = service.CreateOrder(order)
  5014. if err != nil {
  5015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5016. return
  5017. }
  5018. for _, item := range res.Output.Result {
  5019. temp := strings.Split(item.FeedetlSn, "-")
  5020. var advice_id int64 = 0
  5021. var project_id int64 = 0
  5022. var types int64 = 0
  5023. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5024. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5025. if temp[1] == "1" {
  5026. advice_id = id
  5027. project_id = 0
  5028. } else if temp[1] == "2" {
  5029. advice_id = 0
  5030. project_id = id
  5031. }
  5032. info := &models.HisOrderInfo{
  5033. OrderNumber: order.Number,
  5034. FeedetlSn: item.FeedetlSn,
  5035. UploadDate: time.Now().Unix(),
  5036. AdviceId: advice_id,
  5037. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5038. Cnt: item.Cnt,
  5039. Pric: float64(item.Pric),
  5040. PatientId: his.PatientId,
  5041. PricUplmtAmt: item.PricUplmtAmt,
  5042. SelfpayProp: item.SelfpayProp,
  5043. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5044. OverlmtAmt: item.OverlmtAmt,
  5045. PreselfpayAmt: item.PreselfpayAmt,
  5046. BasMednFlag: item.BasMednFlag,
  5047. MedChrgitmType: item.MedChrgitmType,
  5048. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5049. Status: 1,
  5050. Memo: item.Memo,
  5051. Mtime: time.Now().Unix(),
  5052. InscpScpAmt: item.InscpScpAmt,
  5053. DrtReimFlag: item.DrtReimFlag,
  5054. Ctime: time.Now().Unix(),
  5055. ListSpItemFlag: item.ListSpItemFlag,
  5056. ChldMedcFlag: item.ChldMedcFlag,
  5057. LmtUsedFlag: item.LmtUsedFlag,
  5058. ChrgitmLv: item.ChrgitmLv,
  5059. UserOrgId: adminUser.CurrentOrgId,
  5060. HisPatientId: his.ID,
  5061. OrderId: order.ID,
  5062. ProjectId: project_id,
  5063. Type: types,
  5064. }
  5065. service.CreateOrderInfo(info)
  5066. }
  5067. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5068. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5069. var total float64
  5070. for _, item := range prescriptions {
  5071. if item.Type == 1 { //药品
  5072. for _, subItem := range item.HisDoctorAdviceInfo {
  5073. total = total + (subItem.Price * subItem.PrescribingNumber)
  5074. }
  5075. }
  5076. if item.Type == 2 { //项目
  5077. for _, subItem := range item.HisPrescriptionProject {
  5078. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5079. total = total + (subItem.Price * cnt)
  5080. }
  5081. }
  5082. }
  5083. for _, item := range prescriptions {
  5084. for _, subItem := range item.HisAdditionalCharge {
  5085. total = total + (subItem.Price * float64(subItem.Count))
  5086. }
  5087. }
  5088. var allTotal string
  5089. if adminUser.CurrentOrgId == 9919 {
  5090. allTotal = fmt.Sprintf("%.4f", total)
  5091. } else {
  5092. allTotal = fmt.Sprintf("%.4f", total)
  5093. }
  5094. if res.Infcode == 0 {
  5095. var rf []*ResultFive
  5096. json.Unmarshal([]byte(his.Iinfo), &rf)
  5097. chrg_bchno := chrg_bchno
  5098. cert_no := his.Certno
  5099. var insutypes []string
  5100. var insutype string
  5101. var is390 int = 0
  5102. var is310 int = 0
  5103. for _, item := range rf {
  5104. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5105. insutypes = append(insutypes, item.Insutype)
  5106. }
  5107. }
  5108. if len(insutypes) == 1 {
  5109. insutype = insutypes[0]
  5110. } else {
  5111. for _, i := range insutypes {
  5112. if i == "390" {
  5113. is390 = 1
  5114. }
  5115. if i == "310" {
  5116. is310 = 1
  5117. }
  5118. }
  5119. }
  5120. if is390 == 1 {
  5121. insutype = "390"
  5122. }
  5123. if is310 == 1 {
  5124. insutype = "310"
  5125. }
  5126. if len(insutypes) == 0 {
  5127. insutype = "310"
  5128. }
  5129. if len(insutypes) == 2 {
  5130. insutype = strconv.FormatInt(his.SocialType, 10)
  5131. }
  5132. insutype = strconv.FormatInt(his.SocialType, 10)
  5133. //insutype = "390"
  5134. if his.IdCardType == 1 {
  5135. // cert_no = his.MedicalInsuranceNumber
  5136. cert_no = his.Certno
  5137. } else {
  5138. cert_no = his.Certno
  5139. }
  5140. var res ResultSeven
  5141. var resSeven10265 ResultSeven10265
  5142. var src_resquest string
  5143. var result2 string
  5144. var acct_used_flag string
  5145. fmt.Println("pay_way")
  5146. fmt.Println(pay_way)
  5147. fmt.Println("pay_way")
  5148. if pay_way == 4 {
  5149. acct_used_flag = "1"
  5150. } else {
  5151. acct_used_flag = "0"
  5152. }
  5153. if miConfig.MdtrtareaAdmvs == "421300" {
  5154. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5155. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5156. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5157. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5158. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5159. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5160. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5161. resp, requestErr := http.Get(api)
  5162. if requestErr != nil {
  5163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5164. return
  5165. }
  5166. body, ioErr := ioutil.ReadAll(resp.Body)
  5167. if ioErr != nil {
  5168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5170. return
  5171. }
  5172. var respJSON map[string]interface{}
  5173. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5176. return
  5177. }
  5178. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5179. result, _ := json.Marshal(respJSON)
  5180. if miConfig.Code == "H15049901371" {
  5181. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5182. utils.ErrorLog("解析失败:%v", err)
  5183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5184. return
  5185. }
  5186. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5187. res.Output = resSeven10265.Output
  5188. res.ErrMsg = resSeven10265.ErrMsg
  5189. res.Cainfo = resSeven10265.Cainfo
  5190. res.WarnMsg = resSeven10265.WarnMsg
  5191. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5192. res.Infcode = infocode
  5193. } else {
  5194. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5195. utils.ErrorLog("解析失败:%v", err)
  5196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5197. return
  5198. }
  5199. }
  5200. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5201. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5202. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5203. //psn_info, _ := service.GetPsnByPatientId(id)
  5204. bas := strings.Split(psn_info.CardInfo, "|")
  5205. if his.IdCardType == 1 {
  5206. cert_no = bas[2]
  5207. } else if his.IdCardType == 3 {
  5208. cert_no = his.Certno
  5209. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5210. } else {
  5211. cert_no = bas[1]
  5212. }
  5213. //江苏地区国家医保医疗类别
  5214. //职工透析:医疗类别选特殊情况门诊9933
  5215. //居民血透门慢: 医疗类别选门诊慢病1402
  5216. //var med_type string
  5217. //if his.Insutype == "310" {
  5218. // if reg_type == 14 {
  5219. // med_type = "9933"
  5220. // } else if reg_type == 11 {
  5221. // med_type = "11"
  5222. //
  5223. // }
  5224. //} else if his.Insutype == "390" {
  5225. // if reg_type == 14 {
  5226. // med_type = "1402"
  5227. // } else if reg_type == 11 {
  5228. // med_type = "11"
  5229. // }
  5230. //}
  5231. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5232. var api string
  5233. if miConfig.MdtrtareaAdmvs == "320921" {
  5234. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5235. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5236. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5237. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5238. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5239. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5240. "&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
  5241. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5242. } else {
  5243. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5244. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5245. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5246. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5247. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5248. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5249. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5250. "&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
  5251. }
  5252. resp, requestErr := http.Get(api)
  5253. if requestErr != nil {
  5254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5255. return
  5256. }
  5257. body, ioErr := ioutil.ReadAll(resp.Body)
  5258. if ioErr != nil {
  5259. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5261. return
  5262. }
  5263. var respJSON map[string]interface{}
  5264. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5267. return
  5268. }
  5269. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5270. result, _ := json.Marshal(respJSON)
  5271. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5272. utils.ErrorLog("解析失败:%v", err)
  5273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5274. return
  5275. }
  5276. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5277. res.Output = resSeven10265.Output
  5278. res.ErrMsg = resSeven10265.ErrMsg
  5279. res.Cainfo = resSeven10265.Cainfo
  5280. res.WarnMsg = resSeven10265.WarnMsg
  5281. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5282. res.Infcode = infocode
  5283. } else {
  5284. if miConfig.Code == "H15049901371" {
  5285. //赤峰地区国家医保医疗类别
  5286. //职工透析:医疗类别选特殊情况门诊990502
  5287. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5288. var med_type string
  5289. if his.Insutype == "390" {
  5290. if reg_type == 14 {
  5291. med_type = "9933"
  5292. } else if reg_type == 11 {
  5293. med_type = "11"
  5294. }
  5295. } else if his.Insutype == "310" {
  5296. if reg_type == 14 {
  5297. med_type = "990502"
  5298. } else if reg_type == 11 {
  5299. med_type = "11"
  5300. }
  5301. }
  5302. 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)
  5303. } else {
  5304. 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)
  5305. }
  5306. //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)
  5307. var dat map[string]interface{}
  5308. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5309. fmt.Println(dat)
  5310. } else {
  5311. fmt.Println(err)
  5312. }
  5313. saveLog(result2, src_resquest, "2207", "结算")
  5314. userJSONBytes, _ := json.Marshal(dat)
  5315. if miConfig.Code == "H15049901371" {
  5316. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5317. utils.ErrorLog("解析失败:%v", err)
  5318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5319. return
  5320. }
  5321. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5322. res.Output = resSeven10265.Output
  5323. res.ErrMsg = resSeven10265.ErrMsg
  5324. res.Cainfo = resSeven10265.Cainfo
  5325. res.WarnMsg = resSeven10265.WarnMsg
  5326. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5327. res.Infcode = infocode
  5328. } else {
  5329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5330. utils.ErrorLog("解析失败:%v", err)
  5331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5332. return
  5333. }
  5334. }
  5335. }
  5336. if res.Infcode != 0 {
  5337. errlog := &models.HisOrderError{
  5338. UserOrgId: adminUser.CurrentOrgId,
  5339. Ctime: time.Now().Unix(),
  5340. Mtime: time.Now().Unix(),
  5341. Number: chrg_bchno,
  5342. ErrMsg: res.ErrMsg,
  5343. Status: 1,
  5344. PatientId: id,
  5345. RecordTime: recordDateTime,
  5346. Stage: 6,
  5347. }
  5348. service.CreateErrMsgLog(errlog)
  5349. c.ServeSuccessJSON(map[string]interface{}{
  5350. "failed_code": -10,
  5351. "msg": res.ErrMsg,
  5352. })
  5353. return
  5354. } else {
  5355. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5356. order.OrderStatus = 2
  5357. order.Status = 1
  5358. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5359. order.SetlId = res.Output.Setlinfo.SetlID
  5360. order.PsnNo = res.Output.Setlinfo.PsnNo
  5361. order.PsnName = res.Output.Setlinfo.PsnName
  5362. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5363. order.Certno = res.Output.Setlinfo.Certno
  5364. order.Gend = res.Output.Setlinfo.Gend
  5365. order.Naty = res.Output.Setlinfo.Naty
  5366. order.Age = res.Output.Setlinfo.Age
  5367. order.Insutype = res.Output.Setlinfo.Insutype
  5368. order.PsnType = res.Output.Setlinfo.PsnType
  5369. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5370. order.SetlTime = res.Output.Setlinfo.SetlTime
  5371. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5372. if res.Output.Setlinfo.MedType == "140101" {
  5373. order.MedType = "14"
  5374. } else {
  5375. order.MedType = res.Output.Setlinfo.MedType
  5376. }
  5377. if reg_type == 1112 {
  5378. order.MedType = "1112"
  5379. }
  5380. if reg_type == 1111 {
  5381. order.MedType = "1111"
  5382. }
  5383. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5384. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5385. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5386. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5387. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5388. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5389. order.HifpPay = res.Output.Setlinfo.HifpPay
  5390. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5391. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5392. order.HifesPay = res.Output.Setlinfo.HifesPay
  5393. order.HifobPay = res.Output.Setlinfo.HifobPay
  5394. order.MafPay = res.Output.Setlinfo.MafPay
  5395. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5396. order.OthPay = res.Output.Setlinfo.OthPay
  5397. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5398. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5399. order.AcctPay = res.Output.Setlinfo.AcctPay
  5400. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5401. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5402. order.Balc = res.Output.Setlinfo.Balc
  5403. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5404. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5405. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5406. order.ClrType = res.Output.Setlinfo.ClrType
  5407. order.ClrWay = res.Output.Setlinfo.ClrWay
  5408. order.Creator = order.Creator
  5409. order.Modify = roles.AdminUserId
  5410. order.RequestLog = src_resquest
  5411. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5412. detailStr := string(setlDetail)
  5413. order.SetlDetail = detailStr
  5414. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5415. err = service.UpDateOrder(order)
  5416. if err == nil {
  5417. c.ServeSuccessJSON(map[string]interface{}{
  5418. "msg": "结算成功",
  5419. })
  5420. } else {
  5421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5422. return
  5423. }
  5424. }
  5425. } else {
  5426. adminUser := c.GetAdminUserInfo()
  5427. errlog := &models.HisOrderError{
  5428. UserOrgId: adminUser.CurrentOrgId,
  5429. Ctime: time.Now().Unix(),
  5430. Mtime: time.Now().Unix(),
  5431. ErrMsg: res.ErrMsg,
  5432. Status: 1,
  5433. PatientId: id,
  5434. RecordTime: recordDateTime,
  5435. Stage: 4,
  5436. }
  5437. service.CreateErrMsgLog(errlog)
  5438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5439. return
  5440. }
  5441. } else {
  5442. adminUser := c.GetAdminUserInfo()
  5443. errlog := &models.HisOrderError{
  5444. UserOrgId: adminUser.CurrentOrgId,
  5445. Ctime: time.Now().Unix(),
  5446. Mtime: time.Now().Unix(),
  5447. ErrMsg: res.ErrMsg,
  5448. Status: 1,
  5449. PatientId: id,
  5450. RecordTime: recordDateTime,
  5451. Stage: 4,
  5452. }
  5453. service.CreateErrMsgLog(errlog)
  5454. c.ServeSuccessJSON(map[string]interface{}{
  5455. "failed_code": -10,
  5456. "msg": res.ErrMsg,
  5457. })
  5458. return
  5459. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5460. //return
  5461. }
  5462. }
  5463. }
  5464. } else if tempOrder.ID > 0 {
  5465. if tempOrder.IsPre == 1 {
  5466. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5467. var rf []*ResultFive
  5468. json.Unmarshal([]byte(his.Iinfo), &rf)
  5469. chrg_bchno := tempOrder.Number
  5470. cert_no := his.Certno
  5471. var insutypes []string
  5472. var insutype string
  5473. var is390 int = 0
  5474. var is310 int = 0
  5475. for _, item := range rf {
  5476. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5477. insutypes = append(insutypes, item.Insutype)
  5478. }
  5479. }
  5480. if len(insutypes) == 1 {
  5481. insutype = insutypes[0]
  5482. } else {
  5483. for _, i := range insutypes {
  5484. if i == "390" {
  5485. is390 = 1
  5486. }
  5487. if i == "310" {
  5488. is310 = 1
  5489. }
  5490. }
  5491. }
  5492. if is390 == 1 {
  5493. insutype = "390"
  5494. }
  5495. if is310 == 1 {
  5496. insutype = "310"
  5497. }
  5498. if len(insutypes) == 0 {
  5499. insutype = "310"
  5500. }
  5501. if len(insutypes) == 2 {
  5502. insutype = strconv.FormatInt(his.SocialType, 64)
  5503. }
  5504. //insutype = "390"
  5505. if his.IdCardType == 1 {
  5506. // cert_no = his.MedicalInsuranceNumber
  5507. cert_no = his.Certno
  5508. } else {
  5509. cert_no = his.Certno
  5510. }
  5511. var res ResultSeven
  5512. var resSeven10265 ResultSeven10265
  5513. var src_resquest string
  5514. var result2 string
  5515. var acct_used_flag string
  5516. fmt.Println("pay_way")
  5517. fmt.Println(pay_way)
  5518. fmt.Println("pay_way")
  5519. if pay_way == 4 {
  5520. acct_used_flag = "1"
  5521. } else {
  5522. acct_used_flag = "0"
  5523. }
  5524. if miConfig.MdtrtareaAdmvs == "421300" {
  5525. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5526. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5527. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5528. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5529. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5530. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5531. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5532. resp, requestErr := http.Get(api)
  5533. if requestErr != nil {
  5534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5535. return
  5536. }
  5537. body, ioErr := ioutil.ReadAll(resp.Body)
  5538. if ioErr != nil {
  5539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5541. return
  5542. }
  5543. var respJSON map[string]interface{}
  5544. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5547. return
  5548. }
  5549. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5550. result, _ := json.Marshal(respJSON)
  5551. fmt.Println("log")
  5552. fmt.Println(string(result))
  5553. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5554. utils.ErrorLog("解析失败:%v", err)
  5555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5556. return
  5557. }
  5558. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5559. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5560. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5561. //psn_info, _ := service.GetPsnByPatientId(id)
  5562. bas := strings.Split(psn_info.CardInfo, "|")
  5563. if his.IdCardType == 1 {
  5564. cert_no = bas[2]
  5565. } else {
  5566. cert_no = bas[1]
  5567. }
  5568. //江苏地区国家医保医疗类别
  5569. //职工透析:医疗类别选特殊情况门诊9933
  5570. //居民血透门慢: 医疗类别选门诊慢病1402
  5571. //var med_type string
  5572. //if his.Insutype == "310" {
  5573. // if reg_type == 14 {
  5574. // med_type = "9933"
  5575. // } else if reg_type == 11 {
  5576. // med_type = "11"
  5577. //
  5578. // }
  5579. //} else if his.Insutype == "390" {
  5580. // if reg_type == 14 {
  5581. // med_type = "1402"
  5582. // } else if reg_type == 11 {
  5583. // med_type = "11"
  5584. // }
  5585. //}
  5586. var api string
  5587. if miConfig.MdtrtareaAdmvs == "320921" {
  5588. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5589. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5590. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5591. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5592. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5593. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5594. "&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
  5595. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5596. } else {
  5597. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5598. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5599. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5600. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5601. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5602. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5603. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5604. "&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
  5605. }
  5606. resp, requestErr := http.Get(api)
  5607. if requestErr != nil {
  5608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5609. return
  5610. }
  5611. body, ioErr := ioutil.ReadAll(resp.Body)
  5612. if ioErr != nil {
  5613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5615. return
  5616. }
  5617. var respJSON map[string]interface{}
  5618. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5621. return
  5622. }
  5623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5624. result, _ := json.Marshal(respJSON)
  5625. fmt.Println("log")
  5626. fmt.Println(string(result))
  5627. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5628. utils.ErrorLog("解析失败:%v", err)
  5629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5630. return
  5631. }
  5632. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5633. res.Output = resSeven10265.Output
  5634. res.ErrMsg = resSeven10265.ErrMsg
  5635. res.Cainfo = resSeven10265.Cainfo
  5636. res.WarnMsg = resSeven10265.WarnMsg
  5637. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5638. res.Infcode = infocode
  5639. } else {
  5640. var src_resquest string
  5641. if miConfig.Code == "H15049901371" {
  5642. //赤峰地区国家医保医疗类别
  5643. //职工透析:医疗类别选特殊情况门诊990502
  5644. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5645. var med_type string
  5646. if his.Insutype == "390" {
  5647. if reg_type == 14 {
  5648. med_type = "9933"
  5649. } else if reg_type == 11 {
  5650. med_type = "11"
  5651. }
  5652. } else if his.Insutype == "310" {
  5653. if reg_type == 14 {
  5654. med_type = "990502"
  5655. } else if reg_type == 11 {
  5656. med_type = "11"
  5657. }
  5658. }
  5659. 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)
  5660. } else {
  5661. 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)
  5662. }
  5663. var dat map[string]interface{}
  5664. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5665. fmt.Println(dat)
  5666. } else {
  5667. fmt.Println(err)
  5668. }
  5669. saveLog(result2, src_resquest, "2207", "结算")
  5670. userJSONBytes, _ := json.Marshal(dat)
  5671. if miConfig.Code == "H15049901371" {
  5672. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5673. utils.ErrorLog("解析失败:%v", err)
  5674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5675. return
  5676. }
  5677. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5678. res.Output = resSeven10265.Output
  5679. res.ErrMsg = resSeven10265.ErrMsg
  5680. res.Cainfo = resSeven10265.Cainfo
  5681. res.WarnMsg = resSeven10265.WarnMsg
  5682. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5683. res.Infcode = infocode
  5684. } else {
  5685. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5686. utils.ErrorLog("解析失败:%v", err)
  5687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5688. return
  5689. }
  5690. }
  5691. }
  5692. if res.Infcode != 0 {
  5693. errlog := &models.HisOrderError{
  5694. UserOrgId: adminUser.CurrentOrgId,
  5695. Ctime: time.Now().Unix(),
  5696. Mtime: time.Now().Unix(),
  5697. Number: chrg_bchno,
  5698. ErrMsg: res.ErrMsg,
  5699. Status: 1,
  5700. PatientId: id,
  5701. RecordTime: recordDateTime,
  5702. Stage: 6,
  5703. }
  5704. service.CreateErrMsgLog(errlog)
  5705. c.ServeSuccessJSON(map[string]interface{}{
  5706. "failed_code": -10,
  5707. "msg": res.ErrMsg,
  5708. })
  5709. return
  5710. } else {
  5711. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5712. order.OrderStatus = 2
  5713. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5714. order.SetlId = res.Output.Setlinfo.SetlID
  5715. order.PsnNo = res.Output.Setlinfo.PsnNo
  5716. order.PsnName = res.Output.Setlinfo.PsnName
  5717. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5718. order.Certno = res.Output.Setlinfo.Certno
  5719. order.Gend = res.Output.Setlinfo.Gend
  5720. order.Naty = res.Output.Setlinfo.Naty
  5721. order.Age = res.Output.Setlinfo.Age
  5722. order.Insutype = res.Output.Setlinfo.Insutype
  5723. order.PsnType = res.Output.Setlinfo.PsnType
  5724. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5725. order.SetlTime = res.Output.Setlinfo.SetlTime
  5726. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5727. //order.MedType = res.Output.Setlinfo.MedType
  5728. if reg_type == 1112 {
  5729. order.MedType = "1112"
  5730. }
  5731. if reg_type == 1111 {
  5732. order.MedType = "1111"
  5733. }
  5734. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5735. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5736. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5737. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5738. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5739. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5740. order.HifpPay = res.Output.Setlinfo.HifpPay
  5741. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5742. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5743. order.HifesPay = res.Output.Setlinfo.HifesPay
  5744. order.HifobPay = res.Output.Setlinfo.HifobPay
  5745. order.MafPay = res.Output.Setlinfo.MafPay
  5746. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5747. order.OthPay = res.Output.Setlinfo.OthPay
  5748. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5749. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5750. order.AcctPay = res.Output.Setlinfo.AcctPay
  5751. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5752. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5753. order.Balc = res.Output.Setlinfo.Balc
  5754. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5755. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5756. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5757. order.ClrWay = res.Output.Setlinfo.ClrWay
  5758. order.Creator = order.Creator
  5759. order.Modify = roles.AdminUserId
  5760. order.RequestLog = src_resquest
  5761. order.Diagnosis = diagnosis_id
  5762. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5763. detailStr := string(setlDetail)
  5764. order.SetlDetail = detailStr
  5765. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5766. err = service.UpDateOrder(order)
  5767. if err == nil {
  5768. c.ServeSuccessJSON(map[string]interface{}{
  5769. "msg": "结算成功",
  5770. })
  5771. } else {
  5772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5773. return
  5774. }
  5775. }
  5776. }
  5777. }
  5778. }
  5779. //func (c *HisApiController) GetPreUploadInfo() {
  5780. // id, _ := c.GetInt64("id")
  5781. // record_time := c.GetString("record_time")
  5782. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5783. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5784. //
  5785. // timeLayout := "2006-01-02"
  5786. // loc, _ := time.LoadLocation("Local")
  5787. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5788. // if err != nil {
  5789. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5790. // return
  5791. // }
  5792. // recordDateTime := theTime.Unix()
  5793. // adminUser := c.GetAdminUserInfo()
  5794. //
  5795. // var prescriptions []*models.HisPrescription
  5796. //
  5797. // var start_time int64
  5798. // var end_time int64
  5799. //
  5800. // data := make(map[string]interface{})
  5801. // if settle_accounts_type == 1 { //日结
  5802. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5803. // data["pre"] = prescriptions
  5804. //
  5805. // } else { //月结
  5806. // start_time_str := c.GetString("start_time")
  5807. // end_time_str := c.GetString("end_time")
  5808. // timeLayout := "2006-01-02"
  5809. // loc, _ := time.LoadLocation("Local")
  5810. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5811. // if err != nil {
  5812. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5813. // return
  5814. // }
  5815. // recordStartTime := theStartTime.Unix()
  5816. // start_time = recordStartTime
  5817. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5818. // if err != nil {
  5819. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5820. // return
  5821. // }
  5822. // recordEndTime := theEndTime.Unix()
  5823. // end_time = recordEndTime
  5824. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5825. // data["pre"] = prescriptions
  5826. //
  5827. // }
  5828. //
  5829. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5830. //
  5831. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5832. // timestamp := time.Now().Unix()
  5833. // tempTime := time.Unix(timestamp, 0)
  5834. // timeFormat := tempTime.Format("20060102150405")
  5835. // chrgBchno := rand.Intn(100000) + 10000
  5836. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5837. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5838. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5839. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5840. // strconv.FormatInt(his.PatientId, 10)
  5841. // client := &http.Client{}
  5842. // data["psn_no"] = his.PsnNo
  5843. // data["mdtrt_id"] = his.Number
  5844. // data["chrg_bchno"] = chrg_bchno
  5845. // data["org_name"] = miConfig.OrgName
  5846. // data["doctor"] = roles.UserName
  5847. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5848. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5849. // data["fixmedins_code"] = miConfig.Code
  5850. // data["dept_code"] = department.Number
  5851. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5852. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5853. // data["secret_key"] = miConfig.SecretKey
  5854. // var ids []int64
  5855. //
  5856. // for _, item := range prescriptions {
  5857. // ids = append(ids, item.ID)
  5858. // }
  5859. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5860. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5861. // bytesData, _ := json.Marshal(data)
  5862. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5863. // resp, _ := client.Do(req)
  5864. // defer resp.Body.Close()
  5865. // body, ioErr := ioutil.ReadAll(resp.Body)
  5866. // if ioErr != nil {
  5867. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5869. // return
  5870. // }
  5871. // var respJSON map[string]interface{}
  5872. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5873. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5875. // return
  5876. // }
  5877. //
  5878. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5879. // userJSONBytes, _ := json.Marshal(respJSON)
  5880. // var res ResultFour
  5881. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5882. // utils.ErrorLog("解析失败:%v", err)
  5883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5884. // return
  5885. // }
  5886. //
  5887. // if res.Infcode == 0 {
  5888. // order := &models.HisOrder{
  5889. // UserOrgId: adminUser.CurrentOrgId,
  5890. // HisPatientId: his.ID,
  5891. // PatientId: his.PatientId,
  5892. // SettleAccountsDate: recordDateTime,
  5893. // Ctime: time.Now().Unix(),
  5894. // Mtime: time.Now().Unix(),
  5895. // Status: 1,
  5896. // Number: chrg_bchno,
  5897. // Infcode: res.Infcode,
  5898. // WarnMsg: res.WarnMsg,
  5899. // Cainfo: res.Cainfo,
  5900. // ErrMsg: res.ErrMsg,
  5901. // RespondTime: res.RefmsgTime,
  5902. // InfRefmsgid: res.InfRefmsgid,
  5903. // OrderStatus: 1,
  5904. // IsMedicineInsurance: 1,
  5905. // SettleType: settle_accounts_type,
  5906. // SettleStartTime: start_time,
  5907. // SettleEndTime: end_time,
  5908. // Creator: roles.ID,
  5909. // Modify: roles.ID,
  5910. // PType: 2,
  5911. // }
  5912. // err = service.CreateOrder(order)
  5913. // if err != nil {
  5914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5915. // return
  5916. // }
  5917. //
  5918. // for _, item := range res.Output.Result {
  5919. // temp := strings.Split(item.FeedetlSn, "-")
  5920. // var advice_id int64 = 0
  5921. // var project_id int64 = 0
  5922. // var types int64 = 0
  5923. //
  5924. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5925. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5926. //
  5927. // if temp[1] == "1" {
  5928. // advice_id = id
  5929. // project_id = 0
  5930. // } else if temp[1] == "2" {
  5931. // advice_id = 0
  5932. // project_id = id
  5933. // }
  5934. //
  5935. // info := &models.HisOrderInfo{
  5936. // OrderNumber: order.Number,
  5937. // FeedetlSn: item.FeedetlSn,
  5938. // UploadDate: time.Now().Unix(),
  5939. // AdviceId: advice_id,
  5940. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5941. // Cnt: item.Cnt,
  5942. // Pric: float64(item.Pric),
  5943. // PatientId: his.PatientId,
  5944. // PricUplmtAmt: item.PricUplmtAmt,
  5945. // SelfpayProp: item.SelfpayProp,
  5946. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5947. // OverlmtAmt: item.OverlmtAmt,
  5948. // PreselfpayAmt: item.PreselfpayAmt,
  5949. // BasMednFlag: item.BasMednFlag,
  5950. // MedChrgitmType: item.MedChrgitmType,
  5951. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5952. // Status: 1,
  5953. // Memo: item.Memo,
  5954. // Mtime: time.Now().Unix(),
  5955. // InscpScpAmt: item.InscpScpAmt,
  5956. // DrtReimFlag: item.DrtReimFlag,
  5957. // Ctime: time.Now().Unix(),
  5958. // ListSpItemFlag: item.ListSpItemFlag,
  5959. // ChldMedcFlag: item.ChldMedcFlag,
  5960. // LmtUsedFlag: item.LmtUsedFlag,
  5961. // ChrgitmLv: item.ChrgitmLv,
  5962. // UserOrgId: adminUser.CurrentOrgId,
  5963. // HisPatientId: his.ID,
  5964. // OrderId: order.ID,
  5965. // ProjectId: project_id,
  5966. // Type: types,
  5967. // }
  5968. // service.CreateOrderInfo(info)
  5969. //
  5970. // }
  5971. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5972. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5973. //
  5974. // var total float64
  5975. // for _, item := range prescriptions {
  5976. // if item.Type == 1 { //药品
  5977. // for _, subItem := range item.HisDoctorAdviceInfo {
  5978. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5979. // }
  5980. // }
  5981. // if item.Type == 2 { //项目
  5982. // for _, subItem := range item.HisPrescriptionProject {
  5983. // total = total + (subItem.Price * float64(subItem.Count))
  5984. // }
  5985. // }
  5986. // }
  5987. //
  5988. // for _, item := range prescriptions {
  5989. // for _, subItem := range item.HisAdditionalCharge {
  5990. // total = total + (subItem.Price * float64(subItem.Count))
  5991. // }
  5992. // }
  5993. //
  5994. // allTotal := fmt.Sprintf("%.2f", total)
  5995. // if res.Infcode == 0 {
  5996. // var rf []*ResultFive
  5997. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5998. // psn_no := his.PsnNo
  5999. // mdtrt_id := his.Number
  6000. // chrg_bchno := chrg_bchno
  6001. // cert_no := his.Certno
  6002. // insutype := rf[0].Insutype
  6003. //
  6004. // if his.IdCardType == 1 {
  6005. // cert_no = his.MedicalInsuranceNumber
  6006. //
  6007. // } else {
  6008. //
  6009. // cert_no = his.Certno
  6010. //
  6011. // }
  6012. //
  6013. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6014. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6015. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6016. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6017. // resp, requestErr := http.Get(api)
  6018. // if requestErr != nil {
  6019. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6020. // return
  6021. // }
  6022. // defer resp.Body.Close()
  6023. // body, ioErr := ioutil.ReadAll(resp.Body)
  6024. // if ioErr != nil {
  6025. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6027. // return
  6028. // }
  6029. // var respJSON map[string]interface{}
  6030. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6031. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6032. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6033. // return
  6034. // }
  6035. // fmt.Println(respJSON)
  6036. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6037. // userJSONBytes, _ := json.Marshal(respJSON)
  6038. // var res ResultSeven
  6039. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6040. // utils.ErrorLog("解析失败:%v", err)
  6041. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6042. // return
  6043. // }
  6044. // if res.Infcode != 0 {
  6045. // errlog := &models.HisOrderError{
  6046. // UserOrgId: adminUser.CurrentOrgId,
  6047. // Ctime: time.Now().Unix(),
  6048. // Mtime: time.Now().Unix(),
  6049. // Number: chrg_bchno,
  6050. // ErrMsg: res.ErrMsg,
  6051. // Status: 1,
  6052. // PatientId: id,
  6053. // RecordTime: recordDateTime,
  6054. // Stage: 7,
  6055. // }
  6056. // service.CreateErrMsgLog(errlog)
  6057. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6058. // return
  6059. // } else {
  6060. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6061. // order.OrderStatus = 1
  6062. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6063. // order.SetlId = res.Output.Setlinfo.SetlID
  6064. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6065. // order.PsnName = res.Output.Setlinfo.PsnName
  6066. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6067. // order.Certno = res.Output.Setlinfo.Certno
  6068. // order.Gend = res.Output.Setlinfo.Gend
  6069. // order.Naty = res.Output.Setlinfo.Naty
  6070. // order.Age = res.Output.Setlinfo.Age
  6071. // order.Insutype = res.Output.Setlinfo.Insutype
  6072. // order.PsnType = res.Output.Setlinfo.PsnType
  6073. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6074. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6075. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6076. // order.MedType = res.Output.Setlinfo.MedType
  6077. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6078. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6079. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6080. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6081. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6082. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6083. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6084. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6085. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6086. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6087. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6088. // order.MafPay = res.Output.Setlinfo.MafPay
  6089. // order.OthPay = res.Output.Setlinfo.OthPay
  6090. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6091. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6092. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6093. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6094. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6095. // order.Balc = res.Output.Setlinfo.Balc
  6096. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6097. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6098. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6099. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6100. // order.Creator = order.Creator
  6101. // order.Modify = roles.ID
  6102. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6103. // detailStr := string(setlDetail)
  6104. // order.SetlDetail = detailStr
  6105. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6106. // err = service.UpDateOrder(order)
  6107. // if err == nil {
  6108. // c.ServeSuccessJSON(map[string]interface{}{
  6109. // "msg": "预结算成功",
  6110. // })
  6111. // } else {
  6112. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6113. // return
  6114. // }
  6115. // }
  6116. // } else {
  6117. // adminUser := c.GetAdminUserInfo()
  6118. // errlog := &models.HisOrderError{
  6119. // UserOrgId: adminUser.CurrentOrgId,
  6120. // Ctime: time.Now().Unix(),
  6121. // Mtime: time.Now().Unix(),
  6122. // ErrMsg: res.ErrMsg,
  6123. // Status: 1,
  6124. // PatientId: id,
  6125. // RecordTime: recordDateTime,
  6126. // Stage: 4,
  6127. // }
  6128. // service.CreateErrMsgLog(errlog)
  6129. //
  6130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6131. // return
  6132. // }
  6133. // } else {
  6134. // adminUser := c.GetAdminUserInfo()
  6135. // errlog := &models.HisOrderError{
  6136. // UserOrgId: adminUser.CurrentOrgId,
  6137. // Ctime: time.Now().Unix(),
  6138. // Mtime: time.Now().Unix(),
  6139. // ErrMsg: res.ErrMsg,
  6140. // Status: 1,
  6141. // PatientId: id,
  6142. // RecordTime: recordDateTime,
  6143. // Stage: 4,
  6144. // }
  6145. // service.CreateErrMsgLog(errlog)
  6146. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6147. // return
  6148. // }
  6149. //
  6150. // } else {
  6151. // var total float64
  6152. // for _, item := range prescriptions {
  6153. // if item.Type == 1 { //药品
  6154. // for _, subItem := range item.HisDoctorAdviceInfo {
  6155. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6156. // }
  6157. // }
  6158. // if item.Type == 2 { //项目
  6159. // for _, subItem := range item.HisPrescriptionProject {
  6160. // total = total + (subItem.Price * float64(subItem.Count))
  6161. // }
  6162. // }
  6163. //
  6164. // for _, subItem := range item.HisAdditionalCharge {
  6165. // total = total + (subItem.Price * float64(subItem.Count))
  6166. // }
  6167. // }
  6168. //
  6169. // allTotal := fmt.Sprintf("%.2f", total)
  6170. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6171. // order := &models.HisOrder{
  6172. // UserOrgId: adminUser.CurrentOrgId,
  6173. // HisPatientId: his.ID,
  6174. // PatientId: id,
  6175. // SettleAccountsDate: recordDateTime,
  6176. // Ctime: time.Now().Unix(),
  6177. // Mtime: time.Now().Unix(),
  6178. // Status: 1,
  6179. // OrderStatus: 2,
  6180. // Number: chrg_bchno,
  6181. // MedfeeSumamt: totals,
  6182. // }
  6183. // err = service.CreateOrder(order)
  6184. // if err != nil {
  6185. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6186. // return
  6187. // }
  6188. //
  6189. // var customs []*Custom
  6190. // for _, item := range prescriptions {
  6191. //
  6192. // if item.Type == 1 { //药品
  6193. // for _, subItem := range item.HisDoctorAdviceInfo {
  6194. // cus := &Custom{
  6195. // AdviceId: subItem.ID,
  6196. // ProjectId: 0,
  6197. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6198. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6199. // FeedetlSn: subItem.FeedetlSn,
  6200. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6201. // MedListCodg: subItem.MedListCodg,
  6202. // Type: 1,
  6203. // }
  6204. // customs = append(customs, cus)
  6205. // }
  6206. // }
  6207. //
  6208. // if item.Type == 2 { //项目
  6209. // for _, subItem := range item.HisPrescriptionProject {
  6210. //
  6211. // cus := &Custom{
  6212. // AdviceId: 0,
  6213. // ProjectId: subItem.ID,
  6214. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6215. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6216. // FeedetlSn: subItem.FeedetlSn,
  6217. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6218. // MedListCodg: subItem.MedListCodg,
  6219. // Type: 2,
  6220. // }
  6221. //
  6222. // customs = append(customs, cus)
  6223. // }
  6224. // }
  6225. //
  6226. // for _, item := range item.HisAdditionalCharge {
  6227. // cus := &Custom{
  6228. // ItemId: item.ID,
  6229. // AdviceId: 0,
  6230. // ProjectId: 0,
  6231. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6232. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6233. // FeedetlSn: item.FeedetlSn,
  6234. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6235. // MedListCodg: item.XtHisAddtionConfig.Code,
  6236. // Type: 3,
  6237. // }
  6238. //
  6239. // customs = append(customs, cus)
  6240. // }
  6241. //
  6242. // }
  6243. //
  6244. // for _, item := range customs {
  6245. // var advice_id int64 = 0
  6246. // var project_id int64 = 0
  6247. // var item_id int64 = 0
  6248. //
  6249. // var types int64 = 0
  6250. //
  6251. // if item.Type == 1 {
  6252. // advice_id = item.AdviceId
  6253. // project_id = 0
  6254. // item_id = 0
  6255. // } else if item.Type == 2 {
  6256. // advice_id = 0
  6257. // item_id = 0
  6258. //
  6259. // project_id = item.ProjectId
  6260. // } else if item.Type == 3 {
  6261. // advice_id = 0
  6262. // item_id = item.ItemId
  6263. // project_id = 0
  6264. // }
  6265. //
  6266. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6267. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6268. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6269. //
  6270. // info := &models.HisOrderInfo{
  6271. // OrderNumber: order.Number,
  6272. // UploadDate: time.Now().Unix(),
  6273. // AdviceId: advice_id,
  6274. // DetItemFeeSumamt: detItemFeeSumamt,
  6275. // Cnt: cut,
  6276. // Pric: pric,
  6277. // PatientId: id,
  6278. // Status: 1,
  6279. // Mtime: time.Now().Unix(),
  6280. // Ctime: time.Now().Unix(),
  6281. // UserOrgId: adminUser.CurrentOrgId,
  6282. // HisPatientId: his.ID,
  6283. // OrderId: order.ID,
  6284. // ProjectId: project_id,
  6285. // Type: types,
  6286. // ItemId: item_id,
  6287. // }
  6288. // service.CreateOrderInfo(info)
  6289. // }
  6290. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6291. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6292. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6293. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6294. // if err == nil {
  6295. // c.ServeSuccessJSON(map[string]interface{}{
  6296. // "msg": "结算成功",
  6297. // })
  6298. // } else {
  6299. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6300. // return
  6301. // }
  6302. // }
  6303. //}
  6304. //上传明细-预结算-
  6305. func (c *HisApiController) GetPreUploadInfo() {
  6306. id, _ := c.GetInt64("id")
  6307. record_time := c.GetString("record_time")
  6308. his_patient_id, _ := c.GetInt64("his_patient_id")
  6309. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6310. admin_user_id, _ := c.GetInt64("admin_user_id")
  6311. diagnosis_id := c.GetString("diagnosis")
  6312. sick_type, _ := c.GetInt64("sick_type")
  6313. reg_type, _ := c.GetInt64("p_type")
  6314. begin_time := c.GetString("begin_time")
  6315. id_str := c.GetString("ids")
  6316. ids_arr := strings.Split(id_str, ",")
  6317. timeLayout := "2006-01-02"
  6318. loc, _ := time.LoadLocation("Local")
  6319. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6320. if err != nil {
  6321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6322. return
  6323. }
  6324. recordDateTime := theTime.Unix()
  6325. adminUser := c.GetAdminUserInfo()
  6326. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6327. var config []*models.HisXtDiagnoseConfig
  6328. for _, item := range diagnosis_ids {
  6329. id, _ := strconv.ParseInt(item, 10, 64)
  6330. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6331. config = append(config, &diagnosisConfig)
  6332. }
  6333. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6334. sickConfig, _ := service.FindSickById(sick_type)
  6335. var prescriptions []*models.HisPrescription
  6336. var start_time int64
  6337. var end_time int64
  6338. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6339. fmt.Println(his_patient_id)
  6340. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6341. timestamp := time.Now().Unix()
  6342. tempTime := time.Unix(timestamp, 0)
  6343. timeFormat := tempTime.Format("20060102150405")
  6344. chrgBchno := rand.Intn(100000) + 10000
  6345. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6346. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6347. var patientPrescription models.HisPrescriptionInfo
  6348. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6349. if patientPrescription.ID == 0 {
  6350. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6351. }
  6352. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6353. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6354. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6355. strconv.FormatInt(his.PatientId, 10)
  6356. var res2 ResultSix
  6357. var resSix10265 ResultSix10265
  6358. var time_stamp string
  6359. if miConfig.MdtrtareaAdmvs == "421300" {
  6360. data := make(map[string]interface{})
  6361. client := &http.Client{}
  6362. data["psn_no"] = his.PsnNo
  6363. data["mdtrt_id"] = his.Number
  6364. data["doctor"] = roles.UserName
  6365. data["department"] = department.Name
  6366. data["org_name"] = miConfig.OrgName
  6367. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6368. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6369. data["fixmedins_code"] = miConfig.Code
  6370. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6371. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6372. data["secret_key"] = miConfig.SecretKey
  6373. data["sick_code"] = sickConfig.CountryCode
  6374. data["sick_name"] = sickConfig.ClassName
  6375. data["begin_time"] = begin_time
  6376. data["dept"] = strconv.FormatInt(department.ID, 10)
  6377. data["config"] = config
  6378. fmt.Println(data)
  6379. bytesData, _ := json.Marshal(data)
  6380. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6381. resp, _ := client.Do(req)
  6382. defer resp.Body.Close()
  6383. body, ioErr := ioutil.ReadAll(resp.Body)
  6384. if ioErr != nil {
  6385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6387. return
  6388. }
  6389. var respJSON map[string]interface{}
  6390. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6393. return
  6394. }
  6395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6396. userJSONBytes, _ := json.Marshal(respJSON)
  6397. fmt.Println("log")
  6398. fmt.Println(string(userJSONBytes))
  6399. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6400. utils.ErrorLog("解析失败:%v", err)
  6401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6402. return
  6403. }
  6404. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6405. //江苏地区国家医保医疗类别
  6406. //职工透析:医疗类别选特殊情况门诊9933
  6407. //居民血透门慢: 医疗类别选门诊慢病1402
  6408. //var med_type string
  6409. //if his.Insutype == "310" {
  6410. // if reg_type == 14 {
  6411. // med_type = "9933"
  6412. // } else if reg_type == 11 {
  6413. // med_type = "11"
  6414. //
  6415. // }
  6416. //} else if his.Insutype == "390" {
  6417. // if reg_type == 14 {
  6418. // med_type = "1402"
  6419. // } else if reg_type == 11 {
  6420. // med_type = "11"
  6421. // }
  6422. //}
  6423. data := make(map[string]interface{})
  6424. client := &http.Client{}
  6425. data["psn_no"] = his.PsnNo
  6426. data["mdtrt_id"] = his.Number
  6427. data["doctor"] = roles.UserName
  6428. data["department"] = department.Name
  6429. data["org_name"] = miConfig.OrgName
  6430. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6431. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6432. data["fixmedins_code"] = miConfig.Code
  6433. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6434. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6435. data["secret_key"] = miConfig.SecretKey
  6436. data["sick_code"] = sickConfig.CountryCode
  6437. data["sick_name"] = sickConfig.ClassName
  6438. data["begin_time"] = begin_time
  6439. data["dept"] = strconv.FormatInt(department.ID, 10)
  6440. data["config"] = config
  6441. data["url"] = miConfig.Url
  6442. data["ak"] = miConfig.AccessKey
  6443. data["cainfo"] = miConfig.Cainfo
  6444. bytesData, _ := json.Marshal(data)
  6445. var req *http.Request
  6446. if miConfig.MdtrtareaAdmvs == "320921" {
  6447. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6448. //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 +
  6449. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6450. } else {
  6451. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6452. }
  6453. resp, _ := client.Do(req)
  6454. defer resp.Body.Close()
  6455. body, ioErr := ioutil.ReadAll(resp.Body)
  6456. if ioErr != nil {
  6457. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6459. return
  6460. }
  6461. var respJSON map[string]interface{}
  6462. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6463. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6465. return
  6466. }
  6467. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6468. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6469. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6470. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6471. userJSONBytes, _ := json.Marshal(respJSON)
  6472. fmt.Println("log")
  6473. fmt.Println(string(userJSONBytes))
  6474. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6475. utils.ErrorLog("解析失败:%v", err)
  6476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6477. return
  6478. }
  6479. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6480. res2.Output = resSix10265.Output
  6481. res2.ErrMsg = resSix10265.ErrMsg
  6482. res2.Cainfo = resSix10265.Cainfo
  6483. res2.WarnMsg = resSix10265.WarnMsg
  6484. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6485. res2.Infcode = infocode
  6486. } else {
  6487. var result string
  6488. var requestLog string
  6489. if miConfig.MdtrtareaAdmvs == "440781" { //
  6490. 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)
  6491. } else {
  6492. if miConfig.Code == "H15049901371" {
  6493. //赤峰地区国家医保医疗类别
  6494. //职工透析:医疗类别选特殊情况门诊990502
  6495. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6496. var med_type string
  6497. if his.Insutype == "390" {
  6498. if reg_type == 14 {
  6499. med_type = "9933"
  6500. } else if reg_type == 11 {
  6501. med_type = "11"
  6502. }
  6503. } else if his.Insutype == "310" {
  6504. if reg_type == 14 {
  6505. med_type = "990502"
  6506. } else if reg_type == 11 {
  6507. med_type = "11"
  6508. }
  6509. }
  6510. 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)
  6511. } else {
  6512. 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)
  6513. }
  6514. saveLog(result, requestLog, "2203", "上传就诊信息")
  6515. var respJSON2 map[string]interface{}
  6516. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6519. return
  6520. }
  6521. userJSONBytes2, _ := json.Marshal(respJSON2)
  6522. if miConfig.Code == "H15049901371" {
  6523. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6524. utils.ErrorLog("解析失败:%v", err)
  6525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6526. return
  6527. }
  6528. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6529. res2.Output = resSix10265.Output
  6530. res2.ErrMsg = resSix10265.ErrMsg
  6531. res2.Cainfo = resSix10265.Cainfo
  6532. res2.WarnMsg = resSix10265.WarnMsg
  6533. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6534. res2.Infcode = infocode
  6535. } else {
  6536. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6537. utils.ErrorLog("解析失败:%v", err)
  6538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6539. return
  6540. }
  6541. }
  6542. }
  6543. }
  6544. if res2.Infcode != 0 {
  6545. adminUser := c.GetAdminUserInfo()
  6546. errlog := &models.HisOrderError{
  6547. UserOrgId: adminUser.CurrentOrgId,
  6548. Ctime: time.Now().Unix(),
  6549. Mtime: time.Now().Unix(),
  6550. ErrMsg: res2.ErrMsg,
  6551. Status: 1,
  6552. PatientId: id,
  6553. RecordTime: recordDateTime,
  6554. Stage: 3,
  6555. }
  6556. service.CreateErrMsgLog(errlog)
  6557. c.ServeSuccessJSON(map[string]interface{}{
  6558. "failed_code": -10,
  6559. "msg": res2.ErrMsg,
  6560. })
  6561. return
  6562. } else {
  6563. his.Diagnosis = diagnosis_id
  6564. his.SickType = sickConfig.ID
  6565. his.PType = fmt.Sprintf("%d", reg_type)
  6566. service.UpdateHisPatientThree(&his)
  6567. data := make(map[string]interface{})
  6568. if settle_accounts_type == 1 { //日结
  6569. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6570. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6571. } else {
  6572. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6573. }
  6574. data["pre"] = prescriptions
  6575. } else { //月结
  6576. start_time_str := c.GetString("start_time")
  6577. end_time_str := c.GetString("end_time")
  6578. timeLayout := "2006-01-02"
  6579. loc, _ := time.LoadLocation("Local")
  6580. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6581. if err != nil {
  6582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6583. return
  6584. }
  6585. recordStartTime := theStartTime.Unix()
  6586. start_time = recordStartTime
  6587. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6588. if err != nil {
  6589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6590. return
  6591. }
  6592. recordEndTime := theEndTime.Unix()
  6593. end_time = recordEndTime
  6594. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6595. data["pre"] = prescriptions
  6596. }
  6597. client := &http.Client{}
  6598. data["psn_no"] = his.PsnNo
  6599. data["mdtrt_id"] = his.Number
  6600. data["chrg_bchno"] = chrg_bchno
  6601. data["org_name"] = miConfig.OrgName
  6602. data["doctor"] = roles.UserName
  6603. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6604. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6605. data["fixmedins_code"] = miConfig.Code
  6606. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6607. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6608. data["dept_code"] = "15"
  6609. } else {
  6610. data["dept_code"] = department.Number
  6611. }
  6612. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6613. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6614. data["secret_key"] = miConfig.SecretKey
  6615. data["url"] = miConfig.Url
  6616. data["ak"] = miConfig.AccessKey
  6617. data["new_doctor_name"] = patientPrescription.Doctor
  6618. data["diag_code"] = sickConfig.CountryCode
  6619. data["time_stamp"] = time_stamp
  6620. data["cainfo"] = miConfig.Cainfo
  6621. var ids []int64
  6622. for _, item := range prescriptions {
  6623. ids = append(ids, item.ID)
  6624. }
  6625. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6626. if config.IsOpen == 1 { //对接了医保,走医保流程
  6627. var res ResultFour
  6628. var resFour10265 ResultFour10265
  6629. if miConfig.MdtrtareaAdmvs == "421300" {
  6630. bytesData, _ := json.Marshal(data)
  6631. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6632. resp, _ := client.Do(req)
  6633. defer resp.Body.Close()
  6634. body, ioErr := ioutil.ReadAll(resp.Body)
  6635. if ioErr != nil {
  6636. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6638. return
  6639. }
  6640. var respJSON map[string]interface{}
  6641. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6644. return
  6645. }
  6646. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6647. userJSONBytes, _ := json.Marshal(respJSON)
  6648. fmt.Println("log")
  6649. fmt.Println(string(userJSONBytes))
  6650. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6651. utils.ErrorLog("解析失败:%v", err)
  6652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6653. return
  6654. }
  6655. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6656. bytesData, _ := json.Marshal(data)
  6657. var req *http.Request
  6658. if miConfig.MdtrtareaAdmvs == "320921" {
  6659. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6660. } else {
  6661. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6662. }
  6663. resp, _ := client.Do(req)
  6664. defer resp.Body.Close()
  6665. body, ioErr := ioutil.ReadAll(resp.Body)
  6666. if ioErr != nil {
  6667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6669. return
  6670. }
  6671. var respJSON map[string]interface{}
  6672. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6675. return
  6676. }
  6677. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6678. userJSONBytes, _ := json.Marshal(respJSON)
  6679. fmt.Println("log")
  6680. fmt.Println(string(userJSONBytes))
  6681. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6682. utils.ErrorLog("解析失败:%v", err)
  6683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6684. return
  6685. }
  6686. res.InfRefmsgid = resFour10265.InfRefmsgid
  6687. res.Output = resFour10265.Output
  6688. res.ErrMsg = resFour10265.ErrMsg
  6689. res.Cainfo = resFour10265.Cainfo
  6690. res.WarnMsg = resFour10265.WarnMsg
  6691. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6692. res.Infcode = infocode
  6693. } else {
  6694. if miConfig.Code == "H15049901371" {
  6695. 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)
  6696. var dat map[string]interface{}
  6697. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6698. fmt.Println(dat)
  6699. } else {
  6700. fmt.Println(err)
  6701. }
  6702. saveLog(result, request_log, "2204", "上传费用明细")
  6703. userJSONBytes, _ := json.Marshal(dat)
  6704. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6705. utils.ErrorLog("解析失败:%v", err)
  6706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6707. return
  6708. }
  6709. res.InfRefmsgid = resFour10265.InfRefmsgid
  6710. res.Output = resFour10265.Output
  6711. res.ErrMsg = resFour10265.ErrMsg
  6712. res.Cainfo = resFour10265.Cainfo
  6713. res.WarnMsg = resFour10265.WarnMsg
  6714. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6715. res.Infcode = infocode
  6716. } else {
  6717. 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)
  6718. var dat map[string]interface{}
  6719. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6720. fmt.Println(dat)
  6721. } else {
  6722. fmt.Println(err)
  6723. }
  6724. saveLog(result, request_log, "2204", "上传费用明细")
  6725. userJSONBytes, _ := json.Marshal(dat)
  6726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6727. utils.ErrorLog("解析失败:%v", err)
  6728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6729. return
  6730. }
  6731. }
  6732. }
  6733. if res.Infcode == 0 {
  6734. order := &models.HisOrder{
  6735. UserOrgId: adminUser.CurrentOrgId,
  6736. HisPatientId: his.ID,
  6737. PatientId: his.PatientId,
  6738. SettleAccountsDate: recordDateTime,
  6739. Ctime: time.Now().Unix(),
  6740. Mtime: time.Now().Unix(),
  6741. MdtrtId: his.Number,
  6742. PsnNo: his.PsnNo,
  6743. MedType: strconv.FormatInt(reg_type, 10),
  6744. Status: 1,
  6745. Number: chrg_bchno,
  6746. Infcode: res.Infcode,
  6747. WarnMsg: res.WarnMsg,
  6748. Cainfo: res.Cainfo,
  6749. ErrMsg: res.ErrMsg,
  6750. RespondTime: res.RefmsgTime,
  6751. InfRefmsgid: res.InfRefmsgid,
  6752. OrderStatus: 1,
  6753. IsMedicineInsurance: 1,
  6754. SettleType: settle_accounts_type,
  6755. SettleStartTime: start_time,
  6756. SettleEndTime: end_time,
  6757. Creator: roles.AdminUserId,
  6758. Modify: roles.AdminUserId,
  6759. PType: 2,
  6760. Diagnosis: diagnosis_id,
  6761. }
  6762. err = service.CreateOrder(order)
  6763. if err != nil {
  6764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6765. return
  6766. }
  6767. for _, item := range res.Output.Result {
  6768. temp := strings.Split(item.FeedetlSn, "-")
  6769. var advice_id int64 = 0
  6770. var project_id int64 = 0
  6771. var types int64 = 0
  6772. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6773. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6774. if temp[1] == "1" {
  6775. advice_id = id
  6776. project_id = 0
  6777. } else if temp[1] == "2" {
  6778. advice_id = 0
  6779. project_id = id
  6780. }
  6781. info := &models.HisOrderInfo{
  6782. OrderNumber: order.Number,
  6783. FeedetlSn: item.FeedetlSn,
  6784. UploadDate: time.Now().Unix(),
  6785. AdviceId: advice_id,
  6786. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6787. Cnt: item.Cnt,
  6788. Pric: float64(item.Pric),
  6789. PatientId: his.PatientId,
  6790. PricUplmtAmt: item.PricUplmtAmt,
  6791. SelfpayProp: item.SelfpayProp,
  6792. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6793. OverlmtAmt: item.OverlmtAmt,
  6794. PreselfpayAmt: item.PreselfpayAmt,
  6795. BasMednFlag: item.BasMednFlag,
  6796. MedChrgitmType: item.MedChrgitmType,
  6797. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6798. Status: 1,
  6799. Memo: item.Memo,
  6800. Mtime: time.Now().Unix(),
  6801. InscpScpAmt: item.InscpScpAmt,
  6802. DrtReimFlag: item.DrtReimFlag,
  6803. Ctime: time.Now().Unix(),
  6804. ListSpItemFlag: item.ListSpItemFlag,
  6805. ChldMedcFlag: item.ChldMedcFlag,
  6806. LmtUsedFlag: item.LmtUsedFlag,
  6807. ChrgitmLv: item.ChrgitmLv,
  6808. UserOrgId: adminUser.CurrentOrgId,
  6809. HisPatientId: his.ID,
  6810. OrderId: order.ID,
  6811. ProjectId: project_id,
  6812. Type: types,
  6813. }
  6814. service.CreateOrderInfo(info)
  6815. }
  6816. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6817. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6818. var total float64
  6819. for _, item := range prescriptions {
  6820. if item.Type == 1 { //药品
  6821. for _, subItem := range item.HisDoctorAdviceInfo {
  6822. total = total + (subItem.Price * subItem.PrescribingNumber)
  6823. }
  6824. }
  6825. if item.Type == 2 { //项目
  6826. for _, subItem := range item.HisPrescriptionProject {
  6827. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6828. total = total + (subItem.Price * cnt)
  6829. }
  6830. }
  6831. }
  6832. for _, item := range prescriptions {
  6833. for _, subItem := range item.HisAdditionalCharge {
  6834. total = total + (subItem.Price * float64(subItem.Count))
  6835. }
  6836. }
  6837. allTotal := fmt.Sprintf("%.4f", total)
  6838. if res.Infcode == 0 {
  6839. var rf []*ResultFive
  6840. json.Unmarshal([]byte(his.Iinfo), &rf)
  6841. chrg_bchno := chrg_bchno
  6842. cert_no := his.Certno
  6843. var insutypes []string
  6844. var insutype string
  6845. var is390 int = 0
  6846. var is310 int = 0
  6847. for _, item := range rf {
  6848. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6849. insutypes = append(insutypes, item.Insutype)
  6850. }
  6851. }
  6852. if len(insutypes) == 1 {
  6853. insutype = insutypes[0]
  6854. } else {
  6855. for _, i := range insutypes {
  6856. if i == "390" {
  6857. is390 = 1
  6858. }
  6859. if i == "310" {
  6860. is310 = 1
  6861. }
  6862. }
  6863. }
  6864. if is390 == 1 {
  6865. insutype = "390"
  6866. }
  6867. if is310 == 1 {
  6868. insutype = "310"
  6869. }
  6870. if len(insutypes) == 0 {
  6871. insutype = "310"
  6872. }
  6873. if len(insutypes) == 2 {
  6874. insutype = strconv.FormatInt(his.SocialType, 64)
  6875. }
  6876. //insutype = "390"
  6877. if his.IdCardType == 1 {
  6878. cert_no = his.MedicalInsuranceNumber
  6879. } else {
  6880. cert_no = his.Certno
  6881. }
  6882. var res ResultSeven
  6883. var resSeven10265 ResultSeven10265
  6884. if miConfig.MdtrtareaAdmvs == "421300" {
  6885. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6886. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6887. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6888. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6889. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6890. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6891. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6892. resp, requestErr := http.Get(api)
  6893. if requestErr != nil {
  6894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6895. return
  6896. }
  6897. body, ioErr := ioutil.ReadAll(resp.Body)
  6898. if ioErr != nil {
  6899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6901. return
  6902. }
  6903. var respJSON map[string]interface{}
  6904. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6907. return
  6908. }
  6909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6910. result, _ := json.Marshal(respJSON)
  6911. fmt.Println("log")
  6912. fmt.Println(string(result))
  6913. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6914. utils.ErrorLog("解析失败:%v", err)
  6915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6916. return
  6917. }
  6918. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6919. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6920. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6921. bas := strings.Split(psn_info.CardInfo, "|")
  6922. if his.IdCardType == 1 {
  6923. cert_no = bas[2]
  6924. } else {
  6925. cert_no = bas[1]
  6926. }
  6927. //江苏地区国家医保医疗类别
  6928. //职工透析:医疗类别选特殊情况门诊9933
  6929. //居民血透门慢: 医疗类别选门诊慢病1402
  6930. //var med_type string
  6931. //if his.Insutype == "310" {
  6932. // if reg_type == 14 {
  6933. // med_type = "9933"
  6934. // } else if reg_type == 11 {
  6935. // med_type = "11"
  6936. //
  6937. // }
  6938. //} else if his.Insutype == "390" {
  6939. // if reg_type == 14 {
  6940. // med_type = "1402"
  6941. // } else if reg_type == 11 {
  6942. // med_type = "11"
  6943. // }
  6944. //}
  6945. var api string
  6946. if miConfig.MdtrtareaAdmvs == "320921" {
  6947. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6948. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6949. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6950. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6951. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6952. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6953. "&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
  6954. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6955. } else {
  6956. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6957. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6958. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6959. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6960. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6961. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6962. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6963. "&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
  6964. }
  6965. resp, requestErr := http.Get(api)
  6966. if requestErr != nil {
  6967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6968. return
  6969. }
  6970. body, ioErr := ioutil.ReadAll(resp.Body)
  6971. if ioErr != nil {
  6972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6974. return
  6975. }
  6976. var respJSON map[string]interface{}
  6977. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6980. return
  6981. }
  6982. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6983. result, _ := json.Marshal(respJSON)
  6984. fmt.Println("log")
  6985. fmt.Println(string(result))
  6986. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6987. utils.ErrorLog("解析失败:%v", err)
  6988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6989. return
  6990. }
  6991. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6992. res.Output = resSeven10265.Output
  6993. res.ErrMsg = resSeven10265.ErrMsg
  6994. res.Cainfo = resSeven10265.Cainfo
  6995. res.WarnMsg = resSeven10265.WarnMsg
  6996. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6997. res.Infcode = infocode
  6998. } else {
  6999. var result string
  7000. var request_log string
  7001. if miConfig.Code == "H15049901371" {
  7002. //赤峰地区国家医保医疗类别
  7003. //职工透析:医疗类别选特殊情况门诊990502
  7004. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7005. var med_type string
  7006. if his.Insutype == "390" {
  7007. if reg_type == 14 {
  7008. med_type = "9933"
  7009. } else if reg_type == 11 {
  7010. med_type = "11"
  7011. }
  7012. } else if his.Insutype == "310" {
  7013. if reg_type == 14 {
  7014. med_type = "990502"
  7015. } else if reg_type == 11 {
  7016. med_type = "11"
  7017. }
  7018. }
  7019. 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)
  7020. } else {
  7021. 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)
  7022. }
  7023. var dat map[string]interface{}
  7024. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7025. fmt.Println(dat)
  7026. } else {
  7027. fmt.Println(err)
  7028. }
  7029. saveLog(result, request_log, "2206", "预结算")
  7030. //userJSONBytes, _ := json.Marshal(dat)
  7031. //
  7032. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7033. // utils.ErrorLog("解析失败:%v", err)
  7034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7035. // return
  7036. //}
  7037. userJSONBytes, _ := json.Marshal(dat)
  7038. if miConfig.Code == "H15049901371" {
  7039. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7040. utils.ErrorLog("解析失败:%v", err)
  7041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7042. return
  7043. }
  7044. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7045. res.Output = resSeven10265.Output
  7046. res.ErrMsg = resSeven10265.ErrMsg
  7047. res.Cainfo = resSeven10265.Cainfo
  7048. res.WarnMsg = resSeven10265.WarnMsg
  7049. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7050. res.Infcode = infocode
  7051. } else {
  7052. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7053. utils.ErrorLog("解析失败:%v", err)
  7054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7055. return
  7056. }
  7057. }
  7058. }
  7059. if res.Infcode != 0 {
  7060. errlog := &models.HisOrderError{
  7061. UserOrgId: adminUser.CurrentOrgId,
  7062. Ctime: time.Now().Unix(),
  7063. Mtime: time.Now().Unix(),
  7064. Number: chrg_bchno,
  7065. ErrMsg: res.ErrMsg,
  7066. Status: 1,
  7067. PatientId: id,
  7068. RecordTime: recordDateTime,
  7069. Stage: 20,
  7070. }
  7071. service.CreateErrMsgLog(errlog)
  7072. c.ServeSuccessJSON(map[string]interface{}{
  7073. "failed_code": -10,
  7074. "msg": res.ErrMsg,
  7075. })
  7076. return
  7077. } else {
  7078. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7079. order.OrderStatus = 1
  7080. order.IsPre = 1
  7081. order.Status = 1
  7082. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7083. order.SetlId = res.Output.Setlinfo.SetlID
  7084. order.PsnNo = res.Output.Setlinfo.PsnNo
  7085. order.PsnName = res.Output.Setlinfo.PsnName
  7086. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7087. order.Certno = res.Output.Setlinfo.Certno
  7088. order.Gend = res.Output.Setlinfo.Gend
  7089. order.Naty = res.Output.Setlinfo.Naty
  7090. order.Age = res.Output.Setlinfo.Age
  7091. order.Insutype = res.Output.Setlinfo.Insutype
  7092. order.PsnType = res.Output.Setlinfo.PsnType
  7093. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7094. order.SetlTime = res.Output.Setlinfo.SetlTime
  7095. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7096. if res.Output.Setlinfo.MedType == "140101" {
  7097. order.MedType = "14"
  7098. } else {
  7099. order.MedType = res.Output.Setlinfo.MedType
  7100. }
  7101. if reg_type == 1112 {
  7102. order.MedType = "1112"
  7103. }
  7104. if reg_type == 1111 {
  7105. order.MedType = "1111"
  7106. }
  7107. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7108. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7109. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7110. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7111. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7112. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7113. order.HifpPay = res.Output.Setlinfo.HifpPay
  7114. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7115. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7116. order.HifesPay = res.Output.Setlinfo.HifesPay
  7117. order.HifobPay = res.Output.Setlinfo.HifobPay
  7118. order.MafPay = res.Output.Setlinfo.MafPay
  7119. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7120. order.OthPay = res.Output.Setlinfo.OthPay
  7121. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7122. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7123. order.AcctPay = res.Output.Setlinfo.AcctPay
  7124. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7125. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7126. order.Balc = res.Output.Setlinfo.Balc
  7127. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7128. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7129. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7130. order.ClrWay = res.Output.Setlinfo.ClrWay
  7131. order.Creator = order.Creator
  7132. order.Modify = roles.AdminUserId
  7133. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7134. detailStr := string(setlDetail)
  7135. order.SetlDetail = detailStr
  7136. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7137. err = service.UpDateOrder(order)
  7138. if err == nil {
  7139. c.ServeSuccessJSON(map[string]interface{}{
  7140. "msg": "预结算成功",
  7141. })
  7142. } else {
  7143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7144. return
  7145. }
  7146. }
  7147. } else {
  7148. adminUser := c.GetAdminUserInfo()
  7149. errlog := &models.HisOrderError{
  7150. UserOrgId: adminUser.CurrentOrgId,
  7151. Ctime: time.Now().Unix(),
  7152. Mtime: time.Now().Unix(),
  7153. ErrMsg: res.ErrMsg,
  7154. Status: 1,
  7155. PatientId: id,
  7156. RecordTime: recordDateTime,
  7157. Stage: 4,
  7158. }
  7159. service.CreateErrMsgLog(errlog)
  7160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7161. return
  7162. }
  7163. } else {
  7164. adminUser := c.GetAdminUserInfo()
  7165. errlog := &models.HisOrderError{
  7166. UserOrgId: adminUser.CurrentOrgId,
  7167. Ctime: time.Now().Unix(),
  7168. Mtime: time.Now().Unix(),
  7169. ErrMsg: res.ErrMsg,
  7170. Status: 1,
  7171. PatientId: id,
  7172. RecordTime: recordDateTime,
  7173. Stage: 4,
  7174. }
  7175. service.CreateErrMsgLog(errlog)
  7176. c.ServeSuccessJSON(map[string]interface{}{
  7177. "failed_code": -10,
  7178. "msg": res.ErrMsg,
  7179. })
  7180. return
  7181. }
  7182. }
  7183. }
  7184. }
  7185. //func (c *HisApiController) GetSettleInfo() {
  7186. // id, _ := c.GetInt64("id")
  7187. // order_id, _ := c.GetInt64("order_id")
  7188. //
  7189. // record_time := c.GetString("record_time")
  7190. // pay_way, _ := c.GetInt64("pay_way")
  7191. // pay_price, _ := c.GetFloat("pay_price")
  7192. // pay_card_no := c.GetString("pay_card_no")
  7193. // discount_price, _ := c.GetFloat("discount_price")
  7194. // preferential_price, _ := c.GetFloat("preferential_price")
  7195. // reality_price, _ := c.GetFloat("reality_price")
  7196. // found_price, _ := c.GetFloat("found_price")
  7197. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7198. // private_price, _ := c.GetFloat("private_price")
  7199. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7200. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7201. //
  7202. // timeLayout := "2006-01-02"
  7203. // loc, _ := time.LoadLocation("Local")
  7204. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7205. // if err != nil {
  7206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7207. // return
  7208. // }
  7209. // recordDateTime := theTime.Unix()
  7210. // adminUser := c.GetAdminUserInfo()
  7211. //
  7212. // var prescriptions []*models.HisPrescription
  7213. //
  7214. // data := make(map[string]interface{})
  7215. // if settle_accounts_type == 1 { //日结
  7216. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7217. // data["pre"] = prescriptions
  7218. //
  7219. // } else { //月结
  7220. // start_time_str := c.GetString("start_time")
  7221. // end_time_str := c.GetString("end_time")
  7222. // timeLayout := "2006-01-02"
  7223. // loc, _ := time.LoadLocation("Local")
  7224. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7225. // if err != nil {
  7226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7227. // return
  7228. // }
  7229. // recordStartTime := theStartTime.Unix()
  7230. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7231. // if err != nil {
  7232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7233. // return
  7234. // }
  7235. // recordEndTime := theEndTime.Unix()
  7236. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7237. // data["pre"] = prescriptions
  7238. //
  7239. // }
  7240. //
  7241. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7242. //
  7243. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7244. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7245. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7246. // strconv.FormatInt(his.PatientId, 10)
  7247. //
  7248. // order_src, _ := service.GetHisOrderByID(order_id)
  7249. //
  7250. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7251. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7252. //
  7253. // var total float64
  7254. // for _, item := range prescriptions {
  7255. // if item.Type == 1 { //药品
  7256. // for _, subItem := range item.HisDoctorAdviceInfo {
  7257. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7258. // }
  7259. // }
  7260. // if item.Type == 2 { //项目
  7261. // for _, subItem := range item.HisPrescriptionProject {
  7262. // total = total + (subItem.Price * float64(subItem.Count))
  7263. // }
  7264. // }
  7265. // }
  7266. //
  7267. // for _, item := range prescriptions {
  7268. // for _, subItem := range item.HisAdditionalCharge {
  7269. // total = total + (subItem.Price * float64(subItem.Count))
  7270. // }
  7271. // }
  7272. //
  7273. // allTotal := fmt.Sprintf("%.2f", total)
  7274. // var rf []*ResultFive
  7275. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7276. // psn_no := order_src.PsnNo
  7277. // mdtrt_id := order_src.MdtrtId
  7278. // chrg_bchno := order_src.Number
  7279. // cert_no := order_src.Certno
  7280. // insutype := rf[0].Insutype
  7281. //
  7282. // if his.IdCardType == 1 {
  7283. // cert_no = his.MedicalInsuranceNumber
  7284. // } else {
  7285. // cert_no = his.Certno
  7286. // }
  7287. //
  7288. // 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)
  7289. // var dat map[string]interface{}
  7290. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7291. // fmt.Println(dat)
  7292. // } else {
  7293. // fmt.Println(err)
  7294. // }
  7295. //
  7296. // userJSONBytes, _ := json.Marshal(dat)
  7297. //
  7298. //
  7299. //
  7300. // var res ResultSeven
  7301. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7302. // utils.ErrorLog("解析失败:%v", err)
  7303. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7304. // return
  7305. // }
  7306. // if res.Infcode == -1 {
  7307. // errlog := &models.HisOrderError{
  7308. // UserOrgId: adminUser.CurrentOrgId,
  7309. // Ctime: time.Now().Unix(),
  7310. // Mtime: time.Now().Unix(),
  7311. // Number: chrg_bchno,
  7312. // ErrMsg: res.ErrMsg,
  7313. // Status: 1,
  7314. // PatientId: id,
  7315. // RecordTime: recordDateTime,
  7316. // Stage: 6,
  7317. // }
  7318. // service.CreateErrMsgLog(errlog)
  7319. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7320. // return
  7321. // } else {
  7322. // order_src.OrderStatus = 2
  7323. // order_src.PayWay = pay_way
  7324. // order_src.PayPrice = pay_price
  7325. // order_src.PayCardNo = pay_card_no
  7326. // order_src.DiscountPrice = discount_price
  7327. // order_src.PreferentialPrice = preferential_price
  7328. // order_src.RealityPrice = reality_price
  7329. // order_src.FoundPrice = found_price
  7330. // order_src.MedicalInsurancePrice = medical_insurance_price
  7331. // order_src.PrivatePrice = private_price
  7332. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7333. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7334. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7335. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7336. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7337. // order_src.Certno = res.Output.Setlinfo.Certno
  7338. // order_src.Gend = res.Output.Setlinfo.Gend
  7339. // order_src.Naty = res.Output.Setlinfo.Naty
  7340. // order_src.Age = res.Output.Setlinfo.Age
  7341. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7342. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7343. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7344. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7345. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7346. // order_src.MedType = res.Output.Setlinfo.MedType
  7347. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7348. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7349. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7350. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7351. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7352. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7353. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7354. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7355. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7356. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7357. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7358. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7359. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7360. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7361. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7362. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7363. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7364. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7365. // order_src.Balc = res.Output.Setlinfo.Balc
  7366. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7367. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7368. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7369. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7370. // order_src.Creator = order_src.Creator
  7371. // order_src.Modify = roles.ID
  7372. // order_src.RequestLog = src_resquest
  7373. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7374. // detailStr := string(setlDetail)
  7375. // order_src.SetlDetail = detailStr
  7376. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7377. // err = service.UpDateOrder(order_src)
  7378. //
  7379. // if err == nil {
  7380. // c.ServeSuccessJSON(map[string]interface{}{
  7381. // "msg": "结算成功",
  7382. // })
  7383. // } else {
  7384. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7385. // return
  7386. // }
  7387. // }
  7388. // }
  7389. //}
  7390. //退款
  7391. func (c *HisApiController) Refund() {
  7392. order_id, _ := c.GetInt64("order_id")
  7393. admin_user_id, _ := c.GetInt64("admin_user_id")
  7394. adminUser := c.GetAdminUserInfo()
  7395. var order models.HisOrder
  7396. order, _ = service.GetHisOrderByID(order_id)
  7397. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7398. if order.ID == 0 {
  7399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7400. return
  7401. }
  7402. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7403. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7404. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7405. if config.IsOpen == 1 { //对接了医保,走医保流程
  7406. var res ResultSixteen
  7407. var resSixteen10265 ResultSixteen10265
  7408. var src_resquest string
  7409. var result string
  7410. if miConfig.MdtrtareaAdmvs == "421300" {
  7411. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7412. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7413. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7414. resp3, requestErr3 := http.Get(api3)
  7415. if requestErr3 != nil {
  7416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7417. return
  7418. }
  7419. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7420. if ioErr3 != nil {
  7421. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7423. return
  7424. }
  7425. var respJSON3 map[string]interface{}
  7426. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7429. return
  7430. }
  7431. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7432. userJSONBytes3, _ := json.Marshal(respJSON3)
  7433. fmt.Println("log")
  7434. fmt.Println(string(userJSONBytes3))
  7435. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7436. utils.ErrorLog("解析失败:%v", err)
  7437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7438. return
  7439. }
  7440. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7441. var api3 string
  7442. if miConfig.MdtrtareaAdmvs == "320921" {
  7443. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7444. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7445. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7446. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7447. } else {
  7448. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7449. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7450. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7451. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7452. }
  7453. resp3, requestErr3 := http.Get(api3)
  7454. if requestErr3 != nil {
  7455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7456. return
  7457. }
  7458. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7459. if ioErr3 != nil {
  7460. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7462. return
  7463. }
  7464. var respJSON3 map[string]interface{}
  7465. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7466. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7468. return
  7469. }
  7470. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7471. userJSONBytes3, _ := json.Marshal(respJSON3)
  7472. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7473. utils.ErrorLog("解析失败:%v", err)
  7474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7475. return
  7476. }
  7477. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7478. res.Output = resSixteen10265.Output
  7479. res.ErrMsg = resSixteen10265.ErrMsg
  7480. res.Cainfo = resSixteen10265.Cainfo
  7481. res.WarnMsg = resSixteen10265.WarnMsg
  7482. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7483. res.Infcode = infocode
  7484. } else {
  7485. if miConfig.Code == "H15049901371" {
  7486. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7487. var dat map[string]interface{}
  7488. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7489. fmt.Println(dat)
  7490. } else {
  7491. fmt.Println(err)
  7492. }
  7493. saveLog(result, src_resquest, "2208", "退费")
  7494. userJSONBytes, _ := json.Marshal(dat)
  7495. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7496. utils.ErrorLog("解析失败:%v", err)
  7497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7498. return
  7499. }
  7500. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7501. res.Output = resSixteen10265.Output
  7502. res.ErrMsg = resSixteen10265.ErrMsg
  7503. res.Cainfo = resSixteen10265.Cainfo
  7504. res.WarnMsg = resSixteen10265.WarnMsg
  7505. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7506. res.Infcode = infocode
  7507. } else {
  7508. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7509. var dat map[string]interface{}
  7510. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7511. fmt.Println(dat)
  7512. } else {
  7513. fmt.Println(err)
  7514. }
  7515. saveLog(result, src_resquest, "2208", "退费")
  7516. userJSONBytes, _ := json.Marshal(dat)
  7517. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7518. utils.ErrorLog("解析失败:%v", err)
  7519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7520. return
  7521. }
  7522. }
  7523. }
  7524. if res.Infcode == 0 {
  7525. var res2 ResultSix
  7526. var resSix10265 ResultSix10265
  7527. if miConfig.MdtrtareaAdmvs == "421300" {
  7528. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7529. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7530. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7531. resp3, requestErr3 := http.Get(api3)
  7532. if requestErr3 != nil {
  7533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7534. return
  7535. }
  7536. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7537. if ioErr3 != nil {
  7538. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7540. return
  7541. }
  7542. var respJSON3 map[string]interface{}
  7543. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7544. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7546. return
  7547. }
  7548. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7549. userJSONBytes3, _ := json.Marshal(respJSON3)
  7550. fmt.Println("log")
  7551. fmt.Println(string(userJSONBytes3))
  7552. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7553. utils.ErrorLog("解析失败:%v", err)
  7554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7555. return
  7556. }
  7557. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7558. var api3 string
  7559. if miConfig.MdtrtareaAdmvs == "320921" {
  7560. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7561. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7562. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7563. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7564. } else {
  7565. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7566. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7567. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7568. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7569. }
  7570. resp3, requestErr3 := http.Get(api3)
  7571. if requestErr3 != nil {
  7572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7573. return
  7574. }
  7575. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7576. if ioErr3 != nil {
  7577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7579. return
  7580. }
  7581. var respJSON3 map[string]interface{}
  7582. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7585. return
  7586. }
  7587. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7588. userJSONBytes3, _ := json.Marshal(respJSON3)
  7589. fmt.Println("log")
  7590. fmt.Println(string(userJSONBytes3))
  7591. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7592. utils.ErrorLog("解析失败:%v", err)
  7593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7594. return
  7595. }
  7596. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7597. res2.Output = resSix10265.Output
  7598. res2.ErrMsg = resSix10265.ErrMsg
  7599. res2.Cainfo = resSix10265.Cainfo
  7600. res2.WarnMsg = resSix10265.WarnMsg
  7601. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7602. res2.Infcode = infocode
  7603. } else {
  7604. if miConfig.Code == "H15049901371" {
  7605. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7606. var dat map[string]interface{}
  7607. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7608. fmt.Println(dat)
  7609. } else {
  7610. fmt.Println(err)
  7611. }
  7612. saveLog(result2, src_request, "2205", "撤销明细")
  7613. userJSONBytes, _ := json.Marshal(dat)
  7614. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7615. utils.ErrorLog("解析失败:%v", err)
  7616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7617. return
  7618. }
  7619. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7620. res2.Output = resSix10265.Output
  7621. res2.ErrMsg = resSix10265.ErrMsg
  7622. res2.Cainfo = resSix10265.Cainfo
  7623. res2.WarnMsg = resSix10265.WarnMsg
  7624. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7625. res2.Infcode = infocode
  7626. } else {
  7627. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7628. var dat map[string]interface{}
  7629. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7630. fmt.Println(dat)
  7631. } else {
  7632. fmt.Println(err)
  7633. }
  7634. saveLog(result2, src_request, "2205", "撤销明细")
  7635. userJSONBytes, _ := json.Marshal(dat)
  7636. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7637. utils.ErrorLog("解析失败:%v", err)
  7638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7639. return
  7640. }
  7641. }
  7642. }
  7643. if res2.Infcode == 0 {
  7644. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7645. if err == nil {
  7646. c.ServeSuccessJSON(map[string]interface{}{
  7647. "msg": "退费成功",
  7648. })
  7649. } else {
  7650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7651. return
  7652. }
  7653. } else {
  7654. c.ServeSuccessJSON(map[string]interface{}{
  7655. "code": -10,
  7656. "msg": res2.ErrMsg,
  7657. })
  7658. }
  7659. } else {
  7660. c.ServeSuccessJSON(map[string]interface{}{
  7661. "code": -10,
  7662. "msg": res.ErrMsg,
  7663. })
  7664. }
  7665. }
  7666. }
  7667. func (c *HisApiController) RefundNumber() {
  7668. record_time := c.GetString("record_time")
  7669. //patient_id, _ := c.GetInt64("patient_id")
  7670. admin_user_id, _ := c.GetInt64("admin_user_id")
  7671. his_patient_id, _ := c.GetInt64("id")
  7672. timeLayout := "2006-01-02"
  7673. loc, _ := time.LoadLocation("Local")
  7674. adminUser := c.GetAdminUserInfo()
  7675. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7676. fmt.Println(err)
  7677. if err != nil {
  7678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7679. return
  7680. }
  7681. recordDateTime := theTime.Unix()
  7682. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7683. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7684. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7685. //order, _ := service.GetHisOrderByID(order_id)
  7686. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7687. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7688. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7689. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7690. if count > 0 {
  7691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7692. return
  7693. }
  7694. if config.IsOpen == 1 { //对接了医保,走医保流程
  7695. var res2 ResultSix
  7696. var resSix10265 ResultSix10265
  7697. if miConfig.MdtrtareaAdmvs == "421300" {
  7698. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7699. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7700. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7701. resp3, requestErr3 := http.Get(api3)
  7702. if requestErr3 != nil {
  7703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7704. return
  7705. }
  7706. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7707. if ioErr3 != nil {
  7708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7710. return
  7711. }
  7712. var respJSON3 map[string]interface{}
  7713. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7716. return
  7717. }
  7718. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7719. userJSONBytes3, _ := json.Marshal(respJSON3)
  7720. fmt.Println("log")
  7721. fmt.Println(string(userJSONBytes3))
  7722. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7723. utils.ErrorLog("解析失败:%v", err)
  7724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7725. return
  7726. }
  7727. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7728. var api3 string
  7729. if miConfig.MdtrtareaAdmvs == "320921" {
  7730. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7731. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7732. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7733. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7734. } else {
  7735. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7736. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7737. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7738. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7739. }
  7740. resp3, requestErr3 := http.Get(api3)
  7741. if requestErr3 != nil {
  7742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7743. return
  7744. }
  7745. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7746. if ioErr3 != nil {
  7747. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7749. return
  7750. }
  7751. var respJSON3 map[string]interface{}
  7752. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7755. return
  7756. }
  7757. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7758. userJSONBytes3, _ := json.Marshal(respJSON3)
  7759. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7760. utils.ErrorLog("解析失败:%v", err)
  7761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7762. return
  7763. }
  7764. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7765. res2.Output = resSix10265.Output
  7766. res2.ErrMsg = resSix10265.ErrMsg
  7767. res2.Cainfo = resSix10265.Cainfo
  7768. res2.WarnMsg = resSix10265.WarnMsg
  7769. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7770. res2.Infcode = infocode
  7771. } else {
  7772. var api3 string
  7773. if miConfig.Code == "H15049901371" {
  7774. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7775. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7776. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7777. } else {
  7778. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7779. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7780. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7781. }
  7782. resp3, requestErr3 := http.Get(api3)
  7783. if requestErr3 != nil {
  7784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7785. return
  7786. }
  7787. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7788. if ioErr3 != nil {
  7789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7791. return
  7792. }
  7793. var respJSON3 map[string]interface{}
  7794. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7797. return
  7798. }
  7799. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7800. userJSONBytes3, _ := json.Marshal(respJSON3)
  7801. if miConfig.Code == "H15049901371" {
  7802. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7803. utils.ErrorLog("解析失败:%v", err)
  7804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7805. return
  7806. }
  7807. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7808. res2.Output = resSix10265.Output
  7809. res2.ErrMsg = resSix10265.ErrMsg
  7810. res2.Cainfo = resSix10265.Cainfo
  7811. res2.WarnMsg = resSix10265.WarnMsg
  7812. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7813. res2.Infcode = infocode
  7814. } else {
  7815. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7816. utils.ErrorLog("解析失败:%v", err)
  7817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7818. return
  7819. }
  7820. }
  7821. }
  7822. if res2.Infcode == 0 {
  7823. if err == nil {
  7824. c.ServeSuccessJSON(map[string]interface{}{
  7825. "msg": "退号成功",
  7826. })
  7827. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7828. } else {
  7829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7830. return
  7831. }
  7832. } else {
  7833. c.ServeSuccessJSON(map[string]interface{}{
  7834. "code": -10,
  7835. "msg": res2.ErrMsg,
  7836. })
  7837. }
  7838. } else {
  7839. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7840. //if err == nil {
  7841. // c.ServeSuccessJSON(map[string]interface{}{
  7842. // "msg": "退费成功",
  7843. // })
  7844. //} else {
  7845. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7846. // return
  7847. //}
  7848. }
  7849. }
  7850. func (c *HisApiController) RefundDetail() {
  7851. order_id, _ := c.GetInt64("order_id")
  7852. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7853. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7854. number := c.GetString("number")
  7855. record_time := c.GetString("record_time")
  7856. patient_id, _ := c.GetInt64("patient_id")
  7857. //med_type, _ := c.GetInt64("med_type")
  7858. timeLayout := "2006-01-02"
  7859. loc, _ := time.LoadLocation("Local")
  7860. adminUser := c.GetAdminUserInfo()
  7861. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7862. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7863. fmt.Println(err)
  7864. if err != nil {
  7865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7866. return
  7867. }
  7868. recordDateTime := theTime.Unix()
  7869. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7870. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7871. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7872. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7873. var order models.HisOrder
  7874. order, _ = service.GetHisOrderByID(order_id)
  7875. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7876. if config.IsOpen == 1 { //对接了医保,走医保流程
  7877. var res2 ResultSix
  7878. if miConfig.MdtrtareaAdmvs == "421300" {
  7879. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7880. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7881. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7882. resp3, requestErr3 := http.Get(api3)
  7883. if requestErr3 != nil {
  7884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7885. return
  7886. }
  7887. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7888. if ioErr3 != nil {
  7889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7891. return
  7892. }
  7893. var respJSON3 map[string]interface{}
  7894. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7897. return
  7898. }
  7899. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7900. userJSONBytes3, _ := json.Marshal(respJSON3)
  7901. fmt.Println("log")
  7902. fmt.Println(string(userJSONBytes3))
  7903. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7904. utils.ErrorLog("解析失败:%v", err)
  7905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7906. return
  7907. }
  7908. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7909. if err == nil {
  7910. c.ServeSuccessJSON(map[string]interface{}{
  7911. "msg": "撤销明细成功",
  7912. })
  7913. return
  7914. } else {
  7915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7916. return
  7917. }
  7918. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7919. var resSix10265 ResultSix10265
  7920. var api3 string
  7921. if miConfig.MdtrtareaAdmvs == "320921" {
  7922. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7923. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7924. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7925. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7926. } else {
  7927. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7928. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7929. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7930. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7931. }
  7932. resp3, requestErr3 := http.Get(api3)
  7933. if requestErr3 != nil {
  7934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7935. return
  7936. }
  7937. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7938. if ioErr3 != nil {
  7939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7941. return
  7942. }
  7943. var respJSON3 map[string]interface{}
  7944. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7947. return
  7948. }
  7949. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7950. userJSONBytes3, _ := json.Marshal(respJSON3)
  7951. fmt.Println("log")
  7952. fmt.Println(string(userJSONBytes3))
  7953. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7954. utils.ErrorLog("解析失败:%v", err)
  7955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7956. return
  7957. }
  7958. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7959. res2.Output = resSix10265.Output
  7960. res2.ErrMsg = resSix10265.ErrMsg
  7961. res2.Cainfo = resSix10265.Cainfo
  7962. res2.WarnMsg = resSix10265.WarnMsg
  7963. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7964. res2.Infcode = infocode
  7965. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7966. if err == nil {
  7967. c.ServeSuccessJSON(map[string]interface{}{
  7968. "msg": "撤销明细成功",
  7969. })
  7970. return
  7971. } else {
  7972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7973. return
  7974. }
  7975. } else {
  7976. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7977. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7978. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7979. resp2, requestErr2 := http.Get(api2)
  7980. if requestErr2 != nil {
  7981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7982. return
  7983. }
  7984. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7985. if ioErr2 != nil {
  7986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7988. return
  7989. }
  7990. var respJSON2 map[string]interface{}
  7991. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7994. return
  7995. }
  7996. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7997. if err == nil {
  7998. c.ServeSuccessJSON(map[string]interface{}{
  7999. "msg": "撤销明细成功",
  8000. })
  8001. return
  8002. } else {
  8003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8004. return
  8005. }
  8006. }
  8007. } else {
  8008. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8009. if err == nil {
  8010. c.ServeSuccessJSON(map[string]interface{}{
  8011. "msg": "退费成功",
  8012. })
  8013. } else {
  8014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8015. return
  8016. }
  8017. }
  8018. }
  8019. //对账
  8020. func (c *HisApiController) GetCheckAccount() {
  8021. start_time := c.GetString("start_time")
  8022. end_time := c.GetString("end_time")
  8023. insutype := c.GetString("insutype")
  8024. clr_type := c.GetString("clr_type")
  8025. clr_org := c.GetString("clr_optins")
  8026. admin_user_id, _ := c.GetInt64("admin_user_id")
  8027. adminUser := c.GetAdminUserInfo()
  8028. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8029. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8030. if len(clr_org) == 0 {
  8031. clr_org = miConfig.MdtrtareaAdmvs
  8032. }
  8033. timeLayout := "2006-01-02"
  8034. loc, _ := time.LoadLocation("Local")
  8035. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8036. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8037. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  8038. fixmedins_setl_cnt := int64(len(orders))
  8039. var medfee_sumamt float64
  8040. var acct_pay float64
  8041. var fund_pay_sumamt float64
  8042. for _, item := range orders {
  8043. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8044. acct_pay = acct_pay + item.AcctPay
  8045. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8046. }
  8047. var user_name string
  8048. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8049. if role.ID == 0 {
  8050. user_name = "xxx"
  8051. } else {
  8052. user_name = role.UserName
  8053. }
  8054. var res ResultEight
  8055. var res10188 ResultEightFor10188
  8056. if config.IsOpen == 1 {
  8057. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8058. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8059. "insutype=" + insutype +
  8060. "&clr_type=" + "11" +
  8061. "&setl_optins=" + clr_org +
  8062. "&stmt_begndate=" + start_time +
  8063. "&stm_enddate=" + end_time +
  8064. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8065. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8066. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8067. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8068. "&fixmedins_code=" + miConfig.Code +
  8069. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8070. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8071. "&secret_key=" + miConfig.SecretKey +
  8072. "&org_name=" + miConfig.OrgName +
  8073. "&doctor=" + user_name +
  8074. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8075. fmt.Println(api)
  8076. resp, requestErr := http.Get(api)
  8077. if requestErr != nil {
  8078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8079. return
  8080. }
  8081. body, ioErr := ioutil.ReadAll(resp.Body)
  8082. fmt.Println(body)
  8083. if ioErr != nil {
  8084. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8086. return
  8087. }
  8088. var respJSON map[string]interface{}
  8089. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8092. return
  8093. }
  8094. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8095. userJSONBytes, _ := json.Marshal(respJSON)
  8096. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8097. utils.ErrorLog("解析失败:%v", err)
  8098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8099. return
  8100. }
  8101. res.InfRefmsgid = res10188.InfRefmsgid
  8102. res.Output = res10188.Output
  8103. res.ErrMsg = res10188.ErrMsg
  8104. res.Cainfo = res10188.Cainfo
  8105. res.WarnMsg = res10188.WarnMsg
  8106. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8107. res.Infcode = infocode
  8108. } else {
  8109. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8110. "insutype=" + insutype +
  8111. "&clr_type=" + clr_type +
  8112. "&setl_optins=" + clr_org +
  8113. "&stmt_begndate=" + start_time +
  8114. "&stm_enddate=" + end_time +
  8115. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8116. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8117. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8118. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8119. "&fixmedins_code=" + miConfig.Code +
  8120. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8121. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8122. "&secret_key=" + miConfig.SecretKey +
  8123. "&org_name=" + miConfig.OrgName +
  8124. "&doctor=" + user_name
  8125. fmt.Println(api)
  8126. resp, requestErr := http.Get(api)
  8127. if requestErr != nil {
  8128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8129. return
  8130. }
  8131. body, ioErr := ioutil.ReadAll(resp.Body)
  8132. fmt.Println(body)
  8133. if ioErr != nil {
  8134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8136. return
  8137. }
  8138. var respJSON map[string]interface{}
  8139. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8142. return
  8143. }
  8144. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8145. userJSONBytes, _ := json.Marshal(respJSON)
  8146. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8147. utils.ErrorLog("解析失败:%v", err)
  8148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8149. return
  8150. }
  8151. }
  8152. if res.Infcode == 0 {
  8153. if res.Output.Stmtinfo.StmtRslt == "0" {
  8154. micc := &models.MedicalInsuranceCostCompare{
  8155. StartTime: startime.Unix(),
  8156. EndTime: endtime.Unix(),
  8157. Insutype: insutype,
  8158. CheckType: 1,
  8159. Num: fixmedins_setl_cnt,
  8160. Mtime: time.Now().Unix(),
  8161. Status: 1,
  8162. UserOrgId: adminUser.CurrentOrgId,
  8163. CostTotal: medfee_sumamt,
  8164. FuncTotal: fund_pay_sumamt,
  8165. PsnPay: acct_pay,
  8166. Creator: admin_user_id,
  8167. Ctime: time.Now().Unix(),
  8168. ClrType: clr_type,
  8169. }
  8170. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8171. if err == nil {
  8172. c.ServeSuccessJSON(map[string]interface{}{
  8173. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8174. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8175. })
  8176. } else {
  8177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8178. }
  8179. } else {
  8180. c.ServeSuccessJSON(map[string]interface{}{
  8181. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8182. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8183. })
  8184. }
  8185. } else {
  8186. c.ServeSuccessJSON(map[string]interface{}{
  8187. "code": -10,
  8188. "msg": res.ErrMsg,
  8189. })
  8190. }
  8191. }
  8192. }
  8193. func (c *HisApiController) Check310() {
  8194. adminUser := c.GetAdminUserInfo()
  8195. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8196. var user_name string
  8197. user_name = "高慧裕"
  8198. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8199. "insutype=" + "310" +
  8200. "&clr_type=" + "" +
  8201. "&setl_optins=" + "441202" +
  8202. "&stmt_begndate=" + "2022-03-01" +
  8203. "&stm_enddate=" + "2022-03-31" +
  8204. "&medfee_sumamt=" + "194930.12" +
  8205. "&fund_pay_sumamt=" + "188741.46" +
  8206. "&acct_pay=" + "0" +
  8207. "&fixmedins_setl_cnt=" + "452" +
  8208. "&fixmedins_code=" + miConfig.Code +
  8209. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8210. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8211. "&secret_key=" + miConfig.SecretKey +
  8212. "&org_name=" + miConfig.OrgName +
  8213. "&doctor=" + user_name
  8214. fmt.Println(api)
  8215. resp, requestErr := http.Get(api)
  8216. if requestErr != nil {
  8217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8218. return
  8219. }
  8220. body, ioErr := ioutil.ReadAll(resp.Body)
  8221. fmt.Println(body)
  8222. if ioErr != nil {
  8223. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8225. return
  8226. }
  8227. var respJSON map[string]interface{}
  8228. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8229. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8231. return
  8232. }
  8233. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8234. userJSONBytes, _ := json.Marshal(respJSON)
  8235. var res ResultEight
  8236. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8237. utils.ErrorLog("解析失败:%v", err)
  8238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8239. return
  8240. }
  8241. }
  8242. func (c *HisApiController) Check390() {
  8243. adminUser := c.GetAdminUserInfo()
  8244. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8245. var user_name string
  8246. user_name = "高慧裕"
  8247. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8248. "insutype=" + "390" +
  8249. "&clr_type=" + "" +
  8250. "&setl_optins=" + "441202" +
  8251. "&stmt_begndate=" + "2022-03-01" +
  8252. "&stm_enddate=" + "2022-03-31" +
  8253. "&medfee_sumamt=" + "1068448.89" +
  8254. "&fund_pay_sumamt=" + "1014677.62" +
  8255. "&acct_pay=" + "0" +
  8256. "&fixmedins_setl_cnt=" + "1950" +
  8257. "&fixmedins_code=" + miConfig.Code +
  8258. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8259. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8260. "&secret_key=" + miConfig.SecretKey +
  8261. "&org_name=" + miConfig.OrgName +
  8262. "&doctor=" + user_name
  8263. fmt.Println(api)
  8264. resp, requestErr := http.Get(api)
  8265. if requestErr != nil {
  8266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8267. return
  8268. }
  8269. body, ioErr := ioutil.ReadAll(resp.Body)
  8270. fmt.Println(body)
  8271. if ioErr != nil {
  8272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8274. return
  8275. }
  8276. var respJSON map[string]interface{}
  8277. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8280. return
  8281. }
  8282. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8283. userJSONBytes, _ := json.Marshal(respJSON)
  8284. var res ResultEight
  8285. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8286. utils.ErrorLog("解析失败:%v", err)
  8287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8288. return
  8289. }
  8290. }
  8291. //对账明细
  8292. func (c *HisApiController) GetCheckDetailAccount() {
  8293. start_time := c.GetString("start_time")
  8294. end_time := c.GetString("end_time")
  8295. admin_user_id, _ := c.GetInt64("admin_user_id")
  8296. adminUser := c.GetAdminUserInfo()
  8297. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8298. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8299. timeLayout := "2006-01-02"
  8300. loc, _ := time.LoadLocation("Local")
  8301. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8302. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8303. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8304. Mkdir(miConfig.OrgName)
  8305. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  8306. file_name := file + ".txt"
  8307. zip_name := file + ".zip"
  8308. zip_path := miConfig.OrgName + "/" + zip_name
  8309. file_path := miConfig.OrgName + "/" + file_name
  8310. decimal.DivisionPrecision = 2
  8311. var medfee_sumamt float64
  8312. var psn_cash_pay float64
  8313. var fund_pay_sumamt float64
  8314. fixmedins_setl_cnt := int64(len(orders))
  8315. for _, item := range orders {
  8316. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8317. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8318. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8319. }
  8320. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8321. defer f.Close()
  8322. if err != nil {
  8323. fmt.Println(err.Error())
  8324. } else {
  8325. for _, item := range orders {
  8326. var refd_setl_flag string
  8327. if item.OrderStatus == 2 {
  8328. refd_setl_flag = "0"
  8329. var str string
  8330. str = item.SetlId + " " +
  8331. item.MdtrtId + " " +
  8332. item.PsnNo + " " +
  8333. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8334. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8335. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8336. _, err = f.Write([]byte(str))
  8337. }
  8338. if item.OrderStatus == 3 {
  8339. var str string
  8340. str = item.SetlId + " " +
  8341. item.MdtrtId + " " +
  8342. item.PsnNo + " " +
  8343. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8344. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8345. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8346. _, err = f.Write([]byte(str))
  8347. var str2 string
  8348. str2 = item.SetlId + " " +
  8349. item.MdtrtId + " " +
  8350. item.PsnNo + " " +
  8351. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8352. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8353. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8354. _, err = f.Write([]byte(str2))
  8355. }
  8356. }
  8357. }
  8358. Zip(file_path, zip_path)
  8359. fmt.Println(ReadFile(zip_path))
  8360. fmt.Println(string(ReadFile(zip_path)))
  8361. if config.IsOpen == 1 {
  8362. var user_name string
  8363. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8364. if role.ID == 0 {
  8365. user_name = "管理员"
  8366. } else {
  8367. user_name = role.UserName
  8368. }
  8369. baseParams := models.BaseParams{
  8370. SecretKey: miConfig.SecretKey,
  8371. FixmedinsCode: miConfig.Code,
  8372. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8373. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8374. OrgName: miConfig.OrgName,
  8375. Doctor: user_name,
  8376. }
  8377. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  8378. var dat map[string]interface{}
  8379. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8380. fmt.Println(dat)
  8381. } else {
  8382. fmt.Println(err)
  8383. }
  8384. userJSONBytes, _ := json.Marshal(dat)
  8385. var res ResultNine
  8386. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8387. utils.ErrorLog("解析失败:%v", err)
  8388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8389. return
  8390. }
  8391. if res.Infcode == 0 {
  8392. fileNo := res.Output.FileQuryNo
  8393. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8394. "file_qury_no=" + fileNo +
  8395. "&setl_optins=" + "定点医保中心" +
  8396. "&stmt_begndate=" + start_time +
  8397. "&stm_enddate=" + end_time +
  8398. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8399. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8400. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8401. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8402. "&fixmedins_code=" + miConfig.Code +
  8403. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8404. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8405. "&secret_key=" + miConfig.SecretKey +
  8406. "&org_name=" + miConfig.OrgName +
  8407. "&doctor=" + user_name
  8408. resp, requestErr := http.Get(api)
  8409. if requestErr != nil {
  8410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8411. return
  8412. }
  8413. body, ioErr := ioutil.ReadAll(resp.Body)
  8414. if ioErr != nil {
  8415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8417. return
  8418. }
  8419. var respJSON map[string]interface{}
  8420. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8423. return
  8424. }
  8425. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8426. userJSONBytes, _ := json.Marshal(respJSON)
  8427. var res ResultTen
  8428. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8429. utils.ErrorLog("解析失败:%v", err)
  8430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8431. return
  8432. }
  8433. if res.Infcode == 0 {
  8434. service.Gdyb9102(baseParams, zip_name, fileNo)
  8435. micc := &models.MedicalInsuranceCostCompare{
  8436. StartTime: startime.Unix(),
  8437. EndTime: endtime.Unix(),
  8438. Insutype: "0",
  8439. CheckType: 2,
  8440. Num: fixmedins_setl_cnt,
  8441. Mtime: time.Now().Unix(),
  8442. Status: 1,
  8443. UserOrgId: adminUser.CurrentOrgId,
  8444. CostTotal: medfee_sumamt,
  8445. FuncTotal: fund_pay_sumamt,
  8446. PsnPay: psn_cash_pay,
  8447. Creator: admin_user_id,
  8448. Ctime: time.Now().Unix(),
  8449. }
  8450. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8451. c.ServeSuccessJSON(map[string]interface{}{
  8452. "msg": "明细对账成功",
  8453. })
  8454. }
  8455. } else {
  8456. }
  8457. }
  8458. }
  8459. type CustomOrderInfo struct {
  8460. Name string
  8461. Spec string
  8462. Unit string
  8463. Count float64
  8464. Price float64
  8465. Total float64
  8466. }
  8467. func (c *HisApiController) GetSettleAccounts() {
  8468. //id, _ := c.GetInt64("id")
  8469. //record_time := c.GetString("record_time")
  8470. order_id, _ := c.GetInt64("order_id")
  8471. admin_user_id, _ := c.GetInt64("admin_user_id")
  8472. //timeLayout := "2006-01-02"
  8473. //loc, _ := time.LoadLocation("Local")
  8474. //
  8475. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8476. //if err != nil {
  8477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8478. // return
  8479. //}
  8480. //recordDateTime := theTime.Unix()
  8481. adminUser := c.GetAdminUserInfo()
  8482. order, _ := service.GetHisOrderByID(order_id)
  8483. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8484. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8485. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8486. orderInfos = append(orderInfos, orderInfos_two...)
  8487. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8488. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8489. var diagnosis_ids []string
  8490. if his.ID > 0 {
  8491. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8492. } else {
  8493. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8494. }
  8495. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8496. var dia_config []*models.HisXtDiagnoseConfig
  8497. var name string
  8498. for _, item := range diagnosis_ids {
  8499. id, _ := strconv.ParseInt(item, 10, 64)
  8500. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8501. dia_config = append(dia_config, &diagnosisConfig)
  8502. if len(name) == 0 {
  8503. name = diagnosisConfig.ClassName
  8504. } else {
  8505. name = name + "," + diagnosisConfig.ClassName
  8506. }
  8507. }
  8508. var bedCostTotal float64 = 0 //床位总费
  8509. var bedCostSelfTotal float64 = 0 //床位自费
  8510. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8511. var operationCostTotal float64 = 0 //手术费
  8512. var operationCostSelfTotal float64 = 0 //手术费
  8513. var operationCostPartSelfTotal float64 = 0 //手术费
  8514. var otherCostTotal float64 = 0 //其他费用
  8515. var otherCostSelfTotal float64 = 0 //其他费用
  8516. var otherCostPartSelfTotal float64 = 0 //其他费用
  8517. var materialCostTotal float64 = 0 //材料费
  8518. var materialCostSelfTotal float64 = 0 //材料费
  8519. var materialCostPartSelfTotal float64 = 0 //材料费
  8520. var westernMedicineCostTotal float64 = 0 //西药费
  8521. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8522. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8523. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8524. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8525. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8526. var checkCostTotal float64 = 0 //检查费
  8527. var checkCostSelfTotal float64 = 0 //检查费
  8528. var checkCostPartSelfTotal float64 = 0 //检查费
  8529. var laboratoryCostTotal float64 = 0 //化验费
  8530. var laboratoryCostSelfTotal float64 = 0 //化验费
  8531. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8532. var treatCostTotal float64 = 0 //治疗费用
  8533. var treatCostSelfTotal float64 = 0 //治疗费用
  8534. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8535. decimal.DivisionPrecision = 2
  8536. for _, item := range orderInfos {
  8537. if item.MedChrgitmType == "01" { //床位费
  8538. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8539. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8540. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8541. }
  8542. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8543. if item.MedChrgitmType == "03" { //检查费
  8544. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8545. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8546. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8547. }
  8548. } else {
  8549. if item.MedChrgitmType == "03" { //检查费
  8550. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8551. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8552. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8553. }
  8554. }
  8555. if item.MedChrgitmType == "04" { //化验费
  8556. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8557. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8558. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8559. }
  8560. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8561. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8562. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8563. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8564. }
  8565. if item.MedChrgitmType == "06" { //手术费
  8566. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8567. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8568. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8569. }
  8570. if item.MedChrgitmType == "08" { //材料费
  8571. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8572. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8573. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8574. }
  8575. if item.MedChrgitmType == "09" { //西药费
  8576. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8577. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8578. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8579. }
  8580. if item.MedChrgitmType == "11" { //中成费
  8581. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8582. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8583. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8584. }
  8585. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8586. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8587. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8588. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8589. }
  8590. }
  8591. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8592. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8593. var user_name string
  8594. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8595. if role.ID == 0 {
  8596. user_name = "管理员"
  8597. } else {
  8598. user_name = role.UserName
  8599. }
  8600. baseParams := models.BaseParams{
  8601. SecretKey: miConfig.SecretKey,
  8602. FixmedinsCode: miConfig.Code,
  8603. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8604. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8605. OrgName: miConfig.OrgName,
  8606. Doctor: user_name,
  8607. }
  8608. businessParams := models.BusinessParams{
  8609. PsnNo: order.PsnNo,
  8610. MdtrtId: order.MdtrtId,
  8611. SetlId: order.SetlId,
  8612. }
  8613. var res ResultEleven
  8614. var resEleven10265 ResultEleven10265
  8615. if config.IsOpen == 1 {
  8616. if miConfig.MdtrtareaAdmvs == "421300" {
  8617. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8618. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8619. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8620. resp, requestErr := http.Get(api)
  8621. if requestErr != nil {
  8622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8623. return
  8624. }
  8625. body, ioErr := ioutil.ReadAll(resp.Body)
  8626. if ioErr != nil {
  8627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8629. return
  8630. }
  8631. var respJSON map[string]interface{}
  8632. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8635. return
  8636. }
  8637. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8638. result, _ := json.Marshal(respJSON)
  8639. fmt.Println("log")
  8640. fmt.Println(string(result))
  8641. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8642. utils.ErrorLog("解析失败:%v", err)
  8643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8644. return
  8645. }
  8646. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8647. var api string
  8648. if miConfig.MdtrtareaAdmvs == "320921" {
  8649. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8650. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8651. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8652. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8653. } else {
  8654. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8655. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8656. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8657. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8658. }
  8659. resp, requestErr := http.Get(api)
  8660. if requestErr != nil {
  8661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8662. return
  8663. }
  8664. body, ioErr := ioutil.ReadAll(resp.Body)
  8665. if ioErr != nil {
  8666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8668. return
  8669. }
  8670. var respJSON map[string]interface{}
  8671. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8674. return
  8675. }
  8676. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8677. result, _ := json.Marshal(respJSON)
  8678. fmt.Println("log")
  8679. fmt.Println(string(result))
  8680. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8681. utils.ErrorLog("解析失败:%v", err)
  8682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8683. return
  8684. }
  8685. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8686. res.Output = resEleven10265.Output
  8687. res.ErrMsg = resEleven10265.ErrMsg
  8688. res.Cainfo = resEleven10265.Cainfo
  8689. res.WarnMsg = resEleven10265.WarnMsg
  8690. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8691. res.Infcode = infocode
  8692. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8693. fmt.Println("~~~~~~~")
  8694. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8695. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8696. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8697. resp, requestErr := http.Get(api)
  8698. if requestErr != nil {
  8699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8700. return
  8701. }
  8702. body, ioErr := ioutil.ReadAll(resp.Body)
  8703. if ioErr != nil {
  8704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8706. return
  8707. }
  8708. var respJSON map[string]interface{}
  8709. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8712. return
  8713. }
  8714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8715. result, _ := json.Marshal(respJSON)
  8716. fmt.Println("log")
  8717. fmt.Println(string(result))
  8718. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8719. utils.ErrorLog("解析失败:%v", err)
  8720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8721. return
  8722. }
  8723. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8724. res.Output = resEleven10265.Output
  8725. res.ErrMsg = resEleven10265.ErrMsg
  8726. res.Cainfo = resEleven10265.Cainfo
  8727. res.WarnMsg = resEleven10265.WarnMsg
  8728. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8729. res.Infcode = infocode
  8730. } else {
  8731. result := service.Gdyb5203(baseParams, businessParams)
  8732. var dat map[string]interface{}
  8733. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8734. fmt.Println(dat)
  8735. } else {
  8736. fmt.Println(err)
  8737. }
  8738. userJSONBytes, _ := json.Marshal(dat)
  8739. if miConfig.Code == "H15049901371" {
  8740. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8741. utils.ErrorLog("解析失败:%v", err)
  8742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8743. return
  8744. }
  8745. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8746. res.Output = resEleven10265.Output
  8747. res.ErrMsg = resEleven10265.ErrMsg
  8748. res.Cainfo = resEleven10265.Cainfo
  8749. res.WarnMsg = resEleven10265.WarnMsg
  8750. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8751. res.Infcode = infocode
  8752. } else {
  8753. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8754. utils.ErrorLog("解析失败:%v", err)
  8755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8756. return
  8757. }
  8758. }
  8759. }
  8760. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8761. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8762. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8763. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8764. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8765. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8766. var doctor_name string
  8767. if roles.ID == 0 {
  8768. doctor_name = "管理员"
  8769. } else {
  8770. doctor_name = roles.UserName
  8771. }
  8772. yiliao_leibie := ""
  8773. switch order.MedType {
  8774. case "11":
  8775. yiliao_leibie = "普通门诊"
  8776. break
  8777. case "12":
  8778. yiliao_leibie = "门诊挂号"
  8779. break
  8780. case "13":
  8781. yiliao_leibie = "急诊"
  8782. break
  8783. case "14":
  8784. yiliao_leibie = "门诊特殊病"
  8785. break
  8786. case "15":
  8787. yiliao_leibie = "门诊统筹"
  8788. break
  8789. case "16":
  8790. yiliao_leibie = "门诊慢性病"
  8791. break
  8792. case "21":
  8793. yiliao_leibie = "普通住院"
  8794. break
  8795. }
  8796. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8797. if res.Infcode == 0 {
  8798. c.ServeSuccessJSON(map[string]interface{}{
  8799. "diagnosis": name,
  8800. "order_infos": orderInfos,
  8801. "number": order.MdtrtId,
  8802. "date": order.SettleAccountsDate,
  8803. "charge_admin": charge_admin,
  8804. "printor_admin": printor_admin,
  8805. "info": res.Output.Setlinfo,
  8806. "order": order,
  8807. "bedCostTotal": bedCostTotal,
  8808. "bedCostSelfTotal": bedCostSelfTotal,
  8809. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8810. "operationCostTotal": operationCostTotal,
  8811. "operationCostSelfTotal": operationCostSelfTotal,
  8812. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8813. "otherCostTotal": otherCostTotal,
  8814. "otherCostSelfTotal": otherCostSelfTotal,
  8815. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8816. "materialCostTotal": materialCostTotal,
  8817. "materialCostSelfTotal": materialCostSelfTotal,
  8818. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8819. "westernMedicineCostTotal": westernMedicineCostTotal,
  8820. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8821. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8822. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8823. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8824. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8825. "checkCostTotal": checkCostTotal,
  8826. "checkCostSelfTotal": checkCostSelfTotal,
  8827. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8828. "laboratoryCostTotal": laboratoryCostTotal,
  8829. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8830. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8831. "treatCostTotal": treatCostTotal,
  8832. "treatCostSelfTotal": treatCostSelfTotal,
  8833. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8834. "doctor_info": doctor_info,
  8835. "doctor_code": adminRole_two.DoctorCode,
  8836. "doctor_name": doctor_name,
  8837. "health_card_no": order.PsnNo,
  8838. "department": departments.Name,
  8839. "yiliao_leibie": yiliao_leibie,
  8840. "after_money": order.AccountPrice,
  8841. "patient": patient,
  8842. "org_name": miConfig.OrgName,
  8843. "org_code": miConfig.Code,
  8844. "order_number": order.Number,
  8845. "his_hospital": his_hospital,
  8846. "his": his,
  8847. "dia_config": dia_config,
  8848. //"check_order_info": cus_slice,
  8849. })
  8850. }
  8851. }
  8852. }
  8853. func (c *HisApiController) CheckTreatment() {
  8854. patient_id, _ := c.GetInt64("patient_id")
  8855. id_card_no := c.GetString("id_card_no")
  8856. insutype := c.GetString("insutype")
  8857. med_type := c.GetString("med_type")
  8858. admin_user_id, _ := c.GetInt64("admin_user_id")
  8859. adminUser := c.GetAdminUserInfo()
  8860. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8861. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8862. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8863. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8864. if miConfig.MdtrtareaAdmvs == "421300" {
  8865. var res ResultTwo
  8866. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8867. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8868. "&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)
  8869. resp, requestErr := http.Get(api)
  8870. if requestErr != nil {
  8871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8872. return
  8873. }
  8874. body, ioErr := ioutil.ReadAll(resp.Body)
  8875. if ioErr != nil {
  8876. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8878. return
  8879. }
  8880. var respJSON map[string]interface{}
  8881. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8884. return
  8885. }
  8886. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8887. result, _ := json.Marshal(respJSON)
  8888. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8889. utils.ErrorLog("解析失败:%v", err)
  8890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8891. return
  8892. }
  8893. if res.Infcode == 0 {
  8894. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8895. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8896. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8897. resp, requestErr := http.Get(api)
  8898. if requestErr != nil {
  8899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8900. return
  8901. }
  8902. body, ioErr := ioutil.ReadAll(resp.Body)
  8903. if ioErr != nil {
  8904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8906. return
  8907. }
  8908. var respJSON map[string]interface{}
  8909. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8912. return
  8913. }
  8914. var res Result2001
  8915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8916. result2, _ := json.Marshal(respJSON)
  8917. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8918. utils.ErrorLog("解析失败:%v", err)
  8919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8920. return
  8921. }
  8922. if res.Infcode == 0 {
  8923. c.ServeSuccessJSON(map[string]interface{}{
  8924. "msg": res.Output.Trtinfo,
  8925. })
  8926. }
  8927. } else {
  8928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8929. return
  8930. }
  8931. } else {
  8932. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8933. var dat map[string]interface{}
  8934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8935. fmt.Println(dat)
  8936. } else {
  8937. fmt.Println(err)
  8938. }
  8939. userJSONBytes, _ := json.Marshal(dat)
  8940. var res ResultTwo
  8941. var res10265 ResultTwo10265
  8942. if miConfig.Code == "H15049901371" {
  8943. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8944. utils.ErrorLog("解析失败:%v", err)
  8945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8946. return
  8947. }
  8948. res.ErrMsg = res10265.ErrMsg
  8949. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8950. res.Infcode = infocode
  8951. res.Output = res10265.Output
  8952. res.InfRefmsgid = res10265.InfRefmsgid
  8953. } else {
  8954. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8955. utils.ErrorLog("解析失败:%v", err)
  8956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8957. return
  8958. }
  8959. }
  8960. var user_name string
  8961. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8962. if role.ID == 0 {
  8963. user_name = "xxx"
  8964. } else {
  8965. user_name = role.UserName
  8966. }
  8967. baseParams := models.BaseParams{
  8968. SecretKey: miConfig.SecretKey,
  8969. FixmedinsCode: miConfig.Code,
  8970. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8971. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8972. OrgName: miConfig.OrgName,
  8973. Doctor: user_name,
  8974. }
  8975. if config.IsOpen == 1 {
  8976. if miConfig.Code == "H15049901371" {
  8977. if med_type == "14" {
  8978. if insutype == "390" {
  8979. med_type = "9933"
  8980. } else if insutype == "310" {
  8981. med_type = "990502"
  8982. }
  8983. } else if med_type == "11" {
  8984. med_type = "11"
  8985. }
  8986. }
  8987. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8988. var dat map[string]interface{}
  8989. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8990. fmt.Println(dat)
  8991. } else {
  8992. fmt.Println(err)
  8993. }
  8994. var res Result2001
  8995. var res10265 Result2001Org10265
  8996. if miConfig.Code == "H15049901371" {
  8997. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8998. utils.ErrorLog("解析失败:%v", err)
  8999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9000. return
  9001. }
  9002. res.ErrMsg = res10265.ErrMsg
  9003. res.Output = res10265.Output
  9004. res.InfRefmsgid = res10265.InfRefmsgid
  9005. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9006. res.Infcode = infocode
  9007. } else {
  9008. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9009. utils.ErrorLog("解析失败:%v", err)
  9010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9011. return
  9012. }
  9013. }
  9014. if res.Infcode == 0 {
  9015. c.ServeSuccessJSON(map[string]interface{}{
  9016. "msg": res.Output.Trtinfo,
  9017. })
  9018. }
  9019. }
  9020. }
  9021. }
  9022. //func (c *HisApiController) PutRecord() {
  9023. // id, _ := c.GetInt64("id")
  9024. // record_time := c.GetString("record_time")
  9025. // timeLayout := "2006-01-02"
  9026. // loc, _ := time.LoadLocation("Local")
  9027. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9028. // if err != nil {
  9029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9030. // return
  9031. // }
  9032. // recordDateTime := theTime.Unix()
  9033. //
  9034. // adminInfo := c.GetAdminUserInfo()
  9035. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9036. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9037. //
  9038. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9039. //
  9040. // fmt.Println(miConfig.SecretKey)
  9041. //
  9042. // if patient == nil {
  9043. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9044. // return
  9045. // }
  9046. // if len(patient.IdCardNo) == 0 {
  9047. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9048. // return
  9049. // }
  9050. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9051. // if config.IsOpen == 1 {
  9052. // 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
  9053. // resp, requestErr := http.Get(api)
  9054. // if requestErr != nil {
  9055. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9056. // return
  9057. // }
  9058. // defer resp.Body.Close()
  9059. // body, ioErr := ioutil.ReadAll(resp.Body)
  9060. // if ioErr != nil {
  9061. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9062. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9063. // return
  9064. // }
  9065. // var respJSON map[string]interface{}
  9066. //
  9067. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9068. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9069. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9070. // return
  9071. // }
  9072. //
  9073. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9074. // userJSONBytes, _ := json.Marshal(userJSON)
  9075. // var res ResultTwo
  9076. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9077. // utils.ErrorLog("解析失败:%v", err)
  9078. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9079. // return
  9080. // }
  9081. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9082. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9083. // infoStr := string(Iinfos)
  9084. // idetinfoStr := string(Idetinfos)
  9085. //
  9086. // if res.Infcode == 0 {
  9087. // his := models.VMHisPatient{
  9088. // Status: 1,
  9089. // Ctime: time.Now().Unix(),
  9090. // Mtime: time.Now().Unix(),
  9091. // PsnNo: res.Output.Baseinfo.PsnNo,
  9092. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9093. // Certno: res.Output.Baseinfo.Certno,
  9094. // PsnName: res.Output.Baseinfo.PsnName,
  9095. // Gend: res.Output.Baseinfo.Gend,
  9096. // Naty: res.Output.Baseinfo.Naty,
  9097. // Brdy: res.Output.Baseinfo.Brdy,
  9098. // Age: res.Output.Baseinfo.Age,
  9099. // Iinfo: infoStr,
  9100. // Idetinfo: idetinfoStr,
  9101. // PatientId: patient.ID,
  9102. // RecordDate: theTime.Unix(),
  9103. // UserOrgId: adminInfo.CurrentOrgId,
  9104. // AdminUserId: adminInfo.AdminUser.Id,
  9105. // IsReturn: 1,
  9106. // }
  9107. //
  9108. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9109. // //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")
  9110. // //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")
  9111. //
  9112. // //var dat map[string]interface{}
  9113. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9114. // // fmt.Println(dat)
  9115. // //} else {
  9116. // // fmt.Println(err)
  9117. // //}
  9118. //
  9119. // var dat2 map[string]interface{}
  9120. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9121. // fmt.Println(dat2)
  9122. // } else {
  9123. // fmt.Println(err)
  9124. // }
  9125. //
  9126. // } else {
  9127. // adminUser := c.GetAdminUserInfo()
  9128. // errlog := &models.HisOrderError{
  9129. // UserOrgId: adminUser.CurrentOrgId,
  9130. // Ctime: time.Now().Unix(),
  9131. // Mtime: time.Now().Unix(),
  9132. // ErrMsg: res.ErrMsg,
  9133. // Status: 1,
  9134. // PatientId: id,
  9135. // RecordTime: recordDateTime,
  9136. // Stage: 1,
  9137. // }
  9138. // service.CreateErrMsgLog(errlog)
  9139. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9140. // return
  9141. // }
  9142. // }
  9143. //
  9144. //}
  9145. //func (c *HisApiController) GetUploadDiag() {
  9146. // id, _ := c.GetInt64("id")
  9147. // record_time := c.GetString("record_time")
  9148. //
  9149. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9150. // sick_type, _ := c.GetInt64("sick_type")
  9151. // reg_type, _ := c.GetInt64("reg_type")
  9152. //
  9153. // timeLayout := "2006-01-02"
  9154. // loc, _ := time.LoadLocation("Local")
  9155. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9156. // if err != nil {
  9157. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9158. // return
  9159. // }
  9160. //
  9161. // var patientPrescription models.HisPrescriptionInfo
  9162. // recordDateTime := theTime.Unix()
  9163. // adminInfo := c.GetAdminUserInfo()
  9164. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9165. //
  9166. // if patientPrescription.ID == 0 {
  9167. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9168. // }
  9169. //
  9170. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9171. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9172. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9173. // sickConfig, _ := service.FindSickById(sick_type)
  9174. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9175. //
  9176. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9177. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9178. // "&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 +
  9179. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9180. // resp2, requestErr2 := http.Get(api2)
  9181. // if requestErr2 != nil {
  9182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9183. // return
  9184. // }
  9185. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9186. // if ioErr2 != nil {
  9187. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9188. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9189. // return
  9190. // }
  9191. // var respJSON2 map[string]interface{}
  9192. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9193. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9195. // return
  9196. // }
  9197. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9198. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9199. //
  9200. // var res2 ResultSix
  9201. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9202. // utils.ErrorLog("解析失败:%v", err)
  9203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9204. // return
  9205. // }
  9206. // if res2.Infcode != 0 {
  9207. // adminUser := c.GetAdminUserInfo()
  9208. // errlog := &models.HisOrderError{
  9209. // UserOrgId: adminUser.CurrentOrgId,
  9210. // Ctime: time.Now().Unix(),
  9211. // Mtime: time.Now().Unix(),
  9212. // ErrMsg: res2.ErrMsg,
  9213. // Status: 1,
  9214. // PatientId: id,
  9215. // RecordTime: recordDateTime,
  9216. // Stage: 3,
  9217. // }
  9218. // service.CreateErrMsgLog(errlog)
  9219. //
  9220. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9221. // return
  9222. // }
  9223. //
  9224. // c.ServeSuccessJSON(map[string]interface{}{
  9225. // "msg": "上传成功",
  9226. // })
  9227. //
  9228. //}
  9229. type QueryResult struct {
  9230. ID int64
  9231. Name string
  9232. Code string
  9233. List_type_code string
  9234. }
  9235. func (c *HisApiController) GetCheckCode() {
  9236. ids_str := c.GetString("ids")
  9237. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9238. ids_arr := strings.Split(ids_str, ",")
  9239. var queryResult []QueryResult
  9240. ids := make([]int64, 0)
  9241. for _, item := range ids_arr {
  9242. id, _ := strconv.ParseInt(item, 10, 64)
  9243. ids = append(ids, id)
  9244. }
  9245. if record_type == 1 {
  9246. drugs, _ := service.GetBatchDrugList(ids)
  9247. for _, item := range drugs {
  9248. result := QueryResult{
  9249. ID: item.ID,
  9250. Name: item.DrugName,
  9251. Code: item.MedicalInsuranceNumber,
  9252. List_type_code: "101",
  9253. }
  9254. queryResult = append(queryResult, result)
  9255. }
  9256. } else if record_type == 2 {
  9257. goods, _ := service.GetBatchGoodInformationList(ids)
  9258. for _, item := range goods {
  9259. result := QueryResult{
  9260. ID: item.ID,
  9261. Name: item.GoodName,
  9262. Code: item.MedicalInsuranceNumber,
  9263. List_type_code: "301",
  9264. }
  9265. queryResult = append(queryResult, result)
  9266. }
  9267. } else if record_type == 3 {
  9268. projects, _ := service.GetBathchMyPorjecgList(ids)
  9269. for _, item := range projects {
  9270. result := QueryResult{
  9271. ID: item.ID,
  9272. Name: item.ProjectName,
  9273. Code: item.MedicalCode,
  9274. List_type_code: "201",
  9275. }
  9276. queryResult = append(queryResult, result)
  9277. }
  9278. }
  9279. admin_user_id, _ := c.GetInt64("admin_user_id")
  9280. adminUser := c.GetAdminUserInfo()
  9281. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9282. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9283. var user_name string
  9284. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9285. if role.ID == 0 {
  9286. user_name = "xxx"
  9287. } else {
  9288. user_name = role.UserName
  9289. }
  9290. baseParams := &models.BaseParams{
  9291. SecretKey: miConfig.SecretKey,
  9292. FixmedinsCode: miConfig.Code,
  9293. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9294. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9295. OrgName: miConfig.OrgName,
  9296. Doctor: user_name,
  9297. }
  9298. if config.IsOpen == 1 {
  9299. for _, item := range queryResult {
  9300. var result string
  9301. if record_type == 1 {
  9302. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9303. } else if record_type == 2 {
  9304. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9305. } else if record_type == 3 {
  9306. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9307. }
  9308. var dat map[string]interface{}
  9309. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9310. fmt.Println(dat)
  9311. } else {
  9312. fmt.Println(err)
  9313. }
  9314. userJSONBytes, _ := json.Marshal(dat)
  9315. var res ResultSix
  9316. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9317. utils.ErrorLog("解析失败:%v", err)
  9318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9319. return
  9320. }
  9321. if res.Infcode == 0 {
  9322. if record_type == 1 {
  9323. service.UpdateBaseDrugById(item.ID)
  9324. } else if record_type == 2 {
  9325. service.UpdateGoodInformaitonByDetail(item.ID)
  9326. } else if record_type == 3 {
  9327. service.UpdateProjectById(item.ID)
  9328. }
  9329. c.ServeSuccessJSON(map[string]interface{}{
  9330. "failed_code": 0,
  9331. "msg": "目录对照成功",
  9332. })
  9333. } else {
  9334. c.ServeSuccessJSON(map[string]interface{}{
  9335. "failed_code": -10,
  9336. "msg": res.ErrMsg,
  9337. })
  9338. }
  9339. }
  9340. }
  9341. }
  9342. func (c *HisApiController) UnCheckCode() {
  9343. ids_str := c.GetString("ids")
  9344. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9345. admin_user_id, _ := c.GetInt64("admin_user_id")
  9346. ids_arr := strings.Split(ids_str, ",")
  9347. var queryResult []QueryResult
  9348. ids := make([]int64, 0)
  9349. for _, item := range ids_arr {
  9350. id, _ := strconv.ParseInt(item, 10, 64)
  9351. ids = append(ids, id)
  9352. }
  9353. if record_type == 1 {
  9354. drugs, _ := service.GetBatchDrugList(ids)
  9355. for _, item := range drugs {
  9356. result := QueryResult{
  9357. ID: item.ID,
  9358. Name: item.DrugName,
  9359. Code: item.MedicalInsuranceNumber,
  9360. List_type_code: "101",
  9361. }
  9362. queryResult = append(queryResult, result)
  9363. }
  9364. } else if record_type == 2 {
  9365. goods, _ := service.GetBatchGoodInformationList(ids)
  9366. for _, item := range goods {
  9367. result := QueryResult{
  9368. ID: item.ID,
  9369. Name: item.GoodName,
  9370. Code: item.MedicalInsuranceNumber,
  9371. List_type_code: "301",
  9372. }
  9373. queryResult = append(queryResult, result)
  9374. }
  9375. } else if record_type == 3 {
  9376. projects, _ := service.GetBathchMyPorjecgList(ids)
  9377. for _, item := range projects {
  9378. result := QueryResult{
  9379. ID: item.ID,
  9380. Name: item.ProjectName,
  9381. Code: item.MedicalCode,
  9382. List_type_code: "201",
  9383. }
  9384. queryResult = append(queryResult, result)
  9385. }
  9386. }
  9387. adminUser := c.GetAdminUserInfo()
  9388. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9389. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9390. var user_name string
  9391. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9392. if role.ID == 0 {
  9393. user_name = "xxx"
  9394. } else {
  9395. user_name = role.UserName
  9396. }
  9397. baseParams := &models.BaseParams{
  9398. SecretKey: miConfig.SecretKey,
  9399. FixmedinsCode: miConfig.Code,
  9400. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9401. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9402. OrgName: miConfig.OrgName,
  9403. Doctor: user_name,
  9404. }
  9405. if config.IsOpen == 1 {
  9406. for _, item := range queryResult {
  9407. var result string
  9408. if record_type == 1 {
  9409. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9410. } else if record_type == 2 {
  9411. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9412. } else if record_type == 3 {
  9413. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9414. }
  9415. var dat2 map[string]interface{}
  9416. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9417. fmt.Println(dat2)
  9418. } else {
  9419. fmt.Println(err)
  9420. }
  9421. userJSONBytes, _ := json.Marshal(dat2)
  9422. var res ResultSix
  9423. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9424. utils.ErrorLog("解析失败:%v", err)
  9425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9426. return
  9427. }
  9428. if res.Infcode == 0 {
  9429. if record_type == 1 {
  9430. service.UpdateDrugByIdDetail(item.ID)
  9431. } else if record_type == 2 {
  9432. service.UpdateGoodInfoById(item.ID)
  9433. } else if record_type == 3 {
  9434. service.UpdateMyProjectById(item.ID)
  9435. }
  9436. c.ServeSuccessJSON(map[string]interface{}{
  9437. "failed_code": 0,
  9438. "msg": "撤销目录对照成功",
  9439. })
  9440. } else {
  9441. c.ServeSuccessJSON(map[string]interface{}{
  9442. "failed_code": -10,
  9443. "msg": res.ErrMsg,
  9444. })
  9445. }
  9446. }
  9447. }
  9448. }
  9449. func (c *HisApiController) GetPatientInfo() {
  9450. id_card_no := c.GetString("id_card_no")
  9451. admin_user_id, _ := c.GetInt64("admin_user_id")
  9452. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9453. if patient.ID == 0 {
  9454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9455. return
  9456. }
  9457. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9458. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9459. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9460. if config.IsOpen == 1 {
  9461. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9462. var dat map[string]interface{}
  9463. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9464. fmt.Println(dat)
  9465. } else {
  9466. fmt.Println(err)
  9467. }
  9468. userJSONBytes, _ := json.Marshal(dat)
  9469. var res ResultTwo
  9470. var res10265 ResultTwo10265
  9471. if miConfig.Code == "H15049901371" {
  9472. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9473. utils.ErrorLog("解析失败:%v", err)
  9474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9475. return
  9476. }
  9477. res.ErrMsg = res10265.ErrMsg
  9478. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9479. res.Infcode = infocode
  9480. res.Output = res10265.Output
  9481. res.InfRefmsgid = res10265.InfRefmsgid
  9482. } else {
  9483. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9484. utils.ErrorLog("解析失败:%v", err)
  9485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9486. return
  9487. }
  9488. }
  9489. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9490. // utils.ErrorLog("解析失败:%v", err)
  9491. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9492. // return
  9493. //}
  9494. if res.Infcode != 0 {
  9495. c.ServeSuccessJSON(map[string]interface{}{
  9496. "failed_code": -10,
  9497. "msg": res.ErrMsg,
  9498. })
  9499. } else {
  9500. c.ServeSuccessJSON(map[string]interface{}{
  9501. "failed_code": 0,
  9502. "info": res,
  9503. })
  9504. }
  9505. }
  9506. }
  9507. func (c *HisApiController) PsnPutOnRecord() {
  9508. record_type, _ := c.GetInt64("type")
  9509. patient_id, _ := c.GetInt64("patient_id")
  9510. admin_user_id, _ := c.GetInt64("admin_user_id")
  9511. start_time := c.GetString("start_time")
  9512. end_time := c.GetString("end_time")
  9513. adminUser := c.GetAdminUserInfo()
  9514. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9515. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9516. var patients []*models.Patients
  9517. if record_type == 1 { //全部备案
  9518. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9519. patients = append(patients, patient...)
  9520. } else { //单个备案
  9521. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9522. patients = append(patients, patient)
  9523. }
  9524. var user_name string
  9525. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9526. if role.ID == 0 {
  9527. user_name = "xxx"
  9528. } else {
  9529. user_name = role.UserName
  9530. }
  9531. if config.IsOpen == 1 {
  9532. for _, item := range patients {
  9533. 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
  9534. resp, requestErr := http.Get(api)
  9535. if requestErr != nil {
  9536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9537. return
  9538. }
  9539. defer resp.Body.Close()
  9540. body, ioErr := ioutil.ReadAll(resp.Body)
  9541. if ioErr != nil {
  9542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9544. return
  9545. }
  9546. var respJSON map[string]interface{}
  9547. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9550. return
  9551. }
  9552. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9553. userJSONBytes, _ := json.Marshal(userJSON)
  9554. var res ResultTwo
  9555. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9556. utils.ErrorLog("解析失败:%v", err)
  9557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9558. return
  9559. }
  9560. if res.Infcode == 0 {
  9561. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9562. var dat map[string]interface{}
  9563. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9564. fmt.Println(dat)
  9565. } else {
  9566. fmt.Println(err)
  9567. }
  9568. userJSONBytes, _ := json.Marshal(dat)
  9569. var res2 ResultThirteen
  9570. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9571. utils.ErrorLog("解析失败:%v", err)
  9572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9573. return
  9574. }
  9575. if res2.Infcode == 0 {
  9576. psnResult := &models.GdybPsnRecord{
  9577. UserOrgId: adminUser.CurrentOrgId,
  9578. PatientId: item.ID,
  9579. PsnNo: res.Output.Baseinfo.PsnNo,
  9580. Ctime: time.Now().Unix(),
  9581. Mtime: time.Now().Unix(),
  9582. Status: 1,
  9583. IsCancel: 1,
  9584. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9585. }
  9586. service.CreatePsnRecord(psnResult)
  9587. } else {
  9588. c.ServeSuccessJSON(map[string]interface{}{
  9589. "failed_code": -10,
  9590. "msg": res2.ErrMsg,
  9591. })
  9592. return
  9593. }
  9594. }
  9595. }
  9596. }
  9597. }
  9598. func (c *HisApiController) PsnUnPutOnRecord() {
  9599. id, _ := c.GetInt64("id")
  9600. //record_type, _ := c.GetInt64("type")
  9601. admin_user_id, _ := c.GetInt64("admin_user_id")
  9602. adminUser := c.GetAdminUserInfo()
  9603. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9604. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9605. var user_name string
  9606. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9607. if role.ID == 0 {
  9608. user_name = "xxx"
  9609. } else {
  9610. user_name = role.UserName
  9611. }
  9612. psn_record, _ := service.GetPsnRecordById(id)
  9613. if psn_record.ID == 0 {
  9614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9615. return
  9616. }
  9617. if config.IsOpen == 1 {
  9618. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9619. var dat map[string]interface{}
  9620. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9621. fmt.Println(dat)
  9622. } else {
  9623. fmt.Println(err)
  9624. }
  9625. userJSONBytes, _ := json.Marshal(dat)
  9626. var res ResultFourteen
  9627. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9628. utils.ErrorLog("解析失败:%v", err)
  9629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9630. return
  9631. }
  9632. if res.Infcode == 0 {
  9633. psn_record.IsCancel = 2
  9634. service.CreatePsnRecord(&psn_record)
  9635. } else {
  9636. c.ServeSuccessJSON(map[string]interface{}{
  9637. "failed_code": -10,
  9638. "msg": res.ErrMsg,
  9639. })
  9640. return
  9641. }
  9642. }
  9643. }
  9644. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9645. patient_id, _ := c.GetInt64("patient_id")
  9646. insutype_two := c.GetString("insutype")
  9647. psn_no := c.GetString("psn_no")
  9648. doctor_id, _ := c.GetInt64("doctor_id")
  9649. sick_id, _ := c.GetInt64("sick_id")
  9650. department_id, _ := c.GetInt64("department_id")
  9651. start_time := c.GetString("start_time")
  9652. end_time := c.GetString("end_time")
  9653. check_time := c.GetString("check_time")
  9654. adminUser := c.GetAdminUserInfo()
  9655. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9656. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9657. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9658. sick, _ := service.FindSickById(sick_id)
  9659. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9660. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9661. var res ResultTwo
  9662. var res10265 ResultTwo10265
  9663. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9664. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9665. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9666. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9667. "&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
  9668. resp, requestErr := http.Get(api)
  9669. if requestErr != nil {
  9670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9671. return
  9672. }
  9673. body, ioErr := ioutil.ReadAll(resp.Body)
  9674. if ioErr != nil {
  9675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9677. return
  9678. }
  9679. var respJSON map[string]interface{}
  9680. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9683. return
  9684. }
  9685. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9686. result, _ := json.Marshal(respJSON)
  9687. fmt.Println("log")
  9688. fmt.Println(string(result))
  9689. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9690. utils.ErrorLog("解析失败:%v", err)
  9691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9692. return
  9693. }
  9694. res.ErrMsg = res10265.ErrMsg
  9695. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9696. res.Infcode = infocode
  9697. res.Output = res10265.Output
  9698. res.InfRefmsgid = res10265.InfRefmsgid
  9699. } else {
  9700. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9701. if miConfig.Code == "H15049901371" {
  9702. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9703. utils.ErrorLog("解析失败:%v", err)
  9704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9705. return
  9706. }
  9707. res.ErrMsg = res10265.ErrMsg
  9708. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9709. res.Infcode = infocode
  9710. res.Output = res10265.Output
  9711. res.InfRefmsgid = res10265.InfRefmsgid
  9712. } else {
  9713. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9714. utils.ErrorLog("解析失败:%v", err)
  9715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9716. return
  9717. }
  9718. }
  9719. }
  9720. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9721. infoStr := string(Iinfos)
  9722. var rf []*ResultFive
  9723. json.Unmarshal([]byte(infoStr), &rf)
  9724. var insuplc_admdvs string
  9725. var insutype string
  9726. var is390 int = 0
  9727. var is310 int = 0
  9728. var insutypes []*ResultFive
  9729. for _, item := range rf {
  9730. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9731. insutypes = append(insutypes, item)
  9732. }
  9733. }
  9734. if len(insutypes) == 1 {
  9735. insutype = insutypes[0].Insutype
  9736. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9737. } else {
  9738. for _, i := range insutypes {
  9739. if i.Insutype == "390" {
  9740. is390 = 1
  9741. }
  9742. if i.Insutype == "310" {
  9743. is310 = 1
  9744. }
  9745. }
  9746. }
  9747. if is390 == 1 {
  9748. insutype = "390"
  9749. }
  9750. if is310 == 1 {
  9751. insutype = "310"
  9752. }
  9753. if len(insutypes) == 2 {
  9754. insutype = insutype_two
  9755. }
  9756. if len(insutypes) == 0 {
  9757. insutype = "310"
  9758. }
  9759. insutype = insutype_two
  9760. fmt.Println(insutype)
  9761. for _, item := range rf {
  9762. fmt.Println(item.Insutype)
  9763. fmt.Println(insutype)
  9764. if item.Insutype == insutype {
  9765. fmt.Println(item.Insutype)
  9766. fmt.Println(insutype)
  9767. insuplc_admdvs = item.InsuplcAdmdvs
  9768. }
  9769. }
  9770. fmt.Println(insuplc_admdvs)
  9771. var res2 ResultThirteen
  9772. var res10265_2 ResultThirteen10265
  9773. if config.IsOpen == 1 {
  9774. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9775. } else {
  9776. 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)
  9777. var dat map[string]interface{}
  9778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9779. fmt.Println(dat)
  9780. } else {
  9781. fmt.Println(err)
  9782. }
  9783. userJSONBytes, _ := json.Marshal(dat)
  9784. if miConfig.Code == "H15049901371" {
  9785. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9786. utils.ErrorLog("解析失败:%v", err)
  9787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9788. return
  9789. }
  9790. res2.ErrMsg = res10265_2.ErrMsg
  9791. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9792. res2.Infcode = infocode
  9793. res2.Output = res10265_2.Output
  9794. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9795. } else {
  9796. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9797. utils.ErrorLog("解析失败:%v", err)
  9798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9799. return
  9800. }
  9801. }
  9802. }
  9803. if res2.Infcode == 0 {
  9804. psnResult := &models.GdybPsnNcdsRecord{
  9805. UserOrgId: adminUser.CurrentOrgId,
  9806. PatientId: patient.ID,
  9807. PsnNo: psn_no,
  9808. DoctorId: doctor.AdminUserId,
  9809. DepartmentId: department_id,
  9810. SickType: sick_id,
  9811. Insutype: insutype,
  9812. Ctime: time.Now().Unix(),
  9813. Mtime: time.Now().Unix(),
  9814. Status: 1,
  9815. IsCancel: 1,
  9816. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9817. }
  9818. service.CreatePsnNCDSRecord(psnResult)
  9819. c.ServeSuccessJSON(map[string]interface{}{
  9820. "failed_code": 0,
  9821. "msg": "备案成功",
  9822. "result": psnResult,
  9823. })
  9824. } else {
  9825. c.ServeSuccessJSON(map[string]interface{}{
  9826. "failed_code": -10,
  9827. "msg": res2.ErrMsg,
  9828. })
  9829. return
  9830. }
  9831. }
  9832. }
  9833. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9834. id, _ := c.GetInt64("id")
  9835. admin_user_id, _ := c.GetInt64("admin_user_id")
  9836. adminUser := c.GetAdminUserInfo()
  9837. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9838. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9839. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9840. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9841. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9842. //var user_name string
  9843. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9844. //if role.ID == 0 {
  9845. // user_name = "xxx"
  9846. //} else {
  9847. // user_name = role.UserName
  9848. //}
  9849. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9850. if psn_record.ID == 0 {
  9851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9852. return
  9853. }
  9854. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9855. var res ResultTwo
  9856. var res10265 ResultTwo10265
  9857. if miConfig.Code == "H15049901371" {
  9858. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9859. utils.ErrorLog("解析失败:%v", err)
  9860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9861. return
  9862. }
  9863. res.ErrMsg = res10265.ErrMsg
  9864. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9865. res.Infcode = infocode
  9866. res.Output = res10265.Output
  9867. res.InfRefmsgid = res10265.InfRefmsgid
  9868. } else {
  9869. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9870. utils.ErrorLog("解析失败:%v", err)
  9871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9872. return
  9873. }
  9874. }
  9875. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9876. infoStr := string(Iinfos)
  9877. var rf []*ResultFive
  9878. json.Unmarshal([]byte(infoStr), &rf)
  9879. var insuplc_admdvs string
  9880. var insutype string
  9881. var is390 int = 0
  9882. var is310 int = 0
  9883. var insutypes []*ResultFive
  9884. for _, item := range rf {
  9885. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9886. insutypes = append(insutypes, item)
  9887. }
  9888. }
  9889. if len(insutypes) == 1 {
  9890. insutype = insutypes[0].Insutype
  9891. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9892. } else {
  9893. for _, i := range insutypes {
  9894. if i.Insutype == "390" {
  9895. is390 = 1
  9896. }
  9897. if i.Insutype == "310" {
  9898. is310 = 1
  9899. }
  9900. }
  9901. }
  9902. if is390 == 1 {
  9903. insutype = "390"
  9904. }
  9905. if is310 == 1 {
  9906. insutype = "310"
  9907. }
  9908. if len(insutypes) == 0 {
  9909. insutype = "310"
  9910. }
  9911. insutype = psn_record.Insutype
  9912. for _, item := range rf {
  9913. if item.Insutype == insutype {
  9914. insuplc_admdvs = item.InsuplcAdmdvs
  9915. }
  9916. }
  9917. if config.IsOpen == 1 {
  9918. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9919. var dat map[string]interface{}
  9920. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9921. fmt.Println(dat)
  9922. } else {
  9923. fmt.Println(err)
  9924. }
  9925. userJSONBytes, _ := json.Marshal(dat)
  9926. var res ResultFourteen
  9927. var res10265 ResultFourteen10265
  9928. if miConfig.Code == "H15049901371" {
  9929. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9930. utils.ErrorLog("解析失败:%v", err)
  9931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9932. return
  9933. }
  9934. res.ErrMsg = res10265.ErrMsg
  9935. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9936. res.Infcode = infocode
  9937. res.Output = res10265.Output
  9938. res.InfRefmsgid = res10265.InfRefmsgid
  9939. } else {
  9940. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9941. utils.ErrorLog("解析失败:%v", err)
  9942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9943. return
  9944. }
  9945. }
  9946. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9947. // utils.ErrorLog("解析失败:%v", err)
  9948. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9949. // return
  9950. //}
  9951. if res.Infcode == 0 {
  9952. psn_record.IsCancel = 2
  9953. service.CreatePsnNCDSRecord(&psn_record)
  9954. c.ServeSuccessJSON(map[string]interface{}{
  9955. "failed_code": 0,
  9956. "msg": "撤销备案成功",
  9957. })
  9958. } else {
  9959. c.ServeSuccessJSON(map[string]interface{}{
  9960. "failed_code": -10,
  9961. "msg": res.ErrMsg,
  9962. })
  9963. return
  9964. }
  9965. }
  9966. }
  9967. func (c *HisApiController) TestTest() {
  9968. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9969. fmt.Println(patient.Iinfo)
  9970. }
  9971. type CustomData struct {
  9972. MsgId string
  9973. PsnNo string
  9974. Info string
  9975. }
  9976. func (c *HisApiController) ReversalData() {
  9977. var customData []*CustomData
  9978. custom := &CustomData{
  9979. MsgId: "H44022900158202103301714472004",
  9980. PsnNo: "44020000001101329945",
  9981. Info: "2207",
  9982. }
  9983. customData = append(customData, custom)
  9984. custom1 := &CustomData{
  9985. MsgId: "H4402290015820210330172057803",
  9986. PsnNo: "44020000001101161813",
  9987. Info: "2207",
  9988. }
  9989. customData = append(customData, custom1)
  9990. custom2 := &CustomData{
  9991. MsgId: "H44022900158202103301705198813",
  9992. PsnNo: "44190000133097375417",
  9993. Info: "2207",
  9994. }
  9995. customData = append(customData, custom2)
  9996. custom3 := &CustomData{
  9997. MsgId: "H44022900158202103301715524756",
  9998. PsnNo: "44020000001100187221",
  9999. Info: "2207",
  10000. }
  10001. customData = append(customData, custom3)
  10002. custom4 := &CustomData{
  10003. MsgId: "H44022900158202103301730376224",
  10004. PsnNo: "44020000001101959155",
  10005. Info: "2207",
  10006. }
  10007. customData = append(customData, custom4)
  10008. custom5 := &CustomData{
  10009. MsgId: "H44022900158202103301748008725",
  10010. PsnNo: "44020000001104246641",
  10011. Info: "2207",
  10012. }
  10013. customData = append(customData, custom5)
  10014. custom6 := &CustomData{
  10015. MsgId: "H44022900158202103301718096755",
  10016. PsnNo: "44020000001102211860",
  10017. Info: "2207",
  10018. }
  10019. customData = append(customData, custom6)
  10020. custom7 := &CustomData{
  10021. MsgId: "H44022900158202103301736551640",
  10022. PsnNo: "44020000001102687718",
  10023. Info: "2207",
  10024. }
  10025. customData = append(customData, custom7)
  10026. custom8 := &CustomData{
  10027. MsgId: "H44022900158202103301743097676",
  10028. PsnNo: "44020000001102127785",
  10029. Info: "2207",
  10030. }
  10031. customData = append(customData, custom8)
  10032. custom9 := &CustomData{
  10033. MsgId: "H44022900158202103301712304203",
  10034. PsnNo: "44020000001101518097",
  10035. Info: "2207",
  10036. }
  10037. customData = append(customData, custom9)
  10038. custom10 := &CustomData{
  10039. MsgId: "H44022900158202103301738448785",
  10040. PsnNo: "44020000001100500813",
  10041. Info: "2207",
  10042. }
  10043. customData = append(customData, custom10)
  10044. custom11 := &CustomData{
  10045. MsgId: "H44022900158202103301732455843",
  10046. PsnNo: "44020000001102690557",
  10047. Info: "2207",
  10048. }
  10049. customData = append(customData, custom11)
  10050. custom12 := &CustomData{
  10051. MsgId: "H44022900158202103301745421708",
  10052. PsnNo: "44020000001102211928",
  10053. Info: "2207",
  10054. }
  10055. customData = append(customData, custom12)
  10056. custom1212 := &CustomData{
  10057. MsgId: "H440229001582021033017351627",
  10058. PsnNo: "44020000001102481733",
  10059. Info: "2207",
  10060. }
  10061. customData = append(customData, custom1212)
  10062. custom13 := &CustomData{
  10063. MsgId: "H44022900158202103301740327951",
  10064. PsnNo: "44020000001103174866",
  10065. Info: "2207",
  10066. }
  10067. customData = append(customData, custom13)
  10068. custom14 := &CustomData{
  10069. MsgId: "H4402290015820210330174922668",
  10070. PsnNo: "44020000001102927272",
  10071. Info: "2207",
  10072. }
  10073. customData = append(customData, custom14)
  10074. custom15 := &CustomData{
  10075. MsgId: "H44022900158202103301752362273",
  10076. PsnNo: "44020000001102942890",
  10077. Info: "2207",
  10078. }
  10079. customData = append(customData, custom15)
  10080. custom16 := &CustomData{
  10081. MsgId: "H44022900158202103301751082917",
  10082. PsnNo: "44020000001101662162",
  10083. Info: "2207",
  10084. }
  10085. customData = append(customData, custom16)
  10086. custom17 := &CustomData{
  10087. MsgId: "H44022900158202103301754147728",
  10088. PsnNo: "44020000000229014511",
  10089. Info: "2207",
  10090. }
  10091. customData = append(customData, custom17)
  10092. adminUser := c.GetAdminUserInfo()
  10093. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10094. for _, item := range customData {
  10095. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10096. fmt.Println(result)
  10097. }
  10098. }
  10099. func (c *HisApiController) GetAllopatry() {
  10100. year := c.GetString("year")
  10101. month := c.GetString("month")
  10102. admin_user_id, _ := c.GetInt64("admin_user_id")
  10103. adminUser := c.GetAdminUserInfo()
  10104. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10105. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10106. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10107. var dat map[string]interface{}
  10108. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10109. fmt.Println(dat)
  10110. } else {
  10111. fmt.Println(err)
  10112. }
  10113. userJSONBytes, _ := json.Marshal(dat)
  10114. var res models.Result9001
  10115. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10116. utils.ErrorLog("解析失败:%v", err)
  10117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10118. return
  10119. }
  10120. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10121. var dat2 map[string]interface{}
  10122. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10123. fmt.Println(dat)
  10124. } else {
  10125. fmt.Println(err)
  10126. }
  10127. userJSONBytes2, _ := json.Marshal(dat2)
  10128. var res2 models.Result3260
  10129. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10130. utils.ErrorLog("解析失败:%v", err)
  10131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10132. return
  10133. }
  10134. if res2.Infcode == 0 {
  10135. c.ServeSuccessJSON(map[string]interface{}{
  10136. "list": res2.Output.Data,
  10137. })
  10138. return
  10139. } else {
  10140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10141. return
  10142. }
  10143. }
  10144. func (c *HisApiController) ComfirmAllopatry() {
  10145. year := c.GetString("year")
  10146. month := c.GetString("month")
  10147. admin_user_id, _ := c.GetInt64("admin_user_id")
  10148. adminUser := c.GetAdminUserInfo()
  10149. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10150. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10151. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10152. var dat map[string]interface{}
  10153. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10154. fmt.Println(dat)
  10155. } else {
  10156. fmt.Println(err)
  10157. }
  10158. userJSONBytes, _ := json.Marshal(dat)
  10159. var res models.Result9001
  10160. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10161. utils.ErrorLog("解析失败:%v", err)
  10162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10163. return
  10164. }
  10165. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10166. var dat2 map[string]interface{}
  10167. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10168. fmt.Println(dat)
  10169. } else {
  10170. fmt.Println(err)
  10171. }
  10172. userJSONBytes2, _ := json.Marshal(dat2)
  10173. var res2 models.Result3260
  10174. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10175. utils.ErrorLog("解析失败:%v", err)
  10176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10177. return
  10178. }
  10179. if res2.Infcode == 0 {
  10180. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10181. var dat map[string]interface{}
  10182. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10183. fmt.Println(dat)
  10184. } else {
  10185. fmt.Println(err)
  10186. }
  10187. userJSONBytes, _ := json.Marshal(dat)
  10188. var res3 models.Result3261
  10189. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10190. utils.ErrorLog("解析失败:%v", err)
  10191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10192. return
  10193. }
  10194. if res3.Infcode == 0 {
  10195. record := &models.HisYidiClearRecord{
  10196. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10197. Ctime: time.Now().Unix(),
  10198. Mtime: time.Now().Unix(),
  10199. Status: 1,
  10200. MsgId: msgId,
  10201. }
  10202. service.SaveClearRecord(record)
  10203. c.ServeSuccessJSON(map[string]interface{}{
  10204. "msg": "提取成功",
  10205. })
  10206. }
  10207. }
  10208. }
  10209. func (c *HisApiController) RefundAllopatry() {
  10210. year := c.GetString("year")
  10211. month := c.GetString("month")
  10212. id, _ := c.GetInt64("id")
  10213. admin_user_id, _ := c.GetInt64("admin_user_id")
  10214. adminUser := c.GetAdminUserInfo()
  10215. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10216. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10217. record, _ := service.GetClearRecordById(id)
  10218. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10219. var dat map[string]interface{}
  10220. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10221. fmt.Println(dat)
  10222. } else {
  10223. fmt.Println(err)
  10224. }
  10225. userJSONBytes, _ := json.Marshal(dat)
  10226. var empty ResultFourteen
  10227. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10228. utils.ErrorLog("解析失败:%v", err)
  10229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10230. return
  10231. }
  10232. if empty.Infcode == 0 {
  10233. c.ServeSuccessJSON(map[string]interface{}{
  10234. "msg": "撤销成功",
  10235. })
  10236. return
  10237. }
  10238. }
  10239. func (c *HisApiController) ReversalOtherData() {
  10240. var customData []*CustomData
  10241. custom := &CustomData{
  10242. MsgId: "H44022900158202103301714472004",
  10243. PsnNo: "44020000001101329945",
  10244. Info: "2208",
  10245. }
  10246. customData = append(customData, custom)
  10247. custom1 := &CustomData{
  10248. MsgId: "H4402290015820210330172057803",
  10249. PsnNo: "44020000001101161813",
  10250. Info: "2208",
  10251. }
  10252. customData = append(customData, custom1)
  10253. custom2 := &CustomData{
  10254. MsgId: "H44022900158202103301705198813",
  10255. PsnNo: "44190000133097375417",
  10256. Info: "2208",
  10257. }
  10258. customData = append(customData, custom2)
  10259. custom3 := &CustomData{
  10260. MsgId: "H44022900158202103301715524756",
  10261. PsnNo: "44020000001100187221",
  10262. Info: "2208",
  10263. }
  10264. customData = append(customData, custom3)
  10265. custom4 := &CustomData{
  10266. MsgId: "H44022900158202103301730376224",
  10267. PsnNo: "44020000001101959155",
  10268. Info: "2208",
  10269. }
  10270. customData = append(customData, custom4)
  10271. custom5 := &CustomData{
  10272. MsgId: "H44022900158202103301748008725",
  10273. PsnNo: "44020000001104246641",
  10274. Info: "2208",
  10275. }
  10276. customData = append(customData, custom5)
  10277. custom6 := &CustomData{
  10278. MsgId: "H44022900158202103301718096755",
  10279. PsnNo: "44020000001102211860",
  10280. Info: "2208",
  10281. }
  10282. customData = append(customData, custom6)
  10283. custom7 := &CustomData{
  10284. MsgId: "H44022900158202103301736551640",
  10285. PsnNo: "44020000001102687718",
  10286. Info: "2208",
  10287. }
  10288. customData = append(customData, custom7)
  10289. custom8 := &CustomData{
  10290. MsgId: "H44022900158202103301743097676",
  10291. PsnNo: "44020000001102127785",
  10292. Info: "2208",
  10293. }
  10294. customData = append(customData, custom8)
  10295. custom9 := &CustomData{
  10296. MsgId: "H44022900158202103301712304203",
  10297. PsnNo: "44020000001101518097",
  10298. Info: "2208",
  10299. }
  10300. customData = append(customData, custom9)
  10301. custom10 := &CustomData{
  10302. MsgId: "H44022900158202103301738448785",
  10303. PsnNo: "44020000001100500813",
  10304. Info: "2208",
  10305. }
  10306. customData = append(customData, custom10)
  10307. custom11 := &CustomData{
  10308. MsgId: "H44022900158202103301732455843",
  10309. PsnNo: "44020000001102690557",
  10310. Info: "2208",
  10311. }
  10312. customData = append(customData, custom11)
  10313. custom12 := &CustomData{
  10314. MsgId: "H44022900158202103301745421708",
  10315. PsnNo: "44020000001102211928",
  10316. Info: "2208",
  10317. }
  10318. customData = append(customData, custom12)
  10319. custom1212 := &CustomData{
  10320. MsgId: "H440229001582021033017351627",
  10321. PsnNo: "44020000001102481733",
  10322. Info: "2208",
  10323. }
  10324. customData = append(customData, custom1212)
  10325. custom13 := &CustomData{
  10326. MsgId: "H44022900158202103301740327951",
  10327. PsnNo: "44020000001103174866",
  10328. Info: "2208",
  10329. }
  10330. customData = append(customData, custom13)
  10331. custom14 := &CustomData{
  10332. MsgId: "H4402290015820210330174922668",
  10333. PsnNo: "44020000001102927272",
  10334. Info: "2208",
  10335. }
  10336. customData = append(customData, custom14)
  10337. custom15 := &CustomData{
  10338. MsgId: "H44022900158202103301752362273",
  10339. PsnNo: "44020000001102942890",
  10340. Info: "2208",
  10341. }
  10342. customData = append(customData, custom15)
  10343. custom16 := &CustomData{
  10344. MsgId: "H44022900158202103301751082917",
  10345. PsnNo: "44020000001101662162",
  10346. Info: "2208",
  10347. }
  10348. customData = append(customData, custom16)
  10349. custom17 := &CustomData{
  10350. MsgId: "H44022900158202103301754147728",
  10351. PsnNo: "44020000000229014511",
  10352. Info: "2208",
  10353. }
  10354. customData = append(customData, custom17)
  10355. adminUser := c.GetAdminUserInfo()
  10356. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10357. for _, item := range customData {
  10358. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10359. fmt.Println(result)
  10360. }
  10361. }
  10362. func PathExists(path string) (bool, error) {
  10363. _, err := os.Stat(path)
  10364. if err == nil {
  10365. return true, nil
  10366. }
  10367. if os.IsNotExist(err) {
  10368. return false, nil
  10369. }
  10370. return false, err
  10371. }
  10372. //创建文件夹
  10373. func Mkdir(dir string) {
  10374. // 创建文件夹
  10375. exist, err := PathExists(dir)
  10376. if err != nil {
  10377. fmt.Println(err.Error())
  10378. } else {
  10379. if exist {
  10380. fmt.Println(dir + "文件夹已存在!")
  10381. } else {
  10382. // 文件夹名称,权限
  10383. err := os.Mkdir(dir, os.ModePerm)
  10384. if err != nil {
  10385. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10386. } else {
  10387. fmt.Println(dir + "文件夹创建成功!")
  10388. }
  10389. }
  10390. }
  10391. }
  10392. //压缩文件
  10393. func Zip(srcFile string, destZip string) error {
  10394. zipfile, err := os.Create(destZip)
  10395. if err != nil {
  10396. return err
  10397. }
  10398. defer zipfile.Close()
  10399. archive := zip.NewWriter(zipfile)
  10400. defer archive.Close()
  10401. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10402. if err != nil {
  10403. return err
  10404. }
  10405. header, err := zip.FileInfoHeader(info)
  10406. if err != nil {
  10407. return err
  10408. }
  10409. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10410. // header.Name = path
  10411. if info.IsDir() {
  10412. header.Name += "/"
  10413. } else {
  10414. header.Method = zip.Deflate
  10415. }
  10416. writer, err := archive.CreateHeader(header)
  10417. if err != nil {
  10418. return err
  10419. }
  10420. if !info.IsDir() {
  10421. file, err := os.Open(path)
  10422. if err != nil {
  10423. return err
  10424. }
  10425. defer file.Close()
  10426. _, err = io.Copy(writer, file)
  10427. }
  10428. return err
  10429. })
  10430. return err
  10431. }
  10432. func ReadFile(filePath string) []byte {
  10433. f, err := os.Open(filePath)
  10434. if err != nil {
  10435. fmt.Println("read file fail", err)
  10436. return nil
  10437. }
  10438. defer f.Close()
  10439. fd, err := ioutil.ReadAll(f)
  10440. if err != nil {
  10441. fmt.Println("read to fd fail", err)
  10442. return nil
  10443. }
  10444. return fd
  10445. }
  10446. func saveLog(result string, request string, infno string, desc string) {
  10447. org_id, _ := beego.AppConfig.Int64("org_id")
  10448. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10449. dir := miConfig.OrgName + "日志"
  10450. utils.Mkdir(dir)
  10451. month := time.Unix(1557042972, 0).Format("1")
  10452. year := time.Now().Format("2006")
  10453. month = time.Now().Format("01")
  10454. day := time.Now().Format("02")
  10455. hour := time.Now().Format("15")
  10456. min := time.Now().Format("04")
  10457. sec := time.Now().Format("05")
  10458. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10459. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10460. file_name := file + ".txt"
  10461. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10462. exist, _ := utils.PathExists(file_path)
  10463. if exist { //存在
  10464. fmt.Println("存在")
  10465. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10466. if err != nil {
  10467. fmt.Println("read fail")
  10468. }
  10469. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10470. n, _ := f.Seek(0, 2)
  10471. _, err = f.WriteAt([]byte(content), n)
  10472. } else { //不存在
  10473. fmt.Println("文件不存在,创建文件")
  10474. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10475. defer f.Close()
  10476. if err != nil {
  10477. } else {
  10478. _, err = f.Write([]byte("记录日志"))
  10479. }
  10480. }
  10481. }
  10482. type Charset string
  10483. const (
  10484. UTF8 = Charset("UTF-8")
  10485. GB18030 = Charset("GB18030")
  10486. )
  10487. func ConvertToString(src string, srcCode string, tagCode string) string {
  10488. srcCoder := mahonia.NewDecoder(srcCode)
  10489. srcResult := srcCoder.ConvertString(src)
  10490. tagCoder := mahonia.NewDecoder(tagCode)
  10491. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10492. result := string(cdata)
  10493. return result
  10494. }