his_api_controller.go 428KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701
  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. fed.MedType = "11"
  173. //if his.Insutype == "390" {
  174. // fed.MedType = "1402"
  175. //} else {
  176. // fed.MedType = "9933"
  177. //}
  178. var orders []*models.FsiOrderDtos
  179. if trig_scen == "2" {
  180. //处方医嘱信息
  181. for _, item := range prescriptions {
  182. for _, subItem := range item.HisDoctorAdviceInfo {
  183. var order models.FsiOrderDtos
  184. order.RxID = strconv.FormatInt(item.ID, 10)
  185. order.Rxno = strconv.FormatInt(item.ID, 10)
  186. order.LongDrordFlag = "0"
  187. order.HilistType = "1"
  188. order.ChrgType = "1"
  189. order.DrordBhvr = "-"
  190. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  191. order.HosplistName = subItem.BaseDrugLib.DrugName
  192. order.HilistLv = "1"
  193. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  194. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  195. order.HosplistName = subItem.BaseDrugLib.DrugName
  196. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  197. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  198. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  199. order.OwnpayAmt = ""
  200. order.SelfpayAmt = ""
  201. order.Spec = ""
  202. order.SpecUnt = ""
  203. order.DrordBegnDate = s_tm
  204. order.DrordStopDate = ""
  205. order.DrordDrCodg = "1"
  206. order.DrordDeptName = department.Name
  207. order.DrordDrCodg = "1"
  208. order.DrordDrName = doctor_info.UserName
  209. order.DrordDrProfttl = ""
  210. order.CurrDrordFlag = "1"
  211. orders = append(orders, &order)
  212. }
  213. for _, subItem := range item.HisPrescriptionProject {
  214. if subItem.Type == 2 {
  215. var order models.FsiOrderDtos
  216. order.RxID = strconv.FormatInt(item.ID, 10)
  217. order.Rxno = strconv.FormatInt(item.ID, 10)
  218. order.LongDrordFlag = "0"
  219. order.HilistType = "1"
  220. order.ChrgType = "1"
  221. order.DrordBhvr = "-"
  222. order.HilistCode = subItem.HisProject.MedicalCode
  223. order.HosplistName = subItem.HisProject.ProjectName
  224. order.HilistLv = "1"
  225. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  226. order.HosplistCode = subItem.HisProject.MedicalCode
  227. order.HosplistName = subItem.HisProject.ProjectName
  228. order.Cnt = subItem.Count
  229. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  230. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  231. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  232. order.OwnpayAmt = ""
  233. order.SelfpayAmt = ""
  234. order.Spec = ""
  235. order.SpecUnt = ""
  236. order.DrordBegnDate = s_tm
  237. order.DrordStopDate = ""
  238. order.DrordDrCodg = "1"
  239. order.DrordDeptName = department.Name
  240. order.DrordDrCodg = "1"
  241. order.DrordDrName = doctor_info.UserName
  242. order.DrordDrProfttl = ""
  243. order.CurrDrordFlag = "1"
  244. orders = append(orders, &order)
  245. }
  246. if subItem.Type == 3 {
  247. var order models.FsiOrderDtos
  248. order.RxID = strconv.FormatInt(item.ID, 10)
  249. order.Rxno = strconv.FormatInt(item.ID, 10)
  250. order.LongDrordFlag = "0"
  251. order.HilistType = "1"
  252. order.ChrgType = "1"
  253. order.DrordBhvr = "-"
  254. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  255. order.HosplistName = subItem.GoodInfo.GoodName
  256. order.HilistLv = "1"
  257. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  258. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  259. order.HosplistName = subItem.GoodInfo.GoodName
  260. order.Cnt = subItem.Count
  261. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  262. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  263. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  264. order.OwnpayAmt = ""
  265. order.SelfpayAmt = ""
  266. order.Spec = ""
  267. order.SpecUnt = ""
  268. order.DrordBegnDate = s_tm
  269. order.DrordStopDate = ""
  270. order.DrordDrCodg = "1"
  271. order.DrordDeptName = department.Name
  272. order.DrordDrCodg = "1"
  273. order.DrordDrName = doctor_info.UserName
  274. order.DrordDrProfttl = ""
  275. order.CurrDrordFlag = "1"
  276. orders = append(orders, &order)
  277. }
  278. }
  279. }
  280. //处方医嘱信息
  281. }
  282. fed.MatnStas = "0"
  283. fed.MedfeeSumamt = "0"
  284. fed.OwnpayAmt = "0"
  285. fed.SelfpayAmt = "0"
  286. fed.AcctPayamt = "0"
  287. fed.MaAmt = "0"
  288. fed.HifpPayamt = "0"
  289. fed.SetlTotlnum = "1"
  290. fed.Insutype = his.Insutype
  291. fed.ReimFlag = "0"
  292. fed.OutSetlFlag = "0"
  293. var fopd []*models.FsiOperationDtosData
  294. data := make(map[string]interface{})
  295. data["fed"] = fed
  296. data["fdd"] = fdds
  297. data["fod"] = orders
  298. data["pd"] = pd
  299. data["pp"] = pp
  300. data["fopd"] = fopd
  301. data["trig_scen"] = trig_scen
  302. fmt.Println(data)
  303. fmt.Println(fed)
  304. fmt.Println(fdds)
  305. fmt.Println(orders)
  306. fmt.Println(pd)
  307. fmt.Println(pp)
  308. fmt.Println(fopd)
  309. client := &http.Client{}
  310. bytesData, _ := json.Marshal(data)
  311. var req *http.Request
  312. if miConfig.MdtrtareaAdmvs == "320921" {
  313. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  314. } else {
  315. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  316. }
  317. resp, _ := client.Do(req)
  318. defer resp.Body.Close()
  319. body, ioErr := ioutil.ReadAll(resp.Body)
  320. if ioErr != nil {
  321. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  323. return
  324. }
  325. var respJSON map[string]interface{}
  326. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  329. return
  330. }
  331. //手术操作集合
  332. //手术操作集合
  333. }
  334. func (c *HisApiController) Check3102() {
  335. patient_id, _ := c.GetInt64("patient_id")
  336. order_id, _ := c.GetInt64("order_id")
  337. his_patient_id, _ := c.GetInt64("his_patient_id")
  338. admin_user_id, _ := c.GetInt64("admin_user_id")
  339. trig_scen := c.GetString("trig_scen")
  340. adminUser := c.GetAdminUserInfo()
  341. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  342. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  343. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  344. record_time := c.GetString("record_time")
  345. order, _ := service.GetHisOrderByID(order_id)
  346. timeLayout := "2006-01-02"
  347. loc, _ := time.LoadLocation("Local")
  348. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  349. if err != nil {
  350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  351. return
  352. }
  353. recordDateTime := theTime.Unix()
  354. var patientPrescription models.HisPrescriptionInfo
  355. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  356. if patientPrescription.ID == 0 {
  357. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  358. }
  359. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  360. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  361. //
  362. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  363. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  364. var pp models.PublicParams
  365. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  366. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  367. pp.FixmedinsName = miConfig.OrgName
  368. pp.FixmedinsCode = miConfig.Code
  369. pp.RequestUrl = miConfig.Url
  370. pp.Cainfo = miConfig.Cainfo
  371. pp.SecretKey = miConfig.SecretKey
  372. pp.AccessKey = miConfig.AccessKey
  373. pp.OpterName = roles.UserName
  374. var config []*models.HisXtDiagnoseConfig
  375. for _, item := range diagnosis_ids {
  376. id, _ := strconv.ParseInt(item, 10, 64)
  377. diagnosisConfig, _ := service.FindDiagnoseById(id)
  378. config = append(config, &diagnosisConfig)
  379. }
  380. var pd models.PatientDtos
  381. pd.PatnID = his.PsnNo
  382. pd.PatnName = his.Name
  383. pd.Gend = his.Gend
  384. pd.Brdy = his.Brdy
  385. pd.Poolarea = his.InsuplcAdmdvs
  386. pd.CurrMdtrtID = his.Number
  387. var fed models.FsiEncounterDtos
  388. fed.MdtrtID = his.Number
  389. fed.MedinsID = miConfig.Code
  390. fed.MedinsName = miConfig.OrgName
  391. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  392. fed.MedMdtrtType = "1"
  393. fed.MedinsType = "1"
  394. fed.MedinsLv = "11"
  395. tm := time.Unix(his.RecordDate, 0)
  396. s_tm := tm.Format("2006-01-02 15:04:05")
  397. fed.AdmDate = s_tm
  398. fed.DscgDate = s_tm
  399. fed.DscgMainDiseCodg = config[0].CountryCode
  400. fed.DscgMainDiseName = config[0].CountryContentName
  401. //诊断信息
  402. var fdds []*models.FsiDiagnoseDtos
  403. for index, item := range config {
  404. if index == 0 {
  405. var fdd models.FsiDiagnoseDtos
  406. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  407. fdd.InoutDiseType = "1"
  408. fdd.MaindiseFlag = "1"
  409. fdd.DiseDate = s_tm
  410. fdd.DiasSrtNo = "1"
  411. fdd.DiseName = item.CountryContentName
  412. fdd.DiseCodg = item.CountryCode
  413. fdds = append(fdds, &fdd)
  414. } else {
  415. var fdd models.FsiDiagnoseDtos
  416. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  417. fdd.InoutDiseType = "1"
  418. fdd.MaindiseFlag = "1"
  419. fdd.DiseDate = s_tm
  420. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  421. fdd.DiseName = item.CountryContentName
  422. fdd.DiseCodg = item.CountryCode
  423. fdds = append(fdds, &fdd)
  424. }
  425. }
  426. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  427. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  428. fed.AdmDeptName = department.Name
  429. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  430. fed.DscgDeptName = department.Name
  431. fed.MedType = order.MedType
  432. //处方医嘱信息
  433. var orders []*models.FsiOrderDtos
  434. //for _, item := range prescriptions {
  435. // for _, subItem := range item.HisDoctorAdviceInfo {
  436. // var order models.FsiOrderDtos
  437. // order.RxID = strconv.FormatInt(item.ID, 10)
  438. // order.Rxno = strconv.FormatInt(item.ID, 10)
  439. // order.LongDrordFlag = "0"
  440. // order.HilistType = "1"
  441. // order.ChrgType = "1"
  442. // order.DrordBhvr = "-"
  443. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  444. // order.HosplistName = subItem.BaseDrugLib.DrugName
  445. // order.HilistLv = "1"
  446. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  447. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  448. // order.HosplistName = subItem.BaseDrugLib.DrugName
  449. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  450. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  451. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  452. // order.OwnpayAmt = ""
  453. // order.SelfpayAmt = ""
  454. // order.Spec = ""
  455. // order.SpecUnt = ""
  456. // order.DrordBegnDate = s_tm
  457. // order.DrordStopDate = ""
  458. // order.DrordDrCodg = "1"
  459. // order.DrordDeptName = department.Name
  460. // order.DrordDrCodg = "1"
  461. // order.DrordDrName = doctor_info.UserName
  462. // order.DrordDrProfttl = ""
  463. // order.CurrDrordFlag = "1"
  464. // orders = append(orders, &order)
  465. // }
  466. // for _, subItem := range item.HisPrescriptionProject {
  467. // if subItem.Type == 2 {
  468. // var order models.FsiOrderDtos
  469. // order.RxID = strconv.FormatInt(item.ID, 10)
  470. // order.Rxno = strconv.FormatInt(item.ID, 10)
  471. // order.LongDrordFlag = "0"
  472. // order.HilistType = "1"
  473. // order.ChrgType = "1"
  474. // order.DrordBhvr = "-"
  475. // order.HilistCode = subItem.HisProject.MedicalCode
  476. // order.HosplistName = subItem.HisProject.ProjectName
  477. // order.HilistLv = "1"
  478. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  479. // order.HosplistCode = subItem.HisProject.MedicalCode
  480. // order.HosplistName = subItem.HisProject.ProjectName
  481. // order.Cnt = subItem.Count
  482. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  483. //
  484. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  485. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  486. // order.OwnpayAmt = ""
  487. // order.SelfpayAmt = ""
  488. // order.Spec = ""
  489. // order.SpecUnt = ""
  490. // order.DrordBegnDate = s_tm
  491. // order.DrordStopDate = ""
  492. // order.DrordDrCodg = "1"
  493. // order.DrordDeptName = department.Name
  494. // order.DrordDrCodg = "1"
  495. // order.DrordDrName = doctor_info.UserName
  496. // order.DrordDrProfttl = ""
  497. // order.CurrDrordFlag = "1"
  498. // orders = append(orders, &order)
  499. //
  500. // }
  501. // if subItem.Type == 3 {
  502. //
  503. // var order models.FsiOrderDtos
  504. // order.RxID = strconv.FormatInt(item.ID, 10)
  505. // order.Rxno = strconv.FormatInt(item.ID, 10)
  506. // order.LongDrordFlag = "0"
  507. // order.HilistType = "1"
  508. // order.ChrgType = "1"
  509. // order.DrordBhvr = "-"
  510. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  511. // order.HosplistName = subItem.GoodInfo.GoodName
  512. // order.HilistLv = "1"
  513. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  514. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  515. // order.HosplistName = subItem.GoodInfo.GoodName
  516. // order.Cnt = subItem.Count
  517. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  518. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  519. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  520. // order.OwnpayAmt = ""
  521. // order.SelfpayAmt = ""
  522. // order.Spec = ""
  523. // order.SpecUnt = ""
  524. // order.DrordBegnDate = s_tm
  525. // order.DrordStopDate = ""
  526. // order.DrordDrCodg = "1"
  527. // order.DrordDeptName = department.Name
  528. // order.DrordDrCodg = "1"
  529. // order.DrordDrName = doctor_info.UserName
  530. // order.DrordDrProfttl = ""
  531. // order.CurrDrordFlag = "1"
  532. // orders = append(orders, &order)
  533. //
  534. // }
  535. // }
  536. //}
  537. for _, item := range prescriptions {
  538. for _, subItem := range item.HisDoctorAdviceInfo {
  539. var order models.FsiOrderDtos
  540. order.RxID = strconv.FormatInt(item.ID, 10)
  541. order.Rxno = strconv.FormatInt(item.ID, 10)
  542. order.LongDrordFlag = "0"
  543. order.HilistType = "1"
  544. order.ChrgType = "1"
  545. order.DrordBhvr = "-"
  546. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  547. order.HosplistName = subItem.BaseDrugLib.DrugName
  548. order.HilistLv = "1"
  549. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  550. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  551. order.HosplistName = subItem.BaseDrugLib.DrugName
  552. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  553. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  554. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  555. order.OwnpayAmt = ""
  556. order.SelfpayAmt = ""
  557. order.Spec = ""
  558. order.SpecUnt = ""
  559. order.DrordBegnDate = s_tm
  560. order.DrordStopDate = ""
  561. order.DrordDrCodg = "1"
  562. order.DrordDeptName = department.Name
  563. order.DrordDrCodg = "1"
  564. order.DrordDrName = doctor_info.UserName
  565. order.DrordDrProfttl = ""
  566. order.CurrDrordFlag = "1"
  567. orders = append(orders, &order)
  568. }
  569. for _, subItem := range item.HisPrescriptionProject {
  570. if subItem.Type == 2 {
  571. var order models.FsiOrderDtos
  572. order.RxID = strconv.FormatInt(item.ID, 10)
  573. order.Rxno = strconv.FormatInt(item.ID, 10)
  574. order.LongDrordFlag = "0"
  575. order.HilistType = "1"
  576. order.ChrgType = "1"
  577. order.DrordBhvr = "-"
  578. order.HilistCode = subItem.HisProject.MedicalCode
  579. order.HosplistName = subItem.HisProject.ProjectName
  580. order.HilistLv = "1"
  581. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  582. order.HosplistCode = subItem.HisProject.MedicalCode
  583. order.HosplistName = subItem.HisProject.ProjectName
  584. order.Cnt = subItem.Count
  585. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  586. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  587. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  588. order.OwnpayAmt = ""
  589. order.SelfpayAmt = ""
  590. order.Spec = ""
  591. order.SpecUnt = ""
  592. order.DrordBegnDate = s_tm
  593. order.DrordStopDate = ""
  594. order.DrordDrCodg = "1"
  595. order.DrordDeptName = department.Name
  596. order.DrordDrCodg = "1"
  597. order.DrordDrName = doctor_info.UserName
  598. order.DrordDrProfttl = ""
  599. order.CurrDrordFlag = "1"
  600. orders = append(orders, &order)
  601. }
  602. if subItem.Type == 3 {
  603. var order models.FsiOrderDtos
  604. order.RxID = strconv.FormatInt(item.ID, 10)
  605. order.Rxno = strconv.FormatInt(item.ID, 10)
  606. order.LongDrordFlag = "0"
  607. order.HilistType = "1"
  608. order.ChrgType = "1"
  609. order.DrordBhvr = "-"
  610. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  611. order.HosplistName = subItem.GoodInfo.GoodName
  612. order.HilistLv = "1"
  613. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  614. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  615. order.HosplistName = subItem.GoodInfo.GoodName
  616. order.Cnt = subItem.Count
  617. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  618. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  619. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  620. order.OwnpayAmt = ""
  621. order.SelfpayAmt = ""
  622. order.Spec = ""
  623. order.SpecUnt = ""
  624. order.DrordBegnDate = s_tm
  625. order.DrordStopDate = ""
  626. order.DrordDrCodg = "1"
  627. order.DrordDeptName = department.Name
  628. order.DrordDrCodg = "1"
  629. order.DrordDrName = doctor_info.UserName
  630. order.DrordDrProfttl = ""
  631. order.CurrDrordFlag = "1"
  632. orders = append(orders, &order)
  633. }
  634. }
  635. }
  636. //处方医嘱信息
  637. fed.MatnStas = "0"
  638. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  639. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  640. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  641. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  642. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  643. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  644. fed.SetlTotlnum = "1"
  645. fed.Insutype = his.Insutype
  646. fed.ReimFlag = "0"
  647. fed.OutSetlFlag = "0"
  648. var fopd []*models.FsiOperationDtosData
  649. data := make(map[string]interface{})
  650. data["fed"] = fed
  651. data["fdd"] = fdds
  652. data["fod"] = orders
  653. data["pd"] = pd
  654. data["pp"] = pp
  655. data["fopd"] = fopd
  656. data["trig_scen"] = trig_scen
  657. client := &http.Client{}
  658. bytesData, _ := json.Marshal(data)
  659. var req *http.Request
  660. if miConfig.MdtrtareaAdmvs == "320921" {
  661. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  662. } else {
  663. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  664. }
  665. resp, _ := client.Do(req)
  666. defer resp.Body.Close()
  667. body, ioErr := ioutil.ReadAll(resp.Body)
  668. if ioErr != nil {
  669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  671. return
  672. }
  673. var respJSON map[string]interface{}
  674. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  677. return
  678. }
  679. //手术操作集合
  680. //手术操作集合
  681. }
  682. func (c *HisApiController) Check() {
  683. psn_no := c.GetString("psn_no")
  684. in := c.GetString("in")
  685. mt := c.GetString("mt")
  686. baseParams := models.BaseParams{
  687. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  688. FixmedinsCode: "H15049901371",
  689. InsuplcAdmdvs: "150499",
  690. MdtrtareaAdmvs: "150499",
  691. OrgName: "赤峰费森血液透析中心",
  692. Doctor: "1111",
  693. }
  694. service.Gdyb2001(baseParams, psn_no, in, mt)
  695. }
  696. func (c *HisApiController) GetPsnNcdsInfo() {
  697. admin_user_id, _ := c.GetInt64("admin_user_id")
  698. patient_id, _ := c.GetInt64("patient_id")
  699. id, _ := c.GetInt64("id")
  700. adminUser := c.GetAdminUserInfo()
  701. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  702. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  703. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  704. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  705. psn_record, _ := service.GetPsnNCDSRecordById(id)
  706. //
  707. //if psn_record.ID == 0 {
  708. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  709. // return
  710. //}
  711. var res Result5301
  712. var res10265 Result5301For10265
  713. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  714. psn_info, _ := service.GetPsnByPatientId(patient_id)
  715. var api string
  716. if miConfig.MdtrtareaAdmvs == "320921" {
  717. 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 +
  718. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  719. } else {
  720. 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 +
  721. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  722. }
  723. resp, requestErr := http.Get(api)
  724. if requestErr != nil {
  725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  726. return
  727. }
  728. body, ioErr := ioutil.ReadAll(resp.Body)
  729. if ioErr != nil {
  730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  732. return
  733. }
  734. var respJSON map[string]interface{}
  735. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  738. return
  739. }
  740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  741. result, _ := json.Marshal(respJSON)
  742. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  743. utils.ErrorLog("解析失败:%v", err)
  744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  745. return
  746. }
  747. res.ErrMsg = res10265.ErrMsg
  748. res.Output = res10265.Output
  749. res.InfRefmsgid = res10265.InfRefmsgid
  750. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  751. res.Infcode = infocode
  752. } else {
  753. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  754. var dat map[string]interface{}
  755. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  756. fmt.Println(dat)
  757. } else {
  758. fmt.Println(err)
  759. }
  760. userJSONBytes, _ := json.Marshal(dat)
  761. if miConfig.Code == "H15049901371" {
  762. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  763. utils.ErrorLog("解析失败:%v", err)
  764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  765. return
  766. }
  767. res.InfRefmsgid = res10265.InfRefmsgid
  768. res.Output = res10265.Output
  769. res.ErrMsg = res10265.ErrMsg
  770. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  771. res.Infcode = infocode
  772. } else {
  773. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  774. utils.ErrorLog("解析失败:%v", err)
  775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  776. return
  777. }
  778. }
  779. }
  780. if res.Infcode == 0 {
  781. c.ServeSuccessJSON(map[string]interface{}{
  782. "result": res.Output.Result,
  783. })
  784. }
  785. }
  786. func (c *HisApiController) CheckInsutype() {
  787. his_patient_id, _ := c.GetInt64("his_patient_id")
  788. admin_user_id, _ := c.GetInt64("admin_user_id")
  789. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  790. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  791. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  792. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  793. var dat map[string]interface{}
  794. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  795. fmt.Println(dat)
  796. } else {
  797. fmt.Println(err)
  798. }
  799. userJSONBytes, _ := json.Marshal(dat)
  800. var res Result90100
  801. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  802. utils.ErrorLog("解析失败:%v", err)
  803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  804. return
  805. }
  806. if res.Infcode != 0 {
  807. c.ServeSuccessJSON(map[string]interface{}{
  808. "failed_code": -10,
  809. "msg": res.ErrMsg,
  810. })
  811. return
  812. } else {
  813. fmt.Println(res)
  814. }
  815. }
  816. func (c *HisApiController) CheckCardPWD() {
  817. card_pwd := c.GetString("card_pwd")
  818. his_patient_id, _ := c.GetInt64("his_patient_id")
  819. admin_user_id, _ := c.GetInt64("admin_user_id")
  820. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  821. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  822. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  823. psn, _ := service.GetPsnByPatientId(his.PatientId)
  824. bas := strings.Split(psn.CardInfo, "|")
  825. basNumber := bas[2]
  826. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  827. var dat map[string]interface{}
  828. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  829. fmt.Println(dat)
  830. } else {
  831. fmt.Println(err)
  832. }
  833. userJSONBytes, _ := json.Marshal(dat)
  834. var res Result90991
  835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  836. utils.ErrorLog("解析失败:%v", err)
  837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  838. return
  839. }
  840. if res.Infcode != 0 {
  841. c.ServeSuccessJSON(map[string]interface{}{
  842. "failed_code": -10,
  843. "msg": res.ErrMsg,
  844. })
  845. return
  846. } else {
  847. if res.Output.Result.SscnoCheckStat == "0" {
  848. var msg string
  849. switch res.Output.Result.CardStat {
  850. case "00":
  851. msg = "未激活"
  852. break
  853. case "10":
  854. msg = "激活"
  855. break
  856. case "20":
  857. msg = "窗口挂失"
  858. break
  859. case "21":
  860. msg = "电话挂失"
  861. break
  862. case "22":
  863. msg = "单位网上申报挂失"
  864. break
  865. case "23":
  866. msg = "保健办挂失"
  867. break
  868. case "24":
  869. msg = "个人网上挂失"
  870. break
  871. case "25":
  872. msg = "网上服务大厅挂失"
  873. break
  874. case "30":
  875. msg = "注销"
  876. break
  877. case "40":
  878. msg = "回收"
  879. break
  880. case "99":
  881. msg = "制卡中(无效卡)"
  882. break
  883. }
  884. c.ServeSuccessJSON(map[string]interface{}{
  885. "failed_code": -10,
  886. "msg": msg,
  887. })
  888. return
  889. } else {
  890. c.ServeSuccessJSON(map[string]interface{}{
  891. "msg": "校验成功",
  892. })
  893. return
  894. }
  895. }
  896. }
  897. func (c *HisApiController) ReadCard() {
  898. id_card_type, _ := c.GetInt64("id_card_type")
  899. admin_user_id, _ := c.GetInt64("admin_user_id")
  900. certificates, _ := c.GetInt64("certificates")
  901. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  902. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  903. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  904. switch id_card_type {
  905. case 1:
  906. if miConfig.MdtrtareaAdmvs == "421300" {
  907. var res ResultTwo
  908. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  909. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  910. "&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)
  911. resp, requestErr := http.Get(api)
  912. if requestErr != nil {
  913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  914. return
  915. }
  916. body, ioErr := ioutil.ReadAll(resp.Body)
  917. if ioErr != nil {
  918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  920. return
  921. }
  922. var respJSON map[string]interface{}
  923. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  926. return
  927. }
  928. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  929. result, _ := json.Marshal(respJSON)
  930. fmt.Println("log")
  931. fmt.Println(string(result))
  932. if err := json.Unmarshal([]byte(result), &res); err != nil {
  933. utils.ErrorLog("解析失败:%v", err)
  934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  935. return
  936. }
  937. if res.Infcode == 0 {
  938. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  939. if err == gorm.ErrRecordNotFound {
  940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  941. return
  942. } else if err != nil {
  943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  944. return
  945. } else {
  946. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  947. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  948. infoStr := string(Iinfos)
  949. idetinfoStr := string(Idetinfos)
  950. psn := &models.HisPsn{
  951. PsnNo: res.Output.Baseinfo.PsnNo,
  952. Age: res.Output.Baseinfo.Age,
  953. PatientId: patient.ID,
  954. Certno: res.Output.Baseinfo.Certno,
  955. Brdy: res.Output.Baseinfo.Brdy,
  956. Gend: res.Output.Baseinfo.Gend,
  957. Naty: res.Output.Baseinfo.Naty,
  958. PsnCertType: res.Output.Baseinfo.PsnCertType,
  959. PsnName: res.Output.Baseinfo.PsnName,
  960. Idetinfo: idetinfoStr,
  961. Insuinfo: infoStr,
  962. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  963. }
  964. service.CreateHisPsn(psn)
  965. c.ServeSuccessJSON(map[string]interface{}{
  966. "patient": patient,
  967. "number": res.Output.Baseinfo.Certno,
  968. })
  969. }
  970. } else {
  971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  972. return
  973. }
  974. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  975. var api string
  976. if miConfig.MdtrtareaAdmvs == "320921" {
  977. 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 +
  978. "&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
  979. fmt.Println(api)
  980. } else {
  981. 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 +
  982. "&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)
  983. }
  984. resp, requestErr := http.Get(api)
  985. if requestErr != nil {
  986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  987. return
  988. }
  989. body, ioErr := ioutil.ReadAll(resp.Body)
  990. if ioErr != nil {
  991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  993. return
  994. }
  995. var respJSON map[string]interface{}
  996. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  999. return
  1000. }
  1001. var status string
  1002. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1003. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1004. //console.log()
  1005. fmt.Println("type===")
  1006. fmt.Println(card_type)
  1007. var token string
  1008. var res ResultTwo //1101结果
  1009. var res10265 ResultTwo10265 //1101结果
  1010. var card_info string //卡信息
  1011. var busi_card_info string
  1012. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1013. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1014. if status == "0" { //读卡成功
  1015. if card_type == "1" {
  1016. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1017. result, _ := json.Marshal(respJSON)
  1018. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1019. utils.ErrorLog("解析失败:%v", err)
  1020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1021. return
  1022. }
  1023. res.ErrMsg = res10265.ErrMsg
  1024. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1025. res.Infcode = infocode
  1026. res.Output = res10265.Output
  1027. res.InfRefmsgid = res10265.InfRefmsgid
  1028. } else {
  1029. //var card_info string //卡信息
  1030. //var busi_card_info string
  1031. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1032. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1033. //fmt.Println(card_info)
  1034. //fmt.Println(busi_card_info)
  1035. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1036. result, _ := json.Marshal(respJSON)
  1037. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1038. utils.ErrorLog("解析失败:%v", err)
  1039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1040. return
  1041. }
  1042. res.ErrMsg = res10265.ErrMsg
  1043. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1044. res.Infcode = infocode
  1045. res.Output = res10265.Output
  1046. res.InfRefmsgid = res10265.InfRefmsgid
  1047. }
  1048. if res.Infcode == 0 {
  1049. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1050. if err == gorm.ErrRecordNotFound {
  1051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1052. return
  1053. } else if err != nil {
  1054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1055. return
  1056. } else {
  1057. if card_type == "1" {
  1058. bas := strings.Split(card_info, "|")
  1059. basNumber := bas[2]
  1060. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1061. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1062. infoStr := string(Iinfos)
  1063. idetinfoStr := string(Idetinfos)
  1064. psn := &models.HisPsn{
  1065. PsnNo: res.Output.Baseinfo.PsnNo,
  1066. Age: res.Output.Baseinfo.Age,
  1067. PatientId: patient.ID,
  1068. Certno: res.Output.Baseinfo.Certno,
  1069. Brdy: res.Output.Baseinfo.Brdy,
  1070. Gend: res.Output.Baseinfo.Gend,
  1071. Naty: res.Output.Baseinfo.Naty,
  1072. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1073. PsnName: res.Output.Baseinfo.PsnName,
  1074. Idetinfo: idetinfoStr,
  1075. Insuinfo: infoStr,
  1076. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1077. CardInfo: card_info,
  1078. VerifyNumber: busi_card_info,
  1079. }
  1080. service.CreateHisPsn(psn)
  1081. c.ServeSuccessJSON(map[string]interface{}{
  1082. "patient": patient,
  1083. "number": basNumber,
  1084. })
  1085. } else {
  1086. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1087. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1088. infoStr := string(Iinfos)
  1089. idetinfoStr := string(Idetinfos)
  1090. psn := &models.HisPsn{
  1091. PsnNo: res.Output.Baseinfo.PsnNo,
  1092. Age: res.Output.Baseinfo.Age,
  1093. PatientId: patient.ID,
  1094. Certno: res.Output.Baseinfo.Certno,
  1095. Brdy: res.Output.Baseinfo.Brdy,
  1096. Gend: res.Output.Baseinfo.Gend,
  1097. Naty: res.Output.Baseinfo.Naty,
  1098. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1099. PsnName: res.Output.Baseinfo.PsnName,
  1100. Idetinfo: idetinfoStr,
  1101. Insuinfo: infoStr,
  1102. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1103. CardInfo: card_info,
  1104. VerifyNumber: token,
  1105. }
  1106. service.CreateHisPsn(psn)
  1107. c.ServeSuccessJSON(map[string]interface{}{
  1108. "patient": patient,
  1109. "number": token,
  1110. })
  1111. }
  1112. }
  1113. } else {
  1114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1115. return
  1116. }
  1117. } else { //读卡失败
  1118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1119. return
  1120. }
  1121. } else {
  1122. if initFlag == 0 {
  1123. c.TestGetBasBaseInit()
  1124. }
  1125. basStr := c.GetBasBaseInfo()
  1126. if len(basStr) == 0 {
  1127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1128. return
  1129. }
  1130. fmt.Println(basStr)
  1131. bas := strings.Split(basStr, "|")
  1132. basNumber := bas[1]
  1133. fmt.Println(basNumber)
  1134. card_sn := bas[3]
  1135. fmt.Println(card_sn)
  1136. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1137. var dat map[string]interface{}
  1138. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1139. fmt.Println(dat)
  1140. } else {
  1141. fmt.Println(err)
  1142. }
  1143. userJSONBytes, _ := json.Marshal(dat)
  1144. var res ResultTwo
  1145. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1146. utils.ErrorLog("解析失败:%v", err)
  1147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1148. return
  1149. }
  1150. if res.Infcode == 0 {
  1151. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1152. if err == gorm.ErrRecordNotFound {
  1153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1154. return
  1155. } else if err != nil {
  1156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1157. return
  1158. } else {
  1159. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1160. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1161. infoStr := string(Iinfos)
  1162. idetinfoStr := string(Idetinfos)
  1163. psn := &models.HisPsn{
  1164. PsnNo: res.Output.Baseinfo.PsnNo,
  1165. Age: res.Output.Baseinfo.Age,
  1166. PatientId: patient.ID,
  1167. Certno: res.Output.Baseinfo.Certno,
  1168. Brdy: res.Output.Baseinfo.Brdy,
  1169. Gend: res.Output.Baseinfo.Gend,
  1170. Naty: res.Output.Baseinfo.Naty,
  1171. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1172. PsnName: res.Output.Baseinfo.PsnName,
  1173. Idetinfo: idetinfoStr,
  1174. Insuinfo: infoStr,
  1175. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1176. CardInfo: basStr,
  1177. VerifyNumber: "",
  1178. }
  1179. service.CreateHisPsn(psn)
  1180. c.ServeSuccessJSON(map[string]interface{}{
  1181. "patient": patient,
  1182. "number": basNumber,
  1183. })
  1184. }
  1185. } else {
  1186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1187. return
  1188. }
  1189. break
  1190. }
  1191. case 2:
  1192. SFZStr := c.GetSFZBaseInfo()
  1193. id_card_str := strings.Split(SFZStr, "^")
  1194. id_card_number := id_card_str[0]
  1195. card_sn := ""
  1196. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1197. var dat map[string]interface{}
  1198. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1199. fmt.Println(dat)
  1200. } else {
  1201. fmt.Println(err)
  1202. }
  1203. userJSONBytes, _ := json.Marshal(dat)
  1204. var res ResultTwo
  1205. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1206. utils.ErrorLog("解析失败:%v", err)
  1207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1208. return
  1209. }
  1210. if res.Infcode == 0 {
  1211. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1212. if err == gorm.ErrRecordNotFound {
  1213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1214. return
  1215. } else if err != nil {
  1216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1217. return
  1218. } else {
  1219. c.ServeSuccessJSON(map[string]interface{}{
  1220. "patient": patient,
  1221. "number": id_card_number,
  1222. })
  1223. }
  1224. } else {
  1225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1226. return
  1227. }
  1228. break
  1229. case 3:
  1230. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1231. var api string
  1232. if miConfig.MdtrtareaAdmvs == "320921" {
  1233. 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 +
  1234. "&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
  1235. fmt.Println(api)
  1236. } else {
  1237. 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 +
  1238. "&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)
  1239. }
  1240. resp, requestErr := http.Get(api)
  1241. if requestErr != nil {
  1242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1243. return
  1244. }
  1245. body, ioErr := ioutil.ReadAll(resp.Body)
  1246. if ioErr != nil {
  1247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1249. return
  1250. }
  1251. var respJSON map[string]interface{}
  1252. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1255. return
  1256. }
  1257. var status string
  1258. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1259. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1260. var token string
  1261. var res ResultTwo //1101结果
  1262. var res10265 ResultTwo10265 //1101结果
  1263. var card_info string //卡信息
  1264. var busi_card_info string
  1265. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1266. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1267. if status == "0" { //读卡成功
  1268. if card_type == "1" {
  1269. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1270. result, _ := json.Marshal(respJSON)
  1271. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1272. utils.ErrorLog("解析失败:%v", err)
  1273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1274. return
  1275. }
  1276. res.ErrMsg = res10265.ErrMsg
  1277. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1278. res.Infcode = infocode
  1279. res.Output = res10265.Output
  1280. res.InfRefmsgid = res10265.InfRefmsgid
  1281. } else {
  1282. //var card_info string //卡信息
  1283. //var busi_card_info string
  1284. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1285. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1286. //fmt.Println(card_info)
  1287. //fmt.Println(busi_card_info)
  1288. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1289. result, _ := json.Marshal(respJSON)
  1290. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1291. utils.ErrorLog("解析失败:%v", err)
  1292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1293. return
  1294. }
  1295. res.ErrMsg = res10265.ErrMsg
  1296. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1297. res.Infcode = infocode
  1298. res.Output = res10265.Output
  1299. res.InfRefmsgid = res10265.InfRefmsgid
  1300. }
  1301. if res.Infcode == 0 {
  1302. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1303. if err == gorm.ErrRecordNotFound {
  1304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1305. return
  1306. } else if err != nil {
  1307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1308. return
  1309. } else {
  1310. if card_type == "1" {
  1311. bas := strings.Split(card_info, "|")
  1312. basNumber := bas[2]
  1313. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1314. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1315. infoStr := string(Iinfos)
  1316. idetinfoStr := string(Idetinfos)
  1317. psn := &models.HisPsn{
  1318. PsnNo: res.Output.Baseinfo.PsnNo,
  1319. Age: res.Output.Baseinfo.Age,
  1320. PatientId: patient.ID,
  1321. Certno: res.Output.Baseinfo.Certno,
  1322. Brdy: res.Output.Baseinfo.Brdy,
  1323. Gend: res.Output.Baseinfo.Gend,
  1324. Naty: res.Output.Baseinfo.Naty,
  1325. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1326. PsnName: res.Output.Baseinfo.PsnName,
  1327. Idetinfo: idetinfoStr,
  1328. Insuinfo: infoStr,
  1329. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1330. CardInfo: card_info,
  1331. VerifyNumber: busi_card_info,
  1332. }
  1333. service.CreateHisPsn(psn)
  1334. c.ServeSuccessJSON(map[string]interface{}{
  1335. "patient": patient,
  1336. "number": basNumber,
  1337. })
  1338. } else {
  1339. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1340. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1341. infoStr := string(Iinfos)
  1342. idetinfoStr := string(Idetinfos)
  1343. psn := &models.HisPsn{
  1344. PsnNo: res.Output.Baseinfo.PsnNo,
  1345. Age: res.Output.Baseinfo.Age,
  1346. PatientId: patient.ID,
  1347. Certno: res.Output.Baseinfo.Certno,
  1348. Brdy: res.Output.Baseinfo.Brdy,
  1349. Gend: res.Output.Baseinfo.Gend,
  1350. Naty: res.Output.Baseinfo.Naty,
  1351. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1352. PsnName: res.Output.Baseinfo.PsnName,
  1353. Idetinfo: idetinfoStr,
  1354. Insuinfo: infoStr,
  1355. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1356. CardInfo: card_info,
  1357. VerifyNumber: token,
  1358. }
  1359. service.CreateHisPsn(psn)
  1360. c.ServeSuccessJSON(map[string]interface{}{
  1361. "patient": patient,
  1362. "number": token,
  1363. })
  1364. }
  1365. }
  1366. } else {
  1367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1368. return
  1369. }
  1370. } else { //读卡失败
  1371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1372. return
  1373. }
  1374. }
  1375. break
  1376. case 4:
  1377. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1378. var api string
  1379. if miConfig.MdtrtareaAdmvs == "320921" {
  1380. 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 +
  1381. "&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
  1382. fmt.Println(api)
  1383. } else {
  1384. 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 +
  1385. "&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)
  1386. }
  1387. resp, requestErr := http.Get(api)
  1388. if requestErr != nil {
  1389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1390. return
  1391. }
  1392. body, ioErr := ioutil.ReadAll(resp.Body)
  1393. if ioErr != nil {
  1394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1396. return
  1397. }
  1398. var respJSON map[string]interface{}
  1399. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1402. return
  1403. }
  1404. var status string
  1405. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1406. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1407. var token string
  1408. var res ResultTwo //1101结果
  1409. var res10265 ResultTwo10265 //1101结果
  1410. if status == "0" { //读卡成功
  1411. var card_info string //卡信息
  1412. var busi_card_info string
  1413. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1414. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1415. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1416. fmt.Println(card_info)
  1417. fmt.Println(busi_card_info)
  1418. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1419. result, _ := json.Marshal(respJSON)
  1420. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1421. utils.ErrorLog("解析失败:%v", err)
  1422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1423. return
  1424. }
  1425. res.ErrMsg = res10265.ErrMsg
  1426. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1427. res.Infcode = infocode
  1428. res.Output = res10265.Output
  1429. res.InfRefmsgid = res10265.InfRefmsgid
  1430. if res.Infcode == 0 {
  1431. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1432. if err == gorm.ErrRecordNotFound {
  1433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1434. return
  1435. } else if err != nil {
  1436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1437. return
  1438. } else {
  1439. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1440. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1441. infoStr := string(Iinfos)
  1442. idetinfoStr := string(Idetinfos)
  1443. psn := &models.HisPsn{
  1444. PsnNo: res.Output.Baseinfo.PsnNo,
  1445. Age: res.Output.Baseinfo.Age,
  1446. PatientId: patient.ID,
  1447. Certno: res.Output.Baseinfo.Certno,
  1448. Brdy: res.Output.Baseinfo.Brdy,
  1449. Gend: res.Output.Baseinfo.Gend,
  1450. Naty: res.Output.Baseinfo.Naty,
  1451. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1452. PsnName: res.Output.Baseinfo.PsnName,
  1453. Idetinfo: idetinfoStr,
  1454. Insuinfo: infoStr,
  1455. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1456. CardInfo: card_info,
  1457. VerifyNumber: token,
  1458. }
  1459. service.CreateHisPsn(psn)
  1460. c.ServeSuccessJSON(map[string]interface{}{
  1461. "patient": patient,
  1462. "number": token,
  1463. })
  1464. }
  1465. } else {
  1466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1467. return
  1468. }
  1469. } else { //读卡失败
  1470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1471. return
  1472. }
  1473. }
  1474. break
  1475. }
  1476. }
  1477. var initFlag int64 = 0
  1478. func (c *HisApiController) TestGetBasBaseInit() {
  1479. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1480. Iinit := DllDef.MustFindProc("Init")
  1481. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1482. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1483. if ret != 0 {
  1484. fmt.Println("SSCard的报错原因:", err)
  1485. fmt.Println("SSCard的运算结果为:", ret)
  1486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1487. return
  1488. }
  1489. result := int(ret)
  1490. fmt.Println("SSCard的运算结果为1:", result)
  1491. initFlag = 1
  1492. return
  1493. }
  1494. func (c *HisApiController) GetSFZBaseInfo() string {
  1495. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1496. readCard := DllDef.MustFindProc("ReadSFZ")
  1497. if readCard == nil {
  1498. fmt.Println("readcard is nil")
  1499. readCard = DllDef.MustFindProc("ReadSFZ")
  1500. }
  1501. str := make([]byte, 256)
  1502. str1 := make([]byte, 256)
  1503. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1504. fmt.Println(r)
  1505. return string(str)
  1506. }
  1507. func (c *HisApiController) GetBasBaseInfo() string {
  1508. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1509. readCard := DllDef.MustFindProc("ReadCardBas")
  1510. if readCard == nil {
  1511. fmt.Println("readcard is nil")
  1512. readCard = DllDef.MustFindProc("ReadCardBas")
  1513. }
  1514. str := make([]byte, 1024)
  1515. str1 := make([]byte, 1024)
  1516. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1517. fmt.Println(string(str1))
  1518. fmt.Println(string(str))
  1519. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1520. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1521. if ret2 != 0 {
  1522. return ""
  1523. }
  1524. return string(str)
  1525. }
  1526. type CustomFundPay struct {
  1527. FundPayType string `json:"fund_pay_type"`
  1528. FundPayamt float64 `json:"fund_payamt"`
  1529. }
  1530. func (c *HisApiController) GetSettleList() {
  1531. order_id, _ := c.GetInt64("order_id")
  1532. admin_user_id, _ := c.GetInt64("admin_user_id")
  1533. order, _ := service.GetHisOrderByIDTwo(order_id)
  1534. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1535. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1536. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1537. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1538. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1539. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1540. if order.ID == 0 {
  1541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1542. return
  1543. }
  1544. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1545. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1546. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1547. fmt.Println(count)
  1548. var zero string
  1549. number := count + 1
  1550. if number >= 1000 {
  1551. zero = "0000" + strconv.FormatInt(number, 10)
  1552. } else if number >= 10000 {
  1553. zero = "000" + strconv.FormatInt(number, 10)
  1554. } else if number >= 100000 {
  1555. zero = "00" + strconv.FormatInt(number, 10)
  1556. } else if number >= 1000000 {
  1557. zero = "0" + strconv.FormatInt(number, 10)
  1558. } else {
  1559. zero = strconv.FormatInt(number, 10)
  1560. }
  1561. fmt.Println(zero)
  1562. struct4101 := service.Struct4101{
  1563. PsnNo: order.PsnNo,
  1564. MdtrtId: order.MdtrtId,
  1565. SetlId: order.SetlId,
  1566. PsnName: order.PsnName,
  1567. Gend: order.Gend,
  1568. Brdy: his.Brdy,
  1569. Age: his.Age,
  1570. Naty: order.Naty,
  1571. PatnCertType: "01",
  1572. Certno: order.Certno,
  1573. Prfs: "90",
  1574. ConerName: roles[0].UserName,
  1575. PatnRlts: "99",
  1576. ConerAddr: miConfig.OrgName,
  1577. ConerTel: admin.Mobile,
  1578. HiType: order.Insutype,
  1579. Insuplc: miConfig.InsuplcAdmdvs,
  1580. MaindiagFlag: "1",
  1581. BillCode: last_order.FaPiaoCode,
  1582. BillNo: zero,
  1583. BizSn: order.Number,
  1584. PsnSelfPay: order.PsnPartAmt,
  1585. PsnOwnPay: order.PsnPartAmt,
  1586. AcctPay: order.AcctPay,
  1587. PsnCashpay: order.PsnCashPay,
  1588. HiPaymtd: "1",
  1589. Hsorg: miConfig.InsuplcAdmdvs,
  1590. HsorgOpter: miConfig.InsuplcAdmdvs,
  1591. MedinsFillPsn: curRoles.UserName,
  1592. MedinsFillDept: depart.Name,
  1593. IptMedType: "2",
  1594. }
  1595. struct4101.SetlBegnDate = order.SetlTime
  1596. struct4101.SetlEndDate = order.SetlTime
  1597. time_arr := strings.Split(order.SetlTime, " ")
  1598. struct4101.AdmTime = time_arr[0]
  1599. struct4101.AdmEndTime = time_arr[0]
  1600. var rf []CustomFundPay
  1601. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1602. var tempFunPays []service.CustomStruct
  1603. for _, item := range rf {
  1604. var tempFunPay service.CustomStruct
  1605. tempFunPay.FundPayamt = item.FundPayamt
  1606. tempFunPay.FundPayType = item.FundPayType
  1607. tempFunPays = append(tempFunPays, tempFunPay)
  1608. }
  1609. struct4101.CustomStruct = tempFunPays
  1610. var tempDiaginfos []service.DiaginfoStructTwo
  1611. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1612. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1613. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1614. var config []*models.HisXtDiagnoseConfig
  1615. for _, item := range diagnosis_ids {
  1616. id, _ := strconv.ParseInt(item, 10, 64)
  1617. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1618. config = append(config, &diagnosisConfig)
  1619. }
  1620. for index, item := range config {
  1621. if index == 0 {
  1622. var tempDiaginfo service.DiaginfoStructTwo
  1623. tempDiaginfo.DiagCode = item.CountryCode
  1624. tempDiaginfo.DiagName = item.CountryContentName
  1625. tempDiaginfo.DiagType = "1"
  1626. tempDiaginfo.MaindiagFlag = "1"
  1627. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1628. } else {
  1629. var tempDiaginfo service.DiaginfoStructTwo
  1630. tempDiaginfo.DiagCode = item.CountryCode
  1631. tempDiaginfo.DiagName = item.CountryContentName
  1632. tempDiaginfo.DiagType = "2"
  1633. tempDiaginfo.MaindiagFlag = "0"
  1634. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1635. }
  1636. }
  1637. struct4101.Diseinfo = tempDiaginfos
  1638. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1639. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1640. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1641. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1642. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1643. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1644. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1645. var iteminfo service.IteminfoStruct
  1646. var bedCostTotal float64 = 0 //床位总费
  1647. var bedCostSelfTotal float64 = 0 //床位自费
  1648. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1649. var operationCostTotal float64 = 0 //手术费
  1650. var operationCostSelfTotal float64 = 0 //手术费
  1651. var operationCostPartSelfTotal float64 = 0 //手术费
  1652. var otherCostTotal float64 = 0 //其他费用
  1653. var otherCostSelfTotal float64 = 0 //其他费用
  1654. var otherCostPartSelfTotal float64 = 0 //其他费用
  1655. var materialCostTotal float64 = 0 //材料费
  1656. var materialCostSelfTotal float64 = 0 //材料费
  1657. var materialCostPartSelfTotal float64 = 0 //材料费
  1658. var westernMedicineCostTotal float64 = 0 //西药费
  1659. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1660. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1661. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1662. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1663. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1664. var checkCostTotal float64 = 0 //检查费
  1665. var checkCostSelfTotal float64 = 0 //检查费
  1666. var checkCostPartSelfTotal float64 = 0 //检查费
  1667. var laboratoryCostTotal float64 = 0 //化验费
  1668. var laboratoryCostSelfTotal float64 = 0 //化验费
  1669. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1670. var treatCostTotal float64 = 0 //治疗费用
  1671. var treatCostSelfTotal float64 = 0 //治疗费用
  1672. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1673. decimal.DivisionPrecision = 2
  1674. var bed_fulamt_ownpay_amt float64 = 0
  1675. var operation_fulamt_ownpay_amt float64 = 0
  1676. var other_fulamt_ownpay_amt float64 = 0
  1677. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1678. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1679. var check_fulamt_ownpay_amt float64 = 0
  1680. var material_fulamt_ownpay_amt float64 = 0
  1681. var laboratory_fulamt_ownpay_amt float64 = 0
  1682. var treat_fulamt_ownpay_amt float64 = 0
  1683. var bed_claa_sunmfee float64 = 0
  1684. var bed_clab_amt float64 = 0
  1685. var bed_other_amt float64 = 0
  1686. var operation_claa_sunmfee float64 = 0
  1687. var operation_clab_amt float64 = 0
  1688. var operation_other_amt float64 = 0
  1689. var other_claa_sunmfee float64 = 0
  1690. var other_clab_amt float64 = 0
  1691. var other_other_amt float64 = 0
  1692. var westernMedicine_claa_sunmfee float64 = 0
  1693. var westernMedicine_clab_amt float64 = 0
  1694. var westernMedicine_other_amt float64 = 0
  1695. var chineseTraditional_claa_sunmfee float64 = 0
  1696. var chineseTraditional_clab_amt float64 = 0
  1697. var chineseTraditional_other_amt float64 = 0
  1698. var check_claa_sunmfee float64 = 0
  1699. var check_clab_amt float64 = 0
  1700. var check_other_amt float64 = 0
  1701. var material_claa_sunmfee float64 = 0
  1702. var material_clab_amt float64 = 0
  1703. var material_other_amt float64 = 0
  1704. var laboratory_claa_sunmfee float64 = 0
  1705. var laboratory_clab_amt float64 = 0
  1706. var laboratory_other_amt float64 = 0
  1707. var treat_claa_sunmfee float64 = 0
  1708. var treat_clab_amt float64 = 0
  1709. var treat_other_amt float64 = 0
  1710. for _, item := range order.HisOrderInfo {
  1711. if item.MedChrgitmType == "01" { //床位费
  1712. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1713. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1714. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1715. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1716. if item.ChrgitmLv == "1" {
  1717. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1718. }
  1719. if item.ChrgitmLv == "2" {
  1720. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1721. }
  1722. if item.ChrgitmLv == "3" {
  1723. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1724. }
  1725. }
  1726. if item.MedChrgitmType == "03" { //检查费
  1727. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1728. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1729. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1730. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1731. if item.ChrgitmLv == "1" {
  1732. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1733. }
  1734. if item.ChrgitmLv == "2" {
  1735. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1736. }
  1737. if item.ChrgitmLv == "3" {
  1738. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1739. }
  1740. }
  1741. if item.MedChrgitmType == "04" { //化验费
  1742. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1743. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1744. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1745. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1746. if item.ChrgitmLv == "1" {
  1747. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1748. }
  1749. if item.ChrgitmLv == "2" {
  1750. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1751. }
  1752. if item.ChrgitmLv == "3" {
  1753. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1754. }
  1755. }
  1756. if item.MedChrgitmType == "05" { //治疗费
  1757. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1758. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1759. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1760. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1761. if item.ChrgitmLv == "1" {
  1762. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1763. }
  1764. if item.ChrgitmLv == "2" {
  1765. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1766. }
  1767. if item.ChrgitmLv == "3" {
  1768. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1769. }
  1770. }
  1771. if item.MedChrgitmType == "06" { //手术费
  1772. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1773. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1774. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1775. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1776. if item.ChrgitmLv == "1" {
  1777. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1778. }
  1779. if item.ChrgitmLv == "2" {
  1780. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1781. }
  1782. if item.ChrgitmLv == "3" {
  1783. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1784. }
  1785. }
  1786. if item.MedChrgitmType == "08" { //材料费
  1787. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1788. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1789. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1790. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1791. if item.ChrgitmLv == "1" {
  1792. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1793. }
  1794. if item.ChrgitmLv == "2" {
  1795. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1796. }
  1797. if item.ChrgitmLv == "3" {
  1798. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1799. }
  1800. }
  1801. if item.MedChrgitmType == "09" { //西药费
  1802. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1803. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1804. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1805. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1806. if item.ChrgitmLv == "1" {
  1807. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1808. }
  1809. if item.ChrgitmLv == "2" {
  1810. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1811. }
  1812. if item.ChrgitmLv == "3" {
  1813. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1814. }
  1815. }
  1816. if item.MedChrgitmType == "11" { //中成费
  1817. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1818. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1819. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1820. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1821. if item.ChrgitmLv == "1" {
  1822. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1823. }
  1824. if item.ChrgitmLv == "2" {
  1825. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1826. }
  1827. if item.ChrgitmLv == "3" {
  1828. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1829. }
  1830. }
  1831. if item.MedChrgitmType == "14" { //其他费
  1832. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1833. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1834. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1835. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1836. if item.ChrgitmLv == "1" {
  1837. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1838. }
  1839. if item.ChrgitmLv == "2" {
  1840. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1841. }
  1842. if item.ChrgitmLv == "3" {
  1843. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1844. }
  1845. }
  1846. }
  1847. var iteminfoStructs []service.IteminfoStruct
  1848. if bedCostTotal != 0 {
  1849. iteminfo.MedChrgitm = "01"
  1850. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1851. iteminfo.Amt = bedCostTotal
  1852. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1853. iteminfo.ClabAmt = bed_clab_amt
  1854. iteminfo.OthAmt = bed_other_amt
  1855. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1856. }
  1857. if checkCostTotal != 0 {
  1858. iteminfo.MedChrgitm = "03"
  1859. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1860. iteminfo.Amt = checkCostTotal
  1861. iteminfo.ClaaSumfee = check_claa_sunmfee
  1862. iteminfo.ClabAmt = check_clab_amt
  1863. iteminfo.OthAmt = check_other_amt
  1864. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1865. }
  1866. if laboratoryCostTotal != 0 {
  1867. iteminfo.MedChrgitm = "04"
  1868. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1869. iteminfo.Amt = laboratoryCostTotal
  1870. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1871. iteminfo.ClabAmt = laboratory_clab_amt
  1872. iteminfo.OthAmt = laboratory_other_amt
  1873. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1874. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1875. }
  1876. if treatCostTotal != 0 {
  1877. iteminfo.MedChrgitm = "05"
  1878. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1879. iteminfo.Amt = treatCostTotal
  1880. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1881. iteminfo.ClabAmt = treat_clab_amt
  1882. iteminfo.OthAmt = treat_other_amt
  1883. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1884. //(struct4101.IteminfoStruct, iteminfo)
  1885. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1886. }
  1887. if operationCostTotal != 0 {
  1888. iteminfo.MedChrgitm = "06"
  1889. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1890. iteminfo.Amt = operationCostTotal
  1891. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1892. iteminfo.ClabAmt = operation_clab_amt
  1893. iteminfo.OthAmt = operation_other_amt
  1894. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1895. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1896. }
  1897. if materialCostTotal != 0 {
  1898. iteminfo.MedChrgitm = "08"
  1899. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1900. iteminfo.Amt = materialCostTotal
  1901. iteminfo.ClaaSumfee = material_claa_sunmfee
  1902. iteminfo.ClabAmt = material_clab_amt
  1903. iteminfo.OthAmt = material_other_amt
  1904. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1905. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1906. }
  1907. if westernMedicineCostTotal != 0 {
  1908. iteminfo.MedChrgitm = "09"
  1909. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1910. iteminfo.Amt = westernMedicineCostTotal
  1911. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1912. iteminfo.ClabAmt = westernMedicine_clab_amt
  1913. iteminfo.OthAmt = westernMedicine_other_amt
  1914. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1915. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1916. }
  1917. if chineseTraditionalMedicineCostTotal != 0 {
  1918. iteminfo.MedChrgitm = "11"
  1919. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1920. iteminfo.Amt = westernMedicineCostTotal
  1921. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1922. iteminfo.ClabAmt = westernMedicine_clab_amt
  1923. iteminfo.OthAmt = westernMedicine_other_amt
  1924. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1925. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1926. }
  1927. if otherCostTotal != 0 {
  1928. iteminfo.MedChrgitm = "14"
  1929. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1930. iteminfo.Amt = otherCostTotal
  1931. iteminfo.ClaaSumfee = other_claa_sunmfee
  1932. iteminfo.ClabAmt = other_clab_amt
  1933. iteminfo.OthAmt = other_other_amt
  1934. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1935. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1936. }
  1937. struct4101.IteminfoStruct = iteminfoStructs
  1938. struct4101.Ntly = "中国"
  1939. struct4101.AdmCaty = "A03.06"
  1940. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1941. fmt.Println(result)
  1942. var dat map[string]interface{}
  1943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1944. fmt.Println(dat)
  1945. } else {
  1946. fmt.Println(err)
  1947. }
  1948. userJSONBytes, _ := json.Marshal(dat)
  1949. var res ResultSeventeen
  1950. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1951. utils.ErrorLog("解析失败:%v", err)
  1952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1953. return
  1954. }
  1955. if res.Infcode != 0 {
  1956. c.ServeSuccessJSON(map[string]interface{}{
  1957. "failed_code": -10,
  1958. "msg": res.ErrMsg,
  1959. })
  1960. return
  1961. } else {
  1962. order.FaPiaoNumber = zero
  1963. order.FaPiaoCode = last_order.FaPiaoCode
  1964. service.UpdateOrder(order)
  1965. hisFundSettleListResult := &models.HisFundSettleListResult{
  1966. Number: res.Output.SetlListId,
  1967. Status: 1,
  1968. Ctime: time.Now().Unix(),
  1969. Mtime: time.Now().Unix(),
  1970. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1971. IsUpload: 1,
  1972. OrderId: order_id,
  1973. }
  1974. service.CreateUploadRecord(hisFundSettleListResult)
  1975. c.ServeSuccessJSON(map[string]interface{}{
  1976. "msg": "上传成功",
  1977. "result": hisFundSettleListResult,
  1978. })
  1979. return
  1980. }
  1981. }
  1982. func (c *HisApiController) GetSettleListHospital() {
  1983. order_id, _ := c.GetInt64("order_id")
  1984. admin_user_id, _ := c.GetInt64("admin_user_id")
  1985. order, _ := service.GetHisOrderByIDTwo(order_id)
  1986. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1987. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1988. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1989. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1990. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1991. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1992. if order.ID == 0 {
  1993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1994. return
  1995. }
  1996. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1997. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1998. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1999. fmt.Println(count)
  2000. var zero string
  2001. number := count + 1
  2002. if number >= 1000 {
  2003. zero = "0000" + strconv.FormatInt(number, 10)
  2004. } else if number >= 10000 {
  2005. zero = "000" + strconv.FormatInt(number, 10)
  2006. } else if number >= 100000 {
  2007. zero = "00" + strconv.FormatInt(number, 10)
  2008. } else if number >= 1000000 {
  2009. zero = "0" + strconv.FormatInt(number, 10)
  2010. } else {
  2011. zero = strconv.FormatInt(number, 10)
  2012. }
  2013. fmt.Println(zero)
  2014. struct4101 := service.Struct4101{
  2015. PsnNo: order.PsnNo,
  2016. MdtrtId: order.MdtrtId,
  2017. SetlId: order.SetlId,
  2018. PsnName: order.PsnName,
  2019. Gend: order.Gend,
  2020. Brdy: his.Brdy,
  2021. Age: int64(order.Age),
  2022. Naty: order.Naty,
  2023. PatnCertType: "01",
  2024. Certno: order.Certno,
  2025. Prfs: "90",
  2026. ConerName: roles[0].UserName,
  2027. PatnRlts: "99",
  2028. ConerAddr: miConfig.OrgName,
  2029. ConerTel: admin.Mobile,
  2030. HiType: order.Insutype,
  2031. Insuplc: miConfig.InsuplcAdmdvs,
  2032. MaindiagFlag: "1",
  2033. BillCode: last_order.FaPiaoCode,
  2034. BillNo: zero,
  2035. BizSn: order.Number,
  2036. PsnSelfPay: order.PsnPartAmt,
  2037. PsnOwnPay: order.PsnPartAmt,
  2038. AcctPay: order.AcctPay,
  2039. PsnCashpay: order.PsnCashPay,
  2040. HiPaymtd: "1",
  2041. Hsorg: miConfig.InsuplcAdmdvs,
  2042. HsorgOpter: miConfig.InsuplcAdmdvs,
  2043. MedinsFillPsn: curRoles.UserName,
  2044. MedinsFillDept: depart.Name,
  2045. IptMedType: "2",
  2046. AdmTime: his.InHosptialTime,
  2047. AdmEndTime: his.OutHosptialTime,
  2048. }
  2049. struct4101.SetlBegnDate = order.SetlTime
  2050. struct4101.SetlEndDate = order.SetlTime
  2051. var rf []CustomFundPay
  2052. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2053. var tempFunPays []service.CustomStruct
  2054. for _, item := range rf {
  2055. var tempFunPay service.CustomStruct
  2056. tempFunPay.FundPayamt = item.FundPayamt
  2057. tempFunPay.FundPayType = item.FundPayType
  2058. tempFunPays = append(tempFunPays, tempFunPay)
  2059. }
  2060. struct4101.CustomStruct = tempFunPays
  2061. var tempDiaginfos []service.DiaginfoStructTwo
  2062. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2063. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2064. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2065. var config []*models.HisXtDiagnoseConfig
  2066. for _, item := range diagnosis_ids {
  2067. id, _ := strconv.ParseInt(item, 10, 64)
  2068. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2069. config = append(config, &diagnosisConfig)
  2070. }
  2071. for index, item := range config {
  2072. if index == 0 {
  2073. var tempDiaginfo service.DiaginfoStructTwo
  2074. tempDiaginfo.DiagCode = item.CountryCode
  2075. tempDiaginfo.DiagName = item.CountryContentName
  2076. tempDiaginfo.DiagType = "1"
  2077. tempDiaginfo.MaindiagFlag = "1"
  2078. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2079. } else {
  2080. var tempDiaginfo service.DiaginfoStructTwo
  2081. tempDiaginfo.DiagCode = item.CountryCode
  2082. tempDiaginfo.DiagName = item.CountryContentName
  2083. tempDiaginfo.DiagType = "2"
  2084. tempDiaginfo.MaindiagFlag = "0"
  2085. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2086. }
  2087. }
  2088. struct4101.Diseinfo = tempDiaginfos
  2089. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2090. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2091. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2092. tempOpspdiseinfo2.OprnOprtCode = ""
  2093. tempOpspdiseinfo2.OprnOprtName = ""
  2094. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2095. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2096. var iteminfo service.IteminfoStruct
  2097. var bedCostTotal float64 = 0 //床位总费
  2098. var bedCostSelfTotal float64 = 0 //床位自费
  2099. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2100. var operationCostTotal float64 = 0 //手术费
  2101. var operationCostSelfTotal float64 = 0 //手术费
  2102. var operationCostPartSelfTotal float64 = 0 //手术费
  2103. var otherCostTotal float64 = 0 //其他费用
  2104. var otherCostSelfTotal float64 = 0 //其他费用
  2105. var otherCostPartSelfTotal float64 = 0 //其他费用
  2106. var materialCostTotal float64 = 0 //材料费
  2107. var materialCostSelfTotal float64 = 0 //材料费
  2108. var materialCostPartSelfTotal float64 = 0 //材料费
  2109. var westernMedicineCostTotal float64 = 0 //西药费
  2110. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2111. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2112. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2113. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2114. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2115. var checkCostTotal float64 = 0 //检查费
  2116. var checkCostSelfTotal float64 = 0 //检查费
  2117. var checkCostPartSelfTotal float64 = 0 //检查费
  2118. var laboratoryCostTotal float64 = 0 //化验费
  2119. var laboratoryCostSelfTotal float64 = 0 //化验费
  2120. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2121. var treatCostTotal float64 = 0 //治疗费用
  2122. var treatCostSelfTotal float64 = 0 //治疗费用
  2123. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2124. decimal.DivisionPrecision = 2
  2125. var bed_fulamt_ownpay_amt float64 = 0
  2126. var operation_fulamt_ownpay_amt float64 = 0
  2127. var other_fulamt_ownpay_amt float64 = 0
  2128. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2129. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2130. var check_fulamt_ownpay_amt float64 = 0
  2131. var material_fulamt_ownpay_amt float64 = 0
  2132. var laboratory_fulamt_ownpay_amt float64 = 0
  2133. var treat_fulamt_ownpay_amt float64 = 0
  2134. var bed_claa_sunmfee float64 = 0
  2135. var bed_clab_amt float64 = 0
  2136. var bed_other_amt float64 = 0
  2137. var operation_claa_sunmfee float64 = 0
  2138. var operation_clab_amt float64 = 0
  2139. var operation_other_amt float64 = 0
  2140. var other_claa_sunmfee float64 = 0
  2141. var other_clab_amt float64 = 0
  2142. var other_other_amt float64 = 0
  2143. var westernMedicine_claa_sunmfee float64 = 0
  2144. var westernMedicine_clab_amt float64 = 0
  2145. var westernMedicine_other_amt float64 = 0
  2146. var chineseTraditional_claa_sunmfee float64 = 0
  2147. var chineseTraditional_clab_amt float64 = 0
  2148. var chineseTraditional_other_amt float64 = 0
  2149. var check_claa_sunmfee float64 = 0
  2150. var check_clab_amt float64 = 0
  2151. var check_other_amt float64 = 0
  2152. var material_claa_sunmfee float64 = 0
  2153. var material_clab_amt float64 = 0
  2154. var material_other_amt float64 = 0
  2155. var laboratory_claa_sunmfee float64 = 0
  2156. var laboratory_clab_amt float64 = 0
  2157. var laboratory_other_amt float64 = 0
  2158. var treat_claa_sunmfee float64 = 0
  2159. var treat_clab_amt float64 = 0
  2160. var treat_other_amt float64 = 0
  2161. for _, item := range order.HisOrderInfo {
  2162. if item.MedChrgitmType == "01" { //床位费
  2163. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2164. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2165. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2166. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2167. if item.ChrgitmLv == "1" {
  2168. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2169. }
  2170. if item.ChrgitmLv == "2" {
  2171. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2172. }
  2173. if item.ChrgitmLv == "3" {
  2174. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2175. }
  2176. }
  2177. if item.MedChrgitmType == "03" { //检查费
  2178. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2179. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2180. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2181. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2182. if item.ChrgitmLv == "1" {
  2183. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2184. }
  2185. if item.ChrgitmLv == "2" {
  2186. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2187. }
  2188. if item.ChrgitmLv == "3" {
  2189. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2190. }
  2191. }
  2192. if item.MedChrgitmType == "04" { //化验费
  2193. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2194. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2195. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2196. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2197. if item.ChrgitmLv == "1" {
  2198. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2199. }
  2200. if item.ChrgitmLv == "2" {
  2201. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2202. }
  2203. if item.ChrgitmLv == "3" {
  2204. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2205. }
  2206. }
  2207. if item.MedChrgitmType == "05" { //治疗费
  2208. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2209. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2210. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2211. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2212. if item.ChrgitmLv == "1" {
  2213. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2214. }
  2215. if item.ChrgitmLv == "2" {
  2216. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2217. }
  2218. if item.ChrgitmLv == "3" {
  2219. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2220. }
  2221. }
  2222. if item.MedChrgitmType == "06" { //手术费
  2223. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2224. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2225. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2226. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2227. if item.ChrgitmLv == "1" {
  2228. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2229. }
  2230. if item.ChrgitmLv == "2" {
  2231. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2232. }
  2233. if item.ChrgitmLv == "3" {
  2234. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2235. }
  2236. }
  2237. if item.MedChrgitmType == "08" { //材料费
  2238. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2239. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2240. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2241. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2242. if item.ChrgitmLv == "1" {
  2243. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2244. }
  2245. if item.ChrgitmLv == "2" {
  2246. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2247. }
  2248. if item.ChrgitmLv == "3" {
  2249. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2250. }
  2251. }
  2252. if item.MedChrgitmType == "09" { //西药费
  2253. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2254. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2255. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2256. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2257. if item.ChrgitmLv == "1" {
  2258. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2259. }
  2260. if item.ChrgitmLv == "2" {
  2261. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2262. }
  2263. if item.ChrgitmLv == "3" {
  2264. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2265. }
  2266. }
  2267. if item.MedChrgitmType == "11" { //中成费
  2268. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2269. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2270. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2271. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2272. if item.ChrgitmLv == "1" {
  2273. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2274. }
  2275. if item.ChrgitmLv == "2" {
  2276. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2277. }
  2278. if item.ChrgitmLv == "3" {
  2279. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2280. }
  2281. }
  2282. if item.MedChrgitmType == "14" { //其他费
  2283. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2284. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2285. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2286. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2287. if item.ChrgitmLv == "1" {
  2288. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2289. }
  2290. if item.ChrgitmLv == "2" {
  2291. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2292. }
  2293. if item.ChrgitmLv == "3" {
  2294. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2295. }
  2296. }
  2297. }
  2298. var iteminfoStructs []service.IteminfoStruct
  2299. if bedCostTotal != 0 {
  2300. iteminfo.MedChrgitm = "01"
  2301. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2302. iteminfo.Amt = bedCostTotal
  2303. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2304. iteminfo.ClabAmt = bed_clab_amt
  2305. iteminfo.OthAmt = bed_other_amt
  2306. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2307. }
  2308. if checkCostTotal != 0 {
  2309. iteminfo.MedChrgitm = "03"
  2310. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2311. iteminfo.Amt = checkCostTotal
  2312. iteminfo.ClaaSumfee = check_claa_sunmfee
  2313. iteminfo.ClabAmt = check_clab_amt
  2314. iteminfo.OthAmt = check_other_amt
  2315. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2316. }
  2317. if laboratoryCostTotal != 0 {
  2318. iteminfo.MedChrgitm = "04"
  2319. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2320. iteminfo.Amt = laboratoryCostTotal
  2321. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2322. iteminfo.ClabAmt = laboratory_clab_amt
  2323. iteminfo.OthAmt = laboratory_other_amt
  2324. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2325. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2326. }
  2327. if treatCostTotal != 0 {
  2328. iteminfo.MedChrgitm = "05"
  2329. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2330. iteminfo.Amt = treatCostTotal
  2331. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2332. iteminfo.ClabAmt = treat_clab_amt
  2333. iteminfo.OthAmt = treat_other_amt
  2334. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2335. //(struct4101.IteminfoStruct, iteminfo)
  2336. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2337. }
  2338. if operationCostTotal != 0 {
  2339. iteminfo.MedChrgitm = "06"
  2340. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2341. iteminfo.Amt = operationCostTotal
  2342. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2343. iteminfo.ClabAmt = operation_clab_amt
  2344. iteminfo.OthAmt = operation_other_amt
  2345. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2346. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2347. }
  2348. if materialCostTotal != 0 {
  2349. iteminfo.MedChrgitm = "08"
  2350. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2351. iteminfo.Amt = materialCostTotal
  2352. iteminfo.ClaaSumfee = material_claa_sunmfee
  2353. iteminfo.ClabAmt = material_clab_amt
  2354. iteminfo.OthAmt = material_other_amt
  2355. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2356. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2357. }
  2358. if westernMedicineCostTotal != 0 {
  2359. iteminfo.MedChrgitm = "09"
  2360. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2361. iteminfo.Amt = westernMedicineCostTotal
  2362. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2363. iteminfo.ClabAmt = westernMedicine_clab_amt
  2364. iteminfo.OthAmt = westernMedicine_other_amt
  2365. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2366. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2367. }
  2368. if chineseTraditionalMedicineCostTotal != 0 {
  2369. iteminfo.MedChrgitm = "11"
  2370. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2371. iteminfo.Amt = westernMedicineCostTotal
  2372. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2373. iteminfo.ClabAmt = westernMedicine_clab_amt
  2374. iteminfo.OthAmt = westernMedicine_other_amt
  2375. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2376. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2377. }
  2378. if otherCostTotal != 0 {
  2379. iteminfo.MedChrgitm = "14"
  2380. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2381. iteminfo.Amt = otherCostTotal
  2382. iteminfo.ClaaSumfee = other_claa_sunmfee
  2383. iteminfo.ClabAmt = other_clab_amt
  2384. iteminfo.OthAmt = other_other_amt
  2385. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2386. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2387. }
  2388. struct4101.IteminfoStruct = iteminfoStructs
  2389. struct4101.Ntly = "中国"
  2390. struct4101.AdmCaty = "A03.06"
  2391. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2392. fmt.Println(result)
  2393. var dat map[string]interface{}
  2394. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2395. fmt.Println(dat)
  2396. } else {
  2397. fmt.Println(err)
  2398. }
  2399. userJSONBytes, _ := json.Marshal(dat)
  2400. var res ResultSeventeen
  2401. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2402. utils.ErrorLog("解析失败:%v", err)
  2403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2404. return
  2405. }
  2406. if res.Infcode != 0 {
  2407. c.ServeSuccessJSON(map[string]interface{}{
  2408. "failed_code": -10,
  2409. "msg": res.ErrMsg,
  2410. })
  2411. return
  2412. } else {
  2413. order.FaPiaoNumber = zero
  2414. order.FaPiaoCode = last_order.FaPiaoCode
  2415. service.UpdateOrder(order)
  2416. hisFundSettleListResult := &models.HisFundSettleListResult{
  2417. Number: res.Output.SetlListId,
  2418. Status: 1,
  2419. Ctime: time.Now().Unix(),
  2420. Mtime: time.Now().Unix(),
  2421. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2422. IsUpload: 1,
  2423. OrderId: order_id,
  2424. }
  2425. service.CreateUploadRecord(hisFundSettleListResult)
  2426. c.ServeSuccessJSON(map[string]interface{}{
  2427. "msg": "上传成功",
  2428. "result": hisFundSettleListResult,
  2429. })
  2430. return
  2431. }
  2432. }
  2433. func (c *HisApiController) GetBatchSettleList() {
  2434. orders, _ := service.GetAllHisOrder(10106)
  2435. for _, item := range orders {
  2436. order_id := item.ID
  2437. order, _ := service.GetHisOrderByIDTwo(order_id)
  2438. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2439. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2440. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2441. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2442. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2443. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2444. if order.ID == 0 {
  2445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2446. return
  2447. }
  2448. if his.BalanceAccountsType == 2 {
  2449. continue
  2450. }
  2451. struct4101 := service.Struct4101{
  2452. PsnNo: order.PsnNo,
  2453. MdtrtId: order.MdtrtId,
  2454. SetlId: order.SetlId,
  2455. PsnName: order.PsnName,
  2456. Gend: order.Gend,
  2457. Brdy: his.Brdy,
  2458. Age: his.Age,
  2459. Naty: order.Naty,
  2460. PatnCertType: "01",
  2461. Certno: order.Certno,
  2462. Prfs: "90",
  2463. ConerName: roles[0].UserName,
  2464. PatnRlts: "99",
  2465. ConerAddr: miConfig.OrgName,
  2466. ConerTel: admin.Mobile,
  2467. HiType: order.Insutype,
  2468. Insuplc: his.InsuplcAdmdvs,
  2469. MaindiagFlag: "1",
  2470. BillCode: order.FaPiaoCode,
  2471. BillNo: order.FaPiaoNumber,
  2472. BizSn: order.Number,
  2473. PsnSelfPay: order.PsnPartAmt,
  2474. PsnOwnPay: order.PsnPartAmt,
  2475. AcctPay: order.AcctPay,
  2476. PsnCashpay: order.PsnCashPay,
  2477. HiPaymtd: "1",
  2478. Hsorg: his.InsuplcAdmdvs,
  2479. HsorgOpter: his.InsuplcAdmdvs,
  2480. MedinsFillPsn: curRoles.UserName,
  2481. MedinsFillDept: depart.Name,
  2482. IptMedType: "2",
  2483. }
  2484. struct4101.SetlBegnDate = order.SetlTime
  2485. struct4101.SetlEndDate = order.SetlTime
  2486. //if order.SettleType == 1 {
  2487. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2488. // dateStr := t.Format("2006-01-02")
  2489. // struct4101.SetlBegnDate = dateStr
  2490. // struct4101.SetlEndDate = dateStr
  2491. //} else {
  2492. // t := time.Unix(int64(order.SettleStartTime), 0)
  2493. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2494. // dateStartStr := t.Format("2006-01-02")
  2495. // dateEndStr := t2.Format("2006-01-02")
  2496. // struct4101.SetlBegnDate = dateStartStr
  2497. // struct4101.SetlEndDate = dateEndStr
  2498. //}
  2499. var rf []CustomFundPay
  2500. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2501. var tempFunPays []service.CustomStruct
  2502. var tempFunPay610100 service.CustomStruct
  2503. for _, item := range rf {
  2504. if item.FundPayType == "610100" {
  2505. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2506. tempFunPay610100.FundPayType = item.FundPayType
  2507. } else {
  2508. var tempFunPay service.CustomStruct
  2509. tempFunPay.FundPayamt = item.FundPayamt
  2510. tempFunPay.FundPayType = item.FundPayType
  2511. tempFunPays = append(tempFunPays, tempFunPay)
  2512. }
  2513. }
  2514. tempFunPays = append(tempFunPays, tempFunPay610100)
  2515. struct4101.CustomStruct = tempFunPays
  2516. var tempDiaginfos []service.DiaginfoStructTwo
  2517. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2518. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2519. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2520. var config []*models.HisXtDiagnoseConfig
  2521. for _, item := range diagnosis_ids {
  2522. id, _ := strconv.ParseInt(item, 10, 64)
  2523. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2524. config = append(config, &diagnosisConfig)
  2525. }
  2526. for index, item := range config {
  2527. if index == 0 {
  2528. var tempDiaginfo service.DiaginfoStructTwo
  2529. tempDiaginfo.DiagCode = item.CountryCode
  2530. tempDiaginfo.DiagName = item.CountryContentName
  2531. tempDiaginfo.DiagType = "1"
  2532. tempDiaginfo.MaindiagFlag = "1"
  2533. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2534. } else {
  2535. var tempDiaginfo service.DiaginfoStructTwo
  2536. tempDiaginfo.DiagCode = item.CountryCode
  2537. tempDiaginfo.DiagName = item.CountryContentName
  2538. tempDiaginfo.DiagType = "2"
  2539. tempDiaginfo.MaindiagFlag = "0"
  2540. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2541. }
  2542. }
  2543. struct4101.Diseinfo = tempDiaginfos
  2544. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2545. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2546. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2547. tempOpspdiseinfo2.OprnOprtCode = ""
  2548. tempOpspdiseinfo2.OprnOprtName = ""
  2549. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2550. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2551. var iteminfo service.IteminfoStruct
  2552. var bedCostTotal float64 = 0 //床位总费
  2553. var bedCostSelfTotal float64 = 0 //床位自费
  2554. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2555. var examineCostTotal float64 = 0 //诊查总费
  2556. var examineCostSelfTotal float64 = 0 //诊查自费
  2557. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2558. var nursingCostTotal float64 = 0 //护理总费
  2559. var nursingCostSelfTotal float64 = 0 //护理自费
  2560. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2561. var chineseMedicineCostTotal float64 = 0 //中成药
  2562. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2563. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2564. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2565. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2566. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2567. var registerCostTotal float64 = 0 //一般诊疗费
  2568. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2569. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2570. var operationCostTotal float64 = 0 //手术费
  2571. var operationCostSelfTotal float64 = 0 //手术费
  2572. var operationCostPartSelfTotal float64 = 0 //手术费
  2573. var otherCostTotal float64 = 0 //其他费用
  2574. var otherCostSelfTotal float64 = 0 //其他费用
  2575. var otherCostPartSelfTotal float64 = 0 //其他费用
  2576. var materialCostTotal float64 = 0 //材料费
  2577. var materialCostSelfTotal float64 = 0 //材料费
  2578. var materialCostPartSelfTotal float64 = 0 //材料费
  2579. var westernMedicineCostTotal float64 = 0 //西药费
  2580. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2581. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2582. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2583. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2584. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2585. var checkCostTotal float64 = 0 //检查费
  2586. var checkCostSelfTotal float64 = 0 //检查费
  2587. var checkCostPartSelfTotal float64 = 0 //检查费
  2588. var laboratoryCostTotal float64 = 0 //化验费
  2589. var laboratoryCostSelfTotal float64 = 0 //化验费
  2590. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2591. var treatCostTotal float64 = 0 //治疗费用
  2592. var treatCostSelfTotal float64 = 0 //治疗费用
  2593. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2594. decimal.DivisionPrecision = 2
  2595. var bed_fulamt_ownpay_amt float64 = 0
  2596. var examine_fulamt_ownpay_amt float64 = 0
  2597. var nursing_fulamt_ownpay_amt float64 = 0
  2598. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2599. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2600. var register_fulamt_ownpay_amt float64 = 0
  2601. var operation_fulamt_ownpay_amt float64 = 0
  2602. var other_fulamt_ownpay_amt float64 = 0
  2603. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2604. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2605. var check_fulamt_ownpay_amt float64 = 0
  2606. var material_fulamt_ownpay_amt float64 = 0
  2607. var laboratory_fulamt_ownpay_amt float64 = 0
  2608. var treat_fulamt_ownpay_amt float64 = 0
  2609. var bed_claa_sunmfee float64 = 0
  2610. var bed_clab_amt float64 = 0
  2611. var bed_other_amt float64 = 0
  2612. var examine_claa_sunmfee float64 = 0
  2613. var examine_clab_amt float64 = 0
  2614. var examine_other_amt float64 = 0
  2615. var nursing_claa_sunmfee float64 = 0
  2616. var nursing_clab_amt float64 = 0
  2617. var nursing_other_amt float64 = 0
  2618. var chinese_medicine_claa_sunmfee float64 = 0
  2619. var chinese_medicine_clab_amt float64 = 0
  2620. var chinese_medicine_other_amt float64 = 0
  2621. var commonly_treatment_claa_sunmfee float64 = 0
  2622. var commonly_treatment_clab_amt float64 = 0
  2623. var commonly_treatment_other_amt float64 = 0
  2624. var operation_claa_sunmfee float64 = 0
  2625. var operation_clab_amt float64 = 0
  2626. var operation_other_amt float64 = 0
  2627. var other_claa_sunmfee float64 = 0
  2628. var other_clab_amt float64 = 0
  2629. var other_other_amt float64 = 0
  2630. var westernMedicine_claa_sunmfee float64 = 0
  2631. var westernMedicine_clab_amt float64 = 0
  2632. var westernMedicine_other_amt float64 = 0
  2633. var chineseTraditional_claa_sunmfee float64 = 0
  2634. var chineseTraditional_clab_amt float64 = 0
  2635. var chineseTraditional_other_amt float64 = 0
  2636. var check_claa_sunmfee float64 = 0
  2637. var check_clab_amt float64 = 0
  2638. var check_other_amt float64 = 0
  2639. var material_claa_sunmfee float64 = 0
  2640. var material_clab_amt float64 = 0
  2641. var material_other_amt float64 = 0
  2642. var laboratory_claa_sunmfee float64 = 0
  2643. var laboratory_clab_amt float64 = 0
  2644. var laboratory_other_amt float64 = 0
  2645. var treat_claa_sunmfee float64 = 0
  2646. var treat_clab_amt float64 = 0
  2647. var treat_other_amt float64 = 0
  2648. var register_claa_sunmfee float64 = 0
  2649. var register_clab_amt float64 = 0
  2650. var register_other_amt float64 = 0
  2651. for _, item := range order.HisOrderInfo {
  2652. if item.MedChrgitmType == "01" { //床位费
  2653. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2654. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2655. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2656. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2657. if item.ChrgitmLv == "1" {
  2658. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2659. }
  2660. if item.ChrgitmLv == "2" {
  2661. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2662. }
  2663. if item.ChrgitmLv == "3" {
  2664. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2665. }
  2666. }
  2667. if item.MedChrgitmType == "02" { //诊查
  2668. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2669. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2670. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2671. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2672. if item.ChrgitmLv == "1" {
  2673. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2674. }
  2675. if item.ChrgitmLv == "2" {
  2676. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2677. }
  2678. if item.ChrgitmLv == "3" {
  2679. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2680. }
  2681. }
  2682. if item.MedChrgitmType == "03" { //检查费
  2683. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2684. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2685. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2686. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2687. if item.ChrgitmLv == "1" {
  2688. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2689. }
  2690. if item.ChrgitmLv == "2" {
  2691. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2692. }
  2693. if item.ChrgitmLv == "3" {
  2694. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2695. }
  2696. }
  2697. if item.MedChrgitmType == "04" { //化验费
  2698. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2699. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2700. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2701. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2702. if item.ChrgitmLv == "1" {
  2703. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2704. }
  2705. if item.ChrgitmLv == "2" {
  2706. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2707. }
  2708. if item.ChrgitmLv == "3" {
  2709. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2710. }
  2711. }
  2712. if item.MedChrgitmType == "05" { //治疗费
  2713. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2714. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2715. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2716. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2717. if item.ChrgitmLv == "1" {
  2718. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2719. }
  2720. if item.ChrgitmLv == "2" {
  2721. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2722. }
  2723. if item.ChrgitmLv == "3" {
  2724. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2725. }
  2726. }
  2727. if item.MedChrgitmType == "06" { //手术费
  2728. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2729. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2730. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2731. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2732. if item.ChrgitmLv == "1" {
  2733. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2734. }
  2735. if item.ChrgitmLv == "2" {
  2736. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2737. }
  2738. if item.ChrgitmLv == "3" {
  2739. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2740. }
  2741. }
  2742. if item.MedChrgitmType == "07" { //手术费
  2743. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2744. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2745. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2746. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2747. if item.ChrgitmLv == "1" {
  2748. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2749. }
  2750. if item.ChrgitmLv == "2" {
  2751. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2752. }
  2753. if item.ChrgitmLv == "3" {
  2754. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2755. }
  2756. }
  2757. if item.MedChrgitmType == "08" { //材料费
  2758. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2759. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2760. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2761. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2762. if item.ChrgitmLv == "1" {
  2763. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2764. }
  2765. if item.ChrgitmLv == "2" {
  2766. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2767. }
  2768. if item.ChrgitmLv == "3" {
  2769. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2770. }
  2771. }
  2772. if item.MedChrgitmType == "09" { //西药费
  2773. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2774. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2775. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2776. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2777. if item.ChrgitmLv == "1" {
  2778. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2779. }
  2780. if item.ChrgitmLv == "2" {
  2781. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2782. }
  2783. if item.ChrgitmLv == "3" {
  2784. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2785. }
  2786. }
  2787. if item.MedChrgitmType == "10" { //中药饮片
  2788. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2789. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2790. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2791. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2792. if item.ChrgitmLv == "1" {
  2793. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2794. }
  2795. if item.ChrgitmLv == "2" {
  2796. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2797. }
  2798. if item.ChrgitmLv == "3" {
  2799. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2800. }
  2801. }
  2802. if item.MedChrgitmType == "11" { //中成费
  2803. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2804. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2805. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2806. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2807. if item.ChrgitmLv == "1" {
  2808. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2809. }
  2810. if item.ChrgitmLv == "2" {
  2811. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2812. }
  2813. if item.ChrgitmLv == "3" {
  2814. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2815. }
  2816. }
  2817. if item.MedChrgitmType == "12" { //中成费
  2818. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2819. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2820. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2821. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2822. if item.ChrgitmLv == "1" {
  2823. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2824. }
  2825. if item.ChrgitmLv == "2" {
  2826. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2827. }
  2828. if item.ChrgitmLv == "3" {
  2829. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2830. }
  2831. }
  2832. if item.MedChrgitmType == "13" { //中成费
  2833. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2834. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2835. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2836. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2837. if item.ChrgitmLv == "1" {
  2838. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2839. }
  2840. if item.ChrgitmLv == "2" {
  2841. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2842. }
  2843. if item.ChrgitmLv == "3" {
  2844. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2845. }
  2846. }
  2847. if item.MedChrgitmType == "14" { //其他费
  2848. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2849. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2850. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2851. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2852. if item.ChrgitmLv == "1" {
  2853. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2854. }
  2855. if item.ChrgitmLv == "2" {
  2856. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2857. }
  2858. if item.ChrgitmLv == "3" {
  2859. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2860. }
  2861. }
  2862. }
  2863. var iteminfoStructs []service.IteminfoStruct
  2864. if bedCostTotal != 0 {
  2865. iteminfo.MedChrgitm = "01"
  2866. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2867. iteminfo.Amt = bedCostTotal
  2868. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2869. iteminfo.ClabAmt = bed_clab_amt
  2870. iteminfo.OthAmt = bed_other_amt
  2871. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2872. }
  2873. if examineCostTotal != 0 {
  2874. iteminfo.MedChrgitm = "02"
  2875. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2876. iteminfo.Amt = examineCostTotal
  2877. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2878. iteminfo.ClabAmt = examine_clab_amt
  2879. iteminfo.OthAmt = examine_other_amt
  2880. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2881. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2882. }
  2883. if checkCostTotal != 0 {
  2884. iteminfo.MedChrgitm = "03"
  2885. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2886. iteminfo.Amt = checkCostTotal
  2887. iteminfo.ClaaSumfee = check_claa_sunmfee
  2888. iteminfo.ClabAmt = check_clab_amt
  2889. iteminfo.OthAmt = check_other_amt
  2890. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2891. }
  2892. if laboratoryCostTotal != 0 {
  2893. iteminfo.MedChrgitm = "04"
  2894. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2895. iteminfo.Amt = laboratoryCostTotal
  2896. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2897. iteminfo.ClabAmt = laboratory_clab_amt
  2898. iteminfo.OthAmt = laboratory_other_amt
  2899. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2900. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2901. }
  2902. if treatCostTotal != 0 {
  2903. iteminfo.MedChrgitm = "05"
  2904. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2905. iteminfo.Amt = treatCostTotal
  2906. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2907. iteminfo.ClabAmt = treat_clab_amt
  2908. iteminfo.OthAmt = treat_other_amt
  2909. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2910. //(struct4101.IteminfoStruct, iteminfo)
  2911. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2912. }
  2913. if operationCostTotal != 0 {
  2914. iteminfo.MedChrgitm = "06"
  2915. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2916. iteminfo.Amt = operationCostTotal
  2917. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2918. iteminfo.ClabAmt = operation_clab_amt
  2919. iteminfo.OthAmt = operation_other_amt
  2920. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2921. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2922. }
  2923. if nursingCostTotal != 0 {
  2924. iteminfo.MedChrgitm = "07"
  2925. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2926. iteminfo.Amt = nursingCostTotal
  2927. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2928. iteminfo.ClabAmt = nursing_clab_amt
  2929. iteminfo.OthAmt = nursing_other_amt
  2930. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2931. }
  2932. if materialCostTotal != 0 {
  2933. iteminfo.MedChrgitm = "08"
  2934. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2935. iteminfo.Amt = materialCostTotal
  2936. iteminfo.ClaaSumfee = material_claa_sunmfee
  2937. iteminfo.ClabAmt = material_clab_amt
  2938. iteminfo.OthAmt = material_other_amt
  2939. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2940. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2941. }
  2942. if westernMedicineCostTotal != 0 {
  2943. iteminfo.MedChrgitm = "09"
  2944. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2945. iteminfo.Amt = westernMedicineCostTotal
  2946. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2947. iteminfo.ClabAmt = westernMedicine_clab_amt
  2948. iteminfo.OthAmt = westernMedicine_other_amt
  2949. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2950. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2951. }
  2952. if chineseMedicineCostTotal != 0 {
  2953. iteminfo.MedChrgitm = "10"
  2954. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2955. iteminfo.Amt = chineseMedicineCostTotal
  2956. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2957. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2958. iteminfo.OthAmt = chinese_medicine_other_amt
  2959. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2960. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2961. }
  2962. if chineseTraditionalMedicineCostTotal != 0 {
  2963. iteminfo.MedChrgitm = "11"
  2964. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2965. iteminfo.Amt = westernMedicineCostTotal
  2966. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2967. iteminfo.ClabAmt = westernMedicine_clab_amt
  2968. iteminfo.OthAmt = westernMedicine_other_amt
  2969. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2970. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2971. }
  2972. if commonlyTreatmentCostTotal != 0 {
  2973. iteminfo.MedChrgitm = "12"
  2974. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2975. iteminfo.Amt = commonlyTreatmentCostTotal
  2976. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2977. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2978. iteminfo.OthAmt = commonly_treatment_other_amt
  2979. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2980. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2981. }
  2982. if registerCostTotal != 0 {
  2983. iteminfo.MedChrgitm = "13"
  2984. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2985. iteminfo.Amt = registerCostTotal
  2986. iteminfo.ClaaSumfee = register_claa_sunmfee
  2987. iteminfo.ClabAmt = register_clab_amt
  2988. iteminfo.OthAmt = register_other_amt
  2989. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2990. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2991. }
  2992. if otherCostTotal != 0 {
  2993. iteminfo.MedChrgitm = "14"
  2994. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2995. iteminfo.Amt = otherCostTotal
  2996. iteminfo.ClaaSumfee = other_claa_sunmfee
  2997. iteminfo.ClabAmt = other_clab_amt
  2998. iteminfo.OthAmt = other_other_amt
  2999. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3000. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3001. }
  3002. struct4101.IteminfoStruct = iteminfoStructs
  3003. struct4101.Ntly = "中国"
  3004. struct4101.AdmCaty = "A03.06"
  3005. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3006. fmt.Println(result)
  3007. var dat map[string]interface{}
  3008. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3009. fmt.Println(dat)
  3010. } else {
  3011. fmt.Println(err)
  3012. }
  3013. userJSONBytes, _ := json.Marshal(dat)
  3014. var res ResultSeventeen
  3015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3016. utils.ErrorLog("解析失败:%v", err)
  3017. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3018. adminUser := c.GetAdminUserInfo()
  3019. errlog := &models.HisOrderError{
  3020. UserOrgId: adminUser.CurrentOrgId,
  3021. Ctime: time.Now().Unix(),
  3022. Mtime: time.Now().Unix(),
  3023. ErrMsg: res.ErrMsg + "解析失败",
  3024. Status: 1,
  3025. PatientId: order_id,
  3026. Stage: 10106,
  3027. }
  3028. service.CreateErrMsgLog(errlog)
  3029. continue
  3030. }
  3031. if res.Infcode != 0 {
  3032. adminUser := c.GetAdminUserInfo()
  3033. errlog := &models.HisOrderError{
  3034. UserOrgId: adminUser.CurrentOrgId,
  3035. Ctime: time.Now().Unix(),
  3036. Mtime: time.Now().Unix(),
  3037. ErrMsg: res.ErrMsg,
  3038. Status: 1,
  3039. PatientId: order_id,
  3040. Stage: 10106,
  3041. }
  3042. service.CreateErrMsgLog(errlog)
  3043. continue
  3044. } else {
  3045. hisFundSettleListResult := &models.HisFundSettleListResult{
  3046. Number: res.Output.SetlListId,
  3047. Status: 1,
  3048. Ctime: time.Now().Unix(),
  3049. Mtime: time.Now().Unix(),
  3050. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3051. IsUpload: 1,
  3052. OrderId: order_id,
  3053. }
  3054. service.CreateUploadRecord(hisFundSettleListResult)
  3055. continue
  3056. }
  3057. }
  3058. }
  3059. func (c *HisApiController) GetOrgInfo() {
  3060. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3061. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3062. }
  3063. func (c *HisApiController) GetHisPatientInfo() {
  3064. medical_insurance_card := c.GetString("medical_insurance_card")
  3065. id_card_type, _ := c.GetInt64("id_card_type")
  3066. id_card := c.GetString("id_card")
  3067. adminInfo := c.GetAdminUserInfo()
  3068. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3069. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3070. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3071. IdCardNo := ""
  3072. if id_card_type == 1 {
  3073. IdCardNo = medical_insurance_card
  3074. } else if id_card_type == 2 {
  3075. IdCardNo = id_card
  3076. }
  3077. if config.IsOpen == 1 {
  3078. 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
  3079. resp, requestErr := http.Get(api)
  3080. if requestErr != nil {
  3081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3082. return
  3083. }
  3084. defer resp.Body.Close()
  3085. body, ioErr := ioutil.ReadAll(resp.Body)
  3086. if ioErr != nil {
  3087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3089. return
  3090. }
  3091. var respJSON map[string]interface{}
  3092. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3095. return
  3096. }
  3097. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3098. userJSONBytes, _ := json.Marshal(userJSON)
  3099. var res ResultTwo
  3100. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3101. utils.ErrorLog("解析失败:%v", err)
  3102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3103. return
  3104. }
  3105. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3106. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3107. infoStr := string(Iinfos)
  3108. idetinfoStr := string(Idetinfos)
  3109. if res.Infcode == 0 {
  3110. his := models.VMHisPatient{
  3111. Status: 1,
  3112. Ctime: time.Now().Unix(),
  3113. Mtime: time.Now().Unix(),
  3114. PsnNo: res.Output.Baseinfo.PsnNo,
  3115. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3116. Certno: res.Output.Baseinfo.Certno,
  3117. PsnName: res.Output.Baseinfo.PsnName,
  3118. Gend: res.Output.Baseinfo.Gend,
  3119. Naty: res.Output.Baseinfo.Naty,
  3120. Brdy: res.Output.Baseinfo.Brdy,
  3121. Age: res.Output.Baseinfo.Age,
  3122. Iinfo: infoStr,
  3123. Idetinfo: idetinfoStr,
  3124. UserOrgId: adminInfo.CurrentOrgId,
  3125. IsReturn: 1,
  3126. IdCardType: id_card_type,
  3127. }
  3128. c.ServeSuccessJSON(map[string]interface{}{
  3129. "info": his,
  3130. })
  3131. } else {
  3132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3133. return
  3134. }
  3135. }
  3136. }
  3137. //func GetBasBaseInfo() (jsonStr string, err error) {
  3138. //
  3139. // handle := syscall.NewLazyDLL("SSCard.dll")
  3140. // add := handle.NewProc("ReadCardBas")
  3141. // str := make([]byte, 1024)
  3142. // str1 := make([]byte, 1024)
  3143. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3144. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3145. //
  3146. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3147. //
  3148. // fmt.Println("> Add(4,5)的结果为:", ret)
  3149. // handle.Release()
  3150. //
  3151. // return "", nil
  3152. //
  3153. //}
  3154. //func GetQRBaseInfo() (jsonStr string, err error) {
  3155. // handle := syscall.LoadDLL("SSCard.dll")
  3156. // ReadCardBas := handle.FindProc("GetQRBase")
  3157. //
  3158. // str := make([]byte, 256)
  3159. // str1 := make([]byte, 256)
  3160. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3161. //
  3162. // fmt.Println(string(str))
  3163. // fmt.Println(r)
  3164. // return string(str), nil
  3165. //}
  3166. //func CardInit() int {
  3167. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3168. // add := DllTestDef.MustFindProc("Init")
  3169. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3170. // if err != nil {
  3171. // fmt.Println("SSCard的运算结果为:", ret)
  3172. // }
  3173. // result := int(ret)
  3174. // return result
  3175. //}
  3176. //func CardInit() int {
  3177. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3178. // if err != nil {
  3179. // fmt.Println("SSCard的运算结果为:", ret)
  3180. // }
  3181. // fmt.Println(err)
  3182. // result := int(ret)
  3183. // return result
  3184. //}
  3185. func IntPtr(n int) uintptr {
  3186. return uintptr(n)
  3187. }
  3188. func StrPtr(s string) uintptr {
  3189. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3190. }
  3191. type Result2001 struct {
  3192. Cainfo interface{} `json:"cainfo"`
  3193. ErrMsg string `json:"err_msg"`
  3194. InfRefmsgid string `json:"inf_refmsgid"`
  3195. Infcode int64 `json:"infcode"`
  3196. Output struct {
  3197. Trtinfo struct {
  3198. PsnNo string `json:"psn_no"`
  3199. TrtChkType string `json:"trt_chk_type"`
  3200. FundPayType string `json:"fund_pay_type"`
  3201. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3202. Begndate string `json:"begndate"`
  3203. Enddate string `json:"enddate"`
  3204. TrtChkRslt string `json:"trt_chk_rslt"`
  3205. } `json:"trtinfo"`
  3206. } `json:"output"`
  3207. RefmsgTime string `json:"refmsg_time"`
  3208. RespondTime string `json:"respond_time"`
  3209. Signtype interface{} `json:"signtype"`
  3210. WarnMsg interface{} `json:"warn_msg"`
  3211. }
  3212. type Result2001Org10265 struct {
  3213. Cainfo interface{} `json:"cainfo"`
  3214. ErrMsg string `json:"err_msg"`
  3215. InfRefmsgid string `json:"inf_refmsgid"`
  3216. Infcode string `json:"infcode"`
  3217. Output struct {
  3218. Trtinfo struct {
  3219. PsnNo string `json:"psn_no"`
  3220. TrtChkType string `json:"trt_chk_type"`
  3221. FundPayType string `json:"fund_pay_type"`
  3222. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3223. Begndate string `json:"begndate"`
  3224. Enddate string `json:"enddate"`
  3225. TrtChkRslt string `json:"trt_chk_rslt"`
  3226. } `json:"trtinfo"`
  3227. } `json:"output"`
  3228. RefmsgTime string `json:"refmsg_time"`
  3229. RespondTime string `json:"respond_time"`
  3230. Signtype interface{} `json:"signtype"`
  3231. WarnMsg interface{} `json:"warn_msg"`
  3232. }
  3233. type ResultTwo struct {
  3234. ErrMsg string `json:"err_msg"`
  3235. InfRefmsgid string `json:"inf_refmsgid"`
  3236. Infcode int64 `json:"infcode"`
  3237. Output struct {
  3238. Baseinfo struct {
  3239. Age float64 `json:"age"`
  3240. Brdy string `json:"brdy"`
  3241. Certno string `json:"certno"`
  3242. Gend string `json:"gend"`
  3243. Naty string `json:"naty"`
  3244. PsnCertType string `json:"psn_cert_type"`
  3245. PsnName string `json:"psn_name"`
  3246. PsnNo string `json:"psn_no"`
  3247. } `json:"baseinfo"`
  3248. Idetinfo []interface{} `json:"idetinfo"`
  3249. Iinfo []struct {
  3250. Balc float64 `json:"balc"`
  3251. CvlservFlag string `json:"cvlserv_flag"`
  3252. EmpName string `json:"emp_name"`
  3253. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3254. Insutype string `json:"insutype"`
  3255. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3256. PausInsuDate string `json:"paus_insu_date"`
  3257. PsnInsuDate string `json:"psn_insu_date"`
  3258. PsnInsuStas string `json:"psn_insu_stas"`
  3259. PsnType string `json:"psn_type"`
  3260. } `json:"insuinfo"`
  3261. } `json:"output"`
  3262. RefmsgTime string `json:"refmsg_time"`
  3263. RespondTime string `json:"respond_time"`
  3264. Signtype interface{} `json:"signtype"`
  3265. WarnInfo interface{} `json:"warn_info"`
  3266. }
  3267. type ResultTwo10265 struct {
  3268. ErrMsg string `json:"err_msg"`
  3269. InfRefmsgid string `json:"inf_refmsgid"`
  3270. Infcode string `json:"infcode"`
  3271. Output struct {
  3272. Baseinfo struct {
  3273. Age float64 `json:"age"`
  3274. Brdy string `json:"brdy"`
  3275. Certno string `json:"certno"`
  3276. Gend string `json:"gend"`
  3277. Naty string `json:"naty"`
  3278. PsnCertType string `json:"psn_cert_type"`
  3279. PsnName string `json:"psn_name"`
  3280. PsnNo string `json:"psn_no"`
  3281. } `json:"baseinfo"`
  3282. Idetinfo []interface{} `json:"idetinfo"`
  3283. Iinfo []struct {
  3284. Balc float64 `json:"balc"`
  3285. CvlservFlag string `json:"cvlserv_flag"`
  3286. EmpName string `json:"emp_name"`
  3287. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3288. Insutype string `json:"insutype"`
  3289. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3290. PausInsuDate string `json:"paus_insu_date"`
  3291. PsnInsuDate string `json:"psn_insu_date"`
  3292. PsnInsuStas string `json:"psn_insu_stas"`
  3293. PsnType string `json:"psn_type"`
  3294. } `json:"insuinfo"`
  3295. } `json:"output"`
  3296. RefmsgTime string `json:"refmsg_time"`
  3297. RespondTime string `json:"respond_time"`
  3298. Signtype interface{} `json:"signtype"`
  3299. WarnInfo interface{} `json:"warn_info"`
  3300. }
  3301. type ResultThree struct {
  3302. Cainfo interface{} `json:"cainfo"`
  3303. ErrMsg string `json:"err_msg"`
  3304. InfRefmsgid string `json:"inf_refmsgid"`
  3305. Infcode int64 `json:"infcode"`
  3306. Output struct {
  3307. Data struct {
  3308. IptOtpNo string `json:"ipt_otp_no"`
  3309. MdtrtID string `json:"mdtrt_id"`
  3310. PsnNo string `json:"psn_no"`
  3311. } `json:"data"`
  3312. } `json:"output"`
  3313. RefmsgTime string `json:"refmsg_time"`
  3314. RespondTime string `json:"respond_time"`
  3315. Signtype interface{} `json:"signtype"`
  3316. WarnMsg interface{} `json:"warn_msg"`
  3317. }
  3318. type ResultThree10265 struct {
  3319. Cainfo interface{} `json:"cainfo"`
  3320. ErrMsg string `json:"err_msg"`
  3321. InfRefmsgid string `json:"inf_refmsgid"`
  3322. Infcode string `json:"infcode"`
  3323. Output struct {
  3324. Data struct {
  3325. IptOtpNo string `json:"ipt_otp_no"`
  3326. MdtrtID string `json:"mdtrt_id"`
  3327. PsnNo string `json:"psn_no"`
  3328. } `json:"data"`
  3329. } `json:"output"`
  3330. RefmsgTime string `json:"refmsg_time"`
  3331. RespondTime string `json:"respond_time"`
  3332. Signtype interface{} `json:"signtype"`
  3333. WarnMsg interface{} `json:"warn_msg"`
  3334. }
  3335. type ResultFour struct {
  3336. Cainfo string `json:"cainfo"`
  3337. ErrMsg string `json:"err_msg"`
  3338. InfRefmsgid string `json:"inf_refmsgid"`
  3339. Infcode int64 `json:"infcode"`
  3340. Output struct {
  3341. Result []struct {
  3342. BasMednFlag string `json:"bas_medn_flag"`
  3343. ChldMedcFlag string `json:"chld_medc_flag"`
  3344. ChrgitmLv string `json:"chrgitm_lv"`
  3345. Cnt float64 `json:"cnt"`
  3346. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3347. DrtReimFlag string `json:"drt_reim_flag"`
  3348. FeedetlSn string `json:"feedetl_sn"`
  3349. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3350. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3351. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3352. ListSpItemFlag string `json:"list_sp_item_flag"`
  3353. LmtUsedFlag string `json:"lmt_used_flag"`
  3354. MedChrgitmType string `json:"med_chrgitm_type"`
  3355. Memo string `json:"memo"`
  3356. OverlmtAmt float64 `json:"overlmt_amt"`
  3357. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3358. Pric float64 `json:"pric"`
  3359. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3360. SelfpayProp float64 `json:"selfpay_prop"`
  3361. } `json:"result"`
  3362. } `json:"output"`
  3363. RefmsgTime string `json:"refmsg_time"`
  3364. RespondTime string `json:"respond_time"`
  3365. Signtype string `json:"signtype"`
  3366. WarnMsg string `json:"warn_msg"`
  3367. }
  3368. type ResultFour10265 struct {
  3369. Cainfo string `json:"cainfo"`
  3370. ErrMsg string `json:"err_msg"`
  3371. InfRefmsgid string `json:"inf_refmsgid"`
  3372. Infcode string `json:"infcode"`
  3373. Output struct {
  3374. Result []struct {
  3375. BasMednFlag string `json:"bas_medn_flag"`
  3376. ChldMedcFlag string `json:"chld_medc_flag"`
  3377. ChrgitmLv string `json:"chrgitm_lv"`
  3378. Cnt float64 `json:"cnt"`
  3379. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3380. DrtReimFlag string `json:"drt_reim_flag"`
  3381. FeedetlSn string `json:"feedetl_sn"`
  3382. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3383. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3384. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3385. ListSpItemFlag string `json:"list_sp_item_flag"`
  3386. LmtUsedFlag string `json:"lmt_used_flag"`
  3387. MedChrgitmType string `json:"med_chrgitm_type"`
  3388. Memo string `json:"memo"`
  3389. OverlmtAmt float64 `json:"overlmt_amt"`
  3390. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3391. Pric float64 `json:"pric"`
  3392. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3393. SelfpayProp float64 `json:"selfpay_prop"`
  3394. } `json:"result"`
  3395. } `json:"output"`
  3396. RefmsgTime string `json:"refmsg_time"`
  3397. RespondTime string `json:"respond_time"`
  3398. Signtype string `json:"signtype"`
  3399. WarnMsg string `json:"warn_msg"`
  3400. }
  3401. type ResultFive struct {
  3402. Balc float64 `json:"balc"`
  3403. CvlservFlag string `json:"cvlserv_flag"`
  3404. EmpName string `json:"emp_name"`
  3405. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3406. Insutype string `json:"insutype"`
  3407. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3408. PausInsuDate string `json:"paus_insu_date"`
  3409. PsnInsuDate string `json:"psn_insu_date"`
  3410. PsnInsuStas string `json:"psn_insu_stas"`
  3411. PsnType string `json:"psn_type"`
  3412. }
  3413. type ResultSix struct {
  3414. Cainfo interface{} `json:"cainfo"`
  3415. ErrMsg string `json:"err_msg"`
  3416. InfRefmsgid string `json:"inf_refmsgid"`
  3417. Infcode int64 `json:"infcode"`
  3418. Output struct {
  3419. } `json:"output"`
  3420. RefmsgTime string `json:"refmsg_time"`
  3421. RespondTime string `json:"respond_time"`
  3422. Signtype interface{} `json:"signtype"`
  3423. WarnMsg interface{} `json:"warn_msg"`
  3424. }
  3425. type ResultSix10265 struct {
  3426. Cainfo interface{} `json:"cainfo"`
  3427. ErrMsg string `json:"err_msg"`
  3428. InfRefmsgid string `json:"inf_refmsgid"`
  3429. Infcode string `json:"infcode"`
  3430. Output struct {
  3431. } `json:"output"`
  3432. RefmsgTime string `json:"refmsg_time"`
  3433. RespondTime string `json:"respond_time"`
  3434. Signtype interface{} `json:"signtype"`
  3435. WarnMsg interface{} `json:"warn_msg"`
  3436. }
  3437. type ResultSeven struct {
  3438. Cainfo string `json:"cainfo"`
  3439. ErrMsg string `json:"err_msg"`
  3440. InfRefmsgid string `json:"inf_refmsgid"`
  3441. Infcode int64 `json:"infcode"`
  3442. Output struct {
  3443. Setldetail []interface{} `json:"setldetail"`
  3444. Setlinfo struct {
  3445. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3446. AcctPay float64 `json:"acct_pay"`
  3447. ActPayDedc float64 `json:"act_pay_dedc"`
  3448. Age float64 `json:"age"`
  3449. Balc float64 `json:"balc"`
  3450. Brdy string `json:"brdy"`
  3451. Certno string `json:"certno"`
  3452. ClrOptins string `json:"clr_optins"`
  3453. ClrType string `json:"clr_type"`
  3454. ClrWay string `json:"clr_way"`
  3455. CvlservFlag string `json:"cvlserv_flag"`
  3456. CvlservPay float64 `json:"cvlserv_pay"`
  3457. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3458. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3459. Gend string `json:"gend"`
  3460. HifesPay float64 `json:"hifes_pay"`
  3461. HifmiPay float64 `json:"hifmi_pay"`
  3462. HifpPay float64 `json:"hifp_pay"`
  3463. HospPartAmt float64 `json:"hosp_part_amt"`
  3464. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3465. Insutype string `json:"insutype"`
  3466. MafPay float64 `json:"maf_pay"`
  3467. MdtrtCertType string `json:"mdtrt_cert_type"`
  3468. HifobPay float64 `json:"hifob_pay"`
  3469. MdtrtID string `json:"mdtrt_id"`
  3470. MedType string `json:"med_type"`
  3471. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3472. MedinsSetlID string `json:"medins_setl_id"`
  3473. Naty string `json:"naty"`
  3474. OthPay float64 `json:"oth_pay"`
  3475. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3476. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3477. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3478. PsnCashPay float64 `json:"psn_cash_pay"`
  3479. PsnCertType string `json:"psn_cert_type"`
  3480. PsnName string `json:"psn_name"`
  3481. PsnNo string `json:"psn_no"`
  3482. PsnPartAmt float64 `json:"psn_part_amt"`
  3483. PsnType string `json:"psn_type"`
  3484. SetlID string `json:"setl_id"`
  3485. SetlTime string `json:"setl_time"`
  3486. } `json:"setlinfo"`
  3487. } `json:"output"`
  3488. RefmsgTime string `json:"refmsg_time"`
  3489. RespondTime string `json:"respond_time"`
  3490. Signtype interface{} `json:"signtype"`
  3491. WarnMsg interface{} `json:"warn_msg"`
  3492. }
  3493. type ResultSeven10265 struct {
  3494. Cainfo string `json:"cainfo"`
  3495. ErrMsg string `json:"err_msg"`
  3496. InfRefmsgid string `json:"inf_refmsgid"`
  3497. Infcode string `json:"infcode"`
  3498. Output struct {
  3499. Setldetail []interface{} `json:"setldetail"`
  3500. Setlinfo struct {
  3501. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3502. AcctPay float64 `json:"acct_pay"`
  3503. ActPayDedc float64 `json:"act_pay_dedc"`
  3504. Age float64 `json:"age"`
  3505. Balc float64 `json:"balc"`
  3506. Brdy string `json:"brdy"`
  3507. Certno string `json:"certno"`
  3508. ClrOptins string `json:"clr_optins"`
  3509. ClrType string `json:"clr_type"`
  3510. ClrWay string `json:"clr_way"`
  3511. CvlservFlag string `json:"cvlserv_flag"`
  3512. CvlservPay float64 `json:"cvlserv_pay"`
  3513. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3514. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3515. Gend string `json:"gend"`
  3516. HifesPay float64 `json:"hifes_pay"`
  3517. HifmiPay float64 `json:"hifmi_pay"`
  3518. HifpPay float64 `json:"hifp_pay"`
  3519. HospPartAmt float64 `json:"hosp_part_amt"`
  3520. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3521. Insutype string `json:"insutype"`
  3522. MafPay float64 `json:"maf_pay"`
  3523. MdtrtCertType string `json:"mdtrt_cert_type"`
  3524. HifobPay float64 `json:"hifob_pay"`
  3525. MdtrtID string `json:"mdtrt_id"`
  3526. MedType string `json:"med_type"`
  3527. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3528. MedinsSetlID string `json:"medins_setl_id"`
  3529. Naty string `json:"naty"`
  3530. OthPay float64 `json:"oth_pay"`
  3531. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3532. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3533. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3534. PsnCashPay float64 `json:"psn_cash_pay"`
  3535. PsnCertType string `json:"psn_cert_type"`
  3536. PsnName string `json:"psn_name"`
  3537. PsnNo string `json:"psn_no"`
  3538. PsnPartAmt float64 `json:"psn_part_amt"`
  3539. PsnType string `json:"psn_type"`
  3540. SetlID string `json:"setl_id"`
  3541. SetlTime string `json:"setl_time"`
  3542. } `json:"setlinfo"`
  3543. } `json:"output"`
  3544. RefmsgTime string `json:"refmsg_time"`
  3545. RespondTime string `json:"respond_time"`
  3546. Signtype interface{} `json:"signtype"`
  3547. WarnMsg interface{} `json:"warn_msg"`
  3548. }
  3549. type ResultEight struct {
  3550. Cainfo string `json:"cainfo"`
  3551. ErrMsg string `json:"err_msg"`
  3552. InfRefmsgid string `json:"inf_refmsgid"`
  3553. Infcode int64 `json:"infcode"`
  3554. Output struct {
  3555. Stmtinfo struct {
  3556. SetlOptins string `json:"setl_optins"`
  3557. StmtRslt string `json:"stmt_rslt"`
  3558. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3559. } `json:"stmtinfo"`
  3560. } `json:"output"`
  3561. RefmsgTime string `json:"refmsg_time"`
  3562. RespondTime string `json:"respond_time"`
  3563. Signtype interface{} `json:"signtype"`
  3564. WarnMsg interface{} `json:"warn_msg"`
  3565. }
  3566. type ResultEightFor10188 struct {
  3567. Cainfo string `json:"cainfo"`
  3568. ErrMsg string `json:"err_msg"`
  3569. InfRefmsgid string `json:"inf_refmsgid"`
  3570. Infcode string `json:"infcode"`
  3571. Output struct {
  3572. Stmtinfo struct {
  3573. SetlOptins string `json:"setl_optins"`
  3574. StmtRslt string `json:"stmt_rslt"`
  3575. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3576. } `json:"stmtinfo"`
  3577. } `json:"output"`
  3578. RefmsgTime string `json:"refmsg_time"`
  3579. RespondTime string `json:"respond_time"`
  3580. Signtype interface{} `json:"signtype"`
  3581. WarnMsg interface{} `json:"warn_msg"`
  3582. }
  3583. type ResultNine struct {
  3584. Cainfo string `json:"cainfo"`
  3585. ErrMsg string `json:"err_msg"`
  3586. InfRefmsgid string `json:"inf_refmsgid"`
  3587. Infcode int64 `json:"infcode"`
  3588. Output struct {
  3589. FileQuryNo string `json:"file_qury_no"`
  3590. } `json:"output"`
  3591. RefmsgTime string `json:"refmsg_time"`
  3592. RespondTime string `json:"respond_time"`
  3593. Signtype interface{} `json:"signtype"`
  3594. WarnMsg interface{} `json:"warn_msg"`
  3595. }
  3596. type ResultTen struct {
  3597. Cainfo string `json:"cainfo"`
  3598. ErrMsg string `json:"err_msg"`
  3599. InfRefmsgid string `json:"inf_refmsgid"`
  3600. Infcode int64 `json:"infcode"`
  3601. Output struct {
  3602. DldEndtime string `json:"dld_endtime"`
  3603. FileQuryNo string `json:"file_qury_no"`
  3604. Filename string `json:"filename"`
  3605. } `json:"output"`
  3606. RefmsgTime string `json:"refmsg_time"`
  3607. RespondTime string `json:"respond_time"`
  3608. Signtype interface{} `json:"signtype"`
  3609. WarnMsg interface{} `json:"warn_msg"`
  3610. }
  3611. //type Autogenerated struct {
  3612. // Output struct {
  3613. // Setlinfo struct {
  3614. // SetlTime string `json:"setl_time"`
  3615. // CvlservPay float64 `json:"cvlserv_pay"`
  3616. // Year string `json:"year"`
  3617. // MedType string `json:"med_type"`
  3618. // PsnPay float64 `json:"psn_pay"`
  3619. // OpterID string `json:"opter_id"`
  3620. // Begndate string `json:"begndate"`
  3621. // FlxempeFlag string `json:"flxempe_flag"`
  3622. // HifmiPay float64 `json:"hifmi_pay"`
  3623. // PsnNo string `json:"psn_no"`
  3624. // ActPayDedc float64 `json:"act_pay_dedc"`
  3625. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3626. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3627. // ClrWay string `json:"clr_way"`
  3628. // OthPay float64 `json:"oth_pay"`
  3629. // Gend string `json:"gend"`
  3630. // MdtrtID string `json:"mdtrt_id"`
  3631. // AcctPay float64 `json:"acct_pay"`
  3632. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3633. // Insutype string `json:"insutype"`
  3634. // Invono interface{} `json:"invono"`
  3635. // Enddate string `json:"enddate"`
  3636. // CashPayamt float64 `json:"cash_payamt"`
  3637. // PsnType string `json:"psn_type"`
  3638. // FixmedinsName string `json:"fixmedins_name"`
  3639. // HifpPay float64 `json:"hifp_pay"`
  3640. // NewFlag interface{} `json:"new_flag"`
  3641. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3642. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3643. // PayLoc string `json:"pay_loc"`
  3644. // ClrType string `json:"clr_type"`
  3645. // RefdSetlFlag string `json:"refd_setl_flag"`
  3646. // CvlservFlag string `json:"cvlserv_flag"`
  3647. // EmpName string `json:"emp_name"`
  3648. // Brdy string `json:"brdy"`
  3649. // Naty string `json:"naty"`
  3650. // Certno string `json:"certno"`
  3651. // DiseCode string `json:"dise_code"`
  3652. // FixmedinsCode string `json:"fixmedins_code"`
  3653. // DedcHospLv string `json:"dedc_hosp_lv"`
  3654. // OpterName string `json:"opter_name"`
  3655. // Balc float64 `json:"balc"`
  3656. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3657. // PsnCertType string `json:"psn_cert_type"`
  3658. // HifobPay float64 `json:"hifob_pay"`
  3659. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3660. // HifesPay float64 `json:"hifes_pay"`
  3661. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3662. // OptTime string `json:"opt_time"`
  3663. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3664. // SetlID string `json:"setl_id"`
  3665. // MafPay float64 `json:"maf_pay"`
  3666. // PsnName string `json:"psn_name"`
  3667. // InsuOptins interface{} `json:"insu_optins"`
  3668. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3669. // ClrOptins string `json:"clr_optins"`
  3670. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3671. // DiseName string `json:"dise_name"`
  3672. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3673. // Age float64 `json:"age"`
  3674. // DtrtCertType string `json:"dtrt_cert_type"`
  3675. // HospLv string `json:"hosp_lv"`
  3676. // } `json:"setlinfo"`
  3677. // Setldetail []struct {
  3678. // FundPayType string `json:"fund_pay_type"`
  3679. // FundPayamt float64 `json:"fund_payamt"`
  3680. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3681. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3682. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3683. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3684. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3685. // } `json:"setldetail"`
  3686. // } `json:"output"`
  3687. // Infcode int `json:"infcode"`
  3688. // WarnMsg interface{} `json:"warn_msg"`
  3689. // Cainfo interface{} `json:"cainfo"`
  3690. // ErrMsg interface{} `json:"err_msg"`
  3691. // RefmsgTime string `json:"refmsg_time"`
  3692. // Signtype interface{} `json:"signtype"`
  3693. // RespondTime string `json:"respond_time"`
  3694. // InfRefmsgid string `json:"inf_refmsgid"`
  3695. //}
  3696. type ResultEleven struct {
  3697. Cainfo string `json:"cainfo"`
  3698. ErrMsg string `json:"err_msg"`
  3699. InfRefmsgid string `json:"inf_refmsgid"`
  3700. Infcode int64 `json:"infcode"`
  3701. Output struct {
  3702. Setlinfo struct {
  3703. SetlTime string `json:"setl_time"`
  3704. CvlservPay float64 `json:"cvlserv_pay"`
  3705. Year string `json:"year"`
  3706. MedType string `json:"med_type"`
  3707. PsnPay float64 `json:"psn_pay"`
  3708. OpterID string `json:"opter_id"`
  3709. Begndate string `json:"begndate"`
  3710. FlxempeFlag string `json:"flxempe_flag"`
  3711. HifmiPay float64 `json:"hifmi_pay"`
  3712. PsnNo string `json:"psn_no"`
  3713. ActPayDedc float64 `json:"act_pay_dedc"`
  3714. MedinsSetlID interface{} `json:"medins_setl_id"`
  3715. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3716. ClrWay string `json:"clr_way"`
  3717. OthPay float64 `json:"oth_pay"`
  3718. Gend string `json:"gend"`
  3719. MdtrtID string `json:"mdtrt_id"`
  3720. AcctPay float64 `json:"acct_pay"`
  3721. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3722. Insutype string `json:"insutype"`
  3723. Invono interface{} `json:"invono"`
  3724. Enddate string `json:"enddate"`
  3725. CashPayamt float64 `json:"cash_payamt"`
  3726. PsnType string `json:"psn_type"`
  3727. FixmedinsName string `json:"fixmedins_name"`
  3728. HifpPay float64 `json:"hifp_pay"`
  3729. NewFlag interface{} `json:"new_flag"`
  3730. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3731. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3732. PayLoc string `json:"pay_loc"`
  3733. ClrType string `json:"clr_type"`
  3734. RefdSetlFlag string `json:"refd_setl_flag"`
  3735. CvlservFlag string `json:"cvlserv_flag"`
  3736. EmpName string `json:"emp_name"`
  3737. Brdy string `json:"brdy"`
  3738. Naty string `json:"naty"`
  3739. Certno string `json:"certno"`
  3740. DiseCode string `json:"dise_code"`
  3741. FixmedinsCode string `json:"fixmedins_code"`
  3742. DedcHospLv string `json:"dedc_hosp_lv"`
  3743. OpterName string `json:"opter_name"`
  3744. Balc float64 `json:"balc"`
  3745. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3746. PsnCertType string `json:"psn_cert_type"`
  3747. HifobPay float64 `json:"hifob_pay"`
  3748. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3749. HifesPay float64 `json:"hifes_pay"`
  3750. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3751. OptTime string `json:"opt_time"`
  3752. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3753. SetlID string `json:"setl_id"`
  3754. MafPay float64 `json:"maf_pay"`
  3755. PsnName string `json:"psn_name"`
  3756. InsuOptins interface{} `json:"insu_optins"`
  3757. PrefFundPay interface{} `json:"pref_fund_pay"`
  3758. ClrOptins string `json:"clr_optins"`
  3759. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3760. DiseName string `json:"dise_name"`
  3761. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3762. Age float64 `json:"age"`
  3763. DtrtCertType string `json:"dtrt_cert_type"`
  3764. HospLv string `json:"hosp_lv"`
  3765. } `json:"setlinfo"`
  3766. } `json:"output"`
  3767. RefmsgTime string `json:"refmsg_time"`
  3768. RespondTime string `json:"respond_time"`
  3769. Signtype interface{} `json:"signtype"`
  3770. WarnMsg interface{} `json:"warn_msg"`
  3771. }
  3772. type ResultEleven10265 struct {
  3773. Cainfo string `json:"cainfo"`
  3774. ErrMsg string `json:"err_msg"`
  3775. InfRefmsgid string `json:"inf_refmsgid"`
  3776. Infcode string `json:"infcode"`
  3777. Output struct {
  3778. Setlinfo struct {
  3779. SetlTime string `json:"setl_time"`
  3780. CvlservPay float64 `json:"cvlserv_pay"`
  3781. Year string `json:"year"`
  3782. MedType string `json:"med_type"`
  3783. PsnPay float64 `json:"psn_pay"`
  3784. OpterID string `json:"opter_id"`
  3785. Begndate string `json:"begndate"`
  3786. FlxempeFlag string `json:"flxempe_flag"`
  3787. HifmiPay float64 `json:"hifmi_pay"`
  3788. PsnNo string `json:"psn_no"`
  3789. ActPayDedc float64 `json:"act_pay_dedc"`
  3790. MedinsSetlID interface{} `json:"medins_setl_id"`
  3791. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3792. ClrWay string `json:"clr_way"`
  3793. OthPay float64 `json:"oth_pay"`
  3794. Gend string `json:"gend"`
  3795. MdtrtID string `json:"mdtrt_id"`
  3796. AcctPay float64 `json:"acct_pay"`
  3797. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3798. Insutype string `json:"insutype"`
  3799. Invono interface{} `json:"invono"`
  3800. Enddate string `json:"enddate"`
  3801. CashPayamt float64 `json:"cash_payamt"`
  3802. PsnType string `json:"psn_type"`
  3803. FixmedinsName string `json:"fixmedins_name"`
  3804. HifpPay float64 `json:"hifp_pay"`
  3805. NewFlag interface{} `json:"new_flag"`
  3806. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3807. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3808. PayLoc string `json:"pay_loc"`
  3809. ClrType string `json:"clr_type"`
  3810. RefdSetlFlag string `json:"refd_setl_flag"`
  3811. CvlservFlag string `json:"cvlserv_flag"`
  3812. EmpName string `json:"emp_name"`
  3813. Brdy string `json:"brdy"`
  3814. Naty string `json:"naty"`
  3815. Certno string `json:"certno"`
  3816. DiseCode string `json:"dise_code"`
  3817. FixmedinsCode string `json:"fixmedins_code"`
  3818. DedcHospLv string `json:"dedc_hosp_lv"`
  3819. OpterName string `json:"opter_name"`
  3820. Balc float64 `json:"balc"`
  3821. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3822. PsnCertType string `json:"psn_cert_type"`
  3823. HifobPay float64 `json:"hifob_pay"`
  3824. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3825. HifesPay float64 `json:"hifes_pay"`
  3826. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3827. OptTime string `json:"opt_time"`
  3828. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3829. SetlID string `json:"setl_id"`
  3830. MafPay float64 `json:"maf_pay"`
  3831. PsnName string `json:"psn_name"`
  3832. InsuOptins interface{} `json:"insu_optins"`
  3833. PrefFundPay interface{} `json:"pref_fund_pay"`
  3834. ClrOptins string `json:"clr_optins"`
  3835. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3836. DiseName string `json:"dise_name"`
  3837. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3838. Age float64 `json:"age"`
  3839. DtrtCertType string `json:"dtrt_cert_type"`
  3840. HospLv string `json:"hosp_lv"`
  3841. } `json:"setlinfo"`
  3842. } `json:"output"`
  3843. RefmsgTime string `json:"refmsg_time"`
  3844. RespondTime string `json:"respond_time"`
  3845. Signtype interface{} `json:"signtype"`
  3846. WarnMsg interface{} `json:"warn_msg"`
  3847. }
  3848. type ResultTwelve struct {
  3849. Cainfo string `json:"cainfo"`
  3850. ErrMsg string `json:"err_msg"`
  3851. InfRefmsgid string `json:"inf_refmsgid"`
  3852. Infcode int64 `json:"infcode"`
  3853. Output struct {
  3854. MdtrtId string `json:"mdtrt_id"`
  3855. ChrgBchno string `json:"chrg_bchno"`
  3856. PsnNo string `json:"psn_no"`
  3857. } `json:"output"`
  3858. RefmsgTime string `json:"refmsg_time"`
  3859. RespondTime string `json:"respond_time"`
  3860. Signtype interface{} `json:"signtype"`
  3861. WarnMsg interface{} `json:"warn_msg"`
  3862. }
  3863. type ResultThirteen struct {
  3864. ErrMsg string `json:"err_msg"`
  3865. InfRefmsgid string `json:"inf_refmsgid"`
  3866. Infcode int64 `json:"infcode"`
  3867. Output struct {
  3868. Result struct {
  3869. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3870. } `json:"result"`
  3871. } `json:"output"`
  3872. RefmsgTime string `json:"refmsg_time"`
  3873. RespondTime string `json:"respond_time"`
  3874. Signtype interface{} `json:"signtype"`
  3875. WarnInfo interface{} `json:"warn_info"`
  3876. }
  3877. type ResultThirteen10265 struct {
  3878. ErrMsg string `json:"err_msg"`
  3879. InfRefmsgid string `json:"inf_refmsgid"`
  3880. Infcode string `json:"infcode"`
  3881. Output struct {
  3882. Result struct {
  3883. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3884. } `json:"result"`
  3885. } `json:"output"`
  3886. RefmsgTime string `json:"refmsg_time"`
  3887. RespondTime string `json:"respond_time"`
  3888. Signtype interface{} `json:"signtype"`
  3889. WarnInfo interface{} `json:"warn_info"`
  3890. }
  3891. type ResultFourteen struct {
  3892. ErrMsg string `json:"err_msg"`
  3893. InfRefmsgid string `json:"inf_refmsgid"`
  3894. Infcode int64 `json:"infcode"`
  3895. Output struct {
  3896. } `json:"output"`
  3897. RefmsgTime string `json:"refmsg_time"`
  3898. RespondTime string `json:"respond_time"`
  3899. Signtype interface{} `json:"signtype"`
  3900. WarnInfo interface{} `json:"warn_info"`
  3901. }
  3902. type ResultFourteen10265 struct {
  3903. ErrMsg string `json:"err_msg"`
  3904. InfRefmsgid string `json:"inf_refmsgid"`
  3905. Infcode string `json:"infcode"`
  3906. Output struct {
  3907. } `json:"output"`
  3908. RefmsgTime string `json:"refmsg_time"`
  3909. RespondTime string `json:"respond_time"`
  3910. Signtype interface{} `json:"signtype"`
  3911. WarnInfo interface{} `json:"warn_info"`
  3912. }
  3913. type ResultSixteen struct {
  3914. Cainfo string `json:"cainfo"`
  3915. ErrMsg string `json:"err_msg"`
  3916. InfRefmsgid string `json:"inf_refmsgid"`
  3917. Infcode int64 `json:"infcode"`
  3918. Output struct {
  3919. Setldetail []interface{} `json:"setldetail"`
  3920. Setlinfo struct {
  3921. MdtrtID string `json:"mdtrt_id"`
  3922. SetlID string `json:"setl_id"`
  3923. ClrOptins string `json:"clr_optins"`
  3924. SetlTime string `json:"setl_time"`
  3925. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3926. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3927. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3928. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3929. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3930. ActPayDedc float64 `json:"act_pay_dedc"`
  3931. HifpPay float64 `json:"hifp_pay"`
  3932. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3933. Lfpay float64 `json:"selfpay"`
  3934. CvlservPay float64 `json:"cvlserv_pay"`
  3935. HifesPay float64 `json:"hifes_pay"`
  3936. HifmiPay float64 `json:"hifmi_pay"`
  3937. HifobPay float64 `json:"hifob_pay"`
  3938. MafPay float64 `json:"maf_pay"`
  3939. OthPay float64 `json:"oth_pay"`
  3940. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3941. PsnPartAmt float64 `json:"psn_part_amt"`
  3942. AcctPay float64 `json:"acct_pay"`
  3943. Balc float64 `json:"balc"`
  3944. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3945. HospPartAmt float64 `json:"hosp_part_amt"`
  3946. MedinsSetlID string `json:"medins_setl_id"`
  3947. PdnCashPay string `json:"pdn_cash_pay"`
  3948. } `json:"setlinfo"`
  3949. } `json:"output"`
  3950. RefmsgTime string `json:"refmsg_time"`
  3951. RespondTime string `json:"respond_time"`
  3952. Signtype interface{} `json:"signtype"`
  3953. WarnMsg interface{} `json:"warn_msg"`
  3954. }
  3955. type ResultSixteen10265 struct {
  3956. Cainfo string `json:"cainfo"`
  3957. ErrMsg string `json:"err_msg"`
  3958. InfRefmsgid string `json:"inf_refmsgid"`
  3959. Infcode string `json:"infcode"`
  3960. Output struct {
  3961. Setldetail []interface{} `json:"setldetail"`
  3962. Setlinfo struct {
  3963. MdtrtID string `json:"mdtrt_id"`
  3964. SetlID string `json:"setl_id"`
  3965. ClrOptins string `json:"clr_optins"`
  3966. SetlTime string `json:"setl_time"`
  3967. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3968. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3969. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3970. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3971. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3972. ActPayDedc float64 `json:"act_pay_dedc"`
  3973. HifpPay float64 `json:"hifp_pay"`
  3974. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3975. Lfpay float64 `json:"selfpay"`
  3976. CvlservPay float64 `json:"cvlserv_pay"`
  3977. HifesPay float64 `json:"hifes_pay"`
  3978. HifmiPay float64 `json:"hifmi_pay"`
  3979. HifobPay float64 `json:"hifob_pay"`
  3980. MafPay float64 `json:"maf_pay"`
  3981. OthPay float64 `json:"oth_pay"`
  3982. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3983. PsnPartAmt float64 `json:"psn_part_amt"`
  3984. AcctPay float64 `json:"acct_pay"`
  3985. Balc float64 `json:"balc"`
  3986. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3987. HospPartAmt float64 `json:"hosp_part_amt"`
  3988. MedinsSetlID string `json:"medins_setl_id"`
  3989. PdnCashPay string `json:"pdn_cash_pay"`
  3990. } `json:"setlinfo"`
  3991. } `json:"output"`
  3992. RefmsgTime string `json:"refmsg_time"`
  3993. RespondTime string `json:"respond_time"`
  3994. Signtype interface{} `json:"signtype"`
  3995. WarnMsg interface{} `json:"warn_msg"`
  3996. }
  3997. type ResultSeventeen struct {
  3998. ErrMsg string `json:"err_msg"`
  3999. InfRefmsgid string `json:"inf_refmsgid"`
  4000. Infcode int64 `json:"infcode"`
  4001. Output struct {
  4002. SetlListId string `json:"setl_list_id"`
  4003. } `json:"output"`
  4004. RefmsgTime string `json:"refmsg_time"`
  4005. RespondTime string `json:"respond_time"`
  4006. Signtype string `json:"signtype"`
  4007. WarnInfo string `json:"warn_info"`
  4008. }
  4009. type Result90991 struct {
  4010. ErrMsg string `json:"err_msg"`
  4011. InfRefmsgid string `json:"inf_refmsgid"`
  4012. Infcode int64 `json:"infcode"`
  4013. Output struct {
  4014. Result struct {
  4015. PsnNo string `json:"psn_no"`
  4016. CardStat string `json:"card_stat"`
  4017. Certno string `json:"certno"`
  4018. PsnName string `json:"psn_name"`
  4019. CheckStat string `json:"check_stat"`
  4020. SscnoCheckStat string `json:"sscno_check_stat"`
  4021. } `json:"result"`
  4022. } `json:"output"`
  4023. RefmsgTime string `json:"refmsg_time"`
  4024. RespondTime string `json:"respond_time"`
  4025. Signtype interface{} `json:"signtype"`
  4026. WarnInfo interface{} `json:"warn_info"`
  4027. }
  4028. type Result90100 struct {
  4029. ErrMsg string `json:"err_msg"`
  4030. InfRefmsgid string `json:"inf_refmsgid"`
  4031. Infcode int64 `json:"infcode"`
  4032. Output struct {
  4033. PoolareaNo string `json:"poolarea_no"`
  4034. PoolareaNoName string `json:"poolarea_no_name"`
  4035. Insutype string `json:"insutype"`
  4036. InsutypeName string `json:"insutype_name"`
  4037. ClctType string `json:"clct_type"`
  4038. ClctTypeName string `json:"clct_type_name"`
  4039. ClctFlag string `json:"clct_flag"`
  4040. ClctFlagName string `json:"clct_flag_name"`
  4041. AccrymBegn string `json:"accrym_begn"`
  4042. AccrymEnd string `json:"accrym_end"`
  4043. ClctTime string `json:"clct_time"`
  4044. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4045. } `json:"output"`
  4046. RefmsgTime string `json:"refmsg_time"`
  4047. RespondTime string `json:"respond_time"`
  4048. Signtype interface{} `json:"signtype"`
  4049. WarnInfo interface{} `json:"warn_info"`
  4050. }
  4051. type Custom struct {
  4052. DetItemFeeSumamt string
  4053. Cut string
  4054. FeedetlSn string
  4055. Price string
  4056. MedListCodg string
  4057. Type int64
  4058. AdviceId int64
  4059. ProjectId int64
  4060. ItemId int64
  4061. }
  4062. type Result5301 struct {
  4063. ErrMsg string `json:"err_msg"`
  4064. InfRefmsgid string `json:"inf_refmsgid"`
  4065. Infcode int64 `json:"infcode"`
  4066. Output struct {
  4067. Result []struct {
  4068. OpspDiseCode string `json:"opsp_dise_code"`
  4069. OpspDiseName string `json:"opsp_dise_name"`
  4070. Begndate string `json:"begndate"`
  4071. Enddate string `json:"enddate"`
  4072. } `json:"feedetail"`
  4073. } `json:"output"`
  4074. RefmsgTime string `json:"refmsg_time"`
  4075. RespondTime string `json:"respond_time"`
  4076. Signtype interface{} `json:"signtype"`
  4077. WarnInfo interface{} `json:"warn_info"`
  4078. }
  4079. type Result5301For10265 struct {
  4080. ErrMsg string `json:"err_msg"`
  4081. InfRefmsgid string `json:"inf_refmsgid"`
  4082. Infcode string `json:"infcode"`
  4083. Output struct {
  4084. Result []struct {
  4085. OpspDiseCode string `json:"opsp_dise_code"`
  4086. OpspDiseName string `json:"opsp_dise_name"`
  4087. Begndate string `json:"begndate"`
  4088. Enddate string `json:"enddate"`
  4089. } `json:"feedetail"`
  4090. } `json:"output"`
  4091. RefmsgTime string `json:"refmsg_time"`
  4092. RespondTime string `json:"respond_time"`
  4093. Signtype interface{} `json:"signtype"`
  4094. WarnInfo interface{} `json:"warn_info"`
  4095. }
  4096. //获取个人信息----挂号-----上传就诊信息
  4097. func (c *HisApiController) GetRegisterInfo() {
  4098. id, _ := c.GetInt64("id")
  4099. record_time := c.GetString("record_time")
  4100. settlementValue, _ := c.GetInt64("settlement_value")
  4101. medical_insurance_card := c.GetString("medical_insurance_card")
  4102. name := c.GetString("name")
  4103. id_card_type, _ := c.GetInt64("id_card_type")
  4104. certificates, _ := c.GetInt64("certificates")
  4105. medical_care, _ := c.GetInt64("medical_care")
  4106. birthday := c.GetString("birthday")
  4107. id_card := c.GetString("id_card")
  4108. register_type, _ := c.GetInt64("register")
  4109. doctor, _ := c.GetInt64("doctor")
  4110. department, _ := c.GetInt64("department")
  4111. gender, _ := c.GetInt64("sex")
  4112. registration_fee, _ := c.GetFloat("registration_fee")
  4113. medical_expenses, _ := c.GetFloat("medical_expenses")
  4114. social_type, _ := c.GetInt64("social_type")
  4115. med_type := c.GetString("social_type")
  4116. admin_user_id, _ := c.GetInt64("admin_user_id")
  4117. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4118. timeLayout := "2006-01-02"
  4119. loc, _ := time.LoadLocation("Local")
  4120. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4121. birthUnix := birthdays.Unix()
  4122. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4123. if err != nil {
  4124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4125. return
  4126. }
  4127. recordDateTime := theTime.Unix()
  4128. adminInfo := c.GetAdminUserInfo()
  4129. var patient service.Patients
  4130. if id == 0 {
  4131. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4132. } else {
  4133. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4134. }
  4135. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4136. if patientPrescription.ID == 0 {
  4137. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4138. }
  4139. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4140. if patient.ID == 0 {
  4141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4142. return
  4143. }
  4144. if len(patient.IdCardNo) == 0 {
  4145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4146. return
  4147. }
  4148. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4149. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4150. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4151. //就诊结算未完成,不能进行二次挂号
  4152. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4153. if len(his) >= 1 {
  4154. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4155. if len(his) >= 1 && order.ID == 0 {
  4156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4157. return
  4158. }
  4159. }
  4160. //var register_log string
  4161. if config.IsOpen == 1 {
  4162. var res ResultTwo
  4163. var res10265 ResultTwo10265
  4164. var PsnNo string
  4165. var PsnCertType string
  4166. var Certno string
  4167. var PsnName string
  4168. var Gend string
  4169. var Naty string
  4170. var Brdy string
  4171. var Age float64
  4172. var infoStr string
  4173. var idetinfoStr string
  4174. var infocode int64
  4175. var verify_number string
  4176. fmt.Println(verify_number)
  4177. if miConfig.MdtrtareaAdmvs == "421300" {
  4178. psn_info, _ := service.GetPsnByPatientId(id)
  4179. PsnNo = psn_info.PsnNo
  4180. PsnCertType = psn_info.PsnCertType
  4181. Certno = psn_info.Certno
  4182. PsnName = psn_info.PsnName
  4183. Gend = psn_info.Gend
  4184. Naty = psn_info.Naty
  4185. Brdy = psn_info.Brdy
  4186. Age = psn_info.Age
  4187. infoStr = psn_info.Insuinfo
  4188. idetinfoStr = psn_info.Idetinfo
  4189. infocode = 0
  4190. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4191. psn_info, _ := service.GetPsnByPatientId(id)
  4192. PsnNo = psn_info.PsnNo
  4193. PsnCertType = psn_info.PsnCertType
  4194. Certno = psn_info.Certno
  4195. PsnName = psn_info.PsnName
  4196. Gend = psn_info.Gend
  4197. Naty = psn_info.Naty
  4198. Brdy = psn_info.Brdy
  4199. Age = psn_info.Age
  4200. infoStr = psn_info.Insuinfo
  4201. idetinfoStr = psn_info.Idetinfo
  4202. infocode = 0
  4203. verify_number = psn_info.VerifyNumber
  4204. } else {
  4205. var result string
  4206. var requestLog string
  4207. if miConfig.UserOrgId == 10138 {
  4208. 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)
  4209. } else {
  4210. 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)
  4211. }
  4212. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4213. if miConfig.Code == "H15049901371" {
  4214. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4215. utils.ErrorLog("解析失败:%v", err)
  4216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4217. return
  4218. }
  4219. res.ErrMsg = res10265.ErrMsg
  4220. res.Output = res10265.Output
  4221. res.InfRefmsgid = res10265.InfRefmsgid
  4222. } else {
  4223. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4224. utils.ErrorLog("解析失败:%v", err)
  4225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4226. return
  4227. }
  4228. }
  4229. PsnNo = res.Output.Baseinfo.PsnNo
  4230. PsnCertType = res.Output.Baseinfo.PsnCertType
  4231. Certno = res.Output.Baseinfo.Certno
  4232. PsnName = res.Output.Baseinfo.PsnName
  4233. Gend = res.Output.Baseinfo.Gend
  4234. Naty = res.Output.Baseinfo.Naty
  4235. Brdy = res.Output.Baseinfo.Brdy
  4236. Age = res.Output.Baseinfo.Age
  4237. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4238. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4239. infoStr = string(Iinfos)
  4240. idetinfoStr = string(Idetinfos)
  4241. if miConfig.Code == "H15049901371" {
  4242. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4243. } else {
  4244. infocode = res.Infcode
  4245. }
  4246. }
  4247. if infocode == 0 {
  4248. his := models.VMHisPatient{
  4249. Name: name,
  4250. Gender: gender,
  4251. Birthday: birthUnix,
  4252. MedicalTreatmentType: medical_care,
  4253. IdType: certificates,
  4254. IdCardNo: id_card,
  4255. BalanceAccountsType: settlementValue,
  4256. SocialType: social_type,
  4257. MedicalInsuranceNumber: medical_insurance_card,
  4258. RegisterType: register_type,
  4259. RegisterCost: registration_fee,
  4260. TreatmentCost: medical_expenses,
  4261. Status: 1,
  4262. Ctime: time.Now().Unix(),
  4263. Mtime: time.Now().Unix(),
  4264. PsnNo: PsnNo,
  4265. PsnCertType: PsnCertType,
  4266. Certno: Certno,
  4267. PsnName: PsnName,
  4268. Gend: Gend,
  4269. Naty: Naty,
  4270. Brdy: Brdy,
  4271. Age: Age,
  4272. Iinfo: infoStr,
  4273. Idetinfo: idetinfoStr,
  4274. PatientId: patient.ID,
  4275. RecordDate: theTime.Unix(),
  4276. UserOrgId: adminInfo.CurrentOrgId,
  4277. AdminUserId: admin_user_id,
  4278. IsReturn: 1,
  4279. IdCardType: id_card_type,
  4280. Doctor: doctor,
  4281. Departments: department,
  4282. }
  4283. timestamp := time.Now().Unix()
  4284. tempTime := time.Unix(timestamp, 0)
  4285. timeFormat := tempTime.Format("20060102150405")
  4286. chrgBchno := rand.Intn(100000) + 10000
  4287. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4288. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4289. department, _ := service.GetDepartMentDetail(department)
  4290. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4291. IdCardNo := ""
  4292. if id_card_type == 1 {
  4293. // IdCardNo = medical_insurance_card
  4294. IdCardNo = patient.IdCardNo
  4295. } else {
  4296. IdCardNo = patient.IdCardNo
  4297. }
  4298. var rf []*ResultFive
  4299. json.Unmarshal([]byte(his.Iinfo), &rf)
  4300. var insutypes []*ResultFive
  4301. var insutype string
  4302. var insuplc_admdvs_temp string
  4303. var is390 int = 0
  4304. var is310 int = 0
  4305. for _, item := range rf {
  4306. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4307. insutypes = append(insutypes, item)
  4308. }
  4309. }
  4310. if len(insutypes) == 1 {
  4311. insutype = insutypes[0].Insutype
  4312. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4313. } else {
  4314. for _, i := range insutypes {
  4315. if i.Insutype == "390" {
  4316. is390 = 1
  4317. }
  4318. if i.Insutype == "310" {
  4319. is310 = 1
  4320. }
  4321. }
  4322. }
  4323. if is390 == 1 {
  4324. insutype = "390"
  4325. }
  4326. if is310 == 1 {
  4327. insutype = "310"
  4328. }
  4329. if len(insutypes) == 0 {
  4330. insutype = "310"
  4331. }
  4332. if len(insutypes) == 2 {
  4333. insutype = med_type
  4334. }
  4335. if len(med_type) > 0 {
  4336. insutype = med_type
  4337. }
  4338. //for _, item := range rf {
  4339. // if item.Insutype == insutype {
  4340. // insuplc_admdvs = item.InsuplcAdmdvs
  4341. // }
  4342. //}
  4343. var infocode int64
  4344. var resThree ResultThree
  4345. var resThree10265 ResultThree10265
  4346. if len(insuplc_admdvs) == 0 {
  4347. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4348. } else {
  4349. insuplc_admdvs_temp = insuplc_admdvs
  4350. }
  4351. if miConfig.MdtrtareaAdmvs == "421300" {
  4352. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4353. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4354. "&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
  4355. resp, requestErr := http.Get(api)
  4356. if requestErr != nil {
  4357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4358. return
  4359. }
  4360. body, ioErr := ioutil.ReadAll(resp.Body)
  4361. if ioErr != nil {
  4362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4364. return
  4365. }
  4366. var respJSON map[string]interface{}
  4367. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4370. return
  4371. }
  4372. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4373. result, _ := json.Marshal(respJSON)
  4374. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4375. utils.ErrorLog("解析失败:%v", err)
  4376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4377. return
  4378. }
  4379. infocode = resThree.Infcode
  4380. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4381. psn_info, _ := service.GetPsnByPatientId(id)
  4382. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4383. var cert_no string
  4384. if id_card_type == 3 {
  4385. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4386. cert_no = IdCardNo
  4387. } else {
  4388. bas := strings.Split(psn_info.CardInfo, "|")
  4389. cert_no = bas[2]
  4390. }
  4391. var api string
  4392. if miConfig.MdtrtareaAdmvs == "320921" {
  4393. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4394. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4395. "&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
  4396. } else {
  4397. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4398. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4399. "&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
  4400. }
  4401. resp, requestErr := http.Get(api)
  4402. if requestErr != nil {
  4403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4404. return
  4405. }
  4406. body, ioErr := ioutil.ReadAll(resp.Body)
  4407. if ioErr != nil {
  4408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4410. return
  4411. }
  4412. var respJSON map[string]interface{}
  4413. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4416. return
  4417. }
  4418. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4419. result, _ := json.Marshal(respJSON)
  4420. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4421. utils.ErrorLog("解析失败:%v", err)
  4422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4423. return
  4424. }
  4425. resThree.ErrMsg = resThree10265.ErrMsg
  4426. resThree.Output = resThree10265.Output
  4427. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4428. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4429. } else {
  4430. 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)
  4431. saveLog(result, requestLog, "2201A", "挂号")
  4432. if miConfig.Code == "H15049901371" {
  4433. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4434. utils.ErrorLog("解析失败:%v", err)
  4435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4436. return
  4437. }
  4438. resThree.ErrMsg = resThree10265.ErrMsg
  4439. resThree.Output = resThree10265.Output
  4440. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4441. } else {
  4442. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4443. utils.ErrorLog("解析失败:%v", err)
  4444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4445. return
  4446. }
  4447. }
  4448. if miConfig.Code == "H15049901371" {
  4449. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4450. } else {
  4451. infocode = resThree.Infcode
  4452. }
  4453. }
  4454. if infocode != 0 {
  4455. adminUser := c.GetAdminUserInfo()
  4456. errlog := &models.HisOrderError{
  4457. UserOrgId: adminUser.CurrentOrgId,
  4458. Ctime: time.Now().Unix(),
  4459. Mtime: time.Now().Unix(),
  4460. ErrMsg: resThree.ErrMsg,
  4461. Status: 1,
  4462. PatientId: id,
  4463. RecordTime: recordDateTime,
  4464. Stage: 2,
  4465. }
  4466. service.CreateErrMsgLog(errlog)
  4467. c.ServeSuccessJSON(map[string]interface{}{
  4468. "failed_code": -10,
  4469. "msg": resThree.ErrMsg,
  4470. })
  4471. return
  4472. }
  4473. his.Number = resThree.Output.Data.MdtrtID
  4474. his.PsnNo = resThree.Output.Data.PsnNo
  4475. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4476. his.IdCardNo = patient.IdCardNo
  4477. his.PhoneNumber = patient.Phone
  4478. his.UserOrgId = adminInfo.CurrentOrgId
  4479. his.Insutype = insutype
  4480. his.Ctime = time.Now().Unix()
  4481. his.Mtime = time.Now().Unix()
  4482. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4483. his.Status = 1
  4484. service.UpdateHisPatientStatus(&his)
  4485. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4486. c.ServeSuccessJSON(map[string]interface{}{
  4487. "his_info": his,
  4488. })
  4489. } else {
  4490. adminUser := c.GetAdminUserInfo()
  4491. errlog := &models.HisOrderError{
  4492. UserOrgId: adminUser.CurrentOrgId,
  4493. Ctime: time.Now().Unix(),
  4494. Mtime: time.Now().Unix(),
  4495. ErrMsg: res.ErrMsg,
  4496. Status: 1,
  4497. PatientId: id,
  4498. RecordTime: recordDateTime,
  4499. Stage: 1,
  4500. }
  4501. service.CreateErrMsgLog(errlog)
  4502. c.ServeSuccessJSON(map[string]interface{}{
  4503. "failed_code": -10,
  4504. "msg": res.ErrMsg,
  4505. })
  4506. return
  4507. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4508. }
  4509. }
  4510. }
  4511. //上传明细----预结算----确认订单
  4512. func (c *HisApiController) GetUploadInfo() {
  4513. id, _ := c.GetInt64("id")
  4514. record_time := c.GetString("record_time")
  4515. his_patient_id, _ := c.GetInt64("his_patient_id")
  4516. order_id, _ := c.GetInt64("order_id")
  4517. pay_way, _ := c.GetInt64("pay_way")
  4518. pay_price, _ := c.GetFloat("pay_price")
  4519. pay_card_no := c.GetString("pay_card_no")
  4520. discount_price, _ := c.GetFloat("discount_price")
  4521. preferential_price, _ := c.GetFloat("preferential_price")
  4522. reality_price, _ := c.GetFloat("reality_price")
  4523. found_price, _ := c.GetFloat("found_price")
  4524. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4525. private_price, _ := c.GetFloat("private_price")
  4526. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4527. admin_user_id, _ := c.GetInt64("admin_user_id")
  4528. fapiao_code := c.GetString("fapiao_code")
  4529. fapiao_number := c.GetString("fapiao_number")
  4530. diagnosis_id := c.GetString("diagnosis")
  4531. sick_type, _ := c.GetInt64("sick_type")
  4532. reg_type, _ := c.GetInt64("p_type")
  4533. begin_time := c.GetString("begin_time")
  4534. id_str := c.GetString("ids")
  4535. ids_arr := strings.Split(id_str, ",")
  4536. timeLayout := "2006-01-02"
  4537. loc, _ := time.LoadLocation("Local")
  4538. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4539. if err != nil {
  4540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4541. return
  4542. }
  4543. recordDateTime := theTime.Unix()
  4544. adminUser := c.GetAdminUserInfo()
  4545. var tempOrder models.HisOrder
  4546. tempOrder, _ = service.GetHisOrderByID(order_id)
  4547. var prescriptions []*models.HisPrescription
  4548. var start_time int64
  4549. var end_time int64
  4550. //if adminUser.CurrentOrgId == 10106{
  4551. // if len(fapiao_code) == 0{
  4552. // fapiao_code = "144072080589"
  4553. // }
  4554. // if len(fapiao_number) == 0{
  4555. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4556. // if order.ID == 0{
  4557. // fapiao_number = "00001520"
  4558. // }else{
  4559. // //fapiao_code = "00001520"
  4560. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4561. // var zero string
  4562. // if fpNumber >= 1000{
  4563. // zero = "0000" + strconv.Itoa(fpNumber)
  4564. // }else if fpNumber >= 10000{
  4565. // zero = "000" + strconv.Itoa(fpNumber)
  4566. // } else if fpNumber >= 100000{
  4567. // zero = "00" + strconv.Itoa(fpNumber)
  4568. // } else if fpNumber >= 1000000{
  4569. // zero = "0" + strconv.Itoa(fpNumber)
  4570. // }else {
  4571. // zero = strconv.Itoa(fpNumber)
  4572. // }
  4573. // fapiao_number = zero
  4574. // }
  4575. // }
  4576. //}
  4577. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4578. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4579. var patientPrescription models.HisPrescriptionInfo
  4580. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4581. if patientPrescription.ID == 0 {
  4582. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4583. }
  4584. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4585. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4586. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4587. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4588. var config []*models.HisXtDiagnoseConfig
  4589. for _, item := range diagnosis_ids {
  4590. id, _ := strconv.ParseInt(item, 10, 64)
  4591. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4592. config = append(config, &diagnosisConfig)
  4593. }
  4594. sickConfig, _ := service.FindSickById(sick_type)
  4595. //if tempOrder.ID == 0 {
  4596. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4597. //}
  4598. if tempOrder.ID == 0 {
  4599. var result string
  4600. var requestLog string
  4601. var res2 ResultSix
  4602. var ressix10265 ResultSix10265
  4603. if miConfig.MdtrtareaAdmvs == "421300" {
  4604. data := make(map[string]interface{})
  4605. client := &http.Client{}
  4606. data["psn_no"] = his.PsnNo
  4607. data["mdtrt_id"] = his.Number
  4608. data["doctor"] = roles.UserName
  4609. data["department"] = department.Name
  4610. data["org_name"] = miConfig.OrgName
  4611. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4612. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4613. data["fixmedins_code"] = miConfig.Code
  4614. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4615. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4616. data["secret_key"] = miConfig.SecretKey
  4617. data["sick_code"] = sickConfig.CountryCode
  4618. data["sick_name"] = sickConfig.ClassName
  4619. data["dept"] = strconv.FormatInt(department.ID, 10)
  4620. data["config"] = config
  4621. data["begin_time"] = begin_time
  4622. bytesData, _ := json.Marshal(data)
  4623. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4624. resp, _ := client.Do(req)
  4625. defer resp.Body.Close()
  4626. body, ioErr := ioutil.ReadAll(resp.Body)
  4627. if ioErr != nil {
  4628. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4630. return
  4631. }
  4632. var respJSON map[string]interface{}
  4633. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4636. return
  4637. }
  4638. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4639. userJSONBytes, _ := json.Marshal(respJSON)
  4640. fmt.Println("log")
  4641. fmt.Println(string(userJSONBytes))
  4642. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4643. utils.ErrorLog("解析失败:%v", err)
  4644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4645. return
  4646. }
  4647. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4648. //江苏地区国家医保医疗类别
  4649. //职工透析:医疗类别选特殊情况门诊9933
  4650. //居民血透门慢: 医疗类别选门诊慢病1402
  4651. //var med_type string
  4652. //if his.Insutype == "310" {
  4653. // if reg_type == 14 {
  4654. // med_type = "9933"
  4655. // } else if reg_type == 11 {
  4656. // med_type = "11"
  4657. //
  4658. // }
  4659. //} else if his.Insutype == "390" {
  4660. // if reg_type == 14 {
  4661. // med_type = "1402"
  4662. // } else if reg_type == 11 {
  4663. // med_type = "11"
  4664. // }
  4665. //}
  4666. data := make(map[string]interface{})
  4667. client := &http.Client{}
  4668. data["psn_no"] = his.PsnNo
  4669. data["mdtrt_id"] = his.Number
  4670. data["doctor"] = roles.UserName
  4671. data["department"] = department.Name
  4672. data["org_name"] = miConfig.OrgName
  4673. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4674. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4675. data["fixmedins_code"] = miConfig.Code
  4676. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4677. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4678. data["secret_key"] = miConfig.SecretKey
  4679. data["sick_code"] = sickConfig.CountryCode
  4680. data["sick_name"] = sickConfig.ClassName
  4681. data["url"] = miConfig.Url
  4682. data["ak"] = miConfig.AccessKey
  4683. data["begin_time"] = begin_time
  4684. data["cainfo"] = miConfig.Cainfo
  4685. data["dept"] = strconv.FormatInt(department.ID, 10)
  4686. data["config"] = config
  4687. bytesData, _ := json.Marshal(data)
  4688. var req *http.Request
  4689. if miConfig.MdtrtareaAdmvs == "320921" {
  4690. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4691. //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 +
  4692. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4693. } else {
  4694. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4695. }
  4696. resp, _ := client.Do(req)
  4697. defer resp.Body.Close()
  4698. body, ioErr := ioutil.ReadAll(resp.Body)
  4699. if ioErr != nil {
  4700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4702. return
  4703. }
  4704. var respJSON map[string]interface{}
  4705. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4708. return
  4709. }
  4710. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4711. userJSONBytes, _ := json.Marshal(respJSON)
  4712. fmt.Println("log")
  4713. fmt.Println(string(userJSONBytes))
  4714. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4715. utils.ErrorLog("解析失败:%v", err)
  4716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4717. return
  4718. }
  4719. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4720. res2.Output = ressix10265.Output
  4721. res2.ErrMsg = ressix10265.ErrMsg
  4722. res2.Cainfo = ressix10265.Cainfo
  4723. res2.WarnMsg = ressix10265.WarnMsg
  4724. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4725. res2.Infcode = infocode
  4726. } else {
  4727. if miConfig.MdtrtareaAdmvs == "440781" { //
  4728. 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)
  4729. } else {
  4730. if miConfig.Code == "H15049901371" {
  4731. //赤峰地区国家医保医疗类别
  4732. //职工透析:医疗类别选特殊情况门诊990502
  4733. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4734. var med_type string
  4735. if his.Insutype == "390" {
  4736. if reg_type == 14 {
  4737. med_type = "9933"
  4738. } else if reg_type == 11 {
  4739. med_type = "11"
  4740. }
  4741. } else if his.Insutype == "310" {
  4742. if reg_type == 14 {
  4743. med_type = "990502"
  4744. } else if reg_type == 11 {
  4745. med_type = "11"
  4746. }
  4747. }
  4748. 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)
  4749. } else {
  4750. 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)
  4751. }
  4752. }
  4753. saveLog(result, requestLog, "2203", "上传就诊信息")
  4754. var respJSON2 map[string]interface{}
  4755. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4758. return
  4759. }
  4760. userJSONBytes2, _ := json.Marshal(respJSON2)
  4761. if miConfig.Code == "H15049901371" {
  4762. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4763. utils.ErrorLog("解析失败:%v", err)
  4764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4765. return
  4766. }
  4767. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4768. res2.Output = ressix10265.Output
  4769. res2.ErrMsg = ressix10265.ErrMsg
  4770. res2.Cainfo = ressix10265.Cainfo
  4771. res2.WarnMsg = ressix10265.WarnMsg
  4772. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4773. res2.Infcode = infocode
  4774. } else {
  4775. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4776. utils.ErrorLog("解析失败:%v", err)
  4777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4778. return
  4779. }
  4780. }
  4781. }
  4782. if res2.Infcode != 0 {
  4783. adminUser := c.GetAdminUserInfo()
  4784. errlog := &models.HisOrderError{
  4785. UserOrgId: adminUser.CurrentOrgId,
  4786. Ctime: time.Now().Unix(),
  4787. Mtime: time.Now().Unix(),
  4788. ErrMsg: res2.ErrMsg,
  4789. Status: 1,
  4790. PatientId: id,
  4791. RecordTime: recordDateTime,
  4792. Stage: 3,
  4793. }
  4794. service.CreateErrMsgLog(errlog)
  4795. c.ServeSuccessJSON(map[string]interface{}{
  4796. "failed_code": -10,
  4797. "msg": res2.ErrMsg,
  4798. })
  4799. return
  4800. } else {
  4801. his.Diagnosis = diagnosis_id
  4802. his.SickType = sickConfig.ID
  4803. //var p_type int64
  4804. //if reg_type == 1111 || reg_type == 1112 {
  4805. // p_type = 11
  4806. //
  4807. //}
  4808. his.PType = fmt.Sprintf("%d", reg_type)
  4809. service.UpdateHisPatientThree(&his)
  4810. data := make(map[string]interface{})
  4811. if settle_accounts_type == 1 { //日结
  4812. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4813. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4814. } else {
  4815. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4816. }
  4817. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4818. data["pre"] = prescriptions
  4819. } else { //月结
  4820. start_time_str := c.GetString("start_time")
  4821. end_time_str := c.GetString("end_time")
  4822. timeLayout := "2006-01-02"
  4823. loc, _ := time.LoadLocation("Local")
  4824. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4825. if err != nil {
  4826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4827. return
  4828. }
  4829. recordStartTime := theStartTime.Unix()
  4830. start_time = recordStartTime
  4831. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4832. if err != nil {
  4833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4834. return
  4835. }
  4836. recordEndTime := theEndTime.Unix()
  4837. end_time = recordEndTime
  4838. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4839. data["pre"] = prescriptions
  4840. }
  4841. timestamp := time.Now().Unix()
  4842. tempTime := time.Unix(timestamp, 0)
  4843. timeFormat := tempTime.Format("20060102150405")
  4844. chrgBchno := rand.Intn(100000) + 10000
  4845. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4846. strconv.FormatInt(his.PatientId, 10)
  4847. client := &http.Client{}
  4848. data["psn_no"] = his.PsnNo
  4849. data["mdtrt_id"] = his.Number
  4850. data["chrg_bchno"] = chrg_bchno
  4851. data["org_name"] = miConfig.OrgName
  4852. data["doctor"] = roles.UserName
  4853. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4854. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4855. data["fixmedins_code"] = miConfig.Code
  4856. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4857. // data["dept_code"] = "15"
  4858. //} else {
  4859. data["dept_code"] = department.Number
  4860. //}
  4861. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4862. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4863. data["secret_key"] = miConfig.SecretKey
  4864. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4865. data["url"] = miConfig.Url
  4866. data["ak"] = miConfig.AccessKey
  4867. data["new_doctor_name"] = patientPrescription.Doctor
  4868. data["diag_code"] = sickConfig.CountryCode
  4869. data["cainfo"] = miConfig.Cainfo
  4870. var ids []int64
  4871. for _, item := range prescriptions {
  4872. ids = append(ids, item.ID)
  4873. }
  4874. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4875. if config.IsOpen == 1 { //对接了医保,走医保流程
  4876. var res ResultFour
  4877. var resFour10265 ResultFour10265
  4878. if miConfig.MdtrtareaAdmvs == "421300" {
  4879. bytesData, _ := json.Marshal(data)
  4880. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4881. resp, _ := client.Do(req)
  4882. defer resp.Body.Close()
  4883. body, ioErr := ioutil.ReadAll(resp.Body)
  4884. if ioErr != nil {
  4885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4887. return
  4888. }
  4889. var respJSON map[string]interface{}
  4890. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4893. return
  4894. }
  4895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4896. userJSONBytes, _ := json.Marshal(respJSON)
  4897. fmt.Println("log")
  4898. fmt.Println(string(userJSONBytes))
  4899. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4900. utils.ErrorLog("解析失败:%v", err)
  4901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4902. return
  4903. }
  4904. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4905. bytesData, _ := json.Marshal(data)
  4906. var req *http.Request
  4907. if miConfig.MdtrtareaAdmvs == "320921" {
  4908. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4909. } else {
  4910. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4911. }
  4912. resp, _ := client.Do(req)
  4913. defer resp.Body.Close()
  4914. body, ioErr := ioutil.ReadAll(resp.Body)
  4915. if ioErr != nil {
  4916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4918. return
  4919. }
  4920. var respJSON map[string]interface{}
  4921. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4924. return
  4925. }
  4926. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4927. userJSONBytes, _ := json.Marshal(respJSON)
  4928. fmt.Println("log")
  4929. fmt.Println(string(userJSONBytes))
  4930. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4931. utils.ErrorLog("解析失败:%v", err)
  4932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4933. return
  4934. }
  4935. res.InfRefmsgid = resFour10265.InfRefmsgid
  4936. res.Output = resFour10265.Output
  4937. res.ErrMsg = resFour10265.ErrMsg
  4938. res.Cainfo = resFour10265.Cainfo
  4939. res.WarnMsg = resFour10265.WarnMsg
  4940. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4941. res.Infcode = infocode
  4942. } else {
  4943. if miConfig.Code == "H15049901371" {
  4944. 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)
  4945. var dat map[string]interface{}
  4946. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4947. fmt.Println(dat)
  4948. } else {
  4949. fmt.Println(err)
  4950. }
  4951. saveLog(result, request_log, "2204", "上传费用明细")
  4952. userJSONBytes, _ := json.Marshal(dat)
  4953. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4954. utils.ErrorLog("解析失败:%v", err)
  4955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4956. return
  4957. }
  4958. res.InfRefmsgid = resFour10265.InfRefmsgid
  4959. res.Output = resFour10265.Output
  4960. res.ErrMsg = resFour10265.ErrMsg
  4961. res.Cainfo = resFour10265.Cainfo
  4962. res.WarnMsg = resFour10265.WarnMsg
  4963. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4964. res.Infcode = infocode
  4965. } else {
  4966. 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)
  4967. var dat map[string]interface{}
  4968. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4969. fmt.Println(dat)
  4970. } else {
  4971. fmt.Println(err)
  4972. }
  4973. saveLog(result, request_log, "2204", "上传费用明细")
  4974. userJSONBytes, _ := json.Marshal(dat)
  4975. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4976. utils.ErrorLog("解析失败:%v", err)
  4977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4978. return
  4979. }
  4980. }
  4981. }
  4982. if res.Infcode == 0 {
  4983. order := &models.HisOrder{
  4984. UserOrgId: adminUser.CurrentOrgId,
  4985. HisPatientId: his.ID,
  4986. PatientId: his.PatientId,
  4987. SettleAccountsDate: recordDateTime,
  4988. MdtrtId: his.Number,
  4989. PsnNo: his.PsnNo,
  4990. MedType: strconv.FormatInt(reg_type, 10),
  4991. Ctime: time.Now().Unix(),
  4992. Mtime: time.Now().Unix(),
  4993. Status: 1,
  4994. Number: chrg_bchno,
  4995. Infcode: res.Infcode,
  4996. WarnMsg: res.WarnMsg,
  4997. Cainfo: res.Cainfo,
  4998. ErrMsg: res.ErrMsg,
  4999. RespondTime: res.RefmsgTime,
  5000. InfRefmsgid: res.InfRefmsgid,
  5001. OrderStatus: 1,
  5002. PayWay: pay_way,
  5003. PayPrice: pay_price,
  5004. PayCardNo: pay_card_no,
  5005. DiscountPrice: discount_price,
  5006. PreferentialPrice: preferential_price,
  5007. RealityPrice: reality_price,
  5008. FoundPrice: found_price,
  5009. MedicalInsurancePrice: medical_insurance_price,
  5010. PrivatePrice: private_price,
  5011. IsMedicineInsurance: 1,
  5012. SettleType: settle_accounts_type,
  5013. SettleStartTime: start_time,
  5014. SettleEndTime: end_time,
  5015. Creator: roles.AdminUserId,
  5016. Modify: roles.AdminUserId,
  5017. FaPiaoNumber: fapiao_number,
  5018. FaPiaoCode: fapiao_code,
  5019. PType: 2,
  5020. Diagnosis: diagnosis_id,
  5021. }
  5022. err = service.CreateOrder(order)
  5023. if err != nil {
  5024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5025. return
  5026. }
  5027. for _, item := range res.Output.Result {
  5028. temp := strings.Split(item.FeedetlSn, "-")
  5029. var advice_id int64 = 0
  5030. var project_id int64 = 0
  5031. var types int64 = 0
  5032. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5033. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5034. if temp[1] == "1" {
  5035. advice_id = id
  5036. project_id = 0
  5037. } else if temp[1] == "2" {
  5038. advice_id = 0
  5039. project_id = id
  5040. }
  5041. info := &models.HisOrderInfo{
  5042. OrderNumber: order.Number,
  5043. FeedetlSn: item.FeedetlSn,
  5044. UploadDate: time.Now().Unix(),
  5045. AdviceId: advice_id,
  5046. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5047. Cnt: item.Cnt,
  5048. Pric: float64(item.Pric),
  5049. PatientId: his.PatientId,
  5050. PricUplmtAmt: item.PricUplmtAmt,
  5051. SelfpayProp: item.SelfpayProp,
  5052. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5053. OverlmtAmt: item.OverlmtAmt,
  5054. PreselfpayAmt: item.PreselfpayAmt,
  5055. BasMednFlag: item.BasMednFlag,
  5056. MedChrgitmType: item.MedChrgitmType,
  5057. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5058. Status: 1,
  5059. Memo: item.Memo,
  5060. Mtime: time.Now().Unix(),
  5061. InscpScpAmt: item.InscpScpAmt,
  5062. DrtReimFlag: item.DrtReimFlag,
  5063. Ctime: time.Now().Unix(),
  5064. ListSpItemFlag: item.ListSpItemFlag,
  5065. ChldMedcFlag: item.ChldMedcFlag,
  5066. LmtUsedFlag: item.LmtUsedFlag,
  5067. ChrgitmLv: item.ChrgitmLv,
  5068. UserOrgId: adminUser.CurrentOrgId,
  5069. HisPatientId: his.ID,
  5070. OrderId: order.ID,
  5071. ProjectId: project_id,
  5072. Type: types,
  5073. }
  5074. service.CreateOrderInfo(info)
  5075. }
  5076. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5077. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5078. var total float64
  5079. for _, item := range prescriptions {
  5080. if item.Type == 1 { //药品
  5081. for _, subItem := range item.HisDoctorAdviceInfo {
  5082. total = total + (subItem.Price * subItem.PrescribingNumber)
  5083. }
  5084. }
  5085. if item.Type == 2 { //项目
  5086. for _, subItem := range item.HisPrescriptionProject {
  5087. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5088. total = total + (subItem.Price * cnt)
  5089. }
  5090. }
  5091. }
  5092. for _, item := range prescriptions {
  5093. for _, subItem := range item.HisAdditionalCharge {
  5094. total = total + (subItem.Price * float64(subItem.Count))
  5095. }
  5096. }
  5097. var allTotal string
  5098. if adminUser.CurrentOrgId == 9919 {
  5099. allTotal = fmt.Sprintf("%.4f", total)
  5100. } else {
  5101. allTotal = fmt.Sprintf("%.4f", total)
  5102. }
  5103. if res.Infcode == 0 {
  5104. var rf []*ResultFive
  5105. json.Unmarshal([]byte(his.Iinfo), &rf)
  5106. chrg_bchno := chrg_bchno
  5107. cert_no := his.Certno
  5108. var insutypes []string
  5109. var insutype string
  5110. var is390 int = 0
  5111. var is310 int = 0
  5112. for _, item := range rf {
  5113. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5114. insutypes = append(insutypes, item.Insutype)
  5115. }
  5116. }
  5117. if len(insutypes) == 1 {
  5118. insutype = insutypes[0]
  5119. } else {
  5120. for _, i := range insutypes {
  5121. if i == "390" {
  5122. is390 = 1
  5123. }
  5124. if i == "310" {
  5125. is310 = 1
  5126. }
  5127. }
  5128. }
  5129. if is390 == 1 {
  5130. insutype = "390"
  5131. }
  5132. if is310 == 1 {
  5133. insutype = "310"
  5134. }
  5135. if len(insutypes) == 0 {
  5136. insutype = "310"
  5137. }
  5138. if len(insutypes) == 2 {
  5139. insutype = strconv.FormatInt(his.SocialType, 10)
  5140. }
  5141. insutype = strconv.FormatInt(his.SocialType, 10)
  5142. //insutype = "390"
  5143. if his.IdCardType == 1 {
  5144. // cert_no = his.MedicalInsuranceNumber
  5145. cert_no = his.Certno
  5146. } else {
  5147. cert_no = his.Certno
  5148. }
  5149. var res ResultSeven
  5150. var resSeven10265 ResultSeven10265
  5151. var src_resquest string
  5152. var result2 string
  5153. var acct_used_flag string
  5154. fmt.Println("pay_way")
  5155. fmt.Println(pay_way)
  5156. fmt.Println("pay_way")
  5157. if pay_way == 4 {
  5158. acct_used_flag = "1"
  5159. } else {
  5160. acct_used_flag = "0"
  5161. }
  5162. if miConfig.MdtrtareaAdmvs == "421300" {
  5163. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5164. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5165. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5166. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5167. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5168. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5169. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5170. resp, requestErr := http.Get(api)
  5171. if requestErr != nil {
  5172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5173. return
  5174. }
  5175. body, ioErr := ioutil.ReadAll(resp.Body)
  5176. if ioErr != nil {
  5177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5179. return
  5180. }
  5181. var respJSON map[string]interface{}
  5182. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5185. return
  5186. }
  5187. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5188. result, _ := json.Marshal(respJSON)
  5189. if miConfig.Code == "H15049901371" {
  5190. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5191. utils.ErrorLog("解析失败:%v", err)
  5192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5193. return
  5194. }
  5195. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5196. res.Output = resSeven10265.Output
  5197. res.ErrMsg = resSeven10265.ErrMsg
  5198. res.Cainfo = resSeven10265.Cainfo
  5199. res.WarnMsg = resSeven10265.WarnMsg
  5200. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5201. res.Infcode = infocode
  5202. } else {
  5203. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5204. utils.ErrorLog("解析失败:%v", err)
  5205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5206. return
  5207. }
  5208. }
  5209. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5210. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5211. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5212. //psn_info, _ := service.GetPsnByPatientId(id)
  5213. bas := strings.Split(psn_info.CardInfo, "|")
  5214. if his.IdCardType == 1 {
  5215. cert_no = bas[2]
  5216. } else if his.IdCardType == 3 {
  5217. cert_no = his.Certno
  5218. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5219. } else {
  5220. cert_no = bas[1]
  5221. }
  5222. //江苏地区国家医保医疗类别
  5223. //职工透析:医疗类别选特殊情况门诊9933
  5224. //居民血透门慢: 医疗类别选门诊慢病1402
  5225. //var med_type string
  5226. //if his.Insutype == "310" {
  5227. // if reg_type == 14 {
  5228. // med_type = "9933"
  5229. // } else if reg_type == 11 {
  5230. // med_type = "11"
  5231. //
  5232. // }
  5233. //} else if his.Insutype == "390" {
  5234. // if reg_type == 14 {
  5235. // med_type = "1402"
  5236. // } else if reg_type == 11 {
  5237. // med_type = "11"
  5238. // }
  5239. //}
  5240. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5241. var api string
  5242. if miConfig.MdtrtareaAdmvs == "320921" {
  5243. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5244. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5245. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5246. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5247. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5248. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5249. "&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
  5250. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5251. } else {
  5252. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5253. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5254. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5255. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5256. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5257. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5258. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5259. "&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
  5260. }
  5261. resp, requestErr := http.Get(api)
  5262. if requestErr != nil {
  5263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5264. return
  5265. }
  5266. body, ioErr := ioutil.ReadAll(resp.Body)
  5267. if ioErr != nil {
  5268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5270. return
  5271. }
  5272. var respJSON map[string]interface{}
  5273. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5276. return
  5277. }
  5278. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5279. result, _ := json.Marshal(respJSON)
  5280. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5281. utils.ErrorLog("解析失败:%v", err)
  5282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5283. return
  5284. }
  5285. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5286. res.Output = resSeven10265.Output
  5287. res.ErrMsg = resSeven10265.ErrMsg
  5288. res.Cainfo = resSeven10265.Cainfo
  5289. res.WarnMsg = resSeven10265.WarnMsg
  5290. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5291. res.Infcode = infocode
  5292. } else {
  5293. if miConfig.Code == "H15049901371" {
  5294. //赤峰地区国家医保医疗类别
  5295. //职工透析:医疗类别选特殊情况门诊990502
  5296. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5297. var med_type string
  5298. if his.Insutype == "390" {
  5299. if reg_type == 14 {
  5300. med_type = "9933"
  5301. } else if reg_type == 11 {
  5302. med_type = "11"
  5303. }
  5304. } else if his.Insutype == "310" {
  5305. if reg_type == 14 {
  5306. med_type = "990502"
  5307. } else if reg_type == 11 {
  5308. med_type = "11"
  5309. }
  5310. }
  5311. 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)
  5312. } else {
  5313. 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)
  5314. }
  5315. //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)
  5316. var dat map[string]interface{}
  5317. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5318. fmt.Println(dat)
  5319. } else {
  5320. fmt.Println(err)
  5321. }
  5322. saveLog(result2, src_resquest, "2207", "结算")
  5323. userJSONBytes, _ := json.Marshal(dat)
  5324. if miConfig.Code == "H15049901371" {
  5325. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5326. utils.ErrorLog("解析失败:%v", err)
  5327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5328. return
  5329. }
  5330. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5331. res.Output = resSeven10265.Output
  5332. res.ErrMsg = resSeven10265.ErrMsg
  5333. res.Cainfo = resSeven10265.Cainfo
  5334. res.WarnMsg = resSeven10265.WarnMsg
  5335. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5336. res.Infcode = infocode
  5337. } else {
  5338. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5339. utils.ErrorLog("解析失败:%v", err)
  5340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5341. return
  5342. }
  5343. }
  5344. }
  5345. if res.Infcode != 0 {
  5346. errlog := &models.HisOrderError{
  5347. UserOrgId: adminUser.CurrentOrgId,
  5348. Ctime: time.Now().Unix(),
  5349. Mtime: time.Now().Unix(),
  5350. Number: chrg_bchno,
  5351. ErrMsg: res.ErrMsg,
  5352. Status: 1,
  5353. PatientId: id,
  5354. RecordTime: recordDateTime,
  5355. Stage: 6,
  5356. }
  5357. service.CreateErrMsgLog(errlog)
  5358. c.ServeSuccessJSON(map[string]interface{}{
  5359. "failed_code": -10,
  5360. "msg": res.ErrMsg,
  5361. })
  5362. return
  5363. } else {
  5364. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5365. order.OrderStatus = 2
  5366. order.Status = 1
  5367. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5368. order.SetlId = res.Output.Setlinfo.SetlID
  5369. order.PsnNo = res.Output.Setlinfo.PsnNo
  5370. order.PsnName = res.Output.Setlinfo.PsnName
  5371. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5372. order.Certno = res.Output.Setlinfo.Certno
  5373. order.Gend = res.Output.Setlinfo.Gend
  5374. order.Naty = res.Output.Setlinfo.Naty
  5375. order.Age = res.Output.Setlinfo.Age
  5376. order.Insutype = res.Output.Setlinfo.Insutype
  5377. order.PsnType = res.Output.Setlinfo.PsnType
  5378. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5379. order.SetlTime = res.Output.Setlinfo.SetlTime
  5380. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5381. if res.Output.Setlinfo.MedType == "140101" {
  5382. order.MedType = "14"
  5383. } else {
  5384. order.MedType = res.Output.Setlinfo.MedType
  5385. }
  5386. if reg_type == 1112 {
  5387. order.MedType = "1112"
  5388. }
  5389. if reg_type == 1111 {
  5390. order.MedType = "1111"
  5391. }
  5392. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5393. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5394. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5395. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5396. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5397. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5398. order.HifpPay = res.Output.Setlinfo.HifpPay
  5399. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5400. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5401. order.HifesPay = res.Output.Setlinfo.HifesPay
  5402. order.HifobPay = res.Output.Setlinfo.HifobPay
  5403. order.MafPay = res.Output.Setlinfo.MafPay
  5404. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5405. order.OthPay = res.Output.Setlinfo.OthPay
  5406. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5407. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5408. order.AcctPay = res.Output.Setlinfo.AcctPay
  5409. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5410. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5411. order.Balc = res.Output.Setlinfo.Balc
  5412. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5413. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5414. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5415. order.ClrType = res.Output.Setlinfo.ClrType
  5416. order.ClrWay = res.Output.Setlinfo.ClrWay
  5417. order.Creator = order.Creator
  5418. order.Modify = roles.AdminUserId
  5419. order.RequestLog = src_resquest
  5420. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5421. detailStr := string(setlDetail)
  5422. order.SetlDetail = detailStr
  5423. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5424. err = service.UpDateOrder(order)
  5425. if err == nil {
  5426. c.ServeSuccessJSON(map[string]interface{}{
  5427. "msg": "结算成功",
  5428. })
  5429. } else {
  5430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5431. return
  5432. }
  5433. }
  5434. } else {
  5435. adminUser := c.GetAdminUserInfo()
  5436. errlog := &models.HisOrderError{
  5437. UserOrgId: adminUser.CurrentOrgId,
  5438. Ctime: time.Now().Unix(),
  5439. Mtime: time.Now().Unix(),
  5440. ErrMsg: res.ErrMsg,
  5441. Status: 1,
  5442. PatientId: id,
  5443. RecordTime: recordDateTime,
  5444. Stage: 4,
  5445. }
  5446. service.CreateErrMsgLog(errlog)
  5447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5448. return
  5449. }
  5450. } else {
  5451. adminUser := c.GetAdminUserInfo()
  5452. errlog := &models.HisOrderError{
  5453. UserOrgId: adminUser.CurrentOrgId,
  5454. Ctime: time.Now().Unix(),
  5455. Mtime: time.Now().Unix(),
  5456. ErrMsg: res.ErrMsg,
  5457. Status: 1,
  5458. PatientId: id,
  5459. RecordTime: recordDateTime,
  5460. Stage: 4,
  5461. }
  5462. service.CreateErrMsgLog(errlog)
  5463. c.ServeSuccessJSON(map[string]interface{}{
  5464. "failed_code": -10,
  5465. "msg": res.ErrMsg,
  5466. })
  5467. return
  5468. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5469. //return
  5470. }
  5471. }
  5472. }
  5473. } else if tempOrder.ID > 0 {
  5474. if tempOrder.IsPre == 1 {
  5475. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5476. var rf []*ResultFive
  5477. json.Unmarshal([]byte(his.Iinfo), &rf)
  5478. chrg_bchno := tempOrder.Number
  5479. cert_no := his.Certno
  5480. var insutypes []string
  5481. var insutype string
  5482. var is390 int = 0
  5483. var is310 int = 0
  5484. for _, item := range rf {
  5485. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5486. insutypes = append(insutypes, item.Insutype)
  5487. }
  5488. }
  5489. if len(insutypes) == 1 {
  5490. insutype = insutypes[0]
  5491. } else {
  5492. for _, i := range insutypes {
  5493. if i == "390" {
  5494. is390 = 1
  5495. }
  5496. if i == "310" {
  5497. is310 = 1
  5498. }
  5499. }
  5500. }
  5501. if is390 == 1 {
  5502. insutype = "390"
  5503. }
  5504. if is310 == 1 {
  5505. insutype = "310"
  5506. }
  5507. if len(insutypes) == 0 {
  5508. insutype = "310"
  5509. }
  5510. if len(insutypes) == 2 {
  5511. insutype = strconv.FormatInt(his.SocialType, 64)
  5512. }
  5513. //insutype = "390"
  5514. if his.IdCardType == 1 {
  5515. // cert_no = his.MedicalInsuranceNumber
  5516. cert_no = his.Certno
  5517. } else {
  5518. cert_no = his.Certno
  5519. }
  5520. var res ResultSeven
  5521. var resSeven10265 ResultSeven10265
  5522. var src_resquest string
  5523. var result2 string
  5524. var acct_used_flag string
  5525. fmt.Println("pay_way")
  5526. fmt.Println(pay_way)
  5527. fmt.Println("pay_way")
  5528. if pay_way == 4 {
  5529. acct_used_flag = "1"
  5530. } else {
  5531. acct_used_flag = "0"
  5532. }
  5533. if miConfig.MdtrtareaAdmvs == "421300" {
  5534. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5535. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5536. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5537. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5538. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5539. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5540. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5541. resp, requestErr := http.Get(api)
  5542. if requestErr != nil {
  5543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5544. return
  5545. }
  5546. body, ioErr := ioutil.ReadAll(resp.Body)
  5547. if ioErr != nil {
  5548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5550. return
  5551. }
  5552. var respJSON map[string]interface{}
  5553. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5556. return
  5557. }
  5558. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5559. result, _ := json.Marshal(respJSON)
  5560. fmt.Println("log")
  5561. fmt.Println(string(result))
  5562. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5563. utils.ErrorLog("解析失败:%v", err)
  5564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5565. return
  5566. }
  5567. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5568. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5569. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5570. //psn_info, _ := service.GetPsnByPatientId(id)
  5571. bas := strings.Split(psn_info.CardInfo, "|")
  5572. if his.IdCardType == 1 {
  5573. cert_no = bas[2]
  5574. } else {
  5575. cert_no = bas[1]
  5576. }
  5577. //江苏地区国家医保医疗类别
  5578. //职工透析:医疗类别选特殊情况门诊9933
  5579. //居民血透门慢: 医疗类别选门诊慢病1402
  5580. //var med_type string
  5581. //if his.Insutype == "310" {
  5582. // if reg_type == 14 {
  5583. // med_type = "9933"
  5584. // } else if reg_type == 11 {
  5585. // med_type = "11"
  5586. //
  5587. // }
  5588. //} else if his.Insutype == "390" {
  5589. // if reg_type == 14 {
  5590. // med_type = "1402"
  5591. // } else if reg_type == 11 {
  5592. // med_type = "11"
  5593. // }
  5594. //}
  5595. var api string
  5596. if miConfig.MdtrtareaAdmvs == "320921" {
  5597. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5598. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5599. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5600. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5601. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5602. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5603. "&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
  5604. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5605. } else {
  5606. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5607. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5608. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5609. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5610. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5611. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5612. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5613. "&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
  5614. }
  5615. resp, requestErr := http.Get(api)
  5616. if requestErr != nil {
  5617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5618. return
  5619. }
  5620. body, ioErr := ioutil.ReadAll(resp.Body)
  5621. if ioErr != nil {
  5622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5624. return
  5625. }
  5626. var respJSON map[string]interface{}
  5627. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5630. return
  5631. }
  5632. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5633. result, _ := json.Marshal(respJSON)
  5634. fmt.Println("log")
  5635. fmt.Println(string(result))
  5636. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5637. utils.ErrorLog("解析失败:%v", err)
  5638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5639. return
  5640. }
  5641. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5642. res.Output = resSeven10265.Output
  5643. res.ErrMsg = resSeven10265.ErrMsg
  5644. res.Cainfo = resSeven10265.Cainfo
  5645. res.WarnMsg = resSeven10265.WarnMsg
  5646. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5647. res.Infcode = infocode
  5648. } else {
  5649. var src_resquest string
  5650. if miConfig.Code == "H15049901371" {
  5651. //赤峰地区国家医保医疗类别
  5652. //职工透析:医疗类别选特殊情况门诊990502
  5653. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5654. var med_type string
  5655. if his.Insutype == "390" {
  5656. if reg_type == 14 {
  5657. med_type = "9933"
  5658. } else if reg_type == 11 {
  5659. med_type = "11"
  5660. }
  5661. } else if his.Insutype == "310" {
  5662. if reg_type == 14 {
  5663. med_type = "990502"
  5664. } else if reg_type == 11 {
  5665. med_type = "11"
  5666. }
  5667. }
  5668. 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)
  5669. } else {
  5670. 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)
  5671. }
  5672. var dat map[string]interface{}
  5673. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5674. fmt.Println(dat)
  5675. } else {
  5676. fmt.Println(err)
  5677. }
  5678. saveLog(result2, src_resquest, "2207", "结算")
  5679. userJSONBytes, _ := json.Marshal(dat)
  5680. if miConfig.Code == "H15049901371" {
  5681. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5682. utils.ErrorLog("解析失败:%v", err)
  5683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5684. return
  5685. }
  5686. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5687. res.Output = resSeven10265.Output
  5688. res.ErrMsg = resSeven10265.ErrMsg
  5689. res.Cainfo = resSeven10265.Cainfo
  5690. res.WarnMsg = resSeven10265.WarnMsg
  5691. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5692. res.Infcode = infocode
  5693. } else {
  5694. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5695. utils.ErrorLog("解析失败:%v", err)
  5696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5697. return
  5698. }
  5699. }
  5700. }
  5701. if res.Infcode != 0 {
  5702. errlog := &models.HisOrderError{
  5703. UserOrgId: adminUser.CurrentOrgId,
  5704. Ctime: time.Now().Unix(),
  5705. Mtime: time.Now().Unix(),
  5706. Number: chrg_bchno,
  5707. ErrMsg: res.ErrMsg,
  5708. Status: 1,
  5709. PatientId: id,
  5710. RecordTime: recordDateTime,
  5711. Stage: 6,
  5712. }
  5713. service.CreateErrMsgLog(errlog)
  5714. c.ServeSuccessJSON(map[string]interface{}{
  5715. "failed_code": -10,
  5716. "msg": res.ErrMsg,
  5717. })
  5718. return
  5719. } else {
  5720. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5721. order.OrderStatus = 2
  5722. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5723. order.SetlId = res.Output.Setlinfo.SetlID
  5724. order.PsnNo = res.Output.Setlinfo.PsnNo
  5725. order.PsnName = res.Output.Setlinfo.PsnName
  5726. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5727. order.Certno = res.Output.Setlinfo.Certno
  5728. order.Gend = res.Output.Setlinfo.Gend
  5729. order.Naty = res.Output.Setlinfo.Naty
  5730. order.Age = res.Output.Setlinfo.Age
  5731. order.Insutype = res.Output.Setlinfo.Insutype
  5732. order.PsnType = res.Output.Setlinfo.PsnType
  5733. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5734. order.SetlTime = res.Output.Setlinfo.SetlTime
  5735. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5736. //order.MedType = res.Output.Setlinfo.MedType
  5737. if reg_type == 1112 {
  5738. order.MedType = "1112"
  5739. }
  5740. if reg_type == 1111 {
  5741. order.MedType = "1111"
  5742. }
  5743. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5744. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5745. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5746. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5747. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5748. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5749. order.HifpPay = res.Output.Setlinfo.HifpPay
  5750. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5751. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5752. order.HifesPay = res.Output.Setlinfo.HifesPay
  5753. order.HifobPay = res.Output.Setlinfo.HifobPay
  5754. order.MafPay = res.Output.Setlinfo.MafPay
  5755. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5756. order.OthPay = res.Output.Setlinfo.OthPay
  5757. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5758. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5759. order.AcctPay = res.Output.Setlinfo.AcctPay
  5760. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5761. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5762. order.Balc = res.Output.Setlinfo.Balc
  5763. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5764. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5765. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5766. order.ClrWay = res.Output.Setlinfo.ClrWay
  5767. order.Creator = order.Creator
  5768. order.Modify = roles.AdminUserId
  5769. order.RequestLog = src_resquest
  5770. order.Diagnosis = diagnosis_id
  5771. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5772. detailStr := string(setlDetail)
  5773. order.SetlDetail = detailStr
  5774. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5775. err = service.UpDateOrder(order)
  5776. if err == nil {
  5777. c.ServeSuccessJSON(map[string]interface{}{
  5778. "msg": "结算成功",
  5779. })
  5780. } else {
  5781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5782. return
  5783. }
  5784. }
  5785. }
  5786. }
  5787. }
  5788. //func (c *HisApiController) GetPreUploadInfo() {
  5789. // id, _ := c.GetInt64("id")
  5790. // record_time := c.GetString("record_time")
  5791. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5792. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5793. //
  5794. // timeLayout := "2006-01-02"
  5795. // loc, _ := time.LoadLocation("Local")
  5796. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5797. // if err != nil {
  5798. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5799. // return
  5800. // }
  5801. // recordDateTime := theTime.Unix()
  5802. // adminUser := c.GetAdminUserInfo()
  5803. //
  5804. // var prescriptions []*models.HisPrescription
  5805. //
  5806. // var start_time int64
  5807. // var end_time int64
  5808. //
  5809. // data := make(map[string]interface{})
  5810. // if settle_accounts_type == 1 { //日结
  5811. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5812. // data["pre"] = prescriptions
  5813. //
  5814. // } else { //月结
  5815. // start_time_str := c.GetString("start_time")
  5816. // end_time_str := c.GetString("end_time")
  5817. // timeLayout := "2006-01-02"
  5818. // loc, _ := time.LoadLocation("Local")
  5819. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5820. // if err != nil {
  5821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5822. // return
  5823. // }
  5824. // recordStartTime := theStartTime.Unix()
  5825. // start_time = recordStartTime
  5826. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5827. // if err != nil {
  5828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5829. // return
  5830. // }
  5831. // recordEndTime := theEndTime.Unix()
  5832. // end_time = recordEndTime
  5833. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5834. // data["pre"] = prescriptions
  5835. //
  5836. // }
  5837. //
  5838. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5839. //
  5840. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5841. // timestamp := time.Now().Unix()
  5842. // tempTime := time.Unix(timestamp, 0)
  5843. // timeFormat := tempTime.Format("20060102150405")
  5844. // chrgBchno := rand.Intn(100000) + 10000
  5845. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5846. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5847. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5848. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5849. // strconv.FormatInt(his.PatientId, 10)
  5850. // client := &http.Client{}
  5851. // data["psn_no"] = his.PsnNo
  5852. // data["mdtrt_id"] = his.Number
  5853. // data["chrg_bchno"] = chrg_bchno
  5854. // data["org_name"] = miConfig.OrgName
  5855. // data["doctor"] = roles.UserName
  5856. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5857. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5858. // data["fixmedins_code"] = miConfig.Code
  5859. // data["dept_code"] = department.Number
  5860. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5861. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5862. // data["secret_key"] = miConfig.SecretKey
  5863. // var ids []int64
  5864. //
  5865. // for _, item := range prescriptions {
  5866. // ids = append(ids, item.ID)
  5867. // }
  5868. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5869. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5870. // bytesData, _ := json.Marshal(data)
  5871. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5872. // resp, _ := client.Do(req)
  5873. // defer resp.Body.Close()
  5874. // body, ioErr := ioutil.ReadAll(resp.Body)
  5875. // if ioErr != nil {
  5876. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5877. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5878. // return
  5879. // }
  5880. // var respJSON map[string]interface{}
  5881. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5882. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5884. // return
  5885. // }
  5886. //
  5887. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5888. // userJSONBytes, _ := json.Marshal(respJSON)
  5889. // var res ResultFour
  5890. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5891. // utils.ErrorLog("解析失败:%v", err)
  5892. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5893. // return
  5894. // }
  5895. //
  5896. // if res.Infcode == 0 {
  5897. // order := &models.HisOrder{
  5898. // UserOrgId: adminUser.CurrentOrgId,
  5899. // HisPatientId: his.ID,
  5900. // PatientId: his.PatientId,
  5901. // SettleAccountsDate: recordDateTime,
  5902. // Ctime: time.Now().Unix(),
  5903. // Mtime: time.Now().Unix(),
  5904. // Status: 1,
  5905. // Number: chrg_bchno,
  5906. // Infcode: res.Infcode,
  5907. // WarnMsg: res.WarnMsg,
  5908. // Cainfo: res.Cainfo,
  5909. // ErrMsg: res.ErrMsg,
  5910. // RespondTime: res.RefmsgTime,
  5911. // InfRefmsgid: res.InfRefmsgid,
  5912. // OrderStatus: 1,
  5913. // IsMedicineInsurance: 1,
  5914. // SettleType: settle_accounts_type,
  5915. // SettleStartTime: start_time,
  5916. // SettleEndTime: end_time,
  5917. // Creator: roles.ID,
  5918. // Modify: roles.ID,
  5919. // PType: 2,
  5920. // }
  5921. // err = service.CreateOrder(order)
  5922. // if err != nil {
  5923. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5924. // return
  5925. // }
  5926. //
  5927. // for _, item := range res.Output.Result {
  5928. // temp := strings.Split(item.FeedetlSn, "-")
  5929. // var advice_id int64 = 0
  5930. // var project_id int64 = 0
  5931. // var types int64 = 0
  5932. //
  5933. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5934. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5935. //
  5936. // if temp[1] == "1" {
  5937. // advice_id = id
  5938. // project_id = 0
  5939. // } else if temp[1] == "2" {
  5940. // advice_id = 0
  5941. // project_id = id
  5942. // }
  5943. //
  5944. // info := &models.HisOrderInfo{
  5945. // OrderNumber: order.Number,
  5946. // FeedetlSn: item.FeedetlSn,
  5947. // UploadDate: time.Now().Unix(),
  5948. // AdviceId: advice_id,
  5949. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5950. // Cnt: item.Cnt,
  5951. // Pric: float64(item.Pric),
  5952. // PatientId: his.PatientId,
  5953. // PricUplmtAmt: item.PricUplmtAmt,
  5954. // SelfpayProp: item.SelfpayProp,
  5955. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5956. // OverlmtAmt: item.OverlmtAmt,
  5957. // PreselfpayAmt: item.PreselfpayAmt,
  5958. // BasMednFlag: item.BasMednFlag,
  5959. // MedChrgitmType: item.MedChrgitmType,
  5960. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5961. // Status: 1,
  5962. // Memo: item.Memo,
  5963. // Mtime: time.Now().Unix(),
  5964. // InscpScpAmt: item.InscpScpAmt,
  5965. // DrtReimFlag: item.DrtReimFlag,
  5966. // Ctime: time.Now().Unix(),
  5967. // ListSpItemFlag: item.ListSpItemFlag,
  5968. // ChldMedcFlag: item.ChldMedcFlag,
  5969. // LmtUsedFlag: item.LmtUsedFlag,
  5970. // ChrgitmLv: item.ChrgitmLv,
  5971. // UserOrgId: adminUser.CurrentOrgId,
  5972. // HisPatientId: his.ID,
  5973. // OrderId: order.ID,
  5974. // ProjectId: project_id,
  5975. // Type: types,
  5976. // }
  5977. // service.CreateOrderInfo(info)
  5978. //
  5979. // }
  5980. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5981. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5982. //
  5983. // var total float64
  5984. // for _, item := range prescriptions {
  5985. // if item.Type == 1 { //药品
  5986. // for _, subItem := range item.HisDoctorAdviceInfo {
  5987. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5988. // }
  5989. // }
  5990. // if item.Type == 2 { //项目
  5991. // for _, subItem := range item.HisPrescriptionProject {
  5992. // total = total + (subItem.Price * float64(subItem.Count))
  5993. // }
  5994. // }
  5995. // }
  5996. //
  5997. // for _, item := range prescriptions {
  5998. // for _, subItem := range item.HisAdditionalCharge {
  5999. // total = total + (subItem.Price * float64(subItem.Count))
  6000. // }
  6001. // }
  6002. //
  6003. // allTotal := fmt.Sprintf("%.2f", total)
  6004. // if res.Infcode == 0 {
  6005. // var rf []*ResultFive
  6006. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6007. // psn_no := his.PsnNo
  6008. // mdtrt_id := his.Number
  6009. // chrg_bchno := chrg_bchno
  6010. // cert_no := his.Certno
  6011. // insutype := rf[0].Insutype
  6012. //
  6013. // if his.IdCardType == 1 {
  6014. // cert_no = his.MedicalInsuranceNumber
  6015. //
  6016. // } else {
  6017. //
  6018. // cert_no = his.Certno
  6019. //
  6020. // }
  6021. //
  6022. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6023. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6024. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6025. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6026. // resp, requestErr := http.Get(api)
  6027. // if requestErr != nil {
  6028. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6029. // return
  6030. // }
  6031. // defer resp.Body.Close()
  6032. // body, ioErr := ioutil.ReadAll(resp.Body)
  6033. // if ioErr != nil {
  6034. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6035. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6036. // return
  6037. // }
  6038. // var respJSON map[string]interface{}
  6039. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6040. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6041. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6042. // return
  6043. // }
  6044. // fmt.Println(respJSON)
  6045. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6046. // userJSONBytes, _ := json.Marshal(respJSON)
  6047. // var res ResultSeven
  6048. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6049. // utils.ErrorLog("解析失败:%v", err)
  6050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6051. // return
  6052. // }
  6053. // if res.Infcode != 0 {
  6054. // errlog := &models.HisOrderError{
  6055. // UserOrgId: adminUser.CurrentOrgId,
  6056. // Ctime: time.Now().Unix(),
  6057. // Mtime: time.Now().Unix(),
  6058. // Number: chrg_bchno,
  6059. // ErrMsg: res.ErrMsg,
  6060. // Status: 1,
  6061. // PatientId: id,
  6062. // RecordTime: recordDateTime,
  6063. // Stage: 7,
  6064. // }
  6065. // service.CreateErrMsgLog(errlog)
  6066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6067. // return
  6068. // } else {
  6069. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6070. // order.OrderStatus = 1
  6071. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6072. // order.SetlId = res.Output.Setlinfo.SetlID
  6073. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6074. // order.PsnName = res.Output.Setlinfo.PsnName
  6075. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6076. // order.Certno = res.Output.Setlinfo.Certno
  6077. // order.Gend = res.Output.Setlinfo.Gend
  6078. // order.Naty = res.Output.Setlinfo.Naty
  6079. // order.Age = res.Output.Setlinfo.Age
  6080. // order.Insutype = res.Output.Setlinfo.Insutype
  6081. // order.PsnType = res.Output.Setlinfo.PsnType
  6082. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6083. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6084. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6085. // order.MedType = res.Output.Setlinfo.MedType
  6086. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6087. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6088. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6089. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6090. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6091. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6092. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6093. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6094. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6095. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6096. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6097. // order.MafPay = res.Output.Setlinfo.MafPay
  6098. // order.OthPay = res.Output.Setlinfo.OthPay
  6099. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6100. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6101. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6102. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6103. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6104. // order.Balc = res.Output.Setlinfo.Balc
  6105. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6106. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6107. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6108. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6109. // order.Creator = order.Creator
  6110. // order.Modify = roles.ID
  6111. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6112. // detailStr := string(setlDetail)
  6113. // order.SetlDetail = detailStr
  6114. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6115. // err = service.UpDateOrder(order)
  6116. // if err == nil {
  6117. // c.ServeSuccessJSON(map[string]interface{}{
  6118. // "msg": "预结算成功",
  6119. // })
  6120. // } else {
  6121. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6122. // return
  6123. // }
  6124. // }
  6125. // } else {
  6126. // adminUser := c.GetAdminUserInfo()
  6127. // errlog := &models.HisOrderError{
  6128. // UserOrgId: adminUser.CurrentOrgId,
  6129. // Ctime: time.Now().Unix(),
  6130. // Mtime: time.Now().Unix(),
  6131. // ErrMsg: res.ErrMsg,
  6132. // Status: 1,
  6133. // PatientId: id,
  6134. // RecordTime: recordDateTime,
  6135. // Stage: 4,
  6136. // }
  6137. // service.CreateErrMsgLog(errlog)
  6138. //
  6139. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6140. // return
  6141. // }
  6142. // } else {
  6143. // adminUser := c.GetAdminUserInfo()
  6144. // errlog := &models.HisOrderError{
  6145. // UserOrgId: adminUser.CurrentOrgId,
  6146. // Ctime: time.Now().Unix(),
  6147. // Mtime: time.Now().Unix(),
  6148. // ErrMsg: res.ErrMsg,
  6149. // Status: 1,
  6150. // PatientId: id,
  6151. // RecordTime: recordDateTime,
  6152. // Stage: 4,
  6153. // }
  6154. // service.CreateErrMsgLog(errlog)
  6155. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6156. // return
  6157. // }
  6158. //
  6159. // } else {
  6160. // var total float64
  6161. // for _, item := range prescriptions {
  6162. // if item.Type == 1 { //药品
  6163. // for _, subItem := range item.HisDoctorAdviceInfo {
  6164. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6165. // }
  6166. // }
  6167. // if item.Type == 2 { //项目
  6168. // for _, subItem := range item.HisPrescriptionProject {
  6169. // total = total + (subItem.Price * float64(subItem.Count))
  6170. // }
  6171. // }
  6172. //
  6173. // for _, subItem := range item.HisAdditionalCharge {
  6174. // total = total + (subItem.Price * float64(subItem.Count))
  6175. // }
  6176. // }
  6177. //
  6178. // allTotal := fmt.Sprintf("%.2f", total)
  6179. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6180. // order := &models.HisOrder{
  6181. // UserOrgId: adminUser.CurrentOrgId,
  6182. // HisPatientId: his.ID,
  6183. // PatientId: id,
  6184. // SettleAccountsDate: recordDateTime,
  6185. // Ctime: time.Now().Unix(),
  6186. // Mtime: time.Now().Unix(),
  6187. // Status: 1,
  6188. // OrderStatus: 2,
  6189. // Number: chrg_bchno,
  6190. // MedfeeSumamt: totals,
  6191. // }
  6192. // err = service.CreateOrder(order)
  6193. // if err != nil {
  6194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6195. // return
  6196. // }
  6197. //
  6198. // var customs []*Custom
  6199. // for _, item := range prescriptions {
  6200. //
  6201. // if item.Type == 1 { //药品
  6202. // for _, subItem := range item.HisDoctorAdviceInfo {
  6203. // cus := &Custom{
  6204. // AdviceId: subItem.ID,
  6205. // ProjectId: 0,
  6206. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6207. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6208. // FeedetlSn: subItem.FeedetlSn,
  6209. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6210. // MedListCodg: subItem.MedListCodg,
  6211. // Type: 1,
  6212. // }
  6213. // customs = append(customs, cus)
  6214. // }
  6215. // }
  6216. //
  6217. // if item.Type == 2 { //项目
  6218. // for _, subItem := range item.HisPrescriptionProject {
  6219. //
  6220. // cus := &Custom{
  6221. // AdviceId: 0,
  6222. // ProjectId: subItem.ID,
  6223. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6224. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6225. // FeedetlSn: subItem.FeedetlSn,
  6226. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6227. // MedListCodg: subItem.MedListCodg,
  6228. // Type: 2,
  6229. // }
  6230. //
  6231. // customs = append(customs, cus)
  6232. // }
  6233. // }
  6234. //
  6235. // for _, item := range item.HisAdditionalCharge {
  6236. // cus := &Custom{
  6237. // ItemId: item.ID,
  6238. // AdviceId: 0,
  6239. // ProjectId: 0,
  6240. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6241. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6242. // FeedetlSn: item.FeedetlSn,
  6243. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6244. // MedListCodg: item.XtHisAddtionConfig.Code,
  6245. // Type: 3,
  6246. // }
  6247. //
  6248. // customs = append(customs, cus)
  6249. // }
  6250. //
  6251. // }
  6252. //
  6253. // for _, item := range customs {
  6254. // var advice_id int64 = 0
  6255. // var project_id int64 = 0
  6256. // var item_id int64 = 0
  6257. //
  6258. // var types int64 = 0
  6259. //
  6260. // if item.Type == 1 {
  6261. // advice_id = item.AdviceId
  6262. // project_id = 0
  6263. // item_id = 0
  6264. // } else if item.Type == 2 {
  6265. // advice_id = 0
  6266. // item_id = 0
  6267. //
  6268. // project_id = item.ProjectId
  6269. // } else if item.Type == 3 {
  6270. // advice_id = 0
  6271. // item_id = item.ItemId
  6272. // project_id = 0
  6273. // }
  6274. //
  6275. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6276. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6277. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6278. //
  6279. // info := &models.HisOrderInfo{
  6280. // OrderNumber: order.Number,
  6281. // UploadDate: time.Now().Unix(),
  6282. // AdviceId: advice_id,
  6283. // DetItemFeeSumamt: detItemFeeSumamt,
  6284. // Cnt: cut,
  6285. // Pric: pric,
  6286. // PatientId: id,
  6287. // Status: 1,
  6288. // Mtime: time.Now().Unix(),
  6289. // Ctime: time.Now().Unix(),
  6290. // UserOrgId: adminUser.CurrentOrgId,
  6291. // HisPatientId: his.ID,
  6292. // OrderId: order.ID,
  6293. // ProjectId: project_id,
  6294. // Type: types,
  6295. // ItemId: item_id,
  6296. // }
  6297. // service.CreateOrderInfo(info)
  6298. // }
  6299. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6300. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6301. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6302. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6303. // if err == nil {
  6304. // c.ServeSuccessJSON(map[string]interface{}{
  6305. // "msg": "结算成功",
  6306. // })
  6307. // } else {
  6308. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6309. // return
  6310. // }
  6311. // }
  6312. //}
  6313. //上传明细-预结算-
  6314. func (c *HisApiController) GetPreUploadInfo() {
  6315. id, _ := c.GetInt64("id")
  6316. record_time := c.GetString("record_time")
  6317. his_patient_id, _ := c.GetInt64("his_patient_id")
  6318. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6319. admin_user_id, _ := c.GetInt64("admin_user_id")
  6320. diagnosis_id := c.GetString("diagnosis")
  6321. sick_type, _ := c.GetInt64("sick_type")
  6322. reg_type, _ := c.GetInt64("p_type")
  6323. begin_time := c.GetString("begin_time")
  6324. id_str := c.GetString("ids")
  6325. ids_arr := strings.Split(id_str, ",")
  6326. timeLayout := "2006-01-02"
  6327. loc, _ := time.LoadLocation("Local")
  6328. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6329. if err != nil {
  6330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6331. return
  6332. }
  6333. recordDateTime := theTime.Unix()
  6334. adminUser := c.GetAdminUserInfo()
  6335. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6336. var config []*models.HisXtDiagnoseConfig
  6337. for _, item := range diagnosis_ids {
  6338. id, _ := strconv.ParseInt(item, 10, 64)
  6339. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6340. config = append(config, &diagnosisConfig)
  6341. }
  6342. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6343. sickConfig, _ := service.FindSickById(sick_type)
  6344. var prescriptions []*models.HisPrescription
  6345. var start_time int64
  6346. var end_time int64
  6347. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6348. fmt.Println(his_patient_id)
  6349. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6350. timestamp := time.Now().Unix()
  6351. tempTime := time.Unix(timestamp, 0)
  6352. timeFormat := tempTime.Format("20060102150405")
  6353. chrgBchno := rand.Intn(100000) + 10000
  6354. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6355. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6356. var patientPrescription models.HisPrescriptionInfo
  6357. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6358. if patientPrescription.ID == 0 {
  6359. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6360. }
  6361. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6362. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6363. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6364. strconv.FormatInt(his.PatientId, 10)
  6365. var res2 ResultSix
  6366. var resSix10265 ResultSix10265
  6367. var time_stamp string
  6368. if miConfig.MdtrtareaAdmvs == "421300" {
  6369. data := make(map[string]interface{})
  6370. client := &http.Client{}
  6371. data["psn_no"] = his.PsnNo
  6372. data["mdtrt_id"] = his.Number
  6373. data["doctor"] = roles.UserName
  6374. data["department"] = department.Name
  6375. data["org_name"] = miConfig.OrgName
  6376. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6377. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6378. data["fixmedins_code"] = miConfig.Code
  6379. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6380. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6381. data["secret_key"] = miConfig.SecretKey
  6382. data["sick_code"] = sickConfig.CountryCode
  6383. data["sick_name"] = sickConfig.ClassName
  6384. data["begin_time"] = begin_time
  6385. data["dept"] = strconv.FormatInt(department.ID, 10)
  6386. data["config"] = config
  6387. fmt.Println(data)
  6388. bytesData, _ := json.Marshal(data)
  6389. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6390. resp, _ := client.Do(req)
  6391. defer resp.Body.Close()
  6392. body, ioErr := ioutil.ReadAll(resp.Body)
  6393. if ioErr != nil {
  6394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6396. return
  6397. }
  6398. var respJSON map[string]interface{}
  6399. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6402. return
  6403. }
  6404. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6405. userJSONBytes, _ := json.Marshal(respJSON)
  6406. fmt.Println("log")
  6407. fmt.Println(string(userJSONBytes))
  6408. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6409. utils.ErrorLog("解析失败:%v", err)
  6410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6411. return
  6412. }
  6413. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6414. //江苏地区国家医保医疗类别
  6415. //职工透析:医疗类别选特殊情况门诊9933
  6416. //居民血透门慢: 医疗类别选门诊慢病1402
  6417. //var med_type string
  6418. //if his.Insutype == "310" {
  6419. // if reg_type == 14 {
  6420. // med_type = "9933"
  6421. // } else if reg_type == 11 {
  6422. // med_type = "11"
  6423. //
  6424. // }
  6425. //} else if his.Insutype == "390" {
  6426. // if reg_type == 14 {
  6427. // med_type = "1402"
  6428. // } else if reg_type == 11 {
  6429. // med_type = "11"
  6430. // }
  6431. //}
  6432. data := make(map[string]interface{})
  6433. client := &http.Client{}
  6434. data["psn_no"] = his.PsnNo
  6435. data["mdtrt_id"] = his.Number
  6436. data["doctor"] = roles.UserName
  6437. data["department"] = department.Name
  6438. data["org_name"] = miConfig.OrgName
  6439. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6440. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6441. data["fixmedins_code"] = miConfig.Code
  6442. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6443. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6444. data["secret_key"] = miConfig.SecretKey
  6445. data["sick_code"] = sickConfig.CountryCode
  6446. data["sick_name"] = sickConfig.ClassName
  6447. data["begin_time"] = begin_time
  6448. data["dept"] = strconv.FormatInt(department.ID, 10)
  6449. data["config"] = config
  6450. data["url"] = miConfig.Url
  6451. data["ak"] = miConfig.AccessKey
  6452. data["cainfo"] = miConfig.Cainfo
  6453. bytesData, _ := json.Marshal(data)
  6454. var req *http.Request
  6455. if miConfig.MdtrtareaAdmvs == "320921" {
  6456. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6457. //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 +
  6458. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6459. } else {
  6460. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6461. }
  6462. resp, _ := client.Do(req)
  6463. defer resp.Body.Close()
  6464. body, ioErr := ioutil.ReadAll(resp.Body)
  6465. if ioErr != nil {
  6466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6468. return
  6469. }
  6470. var respJSON map[string]interface{}
  6471. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6474. return
  6475. }
  6476. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6477. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6478. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6479. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6480. userJSONBytes, _ := json.Marshal(respJSON)
  6481. fmt.Println("log")
  6482. fmt.Println(string(userJSONBytes))
  6483. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6484. utils.ErrorLog("解析失败:%v", err)
  6485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6486. return
  6487. }
  6488. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6489. res2.Output = resSix10265.Output
  6490. res2.ErrMsg = resSix10265.ErrMsg
  6491. res2.Cainfo = resSix10265.Cainfo
  6492. res2.WarnMsg = resSix10265.WarnMsg
  6493. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6494. res2.Infcode = infocode
  6495. } else {
  6496. var result string
  6497. var requestLog string
  6498. if miConfig.MdtrtareaAdmvs == "440781" { //
  6499. 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)
  6500. } else {
  6501. if miConfig.Code == "H15049901371" {
  6502. //赤峰地区国家医保医疗类别
  6503. //职工透析:医疗类别选特殊情况门诊990502
  6504. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6505. var med_type string
  6506. if his.Insutype == "390" {
  6507. if reg_type == 14 {
  6508. med_type = "9933"
  6509. } else if reg_type == 11 {
  6510. med_type = "11"
  6511. }
  6512. } else if his.Insutype == "310" {
  6513. if reg_type == 14 {
  6514. med_type = "990502"
  6515. } else if reg_type == 11 {
  6516. med_type = "11"
  6517. }
  6518. }
  6519. 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)
  6520. } else {
  6521. 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)
  6522. }
  6523. saveLog(result, requestLog, "2203", "上传就诊信息")
  6524. var respJSON2 map[string]interface{}
  6525. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6528. return
  6529. }
  6530. userJSONBytes2, _ := json.Marshal(respJSON2)
  6531. if miConfig.Code == "H15049901371" {
  6532. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6533. utils.ErrorLog("解析失败:%v", err)
  6534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6535. return
  6536. }
  6537. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6538. res2.Output = resSix10265.Output
  6539. res2.ErrMsg = resSix10265.ErrMsg
  6540. res2.Cainfo = resSix10265.Cainfo
  6541. res2.WarnMsg = resSix10265.WarnMsg
  6542. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6543. res2.Infcode = infocode
  6544. } else {
  6545. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6546. utils.ErrorLog("解析失败:%v", err)
  6547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6548. return
  6549. }
  6550. }
  6551. }
  6552. }
  6553. if res2.Infcode != 0 {
  6554. adminUser := c.GetAdminUserInfo()
  6555. errlog := &models.HisOrderError{
  6556. UserOrgId: adminUser.CurrentOrgId,
  6557. Ctime: time.Now().Unix(),
  6558. Mtime: time.Now().Unix(),
  6559. ErrMsg: res2.ErrMsg,
  6560. Status: 1,
  6561. PatientId: id,
  6562. RecordTime: recordDateTime,
  6563. Stage: 3,
  6564. }
  6565. service.CreateErrMsgLog(errlog)
  6566. c.ServeSuccessJSON(map[string]interface{}{
  6567. "failed_code": -10,
  6568. "msg": res2.ErrMsg,
  6569. })
  6570. return
  6571. } else {
  6572. his.Diagnosis = diagnosis_id
  6573. his.SickType = sickConfig.ID
  6574. his.PType = fmt.Sprintf("%d", reg_type)
  6575. service.UpdateHisPatientThree(&his)
  6576. data := make(map[string]interface{})
  6577. if settle_accounts_type == 1 { //日结
  6578. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6579. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6580. } else {
  6581. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6582. }
  6583. data["pre"] = prescriptions
  6584. } else { //月结
  6585. start_time_str := c.GetString("start_time")
  6586. end_time_str := c.GetString("end_time")
  6587. timeLayout := "2006-01-02"
  6588. loc, _ := time.LoadLocation("Local")
  6589. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6590. if err != nil {
  6591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6592. return
  6593. }
  6594. recordStartTime := theStartTime.Unix()
  6595. start_time = recordStartTime
  6596. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6597. if err != nil {
  6598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6599. return
  6600. }
  6601. recordEndTime := theEndTime.Unix()
  6602. end_time = recordEndTime
  6603. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6604. data["pre"] = prescriptions
  6605. }
  6606. client := &http.Client{}
  6607. data["psn_no"] = his.PsnNo
  6608. data["mdtrt_id"] = his.Number
  6609. data["chrg_bchno"] = chrg_bchno
  6610. data["org_name"] = miConfig.OrgName
  6611. data["doctor"] = roles.UserName
  6612. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6613. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6614. data["fixmedins_code"] = miConfig.Code
  6615. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6616. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6617. data["dept_code"] = "15"
  6618. } else {
  6619. data["dept_code"] = department.Number
  6620. }
  6621. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6622. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6623. data["secret_key"] = miConfig.SecretKey
  6624. data["url"] = miConfig.Url
  6625. data["ak"] = miConfig.AccessKey
  6626. data["new_doctor_name"] = patientPrescription.Doctor
  6627. data["diag_code"] = sickConfig.CountryCode
  6628. data["time_stamp"] = time_stamp
  6629. data["cainfo"] = miConfig.Cainfo
  6630. var ids []int64
  6631. for _, item := range prescriptions {
  6632. ids = append(ids, item.ID)
  6633. }
  6634. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6635. if config.IsOpen == 1 { //对接了医保,走医保流程
  6636. var res ResultFour
  6637. var resFour10265 ResultFour10265
  6638. if miConfig.MdtrtareaAdmvs == "421300" {
  6639. bytesData, _ := json.Marshal(data)
  6640. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6641. resp, _ := client.Do(req)
  6642. defer resp.Body.Close()
  6643. body, ioErr := ioutil.ReadAll(resp.Body)
  6644. if ioErr != nil {
  6645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6647. return
  6648. }
  6649. var respJSON map[string]interface{}
  6650. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6653. return
  6654. }
  6655. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6656. userJSONBytes, _ := json.Marshal(respJSON)
  6657. fmt.Println("log")
  6658. fmt.Println(string(userJSONBytes))
  6659. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6660. utils.ErrorLog("解析失败:%v", err)
  6661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6662. return
  6663. }
  6664. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6665. bytesData, _ := json.Marshal(data)
  6666. var req *http.Request
  6667. if miConfig.MdtrtareaAdmvs == "320921" {
  6668. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6669. } else {
  6670. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6671. }
  6672. resp, _ := client.Do(req)
  6673. defer resp.Body.Close()
  6674. body, ioErr := ioutil.ReadAll(resp.Body)
  6675. if ioErr != nil {
  6676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6678. return
  6679. }
  6680. var respJSON map[string]interface{}
  6681. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6684. return
  6685. }
  6686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6687. userJSONBytes, _ := json.Marshal(respJSON)
  6688. fmt.Println("log")
  6689. fmt.Println(string(userJSONBytes))
  6690. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6691. utils.ErrorLog("解析失败:%v", err)
  6692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6693. return
  6694. }
  6695. res.InfRefmsgid = resFour10265.InfRefmsgid
  6696. res.Output = resFour10265.Output
  6697. res.ErrMsg = resFour10265.ErrMsg
  6698. res.Cainfo = resFour10265.Cainfo
  6699. res.WarnMsg = resFour10265.WarnMsg
  6700. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6701. res.Infcode = infocode
  6702. } else {
  6703. if miConfig.Code == "H15049901371" {
  6704. 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)
  6705. var dat map[string]interface{}
  6706. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6707. fmt.Println(dat)
  6708. } else {
  6709. fmt.Println(err)
  6710. }
  6711. saveLog(result, request_log, "2204", "上传费用明细")
  6712. userJSONBytes, _ := json.Marshal(dat)
  6713. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6714. utils.ErrorLog("解析失败:%v", err)
  6715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6716. return
  6717. }
  6718. res.InfRefmsgid = resFour10265.InfRefmsgid
  6719. res.Output = resFour10265.Output
  6720. res.ErrMsg = resFour10265.ErrMsg
  6721. res.Cainfo = resFour10265.Cainfo
  6722. res.WarnMsg = resFour10265.WarnMsg
  6723. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6724. res.Infcode = infocode
  6725. } else {
  6726. 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)
  6727. var dat map[string]interface{}
  6728. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6729. fmt.Println(dat)
  6730. } else {
  6731. fmt.Println(err)
  6732. }
  6733. saveLog(result, request_log, "2204", "上传费用明细")
  6734. userJSONBytes, _ := json.Marshal(dat)
  6735. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6736. utils.ErrorLog("解析失败:%v", err)
  6737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6738. return
  6739. }
  6740. }
  6741. }
  6742. if res.Infcode == 0 {
  6743. order := &models.HisOrder{
  6744. UserOrgId: adminUser.CurrentOrgId,
  6745. HisPatientId: his.ID,
  6746. PatientId: his.PatientId,
  6747. SettleAccountsDate: recordDateTime,
  6748. Ctime: time.Now().Unix(),
  6749. Mtime: time.Now().Unix(),
  6750. MdtrtId: his.Number,
  6751. PsnNo: his.PsnNo,
  6752. MedType: strconv.FormatInt(reg_type, 10),
  6753. Status: 1,
  6754. Number: chrg_bchno,
  6755. Infcode: res.Infcode,
  6756. WarnMsg: res.WarnMsg,
  6757. Cainfo: res.Cainfo,
  6758. ErrMsg: res.ErrMsg,
  6759. RespondTime: res.RefmsgTime,
  6760. InfRefmsgid: res.InfRefmsgid,
  6761. OrderStatus: 1,
  6762. IsMedicineInsurance: 1,
  6763. SettleType: settle_accounts_type,
  6764. SettleStartTime: start_time,
  6765. SettleEndTime: end_time,
  6766. Creator: roles.AdminUserId,
  6767. Modify: roles.AdminUserId,
  6768. PType: 2,
  6769. Diagnosis: diagnosis_id,
  6770. }
  6771. err = service.CreateOrder(order)
  6772. if err != nil {
  6773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6774. return
  6775. }
  6776. for _, item := range res.Output.Result {
  6777. temp := strings.Split(item.FeedetlSn, "-")
  6778. var advice_id int64 = 0
  6779. var project_id int64 = 0
  6780. var types int64 = 0
  6781. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6782. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6783. if temp[1] == "1" {
  6784. advice_id = id
  6785. project_id = 0
  6786. } else if temp[1] == "2" {
  6787. advice_id = 0
  6788. project_id = id
  6789. }
  6790. info := &models.HisOrderInfo{
  6791. OrderNumber: order.Number,
  6792. FeedetlSn: item.FeedetlSn,
  6793. UploadDate: time.Now().Unix(),
  6794. AdviceId: advice_id,
  6795. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6796. Cnt: item.Cnt,
  6797. Pric: float64(item.Pric),
  6798. PatientId: his.PatientId,
  6799. PricUplmtAmt: item.PricUplmtAmt,
  6800. SelfpayProp: item.SelfpayProp,
  6801. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6802. OverlmtAmt: item.OverlmtAmt,
  6803. PreselfpayAmt: item.PreselfpayAmt,
  6804. BasMednFlag: item.BasMednFlag,
  6805. MedChrgitmType: item.MedChrgitmType,
  6806. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6807. Status: 1,
  6808. Memo: item.Memo,
  6809. Mtime: time.Now().Unix(),
  6810. InscpScpAmt: item.InscpScpAmt,
  6811. DrtReimFlag: item.DrtReimFlag,
  6812. Ctime: time.Now().Unix(),
  6813. ListSpItemFlag: item.ListSpItemFlag,
  6814. ChldMedcFlag: item.ChldMedcFlag,
  6815. LmtUsedFlag: item.LmtUsedFlag,
  6816. ChrgitmLv: item.ChrgitmLv,
  6817. UserOrgId: adminUser.CurrentOrgId,
  6818. HisPatientId: his.ID,
  6819. OrderId: order.ID,
  6820. ProjectId: project_id,
  6821. Type: types,
  6822. }
  6823. service.CreateOrderInfo(info)
  6824. }
  6825. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6826. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6827. var total float64
  6828. for _, item := range prescriptions {
  6829. if item.Type == 1 { //药品
  6830. for _, subItem := range item.HisDoctorAdviceInfo {
  6831. total = total + (subItem.Price * subItem.PrescribingNumber)
  6832. }
  6833. }
  6834. if item.Type == 2 { //项目
  6835. for _, subItem := range item.HisPrescriptionProject {
  6836. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6837. total = total + (subItem.Price * cnt)
  6838. }
  6839. }
  6840. }
  6841. for _, item := range prescriptions {
  6842. for _, subItem := range item.HisAdditionalCharge {
  6843. total = total + (subItem.Price * float64(subItem.Count))
  6844. }
  6845. }
  6846. allTotal := fmt.Sprintf("%.4f", total)
  6847. if res.Infcode == 0 {
  6848. var rf []*ResultFive
  6849. json.Unmarshal([]byte(his.Iinfo), &rf)
  6850. chrg_bchno := chrg_bchno
  6851. cert_no := his.Certno
  6852. var insutypes []string
  6853. var insutype string
  6854. var is390 int = 0
  6855. var is310 int = 0
  6856. for _, item := range rf {
  6857. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6858. insutypes = append(insutypes, item.Insutype)
  6859. }
  6860. }
  6861. if len(insutypes) == 1 {
  6862. insutype = insutypes[0]
  6863. } else {
  6864. for _, i := range insutypes {
  6865. if i == "390" {
  6866. is390 = 1
  6867. }
  6868. if i == "310" {
  6869. is310 = 1
  6870. }
  6871. }
  6872. }
  6873. if is390 == 1 {
  6874. insutype = "390"
  6875. }
  6876. if is310 == 1 {
  6877. insutype = "310"
  6878. }
  6879. if len(insutypes) == 0 {
  6880. insutype = "310"
  6881. }
  6882. if len(insutypes) == 2 {
  6883. insutype = strconv.FormatInt(his.SocialType, 64)
  6884. }
  6885. //insutype = "390"
  6886. if his.IdCardType == 1 {
  6887. cert_no = his.MedicalInsuranceNumber
  6888. } else {
  6889. cert_no = his.Certno
  6890. }
  6891. var res ResultSeven
  6892. var resSeven10265 ResultSeven10265
  6893. if miConfig.MdtrtareaAdmvs == "421300" {
  6894. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6895. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6896. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6897. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6898. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6899. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6900. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6901. resp, requestErr := http.Get(api)
  6902. if requestErr != nil {
  6903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6904. return
  6905. }
  6906. body, ioErr := ioutil.ReadAll(resp.Body)
  6907. if ioErr != nil {
  6908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6910. return
  6911. }
  6912. var respJSON map[string]interface{}
  6913. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6916. return
  6917. }
  6918. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6919. result, _ := json.Marshal(respJSON)
  6920. fmt.Println("log")
  6921. fmt.Println(string(result))
  6922. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6923. utils.ErrorLog("解析失败:%v", err)
  6924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6925. return
  6926. }
  6927. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6928. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6929. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6930. bas := strings.Split(psn_info.CardInfo, "|")
  6931. if his.IdCardType == 1 {
  6932. cert_no = bas[2]
  6933. } else {
  6934. cert_no = bas[1]
  6935. }
  6936. //江苏地区国家医保医疗类别
  6937. //职工透析:医疗类别选特殊情况门诊9933
  6938. //居民血透门慢: 医疗类别选门诊慢病1402
  6939. //var med_type string
  6940. //if his.Insutype == "310" {
  6941. // if reg_type == 14 {
  6942. // med_type = "9933"
  6943. // } else if reg_type == 11 {
  6944. // med_type = "11"
  6945. //
  6946. // }
  6947. //} else if his.Insutype == "390" {
  6948. // if reg_type == 14 {
  6949. // med_type = "1402"
  6950. // } else if reg_type == 11 {
  6951. // med_type = "11"
  6952. // }
  6953. //}
  6954. var api string
  6955. if miConfig.MdtrtareaAdmvs == "320921" {
  6956. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6957. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6958. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6959. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6960. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6961. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6962. "&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
  6963. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6964. } else {
  6965. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6966. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6967. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6968. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6969. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6970. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6971. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6972. "&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
  6973. }
  6974. resp, requestErr := http.Get(api)
  6975. if requestErr != nil {
  6976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6977. return
  6978. }
  6979. body, ioErr := ioutil.ReadAll(resp.Body)
  6980. if ioErr != nil {
  6981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6983. return
  6984. }
  6985. var respJSON map[string]interface{}
  6986. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6989. return
  6990. }
  6991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6992. result, _ := json.Marshal(respJSON)
  6993. fmt.Println("log")
  6994. fmt.Println(string(result))
  6995. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6996. utils.ErrorLog("解析失败:%v", err)
  6997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6998. return
  6999. }
  7000. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7001. res.Output = resSeven10265.Output
  7002. res.ErrMsg = resSeven10265.ErrMsg
  7003. res.Cainfo = resSeven10265.Cainfo
  7004. res.WarnMsg = resSeven10265.WarnMsg
  7005. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7006. res.Infcode = infocode
  7007. } else {
  7008. var result string
  7009. var request_log string
  7010. if miConfig.Code == "H15049901371" {
  7011. //赤峰地区国家医保医疗类别
  7012. //职工透析:医疗类别选特殊情况门诊990502
  7013. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7014. var med_type string
  7015. if his.Insutype == "390" {
  7016. if reg_type == 14 {
  7017. med_type = "9933"
  7018. } else if reg_type == 11 {
  7019. med_type = "11"
  7020. }
  7021. } else if his.Insutype == "310" {
  7022. if reg_type == 14 {
  7023. med_type = "990502"
  7024. } else if reg_type == 11 {
  7025. med_type = "11"
  7026. }
  7027. }
  7028. 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)
  7029. } else {
  7030. 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)
  7031. }
  7032. var dat map[string]interface{}
  7033. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7034. fmt.Println(dat)
  7035. } else {
  7036. fmt.Println(err)
  7037. }
  7038. saveLog(result, request_log, "2206", "预结算")
  7039. //userJSONBytes, _ := json.Marshal(dat)
  7040. //
  7041. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7042. // utils.ErrorLog("解析失败:%v", err)
  7043. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7044. // return
  7045. //}
  7046. userJSONBytes, _ := json.Marshal(dat)
  7047. if miConfig.Code == "H15049901371" {
  7048. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7049. utils.ErrorLog("解析失败:%v", err)
  7050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7051. return
  7052. }
  7053. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7054. res.Output = resSeven10265.Output
  7055. res.ErrMsg = resSeven10265.ErrMsg
  7056. res.Cainfo = resSeven10265.Cainfo
  7057. res.WarnMsg = resSeven10265.WarnMsg
  7058. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7059. res.Infcode = infocode
  7060. } else {
  7061. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7062. utils.ErrorLog("解析失败:%v", err)
  7063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7064. return
  7065. }
  7066. }
  7067. }
  7068. if res.Infcode != 0 {
  7069. errlog := &models.HisOrderError{
  7070. UserOrgId: adminUser.CurrentOrgId,
  7071. Ctime: time.Now().Unix(),
  7072. Mtime: time.Now().Unix(),
  7073. Number: chrg_bchno,
  7074. ErrMsg: res.ErrMsg,
  7075. Status: 1,
  7076. PatientId: id,
  7077. RecordTime: recordDateTime,
  7078. Stage: 20,
  7079. }
  7080. service.CreateErrMsgLog(errlog)
  7081. c.ServeSuccessJSON(map[string]interface{}{
  7082. "failed_code": -10,
  7083. "msg": res.ErrMsg,
  7084. })
  7085. return
  7086. } else {
  7087. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7088. order.OrderStatus = 1
  7089. order.IsPre = 1
  7090. order.Status = 1
  7091. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7092. order.SetlId = res.Output.Setlinfo.SetlID
  7093. order.PsnNo = res.Output.Setlinfo.PsnNo
  7094. order.PsnName = res.Output.Setlinfo.PsnName
  7095. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7096. order.Certno = res.Output.Setlinfo.Certno
  7097. order.Gend = res.Output.Setlinfo.Gend
  7098. order.Naty = res.Output.Setlinfo.Naty
  7099. order.Age = res.Output.Setlinfo.Age
  7100. order.Insutype = res.Output.Setlinfo.Insutype
  7101. order.PsnType = res.Output.Setlinfo.PsnType
  7102. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7103. order.SetlTime = res.Output.Setlinfo.SetlTime
  7104. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7105. if res.Output.Setlinfo.MedType == "140101" {
  7106. order.MedType = "14"
  7107. } else {
  7108. order.MedType = res.Output.Setlinfo.MedType
  7109. }
  7110. if reg_type == 1112 {
  7111. order.MedType = "1112"
  7112. }
  7113. if reg_type == 1111 {
  7114. order.MedType = "1111"
  7115. }
  7116. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7117. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7118. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7119. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7120. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7121. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7122. order.HifpPay = res.Output.Setlinfo.HifpPay
  7123. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7124. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7125. order.HifesPay = res.Output.Setlinfo.HifesPay
  7126. order.HifobPay = res.Output.Setlinfo.HifobPay
  7127. order.MafPay = res.Output.Setlinfo.MafPay
  7128. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7129. order.OthPay = res.Output.Setlinfo.OthPay
  7130. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7131. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7132. order.AcctPay = res.Output.Setlinfo.AcctPay
  7133. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7134. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7135. order.Balc = res.Output.Setlinfo.Balc
  7136. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7137. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7138. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7139. order.ClrWay = res.Output.Setlinfo.ClrWay
  7140. order.Creator = order.Creator
  7141. order.Modify = roles.AdminUserId
  7142. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7143. detailStr := string(setlDetail)
  7144. order.SetlDetail = detailStr
  7145. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7146. err = service.UpDateOrder(order)
  7147. if err == nil {
  7148. c.ServeSuccessJSON(map[string]interface{}{
  7149. "msg": "预结算成功",
  7150. })
  7151. } else {
  7152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7153. return
  7154. }
  7155. }
  7156. } else {
  7157. adminUser := c.GetAdminUserInfo()
  7158. errlog := &models.HisOrderError{
  7159. UserOrgId: adminUser.CurrentOrgId,
  7160. Ctime: time.Now().Unix(),
  7161. Mtime: time.Now().Unix(),
  7162. ErrMsg: res.ErrMsg,
  7163. Status: 1,
  7164. PatientId: id,
  7165. RecordTime: recordDateTime,
  7166. Stage: 4,
  7167. }
  7168. service.CreateErrMsgLog(errlog)
  7169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7170. return
  7171. }
  7172. } else {
  7173. adminUser := c.GetAdminUserInfo()
  7174. errlog := &models.HisOrderError{
  7175. UserOrgId: adminUser.CurrentOrgId,
  7176. Ctime: time.Now().Unix(),
  7177. Mtime: time.Now().Unix(),
  7178. ErrMsg: res.ErrMsg,
  7179. Status: 1,
  7180. PatientId: id,
  7181. RecordTime: recordDateTime,
  7182. Stage: 4,
  7183. }
  7184. service.CreateErrMsgLog(errlog)
  7185. c.ServeSuccessJSON(map[string]interface{}{
  7186. "failed_code": -10,
  7187. "msg": res.ErrMsg,
  7188. })
  7189. return
  7190. }
  7191. }
  7192. }
  7193. }
  7194. //func (c *HisApiController) GetSettleInfo() {
  7195. // id, _ := c.GetInt64("id")
  7196. // order_id, _ := c.GetInt64("order_id")
  7197. //
  7198. // record_time := c.GetString("record_time")
  7199. // pay_way, _ := c.GetInt64("pay_way")
  7200. // pay_price, _ := c.GetFloat("pay_price")
  7201. // pay_card_no := c.GetString("pay_card_no")
  7202. // discount_price, _ := c.GetFloat("discount_price")
  7203. // preferential_price, _ := c.GetFloat("preferential_price")
  7204. // reality_price, _ := c.GetFloat("reality_price")
  7205. // found_price, _ := c.GetFloat("found_price")
  7206. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7207. // private_price, _ := c.GetFloat("private_price")
  7208. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7209. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7210. //
  7211. // timeLayout := "2006-01-02"
  7212. // loc, _ := time.LoadLocation("Local")
  7213. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7214. // if err != nil {
  7215. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7216. // return
  7217. // }
  7218. // recordDateTime := theTime.Unix()
  7219. // adminUser := c.GetAdminUserInfo()
  7220. //
  7221. // var prescriptions []*models.HisPrescription
  7222. //
  7223. // data := make(map[string]interface{})
  7224. // if settle_accounts_type == 1 { //日结
  7225. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7226. // data["pre"] = prescriptions
  7227. //
  7228. // } else { //月结
  7229. // start_time_str := c.GetString("start_time")
  7230. // end_time_str := c.GetString("end_time")
  7231. // timeLayout := "2006-01-02"
  7232. // loc, _ := time.LoadLocation("Local")
  7233. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7234. // if err != nil {
  7235. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7236. // return
  7237. // }
  7238. // recordStartTime := theStartTime.Unix()
  7239. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7240. // if err != nil {
  7241. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7242. // return
  7243. // }
  7244. // recordEndTime := theEndTime.Unix()
  7245. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7246. // data["pre"] = prescriptions
  7247. //
  7248. // }
  7249. //
  7250. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7251. //
  7252. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7253. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7254. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7255. // strconv.FormatInt(his.PatientId, 10)
  7256. //
  7257. // order_src, _ := service.GetHisOrderByID(order_id)
  7258. //
  7259. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7260. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7261. //
  7262. // var total float64
  7263. // for _, item := range prescriptions {
  7264. // if item.Type == 1 { //药品
  7265. // for _, subItem := range item.HisDoctorAdviceInfo {
  7266. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7267. // }
  7268. // }
  7269. // if item.Type == 2 { //项目
  7270. // for _, subItem := range item.HisPrescriptionProject {
  7271. // total = total + (subItem.Price * float64(subItem.Count))
  7272. // }
  7273. // }
  7274. // }
  7275. //
  7276. // for _, item := range prescriptions {
  7277. // for _, subItem := range item.HisAdditionalCharge {
  7278. // total = total + (subItem.Price * float64(subItem.Count))
  7279. // }
  7280. // }
  7281. //
  7282. // allTotal := fmt.Sprintf("%.2f", total)
  7283. // var rf []*ResultFive
  7284. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7285. // psn_no := order_src.PsnNo
  7286. // mdtrt_id := order_src.MdtrtId
  7287. // chrg_bchno := order_src.Number
  7288. // cert_no := order_src.Certno
  7289. // insutype := rf[0].Insutype
  7290. //
  7291. // if his.IdCardType == 1 {
  7292. // cert_no = his.MedicalInsuranceNumber
  7293. // } else {
  7294. // cert_no = his.Certno
  7295. // }
  7296. //
  7297. // 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)
  7298. // var dat map[string]interface{}
  7299. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7300. // fmt.Println(dat)
  7301. // } else {
  7302. // fmt.Println(err)
  7303. // }
  7304. //
  7305. // userJSONBytes, _ := json.Marshal(dat)
  7306. //
  7307. //
  7308. //
  7309. // var res ResultSeven
  7310. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7311. // utils.ErrorLog("解析失败:%v", err)
  7312. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7313. // return
  7314. // }
  7315. // if res.Infcode == -1 {
  7316. // errlog := &models.HisOrderError{
  7317. // UserOrgId: adminUser.CurrentOrgId,
  7318. // Ctime: time.Now().Unix(),
  7319. // Mtime: time.Now().Unix(),
  7320. // Number: chrg_bchno,
  7321. // ErrMsg: res.ErrMsg,
  7322. // Status: 1,
  7323. // PatientId: id,
  7324. // RecordTime: recordDateTime,
  7325. // Stage: 6,
  7326. // }
  7327. // service.CreateErrMsgLog(errlog)
  7328. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7329. // return
  7330. // } else {
  7331. // order_src.OrderStatus = 2
  7332. // order_src.PayWay = pay_way
  7333. // order_src.PayPrice = pay_price
  7334. // order_src.PayCardNo = pay_card_no
  7335. // order_src.DiscountPrice = discount_price
  7336. // order_src.PreferentialPrice = preferential_price
  7337. // order_src.RealityPrice = reality_price
  7338. // order_src.FoundPrice = found_price
  7339. // order_src.MedicalInsurancePrice = medical_insurance_price
  7340. // order_src.PrivatePrice = private_price
  7341. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7342. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7343. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7344. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7345. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7346. // order_src.Certno = res.Output.Setlinfo.Certno
  7347. // order_src.Gend = res.Output.Setlinfo.Gend
  7348. // order_src.Naty = res.Output.Setlinfo.Naty
  7349. // order_src.Age = res.Output.Setlinfo.Age
  7350. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7351. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7352. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7353. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7354. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7355. // order_src.MedType = res.Output.Setlinfo.MedType
  7356. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7357. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7358. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7359. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7360. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7361. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7362. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7363. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7364. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7365. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7366. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7367. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7368. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7369. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7370. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7371. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7372. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7373. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7374. // order_src.Balc = res.Output.Setlinfo.Balc
  7375. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7376. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7377. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7378. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7379. // order_src.Creator = order_src.Creator
  7380. // order_src.Modify = roles.ID
  7381. // order_src.RequestLog = src_resquest
  7382. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7383. // detailStr := string(setlDetail)
  7384. // order_src.SetlDetail = detailStr
  7385. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7386. // err = service.UpDateOrder(order_src)
  7387. //
  7388. // if err == nil {
  7389. // c.ServeSuccessJSON(map[string]interface{}{
  7390. // "msg": "结算成功",
  7391. // })
  7392. // } else {
  7393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7394. // return
  7395. // }
  7396. // }
  7397. // }
  7398. //}
  7399. //退款
  7400. func (c *HisApiController) Refund() {
  7401. order_id, _ := c.GetInt64("order_id")
  7402. admin_user_id, _ := c.GetInt64("admin_user_id")
  7403. adminUser := c.GetAdminUserInfo()
  7404. var order models.HisOrder
  7405. order, _ = service.GetHisOrderByID(order_id)
  7406. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7407. if order.ID == 0 {
  7408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7409. return
  7410. }
  7411. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7412. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7413. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7414. if config.IsOpen == 1 { //对接了医保,走医保流程
  7415. var res ResultSixteen
  7416. var resSixteen10265 ResultSixteen10265
  7417. var src_resquest string
  7418. var result string
  7419. if miConfig.MdtrtareaAdmvs == "421300" {
  7420. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7421. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7422. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7423. resp3, requestErr3 := http.Get(api3)
  7424. if requestErr3 != nil {
  7425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7426. return
  7427. }
  7428. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7429. if ioErr3 != nil {
  7430. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7432. return
  7433. }
  7434. var respJSON3 map[string]interface{}
  7435. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7438. return
  7439. }
  7440. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7441. userJSONBytes3, _ := json.Marshal(respJSON3)
  7442. fmt.Println("log")
  7443. fmt.Println(string(userJSONBytes3))
  7444. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7445. utils.ErrorLog("解析失败:%v", err)
  7446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7447. return
  7448. }
  7449. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7450. var api3 string
  7451. if miConfig.MdtrtareaAdmvs == "320921" {
  7452. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7453. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7454. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7455. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7456. } else {
  7457. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7458. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7459. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7460. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7461. }
  7462. resp3, requestErr3 := http.Get(api3)
  7463. if requestErr3 != nil {
  7464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7465. return
  7466. }
  7467. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7468. if ioErr3 != nil {
  7469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7471. return
  7472. }
  7473. var respJSON3 map[string]interface{}
  7474. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7477. return
  7478. }
  7479. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7480. userJSONBytes3, _ := json.Marshal(respJSON3)
  7481. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7482. utils.ErrorLog("解析失败:%v", err)
  7483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7484. return
  7485. }
  7486. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7487. res.Output = resSixteen10265.Output
  7488. res.ErrMsg = resSixteen10265.ErrMsg
  7489. res.Cainfo = resSixteen10265.Cainfo
  7490. res.WarnMsg = resSixteen10265.WarnMsg
  7491. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7492. res.Infcode = infocode
  7493. } else {
  7494. if miConfig.Code == "H15049901371" {
  7495. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7496. var dat map[string]interface{}
  7497. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7498. fmt.Println(dat)
  7499. } else {
  7500. fmt.Println(err)
  7501. }
  7502. saveLog(result, src_resquest, "2208", "退费")
  7503. userJSONBytes, _ := json.Marshal(dat)
  7504. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7505. utils.ErrorLog("解析失败:%v", err)
  7506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7507. return
  7508. }
  7509. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7510. res.Output = resSixteen10265.Output
  7511. res.ErrMsg = resSixteen10265.ErrMsg
  7512. res.Cainfo = resSixteen10265.Cainfo
  7513. res.WarnMsg = resSixteen10265.WarnMsg
  7514. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7515. res.Infcode = infocode
  7516. } else {
  7517. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7518. var dat map[string]interface{}
  7519. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7520. fmt.Println(dat)
  7521. } else {
  7522. fmt.Println(err)
  7523. }
  7524. saveLog(result, src_resquest, "2208", "退费")
  7525. userJSONBytes, _ := json.Marshal(dat)
  7526. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7527. utils.ErrorLog("解析失败:%v", err)
  7528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7529. return
  7530. }
  7531. }
  7532. }
  7533. if res.Infcode == 0 {
  7534. var res2 ResultSix
  7535. var resSix10265 ResultSix10265
  7536. if miConfig.MdtrtareaAdmvs == "421300" {
  7537. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7538. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7539. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7540. resp3, requestErr3 := http.Get(api3)
  7541. if requestErr3 != nil {
  7542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7543. return
  7544. }
  7545. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7546. if ioErr3 != nil {
  7547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7549. return
  7550. }
  7551. var respJSON3 map[string]interface{}
  7552. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7555. return
  7556. }
  7557. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7558. userJSONBytes3, _ := json.Marshal(respJSON3)
  7559. fmt.Println("log")
  7560. fmt.Println(string(userJSONBytes3))
  7561. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7562. utils.ErrorLog("解析失败:%v", err)
  7563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7564. return
  7565. }
  7566. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7567. var api3 string
  7568. if miConfig.MdtrtareaAdmvs == "320921" {
  7569. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7570. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7571. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7572. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7573. } else {
  7574. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7575. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7576. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7577. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7578. }
  7579. resp3, requestErr3 := http.Get(api3)
  7580. if requestErr3 != nil {
  7581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7582. return
  7583. }
  7584. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7585. if ioErr3 != nil {
  7586. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7588. return
  7589. }
  7590. var respJSON3 map[string]interface{}
  7591. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7594. return
  7595. }
  7596. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7597. userJSONBytes3, _ := json.Marshal(respJSON3)
  7598. fmt.Println("log")
  7599. fmt.Println(string(userJSONBytes3))
  7600. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7601. utils.ErrorLog("解析失败:%v", err)
  7602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7603. return
  7604. }
  7605. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7606. res2.Output = resSix10265.Output
  7607. res2.ErrMsg = resSix10265.ErrMsg
  7608. res2.Cainfo = resSix10265.Cainfo
  7609. res2.WarnMsg = resSix10265.WarnMsg
  7610. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7611. res2.Infcode = infocode
  7612. } else {
  7613. if miConfig.Code == "H15049901371" {
  7614. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7615. var dat map[string]interface{}
  7616. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7617. fmt.Println(dat)
  7618. } else {
  7619. fmt.Println(err)
  7620. }
  7621. saveLog(result2, src_request, "2205", "撤销明细")
  7622. userJSONBytes, _ := json.Marshal(dat)
  7623. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7624. utils.ErrorLog("解析失败:%v", err)
  7625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7626. return
  7627. }
  7628. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7629. res2.Output = resSix10265.Output
  7630. res2.ErrMsg = resSix10265.ErrMsg
  7631. res2.Cainfo = resSix10265.Cainfo
  7632. res2.WarnMsg = resSix10265.WarnMsg
  7633. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7634. res2.Infcode = infocode
  7635. } else {
  7636. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7637. var dat map[string]interface{}
  7638. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7639. fmt.Println(dat)
  7640. } else {
  7641. fmt.Println(err)
  7642. }
  7643. saveLog(result2, src_request, "2205", "撤销明细")
  7644. userJSONBytes, _ := json.Marshal(dat)
  7645. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7646. utils.ErrorLog("解析失败:%v", err)
  7647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7648. return
  7649. }
  7650. }
  7651. }
  7652. if res2.Infcode == 0 {
  7653. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7654. if err == nil {
  7655. c.ServeSuccessJSON(map[string]interface{}{
  7656. "msg": "退费成功",
  7657. })
  7658. } else {
  7659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7660. return
  7661. }
  7662. } else {
  7663. c.ServeSuccessJSON(map[string]interface{}{
  7664. "code": -10,
  7665. "msg": res2.ErrMsg,
  7666. })
  7667. }
  7668. } else {
  7669. c.ServeSuccessJSON(map[string]interface{}{
  7670. "code": -10,
  7671. "msg": res.ErrMsg,
  7672. })
  7673. }
  7674. }
  7675. }
  7676. func (c *HisApiController) RefundNumber() {
  7677. record_time := c.GetString("record_time")
  7678. //patient_id, _ := c.GetInt64("patient_id")
  7679. admin_user_id, _ := c.GetInt64("admin_user_id")
  7680. his_patient_id, _ := c.GetInt64("id")
  7681. timeLayout := "2006-01-02"
  7682. loc, _ := time.LoadLocation("Local")
  7683. adminUser := c.GetAdminUserInfo()
  7684. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7685. fmt.Println(err)
  7686. if err != nil {
  7687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7688. return
  7689. }
  7690. recordDateTime := theTime.Unix()
  7691. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7692. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7693. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7694. //order, _ := service.GetHisOrderByID(order_id)
  7695. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7696. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7697. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7698. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7699. if count > 0 {
  7700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7701. return
  7702. }
  7703. if config.IsOpen == 1 { //对接了医保,走医保流程
  7704. var res2 ResultSix
  7705. var resSix10265 ResultSix10265
  7706. if miConfig.MdtrtareaAdmvs == "421300" {
  7707. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7708. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7709. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7710. resp3, requestErr3 := http.Get(api3)
  7711. if requestErr3 != nil {
  7712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7713. return
  7714. }
  7715. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7716. if ioErr3 != nil {
  7717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7719. return
  7720. }
  7721. var respJSON3 map[string]interface{}
  7722. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7725. return
  7726. }
  7727. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7728. userJSONBytes3, _ := json.Marshal(respJSON3)
  7729. fmt.Println("log")
  7730. fmt.Println(string(userJSONBytes3))
  7731. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7732. utils.ErrorLog("解析失败:%v", err)
  7733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7734. return
  7735. }
  7736. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7737. var api3 string
  7738. if miConfig.MdtrtareaAdmvs == "320921" {
  7739. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7740. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7741. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7742. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7743. } else {
  7744. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7745. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7746. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7747. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7748. }
  7749. resp3, requestErr3 := http.Get(api3)
  7750. if requestErr3 != nil {
  7751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7752. return
  7753. }
  7754. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7755. if ioErr3 != nil {
  7756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7758. return
  7759. }
  7760. var respJSON3 map[string]interface{}
  7761. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7764. return
  7765. }
  7766. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7767. userJSONBytes3, _ := json.Marshal(respJSON3)
  7768. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7769. utils.ErrorLog("解析失败:%v", err)
  7770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7771. return
  7772. }
  7773. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7774. res2.Output = resSix10265.Output
  7775. res2.ErrMsg = resSix10265.ErrMsg
  7776. res2.Cainfo = resSix10265.Cainfo
  7777. res2.WarnMsg = resSix10265.WarnMsg
  7778. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7779. res2.Infcode = infocode
  7780. } else {
  7781. var api3 string
  7782. if miConfig.Code == "H15049901371" {
  7783. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7784. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7785. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7786. } else {
  7787. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7788. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7789. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7790. }
  7791. resp3, requestErr3 := http.Get(api3)
  7792. if requestErr3 != nil {
  7793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7794. return
  7795. }
  7796. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7797. if ioErr3 != nil {
  7798. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7800. return
  7801. }
  7802. var respJSON3 map[string]interface{}
  7803. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7806. return
  7807. }
  7808. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7809. userJSONBytes3, _ := json.Marshal(respJSON3)
  7810. if miConfig.Code == "H15049901371" {
  7811. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7812. utils.ErrorLog("解析失败:%v", err)
  7813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7814. return
  7815. }
  7816. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7817. res2.Output = resSix10265.Output
  7818. res2.ErrMsg = resSix10265.ErrMsg
  7819. res2.Cainfo = resSix10265.Cainfo
  7820. res2.WarnMsg = resSix10265.WarnMsg
  7821. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7822. res2.Infcode = infocode
  7823. } else {
  7824. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7825. utils.ErrorLog("解析失败:%v", err)
  7826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7827. return
  7828. }
  7829. }
  7830. }
  7831. if res2.Infcode == 0 {
  7832. if err == nil {
  7833. c.ServeSuccessJSON(map[string]interface{}{
  7834. "msg": "退号成功",
  7835. })
  7836. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7837. } else {
  7838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7839. return
  7840. }
  7841. } else {
  7842. c.ServeSuccessJSON(map[string]interface{}{
  7843. "code": -10,
  7844. "msg": res2.ErrMsg,
  7845. })
  7846. }
  7847. } else {
  7848. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7849. //if err == nil {
  7850. // c.ServeSuccessJSON(map[string]interface{}{
  7851. // "msg": "退费成功",
  7852. // })
  7853. //} else {
  7854. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7855. // return
  7856. //}
  7857. }
  7858. }
  7859. func (c *HisApiController) RefundDetail() {
  7860. order_id, _ := c.GetInt64("order_id")
  7861. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7862. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7863. number := c.GetString("number")
  7864. record_time := c.GetString("record_time")
  7865. patient_id, _ := c.GetInt64("patient_id")
  7866. //med_type, _ := c.GetInt64("med_type")
  7867. timeLayout := "2006-01-02"
  7868. loc, _ := time.LoadLocation("Local")
  7869. adminUser := c.GetAdminUserInfo()
  7870. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7871. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7872. fmt.Println(err)
  7873. if err != nil {
  7874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7875. return
  7876. }
  7877. recordDateTime := theTime.Unix()
  7878. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7879. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7880. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7881. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7882. var order models.HisOrder
  7883. order, _ = service.GetHisOrderByID(order_id)
  7884. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7885. if config.IsOpen == 1 { //对接了医保,走医保流程
  7886. var res2 ResultSix
  7887. if miConfig.MdtrtareaAdmvs == "421300" {
  7888. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7889. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7890. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7891. resp3, requestErr3 := http.Get(api3)
  7892. if requestErr3 != nil {
  7893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7894. return
  7895. }
  7896. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7897. if ioErr3 != nil {
  7898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7900. return
  7901. }
  7902. var respJSON3 map[string]interface{}
  7903. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7906. return
  7907. }
  7908. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7909. userJSONBytes3, _ := json.Marshal(respJSON3)
  7910. fmt.Println("log")
  7911. fmt.Println(string(userJSONBytes3))
  7912. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7913. utils.ErrorLog("解析失败:%v", err)
  7914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7915. return
  7916. }
  7917. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7918. if err == nil {
  7919. c.ServeSuccessJSON(map[string]interface{}{
  7920. "msg": "撤销明细成功",
  7921. })
  7922. return
  7923. } else {
  7924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7925. return
  7926. }
  7927. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7928. var resSix10265 ResultSix10265
  7929. var api3 string
  7930. if miConfig.MdtrtareaAdmvs == "320921" {
  7931. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7932. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7933. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7934. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7935. } else {
  7936. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7937. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7938. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7939. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7940. }
  7941. resp3, requestErr3 := http.Get(api3)
  7942. if requestErr3 != nil {
  7943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7944. return
  7945. }
  7946. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7947. if ioErr3 != nil {
  7948. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7950. return
  7951. }
  7952. var respJSON3 map[string]interface{}
  7953. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7956. return
  7957. }
  7958. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7959. userJSONBytes3, _ := json.Marshal(respJSON3)
  7960. fmt.Println("log")
  7961. fmt.Println(string(userJSONBytes3))
  7962. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7963. utils.ErrorLog("解析失败:%v", err)
  7964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7965. return
  7966. }
  7967. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7968. res2.Output = resSix10265.Output
  7969. res2.ErrMsg = resSix10265.ErrMsg
  7970. res2.Cainfo = resSix10265.Cainfo
  7971. res2.WarnMsg = resSix10265.WarnMsg
  7972. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7973. res2.Infcode = infocode
  7974. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7975. if err == nil {
  7976. c.ServeSuccessJSON(map[string]interface{}{
  7977. "msg": "撤销明细成功",
  7978. })
  7979. return
  7980. } else {
  7981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7982. return
  7983. }
  7984. } else {
  7985. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7986. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7987. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7988. resp2, requestErr2 := http.Get(api2)
  7989. if requestErr2 != nil {
  7990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7991. return
  7992. }
  7993. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7994. if ioErr2 != nil {
  7995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7997. return
  7998. }
  7999. var respJSON2 map[string]interface{}
  8000. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8003. return
  8004. }
  8005. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8006. if err == nil {
  8007. c.ServeSuccessJSON(map[string]interface{}{
  8008. "msg": "撤销明细成功",
  8009. })
  8010. return
  8011. } else {
  8012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8013. return
  8014. }
  8015. }
  8016. } else {
  8017. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8018. if err == nil {
  8019. c.ServeSuccessJSON(map[string]interface{}{
  8020. "msg": "退费成功",
  8021. })
  8022. } else {
  8023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8024. return
  8025. }
  8026. }
  8027. }
  8028. //对账
  8029. func (c *HisApiController) GetCheckAccount() {
  8030. start_time := c.GetString("start_time")
  8031. end_time := c.GetString("end_time")
  8032. insutype := c.GetString("insutype")
  8033. clr_type := c.GetString("clr_type")
  8034. clr_org := c.GetString("clr_optins")
  8035. admin_user_id, _ := c.GetInt64("admin_user_id")
  8036. adminUser := c.GetAdminUserInfo()
  8037. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8038. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8039. if len(clr_org) == 0 {
  8040. clr_org = miConfig.MdtrtareaAdmvs
  8041. }
  8042. timeLayout := "2006-01-02"
  8043. loc, _ := time.LoadLocation("Local")
  8044. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8045. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8046. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8047. fixmedins_setl_cnt := int64(len(orders))
  8048. var medfee_sumamt float64
  8049. var acct_pay float64
  8050. var fund_pay_sumamt float64
  8051. for _, item := range orders {
  8052. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8053. acct_pay = acct_pay + item.AcctPay
  8054. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8055. }
  8056. var user_name string
  8057. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8058. if role.ID == 0 {
  8059. user_name = "xxx"
  8060. } else {
  8061. user_name = role.UserName
  8062. }
  8063. var res ResultEight
  8064. var res10188 ResultEightFor10188
  8065. if config.IsOpen == 1 {
  8066. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8067. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8068. "insutype=" + insutype +
  8069. "&clr_type=" + "11" +
  8070. "&setl_optins=" + clr_org +
  8071. "&stmt_begndate=" + start_time +
  8072. "&stm_enddate=" + end_time +
  8073. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8074. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8075. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8076. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8077. "&fixmedins_code=" + miConfig.Code +
  8078. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8079. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8080. "&secret_key=" + miConfig.SecretKey +
  8081. "&org_name=" + miConfig.OrgName +
  8082. "&doctor=" + user_name +
  8083. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8084. fmt.Println(api)
  8085. resp, requestErr := http.Get(api)
  8086. if requestErr != nil {
  8087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8088. return
  8089. }
  8090. body, ioErr := ioutil.ReadAll(resp.Body)
  8091. fmt.Println(body)
  8092. if ioErr != nil {
  8093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8095. return
  8096. }
  8097. var respJSON map[string]interface{}
  8098. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8101. return
  8102. }
  8103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8104. userJSONBytes, _ := json.Marshal(respJSON)
  8105. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8106. utils.ErrorLog("解析失败:%v", err)
  8107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8108. return
  8109. }
  8110. res.InfRefmsgid = res10188.InfRefmsgid
  8111. res.Output = res10188.Output
  8112. res.ErrMsg = res10188.ErrMsg
  8113. res.Cainfo = res10188.Cainfo
  8114. res.WarnMsg = res10188.WarnMsg
  8115. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8116. res.Infcode = infocode
  8117. } else {
  8118. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8119. "insutype=" + insutype +
  8120. "&clr_type=" + clr_type +
  8121. "&setl_optins=" + clr_org +
  8122. "&stmt_begndate=" + start_time +
  8123. "&stm_enddate=" + end_time +
  8124. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8125. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8126. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8127. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8128. "&fixmedins_code=" + miConfig.Code +
  8129. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8130. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8131. "&secret_key=" + miConfig.SecretKey +
  8132. "&org_name=" + miConfig.OrgName +
  8133. "&doctor=" + user_name
  8134. fmt.Println(api)
  8135. resp, requestErr := http.Get(api)
  8136. if requestErr != nil {
  8137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8138. return
  8139. }
  8140. body, ioErr := ioutil.ReadAll(resp.Body)
  8141. fmt.Println(body)
  8142. if ioErr != nil {
  8143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8145. return
  8146. }
  8147. var respJSON map[string]interface{}
  8148. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8151. return
  8152. }
  8153. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8154. userJSONBytes, _ := json.Marshal(respJSON)
  8155. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8156. utils.ErrorLog("解析失败:%v", err)
  8157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8158. return
  8159. }
  8160. }
  8161. if res.Infcode == 0 {
  8162. if res.Output.Stmtinfo.StmtRslt == "0" {
  8163. micc := &models.MedicalInsuranceCostCompare{
  8164. StartTime: startime.Unix(),
  8165. EndTime: endtime.Unix(),
  8166. Insutype: insutype,
  8167. CheckType: 1,
  8168. Num: fixmedins_setl_cnt,
  8169. Mtime: time.Now().Unix(),
  8170. Status: 1,
  8171. UserOrgId: adminUser.CurrentOrgId,
  8172. CostTotal: medfee_sumamt,
  8173. FuncTotal: fund_pay_sumamt,
  8174. PsnPay: acct_pay,
  8175. Creator: admin_user_id,
  8176. Ctime: time.Now().Unix(),
  8177. ClrType: clr_type,
  8178. }
  8179. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8180. if err == nil {
  8181. c.ServeSuccessJSON(map[string]interface{}{
  8182. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8183. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8184. })
  8185. } else {
  8186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8187. }
  8188. } else {
  8189. c.ServeSuccessJSON(map[string]interface{}{
  8190. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8191. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8192. })
  8193. }
  8194. } else {
  8195. c.ServeSuccessJSON(map[string]interface{}{
  8196. "code": -10,
  8197. "msg": res.ErrMsg,
  8198. })
  8199. }
  8200. }
  8201. }
  8202. func (c *HisApiController) Check310() {
  8203. adminUser := c.GetAdminUserInfo()
  8204. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8205. var user_name string
  8206. user_name = "高慧裕"
  8207. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8208. "insutype=" + "310" +
  8209. "&clr_type=" + "" +
  8210. "&setl_optins=" + "441202" +
  8211. "&stmt_begndate=" + "2022-03-01" +
  8212. "&stm_enddate=" + "2022-03-31" +
  8213. "&medfee_sumamt=" + "194930.12" +
  8214. "&fund_pay_sumamt=" + "188741.46" +
  8215. "&acct_pay=" + "0" +
  8216. "&fixmedins_setl_cnt=" + "452" +
  8217. "&fixmedins_code=" + miConfig.Code +
  8218. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8219. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8220. "&secret_key=" + miConfig.SecretKey +
  8221. "&org_name=" + miConfig.OrgName +
  8222. "&doctor=" + user_name
  8223. fmt.Println(api)
  8224. resp, requestErr := http.Get(api)
  8225. if requestErr != nil {
  8226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8227. return
  8228. }
  8229. body, ioErr := ioutil.ReadAll(resp.Body)
  8230. fmt.Println(body)
  8231. if ioErr != nil {
  8232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8234. return
  8235. }
  8236. var respJSON map[string]interface{}
  8237. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8240. return
  8241. }
  8242. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8243. userJSONBytes, _ := json.Marshal(respJSON)
  8244. var res ResultEight
  8245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8246. utils.ErrorLog("解析失败:%v", err)
  8247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8248. return
  8249. }
  8250. }
  8251. func (c *HisApiController) Check390() {
  8252. adminUser := c.GetAdminUserInfo()
  8253. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8254. var user_name string
  8255. user_name = "高慧裕"
  8256. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8257. "insutype=" + "390" +
  8258. "&clr_type=" + "" +
  8259. "&setl_optins=" + "441202" +
  8260. "&stmt_begndate=" + "2022-03-01" +
  8261. "&stm_enddate=" + "2022-03-31" +
  8262. "&medfee_sumamt=" + "1068448.89" +
  8263. "&fund_pay_sumamt=" + "1014677.62" +
  8264. "&acct_pay=" + "0" +
  8265. "&fixmedins_setl_cnt=" + "1950" +
  8266. "&fixmedins_code=" + miConfig.Code +
  8267. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8268. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8269. "&secret_key=" + miConfig.SecretKey +
  8270. "&org_name=" + miConfig.OrgName +
  8271. "&doctor=" + user_name
  8272. fmt.Println(api)
  8273. resp, requestErr := http.Get(api)
  8274. if requestErr != nil {
  8275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8276. return
  8277. }
  8278. body, ioErr := ioutil.ReadAll(resp.Body)
  8279. fmt.Println(body)
  8280. if ioErr != nil {
  8281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8283. return
  8284. }
  8285. var respJSON map[string]interface{}
  8286. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8289. return
  8290. }
  8291. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8292. userJSONBytes, _ := json.Marshal(respJSON)
  8293. var res ResultEight
  8294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8295. utils.ErrorLog("解析失败:%v", err)
  8296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8297. return
  8298. }
  8299. }
  8300. //对账明细
  8301. func (c *HisApiController) GetCheckDetailAccount() {
  8302. start_time := c.GetString("start_time")
  8303. end_time := c.GetString("end_time")
  8304. admin_user_id, _ := c.GetInt64("admin_user_id")
  8305. adminUser := c.GetAdminUserInfo()
  8306. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8307. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8308. timeLayout := "2006-01-02"
  8309. loc, _ := time.LoadLocation("Local")
  8310. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8311. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8312. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8313. Mkdir(miConfig.OrgName)
  8314. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  8315. file_name := file + ".txt"
  8316. zip_name := file + ".zip"
  8317. zip_path := miConfig.OrgName + "/" + zip_name
  8318. file_path := miConfig.OrgName + "/" + file_name
  8319. decimal.DivisionPrecision = 2
  8320. var medfee_sumamt float64
  8321. var psn_cash_pay float64
  8322. var fund_pay_sumamt float64
  8323. fixmedins_setl_cnt := int64(len(orders))
  8324. for _, item := range orders {
  8325. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8326. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8327. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8328. }
  8329. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8330. defer f.Close()
  8331. if err != nil {
  8332. fmt.Println(err.Error())
  8333. } else {
  8334. for _, item := range orders {
  8335. var refd_setl_flag string
  8336. if item.OrderStatus == 2 {
  8337. refd_setl_flag = "0"
  8338. var str string
  8339. str = item.SetlId + " " +
  8340. item.MdtrtId + " " +
  8341. item.PsnNo + " " +
  8342. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8343. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8344. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8345. _, err = f.Write([]byte(str))
  8346. }
  8347. if item.OrderStatus == 3 {
  8348. var str string
  8349. str = item.SetlId + " " +
  8350. item.MdtrtId + " " +
  8351. item.PsnNo + " " +
  8352. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8353. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8354. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8355. _, err = f.Write([]byte(str))
  8356. var str2 string
  8357. str2 = item.SetlId + " " +
  8358. item.MdtrtId + " " +
  8359. item.PsnNo + " " +
  8360. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8361. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8362. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8363. _, err = f.Write([]byte(str2))
  8364. }
  8365. }
  8366. }
  8367. Zip(file_path, zip_path)
  8368. fmt.Println(ReadFile(zip_path))
  8369. fmt.Println(string(ReadFile(zip_path)))
  8370. if config.IsOpen == 1 {
  8371. var user_name string
  8372. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8373. if role.ID == 0 {
  8374. user_name = "管理员"
  8375. } else {
  8376. user_name = role.UserName
  8377. }
  8378. baseParams := models.BaseParams{
  8379. SecretKey: miConfig.SecretKey,
  8380. FixmedinsCode: miConfig.Code,
  8381. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8382. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8383. OrgName: miConfig.OrgName,
  8384. Doctor: user_name,
  8385. }
  8386. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  8387. var dat map[string]interface{}
  8388. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8389. fmt.Println(dat)
  8390. } else {
  8391. fmt.Println(err)
  8392. }
  8393. userJSONBytes, _ := json.Marshal(dat)
  8394. var res ResultNine
  8395. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8396. utils.ErrorLog("解析失败:%v", err)
  8397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8398. return
  8399. }
  8400. if res.Infcode == 0 {
  8401. fileNo := res.Output.FileQuryNo
  8402. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8403. "file_qury_no=" + fileNo +
  8404. "&setl_optins=" + "定点医保中心" +
  8405. "&stmt_begndate=" + start_time +
  8406. "&stm_enddate=" + end_time +
  8407. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8408. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8409. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8410. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8411. "&fixmedins_code=" + miConfig.Code +
  8412. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8413. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8414. "&secret_key=" + miConfig.SecretKey +
  8415. "&org_name=" + miConfig.OrgName +
  8416. "&doctor=" + user_name
  8417. resp, requestErr := http.Get(api)
  8418. if requestErr != nil {
  8419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8420. return
  8421. }
  8422. body, ioErr := ioutil.ReadAll(resp.Body)
  8423. if ioErr != nil {
  8424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8426. return
  8427. }
  8428. var respJSON map[string]interface{}
  8429. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8432. return
  8433. }
  8434. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8435. userJSONBytes, _ := json.Marshal(respJSON)
  8436. var res ResultTen
  8437. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8438. utils.ErrorLog("解析失败:%v", err)
  8439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8440. return
  8441. }
  8442. if res.Infcode == 0 {
  8443. service.Gdyb9102(baseParams, zip_name, fileNo)
  8444. micc := &models.MedicalInsuranceCostCompare{
  8445. StartTime: startime.Unix(),
  8446. EndTime: endtime.Unix(),
  8447. Insutype: "0",
  8448. CheckType: 2,
  8449. Num: fixmedins_setl_cnt,
  8450. Mtime: time.Now().Unix(),
  8451. Status: 1,
  8452. UserOrgId: adminUser.CurrentOrgId,
  8453. CostTotal: medfee_sumamt,
  8454. FuncTotal: fund_pay_sumamt,
  8455. PsnPay: psn_cash_pay,
  8456. Creator: admin_user_id,
  8457. Ctime: time.Now().Unix(),
  8458. }
  8459. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8460. c.ServeSuccessJSON(map[string]interface{}{
  8461. "msg": "明细对账成功",
  8462. })
  8463. }
  8464. } else {
  8465. }
  8466. }
  8467. }
  8468. type CustomOrderInfo struct {
  8469. Name string
  8470. Spec string
  8471. Unit string
  8472. Count float64
  8473. Price float64
  8474. Total float64
  8475. }
  8476. func (c *HisApiController) GetSettleAccounts() {
  8477. //id, _ := c.GetInt64("id")
  8478. //record_time := c.GetString("record_time")
  8479. order_id, _ := c.GetInt64("order_id")
  8480. admin_user_id, _ := c.GetInt64("admin_user_id")
  8481. //timeLayout := "2006-01-02"
  8482. //loc, _ := time.LoadLocation("Local")
  8483. //
  8484. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8485. //if err != nil {
  8486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8487. // return
  8488. //}
  8489. //recordDateTime := theTime.Unix()
  8490. adminUser := c.GetAdminUserInfo()
  8491. order, _ := service.GetHisOrderByID(order_id)
  8492. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8493. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8494. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8495. orderInfos = append(orderInfos, orderInfos_two...)
  8496. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8497. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8498. var diagnosis_ids []string
  8499. if his.ID > 0 {
  8500. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8501. } else {
  8502. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8503. }
  8504. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8505. var dia_config []*models.HisXtDiagnoseConfig
  8506. var name string
  8507. for _, item := range diagnosis_ids {
  8508. id, _ := strconv.ParseInt(item, 10, 64)
  8509. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8510. dia_config = append(dia_config, &diagnosisConfig)
  8511. if len(name) == 0 {
  8512. name = diagnosisConfig.ClassName
  8513. } else {
  8514. name = name + "," + diagnosisConfig.ClassName
  8515. }
  8516. }
  8517. var bedCostTotal float64 = 0 //床位总费
  8518. var bedCostSelfTotal float64 = 0 //床位自费
  8519. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8520. var operationCostTotal float64 = 0 //手术费
  8521. var operationCostSelfTotal float64 = 0 //手术费
  8522. var operationCostPartSelfTotal float64 = 0 //手术费
  8523. var otherCostTotal float64 = 0 //其他费用
  8524. var otherCostSelfTotal float64 = 0 //其他费用
  8525. var otherCostPartSelfTotal float64 = 0 //其他费用
  8526. var materialCostTotal float64 = 0 //材料费
  8527. var materialCostSelfTotal float64 = 0 //材料费
  8528. var materialCostPartSelfTotal float64 = 0 //材料费
  8529. var westernMedicineCostTotal float64 = 0 //西药费
  8530. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8531. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8532. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8533. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8534. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8535. var checkCostTotal float64 = 0 //检查费
  8536. var checkCostSelfTotal float64 = 0 //检查费
  8537. var checkCostPartSelfTotal float64 = 0 //检查费
  8538. var laboratoryCostTotal float64 = 0 //化验费
  8539. var laboratoryCostSelfTotal float64 = 0 //化验费
  8540. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8541. var treatCostTotal float64 = 0 //治疗费用
  8542. var treatCostSelfTotal float64 = 0 //治疗费用
  8543. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8544. decimal.DivisionPrecision = 2
  8545. for _, item := range orderInfos {
  8546. if item.MedChrgitmType == "01" { //床位费
  8547. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8548. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8549. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8550. }
  8551. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8552. if item.MedChrgitmType == "03" { //检查费
  8553. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8554. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8555. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8556. }
  8557. } else {
  8558. if item.MedChrgitmType == "03" { //检查费
  8559. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8560. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8561. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8562. }
  8563. }
  8564. if item.MedChrgitmType == "04" { //化验费
  8565. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8566. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8567. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8568. }
  8569. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8570. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8571. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8572. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8573. }
  8574. if item.MedChrgitmType == "06" { //手术费
  8575. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8576. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8577. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8578. }
  8579. if item.MedChrgitmType == "08" { //材料费
  8580. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8581. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8582. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8583. }
  8584. if item.MedChrgitmType == "09" { //西药费
  8585. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8586. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8587. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8588. }
  8589. if item.MedChrgitmType == "11" { //中成费
  8590. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8591. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8592. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8593. }
  8594. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8595. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8596. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8597. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8598. }
  8599. }
  8600. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8601. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8602. var user_name string
  8603. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8604. if role.ID == 0 {
  8605. user_name = "管理员"
  8606. } else {
  8607. user_name = role.UserName
  8608. }
  8609. baseParams := models.BaseParams{
  8610. SecretKey: miConfig.SecretKey,
  8611. FixmedinsCode: miConfig.Code,
  8612. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8613. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8614. OrgName: miConfig.OrgName,
  8615. Doctor: user_name,
  8616. }
  8617. businessParams := models.BusinessParams{
  8618. PsnNo: order.PsnNo,
  8619. MdtrtId: order.MdtrtId,
  8620. SetlId: order.SetlId,
  8621. }
  8622. var res ResultEleven
  8623. var resEleven10265 ResultEleven10265
  8624. if config.IsOpen == 1 {
  8625. if miConfig.MdtrtareaAdmvs == "421300" {
  8626. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8627. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8628. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8629. resp, requestErr := http.Get(api)
  8630. if requestErr != nil {
  8631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8632. return
  8633. }
  8634. body, ioErr := ioutil.ReadAll(resp.Body)
  8635. if ioErr != nil {
  8636. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8638. return
  8639. }
  8640. var respJSON map[string]interface{}
  8641. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8644. return
  8645. }
  8646. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8647. result, _ := json.Marshal(respJSON)
  8648. fmt.Println("log")
  8649. fmt.Println(string(result))
  8650. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8651. utils.ErrorLog("解析失败:%v", err)
  8652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8653. return
  8654. }
  8655. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8656. var api string
  8657. if miConfig.MdtrtareaAdmvs == "320921" {
  8658. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8659. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8660. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8661. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8662. } else {
  8663. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8664. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8665. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8666. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8667. }
  8668. resp, requestErr := http.Get(api)
  8669. if requestErr != nil {
  8670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8671. return
  8672. }
  8673. body, ioErr := ioutil.ReadAll(resp.Body)
  8674. if ioErr != nil {
  8675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8677. return
  8678. }
  8679. var respJSON map[string]interface{}
  8680. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8683. return
  8684. }
  8685. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8686. result, _ := json.Marshal(respJSON)
  8687. fmt.Println("log")
  8688. fmt.Println(string(result))
  8689. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8690. utils.ErrorLog("解析失败:%v", err)
  8691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8692. return
  8693. }
  8694. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8695. res.Output = resEleven10265.Output
  8696. res.ErrMsg = resEleven10265.ErrMsg
  8697. res.Cainfo = resEleven10265.Cainfo
  8698. res.WarnMsg = resEleven10265.WarnMsg
  8699. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8700. res.Infcode = infocode
  8701. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8702. fmt.Println("~~~~~~~")
  8703. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8704. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8705. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8706. resp, requestErr := http.Get(api)
  8707. if requestErr != nil {
  8708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8709. return
  8710. }
  8711. body, ioErr := ioutil.ReadAll(resp.Body)
  8712. if ioErr != nil {
  8713. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8715. return
  8716. }
  8717. var respJSON map[string]interface{}
  8718. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8721. return
  8722. }
  8723. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8724. result, _ := json.Marshal(respJSON)
  8725. fmt.Println("log")
  8726. fmt.Println(string(result))
  8727. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8728. utils.ErrorLog("解析失败:%v", err)
  8729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8730. return
  8731. }
  8732. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8733. res.Output = resEleven10265.Output
  8734. res.ErrMsg = resEleven10265.ErrMsg
  8735. res.Cainfo = resEleven10265.Cainfo
  8736. res.WarnMsg = resEleven10265.WarnMsg
  8737. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8738. res.Infcode = infocode
  8739. } else {
  8740. result := service.Gdyb5203(baseParams, businessParams)
  8741. //service.Gdyb5204(baseParams, businessParams)
  8742. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  8743. var dat map[string]interface{}
  8744. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8745. fmt.Println(dat)
  8746. } else {
  8747. fmt.Println(err)
  8748. }
  8749. userJSONBytes, _ := json.Marshal(dat)
  8750. if miConfig.Code == "H15049901371" {
  8751. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8752. utils.ErrorLog("解析失败:%v", err)
  8753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8754. return
  8755. }
  8756. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8757. res.Output = resEleven10265.Output
  8758. res.ErrMsg = resEleven10265.ErrMsg
  8759. res.Cainfo = resEleven10265.Cainfo
  8760. res.WarnMsg = resEleven10265.WarnMsg
  8761. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8762. res.Infcode = infocode
  8763. } else {
  8764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8765. utils.ErrorLog("解析失败:%v", err)
  8766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8767. return
  8768. }
  8769. }
  8770. }
  8771. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8772. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8773. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8774. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8775. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8776. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8777. var doctor_name string
  8778. if roles.ID == 0 {
  8779. doctor_name = "管理员"
  8780. } else {
  8781. doctor_name = roles.UserName
  8782. }
  8783. yiliao_leibie := ""
  8784. switch order.MedType {
  8785. case "11":
  8786. yiliao_leibie = "普通门诊"
  8787. break
  8788. case "12":
  8789. yiliao_leibie = "门诊挂号"
  8790. break
  8791. case "13":
  8792. yiliao_leibie = "急诊"
  8793. break
  8794. case "14":
  8795. yiliao_leibie = "门诊特殊病"
  8796. break
  8797. case "15":
  8798. yiliao_leibie = "门诊统筹"
  8799. break
  8800. case "16":
  8801. yiliao_leibie = "门诊慢性病"
  8802. break
  8803. case "21":
  8804. yiliao_leibie = "普通住院"
  8805. break
  8806. }
  8807. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8808. if res.Infcode == 0 {
  8809. c.ServeSuccessJSON(map[string]interface{}{
  8810. "diagnosis": name,
  8811. "order_infos": orderInfos,
  8812. "number": order.MdtrtId,
  8813. "date": order.SettleAccountsDate,
  8814. "charge_admin": charge_admin,
  8815. "printor_admin": printor_admin,
  8816. "info": res.Output.Setlinfo,
  8817. "order": order,
  8818. "bedCostTotal": bedCostTotal,
  8819. "bedCostSelfTotal": bedCostSelfTotal,
  8820. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8821. "operationCostTotal": operationCostTotal,
  8822. "operationCostSelfTotal": operationCostSelfTotal,
  8823. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8824. "otherCostTotal": otherCostTotal,
  8825. "otherCostSelfTotal": otherCostSelfTotal,
  8826. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8827. "materialCostTotal": materialCostTotal,
  8828. "materialCostSelfTotal": materialCostSelfTotal,
  8829. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8830. "westernMedicineCostTotal": westernMedicineCostTotal,
  8831. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8832. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8833. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8834. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8835. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8836. "checkCostTotal": checkCostTotal,
  8837. "checkCostSelfTotal": checkCostSelfTotal,
  8838. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8839. "laboratoryCostTotal": laboratoryCostTotal,
  8840. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8841. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8842. "treatCostTotal": treatCostTotal,
  8843. "treatCostSelfTotal": treatCostSelfTotal,
  8844. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8845. "doctor_info": doctor_info,
  8846. "doctor_code": adminRole_two.DoctorCode,
  8847. "doctor_name": doctor_name,
  8848. "health_card_no": order.PsnNo,
  8849. "department": departments.Name,
  8850. "yiliao_leibie": yiliao_leibie,
  8851. "after_money": order.AccountPrice,
  8852. "patient": patient,
  8853. "org_name": miConfig.OrgName,
  8854. "org_code": miConfig.Code,
  8855. "order_number": order.Number,
  8856. "his_hospital": his_hospital,
  8857. "his": his,
  8858. "dia_config": dia_config,
  8859. //"check_order_info": cus_slice,
  8860. })
  8861. }
  8862. }
  8863. }
  8864. func (c *HisApiController) CheckTreatment() {
  8865. patient_id, _ := c.GetInt64("patient_id")
  8866. id_card_no := c.GetString("id_card_no")
  8867. insutype := c.GetString("insutype")
  8868. med_type := c.GetString("med_type")
  8869. admin_user_id, _ := c.GetInt64("admin_user_id")
  8870. adminUser := c.GetAdminUserInfo()
  8871. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8872. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8873. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8874. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8875. if miConfig.MdtrtareaAdmvs == "421300" {
  8876. var res ResultTwo
  8877. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8878. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8879. "&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)
  8880. resp, requestErr := http.Get(api)
  8881. if requestErr != nil {
  8882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8883. return
  8884. }
  8885. body, ioErr := ioutil.ReadAll(resp.Body)
  8886. if ioErr != nil {
  8887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8889. return
  8890. }
  8891. var respJSON map[string]interface{}
  8892. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8895. return
  8896. }
  8897. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8898. result, _ := json.Marshal(respJSON)
  8899. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8900. utils.ErrorLog("解析失败:%v", err)
  8901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8902. return
  8903. }
  8904. if res.Infcode == 0 {
  8905. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8906. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8907. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8908. resp, requestErr := http.Get(api)
  8909. if requestErr != nil {
  8910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8911. return
  8912. }
  8913. body, ioErr := ioutil.ReadAll(resp.Body)
  8914. if ioErr != nil {
  8915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8917. return
  8918. }
  8919. var respJSON map[string]interface{}
  8920. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8923. return
  8924. }
  8925. var res Result2001
  8926. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8927. result2, _ := json.Marshal(respJSON)
  8928. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8929. utils.ErrorLog("解析失败:%v", err)
  8930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8931. return
  8932. }
  8933. if res.Infcode == 0 {
  8934. c.ServeSuccessJSON(map[string]interface{}{
  8935. "msg": res.Output.Trtinfo,
  8936. })
  8937. }
  8938. } else {
  8939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8940. return
  8941. }
  8942. } else {
  8943. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8944. var dat map[string]interface{}
  8945. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8946. fmt.Println(dat)
  8947. } else {
  8948. fmt.Println(err)
  8949. }
  8950. userJSONBytes, _ := json.Marshal(dat)
  8951. var res ResultTwo
  8952. var res10265 ResultTwo10265
  8953. if miConfig.Code == "H15049901371" {
  8954. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8955. utils.ErrorLog("解析失败:%v", err)
  8956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8957. return
  8958. }
  8959. res.ErrMsg = res10265.ErrMsg
  8960. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8961. res.Infcode = infocode
  8962. res.Output = res10265.Output
  8963. res.InfRefmsgid = res10265.InfRefmsgid
  8964. } else {
  8965. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8966. utils.ErrorLog("解析失败:%v", err)
  8967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8968. return
  8969. }
  8970. }
  8971. var user_name string
  8972. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8973. if role.ID == 0 {
  8974. user_name = "xxx"
  8975. } else {
  8976. user_name = role.UserName
  8977. }
  8978. baseParams := models.BaseParams{
  8979. SecretKey: miConfig.SecretKey,
  8980. FixmedinsCode: miConfig.Code,
  8981. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8982. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8983. OrgName: miConfig.OrgName,
  8984. Doctor: user_name,
  8985. }
  8986. if config.IsOpen == 1 {
  8987. if miConfig.Code == "H15049901371" {
  8988. if med_type == "14" {
  8989. if insutype == "390" {
  8990. med_type = "9933"
  8991. } else if insutype == "310" {
  8992. med_type = "990502"
  8993. }
  8994. } else if med_type == "11" {
  8995. med_type = "11"
  8996. }
  8997. }
  8998. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8999. var dat map[string]interface{}
  9000. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9001. fmt.Println(dat)
  9002. } else {
  9003. fmt.Println(err)
  9004. }
  9005. var res Result2001
  9006. var res10265 Result2001Org10265
  9007. if miConfig.Code == "H15049901371" {
  9008. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9009. utils.ErrorLog("解析失败:%v", err)
  9010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9011. return
  9012. }
  9013. res.ErrMsg = res10265.ErrMsg
  9014. res.Output = res10265.Output
  9015. res.InfRefmsgid = res10265.InfRefmsgid
  9016. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9017. res.Infcode = infocode
  9018. } else {
  9019. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9020. utils.ErrorLog("解析失败:%v", err)
  9021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9022. return
  9023. }
  9024. }
  9025. if res.Infcode == 0 {
  9026. c.ServeSuccessJSON(map[string]interface{}{
  9027. "msg": res.Output.Trtinfo,
  9028. })
  9029. }
  9030. }
  9031. }
  9032. }
  9033. //func (c *HisApiController) PutRecord() {
  9034. // id, _ := c.GetInt64("id")
  9035. // record_time := c.GetString("record_time")
  9036. // timeLayout := "2006-01-02"
  9037. // loc, _ := time.LoadLocation("Local")
  9038. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9039. // if err != nil {
  9040. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9041. // return
  9042. // }
  9043. // recordDateTime := theTime.Unix()
  9044. //
  9045. // adminInfo := c.GetAdminUserInfo()
  9046. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9047. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9048. //
  9049. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9050. //
  9051. // fmt.Println(miConfig.SecretKey)
  9052. //
  9053. // if patient == nil {
  9054. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9055. // return
  9056. // }
  9057. // if len(patient.IdCardNo) == 0 {
  9058. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9059. // return
  9060. // }
  9061. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9062. // if config.IsOpen == 1 {
  9063. // 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
  9064. // resp, requestErr := http.Get(api)
  9065. // if requestErr != nil {
  9066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9067. // return
  9068. // }
  9069. // defer resp.Body.Close()
  9070. // body, ioErr := ioutil.ReadAll(resp.Body)
  9071. // if ioErr != nil {
  9072. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9074. // return
  9075. // }
  9076. // var respJSON map[string]interface{}
  9077. //
  9078. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9079. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9080. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9081. // return
  9082. // }
  9083. //
  9084. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9085. // userJSONBytes, _ := json.Marshal(userJSON)
  9086. // var res ResultTwo
  9087. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9088. // utils.ErrorLog("解析失败:%v", err)
  9089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9090. // return
  9091. // }
  9092. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9093. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9094. // infoStr := string(Iinfos)
  9095. // idetinfoStr := string(Idetinfos)
  9096. //
  9097. // if res.Infcode == 0 {
  9098. // his := models.VMHisPatient{
  9099. // Status: 1,
  9100. // Ctime: time.Now().Unix(),
  9101. // Mtime: time.Now().Unix(),
  9102. // PsnNo: res.Output.Baseinfo.PsnNo,
  9103. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9104. // Certno: res.Output.Baseinfo.Certno,
  9105. // PsnName: res.Output.Baseinfo.PsnName,
  9106. // Gend: res.Output.Baseinfo.Gend,
  9107. // Naty: res.Output.Baseinfo.Naty,
  9108. // Brdy: res.Output.Baseinfo.Brdy,
  9109. // Age: res.Output.Baseinfo.Age,
  9110. // Iinfo: infoStr,
  9111. // Idetinfo: idetinfoStr,
  9112. // PatientId: patient.ID,
  9113. // RecordDate: theTime.Unix(),
  9114. // UserOrgId: adminInfo.CurrentOrgId,
  9115. // AdminUserId: adminInfo.AdminUser.Id,
  9116. // IsReturn: 1,
  9117. // }
  9118. //
  9119. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9120. // //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")
  9121. // //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")
  9122. //
  9123. // //var dat map[string]interface{}
  9124. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9125. // // fmt.Println(dat)
  9126. // //} else {
  9127. // // fmt.Println(err)
  9128. // //}
  9129. //
  9130. // var dat2 map[string]interface{}
  9131. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9132. // fmt.Println(dat2)
  9133. // } else {
  9134. // fmt.Println(err)
  9135. // }
  9136. //
  9137. // } else {
  9138. // adminUser := c.GetAdminUserInfo()
  9139. // errlog := &models.HisOrderError{
  9140. // UserOrgId: adminUser.CurrentOrgId,
  9141. // Ctime: time.Now().Unix(),
  9142. // Mtime: time.Now().Unix(),
  9143. // ErrMsg: res.ErrMsg,
  9144. // Status: 1,
  9145. // PatientId: id,
  9146. // RecordTime: recordDateTime,
  9147. // Stage: 1,
  9148. // }
  9149. // service.CreateErrMsgLog(errlog)
  9150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9151. // return
  9152. // }
  9153. // }
  9154. //
  9155. //}
  9156. //func (c *HisApiController) GetUploadDiag() {
  9157. // id, _ := c.GetInt64("id")
  9158. // record_time := c.GetString("record_time")
  9159. //
  9160. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9161. // sick_type, _ := c.GetInt64("sick_type")
  9162. // reg_type, _ := c.GetInt64("reg_type")
  9163. //
  9164. // timeLayout := "2006-01-02"
  9165. // loc, _ := time.LoadLocation("Local")
  9166. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9167. // if err != nil {
  9168. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9169. // return
  9170. // }
  9171. //
  9172. // var patientPrescription models.HisPrescriptionInfo
  9173. // recordDateTime := theTime.Unix()
  9174. // adminInfo := c.GetAdminUserInfo()
  9175. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9176. //
  9177. // if patientPrescription.ID == 0 {
  9178. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9179. // }
  9180. //
  9181. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9182. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9183. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9184. // sickConfig, _ := service.FindSickById(sick_type)
  9185. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9186. //
  9187. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9188. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9189. // "&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 +
  9190. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9191. // resp2, requestErr2 := http.Get(api2)
  9192. // if requestErr2 != nil {
  9193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9194. // return
  9195. // }
  9196. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9197. // if ioErr2 != nil {
  9198. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9200. // return
  9201. // }
  9202. // var respJSON2 map[string]interface{}
  9203. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9204. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9206. // return
  9207. // }
  9208. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9209. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9210. //
  9211. // var res2 ResultSix
  9212. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9213. // utils.ErrorLog("解析失败:%v", err)
  9214. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9215. // return
  9216. // }
  9217. // if res2.Infcode != 0 {
  9218. // adminUser := c.GetAdminUserInfo()
  9219. // errlog := &models.HisOrderError{
  9220. // UserOrgId: adminUser.CurrentOrgId,
  9221. // Ctime: time.Now().Unix(),
  9222. // Mtime: time.Now().Unix(),
  9223. // ErrMsg: res2.ErrMsg,
  9224. // Status: 1,
  9225. // PatientId: id,
  9226. // RecordTime: recordDateTime,
  9227. // Stage: 3,
  9228. // }
  9229. // service.CreateErrMsgLog(errlog)
  9230. //
  9231. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9232. // return
  9233. // }
  9234. //
  9235. // c.ServeSuccessJSON(map[string]interface{}{
  9236. // "msg": "上传成功",
  9237. // })
  9238. //
  9239. //}
  9240. type QueryResult struct {
  9241. ID int64
  9242. Name string
  9243. Code string
  9244. List_type_code string
  9245. }
  9246. func (c *HisApiController) GetCheckCode() {
  9247. ids_str := c.GetString("ids")
  9248. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9249. ids_arr := strings.Split(ids_str, ",")
  9250. var queryResult []QueryResult
  9251. ids := make([]int64, 0)
  9252. for _, item := range ids_arr {
  9253. id, _ := strconv.ParseInt(item, 10, 64)
  9254. ids = append(ids, id)
  9255. }
  9256. if record_type == 1 {
  9257. drugs, _ := service.GetBatchDrugList(ids)
  9258. for _, item := range drugs {
  9259. result := QueryResult{
  9260. ID: item.ID,
  9261. Name: item.DrugName,
  9262. Code: item.MedicalInsuranceNumber,
  9263. List_type_code: "101",
  9264. }
  9265. queryResult = append(queryResult, result)
  9266. }
  9267. } else if record_type == 2 {
  9268. goods, _ := service.GetBatchGoodInformationList(ids)
  9269. for _, item := range goods {
  9270. result := QueryResult{
  9271. ID: item.ID,
  9272. Name: item.GoodName,
  9273. Code: item.MedicalInsuranceNumber,
  9274. List_type_code: "301",
  9275. }
  9276. queryResult = append(queryResult, result)
  9277. }
  9278. } else if record_type == 3 {
  9279. projects, _ := service.GetBathchMyPorjecgList(ids)
  9280. for _, item := range projects {
  9281. result := QueryResult{
  9282. ID: item.ID,
  9283. Name: item.ProjectName,
  9284. Code: item.MedicalCode,
  9285. List_type_code: "201",
  9286. }
  9287. queryResult = append(queryResult, result)
  9288. }
  9289. }
  9290. admin_user_id, _ := c.GetInt64("admin_user_id")
  9291. adminUser := c.GetAdminUserInfo()
  9292. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9293. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9294. var user_name string
  9295. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9296. if role.ID == 0 {
  9297. user_name = "xxx"
  9298. } else {
  9299. user_name = role.UserName
  9300. }
  9301. baseParams := &models.BaseParams{
  9302. SecretKey: miConfig.SecretKey,
  9303. FixmedinsCode: miConfig.Code,
  9304. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9305. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9306. OrgName: miConfig.OrgName,
  9307. Doctor: user_name,
  9308. }
  9309. if config.IsOpen == 1 {
  9310. for _, item := range queryResult {
  9311. var result string
  9312. if record_type == 1 {
  9313. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9314. } else if record_type == 2 {
  9315. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9316. } else if record_type == 3 {
  9317. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9318. }
  9319. var dat map[string]interface{}
  9320. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9321. fmt.Println(dat)
  9322. } else {
  9323. fmt.Println(err)
  9324. }
  9325. userJSONBytes, _ := json.Marshal(dat)
  9326. var res ResultSix
  9327. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9328. utils.ErrorLog("解析失败:%v", err)
  9329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9330. return
  9331. }
  9332. if res.Infcode == 0 {
  9333. if record_type == 1 {
  9334. service.UpdateBaseDrugById(item.ID)
  9335. } else if record_type == 2 {
  9336. service.UpdateGoodInformaitonByDetail(item.ID)
  9337. } else if record_type == 3 {
  9338. service.UpdateProjectById(item.ID)
  9339. }
  9340. c.ServeSuccessJSON(map[string]interface{}{
  9341. "failed_code": 0,
  9342. "msg": "目录对照成功",
  9343. })
  9344. } else {
  9345. c.ServeSuccessJSON(map[string]interface{}{
  9346. "failed_code": -10,
  9347. "msg": res.ErrMsg,
  9348. })
  9349. }
  9350. }
  9351. }
  9352. }
  9353. func (c *HisApiController) UnCheckCode() {
  9354. ids_str := c.GetString("ids")
  9355. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9356. admin_user_id, _ := c.GetInt64("admin_user_id")
  9357. ids_arr := strings.Split(ids_str, ",")
  9358. var queryResult []QueryResult
  9359. ids := make([]int64, 0)
  9360. for _, item := range ids_arr {
  9361. id, _ := strconv.ParseInt(item, 10, 64)
  9362. ids = append(ids, id)
  9363. }
  9364. if record_type == 1 {
  9365. drugs, _ := service.GetBatchDrugList(ids)
  9366. for _, item := range drugs {
  9367. result := QueryResult{
  9368. ID: item.ID,
  9369. Name: item.DrugName,
  9370. Code: item.MedicalInsuranceNumber,
  9371. List_type_code: "101",
  9372. }
  9373. queryResult = append(queryResult, result)
  9374. }
  9375. } else if record_type == 2 {
  9376. goods, _ := service.GetBatchGoodInformationList(ids)
  9377. for _, item := range goods {
  9378. result := QueryResult{
  9379. ID: item.ID,
  9380. Name: item.GoodName,
  9381. Code: item.MedicalInsuranceNumber,
  9382. List_type_code: "301",
  9383. }
  9384. queryResult = append(queryResult, result)
  9385. }
  9386. } else if record_type == 3 {
  9387. projects, _ := service.GetBathchMyPorjecgList(ids)
  9388. for _, item := range projects {
  9389. result := QueryResult{
  9390. ID: item.ID,
  9391. Name: item.ProjectName,
  9392. Code: item.MedicalCode,
  9393. List_type_code: "201",
  9394. }
  9395. queryResult = append(queryResult, result)
  9396. }
  9397. }
  9398. adminUser := c.GetAdminUserInfo()
  9399. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9400. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9401. var user_name string
  9402. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9403. if role.ID == 0 {
  9404. user_name = "xxx"
  9405. } else {
  9406. user_name = role.UserName
  9407. }
  9408. baseParams := &models.BaseParams{
  9409. SecretKey: miConfig.SecretKey,
  9410. FixmedinsCode: miConfig.Code,
  9411. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9412. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9413. OrgName: miConfig.OrgName,
  9414. Doctor: user_name,
  9415. }
  9416. if config.IsOpen == 1 {
  9417. for _, item := range queryResult {
  9418. var result string
  9419. if record_type == 1 {
  9420. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9421. } else if record_type == 2 {
  9422. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9423. } else if record_type == 3 {
  9424. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9425. }
  9426. var dat2 map[string]interface{}
  9427. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9428. fmt.Println(dat2)
  9429. } else {
  9430. fmt.Println(err)
  9431. }
  9432. userJSONBytes, _ := json.Marshal(dat2)
  9433. var res ResultSix
  9434. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9435. utils.ErrorLog("解析失败:%v", err)
  9436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9437. return
  9438. }
  9439. if res.Infcode == 0 {
  9440. if record_type == 1 {
  9441. service.UpdateDrugByIdDetail(item.ID)
  9442. } else if record_type == 2 {
  9443. service.UpdateGoodInfoById(item.ID)
  9444. } else if record_type == 3 {
  9445. service.UpdateMyProjectById(item.ID)
  9446. }
  9447. c.ServeSuccessJSON(map[string]interface{}{
  9448. "failed_code": 0,
  9449. "msg": "撤销目录对照成功",
  9450. })
  9451. } else {
  9452. c.ServeSuccessJSON(map[string]interface{}{
  9453. "failed_code": -10,
  9454. "msg": res.ErrMsg,
  9455. })
  9456. }
  9457. }
  9458. }
  9459. }
  9460. func (c *HisApiController) GetPatientInfo() {
  9461. id_card_no := c.GetString("id_card_no")
  9462. admin_user_id, _ := c.GetInt64("admin_user_id")
  9463. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9464. if patient.ID == 0 {
  9465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9466. return
  9467. }
  9468. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9469. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9470. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9471. if config.IsOpen == 1 {
  9472. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9473. var dat map[string]interface{}
  9474. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9475. fmt.Println(dat)
  9476. } else {
  9477. fmt.Println(err)
  9478. }
  9479. userJSONBytes, _ := json.Marshal(dat)
  9480. var res ResultTwo
  9481. var res10265 ResultTwo10265
  9482. if miConfig.Code == "H15049901371" {
  9483. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9484. utils.ErrorLog("解析失败:%v", err)
  9485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9486. return
  9487. }
  9488. res.ErrMsg = res10265.ErrMsg
  9489. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9490. res.Infcode = infocode
  9491. res.Output = res10265.Output
  9492. res.InfRefmsgid = res10265.InfRefmsgid
  9493. } else {
  9494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9495. utils.ErrorLog("解析失败:%v", err)
  9496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9497. return
  9498. }
  9499. }
  9500. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9501. // utils.ErrorLog("解析失败:%v", err)
  9502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9503. // return
  9504. //}
  9505. if res.Infcode != 0 {
  9506. c.ServeSuccessJSON(map[string]interface{}{
  9507. "failed_code": -10,
  9508. "msg": res.ErrMsg,
  9509. })
  9510. } else {
  9511. c.ServeSuccessJSON(map[string]interface{}{
  9512. "failed_code": 0,
  9513. "info": res,
  9514. })
  9515. }
  9516. }
  9517. }
  9518. func (c *HisApiController) PsnPutOnRecord() {
  9519. record_type, _ := c.GetInt64("type")
  9520. patient_id, _ := c.GetInt64("patient_id")
  9521. admin_user_id, _ := c.GetInt64("admin_user_id")
  9522. start_time := c.GetString("start_time")
  9523. end_time := c.GetString("end_time")
  9524. adminUser := c.GetAdminUserInfo()
  9525. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9526. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9527. var patients []*models.Patients
  9528. if record_type == 1 { //全部备案
  9529. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9530. patients = append(patients, patient...)
  9531. } else { //单个备案
  9532. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9533. patients = append(patients, patient)
  9534. }
  9535. var user_name string
  9536. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9537. if role.ID == 0 {
  9538. user_name = "xxx"
  9539. } else {
  9540. user_name = role.UserName
  9541. }
  9542. if config.IsOpen == 1 {
  9543. for _, item := range patients {
  9544. 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
  9545. resp, requestErr := http.Get(api)
  9546. if requestErr != nil {
  9547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9548. return
  9549. }
  9550. defer resp.Body.Close()
  9551. body, ioErr := ioutil.ReadAll(resp.Body)
  9552. if ioErr != nil {
  9553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9555. return
  9556. }
  9557. var respJSON map[string]interface{}
  9558. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9561. return
  9562. }
  9563. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9564. userJSONBytes, _ := json.Marshal(userJSON)
  9565. var res ResultTwo
  9566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9567. utils.ErrorLog("解析失败:%v", err)
  9568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9569. return
  9570. }
  9571. if res.Infcode == 0 {
  9572. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9573. var dat map[string]interface{}
  9574. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9575. fmt.Println(dat)
  9576. } else {
  9577. fmt.Println(err)
  9578. }
  9579. userJSONBytes, _ := json.Marshal(dat)
  9580. var res2 ResultThirteen
  9581. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9582. utils.ErrorLog("解析失败:%v", err)
  9583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9584. return
  9585. }
  9586. if res2.Infcode == 0 {
  9587. psnResult := &models.GdybPsnRecord{
  9588. UserOrgId: adminUser.CurrentOrgId,
  9589. PatientId: item.ID,
  9590. PsnNo: res.Output.Baseinfo.PsnNo,
  9591. Ctime: time.Now().Unix(),
  9592. Mtime: time.Now().Unix(),
  9593. Status: 1,
  9594. IsCancel: 1,
  9595. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9596. }
  9597. service.CreatePsnRecord(psnResult)
  9598. } else {
  9599. c.ServeSuccessJSON(map[string]interface{}{
  9600. "failed_code": -10,
  9601. "msg": res2.ErrMsg,
  9602. })
  9603. return
  9604. }
  9605. }
  9606. }
  9607. }
  9608. }
  9609. func (c *HisApiController) PsnUnPutOnRecord() {
  9610. id, _ := c.GetInt64("id")
  9611. //record_type, _ := c.GetInt64("type")
  9612. admin_user_id, _ := c.GetInt64("admin_user_id")
  9613. adminUser := c.GetAdminUserInfo()
  9614. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9615. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9616. var user_name string
  9617. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9618. if role.ID == 0 {
  9619. user_name = "xxx"
  9620. } else {
  9621. user_name = role.UserName
  9622. }
  9623. psn_record, _ := service.GetPsnRecordById(id)
  9624. if psn_record.ID == 0 {
  9625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9626. return
  9627. }
  9628. if config.IsOpen == 1 {
  9629. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9630. var dat map[string]interface{}
  9631. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9632. fmt.Println(dat)
  9633. } else {
  9634. fmt.Println(err)
  9635. }
  9636. userJSONBytes, _ := json.Marshal(dat)
  9637. var res ResultFourteen
  9638. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9639. utils.ErrorLog("解析失败:%v", err)
  9640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9641. return
  9642. }
  9643. if res.Infcode == 0 {
  9644. psn_record.IsCancel = 2
  9645. service.CreatePsnRecord(&psn_record)
  9646. } else {
  9647. c.ServeSuccessJSON(map[string]interface{}{
  9648. "failed_code": -10,
  9649. "msg": res.ErrMsg,
  9650. })
  9651. return
  9652. }
  9653. }
  9654. }
  9655. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9656. patient_id, _ := c.GetInt64("patient_id")
  9657. insutype_two := c.GetString("insutype")
  9658. psn_no := c.GetString("psn_no")
  9659. doctor_id, _ := c.GetInt64("doctor_id")
  9660. sick_id, _ := c.GetInt64("sick_id")
  9661. department_id, _ := c.GetInt64("department_id")
  9662. start_time := c.GetString("start_time")
  9663. end_time := c.GetString("end_time")
  9664. check_time := c.GetString("check_time")
  9665. adminUser := c.GetAdminUserInfo()
  9666. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9667. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9668. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9669. sick, _ := service.FindSickById(sick_id)
  9670. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9671. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9672. var res ResultTwo
  9673. var res10265 ResultTwo10265
  9674. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9675. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9676. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9677. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9678. "&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
  9679. resp, requestErr := http.Get(api)
  9680. if requestErr != nil {
  9681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9682. return
  9683. }
  9684. body, ioErr := ioutil.ReadAll(resp.Body)
  9685. if ioErr != nil {
  9686. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9688. return
  9689. }
  9690. var respJSON map[string]interface{}
  9691. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9692. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9694. return
  9695. }
  9696. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9697. result, _ := json.Marshal(respJSON)
  9698. fmt.Println("log")
  9699. fmt.Println(string(result))
  9700. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9701. utils.ErrorLog("解析失败:%v", err)
  9702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9703. return
  9704. }
  9705. res.ErrMsg = res10265.ErrMsg
  9706. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9707. res.Infcode = infocode
  9708. res.Output = res10265.Output
  9709. res.InfRefmsgid = res10265.InfRefmsgid
  9710. } else {
  9711. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9712. if miConfig.Code == "H15049901371" {
  9713. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9714. utils.ErrorLog("解析失败:%v", err)
  9715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9716. return
  9717. }
  9718. res.ErrMsg = res10265.ErrMsg
  9719. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9720. res.Infcode = infocode
  9721. res.Output = res10265.Output
  9722. res.InfRefmsgid = res10265.InfRefmsgid
  9723. } else {
  9724. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9725. utils.ErrorLog("解析失败:%v", err)
  9726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9727. return
  9728. }
  9729. }
  9730. }
  9731. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9732. infoStr := string(Iinfos)
  9733. var rf []*ResultFive
  9734. json.Unmarshal([]byte(infoStr), &rf)
  9735. var insuplc_admdvs string
  9736. var insutype string
  9737. var is390 int = 0
  9738. var is310 int = 0
  9739. var insutypes []*ResultFive
  9740. for _, item := range rf {
  9741. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9742. insutypes = append(insutypes, item)
  9743. }
  9744. }
  9745. if len(insutypes) == 1 {
  9746. insutype = insutypes[0].Insutype
  9747. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9748. } else {
  9749. for _, i := range insutypes {
  9750. if i.Insutype == "390" {
  9751. is390 = 1
  9752. }
  9753. if i.Insutype == "310" {
  9754. is310 = 1
  9755. }
  9756. }
  9757. }
  9758. if is390 == 1 {
  9759. insutype = "390"
  9760. }
  9761. if is310 == 1 {
  9762. insutype = "310"
  9763. }
  9764. if len(insutypes) == 2 {
  9765. insutype = insutype_two
  9766. }
  9767. if len(insutypes) == 0 {
  9768. insutype = "310"
  9769. }
  9770. insutype = insutype_two
  9771. fmt.Println(insutype)
  9772. for _, item := range rf {
  9773. fmt.Println(item.Insutype)
  9774. fmt.Println(insutype)
  9775. if item.Insutype == insutype {
  9776. fmt.Println(item.Insutype)
  9777. fmt.Println(insutype)
  9778. insuplc_admdvs = item.InsuplcAdmdvs
  9779. }
  9780. }
  9781. fmt.Println(insuplc_admdvs)
  9782. var res2 ResultThirteen
  9783. var res10265_2 ResultThirteen10265
  9784. if config.IsOpen == 1 {
  9785. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9786. } else {
  9787. 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)
  9788. var dat map[string]interface{}
  9789. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9790. fmt.Println(dat)
  9791. } else {
  9792. fmt.Println(err)
  9793. }
  9794. userJSONBytes, _ := json.Marshal(dat)
  9795. if miConfig.Code == "H15049901371" {
  9796. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9797. utils.ErrorLog("解析失败:%v", err)
  9798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9799. return
  9800. }
  9801. res2.ErrMsg = res10265_2.ErrMsg
  9802. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9803. res2.Infcode = infocode
  9804. res2.Output = res10265_2.Output
  9805. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9806. } else {
  9807. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9808. utils.ErrorLog("解析失败:%v", err)
  9809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9810. return
  9811. }
  9812. }
  9813. }
  9814. if res2.Infcode == 0 {
  9815. psnResult := &models.GdybPsnNcdsRecord{
  9816. UserOrgId: adminUser.CurrentOrgId,
  9817. PatientId: patient.ID,
  9818. PsnNo: psn_no,
  9819. DoctorId: doctor.AdminUserId,
  9820. DepartmentId: department_id,
  9821. SickType: sick_id,
  9822. Insutype: insutype,
  9823. Ctime: time.Now().Unix(),
  9824. Mtime: time.Now().Unix(),
  9825. Status: 1,
  9826. IsCancel: 1,
  9827. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9828. }
  9829. service.CreatePsnNCDSRecord(psnResult)
  9830. c.ServeSuccessJSON(map[string]interface{}{
  9831. "failed_code": 0,
  9832. "msg": "备案成功",
  9833. "result": psnResult,
  9834. })
  9835. } else {
  9836. c.ServeSuccessJSON(map[string]interface{}{
  9837. "failed_code": -10,
  9838. "msg": res2.ErrMsg,
  9839. })
  9840. return
  9841. }
  9842. }
  9843. }
  9844. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9845. id, _ := c.GetInt64("id")
  9846. admin_user_id, _ := c.GetInt64("admin_user_id")
  9847. adminUser := c.GetAdminUserInfo()
  9848. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9849. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9850. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9851. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9852. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9853. //var user_name string
  9854. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9855. //if role.ID == 0 {
  9856. // user_name = "xxx"
  9857. //} else {
  9858. // user_name = role.UserName
  9859. //}
  9860. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9861. if psn_record.ID == 0 {
  9862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9863. return
  9864. }
  9865. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9866. var res ResultTwo
  9867. var res10265 ResultTwo10265
  9868. if miConfig.Code == "H15049901371" {
  9869. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9870. utils.ErrorLog("解析失败:%v", err)
  9871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9872. return
  9873. }
  9874. res.ErrMsg = res10265.ErrMsg
  9875. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9876. res.Infcode = infocode
  9877. res.Output = res10265.Output
  9878. res.InfRefmsgid = res10265.InfRefmsgid
  9879. } else {
  9880. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9881. utils.ErrorLog("解析失败:%v", err)
  9882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9883. return
  9884. }
  9885. }
  9886. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9887. infoStr := string(Iinfos)
  9888. var rf []*ResultFive
  9889. json.Unmarshal([]byte(infoStr), &rf)
  9890. var insuplc_admdvs string
  9891. var insutype string
  9892. var is390 int = 0
  9893. var is310 int = 0
  9894. var insutypes []*ResultFive
  9895. for _, item := range rf {
  9896. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9897. insutypes = append(insutypes, item)
  9898. }
  9899. }
  9900. if len(insutypes) == 1 {
  9901. insutype = insutypes[0].Insutype
  9902. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9903. } else {
  9904. for _, i := range insutypes {
  9905. if i.Insutype == "390" {
  9906. is390 = 1
  9907. }
  9908. if i.Insutype == "310" {
  9909. is310 = 1
  9910. }
  9911. }
  9912. }
  9913. if is390 == 1 {
  9914. insutype = "390"
  9915. }
  9916. if is310 == 1 {
  9917. insutype = "310"
  9918. }
  9919. if len(insutypes) == 0 {
  9920. insutype = "310"
  9921. }
  9922. insutype = psn_record.Insutype
  9923. for _, item := range rf {
  9924. if item.Insutype == insutype {
  9925. insuplc_admdvs = item.InsuplcAdmdvs
  9926. }
  9927. }
  9928. if config.IsOpen == 1 {
  9929. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9930. var dat map[string]interface{}
  9931. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9932. fmt.Println(dat)
  9933. } else {
  9934. fmt.Println(err)
  9935. }
  9936. userJSONBytes, _ := json.Marshal(dat)
  9937. var res ResultFourteen
  9938. var res10265 ResultFourteen10265
  9939. if miConfig.Code == "H15049901371" {
  9940. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9941. utils.ErrorLog("解析失败:%v", err)
  9942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9943. return
  9944. }
  9945. res.ErrMsg = res10265.ErrMsg
  9946. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9947. res.Infcode = infocode
  9948. res.Output = res10265.Output
  9949. res.InfRefmsgid = res10265.InfRefmsgid
  9950. } else {
  9951. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9952. utils.ErrorLog("解析失败:%v", err)
  9953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9954. return
  9955. }
  9956. }
  9957. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9958. // utils.ErrorLog("解析失败:%v", err)
  9959. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9960. // return
  9961. //}
  9962. if res.Infcode == 0 {
  9963. psn_record.IsCancel = 2
  9964. service.CreatePsnNCDSRecord(&psn_record)
  9965. c.ServeSuccessJSON(map[string]interface{}{
  9966. "failed_code": 0,
  9967. "msg": "撤销备案成功",
  9968. })
  9969. } else {
  9970. c.ServeSuccessJSON(map[string]interface{}{
  9971. "failed_code": -10,
  9972. "msg": res.ErrMsg,
  9973. })
  9974. return
  9975. }
  9976. }
  9977. }
  9978. func (c *HisApiController) TestTest() {
  9979. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9980. fmt.Println(patient.Iinfo)
  9981. }
  9982. type CustomData struct {
  9983. MsgId string
  9984. PsnNo string
  9985. Info string
  9986. }
  9987. func (c *HisApiController) ReversalData() {
  9988. var customData []*CustomData
  9989. custom := &CustomData{
  9990. MsgId: "H44022900158202103301714472004",
  9991. PsnNo: "44020000001101329945",
  9992. Info: "2207",
  9993. }
  9994. customData = append(customData, custom)
  9995. custom1 := &CustomData{
  9996. MsgId: "H4402290015820210330172057803",
  9997. PsnNo: "44020000001101161813",
  9998. Info: "2207",
  9999. }
  10000. customData = append(customData, custom1)
  10001. custom2 := &CustomData{
  10002. MsgId: "H44022900158202103301705198813",
  10003. PsnNo: "44190000133097375417",
  10004. Info: "2207",
  10005. }
  10006. customData = append(customData, custom2)
  10007. custom3 := &CustomData{
  10008. MsgId: "H44022900158202103301715524756",
  10009. PsnNo: "44020000001100187221",
  10010. Info: "2207",
  10011. }
  10012. customData = append(customData, custom3)
  10013. custom4 := &CustomData{
  10014. MsgId: "H44022900158202103301730376224",
  10015. PsnNo: "44020000001101959155",
  10016. Info: "2207",
  10017. }
  10018. customData = append(customData, custom4)
  10019. custom5 := &CustomData{
  10020. MsgId: "H44022900158202103301748008725",
  10021. PsnNo: "44020000001104246641",
  10022. Info: "2207",
  10023. }
  10024. customData = append(customData, custom5)
  10025. custom6 := &CustomData{
  10026. MsgId: "H44022900158202103301718096755",
  10027. PsnNo: "44020000001102211860",
  10028. Info: "2207",
  10029. }
  10030. customData = append(customData, custom6)
  10031. custom7 := &CustomData{
  10032. MsgId: "H44022900158202103301736551640",
  10033. PsnNo: "44020000001102687718",
  10034. Info: "2207",
  10035. }
  10036. customData = append(customData, custom7)
  10037. custom8 := &CustomData{
  10038. MsgId: "H44022900158202103301743097676",
  10039. PsnNo: "44020000001102127785",
  10040. Info: "2207",
  10041. }
  10042. customData = append(customData, custom8)
  10043. custom9 := &CustomData{
  10044. MsgId: "H44022900158202103301712304203",
  10045. PsnNo: "44020000001101518097",
  10046. Info: "2207",
  10047. }
  10048. customData = append(customData, custom9)
  10049. custom10 := &CustomData{
  10050. MsgId: "H44022900158202103301738448785",
  10051. PsnNo: "44020000001100500813",
  10052. Info: "2207",
  10053. }
  10054. customData = append(customData, custom10)
  10055. custom11 := &CustomData{
  10056. MsgId: "H44022900158202103301732455843",
  10057. PsnNo: "44020000001102690557",
  10058. Info: "2207",
  10059. }
  10060. customData = append(customData, custom11)
  10061. custom12 := &CustomData{
  10062. MsgId: "H44022900158202103301745421708",
  10063. PsnNo: "44020000001102211928",
  10064. Info: "2207",
  10065. }
  10066. customData = append(customData, custom12)
  10067. custom1212 := &CustomData{
  10068. MsgId: "H440229001582021033017351627",
  10069. PsnNo: "44020000001102481733",
  10070. Info: "2207",
  10071. }
  10072. customData = append(customData, custom1212)
  10073. custom13 := &CustomData{
  10074. MsgId: "H44022900158202103301740327951",
  10075. PsnNo: "44020000001103174866",
  10076. Info: "2207",
  10077. }
  10078. customData = append(customData, custom13)
  10079. custom14 := &CustomData{
  10080. MsgId: "H4402290015820210330174922668",
  10081. PsnNo: "44020000001102927272",
  10082. Info: "2207",
  10083. }
  10084. customData = append(customData, custom14)
  10085. custom15 := &CustomData{
  10086. MsgId: "H44022900158202103301752362273",
  10087. PsnNo: "44020000001102942890",
  10088. Info: "2207",
  10089. }
  10090. customData = append(customData, custom15)
  10091. custom16 := &CustomData{
  10092. MsgId: "H44022900158202103301751082917",
  10093. PsnNo: "44020000001101662162",
  10094. Info: "2207",
  10095. }
  10096. customData = append(customData, custom16)
  10097. custom17 := &CustomData{
  10098. MsgId: "H44022900158202103301754147728",
  10099. PsnNo: "44020000000229014511",
  10100. Info: "2207",
  10101. }
  10102. customData = append(customData, custom17)
  10103. adminUser := c.GetAdminUserInfo()
  10104. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10105. for _, item := range customData {
  10106. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10107. fmt.Println(result)
  10108. }
  10109. }
  10110. func (c *HisApiController) GetAllopatry() {
  10111. year := c.GetString("year")
  10112. month := c.GetString("month")
  10113. admin_user_id, _ := c.GetInt64("admin_user_id")
  10114. adminUser := c.GetAdminUserInfo()
  10115. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10116. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10117. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10118. var dat map[string]interface{}
  10119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10120. fmt.Println(dat)
  10121. } else {
  10122. fmt.Println(err)
  10123. }
  10124. userJSONBytes, _ := json.Marshal(dat)
  10125. var res models.Result9001
  10126. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10127. utils.ErrorLog("解析失败:%v", err)
  10128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10129. return
  10130. }
  10131. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10132. var dat2 map[string]interface{}
  10133. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10134. fmt.Println(dat)
  10135. } else {
  10136. fmt.Println(err)
  10137. }
  10138. userJSONBytes2, _ := json.Marshal(dat2)
  10139. var res2 models.Result3260
  10140. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10141. utils.ErrorLog("解析失败:%v", err)
  10142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10143. return
  10144. }
  10145. if res2.Infcode == 0 {
  10146. c.ServeSuccessJSON(map[string]interface{}{
  10147. "list": res2.Output.Data,
  10148. })
  10149. return
  10150. } else {
  10151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10152. return
  10153. }
  10154. }
  10155. func (c *HisApiController) ComfirmAllopatry() {
  10156. year := c.GetString("year")
  10157. month := c.GetString("month")
  10158. admin_user_id, _ := c.GetInt64("admin_user_id")
  10159. adminUser := c.GetAdminUserInfo()
  10160. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10161. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10162. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10163. var dat map[string]interface{}
  10164. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10165. fmt.Println(dat)
  10166. } else {
  10167. fmt.Println(err)
  10168. }
  10169. userJSONBytes, _ := json.Marshal(dat)
  10170. var res models.Result9001
  10171. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10172. utils.ErrorLog("解析失败:%v", err)
  10173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10174. return
  10175. }
  10176. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10177. var dat2 map[string]interface{}
  10178. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10179. fmt.Println(dat)
  10180. } else {
  10181. fmt.Println(err)
  10182. }
  10183. userJSONBytes2, _ := json.Marshal(dat2)
  10184. var res2 models.Result3260
  10185. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10186. utils.ErrorLog("解析失败:%v", err)
  10187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10188. return
  10189. }
  10190. if res2.Infcode == 0 {
  10191. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10192. var dat map[string]interface{}
  10193. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10194. fmt.Println(dat)
  10195. } else {
  10196. fmt.Println(err)
  10197. }
  10198. userJSONBytes, _ := json.Marshal(dat)
  10199. var res3 models.Result3261
  10200. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10201. utils.ErrorLog("解析失败:%v", err)
  10202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10203. return
  10204. }
  10205. if res3.Infcode == 0 {
  10206. record := &models.HisYidiClearRecord{
  10207. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10208. Ctime: time.Now().Unix(),
  10209. Mtime: time.Now().Unix(),
  10210. Status: 1,
  10211. MsgId: msgId,
  10212. }
  10213. service.SaveClearRecord(record)
  10214. c.ServeSuccessJSON(map[string]interface{}{
  10215. "msg": "提取成功",
  10216. })
  10217. }
  10218. }
  10219. }
  10220. func (c *HisApiController) RefundAllopatry() {
  10221. year := c.GetString("year")
  10222. month := c.GetString("month")
  10223. id, _ := c.GetInt64("id")
  10224. admin_user_id, _ := c.GetInt64("admin_user_id")
  10225. adminUser := c.GetAdminUserInfo()
  10226. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10227. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10228. record, _ := service.GetClearRecordById(id)
  10229. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10230. var dat map[string]interface{}
  10231. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10232. fmt.Println(dat)
  10233. } else {
  10234. fmt.Println(err)
  10235. }
  10236. userJSONBytes, _ := json.Marshal(dat)
  10237. var empty ResultFourteen
  10238. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10239. utils.ErrorLog("解析失败:%v", err)
  10240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10241. return
  10242. }
  10243. if empty.Infcode == 0 {
  10244. c.ServeSuccessJSON(map[string]interface{}{
  10245. "msg": "撤销成功",
  10246. })
  10247. return
  10248. }
  10249. }
  10250. func (c *HisApiController) ReversalOtherData() {
  10251. var customData []*CustomData
  10252. custom := &CustomData{
  10253. MsgId: "H44022900158202103301714472004",
  10254. PsnNo: "44020000001101329945",
  10255. Info: "2208",
  10256. }
  10257. customData = append(customData, custom)
  10258. custom1 := &CustomData{
  10259. MsgId: "H4402290015820210330172057803",
  10260. PsnNo: "44020000001101161813",
  10261. Info: "2208",
  10262. }
  10263. customData = append(customData, custom1)
  10264. custom2 := &CustomData{
  10265. MsgId: "H44022900158202103301705198813",
  10266. PsnNo: "44190000133097375417",
  10267. Info: "2208",
  10268. }
  10269. customData = append(customData, custom2)
  10270. custom3 := &CustomData{
  10271. MsgId: "H44022900158202103301715524756",
  10272. PsnNo: "44020000001100187221",
  10273. Info: "2208",
  10274. }
  10275. customData = append(customData, custom3)
  10276. custom4 := &CustomData{
  10277. MsgId: "H44022900158202103301730376224",
  10278. PsnNo: "44020000001101959155",
  10279. Info: "2208",
  10280. }
  10281. customData = append(customData, custom4)
  10282. custom5 := &CustomData{
  10283. MsgId: "H44022900158202103301748008725",
  10284. PsnNo: "44020000001104246641",
  10285. Info: "2208",
  10286. }
  10287. customData = append(customData, custom5)
  10288. custom6 := &CustomData{
  10289. MsgId: "H44022900158202103301718096755",
  10290. PsnNo: "44020000001102211860",
  10291. Info: "2208",
  10292. }
  10293. customData = append(customData, custom6)
  10294. custom7 := &CustomData{
  10295. MsgId: "H44022900158202103301736551640",
  10296. PsnNo: "44020000001102687718",
  10297. Info: "2208",
  10298. }
  10299. customData = append(customData, custom7)
  10300. custom8 := &CustomData{
  10301. MsgId: "H44022900158202103301743097676",
  10302. PsnNo: "44020000001102127785",
  10303. Info: "2208",
  10304. }
  10305. customData = append(customData, custom8)
  10306. custom9 := &CustomData{
  10307. MsgId: "H44022900158202103301712304203",
  10308. PsnNo: "44020000001101518097",
  10309. Info: "2208",
  10310. }
  10311. customData = append(customData, custom9)
  10312. custom10 := &CustomData{
  10313. MsgId: "H44022900158202103301738448785",
  10314. PsnNo: "44020000001100500813",
  10315. Info: "2208",
  10316. }
  10317. customData = append(customData, custom10)
  10318. custom11 := &CustomData{
  10319. MsgId: "H44022900158202103301732455843",
  10320. PsnNo: "44020000001102690557",
  10321. Info: "2208",
  10322. }
  10323. customData = append(customData, custom11)
  10324. custom12 := &CustomData{
  10325. MsgId: "H44022900158202103301745421708",
  10326. PsnNo: "44020000001102211928",
  10327. Info: "2208",
  10328. }
  10329. customData = append(customData, custom12)
  10330. custom1212 := &CustomData{
  10331. MsgId: "H440229001582021033017351627",
  10332. PsnNo: "44020000001102481733",
  10333. Info: "2208",
  10334. }
  10335. customData = append(customData, custom1212)
  10336. custom13 := &CustomData{
  10337. MsgId: "H44022900158202103301740327951",
  10338. PsnNo: "44020000001103174866",
  10339. Info: "2208",
  10340. }
  10341. customData = append(customData, custom13)
  10342. custom14 := &CustomData{
  10343. MsgId: "H4402290015820210330174922668",
  10344. PsnNo: "44020000001102927272",
  10345. Info: "2208",
  10346. }
  10347. customData = append(customData, custom14)
  10348. custom15 := &CustomData{
  10349. MsgId: "H44022900158202103301752362273",
  10350. PsnNo: "44020000001102942890",
  10351. Info: "2208",
  10352. }
  10353. customData = append(customData, custom15)
  10354. custom16 := &CustomData{
  10355. MsgId: "H44022900158202103301751082917",
  10356. PsnNo: "44020000001101662162",
  10357. Info: "2208",
  10358. }
  10359. customData = append(customData, custom16)
  10360. custom17 := &CustomData{
  10361. MsgId: "H44022900158202103301754147728",
  10362. PsnNo: "44020000000229014511",
  10363. Info: "2208",
  10364. }
  10365. customData = append(customData, custom17)
  10366. adminUser := c.GetAdminUserInfo()
  10367. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10368. for _, item := range customData {
  10369. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10370. fmt.Println(result)
  10371. }
  10372. }
  10373. func PathExists(path string) (bool, error) {
  10374. _, err := os.Stat(path)
  10375. if err == nil {
  10376. return true, nil
  10377. }
  10378. if os.IsNotExist(err) {
  10379. return false, nil
  10380. }
  10381. return false, err
  10382. }
  10383. //创建文件夹
  10384. func Mkdir(dir string) {
  10385. // 创建文件夹
  10386. exist, err := PathExists(dir)
  10387. if err != nil {
  10388. fmt.Println(err.Error())
  10389. } else {
  10390. if exist {
  10391. fmt.Println(dir + "文件夹已存在!")
  10392. } else {
  10393. // 文件夹名称,权限
  10394. err := os.Mkdir(dir, os.ModePerm)
  10395. if err != nil {
  10396. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10397. } else {
  10398. fmt.Println(dir + "文件夹创建成功!")
  10399. }
  10400. }
  10401. }
  10402. }
  10403. //压缩文件
  10404. func Zip(srcFile string, destZip string) error {
  10405. zipfile, err := os.Create(destZip)
  10406. if err != nil {
  10407. return err
  10408. }
  10409. defer zipfile.Close()
  10410. archive := zip.NewWriter(zipfile)
  10411. defer archive.Close()
  10412. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10413. if err != nil {
  10414. return err
  10415. }
  10416. header, err := zip.FileInfoHeader(info)
  10417. if err != nil {
  10418. return err
  10419. }
  10420. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10421. // header.Name = path
  10422. if info.IsDir() {
  10423. header.Name += "/"
  10424. } else {
  10425. header.Method = zip.Deflate
  10426. }
  10427. writer, err := archive.CreateHeader(header)
  10428. if err != nil {
  10429. return err
  10430. }
  10431. if !info.IsDir() {
  10432. file, err := os.Open(path)
  10433. if err != nil {
  10434. return err
  10435. }
  10436. defer file.Close()
  10437. _, err = io.Copy(writer, file)
  10438. }
  10439. return err
  10440. })
  10441. return err
  10442. }
  10443. func ReadFile(filePath string) []byte {
  10444. f, err := os.Open(filePath)
  10445. if err != nil {
  10446. fmt.Println("read file fail", err)
  10447. return nil
  10448. }
  10449. defer f.Close()
  10450. fd, err := ioutil.ReadAll(f)
  10451. if err != nil {
  10452. fmt.Println("read to fd fail", err)
  10453. return nil
  10454. }
  10455. return fd
  10456. }
  10457. func saveLog(result string, request string, infno string, desc string) {
  10458. org_id, _ := beego.AppConfig.Int64("org_id")
  10459. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10460. dir := miConfig.OrgName + "日志"
  10461. utils.Mkdir(dir)
  10462. month := time.Unix(1557042972, 0).Format("1")
  10463. year := time.Now().Format("2006")
  10464. month = time.Now().Format("01")
  10465. day := time.Now().Format("02")
  10466. hour := time.Now().Format("15")
  10467. min := time.Now().Format("04")
  10468. sec := time.Now().Format("05")
  10469. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10470. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10471. file_name := file + ".txt"
  10472. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10473. exist, _ := utils.PathExists(file_path)
  10474. if exist { //存在
  10475. fmt.Println("存在")
  10476. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10477. if err != nil {
  10478. fmt.Println("read fail")
  10479. }
  10480. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10481. n, _ := f.Seek(0, 2)
  10482. _, err = f.WriteAt([]byte(content), n)
  10483. } else { //不存在
  10484. fmt.Println("文件不存在,创建文件")
  10485. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10486. defer f.Close()
  10487. if err != nil {
  10488. } else {
  10489. _, err = f.Write([]byte("记录日志"))
  10490. }
  10491. }
  10492. }
  10493. type Charset string
  10494. const (
  10495. UTF8 = Charset("UTF-8")
  10496. GB18030 = Charset("GB18030")
  10497. )
  10498. func ConvertToString(src string, srcCode string, tagCode string) string {
  10499. srcCoder := mahonia.NewDecoder(srcCode)
  10500. srcResult := srcCoder.ConvertString(src)
  10501. tagCoder := mahonia.NewDecoder(tagCode)
  10502. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10503. result := string(cdata)
  10504. return result
  10505. }