his_api_controller.go 422KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551
  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.RequestUrl = miConfig.Url
  109. pp.Cainfo = miConfig.Cainfo
  110. pp.SecretKey = miConfig.SecretKey
  111. pp.AccessKey = miConfig.AccessKey
  112. pp.OpterName = roles.UserName
  113. var config []*models.HisXtDiagnoseConfig
  114. for _, item := range diagnosis_ids {
  115. id, _ := strconv.ParseInt(item, 10, 64)
  116. diagnosisConfig, _ := service.FindDiagnoseById(id)
  117. config = append(config, &diagnosisConfig)
  118. }
  119. var pd models.PatientDtos
  120. pd.PatnID = his.PsnNo
  121. pd.PatnName = his.Name
  122. pd.Gend = his.Gend
  123. pd.Brdy = his.Brdy
  124. pd.Poolarea = his.InsuplcAdmdvs
  125. pd.CurrMdtrtID = his.Number
  126. var fed models.FsiEncounterDtos
  127. fed.MdtrtID = his.Number
  128. fed.MedinsID = miConfig.Code
  129. fed.MedinsName = miConfig.OrgName
  130. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  131. fed.MedMdtrtType = "1"
  132. fed.MedinsLv = "11"
  133. tm := time.Unix(his.RecordDate, 0)
  134. s_tm := tm.Format("2006-01-02 15:04:05")
  135. fed.AdmDate = s_tm
  136. fed.DscgDate = s_tm
  137. fed.DscgMainDiseCodg = config[0].CountryCode
  138. fed.DscgMainDiseName = config[0].CountryContentName
  139. //诊断信息
  140. var fdds []*models.FsiDiagnoseDtos
  141. for index, item := range config {
  142. if index == 0 {
  143. var fdd models.FsiDiagnoseDtos
  144. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  145. fdd.InoutDiseType = "1"
  146. fdd.MaindiseFlag = "1"
  147. fdd.DiseDate = s_tm
  148. fdd.DiasSrtNo = "1"
  149. fdd.DiseName = item.CountryContentName
  150. fdd.DiseCodg = item.CountryCode
  151. fdds = append(fdds, &fdd)
  152. } else {
  153. var fdd models.FsiDiagnoseDtos
  154. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  155. fdd.InoutDiseType = "1"
  156. fdd.MaindiseFlag = "1"
  157. fdd.DiseDate = s_tm
  158. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  159. fdd.DiseName = item.CountryContentName
  160. fdd.DiseCodg = item.CountryCode
  161. fdds = append(fdds, &fdd)
  162. }
  163. }
  164. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  165. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  166. fed.AdmDeptName = department.Name
  167. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  168. fed.DscgDeptName = department.Name
  169. fed.MedMdtrtType = ""
  170. if his.Insutype == "390" {
  171. fed.MedType = "1402"
  172. } else {
  173. fed.MedType = "9933"
  174. }
  175. var orders []*models.FsiOrderDtos
  176. if trig_scen == "2" {
  177. //处方医嘱信息
  178. for _, item := range prescriptions {
  179. for _, subItem := range item.HisDoctorAdviceInfo {
  180. var order models.FsiOrderDtos
  181. order.RxID = strconv.FormatInt(item.ID, 10)
  182. order.Rxno = strconv.FormatInt(item.ID, 10)
  183. order.LongDrordFlag = "0"
  184. order.HilistType = "1"
  185. order.ChrgType = "1"
  186. order.DrordBhvr = "-"
  187. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  188. order.HosplistName = subItem.BaseDrugLib.DrugName
  189. order.HilistLv = "1"
  190. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  191. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  192. order.HosplistName = subItem.BaseDrugLib.DrugName
  193. order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  194. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  195. order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  196. order.OwnpayAmt = ""
  197. order.SelfpayAmt = ""
  198. order.Spec = ""
  199. order.SpecUnt = ""
  200. order.DrordBegnDate = s_tm
  201. order.DrordStopDate = ""
  202. order.DrordDrCodg = "1"
  203. order.DrordDeptName = department.Name
  204. order.DrordDrCodg = "1"
  205. order.DrordDrName = doctor_info.UserName
  206. order.DrordDrProfttl = ""
  207. order.CurrDrordFlag = "1"
  208. orders = append(orders, &order)
  209. }
  210. for _, subItem := range item.HisPrescriptionProject {
  211. if subItem.Type == 2 {
  212. var order models.FsiOrderDtos
  213. order.RxID = strconv.FormatInt(item.ID, 10)
  214. order.Rxno = strconv.FormatInt(item.ID, 10)
  215. order.LongDrordFlag = "0"
  216. order.HilistType = "1"
  217. order.ChrgType = "1"
  218. order.DrordBhvr = "-"
  219. order.HilistCode = subItem.HisProject.MedicalCode
  220. order.HosplistName = subItem.HisProject.ProjectName
  221. order.HilistLv = "1"
  222. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  223. order.HosplistCode = subItem.HisProject.MedicalCode
  224. order.HosplistName = subItem.HisProject.ProjectName
  225. order.Cnt = subItem.Count
  226. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  227. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  228. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  229. order.OwnpayAmt = ""
  230. order.SelfpayAmt = ""
  231. order.Spec = ""
  232. order.SpecUnt = ""
  233. order.DrordBegnDate = s_tm
  234. order.DrordStopDate = ""
  235. order.DrordDrCodg = "1"
  236. order.DrordDeptName = department.Name
  237. order.DrordDrCodg = "1"
  238. order.DrordDrName = doctor_info.UserName
  239. order.DrordDrProfttl = ""
  240. order.CurrDrordFlag = "1"
  241. orders = append(orders, &order)
  242. }
  243. if subItem.Type == 3 {
  244. var order models.FsiOrderDtos
  245. order.RxID = strconv.FormatInt(item.ID, 10)
  246. order.Rxno = strconv.FormatInt(item.ID, 10)
  247. order.LongDrordFlag = "0"
  248. order.HilistType = "1"
  249. order.ChrgType = "1"
  250. order.DrordBhvr = "-"
  251. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  252. order.HosplistName = subItem.GoodInfo.GoodName
  253. order.HilistLv = "1"
  254. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  255. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  256. order.HosplistName = subItem.GoodInfo.GoodName
  257. order.Cnt = subItem.Count
  258. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  259. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  260. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  261. order.OwnpayAmt = ""
  262. order.SelfpayAmt = ""
  263. order.Spec = ""
  264. order.SpecUnt = ""
  265. order.DrordBegnDate = s_tm
  266. order.DrordStopDate = ""
  267. order.DrordDrCodg = "1"
  268. order.DrordDeptName = department.Name
  269. order.DrordDrCodg = "1"
  270. order.DrordDrName = doctor_info.UserName
  271. order.DrordDrProfttl = ""
  272. order.CurrDrordFlag = "1"
  273. orders = append(orders, &order)
  274. }
  275. }
  276. }
  277. //处方医嘱信息
  278. }
  279. fed.MatnStas = "0"
  280. fed.MedfeeSumamt = "0"
  281. fed.OwnpayAmt = "0"
  282. fed.SelfpayAmt = "0"
  283. fed.AcctPayamt = "0"
  284. fed.MaAmt = "0"
  285. fed.HifpPayamt = "0"
  286. fed.SetlTotlnum = "0"
  287. fed.Insutype = his.Insutype
  288. fed.ReimFlag = "0"
  289. fed.OutSetlFlag = "0"
  290. var fopd []*models.FsiOperationDtosData
  291. data := make(map[string]interface{})
  292. data["fed"] = fed
  293. data["fdd"] = fdds
  294. data["fod"] = orders
  295. data["pd"] = pd
  296. data["pp"] = pp
  297. data["fopd"] = fopd
  298. data["trig_scen"] = trig_scen
  299. fmt.Println(data)
  300. fmt.Println(fed)
  301. fmt.Println(fdds)
  302. fmt.Println(orders)
  303. fmt.Println(pd)
  304. fmt.Println(pp)
  305. fmt.Println(fopd)
  306. client := &http.Client{}
  307. bytesData, _ := json.Marshal(data)
  308. var req *http.Request
  309. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  310. resp, _ := client.Do(req)
  311. defer resp.Body.Close()
  312. body, ioErr := ioutil.ReadAll(resp.Body)
  313. if ioErr != nil {
  314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  316. return
  317. }
  318. var respJSON map[string]interface{}
  319. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  322. return
  323. }
  324. //手术操作集合
  325. //手术操作集合
  326. }
  327. func (c *HisApiController) Check3102() {
  328. patient_id, _ := c.GetInt64("patient_id")
  329. order_id, _ := c.GetInt64("order_id")
  330. his_patient_id, _ := c.GetInt64("his_patient_id")
  331. admin_user_id, _ := c.GetInt64("admin_user_id")
  332. trig_scen := c.GetString("trig_scen")
  333. adminUser := c.GetAdminUserInfo()
  334. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  335. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  336. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  337. record_time := c.GetString("record_time")
  338. order, _ := service.GetHisOrderByID(order_id)
  339. timeLayout := "2006-01-02"
  340. loc, _ := time.LoadLocation("Local")
  341. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  342. if err != nil {
  343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  344. return
  345. }
  346. recordDateTime := theTime.Unix()
  347. var patientPrescription models.HisPrescriptionInfo
  348. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  349. if patientPrescription.ID == 0 {
  350. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  351. }
  352. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  353. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  354. //
  355. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  356. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  357. var pp models.PublicParams
  358. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  359. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  360. pp.FixmedinsName = miConfig.OrgName
  361. pp.FixmedinsCode = miConfig.Code
  362. pp.RequestUrl = miConfig.Url
  363. pp.Cainfo = miConfig.Cainfo
  364. pp.SecretKey = miConfig.SecretKey
  365. pp.AccessKey = miConfig.AccessKey
  366. pp.OpterName = roles.UserName
  367. var config []*models.HisXtDiagnoseConfig
  368. for _, item := range diagnosis_ids {
  369. id, _ := strconv.ParseInt(item, 10, 64)
  370. diagnosisConfig, _ := service.FindDiagnoseById(id)
  371. config = append(config, &diagnosisConfig)
  372. }
  373. var pd models.PatientDtos
  374. pd.PatnID = his.PsnNo
  375. pd.PatnName = his.Name
  376. pd.Gend = his.Gend
  377. pd.Brdy = his.Brdy
  378. pd.Poolarea = his.InsuplcAdmdvs
  379. pd.CurrMdtrtID = his.Number
  380. var fed models.FsiEncounterDtos
  381. fed.MdtrtID = his.Number
  382. fed.MedinsID = miConfig.Code
  383. fed.MedinsName = miConfig.OrgName
  384. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  385. fed.MedMdtrtType = "1"
  386. fed.MedinsLv = "11"
  387. tm := time.Unix(his.RecordDate, 0)
  388. s_tm := tm.Format("2006-01-02 15:04:05")
  389. fed.AdmDate = s_tm
  390. fed.DscgDate = s_tm
  391. fed.DscgMainDiseCodg = config[0].CountryCode
  392. fed.DscgMainDiseName = config[0].CountryContentName
  393. //诊断信息
  394. var fdds []*models.FsiDiagnoseDtos
  395. for index, item := range config {
  396. if index == 0 {
  397. var fdd models.FsiDiagnoseDtos
  398. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  399. fdd.InoutDiseType = "1"
  400. fdd.MaindiseFlag = "1"
  401. fdd.DiseDate = s_tm
  402. fdd.DiasSrtNo = "1"
  403. fdd.DiseName = item.CountryContentName
  404. fdd.DiseCodg = item.CountryCode
  405. fdds = append(fdds, &fdd)
  406. } else {
  407. var fdd models.FsiDiagnoseDtos
  408. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  409. fdd.InoutDiseType = "1"
  410. fdd.MaindiseFlag = "1"
  411. fdd.DiseDate = s_tm
  412. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  413. fdd.DiseName = item.CountryContentName
  414. fdd.DiseCodg = item.CountryCode
  415. fdds = append(fdds, &fdd)
  416. }
  417. }
  418. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  419. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  420. fed.AdmDeptName = department.Name
  421. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  422. fed.DscgDeptName = department.Name
  423. fed.MedMdtrtType = ""
  424. fed.MedType = order.MedType
  425. //处方医嘱信息
  426. var orders []*models.FsiOrderDtos
  427. for _, item := range prescriptions {
  428. for _, subItem := range item.HisDoctorAdviceInfo {
  429. var order models.FsiOrderDtos
  430. order.RxID = strconv.FormatInt(item.ID, 10)
  431. order.Rxno = strconv.FormatInt(item.ID, 10)
  432. order.LongDrordFlag = "0"
  433. order.HilistType = "1"
  434. order.ChrgType = "1"
  435. order.DrordBhvr = "-"
  436. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  437. order.HosplistName = subItem.BaseDrugLib.DrugName
  438. order.HilistLv = "1"
  439. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  440. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  441. order.HosplistName = subItem.BaseDrugLib.DrugName
  442. order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  443. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  444. order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  445. order.OwnpayAmt = ""
  446. order.SelfpayAmt = ""
  447. order.Spec = ""
  448. order.SpecUnt = ""
  449. order.DrordBegnDate = s_tm
  450. order.DrordStopDate = ""
  451. order.DrordDrCodg = "1"
  452. order.DrordDeptName = department.Name
  453. order.DrordDrCodg = "1"
  454. order.DrordDrName = doctor_info.UserName
  455. order.DrordDrProfttl = ""
  456. order.CurrDrordFlag = "1"
  457. orders = append(orders, &order)
  458. }
  459. for _, subItem := range item.HisPrescriptionProject {
  460. if subItem.Type == 2 {
  461. var order models.FsiOrderDtos
  462. order.RxID = strconv.FormatInt(item.ID, 10)
  463. order.Rxno = strconv.FormatInt(item.ID, 10)
  464. order.LongDrordFlag = "0"
  465. order.HilistType = "1"
  466. order.ChrgType = "1"
  467. order.DrordBhvr = "-"
  468. order.HilistCode = subItem.HisProject.MedicalCode
  469. order.HosplistName = subItem.HisProject.ProjectName
  470. order.HilistLv = "1"
  471. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  472. order.HosplistCode = subItem.HisProject.MedicalCode
  473. order.HosplistName = subItem.HisProject.ProjectName
  474. order.Cnt = subItem.Count
  475. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  476. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  477. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  478. order.OwnpayAmt = ""
  479. order.SelfpayAmt = ""
  480. order.Spec = ""
  481. order.SpecUnt = ""
  482. order.DrordBegnDate = s_tm
  483. order.DrordStopDate = ""
  484. order.DrordDrCodg = "1"
  485. order.DrordDeptName = department.Name
  486. order.DrordDrCodg = "1"
  487. order.DrordDrName = doctor_info.UserName
  488. order.DrordDrProfttl = ""
  489. order.CurrDrordFlag = "1"
  490. orders = append(orders, &order)
  491. }
  492. if subItem.Type == 3 {
  493. var order models.FsiOrderDtos
  494. order.RxID = strconv.FormatInt(item.ID, 10)
  495. order.Rxno = strconv.FormatInt(item.ID, 10)
  496. order.LongDrordFlag = "0"
  497. order.HilistType = "1"
  498. order.ChrgType = "1"
  499. order.DrordBhvr = "-"
  500. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  501. order.HosplistName = subItem.GoodInfo.GoodName
  502. order.HilistLv = "1"
  503. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  504. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  505. order.HosplistName = subItem.GoodInfo.GoodName
  506. order.Cnt = subItem.Count
  507. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  508. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  509. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  510. order.OwnpayAmt = ""
  511. order.SelfpayAmt = ""
  512. order.Spec = ""
  513. order.SpecUnt = ""
  514. order.DrordBegnDate = s_tm
  515. order.DrordStopDate = ""
  516. order.DrordDrCodg = "1"
  517. order.DrordDeptName = department.Name
  518. order.DrordDrCodg = "1"
  519. order.DrordDrName = doctor_info.UserName
  520. order.DrordDrProfttl = ""
  521. order.CurrDrordFlag = "1"
  522. orders = append(orders, &order)
  523. }
  524. }
  525. }
  526. //处方医嘱信息
  527. fed.MatnStas = "0"
  528. fed.MedfeeSumamt = strconv.FormatFloat(order.MedfeeSumamt, 'E', -1, 64)
  529. fed.OwnpayAmt = strconv.FormatFloat(order.FulamtOwnpayAmt, 'E', -1, 64)
  530. fed.SelfpayAmt = strconv.FormatFloat(order.PreselfpayAmt, 'E', -1, 64)
  531. fed.AcctPayamt = strconv.FormatFloat(order.AcctPay, 'E', -1, 64)
  532. fed.MaAmt = strconv.FormatFloat(order.MafPay, 'E', -1, 64)
  533. fed.HifpPayamt = strconv.FormatFloat(order.HifpPay, 'E', -1, 64)
  534. fed.SetlTotlnum = "1"
  535. fed.Insutype = his.Insutype
  536. fed.ReimFlag = "0"
  537. fed.OutSetlFlag = "0"
  538. var fopd []*models.FsiOperationDtosData
  539. data := make(map[string]interface{})
  540. data["fed"] = fed
  541. data["fdd"] = fdds
  542. data["fod"] = orders
  543. data["pd"] = pd
  544. data["pp"] = pp
  545. data["fopd"] = fopd
  546. data["trig_scen"] = trig_scen
  547. fmt.Println(data)
  548. fmt.Println(fed)
  549. fmt.Println(fdds)
  550. fmt.Println(orders)
  551. fmt.Println(pd)
  552. fmt.Println(pp)
  553. fmt.Println(fopd)
  554. client := &http.Client{}
  555. bytesData, _ := json.Marshal(data)
  556. var req *http.Request
  557. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  558. resp, _ := client.Do(req)
  559. defer resp.Body.Close()
  560. body, ioErr := ioutil.ReadAll(resp.Body)
  561. if ioErr != nil {
  562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  564. return
  565. }
  566. var respJSON map[string]interface{}
  567. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  570. return
  571. }
  572. //手术操作集合
  573. //手术操作集合
  574. }
  575. func (c *HisApiController) Check() {
  576. psn_no := c.GetString("psn_no")
  577. in := c.GetString("in")
  578. mt := c.GetString("mt")
  579. baseParams := models.BaseParams{
  580. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  581. FixmedinsCode: "H15049901371",
  582. InsuplcAdmdvs: "150499",
  583. MdtrtareaAdmvs: "150499",
  584. OrgName: "赤峰费森血液透析中心",
  585. Doctor: "1111",
  586. }
  587. service.Gdyb2001(baseParams, psn_no, in, mt)
  588. }
  589. func (c *HisApiController) GetPsnNcdsInfo() {
  590. admin_user_id, _ := c.GetInt64("admin_user_id")
  591. patient_id, _ := c.GetInt64("patient_id")
  592. id, _ := c.GetInt64("id")
  593. adminUser := c.GetAdminUserInfo()
  594. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  595. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  596. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  597. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  598. psn_record, _ := service.GetPsnNCDSRecordById(id)
  599. //
  600. //if psn_record.ID == 0 {
  601. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  602. // return
  603. //}
  604. var res Result5301
  605. var res10265 Result5301For10265
  606. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  607. psn_info, _ := service.GetPsnByPatientId(patient_id)
  608. var api string
  609. if miConfig.MdtrtareaAdmvs == "320921" {
  610. 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 +
  611. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  612. } else {
  613. 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 +
  614. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  615. }
  616. resp, requestErr := http.Get(api)
  617. if requestErr != nil {
  618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  619. return
  620. }
  621. body, ioErr := ioutil.ReadAll(resp.Body)
  622. if ioErr != nil {
  623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  625. return
  626. }
  627. var respJSON map[string]interface{}
  628. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  631. return
  632. }
  633. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  634. result, _ := json.Marshal(respJSON)
  635. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  636. utils.ErrorLog("解析失败:%v", err)
  637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  638. return
  639. }
  640. res.ErrMsg = res10265.ErrMsg
  641. res.Output = res10265.Output
  642. res.InfRefmsgid = res10265.InfRefmsgid
  643. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  644. res.Infcode = infocode
  645. } else {
  646. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  647. var dat map[string]interface{}
  648. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  649. fmt.Println(dat)
  650. } else {
  651. fmt.Println(err)
  652. }
  653. userJSONBytes, _ := json.Marshal(dat)
  654. if miConfig.Code == "H15049901371" {
  655. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  656. utils.ErrorLog("解析失败:%v", err)
  657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  658. return
  659. }
  660. res.InfRefmsgid = res10265.InfRefmsgid
  661. res.Output = res10265.Output
  662. res.ErrMsg = res10265.ErrMsg
  663. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  664. res.Infcode = infocode
  665. } else {
  666. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  667. utils.ErrorLog("解析失败:%v", err)
  668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  669. return
  670. }
  671. }
  672. }
  673. if res.Infcode == 0 {
  674. c.ServeSuccessJSON(map[string]interface{}{
  675. "result": res.Output.Result,
  676. })
  677. }
  678. }
  679. func (c *HisApiController) CheckInsutype() {
  680. his_patient_id, _ := c.GetInt64("his_patient_id")
  681. admin_user_id, _ := c.GetInt64("admin_user_id")
  682. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  683. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  684. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  685. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  686. var dat map[string]interface{}
  687. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  688. fmt.Println(dat)
  689. } else {
  690. fmt.Println(err)
  691. }
  692. userJSONBytes, _ := json.Marshal(dat)
  693. var res Result90100
  694. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  695. utils.ErrorLog("解析失败:%v", err)
  696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  697. return
  698. }
  699. if res.Infcode != 0 {
  700. c.ServeSuccessJSON(map[string]interface{}{
  701. "failed_code": -10,
  702. "msg": res.ErrMsg,
  703. })
  704. return
  705. } else {
  706. fmt.Println(res)
  707. }
  708. }
  709. func (c *HisApiController) CheckCardPWD() {
  710. card_pwd := c.GetString("card_pwd")
  711. his_patient_id, _ := c.GetInt64("his_patient_id")
  712. admin_user_id, _ := c.GetInt64("admin_user_id")
  713. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  714. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  715. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  716. psn, _ := service.GetPsnByPatientId(his.PatientId)
  717. bas := strings.Split(psn.CardInfo, "|")
  718. basNumber := bas[2]
  719. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  720. var dat map[string]interface{}
  721. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  722. fmt.Println(dat)
  723. } else {
  724. fmt.Println(err)
  725. }
  726. userJSONBytes, _ := json.Marshal(dat)
  727. var res Result90991
  728. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  729. utils.ErrorLog("解析失败:%v", err)
  730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  731. return
  732. }
  733. if res.Infcode != 0 {
  734. c.ServeSuccessJSON(map[string]interface{}{
  735. "failed_code": -10,
  736. "msg": res.ErrMsg,
  737. })
  738. return
  739. } else {
  740. if res.Output.Result.CheckStat == "0" {
  741. var msg string
  742. switch res.Output.Result.CardStat {
  743. case "00":
  744. msg = "未激活"
  745. break
  746. case "10":
  747. msg = "激活"
  748. break
  749. case "20":
  750. msg = "窗口挂失"
  751. break
  752. case "21":
  753. msg = "电话挂失"
  754. break
  755. case "22":
  756. msg = "单位网上申报挂失"
  757. break
  758. case "23":
  759. msg = "保健办挂失"
  760. break
  761. case "24":
  762. msg = "个人网上挂失"
  763. break
  764. case "25":
  765. msg = "网上服务大厅挂失"
  766. break
  767. case "30":
  768. msg = "注销"
  769. break
  770. case "40":
  771. msg = "回收"
  772. break
  773. case "99":
  774. msg = "制卡中(无效卡)"
  775. break
  776. }
  777. c.ServeSuccessJSON(map[string]interface{}{
  778. "failed_code": -10,
  779. "msg": msg,
  780. })
  781. return
  782. } else {
  783. c.ServeSuccessJSON(map[string]interface{}{
  784. "msg": "校验成功",
  785. })
  786. return
  787. }
  788. }
  789. }
  790. func (c *HisApiController) ReadCard() {
  791. id_card_type, _ := c.GetInt64("id_card_type")
  792. admin_user_id, _ := c.GetInt64("admin_user_id")
  793. certificates, _ := c.GetInt64("certificates")
  794. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  795. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  796. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  797. switch id_card_type {
  798. case 1:
  799. if miConfig.MdtrtareaAdmvs == "421300" {
  800. var res ResultTwo
  801. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  802. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  803. "&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)
  804. resp, requestErr := http.Get(api)
  805. if requestErr != nil {
  806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  807. return
  808. }
  809. body, ioErr := ioutil.ReadAll(resp.Body)
  810. if ioErr != nil {
  811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  813. return
  814. }
  815. var respJSON map[string]interface{}
  816. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  819. return
  820. }
  821. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  822. result, _ := json.Marshal(respJSON)
  823. fmt.Println("log")
  824. fmt.Println(string(result))
  825. if err := json.Unmarshal([]byte(result), &res); err != nil {
  826. utils.ErrorLog("解析失败:%v", err)
  827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  828. return
  829. }
  830. if res.Infcode == 0 {
  831. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  832. if err == gorm.ErrRecordNotFound {
  833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  834. return
  835. } else if err != nil {
  836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  837. return
  838. } else {
  839. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  840. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  841. infoStr := string(Iinfos)
  842. idetinfoStr := string(Idetinfos)
  843. psn := &models.HisPsn{
  844. PsnNo: res.Output.Baseinfo.PsnNo,
  845. Age: res.Output.Baseinfo.Age,
  846. PatientId: patient.ID,
  847. Certno: res.Output.Baseinfo.Certno,
  848. Brdy: res.Output.Baseinfo.Brdy,
  849. Gend: res.Output.Baseinfo.Gend,
  850. Naty: res.Output.Baseinfo.Naty,
  851. PsnCertType: res.Output.Baseinfo.PsnCertType,
  852. PsnName: res.Output.Baseinfo.PsnName,
  853. Idetinfo: idetinfoStr,
  854. Insuinfo: infoStr,
  855. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  856. }
  857. service.CreateHisPsn(psn)
  858. c.ServeSuccessJSON(map[string]interface{}{
  859. "patient": patient,
  860. "number": res.Output.Baseinfo.Certno,
  861. })
  862. }
  863. } else {
  864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  865. return
  866. }
  867. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  868. var api string
  869. if miConfig.MdtrtareaAdmvs == "320921" {
  870. 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 +
  871. "&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
  872. fmt.Println(api)
  873. } else {
  874. 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 +
  875. "&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)
  876. }
  877. resp, requestErr := http.Get(api)
  878. if requestErr != nil {
  879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  880. return
  881. }
  882. body, ioErr := ioutil.ReadAll(resp.Body)
  883. if ioErr != nil {
  884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  886. return
  887. }
  888. var respJSON map[string]interface{}
  889. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  892. return
  893. }
  894. var status string
  895. status = respJSON["data"].(map[string]interface{})["status"].(string)
  896. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  897. //console.log()
  898. fmt.Println("type===")
  899. fmt.Println(card_type)
  900. var token string
  901. var res ResultTwo //1101结果
  902. var res10265 ResultTwo10265 //1101结果
  903. var card_info string //卡信息
  904. var busi_card_info string
  905. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  906. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  907. if status == "0" { //读卡成功
  908. if card_type == "1" {
  909. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  910. result, _ := json.Marshal(respJSON)
  911. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  912. utils.ErrorLog("解析失败:%v", err)
  913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  914. return
  915. }
  916. res.ErrMsg = res10265.ErrMsg
  917. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  918. res.Infcode = infocode
  919. res.Output = res10265.Output
  920. res.InfRefmsgid = res10265.InfRefmsgid
  921. } else {
  922. //var card_info string //卡信息
  923. //var busi_card_info string
  924. token = respJSON["data"].(map[string]interface{})["token"].(string)
  925. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  926. //fmt.Println(card_info)
  927. //fmt.Println(busi_card_info)
  928. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  929. result, _ := json.Marshal(respJSON)
  930. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  931. utils.ErrorLog("解析失败:%v", err)
  932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  933. return
  934. }
  935. res.ErrMsg = res10265.ErrMsg
  936. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  937. res.Infcode = infocode
  938. res.Output = res10265.Output
  939. res.InfRefmsgid = res10265.InfRefmsgid
  940. }
  941. if res.Infcode == 0 {
  942. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  943. if err == gorm.ErrRecordNotFound {
  944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  945. return
  946. } else if err != nil {
  947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  948. return
  949. } else {
  950. if card_type == "1" {
  951. bas := strings.Split(card_info, "|")
  952. basNumber := bas[2]
  953. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  954. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  955. infoStr := string(Iinfos)
  956. idetinfoStr := string(Idetinfos)
  957. psn := &models.HisPsn{
  958. PsnNo: res.Output.Baseinfo.PsnNo,
  959. Age: res.Output.Baseinfo.Age,
  960. PatientId: patient.ID,
  961. Certno: res.Output.Baseinfo.Certno,
  962. Brdy: res.Output.Baseinfo.Brdy,
  963. Gend: res.Output.Baseinfo.Gend,
  964. Naty: res.Output.Baseinfo.Naty,
  965. PsnCertType: res.Output.Baseinfo.PsnCertType,
  966. PsnName: res.Output.Baseinfo.PsnName,
  967. Idetinfo: idetinfoStr,
  968. Insuinfo: infoStr,
  969. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  970. CardInfo: card_info,
  971. VerifyNumber: busi_card_info,
  972. }
  973. service.CreateHisPsn(psn)
  974. c.ServeSuccessJSON(map[string]interface{}{
  975. "patient": patient,
  976. "number": basNumber,
  977. })
  978. } else {
  979. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  980. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  981. infoStr := string(Iinfos)
  982. idetinfoStr := string(Idetinfos)
  983. psn := &models.HisPsn{
  984. PsnNo: res.Output.Baseinfo.PsnNo,
  985. Age: res.Output.Baseinfo.Age,
  986. PatientId: patient.ID,
  987. Certno: res.Output.Baseinfo.Certno,
  988. Brdy: res.Output.Baseinfo.Brdy,
  989. Gend: res.Output.Baseinfo.Gend,
  990. Naty: res.Output.Baseinfo.Naty,
  991. PsnCertType: res.Output.Baseinfo.PsnCertType,
  992. PsnName: res.Output.Baseinfo.PsnName,
  993. Idetinfo: idetinfoStr,
  994. Insuinfo: infoStr,
  995. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  996. CardInfo: card_info,
  997. VerifyNumber: token,
  998. }
  999. service.CreateHisPsn(psn)
  1000. c.ServeSuccessJSON(map[string]interface{}{
  1001. "patient": patient,
  1002. "number": token,
  1003. })
  1004. }
  1005. }
  1006. } else {
  1007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1008. return
  1009. }
  1010. } else { //读卡失败
  1011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1012. return
  1013. }
  1014. } else {
  1015. if initFlag == 0 {
  1016. c.TestGetBasBaseInit()
  1017. }
  1018. basStr := c.GetBasBaseInfo()
  1019. if len(basStr) == 0 {
  1020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1021. return
  1022. }
  1023. fmt.Println(basStr)
  1024. bas := strings.Split(basStr, "|")
  1025. basNumber := bas[1]
  1026. fmt.Println(basNumber)
  1027. card_sn := bas[3]
  1028. fmt.Println(card_sn)
  1029. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1030. var dat map[string]interface{}
  1031. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1032. fmt.Println(dat)
  1033. } else {
  1034. fmt.Println(err)
  1035. }
  1036. userJSONBytes, _ := json.Marshal(dat)
  1037. var res ResultTwo
  1038. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1039. utils.ErrorLog("解析失败:%v", err)
  1040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1041. return
  1042. }
  1043. if res.Infcode == 0 {
  1044. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1045. if err == gorm.ErrRecordNotFound {
  1046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1047. return
  1048. } else if err != nil {
  1049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1050. return
  1051. } else {
  1052. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1053. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1054. infoStr := string(Iinfos)
  1055. idetinfoStr := string(Idetinfos)
  1056. psn := &models.HisPsn{
  1057. PsnNo: res.Output.Baseinfo.PsnNo,
  1058. Age: res.Output.Baseinfo.Age,
  1059. PatientId: patient.ID,
  1060. Certno: res.Output.Baseinfo.Certno,
  1061. Brdy: res.Output.Baseinfo.Brdy,
  1062. Gend: res.Output.Baseinfo.Gend,
  1063. Naty: res.Output.Baseinfo.Naty,
  1064. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1065. PsnName: res.Output.Baseinfo.PsnName,
  1066. Idetinfo: idetinfoStr,
  1067. Insuinfo: infoStr,
  1068. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1069. CardInfo: basStr,
  1070. VerifyNumber: "",
  1071. }
  1072. service.CreateHisPsn(psn)
  1073. c.ServeSuccessJSON(map[string]interface{}{
  1074. "patient": patient,
  1075. "number": basNumber,
  1076. })
  1077. }
  1078. } else {
  1079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1080. return
  1081. }
  1082. break
  1083. }
  1084. case 2:
  1085. SFZStr := c.GetSFZBaseInfo()
  1086. id_card_str := strings.Split(SFZStr, "^")
  1087. id_card_number := id_card_str[0]
  1088. card_sn := ""
  1089. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1090. var dat map[string]interface{}
  1091. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1092. fmt.Println(dat)
  1093. } else {
  1094. fmt.Println(err)
  1095. }
  1096. userJSONBytes, _ := json.Marshal(dat)
  1097. var res ResultTwo
  1098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1099. utils.ErrorLog("解析失败:%v", err)
  1100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1101. return
  1102. }
  1103. if res.Infcode == 0 {
  1104. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1105. if err == gorm.ErrRecordNotFound {
  1106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1107. return
  1108. } else if err != nil {
  1109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1110. return
  1111. } else {
  1112. c.ServeSuccessJSON(map[string]interface{}{
  1113. "patient": patient,
  1114. "number": id_card_number,
  1115. })
  1116. }
  1117. } else {
  1118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1119. return
  1120. }
  1121. break
  1122. case 3:
  1123. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1124. var api string
  1125. if miConfig.MdtrtareaAdmvs == "320921" {
  1126. 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 +
  1127. "&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
  1128. fmt.Println(api)
  1129. } else {
  1130. 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 +
  1131. "&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)
  1132. }
  1133. resp, requestErr := http.Get(api)
  1134. if requestErr != nil {
  1135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1136. return
  1137. }
  1138. body, ioErr := ioutil.ReadAll(resp.Body)
  1139. if ioErr != nil {
  1140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1142. return
  1143. }
  1144. var respJSON map[string]interface{}
  1145. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1148. return
  1149. }
  1150. var status string
  1151. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1152. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1153. var token string
  1154. var res ResultTwo //1101结果
  1155. var res10265 ResultTwo10265 //1101结果
  1156. var card_info string //卡信息
  1157. var busi_card_info string
  1158. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1159. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1160. if status == "0" { //读卡成功
  1161. if card_type == "1" {
  1162. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1163. result, _ := json.Marshal(respJSON)
  1164. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1165. utils.ErrorLog("解析失败:%v", err)
  1166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1167. return
  1168. }
  1169. res.ErrMsg = res10265.ErrMsg
  1170. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1171. res.Infcode = infocode
  1172. res.Output = res10265.Output
  1173. res.InfRefmsgid = res10265.InfRefmsgid
  1174. } else {
  1175. //var card_info string //卡信息
  1176. //var busi_card_info string
  1177. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1178. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1179. //fmt.Println(card_info)
  1180. //fmt.Println(busi_card_info)
  1181. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1182. result, _ := json.Marshal(respJSON)
  1183. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1184. utils.ErrorLog("解析失败:%v", err)
  1185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1186. return
  1187. }
  1188. res.ErrMsg = res10265.ErrMsg
  1189. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1190. res.Infcode = infocode
  1191. res.Output = res10265.Output
  1192. res.InfRefmsgid = res10265.InfRefmsgid
  1193. }
  1194. if res.Infcode == 0 {
  1195. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1196. if err == gorm.ErrRecordNotFound {
  1197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1198. return
  1199. } else if err != nil {
  1200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1201. return
  1202. } else {
  1203. if card_type == "1" {
  1204. bas := strings.Split(card_info, "|")
  1205. basNumber := bas[2]
  1206. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1207. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1208. infoStr := string(Iinfos)
  1209. idetinfoStr := string(Idetinfos)
  1210. psn := &models.HisPsn{
  1211. PsnNo: res.Output.Baseinfo.PsnNo,
  1212. Age: res.Output.Baseinfo.Age,
  1213. PatientId: patient.ID,
  1214. Certno: res.Output.Baseinfo.Certno,
  1215. Brdy: res.Output.Baseinfo.Brdy,
  1216. Gend: res.Output.Baseinfo.Gend,
  1217. Naty: res.Output.Baseinfo.Naty,
  1218. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1219. PsnName: res.Output.Baseinfo.PsnName,
  1220. Idetinfo: idetinfoStr,
  1221. Insuinfo: infoStr,
  1222. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1223. CardInfo: card_info,
  1224. VerifyNumber: busi_card_info,
  1225. }
  1226. service.CreateHisPsn(psn)
  1227. c.ServeSuccessJSON(map[string]interface{}{
  1228. "patient": patient,
  1229. "number": basNumber,
  1230. })
  1231. } else {
  1232. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1233. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1234. infoStr := string(Iinfos)
  1235. idetinfoStr := string(Idetinfos)
  1236. psn := &models.HisPsn{
  1237. PsnNo: res.Output.Baseinfo.PsnNo,
  1238. Age: res.Output.Baseinfo.Age,
  1239. PatientId: patient.ID,
  1240. Certno: res.Output.Baseinfo.Certno,
  1241. Brdy: res.Output.Baseinfo.Brdy,
  1242. Gend: res.Output.Baseinfo.Gend,
  1243. Naty: res.Output.Baseinfo.Naty,
  1244. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1245. PsnName: res.Output.Baseinfo.PsnName,
  1246. Idetinfo: idetinfoStr,
  1247. Insuinfo: infoStr,
  1248. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1249. CardInfo: card_info,
  1250. VerifyNumber: token,
  1251. }
  1252. service.CreateHisPsn(psn)
  1253. c.ServeSuccessJSON(map[string]interface{}{
  1254. "patient": patient,
  1255. "number": token,
  1256. })
  1257. }
  1258. }
  1259. } else {
  1260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1261. return
  1262. }
  1263. } else { //读卡失败
  1264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1265. return
  1266. }
  1267. }
  1268. break
  1269. case 4:
  1270. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1271. var api string
  1272. if miConfig.MdtrtareaAdmvs == "320921" {
  1273. 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 +
  1274. "&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
  1275. fmt.Println(api)
  1276. } else {
  1277. 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 +
  1278. "&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)
  1279. }
  1280. resp, requestErr := http.Get(api)
  1281. if requestErr != nil {
  1282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1283. return
  1284. }
  1285. body, ioErr := ioutil.ReadAll(resp.Body)
  1286. if ioErr != nil {
  1287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1289. return
  1290. }
  1291. var respJSON map[string]interface{}
  1292. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1295. return
  1296. }
  1297. var status string
  1298. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1299. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1300. var token string
  1301. var res ResultTwo //1101结果
  1302. var res10265 ResultTwo10265 //1101结果
  1303. if status == "0" { //读卡成功
  1304. var card_info string //卡信息
  1305. var busi_card_info string
  1306. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1307. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1308. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1309. fmt.Println(card_info)
  1310. fmt.Println(busi_card_info)
  1311. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1312. result, _ := json.Marshal(respJSON)
  1313. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1314. utils.ErrorLog("解析失败:%v", err)
  1315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1316. return
  1317. }
  1318. res.ErrMsg = res10265.ErrMsg
  1319. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1320. res.Infcode = infocode
  1321. res.Output = res10265.Output
  1322. res.InfRefmsgid = res10265.InfRefmsgid
  1323. if res.Infcode == 0 {
  1324. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1325. if err == gorm.ErrRecordNotFound {
  1326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1327. return
  1328. } else if err != nil {
  1329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1330. return
  1331. } else {
  1332. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1333. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1334. infoStr := string(Iinfos)
  1335. idetinfoStr := string(Idetinfos)
  1336. psn := &models.HisPsn{
  1337. PsnNo: res.Output.Baseinfo.PsnNo,
  1338. Age: res.Output.Baseinfo.Age,
  1339. PatientId: patient.ID,
  1340. Certno: res.Output.Baseinfo.Certno,
  1341. Brdy: res.Output.Baseinfo.Brdy,
  1342. Gend: res.Output.Baseinfo.Gend,
  1343. Naty: res.Output.Baseinfo.Naty,
  1344. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1345. PsnName: res.Output.Baseinfo.PsnName,
  1346. Idetinfo: idetinfoStr,
  1347. Insuinfo: infoStr,
  1348. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1349. CardInfo: card_info,
  1350. VerifyNumber: token,
  1351. }
  1352. service.CreateHisPsn(psn)
  1353. c.ServeSuccessJSON(map[string]interface{}{
  1354. "patient": patient,
  1355. "number": token,
  1356. })
  1357. }
  1358. } else {
  1359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1360. return
  1361. }
  1362. } else { //读卡失败
  1363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1364. return
  1365. }
  1366. }
  1367. break
  1368. }
  1369. }
  1370. var initFlag int64 = 0
  1371. func (c *HisApiController) TestGetBasBaseInit() {
  1372. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1373. Iinit := DllDef.MustFindProc("Init")
  1374. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1375. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1376. if ret != 0 {
  1377. fmt.Println("SSCard的报错原因:", err)
  1378. fmt.Println("SSCard的运算结果为:", ret)
  1379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1380. return
  1381. }
  1382. result := int(ret)
  1383. fmt.Println("SSCard的运算结果为1:", result)
  1384. initFlag = 1
  1385. return
  1386. }
  1387. func (c *HisApiController) GetSFZBaseInfo() string {
  1388. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1389. readCard := DllDef.MustFindProc("ReadSFZ")
  1390. if readCard == nil {
  1391. fmt.Println("readcard is nil")
  1392. readCard = DllDef.MustFindProc("ReadSFZ")
  1393. }
  1394. str := make([]byte, 256)
  1395. str1 := make([]byte, 256)
  1396. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1397. fmt.Println(r)
  1398. return string(str)
  1399. }
  1400. func (c *HisApiController) GetBasBaseInfo() string {
  1401. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1402. readCard := DllDef.MustFindProc("ReadCardBas")
  1403. if readCard == nil {
  1404. fmt.Println("readcard is nil")
  1405. readCard = DllDef.MustFindProc("ReadCardBas")
  1406. }
  1407. str := make([]byte, 1024)
  1408. str1 := make([]byte, 1024)
  1409. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1410. fmt.Println(string(str1))
  1411. fmt.Println(string(str))
  1412. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1413. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1414. if ret2 != 0 {
  1415. return ""
  1416. }
  1417. return string(str)
  1418. }
  1419. type CustomFundPay struct {
  1420. FundPayType string `json:"fund_pay_type"`
  1421. FundPayamt float64 `json:"fund_payamt"`
  1422. }
  1423. func (c *HisApiController) GetSettleList() {
  1424. order_id, _ := c.GetInt64("order_id")
  1425. admin_user_id, _ := c.GetInt64("admin_user_id")
  1426. order, _ := service.GetHisOrderByIDTwo(order_id)
  1427. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1428. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1429. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1430. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1431. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1432. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1433. if order.ID == 0 {
  1434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1435. return
  1436. }
  1437. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1438. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1439. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1440. fmt.Println(count)
  1441. var zero string
  1442. number := count + 1
  1443. if number >= 1000 {
  1444. zero = "0000" + strconv.FormatInt(number, 10)
  1445. } else if number >= 10000 {
  1446. zero = "000" + strconv.FormatInt(number, 10)
  1447. } else if number >= 100000 {
  1448. zero = "00" + strconv.FormatInt(number, 10)
  1449. } else if number >= 1000000 {
  1450. zero = "0" + strconv.FormatInt(number, 10)
  1451. } else {
  1452. zero = strconv.FormatInt(number, 10)
  1453. }
  1454. fmt.Println(zero)
  1455. struct4101 := service.Struct4101{
  1456. PsnNo: order.PsnNo,
  1457. MdtrtId: order.MdtrtId,
  1458. SetlId: order.SetlId,
  1459. PsnName: order.PsnName,
  1460. Gend: order.Gend,
  1461. Brdy: his.Brdy,
  1462. Age: his.Age,
  1463. Naty: order.Naty,
  1464. PatnCertType: "01",
  1465. Certno: order.Certno,
  1466. Prfs: "90",
  1467. ConerName: roles[0].UserName,
  1468. PatnRlts: "99",
  1469. ConerAddr: miConfig.OrgName,
  1470. ConerTel: admin.Mobile,
  1471. HiType: order.Insutype,
  1472. Insuplc: miConfig.InsuplcAdmdvs,
  1473. MaindiagFlag: "1",
  1474. BillCode: last_order.FaPiaoCode,
  1475. BillNo: zero,
  1476. BizSn: order.Number,
  1477. PsnSelfPay: order.PsnPartAmt,
  1478. PsnOwnPay: order.PsnPartAmt,
  1479. AcctPay: order.AcctPay,
  1480. PsnCashpay: order.PsnCashPay,
  1481. HiPaymtd: "1",
  1482. Hsorg: miConfig.InsuplcAdmdvs,
  1483. HsorgOpter: miConfig.InsuplcAdmdvs,
  1484. MedinsFillPsn: curRoles.UserName,
  1485. MedinsFillDept: depart.Name,
  1486. IptMedType: "2",
  1487. }
  1488. struct4101.SetlBegnDate = order.SetlTime
  1489. struct4101.SetlEndDate = order.SetlTime
  1490. time_arr := strings.Split(order.SetlTime, " ")
  1491. struct4101.AdmTime = time_arr[0]
  1492. struct4101.AdmEndTime = time_arr[0]
  1493. var rf []CustomFundPay
  1494. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1495. var tempFunPays []service.CustomStruct
  1496. for _, item := range rf {
  1497. var tempFunPay service.CustomStruct
  1498. tempFunPay.FundPayamt = item.FundPayamt
  1499. tempFunPay.FundPayType = item.FundPayType
  1500. tempFunPays = append(tempFunPays, tempFunPay)
  1501. }
  1502. struct4101.CustomStruct = tempFunPays
  1503. var tempDiaginfos []service.DiaginfoStructTwo
  1504. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1505. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1506. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1507. var config []*models.HisXtDiagnoseConfig
  1508. for _, item := range diagnosis_ids {
  1509. id, _ := strconv.ParseInt(item, 10, 64)
  1510. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1511. config = append(config, &diagnosisConfig)
  1512. }
  1513. for index, item := range config {
  1514. if index == 0 {
  1515. var tempDiaginfo service.DiaginfoStructTwo
  1516. tempDiaginfo.DiagCode = item.CountryCode
  1517. tempDiaginfo.DiagName = item.CountryContentName
  1518. tempDiaginfo.DiagType = "1"
  1519. tempDiaginfo.MaindiagFlag = "1"
  1520. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1521. } else {
  1522. var tempDiaginfo service.DiaginfoStructTwo
  1523. tempDiaginfo.DiagCode = item.CountryCode
  1524. tempDiaginfo.DiagName = item.CountryContentName
  1525. tempDiaginfo.DiagType = "2"
  1526. tempDiaginfo.MaindiagFlag = "0"
  1527. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1528. }
  1529. }
  1530. struct4101.Diseinfo = tempDiaginfos
  1531. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1532. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1533. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1534. tempOpspdiseinfo2.OprnOprtCode = ""
  1535. tempOpspdiseinfo2.OprnOprtName = ""
  1536. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1537. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1538. var iteminfo service.IteminfoStruct
  1539. var bedCostTotal float64 = 0 //床位总费
  1540. var bedCostSelfTotal float64 = 0 //床位自费
  1541. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1542. var operationCostTotal float64 = 0 //手术费
  1543. var operationCostSelfTotal float64 = 0 //手术费
  1544. var operationCostPartSelfTotal float64 = 0 //手术费
  1545. var otherCostTotal float64 = 0 //其他费用
  1546. var otherCostSelfTotal float64 = 0 //其他费用
  1547. var otherCostPartSelfTotal float64 = 0 //其他费用
  1548. var materialCostTotal float64 = 0 //材料费
  1549. var materialCostSelfTotal float64 = 0 //材料费
  1550. var materialCostPartSelfTotal float64 = 0 //材料费
  1551. var westernMedicineCostTotal float64 = 0 //西药费
  1552. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1553. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1554. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1555. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1556. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1557. var checkCostTotal float64 = 0 //检查费
  1558. var checkCostSelfTotal float64 = 0 //检查费
  1559. var checkCostPartSelfTotal float64 = 0 //检查费
  1560. var laboratoryCostTotal float64 = 0 //化验费
  1561. var laboratoryCostSelfTotal float64 = 0 //化验费
  1562. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1563. var treatCostTotal float64 = 0 //治疗费用
  1564. var treatCostSelfTotal float64 = 0 //治疗费用
  1565. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1566. decimal.DivisionPrecision = 2
  1567. var bed_fulamt_ownpay_amt float64 = 0
  1568. var operation_fulamt_ownpay_amt float64 = 0
  1569. var other_fulamt_ownpay_amt float64 = 0
  1570. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1571. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1572. var check_fulamt_ownpay_amt float64 = 0
  1573. var material_fulamt_ownpay_amt float64 = 0
  1574. var laboratory_fulamt_ownpay_amt float64 = 0
  1575. var treat_fulamt_ownpay_amt float64 = 0
  1576. var bed_claa_sunmfee float64 = 0
  1577. var bed_clab_amt float64 = 0
  1578. var bed_other_amt float64 = 0
  1579. var operation_claa_sunmfee float64 = 0
  1580. var operation_clab_amt float64 = 0
  1581. var operation_other_amt float64 = 0
  1582. var other_claa_sunmfee float64 = 0
  1583. var other_clab_amt float64 = 0
  1584. var other_other_amt float64 = 0
  1585. var westernMedicine_claa_sunmfee float64 = 0
  1586. var westernMedicine_clab_amt float64 = 0
  1587. var westernMedicine_other_amt float64 = 0
  1588. var chineseTraditional_claa_sunmfee float64 = 0
  1589. var chineseTraditional_clab_amt float64 = 0
  1590. var chineseTraditional_other_amt float64 = 0
  1591. var check_claa_sunmfee float64 = 0
  1592. var check_clab_amt float64 = 0
  1593. var check_other_amt float64 = 0
  1594. var material_claa_sunmfee float64 = 0
  1595. var material_clab_amt float64 = 0
  1596. var material_other_amt float64 = 0
  1597. var laboratory_claa_sunmfee float64 = 0
  1598. var laboratory_clab_amt float64 = 0
  1599. var laboratory_other_amt float64 = 0
  1600. var treat_claa_sunmfee float64 = 0
  1601. var treat_clab_amt float64 = 0
  1602. var treat_other_amt float64 = 0
  1603. for _, item := range order.HisOrderInfo {
  1604. if item.MedChrgitmType == "01" { //床位费
  1605. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1606. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1607. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1608. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1609. if item.ChrgitmLv == "1" {
  1610. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1611. }
  1612. if item.ChrgitmLv == "2" {
  1613. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1614. }
  1615. if item.ChrgitmLv == "3" {
  1616. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1617. }
  1618. }
  1619. if item.MedChrgitmType == "03" { //检查费
  1620. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1621. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1622. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1623. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1624. if item.ChrgitmLv == "1" {
  1625. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1626. }
  1627. if item.ChrgitmLv == "2" {
  1628. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1629. }
  1630. if item.ChrgitmLv == "3" {
  1631. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1632. }
  1633. }
  1634. if item.MedChrgitmType == "04" { //化验费
  1635. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1636. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1637. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1638. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1639. if item.ChrgitmLv == "1" {
  1640. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1641. }
  1642. if item.ChrgitmLv == "2" {
  1643. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1644. }
  1645. if item.ChrgitmLv == "3" {
  1646. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1647. }
  1648. }
  1649. if item.MedChrgitmType == "05" { //治疗费
  1650. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1651. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1652. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1653. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1654. if item.ChrgitmLv == "1" {
  1655. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1656. }
  1657. if item.ChrgitmLv == "2" {
  1658. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1659. }
  1660. if item.ChrgitmLv == "3" {
  1661. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1662. }
  1663. }
  1664. if item.MedChrgitmType == "06" { //手术费
  1665. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1666. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1667. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1668. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1669. if item.ChrgitmLv == "1" {
  1670. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1671. }
  1672. if item.ChrgitmLv == "2" {
  1673. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1674. }
  1675. if item.ChrgitmLv == "3" {
  1676. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1677. }
  1678. }
  1679. if item.MedChrgitmType == "08" { //材料费
  1680. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1681. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1682. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1683. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1684. if item.ChrgitmLv == "1" {
  1685. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1686. }
  1687. if item.ChrgitmLv == "2" {
  1688. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1689. }
  1690. if item.ChrgitmLv == "3" {
  1691. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1692. }
  1693. }
  1694. if item.MedChrgitmType == "09" { //西药费
  1695. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1696. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1697. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1698. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1699. if item.ChrgitmLv == "1" {
  1700. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1701. }
  1702. if item.ChrgitmLv == "2" {
  1703. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1704. }
  1705. if item.ChrgitmLv == "3" {
  1706. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1707. }
  1708. }
  1709. if item.MedChrgitmType == "11" { //中成费
  1710. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1711. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1712. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1713. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1714. if item.ChrgitmLv == "1" {
  1715. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1716. }
  1717. if item.ChrgitmLv == "2" {
  1718. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1719. }
  1720. if item.ChrgitmLv == "3" {
  1721. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1722. }
  1723. }
  1724. if item.MedChrgitmType == "14" { //其他费
  1725. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1726. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1727. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1728. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1729. if item.ChrgitmLv == "1" {
  1730. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1731. }
  1732. if item.ChrgitmLv == "2" {
  1733. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1734. }
  1735. if item.ChrgitmLv == "3" {
  1736. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1737. }
  1738. }
  1739. }
  1740. var iteminfoStructs []service.IteminfoStruct
  1741. if bedCostTotal != 0 {
  1742. iteminfo.MedChrgitm = "01"
  1743. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1744. iteminfo.Amt = bedCostTotal
  1745. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1746. iteminfo.ClabAmt = bed_clab_amt
  1747. iteminfo.OthAmt = bed_other_amt
  1748. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1749. }
  1750. if checkCostTotal != 0 {
  1751. iteminfo.MedChrgitm = "03"
  1752. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1753. iteminfo.Amt = checkCostTotal
  1754. iteminfo.ClaaSumfee = check_claa_sunmfee
  1755. iteminfo.ClabAmt = check_clab_amt
  1756. iteminfo.OthAmt = check_other_amt
  1757. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1758. }
  1759. if laboratoryCostTotal != 0 {
  1760. iteminfo.MedChrgitm = "04"
  1761. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1762. iteminfo.Amt = laboratoryCostTotal
  1763. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1764. iteminfo.ClabAmt = laboratory_clab_amt
  1765. iteminfo.OthAmt = laboratory_other_amt
  1766. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1767. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1768. }
  1769. if treatCostTotal != 0 {
  1770. iteminfo.MedChrgitm = "05"
  1771. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1772. iteminfo.Amt = treatCostTotal
  1773. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1774. iteminfo.ClabAmt = treat_clab_amt
  1775. iteminfo.OthAmt = treat_other_amt
  1776. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1777. //(struct4101.IteminfoStruct, iteminfo)
  1778. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1779. }
  1780. if operationCostTotal != 0 {
  1781. iteminfo.MedChrgitm = "06"
  1782. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1783. iteminfo.Amt = operationCostTotal
  1784. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1785. iteminfo.ClabAmt = operation_clab_amt
  1786. iteminfo.OthAmt = operation_other_amt
  1787. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1788. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1789. }
  1790. if materialCostTotal != 0 {
  1791. iteminfo.MedChrgitm = "08"
  1792. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1793. iteminfo.Amt = materialCostTotal
  1794. iteminfo.ClaaSumfee = material_claa_sunmfee
  1795. iteminfo.ClabAmt = material_clab_amt
  1796. iteminfo.OthAmt = material_other_amt
  1797. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1798. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1799. }
  1800. if westernMedicineCostTotal != 0 {
  1801. iteminfo.MedChrgitm = "09"
  1802. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1803. iteminfo.Amt = westernMedicineCostTotal
  1804. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1805. iteminfo.ClabAmt = westernMedicine_clab_amt
  1806. iteminfo.OthAmt = westernMedicine_other_amt
  1807. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1808. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1809. }
  1810. if chineseTraditionalMedicineCostTotal != 0 {
  1811. iteminfo.MedChrgitm = "11"
  1812. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1813. iteminfo.Amt = westernMedicineCostTotal
  1814. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1815. iteminfo.ClabAmt = westernMedicine_clab_amt
  1816. iteminfo.OthAmt = westernMedicine_other_amt
  1817. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1818. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1819. }
  1820. if otherCostTotal != 0 {
  1821. iteminfo.MedChrgitm = "14"
  1822. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1823. iteminfo.Amt = otherCostTotal
  1824. iteminfo.ClaaSumfee = other_claa_sunmfee
  1825. iteminfo.ClabAmt = other_clab_amt
  1826. iteminfo.OthAmt = other_other_amt
  1827. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1828. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1829. }
  1830. struct4101.IteminfoStruct = iteminfoStructs
  1831. struct4101.Ntly = "中国"
  1832. struct4101.AdmCaty = "A03.06"
  1833. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1834. fmt.Println(result)
  1835. var dat map[string]interface{}
  1836. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1837. fmt.Println(dat)
  1838. } else {
  1839. fmt.Println(err)
  1840. }
  1841. userJSONBytes, _ := json.Marshal(dat)
  1842. var res ResultSeventeen
  1843. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1844. utils.ErrorLog("解析失败:%v", err)
  1845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1846. return
  1847. }
  1848. if res.Infcode != 0 {
  1849. c.ServeSuccessJSON(map[string]interface{}{
  1850. "failed_code": -10,
  1851. "msg": res.ErrMsg,
  1852. })
  1853. return
  1854. } else {
  1855. order.FaPiaoNumber = zero
  1856. order.FaPiaoCode = last_order.FaPiaoCode
  1857. service.UpdateOrder(order)
  1858. hisFundSettleListResult := &models.HisFundSettleListResult{
  1859. Number: res.Output.SetlListId,
  1860. Status: 1,
  1861. Ctime: time.Now().Unix(),
  1862. Mtime: time.Now().Unix(),
  1863. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1864. IsUpload: 1,
  1865. OrderId: order_id,
  1866. }
  1867. service.CreateUploadRecord(hisFundSettleListResult)
  1868. c.ServeSuccessJSON(map[string]interface{}{
  1869. "msg": "上传成功",
  1870. "result": hisFundSettleListResult,
  1871. })
  1872. return
  1873. }
  1874. }
  1875. func (c *HisApiController) GetSettleListHospital() {
  1876. order_id, _ := c.GetInt64("order_id")
  1877. admin_user_id, _ := c.GetInt64("admin_user_id")
  1878. order, _ := service.GetHisOrderByIDTwo(order_id)
  1879. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1880. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1881. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1882. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1883. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1884. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1885. if order.ID == 0 {
  1886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1887. return
  1888. }
  1889. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1890. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1891. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1892. fmt.Println(count)
  1893. var zero string
  1894. number := count + 1
  1895. if number >= 1000 {
  1896. zero = "0000" + strconv.FormatInt(number, 10)
  1897. } else if number >= 10000 {
  1898. zero = "000" + strconv.FormatInt(number, 10)
  1899. } else if number >= 100000 {
  1900. zero = "00" + strconv.FormatInt(number, 10)
  1901. } else if number >= 1000000 {
  1902. zero = "0" + strconv.FormatInt(number, 10)
  1903. } else {
  1904. zero = strconv.FormatInt(number, 10)
  1905. }
  1906. fmt.Println(zero)
  1907. struct4101 := service.Struct4101{
  1908. PsnNo: order.PsnNo,
  1909. MdtrtId: order.MdtrtId,
  1910. SetlId: order.SetlId,
  1911. PsnName: order.PsnName,
  1912. Gend: order.Gend,
  1913. Brdy: his.Brdy,
  1914. Age: int64(order.Age),
  1915. Naty: order.Naty,
  1916. PatnCertType: "01",
  1917. Certno: order.Certno,
  1918. Prfs: "90",
  1919. ConerName: roles[0].UserName,
  1920. PatnRlts: "99",
  1921. ConerAddr: miConfig.OrgName,
  1922. ConerTel: admin.Mobile,
  1923. HiType: order.Insutype,
  1924. Insuplc: miConfig.InsuplcAdmdvs,
  1925. MaindiagFlag: "1",
  1926. BillCode: last_order.FaPiaoCode,
  1927. BillNo: zero,
  1928. BizSn: order.Number,
  1929. PsnSelfPay: order.PsnPartAmt,
  1930. PsnOwnPay: order.PsnPartAmt,
  1931. AcctPay: order.AcctPay,
  1932. PsnCashpay: order.PsnCashPay,
  1933. HiPaymtd: "1",
  1934. Hsorg: miConfig.InsuplcAdmdvs,
  1935. HsorgOpter: miConfig.InsuplcAdmdvs,
  1936. MedinsFillPsn: curRoles.UserName,
  1937. MedinsFillDept: depart.Name,
  1938. IptMedType: "2",
  1939. AdmTime: his.InHosptialTime,
  1940. AdmEndTime: his.OutHosptialTime,
  1941. }
  1942. struct4101.SetlBegnDate = order.SetlTime
  1943. struct4101.SetlEndDate = order.SetlTime
  1944. var rf []CustomFundPay
  1945. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1946. var tempFunPays []service.CustomStruct
  1947. for _, item := range rf {
  1948. var tempFunPay service.CustomStruct
  1949. tempFunPay.FundPayamt = item.FundPayamt
  1950. tempFunPay.FundPayType = item.FundPayType
  1951. tempFunPays = append(tempFunPays, tempFunPay)
  1952. }
  1953. struct4101.CustomStruct = tempFunPays
  1954. var tempDiaginfos []service.DiaginfoStructTwo
  1955. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1956. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1957. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1958. var config []*models.HisXtDiagnoseConfig
  1959. for _, item := range diagnosis_ids {
  1960. id, _ := strconv.ParseInt(item, 10, 64)
  1961. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1962. config = append(config, &diagnosisConfig)
  1963. }
  1964. for index, item := range config {
  1965. if index == 0 {
  1966. var tempDiaginfo service.DiaginfoStructTwo
  1967. tempDiaginfo.DiagCode = item.CountryCode
  1968. tempDiaginfo.DiagName = item.CountryContentName
  1969. tempDiaginfo.DiagType = "1"
  1970. tempDiaginfo.MaindiagFlag = "1"
  1971. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1972. } else {
  1973. var tempDiaginfo service.DiaginfoStructTwo
  1974. tempDiaginfo.DiagCode = item.CountryCode
  1975. tempDiaginfo.DiagName = item.CountryContentName
  1976. tempDiaginfo.DiagType = "2"
  1977. tempDiaginfo.MaindiagFlag = "0"
  1978. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1979. }
  1980. }
  1981. struct4101.Diseinfo = tempDiaginfos
  1982. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1983. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1984. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1985. tempOpspdiseinfo2.OprnOprtCode = ""
  1986. tempOpspdiseinfo2.OprnOprtName = ""
  1987. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1988. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1989. var iteminfo service.IteminfoStruct
  1990. var bedCostTotal float64 = 0 //床位总费
  1991. var bedCostSelfTotal float64 = 0 //床位自费
  1992. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1993. var operationCostTotal float64 = 0 //手术费
  1994. var operationCostSelfTotal float64 = 0 //手术费
  1995. var operationCostPartSelfTotal float64 = 0 //手术费
  1996. var otherCostTotal float64 = 0 //其他费用
  1997. var otherCostSelfTotal float64 = 0 //其他费用
  1998. var otherCostPartSelfTotal float64 = 0 //其他费用
  1999. var materialCostTotal float64 = 0 //材料费
  2000. var materialCostSelfTotal float64 = 0 //材料费
  2001. var materialCostPartSelfTotal float64 = 0 //材料费
  2002. var westernMedicineCostTotal float64 = 0 //西药费
  2003. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2004. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2005. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2006. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2007. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2008. var checkCostTotal float64 = 0 //检查费
  2009. var checkCostSelfTotal float64 = 0 //检查费
  2010. var checkCostPartSelfTotal float64 = 0 //检查费
  2011. var laboratoryCostTotal float64 = 0 //化验费
  2012. var laboratoryCostSelfTotal float64 = 0 //化验费
  2013. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2014. var treatCostTotal float64 = 0 //治疗费用
  2015. var treatCostSelfTotal float64 = 0 //治疗费用
  2016. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2017. decimal.DivisionPrecision = 2
  2018. var bed_fulamt_ownpay_amt float64 = 0
  2019. var operation_fulamt_ownpay_amt float64 = 0
  2020. var other_fulamt_ownpay_amt float64 = 0
  2021. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2022. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2023. var check_fulamt_ownpay_amt float64 = 0
  2024. var material_fulamt_ownpay_amt float64 = 0
  2025. var laboratory_fulamt_ownpay_amt float64 = 0
  2026. var treat_fulamt_ownpay_amt float64 = 0
  2027. var bed_claa_sunmfee float64 = 0
  2028. var bed_clab_amt float64 = 0
  2029. var bed_other_amt float64 = 0
  2030. var operation_claa_sunmfee float64 = 0
  2031. var operation_clab_amt float64 = 0
  2032. var operation_other_amt float64 = 0
  2033. var other_claa_sunmfee float64 = 0
  2034. var other_clab_amt float64 = 0
  2035. var other_other_amt float64 = 0
  2036. var westernMedicine_claa_sunmfee float64 = 0
  2037. var westernMedicine_clab_amt float64 = 0
  2038. var westernMedicine_other_amt float64 = 0
  2039. var chineseTraditional_claa_sunmfee float64 = 0
  2040. var chineseTraditional_clab_amt float64 = 0
  2041. var chineseTraditional_other_amt float64 = 0
  2042. var check_claa_sunmfee float64 = 0
  2043. var check_clab_amt float64 = 0
  2044. var check_other_amt float64 = 0
  2045. var material_claa_sunmfee float64 = 0
  2046. var material_clab_amt float64 = 0
  2047. var material_other_amt float64 = 0
  2048. var laboratory_claa_sunmfee float64 = 0
  2049. var laboratory_clab_amt float64 = 0
  2050. var laboratory_other_amt float64 = 0
  2051. var treat_claa_sunmfee float64 = 0
  2052. var treat_clab_amt float64 = 0
  2053. var treat_other_amt float64 = 0
  2054. for _, item := range order.HisOrderInfo {
  2055. if item.MedChrgitmType == "01" { //床位费
  2056. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2057. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2058. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2059. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2060. if item.ChrgitmLv == "1" {
  2061. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2062. }
  2063. if item.ChrgitmLv == "2" {
  2064. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2065. }
  2066. if item.ChrgitmLv == "3" {
  2067. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2068. }
  2069. }
  2070. if item.MedChrgitmType == "03" { //检查费
  2071. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2072. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2073. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2074. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2075. if item.ChrgitmLv == "1" {
  2076. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2077. }
  2078. if item.ChrgitmLv == "2" {
  2079. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2080. }
  2081. if item.ChrgitmLv == "3" {
  2082. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2083. }
  2084. }
  2085. if item.MedChrgitmType == "04" { //化验费
  2086. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2087. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2088. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2089. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2090. if item.ChrgitmLv == "1" {
  2091. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2092. }
  2093. if item.ChrgitmLv == "2" {
  2094. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2095. }
  2096. if item.ChrgitmLv == "3" {
  2097. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2098. }
  2099. }
  2100. if item.MedChrgitmType == "05" { //治疗费
  2101. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2102. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2103. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2104. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2105. if item.ChrgitmLv == "1" {
  2106. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2107. }
  2108. if item.ChrgitmLv == "2" {
  2109. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2110. }
  2111. if item.ChrgitmLv == "3" {
  2112. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2113. }
  2114. }
  2115. if item.MedChrgitmType == "06" { //手术费
  2116. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2117. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2118. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2119. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2120. if item.ChrgitmLv == "1" {
  2121. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2122. }
  2123. if item.ChrgitmLv == "2" {
  2124. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2125. }
  2126. if item.ChrgitmLv == "3" {
  2127. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2128. }
  2129. }
  2130. if item.MedChrgitmType == "08" { //材料费
  2131. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2132. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2133. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2134. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2135. if item.ChrgitmLv == "1" {
  2136. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2137. }
  2138. if item.ChrgitmLv == "2" {
  2139. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2140. }
  2141. if item.ChrgitmLv == "3" {
  2142. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2143. }
  2144. }
  2145. if item.MedChrgitmType == "09" { //西药费
  2146. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2147. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2148. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2149. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2150. if item.ChrgitmLv == "1" {
  2151. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2152. }
  2153. if item.ChrgitmLv == "2" {
  2154. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2155. }
  2156. if item.ChrgitmLv == "3" {
  2157. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2158. }
  2159. }
  2160. if item.MedChrgitmType == "11" { //中成费
  2161. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2162. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2163. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2164. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2165. if item.ChrgitmLv == "1" {
  2166. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2167. }
  2168. if item.ChrgitmLv == "2" {
  2169. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2170. }
  2171. if item.ChrgitmLv == "3" {
  2172. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2173. }
  2174. }
  2175. if item.MedChrgitmType == "14" { //其他费
  2176. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2177. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2178. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2179. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2180. if item.ChrgitmLv == "1" {
  2181. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2182. }
  2183. if item.ChrgitmLv == "2" {
  2184. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2185. }
  2186. if item.ChrgitmLv == "3" {
  2187. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2188. }
  2189. }
  2190. }
  2191. var iteminfoStructs []service.IteminfoStruct
  2192. if bedCostTotal != 0 {
  2193. iteminfo.MedChrgitm = "01"
  2194. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2195. iteminfo.Amt = bedCostTotal
  2196. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2197. iteminfo.ClabAmt = bed_clab_amt
  2198. iteminfo.OthAmt = bed_other_amt
  2199. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2200. }
  2201. if checkCostTotal != 0 {
  2202. iteminfo.MedChrgitm = "03"
  2203. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2204. iteminfo.Amt = checkCostTotal
  2205. iteminfo.ClaaSumfee = check_claa_sunmfee
  2206. iteminfo.ClabAmt = check_clab_amt
  2207. iteminfo.OthAmt = check_other_amt
  2208. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2209. }
  2210. if laboratoryCostTotal != 0 {
  2211. iteminfo.MedChrgitm = "04"
  2212. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2213. iteminfo.Amt = laboratoryCostTotal
  2214. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2215. iteminfo.ClabAmt = laboratory_clab_amt
  2216. iteminfo.OthAmt = laboratory_other_amt
  2217. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2218. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2219. }
  2220. if treatCostTotal != 0 {
  2221. iteminfo.MedChrgitm = "05"
  2222. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2223. iteminfo.Amt = treatCostTotal
  2224. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2225. iteminfo.ClabAmt = treat_clab_amt
  2226. iteminfo.OthAmt = treat_other_amt
  2227. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2228. //(struct4101.IteminfoStruct, iteminfo)
  2229. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2230. }
  2231. if operationCostTotal != 0 {
  2232. iteminfo.MedChrgitm = "06"
  2233. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2234. iteminfo.Amt = operationCostTotal
  2235. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2236. iteminfo.ClabAmt = operation_clab_amt
  2237. iteminfo.OthAmt = operation_other_amt
  2238. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2239. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2240. }
  2241. if materialCostTotal != 0 {
  2242. iteminfo.MedChrgitm = "08"
  2243. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2244. iteminfo.Amt = materialCostTotal
  2245. iteminfo.ClaaSumfee = material_claa_sunmfee
  2246. iteminfo.ClabAmt = material_clab_amt
  2247. iteminfo.OthAmt = material_other_amt
  2248. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2249. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2250. }
  2251. if westernMedicineCostTotal != 0 {
  2252. iteminfo.MedChrgitm = "09"
  2253. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2254. iteminfo.Amt = westernMedicineCostTotal
  2255. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2256. iteminfo.ClabAmt = westernMedicine_clab_amt
  2257. iteminfo.OthAmt = westernMedicine_other_amt
  2258. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2259. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2260. }
  2261. if chineseTraditionalMedicineCostTotal != 0 {
  2262. iteminfo.MedChrgitm = "11"
  2263. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2264. iteminfo.Amt = westernMedicineCostTotal
  2265. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2266. iteminfo.ClabAmt = westernMedicine_clab_amt
  2267. iteminfo.OthAmt = westernMedicine_other_amt
  2268. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2269. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2270. }
  2271. if otherCostTotal != 0 {
  2272. iteminfo.MedChrgitm = "14"
  2273. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2274. iteminfo.Amt = otherCostTotal
  2275. iteminfo.ClaaSumfee = other_claa_sunmfee
  2276. iteminfo.ClabAmt = other_clab_amt
  2277. iteminfo.OthAmt = other_other_amt
  2278. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2279. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2280. }
  2281. struct4101.IteminfoStruct = iteminfoStructs
  2282. struct4101.Ntly = "中国"
  2283. struct4101.AdmCaty = "A03.06"
  2284. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2285. fmt.Println(result)
  2286. var dat map[string]interface{}
  2287. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2288. fmt.Println(dat)
  2289. } else {
  2290. fmt.Println(err)
  2291. }
  2292. userJSONBytes, _ := json.Marshal(dat)
  2293. var res ResultSeventeen
  2294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2295. utils.ErrorLog("解析失败:%v", err)
  2296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2297. return
  2298. }
  2299. if res.Infcode != 0 {
  2300. c.ServeSuccessJSON(map[string]interface{}{
  2301. "failed_code": -10,
  2302. "msg": res.ErrMsg,
  2303. })
  2304. return
  2305. } else {
  2306. order.FaPiaoNumber = zero
  2307. order.FaPiaoCode = last_order.FaPiaoCode
  2308. service.UpdateOrder(order)
  2309. hisFundSettleListResult := &models.HisFundSettleListResult{
  2310. Number: res.Output.SetlListId,
  2311. Status: 1,
  2312. Ctime: time.Now().Unix(),
  2313. Mtime: time.Now().Unix(),
  2314. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2315. IsUpload: 1,
  2316. OrderId: order_id,
  2317. }
  2318. service.CreateUploadRecord(hisFundSettleListResult)
  2319. c.ServeSuccessJSON(map[string]interface{}{
  2320. "msg": "上传成功",
  2321. "result": hisFundSettleListResult,
  2322. })
  2323. return
  2324. }
  2325. }
  2326. func (c *HisApiController) GetBatchSettleList() {
  2327. orders, _ := service.GetAllHisOrder(10106)
  2328. for _, item := range orders {
  2329. order_id := item.ID
  2330. order, _ := service.GetHisOrderByIDTwo(order_id)
  2331. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2332. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2333. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2334. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2335. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2336. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2337. if order.ID == 0 {
  2338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2339. return
  2340. }
  2341. if his.BalanceAccountsType == 2 {
  2342. continue
  2343. }
  2344. struct4101 := service.Struct4101{
  2345. PsnNo: order.PsnNo,
  2346. MdtrtId: order.MdtrtId,
  2347. SetlId: order.SetlId,
  2348. PsnName: order.PsnName,
  2349. Gend: order.Gend,
  2350. Brdy: his.Brdy,
  2351. Age: his.Age,
  2352. Naty: order.Naty,
  2353. PatnCertType: "01",
  2354. Certno: order.Certno,
  2355. Prfs: "90",
  2356. ConerName: roles[0].UserName,
  2357. PatnRlts: "99",
  2358. ConerAddr: miConfig.OrgName,
  2359. ConerTel: admin.Mobile,
  2360. HiType: order.Insutype,
  2361. Insuplc: his.InsuplcAdmdvs,
  2362. MaindiagFlag: "1",
  2363. BillCode: order.FaPiaoCode,
  2364. BillNo: order.FaPiaoNumber,
  2365. BizSn: order.Number,
  2366. PsnSelfPay: order.PsnPartAmt,
  2367. PsnOwnPay: order.PsnPartAmt,
  2368. AcctPay: order.AcctPay,
  2369. PsnCashpay: order.PsnCashPay,
  2370. HiPaymtd: "1",
  2371. Hsorg: his.InsuplcAdmdvs,
  2372. HsorgOpter: his.InsuplcAdmdvs,
  2373. MedinsFillPsn: curRoles.UserName,
  2374. MedinsFillDept: depart.Name,
  2375. IptMedType: "2",
  2376. }
  2377. struct4101.SetlBegnDate = order.SetlTime
  2378. struct4101.SetlEndDate = order.SetlTime
  2379. //if order.SettleType == 1 {
  2380. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2381. // dateStr := t.Format("2006-01-02")
  2382. // struct4101.SetlBegnDate = dateStr
  2383. // struct4101.SetlEndDate = dateStr
  2384. //} else {
  2385. // t := time.Unix(int64(order.SettleStartTime), 0)
  2386. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2387. // dateStartStr := t.Format("2006-01-02")
  2388. // dateEndStr := t2.Format("2006-01-02")
  2389. // struct4101.SetlBegnDate = dateStartStr
  2390. // struct4101.SetlEndDate = dateEndStr
  2391. //}
  2392. var rf []CustomFundPay
  2393. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2394. var tempFunPays []service.CustomStruct
  2395. var tempFunPay610100 service.CustomStruct
  2396. for _, item := range rf {
  2397. if item.FundPayType == "610100" {
  2398. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2399. tempFunPay610100.FundPayType = item.FundPayType
  2400. } else {
  2401. var tempFunPay service.CustomStruct
  2402. tempFunPay.FundPayamt = item.FundPayamt
  2403. tempFunPay.FundPayType = item.FundPayType
  2404. tempFunPays = append(tempFunPays, tempFunPay)
  2405. }
  2406. }
  2407. tempFunPays = append(tempFunPays, tempFunPay610100)
  2408. struct4101.CustomStruct = tempFunPays
  2409. var tempDiaginfos []service.DiaginfoStructTwo
  2410. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2411. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2412. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2413. var config []*models.HisXtDiagnoseConfig
  2414. for _, item := range diagnosis_ids {
  2415. id, _ := strconv.ParseInt(item, 10, 64)
  2416. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2417. config = append(config, &diagnosisConfig)
  2418. }
  2419. for index, item := range config {
  2420. if index == 0 {
  2421. var tempDiaginfo service.DiaginfoStructTwo
  2422. tempDiaginfo.DiagCode = item.CountryCode
  2423. tempDiaginfo.DiagName = item.CountryContentName
  2424. tempDiaginfo.DiagType = "1"
  2425. tempDiaginfo.MaindiagFlag = "1"
  2426. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2427. } else {
  2428. var tempDiaginfo service.DiaginfoStructTwo
  2429. tempDiaginfo.DiagCode = item.CountryCode
  2430. tempDiaginfo.DiagName = item.CountryContentName
  2431. tempDiaginfo.DiagType = "2"
  2432. tempDiaginfo.MaindiagFlag = "0"
  2433. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2434. }
  2435. }
  2436. struct4101.Diseinfo = tempDiaginfos
  2437. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2438. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2439. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2440. tempOpspdiseinfo2.OprnOprtCode = ""
  2441. tempOpspdiseinfo2.OprnOprtName = ""
  2442. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2443. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2444. var iteminfo service.IteminfoStruct
  2445. var bedCostTotal float64 = 0 //床位总费
  2446. var bedCostSelfTotal float64 = 0 //床位自费
  2447. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2448. var examineCostTotal float64 = 0 //诊查总费
  2449. var examineCostSelfTotal float64 = 0 //诊查自费
  2450. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2451. var nursingCostTotal float64 = 0 //护理总费
  2452. var nursingCostSelfTotal float64 = 0 //护理自费
  2453. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2454. var chineseMedicineCostTotal float64 = 0 //中成药
  2455. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2456. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2457. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2458. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2459. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2460. var registerCostTotal float64 = 0 //一般诊疗费
  2461. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2462. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2463. var operationCostTotal float64 = 0 //手术费
  2464. var operationCostSelfTotal float64 = 0 //手术费
  2465. var operationCostPartSelfTotal float64 = 0 //手术费
  2466. var otherCostTotal float64 = 0 //其他费用
  2467. var otherCostSelfTotal float64 = 0 //其他费用
  2468. var otherCostPartSelfTotal float64 = 0 //其他费用
  2469. var materialCostTotal float64 = 0 //材料费
  2470. var materialCostSelfTotal float64 = 0 //材料费
  2471. var materialCostPartSelfTotal float64 = 0 //材料费
  2472. var westernMedicineCostTotal float64 = 0 //西药费
  2473. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2474. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2475. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2476. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2477. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2478. var checkCostTotal float64 = 0 //检查费
  2479. var checkCostSelfTotal float64 = 0 //检查费
  2480. var checkCostPartSelfTotal float64 = 0 //检查费
  2481. var laboratoryCostTotal float64 = 0 //化验费
  2482. var laboratoryCostSelfTotal float64 = 0 //化验费
  2483. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2484. var treatCostTotal float64 = 0 //治疗费用
  2485. var treatCostSelfTotal float64 = 0 //治疗费用
  2486. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2487. decimal.DivisionPrecision = 2
  2488. var bed_fulamt_ownpay_amt float64 = 0
  2489. var examine_fulamt_ownpay_amt float64 = 0
  2490. var nursing_fulamt_ownpay_amt float64 = 0
  2491. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2492. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2493. var register_fulamt_ownpay_amt float64 = 0
  2494. var operation_fulamt_ownpay_amt float64 = 0
  2495. var other_fulamt_ownpay_amt float64 = 0
  2496. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2497. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2498. var check_fulamt_ownpay_amt float64 = 0
  2499. var material_fulamt_ownpay_amt float64 = 0
  2500. var laboratory_fulamt_ownpay_amt float64 = 0
  2501. var treat_fulamt_ownpay_amt float64 = 0
  2502. var bed_claa_sunmfee float64 = 0
  2503. var bed_clab_amt float64 = 0
  2504. var bed_other_amt float64 = 0
  2505. var examine_claa_sunmfee float64 = 0
  2506. var examine_clab_amt float64 = 0
  2507. var examine_other_amt float64 = 0
  2508. var nursing_claa_sunmfee float64 = 0
  2509. var nursing_clab_amt float64 = 0
  2510. var nursing_other_amt float64 = 0
  2511. var chinese_medicine_claa_sunmfee float64 = 0
  2512. var chinese_medicine_clab_amt float64 = 0
  2513. var chinese_medicine_other_amt float64 = 0
  2514. var commonly_treatment_claa_sunmfee float64 = 0
  2515. var commonly_treatment_clab_amt float64 = 0
  2516. var commonly_treatment_other_amt float64 = 0
  2517. var operation_claa_sunmfee float64 = 0
  2518. var operation_clab_amt float64 = 0
  2519. var operation_other_amt float64 = 0
  2520. var other_claa_sunmfee float64 = 0
  2521. var other_clab_amt float64 = 0
  2522. var other_other_amt float64 = 0
  2523. var westernMedicine_claa_sunmfee float64 = 0
  2524. var westernMedicine_clab_amt float64 = 0
  2525. var westernMedicine_other_amt float64 = 0
  2526. var chineseTraditional_claa_sunmfee float64 = 0
  2527. var chineseTraditional_clab_amt float64 = 0
  2528. var chineseTraditional_other_amt float64 = 0
  2529. var check_claa_sunmfee float64 = 0
  2530. var check_clab_amt float64 = 0
  2531. var check_other_amt float64 = 0
  2532. var material_claa_sunmfee float64 = 0
  2533. var material_clab_amt float64 = 0
  2534. var material_other_amt float64 = 0
  2535. var laboratory_claa_sunmfee float64 = 0
  2536. var laboratory_clab_amt float64 = 0
  2537. var laboratory_other_amt float64 = 0
  2538. var treat_claa_sunmfee float64 = 0
  2539. var treat_clab_amt float64 = 0
  2540. var treat_other_amt float64 = 0
  2541. var register_claa_sunmfee float64 = 0
  2542. var register_clab_amt float64 = 0
  2543. var register_other_amt float64 = 0
  2544. for _, item := range order.HisOrderInfo {
  2545. if item.MedChrgitmType == "01" { //床位费
  2546. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2547. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2548. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2549. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2550. if item.ChrgitmLv == "1" {
  2551. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2552. }
  2553. if item.ChrgitmLv == "2" {
  2554. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2555. }
  2556. if item.ChrgitmLv == "3" {
  2557. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2558. }
  2559. }
  2560. if item.MedChrgitmType == "02" { //诊查
  2561. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2562. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2563. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2564. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2565. if item.ChrgitmLv == "1" {
  2566. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2567. }
  2568. if item.ChrgitmLv == "2" {
  2569. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2570. }
  2571. if item.ChrgitmLv == "3" {
  2572. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2573. }
  2574. }
  2575. if item.MedChrgitmType == "03" { //检查费
  2576. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2577. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2578. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2579. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2580. if item.ChrgitmLv == "1" {
  2581. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2582. }
  2583. if item.ChrgitmLv == "2" {
  2584. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2585. }
  2586. if item.ChrgitmLv == "3" {
  2587. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2588. }
  2589. }
  2590. if item.MedChrgitmType == "04" { //化验费
  2591. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2592. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2593. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2594. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2595. if item.ChrgitmLv == "1" {
  2596. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2597. }
  2598. if item.ChrgitmLv == "2" {
  2599. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2600. }
  2601. if item.ChrgitmLv == "3" {
  2602. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2603. }
  2604. }
  2605. if item.MedChrgitmType == "05" { //治疗费
  2606. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2607. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2608. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2609. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2610. if item.ChrgitmLv == "1" {
  2611. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2612. }
  2613. if item.ChrgitmLv == "2" {
  2614. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2615. }
  2616. if item.ChrgitmLv == "3" {
  2617. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2618. }
  2619. }
  2620. if item.MedChrgitmType == "06" { //手术费
  2621. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2622. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2623. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2624. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2625. if item.ChrgitmLv == "1" {
  2626. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2627. }
  2628. if item.ChrgitmLv == "2" {
  2629. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2630. }
  2631. if item.ChrgitmLv == "3" {
  2632. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2633. }
  2634. }
  2635. if item.MedChrgitmType == "07" { //手术费
  2636. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2637. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2638. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2639. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2640. if item.ChrgitmLv == "1" {
  2641. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2642. }
  2643. if item.ChrgitmLv == "2" {
  2644. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2645. }
  2646. if item.ChrgitmLv == "3" {
  2647. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2648. }
  2649. }
  2650. if item.MedChrgitmType == "08" { //材料费
  2651. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2652. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2653. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2654. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2655. if item.ChrgitmLv == "1" {
  2656. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2657. }
  2658. if item.ChrgitmLv == "2" {
  2659. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2660. }
  2661. if item.ChrgitmLv == "3" {
  2662. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2663. }
  2664. }
  2665. if item.MedChrgitmType == "09" { //西药费
  2666. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2667. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2668. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2669. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2670. if item.ChrgitmLv == "1" {
  2671. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2672. }
  2673. if item.ChrgitmLv == "2" {
  2674. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2675. }
  2676. if item.ChrgitmLv == "3" {
  2677. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2678. }
  2679. }
  2680. if item.MedChrgitmType == "10" { //中药饮片
  2681. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2682. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2683. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2684. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2685. if item.ChrgitmLv == "1" {
  2686. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2687. }
  2688. if item.ChrgitmLv == "2" {
  2689. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2690. }
  2691. if item.ChrgitmLv == "3" {
  2692. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2693. }
  2694. }
  2695. if item.MedChrgitmType == "11" { //中成费
  2696. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2697. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2698. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2699. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2700. if item.ChrgitmLv == "1" {
  2701. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2702. }
  2703. if item.ChrgitmLv == "2" {
  2704. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2705. }
  2706. if item.ChrgitmLv == "3" {
  2707. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2708. }
  2709. }
  2710. if item.MedChrgitmType == "12" { //中成费
  2711. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2712. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2713. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2714. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2715. if item.ChrgitmLv == "1" {
  2716. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2717. }
  2718. if item.ChrgitmLv == "2" {
  2719. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2720. }
  2721. if item.ChrgitmLv == "3" {
  2722. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2723. }
  2724. }
  2725. if item.MedChrgitmType == "13" { //中成费
  2726. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2727. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2728. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2729. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2730. if item.ChrgitmLv == "1" {
  2731. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2732. }
  2733. if item.ChrgitmLv == "2" {
  2734. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2735. }
  2736. if item.ChrgitmLv == "3" {
  2737. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2738. }
  2739. }
  2740. if item.MedChrgitmType == "14" { //其他费
  2741. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2742. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2743. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2744. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2745. if item.ChrgitmLv == "1" {
  2746. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2747. }
  2748. if item.ChrgitmLv == "2" {
  2749. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2750. }
  2751. if item.ChrgitmLv == "3" {
  2752. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2753. }
  2754. }
  2755. }
  2756. var iteminfoStructs []service.IteminfoStruct
  2757. if bedCostTotal != 0 {
  2758. iteminfo.MedChrgitm = "01"
  2759. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2760. iteminfo.Amt = bedCostTotal
  2761. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2762. iteminfo.ClabAmt = bed_clab_amt
  2763. iteminfo.OthAmt = bed_other_amt
  2764. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2765. }
  2766. if examineCostTotal != 0 {
  2767. iteminfo.MedChrgitm = "02"
  2768. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2769. iteminfo.Amt = examineCostTotal
  2770. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2771. iteminfo.ClabAmt = examine_clab_amt
  2772. iteminfo.OthAmt = examine_other_amt
  2773. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2774. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2775. }
  2776. if checkCostTotal != 0 {
  2777. iteminfo.MedChrgitm = "03"
  2778. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2779. iteminfo.Amt = checkCostTotal
  2780. iteminfo.ClaaSumfee = check_claa_sunmfee
  2781. iteminfo.ClabAmt = check_clab_amt
  2782. iteminfo.OthAmt = check_other_amt
  2783. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2784. }
  2785. if laboratoryCostTotal != 0 {
  2786. iteminfo.MedChrgitm = "04"
  2787. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2788. iteminfo.Amt = laboratoryCostTotal
  2789. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2790. iteminfo.ClabAmt = laboratory_clab_amt
  2791. iteminfo.OthAmt = laboratory_other_amt
  2792. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2793. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2794. }
  2795. if treatCostTotal != 0 {
  2796. iteminfo.MedChrgitm = "05"
  2797. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2798. iteminfo.Amt = treatCostTotal
  2799. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2800. iteminfo.ClabAmt = treat_clab_amt
  2801. iteminfo.OthAmt = treat_other_amt
  2802. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2803. //(struct4101.IteminfoStruct, iteminfo)
  2804. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2805. }
  2806. if operationCostTotal != 0 {
  2807. iteminfo.MedChrgitm = "06"
  2808. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2809. iteminfo.Amt = operationCostTotal
  2810. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2811. iteminfo.ClabAmt = operation_clab_amt
  2812. iteminfo.OthAmt = operation_other_amt
  2813. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2814. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2815. }
  2816. if nursingCostTotal != 0 {
  2817. iteminfo.MedChrgitm = "07"
  2818. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2819. iteminfo.Amt = nursingCostTotal
  2820. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2821. iteminfo.ClabAmt = nursing_clab_amt
  2822. iteminfo.OthAmt = nursing_other_amt
  2823. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2824. }
  2825. if materialCostTotal != 0 {
  2826. iteminfo.MedChrgitm = "08"
  2827. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2828. iteminfo.Amt = materialCostTotal
  2829. iteminfo.ClaaSumfee = material_claa_sunmfee
  2830. iteminfo.ClabAmt = material_clab_amt
  2831. iteminfo.OthAmt = material_other_amt
  2832. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2833. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2834. }
  2835. if westernMedicineCostTotal != 0 {
  2836. iteminfo.MedChrgitm = "09"
  2837. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2838. iteminfo.Amt = westernMedicineCostTotal
  2839. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2840. iteminfo.ClabAmt = westernMedicine_clab_amt
  2841. iteminfo.OthAmt = westernMedicine_other_amt
  2842. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2843. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2844. }
  2845. if chineseMedicineCostTotal != 0 {
  2846. iteminfo.MedChrgitm = "10"
  2847. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2848. iteminfo.Amt = chineseMedicineCostTotal
  2849. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2850. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2851. iteminfo.OthAmt = chinese_medicine_other_amt
  2852. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2853. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2854. }
  2855. if chineseTraditionalMedicineCostTotal != 0 {
  2856. iteminfo.MedChrgitm = "11"
  2857. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2858. iteminfo.Amt = westernMedicineCostTotal
  2859. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2860. iteminfo.ClabAmt = westernMedicine_clab_amt
  2861. iteminfo.OthAmt = westernMedicine_other_amt
  2862. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2863. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2864. }
  2865. if commonlyTreatmentCostTotal != 0 {
  2866. iteminfo.MedChrgitm = "12"
  2867. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2868. iteminfo.Amt = commonlyTreatmentCostTotal
  2869. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2870. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2871. iteminfo.OthAmt = commonly_treatment_other_amt
  2872. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2873. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2874. }
  2875. if registerCostTotal != 0 {
  2876. iteminfo.MedChrgitm = "13"
  2877. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2878. iteminfo.Amt = registerCostTotal
  2879. iteminfo.ClaaSumfee = register_claa_sunmfee
  2880. iteminfo.ClabAmt = register_clab_amt
  2881. iteminfo.OthAmt = register_other_amt
  2882. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2883. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2884. }
  2885. if otherCostTotal != 0 {
  2886. iteminfo.MedChrgitm = "14"
  2887. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2888. iteminfo.Amt = otherCostTotal
  2889. iteminfo.ClaaSumfee = other_claa_sunmfee
  2890. iteminfo.ClabAmt = other_clab_amt
  2891. iteminfo.OthAmt = other_other_amt
  2892. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2893. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2894. }
  2895. struct4101.IteminfoStruct = iteminfoStructs
  2896. struct4101.Ntly = "中国"
  2897. struct4101.AdmCaty = "A03.06"
  2898. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2899. fmt.Println(result)
  2900. var dat map[string]interface{}
  2901. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2902. fmt.Println(dat)
  2903. } else {
  2904. fmt.Println(err)
  2905. }
  2906. userJSONBytes, _ := json.Marshal(dat)
  2907. var res ResultSeventeen
  2908. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2909. utils.ErrorLog("解析失败:%v", err)
  2910. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2911. adminUser := c.GetAdminUserInfo()
  2912. errlog := &models.HisOrderError{
  2913. UserOrgId: adminUser.CurrentOrgId,
  2914. Ctime: time.Now().Unix(),
  2915. Mtime: time.Now().Unix(),
  2916. ErrMsg: res.ErrMsg + "解析失败",
  2917. Status: 1,
  2918. PatientId: order_id,
  2919. Stage: 10106,
  2920. }
  2921. service.CreateErrMsgLog(errlog)
  2922. continue
  2923. }
  2924. if res.Infcode != 0 {
  2925. adminUser := c.GetAdminUserInfo()
  2926. errlog := &models.HisOrderError{
  2927. UserOrgId: adminUser.CurrentOrgId,
  2928. Ctime: time.Now().Unix(),
  2929. Mtime: time.Now().Unix(),
  2930. ErrMsg: res.ErrMsg,
  2931. Status: 1,
  2932. PatientId: order_id,
  2933. Stage: 10106,
  2934. }
  2935. service.CreateErrMsgLog(errlog)
  2936. continue
  2937. } else {
  2938. hisFundSettleListResult := &models.HisFundSettleListResult{
  2939. Number: res.Output.SetlListId,
  2940. Status: 1,
  2941. Ctime: time.Now().Unix(),
  2942. Mtime: time.Now().Unix(),
  2943. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2944. IsUpload: 1,
  2945. OrderId: order_id,
  2946. }
  2947. service.CreateUploadRecord(hisFundSettleListResult)
  2948. continue
  2949. }
  2950. }
  2951. }
  2952. func (c *HisApiController) GetOrgInfo() {
  2953. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2954. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2955. }
  2956. func (c *HisApiController) GetHisPatientInfo() {
  2957. medical_insurance_card := c.GetString("medical_insurance_card")
  2958. id_card_type, _ := c.GetInt64("id_card_type")
  2959. id_card := c.GetString("id_card")
  2960. adminInfo := c.GetAdminUserInfo()
  2961. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2962. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2963. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2964. IdCardNo := ""
  2965. if id_card_type == 1 {
  2966. IdCardNo = medical_insurance_card
  2967. } else if id_card_type == 2 {
  2968. IdCardNo = id_card
  2969. }
  2970. if config.IsOpen == 1 {
  2971. 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
  2972. resp, requestErr := http.Get(api)
  2973. if requestErr != nil {
  2974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2975. return
  2976. }
  2977. defer resp.Body.Close()
  2978. body, ioErr := ioutil.ReadAll(resp.Body)
  2979. if ioErr != nil {
  2980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2982. return
  2983. }
  2984. var respJSON map[string]interface{}
  2985. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2988. return
  2989. }
  2990. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2991. userJSONBytes, _ := json.Marshal(userJSON)
  2992. var res ResultTwo
  2993. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2994. utils.ErrorLog("解析失败:%v", err)
  2995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2996. return
  2997. }
  2998. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2999. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3000. infoStr := string(Iinfos)
  3001. idetinfoStr := string(Idetinfos)
  3002. if res.Infcode == 0 {
  3003. his := models.VMHisPatient{
  3004. Status: 1,
  3005. Ctime: time.Now().Unix(),
  3006. Mtime: time.Now().Unix(),
  3007. PsnNo: res.Output.Baseinfo.PsnNo,
  3008. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3009. Certno: res.Output.Baseinfo.Certno,
  3010. PsnName: res.Output.Baseinfo.PsnName,
  3011. Gend: res.Output.Baseinfo.Gend,
  3012. Naty: res.Output.Baseinfo.Naty,
  3013. Brdy: res.Output.Baseinfo.Brdy,
  3014. Age: res.Output.Baseinfo.Age,
  3015. Iinfo: infoStr,
  3016. Idetinfo: idetinfoStr,
  3017. UserOrgId: adminInfo.CurrentOrgId,
  3018. IsReturn: 1,
  3019. IdCardType: id_card_type,
  3020. }
  3021. c.ServeSuccessJSON(map[string]interface{}{
  3022. "info": his,
  3023. })
  3024. } else {
  3025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3026. return
  3027. }
  3028. }
  3029. }
  3030. //func GetBasBaseInfo() (jsonStr string, err error) {
  3031. //
  3032. // handle := syscall.NewLazyDLL("SSCard.dll")
  3033. // add := handle.NewProc("ReadCardBas")
  3034. // str := make([]byte, 1024)
  3035. // str1 := make([]byte, 1024)
  3036. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3037. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3038. //
  3039. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3040. //
  3041. // fmt.Println("> Add(4,5)的结果为:", ret)
  3042. // handle.Release()
  3043. //
  3044. // return "", nil
  3045. //
  3046. //}
  3047. //func GetQRBaseInfo() (jsonStr string, err error) {
  3048. // handle := syscall.LoadDLL("SSCard.dll")
  3049. // ReadCardBas := handle.FindProc("GetQRBase")
  3050. //
  3051. // str := make([]byte, 256)
  3052. // str1 := make([]byte, 256)
  3053. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3054. //
  3055. // fmt.Println(string(str))
  3056. // fmt.Println(r)
  3057. // return string(str), nil
  3058. //}
  3059. //func CardInit() int {
  3060. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3061. // add := DllTestDef.MustFindProc("Init")
  3062. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3063. // if err != nil {
  3064. // fmt.Println("SSCard的运算结果为:", ret)
  3065. // }
  3066. // result := int(ret)
  3067. // return result
  3068. //}
  3069. //func CardInit() int {
  3070. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3071. // if err != nil {
  3072. // fmt.Println("SSCard的运算结果为:", ret)
  3073. // }
  3074. // fmt.Println(err)
  3075. // result := int(ret)
  3076. // return result
  3077. //}
  3078. func IntPtr(n int) uintptr {
  3079. return uintptr(n)
  3080. }
  3081. func StrPtr(s string) uintptr {
  3082. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3083. }
  3084. type Result2001 struct {
  3085. Cainfo interface{} `json:"cainfo"`
  3086. ErrMsg string `json:"err_msg"`
  3087. InfRefmsgid string `json:"inf_refmsgid"`
  3088. Infcode int64 `json:"infcode"`
  3089. Output struct {
  3090. Trtinfo struct {
  3091. PsnNo string `json:"psn_no"`
  3092. TrtChkType string `json:"trt_chk_type"`
  3093. FundPayType string `json:"fund_pay_type"`
  3094. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3095. Begndate string `json:"begndate"`
  3096. Enddate string `json:"enddate"`
  3097. TrtChkRslt string `json:"trt_chk_rslt"`
  3098. } `json:"trtinfo"`
  3099. } `json:"output"`
  3100. RefmsgTime string `json:"refmsg_time"`
  3101. RespondTime string `json:"respond_time"`
  3102. Signtype interface{} `json:"signtype"`
  3103. WarnMsg interface{} `json:"warn_msg"`
  3104. }
  3105. type Result2001Org10265 struct {
  3106. Cainfo interface{} `json:"cainfo"`
  3107. ErrMsg string `json:"err_msg"`
  3108. InfRefmsgid string `json:"inf_refmsgid"`
  3109. Infcode string `json:"infcode"`
  3110. Output struct {
  3111. Trtinfo struct {
  3112. PsnNo string `json:"psn_no"`
  3113. TrtChkType string `json:"trt_chk_type"`
  3114. FundPayType string `json:"fund_pay_type"`
  3115. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3116. Begndate string `json:"begndate"`
  3117. Enddate string `json:"enddate"`
  3118. TrtChkRslt string `json:"trt_chk_rslt"`
  3119. } `json:"trtinfo"`
  3120. } `json:"output"`
  3121. RefmsgTime string `json:"refmsg_time"`
  3122. RespondTime string `json:"respond_time"`
  3123. Signtype interface{} `json:"signtype"`
  3124. WarnMsg interface{} `json:"warn_msg"`
  3125. }
  3126. type ResultTwo struct {
  3127. ErrMsg string `json:"err_msg"`
  3128. InfRefmsgid string `json:"inf_refmsgid"`
  3129. Infcode int64 `json:"infcode"`
  3130. Output struct {
  3131. Baseinfo struct {
  3132. Age float64 `json:"age"`
  3133. Brdy string `json:"brdy"`
  3134. Certno string `json:"certno"`
  3135. Gend string `json:"gend"`
  3136. Naty string `json:"naty"`
  3137. PsnCertType string `json:"psn_cert_type"`
  3138. PsnName string `json:"psn_name"`
  3139. PsnNo string `json:"psn_no"`
  3140. } `json:"baseinfo"`
  3141. Idetinfo []interface{} `json:"idetinfo"`
  3142. Iinfo []struct {
  3143. Balc float64 `json:"balc"`
  3144. CvlservFlag string `json:"cvlserv_flag"`
  3145. EmpName string `json:"emp_name"`
  3146. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3147. Insutype string `json:"insutype"`
  3148. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3149. PausInsuDate string `json:"paus_insu_date"`
  3150. PsnInsuDate string `json:"psn_insu_date"`
  3151. PsnInsuStas string `json:"psn_insu_stas"`
  3152. PsnType string `json:"psn_type"`
  3153. } `json:"insuinfo"`
  3154. } `json:"output"`
  3155. RefmsgTime string `json:"refmsg_time"`
  3156. RespondTime string `json:"respond_time"`
  3157. Signtype interface{} `json:"signtype"`
  3158. WarnInfo interface{} `json:"warn_info"`
  3159. }
  3160. type ResultTwo10265 struct {
  3161. ErrMsg string `json:"err_msg"`
  3162. InfRefmsgid string `json:"inf_refmsgid"`
  3163. Infcode string `json:"infcode"`
  3164. Output struct {
  3165. Baseinfo struct {
  3166. Age float64 `json:"age"`
  3167. Brdy string `json:"brdy"`
  3168. Certno string `json:"certno"`
  3169. Gend string `json:"gend"`
  3170. Naty string `json:"naty"`
  3171. PsnCertType string `json:"psn_cert_type"`
  3172. PsnName string `json:"psn_name"`
  3173. PsnNo string `json:"psn_no"`
  3174. } `json:"baseinfo"`
  3175. Idetinfo []interface{} `json:"idetinfo"`
  3176. Iinfo []struct {
  3177. Balc float64 `json:"balc"`
  3178. CvlservFlag string `json:"cvlserv_flag"`
  3179. EmpName string `json:"emp_name"`
  3180. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3181. Insutype string `json:"insutype"`
  3182. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3183. PausInsuDate string `json:"paus_insu_date"`
  3184. PsnInsuDate string `json:"psn_insu_date"`
  3185. PsnInsuStas string `json:"psn_insu_stas"`
  3186. PsnType string `json:"psn_type"`
  3187. } `json:"insuinfo"`
  3188. } `json:"output"`
  3189. RefmsgTime string `json:"refmsg_time"`
  3190. RespondTime string `json:"respond_time"`
  3191. Signtype interface{} `json:"signtype"`
  3192. WarnInfo interface{} `json:"warn_info"`
  3193. }
  3194. type ResultThree struct {
  3195. Cainfo interface{} `json:"cainfo"`
  3196. ErrMsg string `json:"err_msg"`
  3197. InfRefmsgid string `json:"inf_refmsgid"`
  3198. Infcode int64 `json:"infcode"`
  3199. Output struct {
  3200. Data struct {
  3201. IptOtpNo string `json:"ipt_otp_no"`
  3202. MdtrtID string `json:"mdtrt_id"`
  3203. PsnNo string `json:"psn_no"`
  3204. } `json:"data"`
  3205. } `json:"output"`
  3206. RefmsgTime string `json:"refmsg_time"`
  3207. RespondTime string `json:"respond_time"`
  3208. Signtype interface{} `json:"signtype"`
  3209. WarnMsg interface{} `json:"warn_msg"`
  3210. }
  3211. type ResultThree10265 struct {
  3212. Cainfo interface{} `json:"cainfo"`
  3213. ErrMsg string `json:"err_msg"`
  3214. InfRefmsgid string `json:"inf_refmsgid"`
  3215. Infcode string `json:"infcode"`
  3216. Output struct {
  3217. Data struct {
  3218. IptOtpNo string `json:"ipt_otp_no"`
  3219. MdtrtID string `json:"mdtrt_id"`
  3220. PsnNo string `json:"psn_no"`
  3221. } `json:"data"`
  3222. } `json:"output"`
  3223. RefmsgTime string `json:"refmsg_time"`
  3224. RespondTime string `json:"respond_time"`
  3225. Signtype interface{} `json:"signtype"`
  3226. WarnMsg interface{} `json:"warn_msg"`
  3227. }
  3228. type ResultFour struct {
  3229. Cainfo string `json:"cainfo"`
  3230. ErrMsg string `json:"err_msg"`
  3231. InfRefmsgid string `json:"inf_refmsgid"`
  3232. Infcode int64 `json:"infcode"`
  3233. Output struct {
  3234. Result []struct {
  3235. BasMednFlag string `json:"bas_medn_flag"`
  3236. ChldMedcFlag string `json:"chld_medc_flag"`
  3237. ChrgitmLv string `json:"chrgitm_lv"`
  3238. Cnt float64 `json:"cnt"`
  3239. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3240. DrtReimFlag string `json:"drt_reim_flag"`
  3241. FeedetlSn string `json:"feedetl_sn"`
  3242. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3243. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3244. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3245. ListSpItemFlag string `json:"list_sp_item_flag"`
  3246. LmtUsedFlag string `json:"lmt_used_flag"`
  3247. MedChrgitmType string `json:"med_chrgitm_type"`
  3248. Memo string `json:"memo"`
  3249. OverlmtAmt float64 `json:"overlmt_amt"`
  3250. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3251. Pric float64 `json:"pric"`
  3252. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3253. SelfpayProp float64 `json:"selfpay_prop"`
  3254. } `json:"result"`
  3255. } `json:"output"`
  3256. RefmsgTime string `json:"refmsg_time"`
  3257. RespondTime string `json:"respond_time"`
  3258. Signtype string `json:"signtype"`
  3259. WarnMsg string `json:"warn_msg"`
  3260. }
  3261. type ResultFour10265 struct {
  3262. Cainfo string `json:"cainfo"`
  3263. ErrMsg string `json:"err_msg"`
  3264. InfRefmsgid string `json:"inf_refmsgid"`
  3265. Infcode string `json:"infcode"`
  3266. Output struct {
  3267. Result []struct {
  3268. BasMednFlag string `json:"bas_medn_flag"`
  3269. ChldMedcFlag string `json:"chld_medc_flag"`
  3270. ChrgitmLv string `json:"chrgitm_lv"`
  3271. Cnt float64 `json:"cnt"`
  3272. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3273. DrtReimFlag string `json:"drt_reim_flag"`
  3274. FeedetlSn string `json:"feedetl_sn"`
  3275. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3276. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3277. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3278. ListSpItemFlag string `json:"list_sp_item_flag"`
  3279. LmtUsedFlag string `json:"lmt_used_flag"`
  3280. MedChrgitmType string `json:"med_chrgitm_type"`
  3281. Memo string `json:"memo"`
  3282. OverlmtAmt float64 `json:"overlmt_amt"`
  3283. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3284. Pric float64 `json:"pric"`
  3285. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3286. SelfpayProp float64 `json:"selfpay_prop"`
  3287. } `json:"result"`
  3288. } `json:"output"`
  3289. RefmsgTime string `json:"refmsg_time"`
  3290. RespondTime string `json:"respond_time"`
  3291. Signtype string `json:"signtype"`
  3292. WarnMsg string `json:"warn_msg"`
  3293. }
  3294. type ResultFive struct {
  3295. Balc float64 `json:"balc"`
  3296. CvlservFlag string `json:"cvlserv_flag"`
  3297. EmpName string `json:"emp_name"`
  3298. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3299. Insutype string `json:"insutype"`
  3300. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3301. PausInsuDate string `json:"paus_insu_date"`
  3302. PsnInsuDate string `json:"psn_insu_date"`
  3303. PsnInsuStas string `json:"psn_insu_stas"`
  3304. PsnType string `json:"psn_type"`
  3305. }
  3306. type ResultSix struct {
  3307. Cainfo interface{} `json:"cainfo"`
  3308. ErrMsg string `json:"err_msg"`
  3309. InfRefmsgid string `json:"inf_refmsgid"`
  3310. Infcode int64 `json:"infcode"`
  3311. Output struct {
  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 ResultSix10265 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. } `json:"output"`
  3325. RefmsgTime string `json:"refmsg_time"`
  3326. RespondTime string `json:"respond_time"`
  3327. Signtype interface{} `json:"signtype"`
  3328. WarnMsg interface{} `json:"warn_msg"`
  3329. }
  3330. type ResultSeven struct {
  3331. Cainfo string `json:"cainfo"`
  3332. ErrMsg string `json:"err_msg"`
  3333. InfRefmsgid string `json:"inf_refmsgid"`
  3334. Infcode int64 `json:"infcode"`
  3335. Output struct {
  3336. Setldetail []interface{} `json:"setldetail"`
  3337. Setlinfo struct {
  3338. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3339. AcctPay float64 `json:"acct_pay"`
  3340. ActPayDedc float64 `json:"act_pay_dedc"`
  3341. Age float64 `json:"age"`
  3342. Balc float64 `json:"balc"`
  3343. Brdy string `json:"brdy"`
  3344. Certno string `json:"certno"`
  3345. ClrOptins string `json:"clr_optins"`
  3346. ClrType string `json:"clr_type"`
  3347. ClrWay string `json:"clr_way"`
  3348. CvlservFlag string `json:"cvlserv_flag"`
  3349. CvlservPay float64 `json:"cvlserv_pay"`
  3350. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3351. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3352. Gend string `json:"gend"`
  3353. HifesPay float64 `json:"hifes_pay"`
  3354. HifmiPay float64 `json:"hifmi_pay"`
  3355. HifpPay float64 `json:"hifp_pay"`
  3356. HospPartAmt float64 `json:"hosp_part_amt"`
  3357. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3358. Insutype string `json:"insutype"`
  3359. MafPay float64 `json:"maf_pay"`
  3360. MdtrtCertType string `json:"mdtrt_cert_type"`
  3361. HifobPay float64 `json:"hifob_pay"`
  3362. MdtrtID string `json:"mdtrt_id"`
  3363. MedType string `json:"med_type"`
  3364. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3365. MedinsSetlID string `json:"medins_setl_id"`
  3366. Naty string `json:"naty"`
  3367. OthPay float64 `json:"oth_pay"`
  3368. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3369. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3370. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3371. PsnCashPay float64 `json:"psn_cash_pay"`
  3372. PsnCertType string `json:"psn_cert_type"`
  3373. PsnName string `json:"psn_name"`
  3374. PsnNo string `json:"psn_no"`
  3375. PsnPartAmt float64 `json:"psn_part_amt"`
  3376. PsnType string `json:"psn_type"`
  3377. SetlID string `json:"setl_id"`
  3378. SetlTime string `json:"setl_time"`
  3379. } `json:"setlinfo"`
  3380. } `json:"output"`
  3381. RefmsgTime string `json:"refmsg_time"`
  3382. RespondTime string `json:"respond_time"`
  3383. Signtype interface{} `json:"signtype"`
  3384. WarnMsg interface{} `json:"warn_msg"`
  3385. }
  3386. type ResultSeven10265 struct {
  3387. Cainfo string `json:"cainfo"`
  3388. ErrMsg string `json:"err_msg"`
  3389. InfRefmsgid string `json:"inf_refmsgid"`
  3390. Infcode string `json:"infcode"`
  3391. Output struct {
  3392. Setldetail []interface{} `json:"setldetail"`
  3393. Setlinfo struct {
  3394. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3395. AcctPay float64 `json:"acct_pay"`
  3396. ActPayDedc float64 `json:"act_pay_dedc"`
  3397. Age float64 `json:"age"`
  3398. Balc float64 `json:"balc"`
  3399. Brdy string `json:"brdy"`
  3400. Certno string `json:"certno"`
  3401. ClrOptins string `json:"clr_optins"`
  3402. ClrType string `json:"clr_type"`
  3403. ClrWay string `json:"clr_way"`
  3404. CvlservFlag string `json:"cvlserv_flag"`
  3405. CvlservPay float64 `json:"cvlserv_pay"`
  3406. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3407. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3408. Gend string `json:"gend"`
  3409. HifesPay float64 `json:"hifes_pay"`
  3410. HifmiPay float64 `json:"hifmi_pay"`
  3411. HifpPay float64 `json:"hifp_pay"`
  3412. HospPartAmt float64 `json:"hosp_part_amt"`
  3413. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3414. Insutype string `json:"insutype"`
  3415. MafPay float64 `json:"maf_pay"`
  3416. MdtrtCertType string `json:"mdtrt_cert_type"`
  3417. HifobPay float64 `json:"hifob_pay"`
  3418. MdtrtID string `json:"mdtrt_id"`
  3419. MedType string `json:"med_type"`
  3420. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3421. MedinsSetlID string `json:"medins_setl_id"`
  3422. Naty string `json:"naty"`
  3423. OthPay float64 `json:"oth_pay"`
  3424. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3425. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3426. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3427. PsnCashPay float64 `json:"psn_cash_pay"`
  3428. PsnCertType string `json:"psn_cert_type"`
  3429. PsnName string `json:"psn_name"`
  3430. PsnNo string `json:"psn_no"`
  3431. PsnPartAmt float64 `json:"psn_part_amt"`
  3432. PsnType string `json:"psn_type"`
  3433. SetlID string `json:"setl_id"`
  3434. SetlTime string `json:"setl_time"`
  3435. } `json:"setlinfo"`
  3436. } `json:"output"`
  3437. RefmsgTime string `json:"refmsg_time"`
  3438. RespondTime string `json:"respond_time"`
  3439. Signtype interface{} `json:"signtype"`
  3440. WarnMsg interface{} `json:"warn_msg"`
  3441. }
  3442. type ResultEight struct {
  3443. Cainfo string `json:"cainfo"`
  3444. ErrMsg string `json:"err_msg"`
  3445. InfRefmsgid string `json:"inf_refmsgid"`
  3446. Infcode int64 `json:"infcode"`
  3447. Output struct {
  3448. Stmtinfo struct {
  3449. SetlOptins string `json:"setl_optins"`
  3450. StmtRslt string `json:"stmt_rslt"`
  3451. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3452. } `json:"stmtinfo"`
  3453. } `json:"output"`
  3454. RefmsgTime string `json:"refmsg_time"`
  3455. RespondTime string `json:"respond_time"`
  3456. Signtype interface{} `json:"signtype"`
  3457. WarnMsg interface{} `json:"warn_msg"`
  3458. }
  3459. type ResultEightFor10188 struct {
  3460. Cainfo string `json:"cainfo"`
  3461. ErrMsg string `json:"err_msg"`
  3462. InfRefmsgid string `json:"inf_refmsgid"`
  3463. Infcode string `json:"infcode"`
  3464. Output struct {
  3465. Stmtinfo struct {
  3466. SetlOptins string `json:"setl_optins"`
  3467. StmtRslt string `json:"stmt_rslt"`
  3468. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3469. } `json:"stmtinfo"`
  3470. } `json:"output"`
  3471. RefmsgTime string `json:"refmsg_time"`
  3472. RespondTime string `json:"respond_time"`
  3473. Signtype interface{} `json:"signtype"`
  3474. WarnMsg interface{} `json:"warn_msg"`
  3475. }
  3476. type ResultNine struct {
  3477. Cainfo string `json:"cainfo"`
  3478. ErrMsg string `json:"err_msg"`
  3479. InfRefmsgid string `json:"inf_refmsgid"`
  3480. Infcode int64 `json:"infcode"`
  3481. Output struct {
  3482. FileQuryNo string `json:"file_qury_no"`
  3483. } `json:"output"`
  3484. RefmsgTime string `json:"refmsg_time"`
  3485. RespondTime string `json:"respond_time"`
  3486. Signtype interface{} `json:"signtype"`
  3487. WarnMsg interface{} `json:"warn_msg"`
  3488. }
  3489. type ResultTen struct {
  3490. Cainfo string `json:"cainfo"`
  3491. ErrMsg string `json:"err_msg"`
  3492. InfRefmsgid string `json:"inf_refmsgid"`
  3493. Infcode int64 `json:"infcode"`
  3494. Output struct {
  3495. DldEndtime string `json:"dld_endtime"`
  3496. FileQuryNo string `json:"file_qury_no"`
  3497. Filename string `json:"filename"`
  3498. } `json:"output"`
  3499. RefmsgTime string `json:"refmsg_time"`
  3500. RespondTime string `json:"respond_time"`
  3501. Signtype interface{} `json:"signtype"`
  3502. WarnMsg interface{} `json:"warn_msg"`
  3503. }
  3504. //type Autogenerated struct {
  3505. // Output struct {
  3506. // Setlinfo struct {
  3507. // SetlTime string `json:"setl_time"`
  3508. // CvlservPay float64 `json:"cvlserv_pay"`
  3509. // Year string `json:"year"`
  3510. // MedType string `json:"med_type"`
  3511. // PsnPay float64 `json:"psn_pay"`
  3512. // OpterID string `json:"opter_id"`
  3513. // Begndate string `json:"begndate"`
  3514. // FlxempeFlag string `json:"flxempe_flag"`
  3515. // HifmiPay float64 `json:"hifmi_pay"`
  3516. // PsnNo string `json:"psn_no"`
  3517. // ActPayDedc float64 `json:"act_pay_dedc"`
  3518. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3519. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3520. // ClrWay string `json:"clr_way"`
  3521. // OthPay float64 `json:"oth_pay"`
  3522. // Gend string `json:"gend"`
  3523. // MdtrtID string `json:"mdtrt_id"`
  3524. // AcctPay float64 `json:"acct_pay"`
  3525. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3526. // Insutype string `json:"insutype"`
  3527. // Invono interface{} `json:"invono"`
  3528. // Enddate string `json:"enddate"`
  3529. // CashPayamt float64 `json:"cash_payamt"`
  3530. // PsnType string `json:"psn_type"`
  3531. // FixmedinsName string `json:"fixmedins_name"`
  3532. // HifpPay float64 `json:"hifp_pay"`
  3533. // NewFlag interface{} `json:"new_flag"`
  3534. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3535. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3536. // PayLoc string `json:"pay_loc"`
  3537. // ClrType string `json:"clr_type"`
  3538. // RefdSetlFlag string `json:"refd_setl_flag"`
  3539. // CvlservFlag string `json:"cvlserv_flag"`
  3540. // EmpName string `json:"emp_name"`
  3541. // Brdy string `json:"brdy"`
  3542. // Naty string `json:"naty"`
  3543. // Certno string `json:"certno"`
  3544. // DiseCode string `json:"dise_code"`
  3545. // FixmedinsCode string `json:"fixmedins_code"`
  3546. // DedcHospLv string `json:"dedc_hosp_lv"`
  3547. // OpterName string `json:"opter_name"`
  3548. // Balc float64 `json:"balc"`
  3549. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3550. // PsnCertType string `json:"psn_cert_type"`
  3551. // HifobPay float64 `json:"hifob_pay"`
  3552. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3553. // HifesPay float64 `json:"hifes_pay"`
  3554. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3555. // OptTime string `json:"opt_time"`
  3556. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3557. // SetlID string `json:"setl_id"`
  3558. // MafPay float64 `json:"maf_pay"`
  3559. // PsnName string `json:"psn_name"`
  3560. // InsuOptins interface{} `json:"insu_optins"`
  3561. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3562. // ClrOptins string `json:"clr_optins"`
  3563. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3564. // DiseName string `json:"dise_name"`
  3565. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3566. // Age float64 `json:"age"`
  3567. // DtrtCertType string `json:"dtrt_cert_type"`
  3568. // HospLv string `json:"hosp_lv"`
  3569. // } `json:"setlinfo"`
  3570. // Setldetail []struct {
  3571. // FundPayType string `json:"fund_pay_type"`
  3572. // FundPayamt float64 `json:"fund_payamt"`
  3573. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3574. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3575. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3576. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3577. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3578. // } `json:"setldetail"`
  3579. // } `json:"output"`
  3580. // Infcode int `json:"infcode"`
  3581. // WarnMsg interface{} `json:"warn_msg"`
  3582. // Cainfo interface{} `json:"cainfo"`
  3583. // ErrMsg interface{} `json:"err_msg"`
  3584. // RefmsgTime string `json:"refmsg_time"`
  3585. // Signtype interface{} `json:"signtype"`
  3586. // RespondTime string `json:"respond_time"`
  3587. // InfRefmsgid string `json:"inf_refmsgid"`
  3588. //}
  3589. type ResultEleven struct {
  3590. Cainfo string `json:"cainfo"`
  3591. ErrMsg string `json:"err_msg"`
  3592. InfRefmsgid string `json:"inf_refmsgid"`
  3593. Infcode int64 `json:"infcode"`
  3594. Output struct {
  3595. Setlinfo struct {
  3596. SetlTime string `json:"setl_time"`
  3597. CvlservPay float64 `json:"cvlserv_pay"`
  3598. Year string `json:"year"`
  3599. MedType string `json:"med_type"`
  3600. PsnPay float64 `json:"psn_pay"`
  3601. OpterID string `json:"opter_id"`
  3602. Begndate string `json:"begndate"`
  3603. FlxempeFlag string `json:"flxempe_flag"`
  3604. HifmiPay float64 `json:"hifmi_pay"`
  3605. PsnNo string `json:"psn_no"`
  3606. ActPayDedc float64 `json:"act_pay_dedc"`
  3607. MedinsSetlID interface{} `json:"medins_setl_id"`
  3608. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3609. ClrWay string `json:"clr_way"`
  3610. OthPay float64 `json:"oth_pay"`
  3611. Gend string `json:"gend"`
  3612. MdtrtID string `json:"mdtrt_id"`
  3613. AcctPay float64 `json:"acct_pay"`
  3614. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3615. Insutype string `json:"insutype"`
  3616. Invono interface{} `json:"invono"`
  3617. Enddate string `json:"enddate"`
  3618. CashPayamt float64 `json:"cash_payamt"`
  3619. PsnType string `json:"psn_type"`
  3620. FixmedinsName string `json:"fixmedins_name"`
  3621. HifpPay float64 `json:"hifp_pay"`
  3622. NewFlag interface{} `json:"new_flag"`
  3623. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3624. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3625. PayLoc string `json:"pay_loc"`
  3626. ClrType string `json:"clr_type"`
  3627. RefdSetlFlag string `json:"refd_setl_flag"`
  3628. CvlservFlag string `json:"cvlserv_flag"`
  3629. EmpName string `json:"emp_name"`
  3630. Brdy string `json:"brdy"`
  3631. Naty string `json:"naty"`
  3632. Certno string `json:"certno"`
  3633. DiseCode string `json:"dise_code"`
  3634. FixmedinsCode string `json:"fixmedins_code"`
  3635. DedcHospLv string `json:"dedc_hosp_lv"`
  3636. OpterName string `json:"opter_name"`
  3637. Balc float64 `json:"balc"`
  3638. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3639. PsnCertType string `json:"psn_cert_type"`
  3640. HifobPay float64 `json:"hifob_pay"`
  3641. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3642. HifesPay float64 `json:"hifes_pay"`
  3643. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3644. OptTime string `json:"opt_time"`
  3645. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3646. SetlID string `json:"setl_id"`
  3647. MafPay float64 `json:"maf_pay"`
  3648. PsnName string `json:"psn_name"`
  3649. InsuOptins interface{} `json:"insu_optins"`
  3650. PrefFundPay interface{} `json:"pref_fund_pay"`
  3651. ClrOptins string `json:"clr_optins"`
  3652. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3653. DiseName string `json:"dise_name"`
  3654. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3655. Age float64 `json:"age"`
  3656. DtrtCertType string `json:"dtrt_cert_type"`
  3657. HospLv string `json:"hosp_lv"`
  3658. } `json:"setlinfo"`
  3659. } `json:"output"`
  3660. RefmsgTime string `json:"refmsg_time"`
  3661. RespondTime string `json:"respond_time"`
  3662. Signtype interface{} `json:"signtype"`
  3663. WarnMsg interface{} `json:"warn_msg"`
  3664. }
  3665. type ResultEleven10265 struct {
  3666. Cainfo string `json:"cainfo"`
  3667. ErrMsg string `json:"err_msg"`
  3668. InfRefmsgid string `json:"inf_refmsgid"`
  3669. Infcode string `json:"infcode"`
  3670. Output struct {
  3671. Setlinfo struct {
  3672. SetlTime string `json:"setl_time"`
  3673. CvlservPay float64 `json:"cvlserv_pay"`
  3674. Year string `json:"year"`
  3675. MedType string `json:"med_type"`
  3676. PsnPay float64 `json:"psn_pay"`
  3677. OpterID string `json:"opter_id"`
  3678. Begndate string `json:"begndate"`
  3679. FlxempeFlag string `json:"flxempe_flag"`
  3680. HifmiPay float64 `json:"hifmi_pay"`
  3681. PsnNo string `json:"psn_no"`
  3682. ActPayDedc float64 `json:"act_pay_dedc"`
  3683. MedinsSetlID interface{} `json:"medins_setl_id"`
  3684. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3685. ClrWay string `json:"clr_way"`
  3686. OthPay float64 `json:"oth_pay"`
  3687. Gend string `json:"gend"`
  3688. MdtrtID string `json:"mdtrt_id"`
  3689. AcctPay float64 `json:"acct_pay"`
  3690. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3691. Insutype string `json:"insutype"`
  3692. Invono interface{} `json:"invono"`
  3693. Enddate string `json:"enddate"`
  3694. CashPayamt float64 `json:"cash_payamt"`
  3695. PsnType string `json:"psn_type"`
  3696. FixmedinsName string `json:"fixmedins_name"`
  3697. HifpPay float64 `json:"hifp_pay"`
  3698. NewFlag interface{} `json:"new_flag"`
  3699. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3700. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3701. PayLoc string `json:"pay_loc"`
  3702. ClrType string `json:"clr_type"`
  3703. RefdSetlFlag string `json:"refd_setl_flag"`
  3704. CvlservFlag string `json:"cvlserv_flag"`
  3705. EmpName string `json:"emp_name"`
  3706. Brdy string `json:"brdy"`
  3707. Naty string `json:"naty"`
  3708. Certno string `json:"certno"`
  3709. DiseCode string `json:"dise_code"`
  3710. FixmedinsCode string `json:"fixmedins_code"`
  3711. DedcHospLv string `json:"dedc_hosp_lv"`
  3712. OpterName string `json:"opter_name"`
  3713. Balc float64 `json:"balc"`
  3714. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3715. PsnCertType string `json:"psn_cert_type"`
  3716. HifobPay float64 `json:"hifob_pay"`
  3717. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3718. HifesPay float64 `json:"hifes_pay"`
  3719. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3720. OptTime string `json:"opt_time"`
  3721. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3722. SetlID string `json:"setl_id"`
  3723. MafPay float64 `json:"maf_pay"`
  3724. PsnName string `json:"psn_name"`
  3725. InsuOptins interface{} `json:"insu_optins"`
  3726. PrefFundPay interface{} `json:"pref_fund_pay"`
  3727. ClrOptins string `json:"clr_optins"`
  3728. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3729. DiseName string `json:"dise_name"`
  3730. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3731. Age float64 `json:"age"`
  3732. DtrtCertType string `json:"dtrt_cert_type"`
  3733. HospLv string `json:"hosp_lv"`
  3734. } `json:"setlinfo"`
  3735. } `json:"output"`
  3736. RefmsgTime string `json:"refmsg_time"`
  3737. RespondTime string `json:"respond_time"`
  3738. Signtype interface{} `json:"signtype"`
  3739. WarnMsg interface{} `json:"warn_msg"`
  3740. }
  3741. type ResultTwelve struct {
  3742. Cainfo string `json:"cainfo"`
  3743. ErrMsg string `json:"err_msg"`
  3744. InfRefmsgid string `json:"inf_refmsgid"`
  3745. Infcode int64 `json:"infcode"`
  3746. Output struct {
  3747. MdtrtId string `json:"mdtrt_id"`
  3748. ChrgBchno string `json:"chrg_bchno"`
  3749. PsnNo string `json:"psn_no"`
  3750. } `json:"output"`
  3751. RefmsgTime string `json:"refmsg_time"`
  3752. RespondTime string `json:"respond_time"`
  3753. Signtype interface{} `json:"signtype"`
  3754. WarnMsg interface{} `json:"warn_msg"`
  3755. }
  3756. type ResultThirteen struct {
  3757. ErrMsg string `json:"err_msg"`
  3758. InfRefmsgid string `json:"inf_refmsgid"`
  3759. Infcode int64 `json:"infcode"`
  3760. Output struct {
  3761. Result struct {
  3762. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3763. } `json:"result"`
  3764. } `json:"output"`
  3765. RefmsgTime string `json:"refmsg_time"`
  3766. RespondTime string `json:"respond_time"`
  3767. Signtype interface{} `json:"signtype"`
  3768. WarnInfo interface{} `json:"warn_info"`
  3769. }
  3770. type ResultThirteen10265 struct {
  3771. ErrMsg string `json:"err_msg"`
  3772. InfRefmsgid string `json:"inf_refmsgid"`
  3773. Infcode string `json:"infcode"`
  3774. Output struct {
  3775. Result struct {
  3776. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3777. } `json:"result"`
  3778. } `json:"output"`
  3779. RefmsgTime string `json:"refmsg_time"`
  3780. RespondTime string `json:"respond_time"`
  3781. Signtype interface{} `json:"signtype"`
  3782. WarnInfo interface{} `json:"warn_info"`
  3783. }
  3784. type ResultFourteen struct {
  3785. ErrMsg string `json:"err_msg"`
  3786. InfRefmsgid string `json:"inf_refmsgid"`
  3787. Infcode int64 `json:"infcode"`
  3788. Output struct {
  3789. } `json:"output"`
  3790. RefmsgTime string `json:"refmsg_time"`
  3791. RespondTime string `json:"respond_time"`
  3792. Signtype interface{} `json:"signtype"`
  3793. WarnInfo interface{} `json:"warn_info"`
  3794. }
  3795. type ResultFourteen10265 struct {
  3796. ErrMsg string `json:"err_msg"`
  3797. InfRefmsgid string `json:"inf_refmsgid"`
  3798. Infcode string `json:"infcode"`
  3799. Output struct {
  3800. } `json:"output"`
  3801. RefmsgTime string `json:"refmsg_time"`
  3802. RespondTime string `json:"respond_time"`
  3803. Signtype interface{} `json:"signtype"`
  3804. WarnInfo interface{} `json:"warn_info"`
  3805. }
  3806. type ResultSixteen struct {
  3807. Cainfo string `json:"cainfo"`
  3808. ErrMsg string `json:"err_msg"`
  3809. InfRefmsgid string `json:"inf_refmsgid"`
  3810. Infcode int64 `json:"infcode"`
  3811. Output struct {
  3812. Setldetail []interface{} `json:"setldetail"`
  3813. Setlinfo struct {
  3814. MdtrtID string `json:"mdtrt_id"`
  3815. SetlID string `json:"setl_id"`
  3816. ClrOptins string `json:"clr_optins"`
  3817. SetlTime string `json:"setl_time"`
  3818. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3819. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3820. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3821. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3822. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3823. ActPayDedc float64 `json:"act_pay_dedc"`
  3824. HifpPay float64 `json:"hifp_pay"`
  3825. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3826. Lfpay float64 `json:"selfpay"`
  3827. CvlservPay float64 `json:"cvlserv_pay"`
  3828. HifesPay float64 `json:"hifes_pay"`
  3829. HifmiPay float64 `json:"hifmi_pay"`
  3830. HifobPay float64 `json:"hifob_pay"`
  3831. MafPay float64 `json:"maf_pay"`
  3832. OthPay float64 `json:"oth_pay"`
  3833. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3834. PsnPartAmt float64 `json:"psn_part_amt"`
  3835. AcctPay float64 `json:"acct_pay"`
  3836. Balc float64 `json:"balc"`
  3837. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3838. HospPartAmt float64 `json:"hosp_part_amt"`
  3839. MedinsSetlID string `json:"medins_setl_id"`
  3840. PdnCashPay string `json:"pdn_cash_pay"`
  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 ResultSixteen10265 struct {
  3849. Cainfo string `json:"cainfo"`
  3850. ErrMsg string `json:"err_msg"`
  3851. InfRefmsgid string `json:"inf_refmsgid"`
  3852. Infcode string `json:"infcode"`
  3853. Output struct {
  3854. Setldetail []interface{} `json:"setldetail"`
  3855. Setlinfo struct {
  3856. MdtrtID string `json:"mdtrt_id"`
  3857. SetlID string `json:"setl_id"`
  3858. ClrOptins string `json:"clr_optins"`
  3859. SetlTime string `json:"setl_time"`
  3860. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3861. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3862. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3863. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3864. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3865. ActPayDedc float64 `json:"act_pay_dedc"`
  3866. HifpPay float64 `json:"hifp_pay"`
  3867. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3868. Lfpay float64 `json:"selfpay"`
  3869. CvlservPay float64 `json:"cvlserv_pay"`
  3870. HifesPay float64 `json:"hifes_pay"`
  3871. HifmiPay float64 `json:"hifmi_pay"`
  3872. HifobPay float64 `json:"hifob_pay"`
  3873. MafPay float64 `json:"maf_pay"`
  3874. OthPay float64 `json:"oth_pay"`
  3875. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3876. PsnPartAmt float64 `json:"psn_part_amt"`
  3877. AcctPay float64 `json:"acct_pay"`
  3878. Balc float64 `json:"balc"`
  3879. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3880. HospPartAmt float64 `json:"hosp_part_amt"`
  3881. MedinsSetlID string `json:"medins_setl_id"`
  3882. PdnCashPay string `json:"pdn_cash_pay"`
  3883. } `json:"setlinfo"`
  3884. } `json:"output"`
  3885. RefmsgTime string `json:"refmsg_time"`
  3886. RespondTime string `json:"respond_time"`
  3887. Signtype interface{} `json:"signtype"`
  3888. WarnMsg interface{} `json:"warn_msg"`
  3889. }
  3890. type ResultSeventeen struct {
  3891. ErrMsg string `json:"err_msg"`
  3892. InfRefmsgid string `json:"inf_refmsgid"`
  3893. Infcode int64 `json:"infcode"`
  3894. Output struct {
  3895. SetlListId string `json:"setl_list_id"`
  3896. } `json:"output"`
  3897. RefmsgTime string `json:"refmsg_time"`
  3898. RespondTime string `json:"respond_time"`
  3899. Signtype string `json:"signtype"`
  3900. WarnInfo string `json:"warn_info"`
  3901. }
  3902. type Result90991 struct {
  3903. ErrMsg string `json:"err_msg"`
  3904. InfRefmsgid string `json:"inf_refmsgid"`
  3905. Infcode int64 `json:"infcode"`
  3906. Output struct {
  3907. Result struct {
  3908. PsnNo string `json:"psn_no"`
  3909. CardStat string `json:"card_stat"`
  3910. Certno string `json:"certno"`
  3911. PsnName string `json:"psn_name"`
  3912. CheckStat string `json:"check_stat"`
  3913. } `json:"result"`
  3914. } `json:"output"`
  3915. RefmsgTime string `json:"refmsg_time"`
  3916. RespondTime string `json:"respond_time"`
  3917. Signtype interface{} `json:"signtype"`
  3918. WarnInfo interface{} `json:"warn_info"`
  3919. }
  3920. type Result90100 struct {
  3921. ErrMsg string `json:"err_msg"`
  3922. InfRefmsgid string `json:"inf_refmsgid"`
  3923. Infcode int64 `json:"infcode"`
  3924. Output struct {
  3925. PoolareaNo string `json:"poolarea_no"`
  3926. PoolareaNoName string `json:"poolarea_no_name"`
  3927. Insutype string `json:"insutype"`
  3928. InsutypeName string `json:"insutype_name"`
  3929. ClctType string `json:"clct_type"`
  3930. ClctTypeName string `json:"clct_type_name"`
  3931. ClctFlag string `json:"clct_flag"`
  3932. ClctFlagName string `json:"clct_flag_name"`
  3933. AccrymBegn string `json:"accrym_begn"`
  3934. AccrymEnd string `json:"accrym_end"`
  3935. ClctTime string `json:"clct_time"`
  3936. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3937. } `json:"output"`
  3938. RefmsgTime string `json:"refmsg_time"`
  3939. RespondTime string `json:"respond_time"`
  3940. Signtype interface{} `json:"signtype"`
  3941. WarnInfo interface{} `json:"warn_info"`
  3942. }
  3943. type Custom struct {
  3944. DetItemFeeSumamt string
  3945. Cut string
  3946. FeedetlSn string
  3947. Price string
  3948. MedListCodg string
  3949. Type int64
  3950. AdviceId int64
  3951. ProjectId int64
  3952. ItemId int64
  3953. }
  3954. type Result5301 struct {
  3955. ErrMsg string `json:"err_msg"`
  3956. InfRefmsgid string `json:"inf_refmsgid"`
  3957. Infcode int64 `json:"infcode"`
  3958. Output struct {
  3959. Result []struct {
  3960. OpspDiseCode string `json:"opsp_dise_code"`
  3961. OpspDiseName string `json:"opsp_dise_name"`
  3962. Begndate string `json:"begndate"`
  3963. Enddate string `json:"enddate"`
  3964. } `json:"feedetail"`
  3965. } `json:"output"`
  3966. RefmsgTime string `json:"refmsg_time"`
  3967. RespondTime string `json:"respond_time"`
  3968. Signtype interface{} `json:"signtype"`
  3969. WarnInfo interface{} `json:"warn_info"`
  3970. }
  3971. type Result5301For10265 struct {
  3972. ErrMsg string `json:"err_msg"`
  3973. InfRefmsgid string `json:"inf_refmsgid"`
  3974. Infcode string `json:"infcode"`
  3975. Output struct {
  3976. Result []struct {
  3977. OpspDiseCode string `json:"opsp_dise_code"`
  3978. OpspDiseName string `json:"opsp_dise_name"`
  3979. Begndate string `json:"begndate"`
  3980. Enddate string `json:"enddate"`
  3981. } `json:"feedetail"`
  3982. } `json:"output"`
  3983. RefmsgTime string `json:"refmsg_time"`
  3984. RespondTime string `json:"respond_time"`
  3985. Signtype interface{} `json:"signtype"`
  3986. WarnInfo interface{} `json:"warn_info"`
  3987. }
  3988. //获取个人信息----挂号-----上传就诊信息
  3989. func (c *HisApiController) GetRegisterInfo() {
  3990. id, _ := c.GetInt64("id")
  3991. record_time := c.GetString("record_time")
  3992. settlementValue, _ := c.GetInt64("settlement_value")
  3993. medical_insurance_card := c.GetString("medical_insurance_card")
  3994. name := c.GetString("name")
  3995. id_card_type, _ := c.GetInt64("id_card_type")
  3996. certificates, _ := c.GetInt64("certificates")
  3997. medical_care, _ := c.GetInt64("medical_care")
  3998. birthday := c.GetString("birthday")
  3999. id_card := c.GetString("id_card")
  4000. register_type, _ := c.GetInt64("register")
  4001. doctor, _ := c.GetInt64("doctor")
  4002. department, _ := c.GetInt64("department")
  4003. gender, _ := c.GetInt64("sex")
  4004. registration_fee, _ := c.GetFloat("registration_fee")
  4005. medical_expenses, _ := c.GetFloat("medical_expenses")
  4006. social_type, _ := c.GetInt64("social_type")
  4007. med_type := c.GetString("social_type")
  4008. admin_user_id, _ := c.GetInt64("admin_user_id")
  4009. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4010. timeLayout := "2006-01-02"
  4011. loc, _ := time.LoadLocation("Local")
  4012. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4013. birthUnix := birthdays.Unix()
  4014. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4015. if err != nil {
  4016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4017. return
  4018. }
  4019. recordDateTime := theTime.Unix()
  4020. adminInfo := c.GetAdminUserInfo()
  4021. var patient service.Patients
  4022. if id == 0 {
  4023. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4024. } else {
  4025. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4026. }
  4027. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4028. if patientPrescription.ID == 0 {
  4029. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4030. }
  4031. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4032. if patient.ID == 0 {
  4033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4034. return
  4035. }
  4036. if len(patient.IdCardNo) == 0 {
  4037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4038. return
  4039. }
  4040. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4041. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4042. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4043. //就诊结算未完成,不能进行二次挂号
  4044. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4045. if len(his) >= 1 {
  4046. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4047. if len(his) >= 1 && order.ID == 0 {
  4048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4049. return
  4050. }
  4051. }
  4052. //var register_log string
  4053. if config.IsOpen == 1 {
  4054. var res ResultTwo
  4055. var res10265 ResultTwo10265
  4056. var PsnNo string
  4057. var PsnCertType string
  4058. var Certno string
  4059. var PsnName string
  4060. var Gend string
  4061. var Naty string
  4062. var Brdy string
  4063. var Age float64
  4064. var infoStr string
  4065. var idetinfoStr string
  4066. var infocode int64
  4067. var verify_number string
  4068. fmt.Println(verify_number)
  4069. if miConfig.MdtrtareaAdmvs == "421300" {
  4070. psn_info, _ := service.GetPsnByPatientId(id)
  4071. PsnNo = psn_info.PsnNo
  4072. PsnCertType = psn_info.PsnCertType
  4073. Certno = psn_info.Certno
  4074. PsnName = psn_info.PsnName
  4075. Gend = psn_info.Gend
  4076. Naty = psn_info.Naty
  4077. Brdy = psn_info.Brdy
  4078. Age = psn_info.Age
  4079. infoStr = psn_info.Insuinfo
  4080. idetinfoStr = psn_info.Idetinfo
  4081. infocode = 0
  4082. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4083. psn_info, _ := service.GetPsnByPatientId(id)
  4084. PsnNo = psn_info.PsnNo
  4085. PsnCertType = psn_info.PsnCertType
  4086. Certno = psn_info.Certno
  4087. PsnName = psn_info.PsnName
  4088. Gend = psn_info.Gend
  4089. Naty = psn_info.Naty
  4090. Brdy = psn_info.Brdy
  4091. Age = psn_info.Age
  4092. infoStr = psn_info.Insuinfo
  4093. idetinfoStr = psn_info.Idetinfo
  4094. infocode = 0
  4095. verify_number = psn_info.VerifyNumber
  4096. } else {
  4097. var result string
  4098. var requestLog string
  4099. if miConfig.UserOrgId == 10138 {
  4100. 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)
  4101. } else {
  4102. 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)
  4103. }
  4104. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4105. if miConfig.Code == "H15049901371" {
  4106. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4107. utils.ErrorLog("解析失败:%v", err)
  4108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4109. return
  4110. }
  4111. res.ErrMsg = res10265.ErrMsg
  4112. res.Output = res10265.Output
  4113. res.InfRefmsgid = res10265.InfRefmsgid
  4114. } else {
  4115. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4116. utils.ErrorLog("解析失败:%v", err)
  4117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4118. return
  4119. }
  4120. }
  4121. PsnNo = res.Output.Baseinfo.PsnNo
  4122. PsnCertType = res.Output.Baseinfo.PsnCertType
  4123. Certno = res.Output.Baseinfo.Certno
  4124. PsnName = res.Output.Baseinfo.PsnName
  4125. Gend = res.Output.Baseinfo.Gend
  4126. Naty = res.Output.Baseinfo.Naty
  4127. Brdy = res.Output.Baseinfo.Brdy
  4128. Age = res.Output.Baseinfo.Age
  4129. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4130. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4131. infoStr = string(Iinfos)
  4132. idetinfoStr = string(Idetinfos)
  4133. if miConfig.Code == "H15049901371" {
  4134. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4135. } else {
  4136. infocode = res.Infcode
  4137. }
  4138. }
  4139. if infocode == 0 {
  4140. his := models.VMHisPatient{
  4141. Name: name,
  4142. Gender: gender,
  4143. Birthday: birthUnix,
  4144. MedicalTreatmentType: medical_care,
  4145. IdType: certificates,
  4146. IdCardNo: id_card,
  4147. BalanceAccountsType: settlementValue,
  4148. SocialType: social_type,
  4149. MedicalInsuranceNumber: medical_insurance_card,
  4150. RegisterType: register_type,
  4151. RegisterCost: registration_fee,
  4152. TreatmentCost: medical_expenses,
  4153. Status: 1,
  4154. Ctime: time.Now().Unix(),
  4155. Mtime: time.Now().Unix(),
  4156. PsnNo: PsnNo,
  4157. PsnCertType: PsnCertType,
  4158. Certno: Certno,
  4159. PsnName: PsnName,
  4160. Gend: Gend,
  4161. Naty: Naty,
  4162. Brdy: Brdy,
  4163. Age: Age,
  4164. Iinfo: infoStr,
  4165. Idetinfo: idetinfoStr,
  4166. PatientId: patient.ID,
  4167. RecordDate: theTime.Unix(),
  4168. UserOrgId: adminInfo.CurrentOrgId,
  4169. AdminUserId: admin_user_id,
  4170. IsReturn: 1,
  4171. IdCardType: id_card_type,
  4172. Doctor: doctor,
  4173. Departments: department,
  4174. }
  4175. timestamp := time.Now().Unix()
  4176. tempTime := time.Unix(timestamp, 0)
  4177. timeFormat := tempTime.Format("20060102150405")
  4178. chrgBchno := rand.Intn(100000) + 10000
  4179. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4180. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4181. department, _ := service.GetDepartMentDetail(department)
  4182. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4183. IdCardNo := ""
  4184. if id_card_type == 1 {
  4185. // IdCardNo = medical_insurance_card
  4186. IdCardNo = patient.IdCardNo
  4187. } else {
  4188. IdCardNo = patient.IdCardNo
  4189. }
  4190. var rf []*ResultFive
  4191. json.Unmarshal([]byte(his.Iinfo), &rf)
  4192. var insutypes []*ResultFive
  4193. var insutype string
  4194. var insuplc_admdvs_temp string
  4195. var is390 int = 0
  4196. var is310 int = 0
  4197. for _, item := range rf {
  4198. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4199. insutypes = append(insutypes, item)
  4200. }
  4201. }
  4202. if len(insutypes) == 1 {
  4203. insutype = insutypes[0].Insutype
  4204. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4205. } else {
  4206. for _, i := range insutypes {
  4207. if i.Insutype == "390" {
  4208. is390 = 1
  4209. }
  4210. if i.Insutype == "310" {
  4211. is310 = 1
  4212. }
  4213. }
  4214. }
  4215. if is390 == 1 {
  4216. insutype = "390"
  4217. }
  4218. if is310 == 1 {
  4219. insutype = "310"
  4220. }
  4221. if len(insutypes) == 0 {
  4222. insutype = "310"
  4223. }
  4224. if len(insutypes) == 2 {
  4225. insutype = med_type
  4226. }
  4227. if len(med_type) > 0 {
  4228. insutype = med_type
  4229. }
  4230. //for _, item := range rf {
  4231. // if item.Insutype == insutype {
  4232. // insuplc_admdvs = item.InsuplcAdmdvs
  4233. // }
  4234. //}
  4235. var infocode int64
  4236. var resThree ResultThree
  4237. var resThree10265 ResultThree10265
  4238. if len(insuplc_admdvs) == 0 {
  4239. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4240. } else {
  4241. insuplc_admdvs_temp = insuplc_admdvs
  4242. }
  4243. if miConfig.MdtrtareaAdmvs == "421300" {
  4244. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4245. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4246. "&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
  4247. resp, requestErr := http.Get(api)
  4248. if requestErr != nil {
  4249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4250. return
  4251. }
  4252. body, ioErr := ioutil.ReadAll(resp.Body)
  4253. if ioErr != nil {
  4254. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4256. return
  4257. }
  4258. var respJSON map[string]interface{}
  4259. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4262. return
  4263. }
  4264. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4265. result, _ := json.Marshal(respJSON)
  4266. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4267. utils.ErrorLog("解析失败:%v", err)
  4268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4269. return
  4270. }
  4271. infocode = resThree.Infcode
  4272. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4273. psn_info, _ := service.GetPsnByPatientId(id)
  4274. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4275. var cert_no string
  4276. if id_card_type == 3 {
  4277. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4278. cert_no = IdCardNo
  4279. } else {
  4280. bas := strings.Split(psn_info.CardInfo, "|")
  4281. cert_no = bas[2]
  4282. }
  4283. var api string
  4284. if miConfig.MdtrtareaAdmvs == "320921" {
  4285. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4286. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4287. "&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
  4288. } else {
  4289. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4290. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4291. "&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
  4292. }
  4293. resp, requestErr := http.Get(api)
  4294. if requestErr != nil {
  4295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4296. return
  4297. }
  4298. body, ioErr := ioutil.ReadAll(resp.Body)
  4299. if ioErr != nil {
  4300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4302. return
  4303. }
  4304. var respJSON map[string]interface{}
  4305. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4308. return
  4309. }
  4310. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4311. result, _ := json.Marshal(respJSON)
  4312. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4313. utils.ErrorLog("解析失败:%v", err)
  4314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4315. return
  4316. }
  4317. resThree.ErrMsg = resThree10265.ErrMsg
  4318. resThree.Output = resThree10265.Output
  4319. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4320. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4321. } else {
  4322. 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)
  4323. saveLog(result, requestLog, "2201A", "挂号")
  4324. if miConfig.Code == "H15049901371" {
  4325. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4326. utils.ErrorLog("解析失败:%v", err)
  4327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4328. return
  4329. }
  4330. resThree.ErrMsg = resThree10265.ErrMsg
  4331. resThree.Output = resThree10265.Output
  4332. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4333. } else {
  4334. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4335. utils.ErrorLog("解析失败:%v", err)
  4336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4337. return
  4338. }
  4339. }
  4340. if miConfig.Code == "H15049901371" {
  4341. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4342. } else {
  4343. infocode = resThree.Infcode
  4344. }
  4345. }
  4346. if infocode != 0 {
  4347. adminUser := c.GetAdminUserInfo()
  4348. errlog := &models.HisOrderError{
  4349. UserOrgId: adminUser.CurrentOrgId,
  4350. Ctime: time.Now().Unix(),
  4351. Mtime: time.Now().Unix(),
  4352. ErrMsg: resThree.ErrMsg,
  4353. Status: 1,
  4354. PatientId: id,
  4355. RecordTime: recordDateTime,
  4356. Stage: 2,
  4357. }
  4358. service.CreateErrMsgLog(errlog)
  4359. c.ServeSuccessJSON(map[string]interface{}{
  4360. "failed_code": -10,
  4361. "msg": resThree.ErrMsg,
  4362. })
  4363. return
  4364. }
  4365. his.Number = resThree.Output.Data.MdtrtID
  4366. his.PsnNo = resThree.Output.Data.PsnNo
  4367. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4368. his.IdCardNo = patient.IdCardNo
  4369. his.PhoneNumber = patient.Phone
  4370. his.UserOrgId = adminInfo.CurrentOrgId
  4371. his.Insutype = insutype
  4372. his.Ctime = time.Now().Unix()
  4373. his.Mtime = time.Now().Unix()
  4374. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4375. his.Status = 1
  4376. service.UpdateHisPatientStatus(&his)
  4377. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4378. c.ServeSuccessJSON(map[string]interface{}{
  4379. "his_info": his,
  4380. })
  4381. } else {
  4382. adminUser := c.GetAdminUserInfo()
  4383. errlog := &models.HisOrderError{
  4384. UserOrgId: adminUser.CurrentOrgId,
  4385. Ctime: time.Now().Unix(),
  4386. Mtime: time.Now().Unix(),
  4387. ErrMsg: res.ErrMsg,
  4388. Status: 1,
  4389. PatientId: id,
  4390. RecordTime: recordDateTime,
  4391. Stage: 1,
  4392. }
  4393. service.CreateErrMsgLog(errlog)
  4394. c.ServeSuccessJSON(map[string]interface{}{
  4395. "failed_code": -10,
  4396. "msg": res.ErrMsg,
  4397. })
  4398. return
  4399. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4400. }
  4401. }
  4402. }
  4403. //上传明细----预结算----确认订单
  4404. func (c *HisApiController) GetUploadInfo() {
  4405. id, _ := c.GetInt64("id")
  4406. record_time := c.GetString("record_time")
  4407. his_patient_id, _ := c.GetInt64("his_patient_id")
  4408. order_id, _ := c.GetInt64("order_id")
  4409. pay_way, _ := c.GetInt64("pay_way")
  4410. pay_price, _ := c.GetFloat("pay_price")
  4411. pay_card_no := c.GetString("pay_card_no")
  4412. discount_price, _ := c.GetFloat("discount_price")
  4413. preferential_price, _ := c.GetFloat("preferential_price")
  4414. reality_price, _ := c.GetFloat("reality_price")
  4415. found_price, _ := c.GetFloat("found_price")
  4416. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4417. private_price, _ := c.GetFloat("private_price")
  4418. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4419. admin_user_id, _ := c.GetInt64("admin_user_id")
  4420. fapiao_code := c.GetString("fapiao_code")
  4421. fapiao_number := c.GetString("fapiao_number")
  4422. diagnosis_id := c.GetString("diagnosis")
  4423. sick_type, _ := c.GetInt64("sick_type")
  4424. reg_type, _ := c.GetInt64("p_type")
  4425. begin_time := c.GetString("begin_time")
  4426. id_str := c.GetString("ids")
  4427. ids_arr := strings.Split(id_str, ",")
  4428. timeLayout := "2006-01-02"
  4429. loc, _ := time.LoadLocation("Local")
  4430. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4431. if err != nil {
  4432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4433. return
  4434. }
  4435. recordDateTime := theTime.Unix()
  4436. adminUser := c.GetAdminUserInfo()
  4437. var tempOrder models.HisOrder
  4438. tempOrder, _ = service.GetHisOrderByID(order_id)
  4439. var prescriptions []*models.HisPrescription
  4440. var start_time int64
  4441. var end_time int64
  4442. //if adminUser.CurrentOrgId == 10106{
  4443. // if len(fapiao_code) == 0{
  4444. // fapiao_code = "144072080589"
  4445. // }
  4446. // if len(fapiao_number) == 0{
  4447. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4448. // if order.ID == 0{
  4449. // fapiao_number = "00001520"
  4450. // }else{
  4451. // //fapiao_code = "00001520"
  4452. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4453. // var zero string
  4454. // if fpNumber >= 1000{
  4455. // zero = "0000" + strconv.Itoa(fpNumber)
  4456. // }else if fpNumber >= 10000{
  4457. // zero = "000" + strconv.Itoa(fpNumber)
  4458. // } else if fpNumber >= 100000{
  4459. // zero = "00" + strconv.Itoa(fpNumber)
  4460. // } else if fpNumber >= 1000000{
  4461. // zero = "0" + strconv.Itoa(fpNumber)
  4462. // }else {
  4463. // zero = strconv.Itoa(fpNumber)
  4464. // }
  4465. // fapiao_number = zero
  4466. // }
  4467. // }
  4468. //}
  4469. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4470. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4471. var patientPrescription models.HisPrescriptionInfo
  4472. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4473. if patientPrescription.ID == 0 {
  4474. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4475. }
  4476. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4477. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4478. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4479. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4480. var config []*models.HisXtDiagnoseConfig
  4481. for _, item := range diagnosis_ids {
  4482. id, _ := strconv.ParseInt(item, 10, 64)
  4483. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4484. config = append(config, &diagnosisConfig)
  4485. }
  4486. sickConfig, _ := service.FindSickById(sick_type)
  4487. //if tempOrder.ID == 0 {
  4488. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4489. //}
  4490. if tempOrder.ID == 0 {
  4491. var result string
  4492. var requestLog string
  4493. var res2 ResultSix
  4494. var ressix10265 ResultSix10265
  4495. if miConfig.MdtrtareaAdmvs == "421300" {
  4496. data := make(map[string]interface{})
  4497. client := &http.Client{}
  4498. data["psn_no"] = his.PsnNo
  4499. data["mdtrt_id"] = his.Number
  4500. data["doctor"] = roles.UserName
  4501. data["department"] = department.Name
  4502. data["org_name"] = miConfig.OrgName
  4503. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4504. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4505. data["fixmedins_code"] = miConfig.Code
  4506. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4507. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4508. data["secret_key"] = miConfig.SecretKey
  4509. data["sick_code"] = sickConfig.CountryCode
  4510. data["sick_name"] = sickConfig.ClassName
  4511. data["dept"] = strconv.FormatInt(department.ID, 10)
  4512. data["config"] = config
  4513. data["begin_time"] = begin_time
  4514. bytesData, _ := json.Marshal(data)
  4515. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4516. resp, _ := client.Do(req)
  4517. defer resp.Body.Close()
  4518. body, ioErr := ioutil.ReadAll(resp.Body)
  4519. if ioErr != nil {
  4520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4522. return
  4523. }
  4524. var respJSON map[string]interface{}
  4525. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4528. return
  4529. }
  4530. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4531. userJSONBytes, _ := json.Marshal(respJSON)
  4532. fmt.Println("log")
  4533. fmt.Println(string(userJSONBytes))
  4534. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4535. utils.ErrorLog("解析失败:%v", err)
  4536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4537. return
  4538. }
  4539. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4540. //江苏地区国家医保医疗类别
  4541. //职工透析:医疗类别选特殊情况门诊9933
  4542. //居民血透门慢: 医疗类别选门诊慢病1402
  4543. //var med_type string
  4544. //if his.Insutype == "310" {
  4545. // if reg_type == 14 {
  4546. // med_type = "9933"
  4547. // } else if reg_type == 11 {
  4548. // med_type = "11"
  4549. //
  4550. // }
  4551. //} else if his.Insutype == "390" {
  4552. // if reg_type == 14 {
  4553. // med_type = "1402"
  4554. // } else if reg_type == 11 {
  4555. // med_type = "11"
  4556. // }
  4557. //}
  4558. data := make(map[string]interface{})
  4559. client := &http.Client{}
  4560. data["psn_no"] = his.PsnNo
  4561. data["mdtrt_id"] = his.Number
  4562. data["doctor"] = roles.UserName
  4563. data["department"] = department.Name
  4564. data["org_name"] = miConfig.OrgName
  4565. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4566. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4567. data["fixmedins_code"] = miConfig.Code
  4568. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4569. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4570. data["secret_key"] = miConfig.SecretKey
  4571. data["sick_code"] = sickConfig.CountryCode
  4572. data["sick_name"] = sickConfig.ClassName
  4573. data["url"] = miConfig.Url
  4574. data["ak"] = miConfig.AccessKey
  4575. data["begin_time"] = begin_time
  4576. data["cainfo"] = miConfig.Cainfo
  4577. data["dept"] = strconv.FormatInt(department.ID, 10)
  4578. data["config"] = config
  4579. bytesData, _ := json.Marshal(data)
  4580. var req *http.Request
  4581. if miConfig.MdtrtareaAdmvs == "320921" {
  4582. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4583. //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 +
  4584. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4585. } else {
  4586. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4587. }
  4588. resp, _ := client.Do(req)
  4589. defer resp.Body.Close()
  4590. body, ioErr := ioutil.ReadAll(resp.Body)
  4591. if ioErr != nil {
  4592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4594. return
  4595. }
  4596. var respJSON map[string]interface{}
  4597. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4600. return
  4601. }
  4602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4603. userJSONBytes, _ := json.Marshal(respJSON)
  4604. fmt.Println("log")
  4605. fmt.Println(string(userJSONBytes))
  4606. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4607. utils.ErrorLog("解析失败:%v", err)
  4608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4609. return
  4610. }
  4611. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4612. res2.Output = ressix10265.Output
  4613. res2.ErrMsg = ressix10265.ErrMsg
  4614. res2.Cainfo = ressix10265.Cainfo
  4615. res2.WarnMsg = ressix10265.WarnMsg
  4616. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4617. res2.Infcode = infocode
  4618. } else {
  4619. if miConfig.MdtrtareaAdmvs == "440781" { //
  4620. 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)
  4621. } else {
  4622. if miConfig.Code == "H15049901371" {
  4623. //赤峰地区国家医保医疗类别
  4624. //职工透析:医疗类别选特殊情况门诊990502
  4625. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4626. var med_type string
  4627. if his.Insutype == "390" {
  4628. if reg_type == 14 {
  4629. med_type = "9933"
  4630. } else if reg_type == 11 {
  4631. med_type = "11"
  4632. }
  4633. } else if his.Insutype == "310" {
  4634. if reg_type == 14 {
  4635. med_type = "990502"
  4636. } else if reg_type == 11 {
  4637. med_type = "11"
  4638. }
  4639. }
  4640. 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)
  4641. } else {
  4642. 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)
  4643. }
  4644. }
  4645. saveLog(result, requestLog, "2203", "上传就诊信息")
  4646. var respJSON2 map[string]interface{}
  4647. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4650. return
  4651. }
  4652. userJSONBytes2, _ := json.Marshal(respJSON2)
  4653. if miConfig.Code == "H15049901371" {
  4654. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4655. utils.ErrorLog("解析失败:%v", err)
  4656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4657. return
  4658. }
  4659. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4660. res2.Output = ressix10265.Output
  4661. res2.ErrMsg = ressix10265.ErrMsg
  4662. res2.Cainfo = ressix10265.Cainfo
  4663. res2.WarnMsg = ressix10265.WarnMsg
  4664. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4665. res2.Infcode = infocode
  4666. } else {
  4667. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4668. utils.ErrorLog("解析失败:%v", err)
  4669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4670. return
  4671. }
  4672. }
  4673. }
  4674. if res2.Infcode != 0 {
  4675. adminUser := c.GetAdminUserInfo()
  4676. errlog := &models.HisOrderError{
  4677. UserOrgId: adminUser.CurrentOrgId,
  4678. Ctime: time.Now().Unix(),
  4679. Mtime: time.Now().Unix(),
  4680. ErrMsg: res2.ErrMsg,
  4681. Status: 1,
  4682. PatientId: id,
  4683. RecordTime: recordDateTime,
  4684. Stage: 3,
  4685. }
  4686. service.CreateErrMsgLog(errlog)
  4687. c.ServeSuccessJSON(map[string]interface{}{
  4688. "failed_code": -10,
  4689. "msg": res2.ErrMsg,
  4690. })
  4691. return
  4692. } else {
  4693. his.Diagnosis = diagnosis_id
  4694. his.SickType = sickConfig.ID
  4695. //var p_type int64
  4696. //if reg_type == 1111 || reg_type == 1112 {
  4697. // p_type = 11
  4698. //
  4699. //}
  4700. his.PType = fmt.Sprintf("%d", reg_type)
  4701. service.UpdateHisPatientThree(&his)
  4702. data := make(map[string]interface{})
  4703. if settle_accounts_type == 1 { //日结
  4704. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4705. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4706. } else {
  4707. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4708. }
  4709. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4710. data["pre"] = prescriptions
  4711. } else { //月结
  4712. start_time_str := c.GetString("start_time")
  4713. end_time_str := c.GetString("end_time")
  4714. timeLayout := "2006-01-02"
  4715. loc, _ := time.LoadLocation("Local")
  4716. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4717. if err != nil {
  4718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4719. return
  4720. }
  4721. recordStartTime := theStartTime.Unix()
  4722. start_time = recordStartTime
  4723. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4724. if err != nil {
  4725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4726. return
  4727. }
  4728. recordEndTime := theEndTime.Unix()
  4729. end_time = recordEndTime
  4730. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4731. data["pre"] = prescriptions
  4732. }
  4733. timestamp := time.Now().Unix()
  4734. tempTime := time.Unix(timestamp, 0)
  4735. timeFormat := tempTime.Format("20060102150405")
  4736. chrgBchno := rand.Intn(100000) + 10000
  4737. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4738. strconv.FormatInt(his.PatientId, 10)
  4739. client := &http.Client{}
  4740. data["psn_no"] = his.PsnNo
  4741. data["mdtrt_id"] = his.Number
  4742. data["chrg_bchno"] = chrg_bchno
  4743. data["org_name"] = miConfig.OrgName
  4744. data["doctor"] = roles.UserName
  4745. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4746. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4747. data["fixmedins_code"] = miConfig.Code
  4748. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4749. // data["dept_code"] = "15"
  4750. //} else {
  4751. data["dept_code"] = department.Number
  4752. //}
  4753. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4754. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4755. data["secret_key"] = miConfig.SecretKey
  4756. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4757. data["url"] = miConfig.Url
  4758. data["ak"] = miConfig.AccessKey
  4759. data["new_doctor_name"] = patientPrescription.Doctor
  4760. data["diag_code"] = sickConfig.CountryCode
  4761. data["cainfo"] = miConfig.Cainfo
  4762. var ids []int64
  4763. for _, item := range prescriptions {
  4764. ids = append(ids, item.ID)
  4765. }
  4766. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4767. if config.IsOpen == 1 { //对接了医保,走医保流程
  4768. var res ResultFour
  4769. var resFour10265 ResultFour10265
  4770. if miConfig.MdtrtareaAdmvs == "421300" {
  4771. bytesData, _ := json.Marshal(data)
  4772. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4773. resp, _ := client.Do(req)
  4774. defer resp.Body.Close()
  4775. body, ioErr := ioutil.ReadAll(resp.Body)
  4776. if ioErr != nil {
  4777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4779. return
  4780. }
  4781. var respJSON map[string]interface{}
  4782. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4785. return
  4786. }
  4787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4788. userJSONBytes, _ := json.Marshal(respJSON)
  4789. fmt.Println("log")
  4790. fmt.Println(string(userJSONBytes))
  4791. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4792. utils.ErrorLog("解析失败:%v", err)
  4793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4794. return
  4795. }
  4796. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4797. bytesData, _ := json.Marshal(data)
  4798. var req *http.Request
  4799. if miConfig.MdtrtareaAdmvs == "320921" {
  4800. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4801. } else {
  4802. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4803. }
  4804. resp, _ := client.Do(req)
  4805. defer resp.Body.Close()
  4806. body, ioErr := ioutil.ReadAll(resp.Body)
  4807. if ioErr != nil {
  4808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4810. return
  4811. }
  4812. var respJSON map[string]interface{}
  4813. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4816. return
  4817. }
  4818. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4819. userJSONBytes, _ := json.Marshal(respJSON)
  4820. fmt.Println("log")
  4821. fmt.Println(string(userJSONBytes))
  4822. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4823. utils.ErrorLog("解析失败:%v", err)
  4824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4825. return
  4826. }
  4827. res.InfRefmsgid = resFour10265.InfRefmsgid
  4828. res.Output = resFour10265.Output
  4829. res.ErrMsg = resFour10265.ErrMsg
  4830. res.Cainfo = resFour10265.Cainfo
  4831. res.WarnMsg = resFour10265.WarnMsg
  4832. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4833. res.Infcode = infocode
  4834. } else {
  4835. if miConfig.Code == "H15049901371" {
  4836. 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)
  4837. var dat map[string]interface{}
  4838. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4839. fmt.Println(dat)
  4840. } else {
  4841. fmt.Println(err)
  4842. }
  4843. saveLog(result, request_log, "2204", "上传费用明细")
  4844. userJSONBytes, _ := json.Marshal(dat)
  4845. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4846. utils.ErrorLog("解析失败:%v", err)
  4847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4848. return
  4849. }
  4850. res.InfRefmsgid = resFour10265.InfRefmsgid
  4851. res.Output = resFour10265.Output
  4852. res.ErrMsg = resFour10265.ErrMsg
  4853. res.Cainfo = resFour10265.Cainfo
  4854. res.WarnMsg = resFour10265.WarnMsg
  4855. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4856. res.Infcode = infocode
  4857. } else {
  4858. 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)
  4859. var dat map[string]interface{}
  4860. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4861. fmt.Println(dat)
  4862. } else {
  4863. fmt.Println(err)
  4864. }
  4865. saveLog(result, request_log, "2204", "上传费用明细")
  4866. userJSONBytes, _ := json.Marshal(dat)
  4867. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4868. utils.ErrorLog("解析失败:%v", err)
  4869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4870. return
  4871. }
  4872. }
  4873. }
  4874. if res.Infcode == 0 {
  4875. order := &models.HisOrder{
  4876. UserOrgId: adminUser.CurrentOrgId,
  4877. HisPatientId: his.ID,
  4878. PatientId: his.PatientId,
  4879. SettleAccountsDate: recordDateTime,
  4880. MdtrtId: his.Number,
  4881. PsnNo: his.PsnNo,
  4882. MedType: strconv.FormatInt(reg_type, 10),
  4883. Ctime: time.Now().Unix(),
  4884. Mtime: time.Now().Unix(),
  4885. Status: 1,
  4886. Number: chrg_bchno,
  4887. Infcode: res.Infcode,
  4888. WarnMsg: res.WarnMsg,
  4889. Cainfo: res.Cainfo,
  4890. ErrMsg: res.ErrMsg,
  4891. RespondTime: res.RefmsgTime,
  4892. InfRefmsgid: res.InfRefmsgid,
  4893. OrderStatus: 1,
  4894. PayWay: pay_way,
  4895. PayPrice: pay_price,
  4896. PayCardNo: pay_card_no,
  4897. DiscountPrice: discount_price,
  4898. PreferentialPrice: preferential_price,
  4899. RealityPrice: reality_price,
  4900. FoundPrice: found_price,
  4901. MedicalInsurancePrice: medical_insurance_price,
  4902. PrivatePrice: private_price,
  4903. IsMedicineInsurance: 1,
  4904. SettleType: settle_accounts_type,
  4905. SettleStartTime: start_time,
  4906. SettleEndTime: end_time,
  4907. Creator: roles.AdminUserId,
  4908. Modify: roles.AdminUserId,
  4909. FaPiaoNumber: fapiao_number,
  4910. FaPiaoCode: fapiao_code,
  4911. PType: 2,
  4912. Diagnosis: diagnosis_id,
  4913. }
  4914. err = service.CreateOrder(order)
  4915. if err != nil {
  4916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4917. return
  4918. }
  4919. for _, item := range res.Output.Result {
  4920. temp := strings.Split(item.FeedetlSn, "-")
  4921. var advice_id int64 = 0
  4922. var project_id int64 = 0
  4923. var types int64 = 0
  4924. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4925. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4926. if temp[1] == "1" {
  4927. advice_id = id
  4928. project_id = 0
  4929. } else if temp[1] == "2" {
  4930. advice_id = 0
  4931. project_id = id
  4932. }
  4933. info := &models.HisOrderInfo{
  4934. OrderNumber: order.Number,
  4935. FeedetlSn: item.FeedetlSn,
  4936. UploadDate: time.Now().Unix(),
  4937. AdviceId: advice_id,
  4938. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4939. Cnt: item.Cnt,
  4940. Pric: float64(item.Pric),
  4941. PatientId: his.PatientId,
  4942. PricUplmtAmt: item.PricUplmtAmt,
  4943. SelfpayProp: item.SelfpayProp,
  4944. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4945. OverlmtAmt: item.OverlmtAmt,
  4946. PreselfpayAmt: item.PreselfpayAmt,
  4947. BasMednFlag: item.BasMednFlag,
  4948. MedChrgitmType: item.MedChrgitmType,
  4949. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4950. Status: 1,
  4951. Memo: item.Memo,
  4952. Mtime: time.Now().Unix(),
  4953. InscpScpAmt: item.InscpScpAmt,
  4954. DrtReimFlag: item.DrtReimFlag,
  4955. Ctime: time.Now().Unix(),
  4956. ListSpItemFlag: item.ListSpItemFlag,
  4957. ChldMedcFlag: item.ChldMedcFlag,
  4958. LmtUsedFlag: item.LmtUsedFlag,
  4959. ChrgitmLv: item.ChrgitmLv,
  4960. UserOrgId: adminUser.CurrentOrgId,
  4961. HisPatientId: his.ID,
  4962. OrderId: order.ID,
  4963. ProjectId: project_id,
  4964. Type: types,
  4965. }
  4966. service.CreateOrderInfo(info)
  4967. }
  4968. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4969. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4970. var total float64
  4971. for _, item := range prescriptions {
  4972. if item.Type == 1 { //药品
  4973. for _, subItem := range item.HisDoctorAdviceInfo {
  4974. total = total + (subItem.Price * subItem.PrescribingNumber)
  4975. }
  4976. }
  4977. if item.Type == 2 { //项目
  4978. for _, subItem := range item.HisPrescriptionProject {
  4979. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4980. total = total + (subItem.Price * cnt)
  4981. }
  4982. }
  4983. }
  4984. for _, item := range prescriptions {
  4985. for _, subItem := range item.HisAdditionalCharge {
  4986. total = total + (subItem.Price * float64(subItem.Count))
  4987. }
  4988. }
  4989. var allTotal string
  4990. if adminUser.CurrentOrgId == 9919 {
  4991. allTotal = fmt.Sprintf("%.4f", total)
  4992. } else {
  4993. allTotal = fmt.Sprintf("%.4f", total)
  4994. }
  4995. if res.Infcode == 0 {
  4996. var rf []*ResultFive
  4997. json.Unmarshal([]byte(his.Iinfo), &rf)
  4998. chrg_bchno := chrg_bchno
  4999. cert_no := his.Certno
  5000. var insutypes []string
  5001. var insutype string
  5002. var is390 int = 0
  5003. var is310 int = 0
  5004. for _, item := range rf {
  5005. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5006. insutypes = append(insutypes, item.Insutype)
  5007. }
  5008. }
  5009. if len(insutypes) == 1 {
  5010. insutype = insutypes[0]
  5011. } else {
  5012. for _, i := range insutypes {
  5013. if i == "390" {
  5014. is390 = 1
  5015. }
  5016. if i == "310" {
  5017. is310 = 1
  5018. }
  5019. }
  5020. }
  5021. if is390 == 1 {
  5022. insutype = "390"
  5023. }
  5024. if is310 == 1 {
  5025. insutype = "310"
  5026. }
  5027. if len(insutypes) == 0 {
  5028. insutype = "310"
  5029. }
  5030. if len(insutypes) == 2 {
  5031. insutype = strconv.FormatInt(his.SocialType, 10)
  5032. }
  5033. insutype = strconv.FormatInt(his.SocialType, 10)
  5034. //insutype = "390"
  5035. if his.IdCardType == 1 {
  5036. // cert_no = his.MedicalInsuranceNumber
  5037. cert_no = his.Certno
  5038. } else {
  5039. cert_no = his.Certno
  5040. }
  5041. var res ResultSeven
  5042. var resSeven10265 ResultSeven10265
  5043. var src_resquest string
  5044. var result2 string
  5045. var acct_used_flag string
  5046. fmt.Println("pay_way")
  5047. fmt.Println(pay_way)
  5048. fmt.Println("pay_way")
  5049. if pay_way == 4 {
  5050. acct_used_flag = "1"
  5051. } else {
  5052. acct_used_flag = "0"
  5053. }
  5054. if miConfig.MdtrtareaAdmvs == "421300" {
  5055. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5056. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5057. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5058. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5059. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5060. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5061. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5062. resp, requestErr := http.Get(api)
  5063. if requestErr != nil {
  5064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5065. return
  5066. }
  5067. body, ioErr := ioutil.ReadAll(resp.Body)
  5068. if ioErr != nil {
  5069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5071. return
  5072. }
  5073. var respJSON map[string]interface{}
  5074. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5077. return
  5078. }
  5079. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5080. result, _ := json.Marshal(respJSON)
  5081. if miConfig.Code == "H15049901371" {
  5082. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5083. utils.ErrorLog("解析失败:%v", err)
  5084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5085. return
  5086. }
  5087. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5088. res.Output = resSeven10265.Output
  5089. res.ErrMsg = resSeven10265.ErrMsg
  5090. res.Cainfo = resSeven10265.Cainfo
  5091. res.WarnMsg = resSeven10265.WarnMsg
  5092. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5093. res.Infcode = infocode
  5094. } else {
  5095. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5096. utils.ErrorLog("解析失败:%v", err)
  5097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5098. return
  5099. }
  5100. }
  5101. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5102. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5103. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5104. //psn_info, _ := service.GetPsnByPatientId(id)
  5105. bas := strings.Split(psn_info.CardInfo, "|")
  5106. if his.IdCardType == 1 {
  5107. cert_no = bas[2]
  5108. } else if his.IdCardType == 3 {
  5109. cert_no = his.Certno
  5110. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5111. } else {
  5112. cert_no = bas[1]
  5113. }
  5114. //江苏地区国家医保医疗类别
  5115. //职工透析:医疗类别选特殊情况门诊9933
  5116. //居民血透门慢: 医疗类别选门诊慢病1402
  5117. //var med_type string
  5118. //if his.Insutype == "310" {
  5119. // if reg_type == 14 {
  5120. // med_type = "9933"
  5121. // } else if reg_type == 11 {
  5122. // med_type = "11"
  5123. //
  5124. // }
  5125. //} else if his.Insutype == "390" {
  5126. // if reg_type == 14 {
  5127. // med_type = "1402"
  5128. // } else if reg_type == 11 {
  5129. // med_type = "11"
  5130. // }
  5131. //}
  5132. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5133. var api string
  5134. if miConfig.MdtrtareaAdmvs == "320921" {
  5135. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5136. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5137. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5138. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5139. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5140. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5141. "&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
  5142. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5143. } else {
  5144. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5145. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5146. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5147. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5148. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5149. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5150. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5151. "&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
  5152. }
  5153. resp, requestErr := http.Get(api)
  5154. if requestErr != nil {
  5155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5156. return
  5157. }
  5158. body, ioErr := ioutil.ReadAll(resp.Body)
  5159. if ioErr != nil {
  5160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5162. return
  5163. }
  5164. var respJSON map[string]interface{}
  5165. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5168. return
  5169. }
  5170. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5171. result, _ := json.Marshal(respJSON)
  5172. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5173. utils.ErrorLog("解析失败:%v", err)
  5174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5175. return
  5176. }
  5177. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5178. res.Output = resSeven10265.Output
  5179. res.ErrMsg = resSeven10265.ErrMsg
  5180. res.Cainfo = resSeven10265.Cainfo
  5181. res.WarnMsg = resSeven10265.WarnMsg
  5182. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5183. res.Infcode = infocode
  5184. } else {
  5185. if miConfig.Code == "H15049901371" {
  5186. //赤峰地区国家医保医疗类别
  5187. //职工透析:医疗类别选特殊情况门诊990502
  5188. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5189. var med_type string
  5190. if his.Insutype == "390" {
  5191. if reg_type == 14 {
  5192. med_type = "9933"
  5193. } else if reg_type == 11 {
  5194. med_type = "11"
  5195. }
  5196. } else if his.Insutype == "310" {
  5197. if reg_type == 14 {
  5198. med_type = "990502"
  5199. } else if reg_type == 11 {
  5200. med_type = "11"
  5201. }
  5202. }
  5203. 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)
  5204. } else {
  5205. 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)
  5206. }
  5207. //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)
  5208. var dat map[string]interface{}
  5209. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5210. fmt.Println(dat)
  5211. } else {
  5212. fmt.Println(err)
  5213. }
  5214. saveLog(result2, src_resquest, "2207", "结算")
  5215. userJSONBytes, _ := json.Marshal(dat)
  5216. if miConfig.Code == "H15049901371" {
  5217. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5218. utils.ErrorLog("解析失败:%v", err)
  5219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5220. return
  5221. }
  5222. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5223. res.Output = resSeven10265.Output
  5224. res.ErrMsg = resSeven10265.ErrMsg
  5225. res.Cainfo = resSeven10265.Cainfo
  5226. res.WarnMsg = resSeven10265.WarnMsg
  5227. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5228. res.Infcode = infocode
  5229. } else {
  5230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5231. utils.ErrorLog("解析失败:%v", err)
  5232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5233. return
  5234. }
  5235. }
  5236. }
  5237. if res.Infcode != 0 {
  5238. errlog := &models.HisOrderError{
  5239. UserOrgId: adminUser.CurrentOrgId,
  5240. Ctime: time.Now().Unix(),
  5241. Mtime: time.Now().Unix(),
  5242. Number: chrg_bchno,
  5243. ErrMsg: res.ErrMsg,
  5244. Status: 1,
  5245. PatientId: id,
  5246. RecordTime: recordDateTime,
  5247. Stage: 6,
  5248. }
  5249. service.CreateErrMsgLog(errlog)
  5250. c.ServeSuccessJSON(map[string]interface{}{
  5251. "failed_code": -10,
  5252. "msg": res.ErrMsg,
  5253. })
  5254. return
  5255. } else {
  5256. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5257. order.OrderStatus = 2
  5258. order.Status = 1
  5259. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5260. order.SetlId = res.Output.Setlinfo.SetlID
  5261. order.PsnNo = res.Output.Setlinfo.PsnNo
  5262. order.PsnName = res.Output.Setlinfo.PsnName
  5263. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5264. order.Certno = res.Output.Setlinfo.Certno
  5265. order.Gend = res.Output.Setlinfo.Gend
  5266. order.Naty = res.Output.Setlinfo.Naty
  5267. order.Age = res.Output.Setlinfo.Age
  5268. order.Insutype = res.Output.Setlinfo.Insutype
  5269. order.PsnType = res.Output.Setlinfo.PsnType
  5270. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5271. order.SetlTime = res.Output.Setlinfo.SetlTime
  5272. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5273. if res.Output.Setlinfo.MedType == "140101" {
  5274. order.MedType = "14"
  5275. } else {
  5276. order.MedType = res.Output.Setlinfo.MedType
  5277. }
  5278. if reg_type == 1112 {
  5279. order.MedType = "1112"
  5280. }
  5281. if reg_type == 1111 {
  5282. order.MedType = "1111"
  5283. }
  5284. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5285. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5286. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5287. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5288. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5289. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5290. order.HifpPay = res.Output.Setlinfo.HifpPay
  5291. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5292. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5293. order.HifesPay = res.Output.Setlinfo.HifesPay
  5294. order.HifobPay = res.Output.Setlinfo.HifobPay
  5295. order.MafPay = res.Output.Setlinfo.MafPay
  5296. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5297. order.OthPay = res.Output.Setlinfo.OthPay
  5298. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5299. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5300. order.AcctPay = res.Output.Setlinfo.AcctPay
  5301. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5302. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5303. order.Balc = res.Output.Setlinfo.Balc
  5304. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5305. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5306. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5307. order.ClrType = res.Output.Setlinfo.ClrType
  5308. order.ClrWay = res.Output.Setlinfo.ClrWay
  5309. order.Creator = order.Creator
  5310. order.Modify = roles.AdminUserId
  5311. order.RequestLog = src_resquest
  5312. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5313. detailStr := string(setlDetail)
  5314. order.SetlDetail = detailStr
  5315. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5316. err = service.UpDateOrder(order)
  5317. if err == nil {
  5318. c.ServeSuccessJSON(map[string]interface{}{
  5319. "msg": "结算成功",
  5320. })
  5321. } else {
  5322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5323. return
  5324. }
  5325. }
  5326. } else {
  5327. adminUser := c.GetAdminUserInfo()
  5328. errlog := &models.HisOrderError{
  5329. UserOrgId: adminUser.CurrentOrgId,
  5330. Ctime: time.Now().Unix(),
  5331. Mtime: time.Now().Unix(),
  5332. ErrMsg: res.ErrMsg,
  5333. Status: 1,
  5334. PatientId: id,
  5335. RecordTime: recordDateTime,
  5336. Stage: 4,
  5337. }
  5338. service.CreateErrMsgLog(errlog)
  5339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5340. return
  5341. }
  5342. } else {
  5343. adminUser := c.GetAdminUserInfo()
  5344. errlog := &models.HisOrderError{
  5345. UserOrgId: adminUser.CurrentOrgId,
  5346. Ctime: time.Now().Unix(),
  5347. Mtime: time.Now().Unix(),
  5348. ErrMsg: res.ErrMsg,
  5349. Status: 1,
  5350. PatientId: id,
  5351. RecordTime: recordDateTime,
  5352. Stage: 4,
  5353. }
  5354. service.CreateErrMsgLog(errlog)
  5355. c.ServeSuccessJSON(map[string]interface{}{
  5356. "failed_code": -10,
  5357. "msg": res.ErrMsg,
  5358. })
  5359. return
  5360. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5361. //return
  5362. }
  5363. }
  5364. }
  5365. } else if tempOrder.ID > 0 {
  5366. if tempOrder.IsPre == 1 {
  5367. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5368. var rf []*ResultFive
  5369. json.Unmarshal([]byte(his.Iinfo), &rf)
  5370. chrg_bchno := tempOrder.Number
  5371. cert_no := his.Certno
  5372. var insutypes []string
  5373. var insutype string
  5374. var is390 int = 0
  5375. var is310 int = 0
  5376. for _, item := range rf {
  5377. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5378. insutypes = append(insutypes, item.Insutype)
  5379. }
  5380. }
  5381. if len(insutypes) == 1 {
  5382. insutype = insutypes[0]
  5383. } else {
  5384. for _, i := range insutypes {
  5385. if i == "390" {
  5386. is390 = 1
  5387. }
  5388. if i == "310" {
  5389. is310 = 1
  5390. }
  5391. }
  5392. }
  5393. if is390 == 1 {
  5394. insutype = "390"
  5395. }
  5396. if is310 == 1 {
  5397. insutype = "310"
  5398. }
  5399. if len(insutypes) == 0 {
  5400. insutype = "310"
  5401. }
  5402. if len(insutypes) == 2 {
  5403. insutype = strconv.FormatInt(his.SocialType, 64)
  5404. }
  5405. //insutype = "390"
  5406. if his.IdCardType == 1 {
  5407. // cert_no = his.MedicalInsuranceNumber
  5408. cert_no = his.Certno
  5409. } else {
  5410. cert_no = his.Certno
  5411. }
  5412. var res ResultSeven
  5413. var resSeven10265 ResultSeven10265
  5414. var src_resquest string
  5415. var result2 string
  5416. var acct_used_flag string
  5417. fmt.Println("pay_way")
  5418. fmt.Println(pay_way)
  5419. fmt.Println("pay_way")
  5420. if pay_way == 4 {
  5421. acct_used_flag = "1"
  5422. } else {
  5423. acct_used_flag = "0"
  5424. }
  5425. if miConfig.MdtrtareaAdmvs == "421300" {
  5426. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5427. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5428. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5429. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5430. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5431. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5432. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5433. resp, requestErr := http.Get(api)
  5434. if requestErr != nil {
  5435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5436. return
  5437. }
  5438. body, ioErr := ioutil.ReadAll(resp.Body)
  5439. if ioErr != nil {
  5440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5442. return
  5443. }
  5444. var respJSON map[string]interface{}
  5445. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5448. return
  5449. }
  5450. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5451. result, _ := json.Marshal(respJSON)
  5452. fmt.Println("log")
  5453. fmt.Println(string(result))
  5454. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5455. utils.ErrorLog("解析失败:%v", err)
  5456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5457. return
  5458. }
  5459. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5460. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5461. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5462. //psn_info, _ := service.GetPsnByPatientId(id)
  5463. bas := strings.Split(psn_info.CardInfo, "|")
  5464. if his.IdCardType == 1 {
  5465. cert_no = bas[2]
  5466. } else {
  5467. cert_no = bas[1]
  5468. }
  5469. //江苏地区国家医保医疗类别
  5470. //职工透析:医疗类别选特殊情况门诊9933
  5471. //居民血透门慢: 医疗类别选门诊慢病1402
  5472. //var med_type string
  5473. //if his.Insutype == "310" {
  5474. // if reg_type == 14 {
  5475. // med_type = "9933"
  5476. // } else if reg_type == 11 {
  5477. // med_type = "11"
  5478. //
  5479. // }
  5480. //} else if his.Insutype == "390" {
  5481. // if reg_type == 14 {
  5482. // med_type = "1402"
  5483. // } else if reg_type == 11 {
  5484. // med_type = "11"
  5485. // }
  5486. //}
  5487. var api string
  5488. if miConfig.MdtrtareaAdmvs == "320921" {
  5489. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5490. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5491. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5492. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5493. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5494. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5495. "&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
  5496. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5497. } else {
  5498. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5499. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5500. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5501. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5502. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5503. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5504. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5505. "&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
  5506. }
  5507. resp, requestErr := http.Get(api)
  5508. if requestErr != nil {
  5509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5510. return
  5511. }
  5512. body, ioErr := ioutil.ReadAll(resp.Body)
  5513. if ioErr != nil {
  5514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5516. return
  5517. }
  5518. var respJSON map[string]interface{}
  5519. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5522. return
  5523. }
  5524. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5525. result, _ := json.Marshal(respJSON)
  5526. fmt.Println("log")
  5527. fmt.Println(string(result))
  5528. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5529. utils.ErrorLog("解析失败:%v", err)
  5530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5531. return
  5532. }
  5533. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5534. res.Output = resSeven10265.Output
  5535. res.ErrMsg = resSeven10265.ErrMsg
  5536. res.Cainfo = resSeven10265.Cainfo
  5537. res.WarnMsg = resSeven10265.WarnMsg
  5538. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5539. res.Infcode = infocode
  5540. } else {
  5541. var src_resquest string
  5542. if miConfig.Code == "H15049901371" {
  5543. //赤峰地区国家医保医疗类别
  5544. //职工透析:医疗类别选特殊情况门诊990502
  5545. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5546. var med_type string
  5547. if his.Insutype == "390" {
  5548. if reg_type == 14 {
  5549. med_type = "9933"
  5550. } else if reg_type == 11 {
  5551. med_type = "11"
  5552. }
  5553. } else if his.Insutype == "310" {
  5554. if reg_type == 14 {
  5555. med_type = "990502"
  5556. } else if reg_type == 11 {
  5557. med_type = "11"
  5558. }
  5559. }
  5560. 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)
  5561. } else {
  5562. 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)
  5563. }
  5564. var dat map[string]interface{}
  5565. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5566. fmt.Println(dat)
  5567. } else {
  5568. fmt.Println(err)
  5569. }
  5570. saveLog(result2, src_resquest, "2207", "结算")
  5571. userJSONBytes, _ := json.Marshal(dat)
  5572. if miConfig.Code == "H15049901371" {
  5573. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5574. utils.ErrorLog("解析失败:%v", err)
  5575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5576. return
  5577. }
  5578. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5579. res.Output = resSeven10265.Output
  5580. res.ErrMsg = resSeven10265.ErrMsg
  5581. res.Cainfo = resSeven10265.Cainfo
  5582. res.WarnMsg = resSeven10265.WarnMsg
  5583. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5584. res.Infcode = infocode
  5585. } else {
  5586. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5587. utils.ErrorLog("解析失败:%v", err)
  5588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5589. return
  5590. }
  5591. }
  5592. }
  5593. if res.Infcode != 0 {
  5594. errlog := &models.HisOrderError{
  5595. UserOrgId: adminUser.CurrentOrgId,
  5596. Ctime: time.Now().Unix(),
  5597. Mtime: time.Now().Unix(),
  5598. Number: chrg_bchno,
  5599. ErrMsg: res.ErrMsg,
  5600. Status: 1,
  5601. PatientId: id,
  5602. RecordTime: recordDateTime,
  5603. Stage: 6,
  5604. }
  5605. service.CreateErrMsgLog(errlog)
  5606. c.ServeSuccessJSON(map[string]interface{}{
  5607. "failed_code": -10,
  5608. "msg": res.ErrMsg,
  5609. })
  5610. return
  5611. } else {
  5612. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5613. order.OrderStatus = 2
  5614. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5615. order.SetlId = res.Output.Setlinfo.SetlID
  5616. order.PsnNo = res.Output.Setlinfo.PsnNo
  5617. order.PsnName = res.Output.Setlinfo.PsnName
  5618. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5619. order.Certno = res.Output.Setlinfo.Certno
  5620. order.Gend = res.Output.Setlinfo.Gend
  5621. order.Naty = res.Output.Setlinfo.Naty
  5622. order.Age = res.Output.Setlinfo.Age
  5623. order.Insutype = res.Output.Setlinfo.Insutype
  5624. order.PsnType = res.Output.Setlinfo.PsnType
  5625. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5626. order.SetlTime = res.Output.Setlinfo.SetlTime
  5627. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5628. //order.MedType = res.Output.Setlinfo.MedType
  5629. if reg_type == 1112 {
  5630. order.MedType = "1112"
  5631. }
  5632. if reg_type == 1111 {
  5633. order.MedType = "1111"
  5634. }
  5635. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5636. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5637. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5638. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5639. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5640. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5641. order.HifpPay = res.Output.Setlinfo.HifpPay
  5642. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5643. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5644. order.HifesPay = res.Output.Setlinfo.HifesPay
  5645. order.HifobPay = res.Output.Setlinfo.HifobPay
  5646. order.MafPay = res.Output.Setlinfo.MafPay
  5647. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5648. order.OthPay = res.Output.Setlinfo.OthPay
  5649. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5650. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5651. order.AcctPay = res.Output.Setlinfo.AcctPay
  5652. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5653. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5654. order.Balc = res.Output.Setlinfo.Balc
  5655. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5656. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5657. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5658. order.ClrWay = res.Output.Setlinfo.ClrWay
  5659. order.Creator = order.Creator
  5660. order.Modify = roles.AdminUserId
  5661. order.RequestLog = src_resquest
  5662. order.Diagnosis = diagnosis_id
  5663. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5664. detailStr := string(setlDetail)
  5665. order.SetlDetail = detailStr
  5666. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5667. err = service.UpDateOrder(order)
  5668. if err == nil {
  5669. c.ServeSuccessJSON(map[string]interface{}{
  5670. "msg": "结算成功",
  5671. })
  5672. } else {
  5673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5674. return
  5675. }
  5676. }
  5677. }
  5678. }
  5679. }
  5680. //func (c *HisApiController) GetPreUploadInfo() {
  5681. // id, _ := c.GetInt64("id")
  5682. // record_time := c.GetString("record_time")
  5683. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5684. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5685. //
  5686. // timeLayout := "2006-01-02"
  5687. // loc, _ := time.LoadLocation("Local")
  5688. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5689. // if err != nil {
  5690. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5691. // return
  5692. // }
  5693. // recordDateTime := theTime.Unix()
  5694. // adminUser := c.GetAdminUserInfo()
  5695. //
  5696. // var prescriptions []*models.HisPrescription
  5697. //
  5698. // var start_time int64
  5699. // var end_time int64
  5700. //
  5701. // data := make(map[string]interface{})
  5702. // if settle_accounts_type == 1 { //日结
  5703. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5704. // data["pre"] = prescriptions
  5705. //
  5706. // } else { //月结
  5707. // start_time_str := c.GetString("start_time")
  5708. // end_time_str := c.GetString("end_time")
  5709. // timeLayout := "2006-01-02"
  5710. // loc, _ := time.LoadLocation("Local")
  5711. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5712. // if err != nil {
  5713. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5714. // return
  5715. // }
  5716. // recordStartTime := theStartTime.Unix()
  5717. // start_time = recordStartTime
  5718. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5719. // if err != nil {
  5720. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5721. // return
  5722. // }
  5723. // recordEndTime := theEndTime.Unix()
  5724. // end_time = recordEndTime
  5725. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5726. // data["pre"] = prescriptions
  5727. //
  5728. // }
  5729. //
  5730. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5731. //
  5732. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5733. // timestamp := time.Now().Unix()
  5734. // tempTime := time.Unix(timestamp, 0)
  5735. // timeFormat := tempTime.Format("20060102150405")
  5736. // chrgBchno := rand.Intn(100000) + 10000
  5737. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5738. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5739. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5740. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5741. // strconv.FormatInt(his.PatientId, 10)
  5742. // client := &http.Client{}
  5743. // data["psn_no"] = his.PsnNo
  5744. // data["mdtrt_id"] = his.Number
  5745. // data["chrg_bchno"] = chrg_bchno
  5746. // data["org_name"] = miConfig.OrgName
  5747. // data["doctor"] = roles.UserName
  5748. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5749. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5750. // data["fixmedins_code"] = miConfig.Code
  5751. // data["dept_code"] = department.Number
  5752. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5753. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5754. // data["secret_key"] = miConfig.SecretKey
  5755. // var ids []int64
  5756. //
  5757. // for _, item := range prescriptions {
  5758. // ids = append(ids, item.ID)
  5759. // }
  5760. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5761. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5762. // bytesData, _ := json.Marshal(data)
  5763. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5764. // resp, _ := client.Do(req)
  5765. // defer resp.Body.Close()
  5766. // body, ioErr := ioutil.ReadAll(resp.Body)
  5767. // if ioErr != nil {
  5768. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5769. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5770. // return
  5771. // }
  5772. // var respJSON map[string]interface{}
  5773. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5774. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5775. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5776. // return
  5777. // }
  5778. //
  5779. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5780. // userJSONBytes, _ := json.Marshal(respJSON)
  5781. // var res ResultFour
  5782. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5783. // utils.ErrorLog("解析失败:%v", err)
  5784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5785. // return
  5786. // }
  5787. //
  5788. // if res.Infcode == 0 {
  5789. // order := &models.HisOrder{
  5790. // UserOrgId: adminUser.CurrentOrgId,
  5791. // HisPatientId: his.ID,
  5792. // PatientId: his.PatientId,
  5793. // SettleAccountsDate: recordDateTime,
  5794. // Ctime: time.Now().Unix(),
  5795. // Mtime: time.Now().Unix(),
  5796. // Status: 1,
  5797. // Number: chrg_bchno,
  5798. // Infcode: res.Infcode,
  5799. // WarnMsg: res.WarnMsg,
  5800. // Cainfo: res.Cainfo,
  5801. // ErrMsg: res.ErrMsg,
  5802. // RespondTime: res.RefmsgTime,
  5803. // InfRefmsgid: res.InfRefmsgid,
  5804. // OrderStatus: 1,
  5805. // IsMedicineInsurance: 1,
  5806. // SettleType: settle_accounts_type,
  5807. // SettleStartTime: start_time,
  5808. // SettleEndTime: end_time,
  5809. // Creator: roles.ID,
  5810. // Modify: roles.ID,
  5811. // PType: 2,
  5812. // }
  5813. // err = service.CreateOrder(order)
  5814. // if err != nil {
  5815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5816. // return
  5817. // }
  5818. //
  5819. // for _, item := range res.Output.Result {
  5820. // temp := strings.Split(item.FeedetlSn, "-")
  5821. // var advice_id int64 = 0
  5822. // var project_id int64 = 0
  5823. // var types int64 = 0
  5824. //
  5825. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5826. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5827. //
  5828. // if temp[1] == "1" {
  5829. // advice_id = id
  5830. // project_id = 0
  5831. // } else if temp[1] == "2" {
  5832. // advice_id = 0
  5833. // project_id = id
  5834. // }
  5835. //
  5836. // info := &models.HisOrderInfo{
  5837. // OrderNumber: order.Number,
  5838. // FeedetlSn: item.FeedetlSn,
  5839. // UploadDate: time.Now().Unix(),
  5840. // AdviceId: advice_id,
  5841. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5842. // Cnt: item.Cnt,
  5843. // Pric: float64(item.Pric),
  5844. // PatientId: his.PatientId,
  5845. // PricUplmtAmt: item.PricUplmtAmt,
  5846. // SelfpayProp: item.SelfpayProp,
  5847. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5848. // OverlmtAmt: item.OverlmtAmt,
  5849. // PreselfpayAmt: item.PreselfpayAmt,
  5850. // BasMednFlag: item.BasMednFlag,
  5851. // MedChrgitmType: item.MedChrgitmType,
  5852. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5853. // Status: 1,
  5854. // Memo: item.Memo,
  5855. // Mtime: time.Now().Unix(),
  5856. // InscpScpAmt: item.InscpScpAmt,
  5857. // DrtReimFlag: item.DrtReimFlag,
  5858. // Ctime: time.Now().Unix(),
  5859. // ListSpItemFlag: item.ListSpItemFlag,
  5860. // ChldMedcFlag: item.ChldMedcFlag,
  5861. // LmtUsedFlag: item.LmtUsedFlag,
  5862. // ChrgitmLv: item.ChrgitmLv,
  5863. // UserOrgId: adminUser.CurrentOrgId,
  5864. // HisPatientId: his.ID,
  5865. // OrderId: order.ID,
  5866. // ProjectId: project_id,
  5867. // Type: types,
  5868. // }
  5869. // service.CreateOrderInfo(info)
  5870. //
  5871. // }
  5872. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5873. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5874. //
  5875. // var total float64
  5876. // for _, item := range prescriptions {
  5877. // if item.Type == 1 { //药品
  5878. // for _, subItem := range item.HisDoctorAdviceInfo {
  5879. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5880. // }
  5881. // }
  5882. // if item.Type == 2 { //项目
  5883. // for _, subItem := range item.HisPrescriptionProject {
  5884. // total = total + (subItem.Price * float64(subItem.Count))
  5885. // }
  5886. // }
  5887. // }
  5888. //
  5889. // for _, item := range prescriptions {
  5890. // for _, subItem := range item.HisAdditionalCharge {
  5891. // total = total + (subItem.Price * float64(subItem.Count))
  5892. // }
  5893. // }
  5894. //
  5895. // allTotal := fmt.Sprintf("%.2f", total)
  5896. // if res.Infcode == 0 {
  5897. // var rf []*ResultFive
  5898. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5899. // psn_no := his.PsnNo
  5900. // mdtrt_id := his.Number
  5901. // chrg_bchno := chrg_bchno
  5902. // cert_no := his.Certno
  5903. // insutype := rf[0].Insutype
  5904. //
  5905. // if his.IdCardType == 1 {
  5906. // cert_no = his.MedicalInsuranceNumber
  5907. //
  5908. // } else {
  5909. //
  5910. // cert_no = his.Certno
  5911. //
  5912. // }
  5913. //
  5914. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5915. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5916. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5917. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5918. // resp, requestErr := http.Get(api)
  5919. // if requestErr != nil {
  5920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5921. // return
  5922. // }
  5923. // defer resp.Body.Close()
  5924. // body, ioErr := ioutil.ReadAll(resp.Body)
  5925. // if ioErr != nil {
  5926. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5927. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5928. // return
  5929. // }
  5930. // var respJSON map[string]interface{}
  5931. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5932. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5934. // return
  5935. // }
  5936. // fmt.Println(respJSON)
  5937. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5938. // userJSONBytes, _ := json.Marshal(respJSON)
  5939. // var res ResultSeven
  5940. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5941. // utils.ErrorLog("解析失败:%v", err)
  5942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5943. // return
  5944. // }
  5945. // if res.Infcode != 0 {
  5946. // errlog := &models.HisOrderError{
  5947. // UserOrgId: adminUser.CurrentOrgId,
  5948. // Ctime: time.Now().Unix(),
  5949. // Mtime: time.Now().Unix(),
  5950. // Number: chrg_bchno,
  5951. // ErrMsg: res.ErrMsg,
  5952. // Status: 1,
  5953. // PatientId: id,
  5954. // RecordTime: recordDateTime,
  5955. // Stage: 7,
  5956. // }
  5957. // service.CreateErrMsgLog(errlog)
  5958. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5959. // return
  5960. // } else {
  5961. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5962. // order.OrderStatus = 1
  5963. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5964. // order.SetlId = res.Output.Setlinfo.SetlID
  5965. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5966. // order.PsnName = res.Output.Setlinfo.PsnName
  5967. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5968. // order.Certno = res.Output.Setlinfo.Certno
  5969. // order.Gend = res.Output.Setlinfo.Gend
  5970. // order.Naty = res.Output.Setlinfo.Naty
  5971. // order.Age = res.Output.Setlinfo.Age
  5972. // order.Insutype = res.Output.Setlinfo.Insutype
  5973. // order.PsnType = res.Output.Setlinfo.PsnType
  5974. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5975. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5976. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5977. // order.MedType = res.Output.Setlinfo.MedType
  5978. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5979. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5980. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5981. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5982. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5983. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5984. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5985. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5986. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5987. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5988. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5989. // order.MafPay = res.Output.Setlinfo.MafPay
  5990. // order.OthPay = res.Output.Setlinfo.OthPay
  5991. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5992. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5993. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5994. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5995. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5996. // order.Balc = res.Output.Setlinfo.Balc
  5997. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5998. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5999. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6000. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6001. // order.Creator = order.Creator
  6002. // order.Modify = roles.ID
  6003. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6004. // detailStr := string(setlDetail)
  6005. // order.SetlDetail = detailStr
  6006. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6007. // err = service.UpDateOrder(order)
  6008. // if err == nil {
  6009. // c.ServeSuccessJSON(map[string]interface{}{
  6010. // "msg": "预结算成功",
  6011. // })
  6012. // } else {
  6013. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6014. // return
  6015. // }
  6016. // }
  6017. // } else {
  6018. // adminUser := c.GetAdminUserInfo()
  6019. // errlog := &models.HisOrderError{
  6020. // UserOrgId: adminUser.CurrentOrgId,
  6021. // Ctime: time.Now().Unix(),
  6022. // Mtime: time.Now().Unix(),
  6023. // ErrMsg: res.ErrMsg,
  6024. // Status: 1,
  6025. // PatientId: id,
  6026. // RecordTime: recordDateTime,
  6027. // Stage: 4,
  6028. // }
  6029. // service.CreateErrMsgLog(errlog)
  6030. //
  6031. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6032. // return
  6033. // }
  6034. // } else {
  6035. // adminUser := c.GetAdminUserInfo()
  6036. // errlog := &models.HisOrderError{
  6037. // UserOrgId: adminUser.CurrentOrgId,
  6038. // Ctime: time.Now().Unix(),
  6039. // Mtime: time.Now().Unix(),
  6040. // ErrMsg: res.ErrMsg,
  6041. // Status: 1,
  6042. // PatientId: id,
  6043. // RecordTime: recordDateTime,
  6044. // Stage: 4,
  6045. // }
  6046. // service.CreateErrMsgLog(errlog)
  6047. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6048. // return
  6049. // }
  6050. //
  6051. // } else {
  6052. // var total float64
  6053. // for _, item := range prescriptions {
  6054. // if item.Type == 1 { //药品
  6055. // for _, subItem := range item.HisDoctorAdviceInfo {
  6056. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6057. // }
  6058. // }
  6059. // if item.Type == 2 { //项目
  6060. // for _, subItem := range item.HisPrescriptionProject {
  6061. // total = total + (subItem.Price * float64(subItem.Count))
  6062. // }
  6063. // }
  6064. //
  6065. // for _, subItem := range item.HisAdditionalCharge {
  6066. // total = total + (subItem.Price * float64(subItem.Count))
  6067. // }
  6068. // }
  6069. //
  6070. // allTotal := fmt.Sprintf("%.2f", total)
  6071. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6072. // order := &models.HisOrder{
  6073. // UserOrgId: adminUser.CurrentOrgId,
  6074. // HisPatientId: his.ID,
  6075. // PatientId: id,
  6076. // SettleAccountsDate: recordDateTime,
  6077. // Ctime: time.Now().Unix(),
  6078. // Mtime: time.Now().Unix(),
  6079. // Status: 1,
  6080. // OrderStatus: 2,
  6081. // Number: chrg_bchno,
  6082. // MedfeeSumamt: totals,
  6083. // }
  6084. // err = service.CreateOrder(order)
  6085. // if err != nil {
  6086. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6087. // return
  6088. // }
  6089. //
  6090. // var customs []*Custom
  6091. // for _, item := range prescriptions {
  6092. //
  6093. // if item.Type == 1 { //药品
  6094. // for _, subItem := range item.HisDoctorAdviceInfo {
  6095. // cus := &Custom{
  6096. // AdviceId: subItem.ID,
  6097. // ProjectId: 0,
  6098. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6099. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6100. // FeedetlSn: subItem.FeedetlSn,
  6101. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6102. // MedListCodg: subItem.MedListCodg,
  6103. // Type: 1,
  6104. // }
  6105. // customs = append(customs, cus)
  6106. // }
  6107. // }
  6108. //
  6109. // if item.Type == 2 { //项目
  6110. // for _, subItem := range item.HisPrescriptionProject {
  6111. //
  6112. // cus := &Custom{
  6113. // AdviceId: 0,
  6114. // ProjectId: subItem.ID,
  6115. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6116. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6117. // FeedetlSn: subItem.FeedetlSn,
  6118. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6119. // MedListCodg: subItem.MedListCodg,
  6120. // Type: 2,
  6121. // }
  6122. //
  6123. // customs = append(customs, cus)
  6124. // }
  6125. // }
  6126. //
  6127. // for _, item := range item.HisAdditionalCharge {
  6128. // cus := &Custom{
  6129. // ItemId: item.ID,
  6130. // AdviceId: 0,
  6131. // ProjectId: 0,
  6132. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6133. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6134. // FeedetlSn: item.FeedetlSn,
  6135. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6136. // MedListCodg: item.XtHisAddtionConfig.Code,
  6137. // Type: 3,
  6138. // }
  6139. //
  6140. // customs = append(customs, cus)
  6141. // }
  6142. //
  6143. // }
  6144. //
  6145. // for _, item := range customs {
  6146. // var advice_id int64 = 0
  6147. // var project_id int64 = 0
  6148. // var item_id int64 = 0
  6149. //
  6150. // var types int64 = 0
  6151. //
  6152. // if item.Type == 1 {
  6153. // advice_id = item.AdviceId
  6154. // project_id = 0
  6155. // item_id = 0
  6156. // } else if item.Type == 2 {
  6157. // advice_id = 0
  6158. // item_id = 0
  6159. //
  6160. // project_id = item.ProjectId
  6161. // } else if item.Type == 3 {
  6162. // advice_id = 0
  6163. // item_id = item.ItemId
  6164. // project_id = 0
  6165. // }
  6166. //
  6167. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6168. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6169. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6170. //
  6171. // info := &models.HisOrderInfo{
  6172. // OrderNumber: order.Number,
  6173. // UploadDate: time.Now().Unix(),
  6174. // AdviceId: advice_id,
  6175. // DetItemFeeSumamt: detItemFeeSumamt,
  6176. // Cnt: cut,
  6177. // Pric: pric,
  6178. // PatientId: id,
  6179. // Status: 1,
  6180. // Mtime: time.Now().Unix(),
  6181. // Ctime: time.Now().Unix(),
  6182. // UserOrgId: adminUser.CurrentOrgId,
  6183. // HisPatientId: his.ID,
  6184. // OrderId: order.ID,
  6185. // ProjectId: project_id,
  6186. // Type: types,
  6187. // ItemId: item_id,
  6188. // }
  6189. // service.CreateOrderInfo(info)
  6190. // }
  6191. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6192. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6193. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6194. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6195. // if err == nil {
  6196. // c.ServeSuccessJSON(map[string]interface{}{
  6197. // "msg": "结算成功",
  6198. // })
  6199. // } else {
  6200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6201. // return
  6202. // }
  6203. // }
  6204. //}
  6205. //上传明细-预结算-
  6206. func (c *HisApiController) GetPreUploadInfo() {
  6207. id, _ := c.GetInt64("id")
  6208. record_time := c.GetString("record_time")
  6209. his_patient_id, _ := c.GetInt64("his_patient_id")
  6210. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6211. admin_user_id, _ := c.GetInt64("admin_user_id")
  6212. diagnosis_id := c.GetString("diagnosis")
  6213. sick_type, _ := c.GetInt64("sick_type")
  6214. reg_type, _ := c.GetInt64("p_type")
  6215. begin_time := c.GetString("begin_time")
  6216. id_str := c.GetString("ids")
  6217. ids_arr := strings.Split(id_str, ",")
  6218. timeLayout := "2006-01-02"
  6219. loc, _ := time.LoadLocation("Local")
  6220. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6221. if err != nil {
  6222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6223. return
  6224. }
  6225. recordDateTime := theTime.Unix()
  6226. adminUser := c.GetAdminUserInfo()
  6227. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6228. var config []*models.HisXtDiagnoseConfig
  6229. for _, item := range diagnosis_ids {
  6230. id, _ := strconv.ParseInt(item, 10, 64)
  6231. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6232. config = append(config, &diagnosisConfig)
  6233. }
  6234. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6235. sickConfig, _ := service.FindSickById(sick_type)
  6236. var prescriptions []*models.HisPrescription
  6237. var start_time int64
  6238. var end_time int64
  6239. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6240. fmt.Println(his_patient_id)
  6241. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6242. timestamp := time.Now().Unix()
  6243. tempTime := time.Unix(timestamp, 0)
  6244. timeFormat := tempTime.Format("20060102150405")
  6245. chrgBchno := rand.Intn(100000) + 10000
  6246. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6247. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6248. var patientPrescription models.HisPrescriptionInfo
  6249. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6250. if patientPrescription.ID == 0 {
  6251. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6252. }
  6253. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6254. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6255. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6256. strconv.FormatInt(his.PatientId, 10)
  6257. var res2 ResultSix
  6258. var resSix10265 ResultSix10265
  6259. var time_stamp string
  6260. if miConfig.MdtrtareaAdmvs == "421300" {
  6261. data := make(map[string]interface{})
  6262. client := &http.Client{}
  6263. data["psn_no"] = his.PsnNo
  6264. data["mdtrt_id"] = his.Number
  6265. data["doctor"] = roles.UserName
  6266. data["department"] = department.Name
  6267. data["org_name"] = miConfig.OrgName
  6268. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6269. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6270. data["fixmedins_code"] = miConfig.Code
  6271. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6272. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6273. data["secret_key"] = miConfig.SecretKey
  6274. data["sick_code"] = sickConfig.CountryCode
  6275. data["sick_name"] = sickConfig.ClassName
  6276. data["begin_time"] = begin_time
  6277. data["dept"] = strconv.FormatInt(department.ID, 10)
  6278. data["config"] = config
  6279. fmt.Println(data)
  6280. bytesData, _ := json.Marshal(data)
  6281. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6282. resp, _ := client.Do(req)
  6283. defer resp.Body.Close()
  6284. body, ioErr := ioutil.ReadAll(resp.Body)
  6285. if ioErr != nil {
  6286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6288. return
  6289. }
  6290. var respJSON map[string]interface{}
  6291. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6294. return
  6295. }
  6296. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6297. userJSONBytes, _ := json.Marshal(respJSON)
  6298. fmt.Println("log")
  6299. fmt.Println(string(userJSONBytes))
  6300. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6301. utils.ErrorLog("解析失败:%v", err)
  6302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6303. return
  6304. }
  6305. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6306. //江苏地区国家医保医疗类别
  6307. //职工透析:医疗类别选特殊情况门诊9933
  6308. //居民血透门慢: 医疗类别选门诊慢病1402
  6309. //var med_type string
  6310. //if his.Insutype == "310" {
  6311. // if reg_type == 14 {
  6312. // med_type = "9933"
  6313. // } else if reg_type == 11 {
  6314. // med_type = "11"
  6315. //
  6316. // }
  6317. //} else if his.Insutype == "390" {
  6318. // if reg_type == 14 {
  6319. // med_type = "1402"
  6320. // } else if reg_type == 11 {
  6321. // med_type = "11"
  6322. // }
  6323. //}
  6324. data := make(map[string]interface{})
  6325. client := &http.Client{}
  6326. data["psn_no"] = his.PsnNo
  6327. data["mdtrt_id"] = his.Number
  6328. data["doctor"] = roles.UserName
  6329. data["department"] = department.Name
  6330. data["org_name"] = miConfig.OrgName
  6331. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6332. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6333. data["fixmedins_code"] = miConfig.Code
  6334. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6335. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6336. data["secret_key"] = miConfig.SecretKey
  6337. data["sick_code"] = sickConfig.CountryCode
  6338. data["sick_name"] = sickConfig.ClassName
  6339. data["begin_time"] = begin_time
  6340. data["dept"] = strconv.FormatInt(department.ID, 10)
  6341. data["config"] = config
  6342. data["url"] = miConfig.Url
  6343. data["ak"] = miConfig.AccessKey
  6344. data["cainfo"] = miConfig.Cainfo
  6345. bytesData, _ := json.Marshal(data)
  6346. var req *http.Request
  6347. if miConfig.MdtrtareaAdmvs == "320921" {
  6348. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6349. //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 +
  6350. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6351. } else {
  6352. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6353. }
  6354. resp, _ := client.Do(req)
  6355. defer resp.Body.Close()
  6356. body, ioErr := ioutil.ReadAll(resp.Body)
  6357. if ioErr != nil {
  6358. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6360. return
  6361. }
  6362. var respJSON map[string]interface{}
  6363. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6364. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6366. return
  6367. }
  6368. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6369. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6370. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6372. userJSONBytes, _ := json.Marshal(respJSON)
  6373. fmt.Println("log")
  6374. fmt.Println(string(userJSONBytes))
  6375. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6376. utils.ErrorLog("解析失败:%v", err)
  6377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6378. return
  6379. }
  6380. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6381. res2.Output = resSix10265.Output
  6382. res2.ErrMsg = resSix10265.ErrMsg
  6383. res2.Cainfo = resSix10265.Cainfo
  6384. res2.WarnMsg = resSix10265.WarnMsg
  6385. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6386. res2.Infcode = infocode
  6387. } else {
  6388. var result string
  6389. var requestLog string
  6390. if miConfig.MdtrtareaAdmvs == "440781" { //
  6391. 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)
  6392. } else {
  6393. if miConfig.Code == "H15049901371" {
  6394. //赤峰地区国家医保医疗类别
  6395. //职工透析:医疗类别选特殊情况门诊990502
  6396. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6397. var med_type string
  6398. if his.Insutype == "390" {
  6399. if reg_type == 14 {
  6400. med_type = "9933"
  6401. } else if reg_type == 11 {
  6402. med_type = "11"
  6403. }
  6404. } else if his.Insutype == "310" {
  6405. if reg_type == 14 {
  6406. med_type = "990502"
  6407. } else if reg_type == 11 {
  6408. med_type = "11"
  6409. }
  6410. }
  6411. 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)
  6412. } else {
  6413. 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)
  6414. }
  6415. saveLog(result, requestLog, "2203", "上传就诊信息")
  6416. var respJSON2 map[string]interface{}
  6417. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6420. return
  6421. }
  6422. userJSONBytes2, _ := json.Marshal(respJSON2)
  6423. if miConfig.Code == "H15049901371" {
  6424. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6425. utils.ErrorLog("解析失败:%v", err)
  6426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6427. return
  6428. }
  6429. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6430. res2.Output = resSix10265.Output
  6431. res2.ErrMsg = resSix10265.ErrMsg
  6432. res2.Cainfo = resSix10265.Cainfo
  6433. res2.WarnMsg = resSix10265.WarnMsg
  6434. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6435. res2.Infcode = infocode
  6436. } else {
  6437. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6438. utils.ErrorLog("解析失败:%v", err)
  6439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6440. return
  6441. }
  6442. }
  6443. }
  6444. }
  6445. if res2.Infcode != 0 {
  6446. adminUser := c.GetAdminUserInfo()
  6447. errlog := &models.HisOrderError{
  6448. UserOrgId: adminUser.CurrentOrgId,
  6449. Ctime: time.Now().Unix(),
  6450. Mtime: time.Now().Unix(),
  6451. ErrMsg: res2.ErrMsg,
  6452. Status: 1,
  6453. PatientId: id,
  6454. RecordTime: recordDateTime,
  6455. Stage: 3,
  6456. }
  6457. service.CreateErrMsgLog(errlog)
  6458. c.ServeSuccessJSON(map[string]interface{}{
  6459. "failed_code": -10,
  6460. "msg": res2.ErrMsg,
  6461. })
  6462. return
  6463. } else {
  6464. his.Diagnosis = diagnosis_id
  6465. his.SickType = sickConfig.ID
  6466. his.PType = fmt.Sprintf("%d", reg_type)
  6467. service.UpdateHisPatientThree(&his)
  6468. data := make(map[string]interface{})
  6469. if settle_accounts_type == 1 { //日结
  6470. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6471. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6472. } else {
  6473. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6474. }
  6475. data["pre"] = prescriptions
  6476. } else { //月结
  6477. start_time_str := c.GetString("start_time")
  6478. end_time_str := c.GetString("end_time")
  6479. timeLayout := "2006-01-02"
  6480. loc, _ := time.LoadLocation("Local")
  6481. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6482. if err != nil {
  6483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6484. return
  6485. }
  6486. recordStartTime := theStartTime.Unix()
  6487. start_time = recordStartTime
  6488. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6489. if err != nil {
  6490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6491. return
  6492. }
  6493. recordEndTime := theEndTime.Unix()
  6494. end_time = recordEndTime
  6495. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6496. data["pre"] = prescriptions
  6497. }
  6498. client := &http.Client{}
  6499. data["psn_no"] = his.PsnNo
  6500. data["mdtrt_id"] = his.Number
  6501. data["chrg_bchno"] = chrg_bchno
  6502. data["org_name"] = miConfig.OrgName
  6503. data["doctor"] = roles.UserName
  6504. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6505. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6506. data["fixmedins_code"] = miConfig.Code
  6507. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6508. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6509. data["dept_code"] = "15"
  6510. } else {
  6511. data["dept_code"] = department.Number
  6512. }
  6513. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6514. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6515. data["secret_key"] = miConfig.SecretKey
  6516. data["url"] = miConfig.Url
  6517. data["ak"] = miConfig.AccessKey
  6518. data["new_doctor_name"] = patientPrescription.Doctor
  6519. data["diag_code"] = sickConfig.CountryCode
  6520. data["time_stamp"] = time_stamp
  6521. data["cainfo"] = miConfig.Cainfo
  6522. var ids []int64
  6523. for _, item := range prescriptions {
  6524. ids = append(ids, item.ID)
  6525. }
  6526. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6527. if config.IsOpen == 1 { //对接了医保,走医保流程
  6528. var res ResultFour
  6529. var resFour10265 ResultFour10265
  6530. if miConfig.MdtrtareaAdmvs == "421300" {
  6531. bytesData, _ := json.Marshal(data)
  6532. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6533. resp, _ := client.Do(req)
  6534. defer resp.Body.Close()
  6535. body, ioErr := ioutil.ReadAll(resp.Body)
  6536. if ioErr != nil {
  6537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6539. return
  6540. }
  6541. var respJSON map[string]interface{}
  6542. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6545. return
  6546. }
  6547. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6548. userJSONBytes, _ := json.Marshal(respJSON)
  6549. fmt.Println("log")
  6550. fmt.Println(string(userJSONBytes))
  6551. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6552. utils.ErrorLog("解析失败:%v", err)
  6553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6554. return
  6555. }
  6556. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6557. bytesData, _ := json.Marshal(data)
  6558. var req *http.Request
  6559. if miConfig.MdtrtareaAdmvs == "320921" {
  6560. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6561. } else {
  6562. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6563. }
  6564. resp, _ := client.Do(req)
  6565. defer resp.Body.Close()
  6566. body, ioErr := ioutil.ReadAll(resp.Body)
  6567. if ioErr != nil {
  6568. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6570. return
  6571. }
  6572. var respJSON map[string]interface{}
  6573. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6576. return
  6577. }
  6578. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6579. userJSONBytes, _ := json.Marshal(respJSON)
  6580. fmt.Println("log")
  6581. fmt.Println(string(userJSONBytes))
  6582. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6583. utils.ErrorLog("解析失败:%v", err)
  6584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6585. return
  6586. }
  6587. res.InfRefmsgid = resFour10265.InfRefmsgid
  6588. res.Output = resFour10265.Output
  6589. res.ErrMsg = resFour10265.ErrMsg
  6590. res.Cainfo = resFour10265.Cainfo
  6591. res.WarnMsg = resFour10265.WarnMsg
  6592. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6593. res.Infcode = infocode
  6594. } else {
  6595. if miConfig.Code == "H15049901371" {
  6596. 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)
  6597. var dat map[string]interface{}
  6598. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6599. fmt.Println(dat)
  6600. } else {
  6601. fmt.Println(err)
  6602. }
  6603. saveLog(result, request_log, "2204", "上传费用明细")
  6604. userJSONBytes, _ := json.Marshal(dat)
  6605. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6606. utils.ErrorLog("解析失败:%v", err)
  6607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6608. return
  6609. }
  6610. res.InfRefmsgid = resFour10265.InfRefmsgid
  6611. res.Output = resFour10265.Output
  6612. res.ErrMsg = resFour10265.ErrMsg
  6613. res.Cainfo = resFour10265.Cainfo
  6614. res.WarnMsg = resFour10265.WarnMsg
  6615. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6616. res.Infcode = infocode
  6617. } else {
  6618. 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)
  6619. var dat map[string]interface{}
  6620. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6621. fmt.Println(dat)
  6622. } else {
  6623. fmt.Println(err)
  6624. }
  6625. saveLog(result, request_log, "2204", "上传费用明细")
  6626. userJSONBytes, _ := json.Marshal(dat)
  6627. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6628. utils.ErrorLog("解析失败:%v", err)
  6629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6630. return
  6631. }
  6632. }
  6633. }
  6634. if res.Infcode == 0 {
  6635. order := &models.HisOrder{
  6636. UserOrgId: adminUser.CurrentOrgId,
  6637. HisPatientId: his.ID,
  6638. PatientId: his.PatientId,
  6639. SettleAccountsDate: recordDateTime,
  6640. Ctime: time.Now().Unix(),
  6641. Mtime: time.Now().Unix(),
  6642. MdtrtId: his.Number,
  6643. PsnNo: his.PsnNo,
  6644. MedType: strconv.FormatInt(reg_type, 10),
  6645. Status: 1,
  6646. Number: chrg_bchno,
  6647. Infcode: res.Infcode,
  6648. WarnMsg: res.WarnMsg,
  6649. Cainfo: res.Cainfo,
  6650. ErrMsg: res.ErrMsg,
  6651. RespondTime: res.RefmsgTime,
  6652. InfRefmsgid: res.InfRefmsgid,
  6653. OrderStatus: 1,
  6654. IsMedicineInsurance: 1,
  6655. SettleType: settle_accounts_type,
  6656. SettleStartTime: start_time,
  6657. SettleEndTime: end_time,
  6658. Creator: roles.AdminUserId,
  6659. Modify: roles.AdminUserId,
  6660. PType: 2,
  6661. Diagnosis: diagnosis_id,
  6662. }
  6663. err = service.CreateOrder(order)
  6664. if err != nil {
  6665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6666. return
  6667. }
  6668. for _, item := range res.Output.Result {
  6669. temp := strings.Split(item.FeedetlSn, "-")
  6670. var advice_id int64 = 0
  6671. var project_id int64 = 0
  6672. var types int64 = 0
  6673. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6674. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6675. if temp[1] == "1" {
  6676. advice_id = id
  6677. project_id = 0
  6678. } else if temp[1] == "2" {
  6679. advice_id = 0
  6680. project_id = id
  6681. }
  6682. info := &models.HisOrderInfo{
  6683. OrderNumber: order.Number,
  6684. FeedetlSn: item.FeedetlSn,
  6685. UploadDate: time.Now().Unix(),
  6686. AdviceId: advice_id,
  6687. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6688. Cnt: item.Cnt,
  6689. Pric: float64(item.Pric),
  6690. PatientId: his.PatientId,
  6691. PricUplmtAmt: item.PricUplmtAmt,
  6692. SelfpayProp: item.SelfpayProp,
  6693. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6694. OverlmtAmt: item.OverlmtAmt,
  6695. PreselfpayAmt: item.PreselfpayAmt,
  6696. BasMednFlag: item.BasMednFlag,
  6697. MedChrgitmType: item.MedChrgitmType,
  6698. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6699. Status: 1,
  6700. Memo: item.Memo,
  6701. Mtime: time.Now().Unix(),
  6702. InscpScpAmt: item.InscpScpAmt,
  6703. DrtReimFlag: item.DrtReimFlag,
  6704. Ctime: time.Now().Unix(),
  6705. ListSpItemFlag: item.ListSpItemFlag,
  6706. ChldMedcFlag: item.ChldMedcFlag,
  6707. LmtUsedFlag: item.LmtUsedFlag,
  6708. ChrgitmLv: item.ChrgitmLv,
  6709. UserOrgId: adminUser.CurrentOrgId,
  6710. HisPatientId: his.ID,
  6711. OrderId: order.ID,
  6712. ProjectId: project_id,
  6713. Type: types,
  6714. }
  6715. service.CreateOrderInfo(info)
  6716. }
  6717. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6718. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6719. var total float64
  6720. for _, item := range prescriptions {
  6721. if item.Type == 1 { //药品
  6722. for _, subItem := range item.HisDoctorAdviceInfo {
  6723. total = total + (subItem.Price * subItem.PrescribingNumber)
  6724. }
  6725. }
  6726. if item.Type == 2 { //项目
  6727. for _, subItem := range item.HisPrescriptionProject {
  6728. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6729. total = total + (subItem.Price * cnt)
  6730. }
  6731. }
  6732. }
  6733. for _, item := range prescriptions {
  6734. for _, subItem := range item.HisAdditionalCharge {
  6735. total = total + (subItem.Price * float64(subItem.Count))
  6736. }
  6737. }
  6738. allTotal := fmt.Sprintf("%.4f", total)
  6739. if res.Infcode == 0 {
  6740. var rf []*ResultFive
  6741. json.Unmarshal([]byte(his.Iinfo), &rf)
  6742. chrg_bchno := chrg_bchno
  6743. cert_no := his.Certno
  6744. var insutypes []string
  6745. var insutype string
  6746. var is390 int = 0
  6747. var is310 int = 0
  6748. for _, item := range rf {
  6749. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6750. insutypes = append(insutypes, item.Insutype)
  6751. }
  6752. }
  6753. if len(insutypes) == 1 {
  6754. insutype = insutypes[0]
  6755. } else {
  6756. for _, i := range insutypes {
  6757. if i == "390" {
  6758. is390 = 1
  6759. }
  6760. if i == "310" {
  6761. is310 = 1
  6762. }
  6763. }
  6764. }
  6765. if is390 == 1 {
  6766. insutype = "390"
  6767. }
  6768. if is310 == 1 {
  6769. insutype = "310"
  6770. }
  6771. if len(insutypes) == 0 {
  6772. insutype = "310"
  6773. }
  6774. if len(insutypes) == 2 {
  6775. insutype = strconv.FormatInt(his.SocialType, 64)
  6776. }
  6777. //insutype = "390"
  6778. if his.IdCardType == 1 {
  6779. cert_no = his.MedicalInsuranceNumber
  6780. } else {
  6781. cert_no = his.Certno
  6782. }
  6783. var res ResultSeven
  6784. var resSeven10265 ResultSeven10265
  6785. if miConfig.MdtrtareaAdmvs == "421300" {
  6786. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6787. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6788. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6789. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6790. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6791. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6792. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6793. resp, requestErr := http.Get(api)
  6794. if requestErr != nil {
  6795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6796. return
  6797. }
  6798. body, ioErr := ioutil.ReadAll(resp.Body)
  6799. if ioErr != nil {
  6800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6802. return
  6803. }
  6804. var respJSON map[string]interface{}
  6805. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6808. return
  6809. }
  6810. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6811. result, _ := json.Marshal(respJSON)
  6812. fmt.Println("log")
  6813. fmt.Println(string(result))
  6814. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6815. utils.ErrorLog("解析失败:%v", err)
  6816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6817. return
  6818. }
  6819. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6820. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6821. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6822. bas := strings.Split(psn_info.CardInfo, "|")
  6823. if his.IdCardType == 1 {
  6824. cert_no = bas[2]
  6825. } else {
  6826. cert_no = bas[1]
  6827. }
  6828. //江苏地区国家医保医疗类别
  6829. //职工透析:医疗类别选特殊情况门诊9933
  6830. //居民血透门慢: 医疗类别选门诊慢病1402
  6831. //var med_type string
  6832. //if his.Insutype == "310" {
  6833. // if reg_type == 14 {
  6834. // med_type = "9933"
  6835. // } else if reg_type == 11 {
  6836. // med_type = "11"
  6837. //
  6838. // }
  6839. //} else if his.Insutype == "390" {
  6840. // if reg_type == 14 {
  6841. // med_type = "1402"
  6842. // } else if reg_type == 11 {
  6843. // med_type = "11"
  6844. // }
  6845. //}
  6846. var api string
  6847. if miConfig.MdtrtareaAdmvs == "320921" {
  6848. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6849. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6850. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6851. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6852. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6853. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6854. "&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
  6855. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6856. } else {
  6857. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6858. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6859. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6860. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6861. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6862. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6863. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6864. "&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
  6865. }
  6866. resp, requestErr := http.Get(api)
  6867. if requestErr != nil {
  6868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6869. return
  6870. }
  6871. body, ioErr := ioutil.ReadAll(resp.Body)
  6872. if ioErr != nil {
  6873. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6875. return
  6876. }
  6877. var respJSON map[string]interface{}
  6878. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6881. return
  6882. }
  6883. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6884. result, _ := json.Marshal(respJSON)
  6885. fmt.Println("log")
  6886. fmt.Println(string(result))
  6887. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6888. utils.ErrorLog("解析失败:%v", err)
  6889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6890. return
  6891. }
  6892. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6893. res.Output = resSeven10265.Output
  6894. res.ErrMsg = resSeven10265.ErrMsg
  6895. res.Cainfo = resSeven10265.Cainfo
  6896. res.WarnMsg = resSeven10265.WarnMsg
  6897. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6898. res.Infcode = infocode
  6899. } else {
  6900. var result string
  6901. var request_log string
  6902. if miConfig.Code == "H15049901371" {
  6903. //赤峰地区国家医保医疗类别
  6904. //职工透析:医疗类别选特殊情况门诊990502
  6905. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6906. var med_type string
  6907. if his.Insutype == "390" {
  6908. if reg_type == 14 {
  6909. med_type = "9933"
  6910. } else if reg_type == 11 {
  6911. med_type = "11"
  6912. }
  6913. } else if his.Insutype == "310" {
  6914. if reg_type == 14 {
  6915. med_type = "990502"
  6916. } else if reg_type == 11 {
  6917. med_type = "11"
  6918. }
  6919. }
  6920. 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)
  6921. } else {
  6922. 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)
  6923. }
  6924. var dat map[string]interface{}
  6925. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6926. fmt.Println(dat)
  6927. } else {
  6928. fmt.Println(err)
  6929. }
  6930. saveLog(result, request_log, "2206", "预结算")
  6931. //userJSONBytes, _ := json.Marshal(dat)
  6932. //
  6933. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6934. // utils.ErrorLog("解析失败:%v", err)
  6935. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6936. // return
  6937. //}
  6938. userJSONBytes, _ := json.Marshal(dat)
  6939. if miConfig.Code == "H15049901371" {
  6940. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6941. utils.ErrorLog("解析失败:%v", err)
  6942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6943. return
  6944. }
  6945. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6946. res.Output = resSeven10265.Output
  6947. res.ErrMsg = resSeven10265.ErrMsg
  6948. res.Cainfo = resSeven10265.Cainfo
  6949. res.WarnMsg = resSeven10265.WarnMsg
  6950. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6951. res.Infcode = infocode
  6952. } else {
  6953. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6954. utils.ErrorLog("解析失败:%v", err)
  6955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6956. return
  6957. }
  6958. }
  6959. }
  6960. if res.Infcode != 0 {
  6961. errlog := &models.HisOrderError{
  6962. UserOrgId: adminUser.CurrentOrgId,
  6963. Ctime: time.Now().Unix(),
  6964. Mtime: time.Now().Unix(),
  6965. Number: chrg_bchno,
  6966. ErrMsg: res.ErrMsg,
  6967. Status: 1,
  6968. PatientId: id,
  6969. RecordTime: recordDateTime,
  6970. Stage: 20,
  6971. }
  6972. service.CreateErrMsgLog(errlog)
  6973. c.ServeSuccessJSON(map[string]interface{}{
  6974. "failed_code": -10,
  6975. "msg": res.ErrMsg,
  6976. })
  6977. return
  6978. } else {
  6979. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6980. order.OrderStatus = 1
  6981. order.IsPre = 1
  6982. order.Status = 1
  6983. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6984. order.SetlId = res.Output.Setlinfo.SetlID
  6985. order.PsnNo = res.Output.Setlinfo.PsnNo
  6986. order.PsnName = res.Output.Setlinfo.PsnName
  6987. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6988. order.Certno = res.Output.Setlinfo.Certno
  6989. order.Gend = res.Output.Setlinfo.Gend
  6990. order.Naty = res.Output.Setlinfo.Naty
  6991. order.Age = res.Output.Setlinfo.Age
  6992. order.Insutype = res.Output.Setlinfo.Insutype
  6993. order.PsnType = res.Output.Setlinfo.PsnType
  6994. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6995. order.SetlTime = res.Output.Setlinfo.SetlTime
  6996. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6997. if res.Output.Setlinfo.MedType == "140101" {
  6998. order.MedType = "14"
  6999. } else {
  7000. order.MedType = res.Output.Setlinfo.MedType
  7001. }
  7002. if reg_type == 1112 {
  7003. order.MedType = "1112"
  7004. }
  7005. if reg_type == 1111 {
  7006. order.MedType = "1111"
  7007. }
  7008. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7009. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7010. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7011. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7012. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7013. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7014. order.HifpPay = res.Output.Setlinfo.HifpPay
  7015. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7016. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7017. order.HifesPay = res.Output.Setlinfo.HifesPay
  7018. order.HifobPay = res.Output.Setlinfo.HifobPay
  7019. order.MafPay = res.Output.Setlinfo.MafPay
  7020. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7021. order.OthPay = res.Output.Setlinfo.OthPay
  7022. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7023. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7024. order.AcctPay = res.Output.Setlinfo.AcctPay
  7025. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7026. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7027. order.Balc = res.Output.Setlinfo.Balc
  7028. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7029. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7030. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7031. order.ClrWay = res.Output.Setlinfo.ClrWay
  7032. order.Creator = order.Creator
  7033. order.Modify = roles.AdminUserId
  7034. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7035. detailStr := string(setlDetail)
  7036. order.SetlDetail = detailStr
  7037. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7038. err = service.UpDateOrder(order)
  7039. if err == nil {
  7040. c.ServeSuccessJSON(map[string]interface{}{
  7041. "msg": "预结算成功",
  7042. })
  7043. } else {
  7044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7045. return
  7046. }
  7047. }
  7048. } else {
  7049. adminUser := c.GetAdminUserInfo()
  7050. errlog := &models.HisOrderError{
  7051. UserOrgId: adminUser.CurrentOrgId,
  7052. Ctime: time.Now().Unix(),
  7053. Mtime: time.Now().Unix(),
  7054. ErrMsg: res.ErrMsg,
  7055. Status: 1,
  7056. PatientId: id,
  7057. RecordTime: recordDateTime,
  7058. Stage: 4,
  7059. }
  7060. service.CreateErrMsgLog(errlog)
  7061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7062. return
  7063. }
  7064. } else {
  7065. adminUser := c.GetAdminUserInfo()
  7066. errlog := &models.HisOrderError{
  7067. UserOrgId: adminUser.CurrentOrgId,
  7068. Ctime: time.Now().Unix(),
  7069. Mtime: time.Now().Unix(),
  7070. ErrMsg: res.ErrMsg,
  7071. Status: 1,
  7072. PatientId: id,
  7073. RecordTime: recordDateTime,
  7074. Stage: 4,
  7075. }
  7076. service.CreateErrMsgLog(errlog)
  7077. c.ServeSuccessJSON(map[string]interface{}{
  7078. "failed_code": -10,
  7079. "msg": res.ErrMsg,
  7080. })
  7081. return
  7082. }
  7083. }
  7084. }
  7085. }
  7086. //func (c *HisApiController) GetSettleInfo() {
  7087. // id, _ := c.GetInt64("id")
  7088. // order_id, _ := c.GetInt64("order_id")
  7089. //
  7090. // record_time := c.GetString("record_time")
  7091. // pay_way, _ := c.GetInt64("pay_way")
  7092. // pay_price, _ := c.GetFloat("pay_price")
  7093. // pay_card_no := c.GetString("pay_card_no")
  7094. // discount_price, _ := c.GetFloat("discount_price")
  7095. // preferential_price, _ := c.GetFloat("preferential_price")
  7096. // reality_price, _ := c.GetFloat("reality_price")
  7097. // found_price, _ := c.GetFloat("found_price")
  7098. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7099. // private_price, _ := c.GetFloat("private_price")
  7100. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7101. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7102. //
  7103. // timeLayout := "2006-01-02"
  7104. // loc, _ := time.LoadLocation("Local")
  7105. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7106. // if err != nil {
  7107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7108. // return
  7109. // }
  7110. // recordDateTime := theTime.Unix()
  7111. // adminUser := c.GetAdminUserInfo()
  7112. //
  7113. // var prescriptions []*models.HisPrescription
  7114. //
  7115. // data := make(map[string]interface{})
  7116. // if settle_accounts_type == 1 { //日结
  7117. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7118. // data["pre"] = prescriptions
  7119. //
  7120. // } else { //月结
  7121. // start_time_str := c.GetString("start_time")
  7122. // end_time_str := c.GetString("end_time")
  7123. // timeLayout := "2006-01-02"
  7124. // loc, _ := time.LoadLocation("Local")
  7125. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7126. // if err != nil {
  7127. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7128. // return
  7129. // }
  7130. // recordStartTime := theStartTime.Unix()
  7131. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7132. // if err != nil {
  7133. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7134. // return
  7135. // }
  7136. // recordEndTime := theEndTime.Unix()
  7137. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7138. // data["pre"] = prescriptions
  7139. //
  7140. // }
  7141. //
  7142. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7143. //
  7144. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7145. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7146. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7147. // strconv.FormatInt(his.PatientId, 10)
  7148. //
  7149. // order_src, _ := service.GetHisOrderByID(order_id)
  7150. //
  7151. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7152. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7153. //
  7154. // var total float64
  7155. // for _, item := range prescriptions {
  7156. // if item.Type == 1 { //药品
  7157. // for _, subItem := range item.HisDoctorAdviceInfo {
  7158. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7159. // }
  7160. // }
  7161. // if item.Type == 2 { //项目
  7162. // for _, subItem := range item.HisPrescriptionProject {
  7163. // total = total + (subItem.Price * float64(subItem.Count))
  7164. // }
  7165. // }
  7166. // }
  7167. //
  7168. // for _, item := range prescriptions {
  7169. // for _, subItem := range item.HisAdditionalCharge {
  7170. // total = total + (subItem.Price * float64(subItem.Count))
  7171. // }
  7172. // }
  7173. //
  7174. // allTotal := fmt.Sprintf("%.2f", total)
  7175. // var rf []*ResultFive
  7176. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7177. // psn_no := order_src.PsnNo
  7178. // mdtrt_id := order_src.MdtrtId
  7179. // chrg_bchno := order_src.Number
  7180. // cert_no := order_src.Certno
  7181. // insutype := rf[0].Insutype
  7182. //
  7183. // if his.IdCardType == 1 {
  7184. // cert_no = his.MedicalInsuranceNumber
  7185. // } else {
  7186. // cert_no = his.Certno
  7187. // }
  7188. //
  7189. // 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)
  7190. // var dat map[string]interface{}
  7191. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7192. // fmt.Println(dat)
  7193. // } else {
  7194. // fmt.Println(err)
  7195. // }
  7196. //
  7197. // userJSONBytes, _ := json.Marshal(dat)
  7198. //
  7199. //
  7200. //
  7201. // var res ResultSeven
  7202. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7203. // utils.ErrorLog("解析失败:%v", err)
  7204. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7205. // return
  7206. // }
  7207. // if res.Infcode == -1 {
  7208. // errlog := &models.HisOrderError{
  7209. // UserOrgId: adminUser.CurrentOrgId,
  7210. // Ctime: time.Now().Unix(),
  7211. // Mtime: time.Now().Unix(),
  7212. // Number: chrg_bchno,
  7213. // ErrMsg: res.ErrMsg,
  7214. // Status: 1,
  7215. // PatientId: id,
  7216. // RecordTime: recordDateTime,
  7217. // Stage: 6,
  7218. // }
  7219. // service.CreateErrMsgLog(errlog)
  7220. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7221. // return
  7222. // } else {
  7223. // order_src.OrderStatus = 2
  7224. // order_src.PayWay = pay_way
  7225. // order_src.PayPrice = pay_price
  7226. // order_src.PayCardNo = pay_card_no
  7227. // order_src.DiscountPrice = discount_price
  7228. // order_src.PreferentialPrice = preferential_price
  7229. // order_src.RealityPrice = reality_price
  7230. // order_src.FoundPrice = found_price
  7231. // order_src.MedicalInsurancePrice = medical_insurance_price
  7232. // order_src.PrivatePrice = private_price
  7233. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7234. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7235. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7236. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7237. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7238. // order_src.Certno = res.Output.Setlinfo.Certno
  7239. // order_src.Gend = res.Output.Setlinfo.Gend
  7240. // order_src.Naty = res.Output.Setlinfo.Naty
  7241. // order_src.Age = res.Output.Setlinfo.Age
  7242. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7243. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7244. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7245. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7246. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7247. // order_src.MedType = res.Output.Setlinfo.MedType
  7248. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7249. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7250. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7251. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7252. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7253. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7254. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7255. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7256. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7257. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7258. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7259. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7260. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7261. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7262. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7263. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7264. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7265. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7266. // order_src.Balc = res.Output.Setlinfo.Balc
  7267. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7268. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7269. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7270. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7271. // order_src.Creator = order_src.Creator
  7272. // order_src.Modify = roles.ID
  7273. // order_src.RequestLog = src_resquest
  7274. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7275. // detailStr := string(setlDetail)
  7276. // order_src.SetlDetail = detailStr
  7277. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7278. // err = service.UpDateOrder(order_src)
  7279. //
  7280. // if err == nil {
  7281. // c.ServeSuccessJSON(map[string]interface{}{
  7282. // "msg": "结算成功",
  7283. // })
  7284. // } else {
  7285. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7286. // return
  7287. // }
  7288. // }
  7289. // }
  7290. //}
  7291. //退款
  7292. func (c *HisApiController) Refund() {
  7293. order_id, _ := c.GetInt64("order_id")
  7294. admin_user_id, _ := c.GetInt64("admin_user_id")
  7295. adminUser := c.GetAdminUserInfo()
  7296. var order models.HisOrder
  7297. order, _ = service.GetHisOrderByID(order_id)
  7298. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7299. if order.ID == 0 {
  7300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7301. return
  7302. }
  7303. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7304. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7305. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7306. if config.IsOpen == 1 { //对接了医保,走医保流程
  7307. var res ResultSixteen
  7308. var resSixteen10265 ResultSixteen10265
  7309. var src_resquest string
  7310. var result string
  7311. if miConfig.MdtrtareaAdmvs == "421300" {
  7312. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7313. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7314. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7315. resp3, requestErr3 := http.Get(api3)
  7316. if requestErr3 != nil {
  7317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7318. return
  7319. }
  7320. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7321. if ioErr3 != nil {
  7322. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7324. return
  7325. }
  7326. var respJSON3 map[string]interface{}
  7327. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7328. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7330. return
  7331. }
  7332. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7333. userJSONBytes3, _ := json.Marshal(respJSON3)
  7334. fmt.Println("log")
  7335. fmt.Println(string(userJSONBytes3))
  7336. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7337. utils.ErrorLog("解析失败:%v", err)
  7338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7339. return
  7340. }
  7341. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7342. var api3 string
  7343. if miConfig.MdtrtareaAdmvs == "320921" {
  7344. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7345. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7346. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7347. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7348. } else {
  7349. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7350. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7351. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7352. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7353. }
  7354. resp3, requestErr3 := http.Get(api3)
  7355. if requestErr3 != nil {
  7356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7357. return
  7358. }
  7359. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7360. if ioErr3 != nil {
  7361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7363. return
  7364. }
  7365. var respJSON3 map[string]interface{}
  7366. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7369. return
  7370. }
  7371. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7372. userJSONBytes3, _ := json.Marshal(respJSON3)
  7373. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7374. utils.ErrorLog("解析失败:%v", err)
  7375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7376. return
  7377. }
  7378. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7379. res.Output = resSixteen10265.Output
  7380. res.ErrMsg = resSixteen10265.ErrMsg
  7381. res.Cainfo = resSixteen10265.Cainfo
  7382. res.WarnMsg = resSixteen10265.WarnMsg
  7383. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7384. res.Infcode = infocode
  7385. } else {
  7386. if miConfig.Code == "H15049901371" {
  7387. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7388. var dat map[string]interface{}
  7389. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7390. fmt.Println(dat)
  7391. } else {
  7392. fmt.Println(err)
  7393. }
  7394. saveLog(result, src_resquest, "2208", "退费")
  7395. userJSONBytes, _ := json.Marshal(dat)
  7396. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7397. utils.ErrorLog("解析失败:%v", err)
  7398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7399. return
  7400. }
  7401. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7402. res.Output = resSixteen10265.Output
  7403. res.ErrMsg = resSixteen10265.ErrMsg
  7404. res.Cainfo = resSixteen10265.Cainfo
  7405. res.WarnMsg = resSixteen10265.WarnMsg
  7406. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7407. res.Infcode = infocode
  7408. } else {
  7409. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7410. var dat map[string]interface{}
  7411. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7412. fmt.Println(dat)
  7413. } else {
  7414. fmt.Println(err)
  7415. }
  7416. saveLog(result, src_resquest, "2208", "退费")
  7417. userJSONBytes, _ := json.Marshal(dat)
  7418. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7419. utils.ErrorLog("解析失败:%v", err)
  7420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7421. return
  7422. }
  7423. }
  7424. }
  7425. if res.Infcode == 0 {
  7426. var res2 ResultSix
  7427. var resSix10265 ResultSix10265
  7428. if miConfig.MdtrtareaAdmvs == "421300" {
  7429. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7430. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7431. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7432. resp3, requestErr3 := http.Get(api3)
  7433. if requestErr3 != nil {
  7434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7435. return
  7436. }
  7437. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7438. if ioErr3 != nil {
  7439. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7441. return
  7442. }
  7443. var respJSON3 map[string]interface{}
  7444. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7445. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7447. return
  7448. }
  7449. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7450. userJSONBytes3, _ := json.Marshal(respJSON3)
  7451. fmt.Println("log")
  7452. fmt.Println(string(userJSONBytes3))
  7453. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7454. utils.ErrorLog("解析失败:%v", err)
  7455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7456. return
  7457. }
  7458. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7459. var api3 string
  7460. if miConfig.MdtrtareaAdmvs == "320921" {
  7461. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7462. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7463. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7464. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7465. } else {
  7466. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7467. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7468. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7469. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7470. }
  7471. resp3, requestErr3 := http.Get(api3)
  7472. if requestErr3 != nil {
  7473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7474. return
  7475. }
  7476. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7477. if ioErr3 != nil {
  7478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7480. return
  7481. }
  7482. var respJSON3 map[string]interface{}
  7483. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7486. return
  7487. }
  7488. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7489. userJSONBytes3, _ := json.Marshal(respJSON3)
  7490. fmt.Println("log")
  7491. fmt.Println(string(userJSONBytes3))
  7492. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7493. utils.ErrorLog("解析失败:%v", err)
  7494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7495. return
  7496. }
  7497. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7498. res2.Output = resSix10265.Output
  7499. res2.ErrMsg = resSix10265.ErrMsg
  7500. res2.Cainfo = resSix10265.Cainfo
  7501. res2.WarnMsg = resSix10265.WarnMsg
  7502. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7503. res2.Infcode = infocode
  7504. } else {
  7505. if miConfig.Code == "H15049901371" {
  7506. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7507. var dat map[string]interface{}
  7508. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7509. fmt.Println(dat)
  7510. } else {
  7511. fmt.Println(err)
  7512. }
  7513. saveLog(result2, src_request, "2205", "撤销明细")
  7514. userJSONBytes, _ := json.Marshal(dat)
  7515. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7516. utils.ErrorLog("解析失败:%v", err)
  7517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7518. return
  7519. }
  7520. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7521. res2.Output = resSix10265.Output
  7522. res2.ErrMsg = resSix10265.ErrMsg
  7523. res2.Cainfo = resSix10265.Cainfo
  7524. res2.WarnMsg = resSix10265.WarnMsg
  7525. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7526. res2.Infcode = infocode
  7527. } else {
  7528. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7529. var dat map[string]interface{}
  7530. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7531. fmt.Println(dat)
  7532. } else {
  7533. fmt.Println(err)
  7534. }
  7535. saveLog(result2, src_request, "2205", "撤销明细")
  7536. userJSONBytes, _ := json.Marshal(dat)
  7537. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7538. utils.ErrorLog("解析失败:%v", err)
  7539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7540. return
  7541. }
  7542. }
  7543. }
  7544. if res2.Infcode == 0 {
  7545. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7546. if err == nil {
  7547. c.ServeSuccessJSON(map[string]interface{}{
  7548. "msg": "退费成功",
  7549. })
  7550. } else {
  7551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7552. return
  7553. }
  7554. } else {
  7555. c.ServeSuccessJSON(map[string]interface{}{
  7556. "code": -10,
  7557. "msg": res2.ErrMsg,
  7558. })
  7559. }
  7560. } else {
  7561. c.ServeSuccessJSON(map[string]interface{}{
  7562. "code": -10,
  7563. "msg": res.ErrMsg,
  7564. })
  7565. }
  7566. }
  7567. }
  7568. func (c *HisApiController) RefundNumber() {
  7569. record_time := c.GetString("record_time")
  7570. //patient_id, _ := c.GetInt64("patient_id")
  7571. admin_user_id, _ := c.GetInt64("admin_user_id")
  7572. his_patient_id, _ := c.GetInt64("id")
  7573. timeLayout := "2006-01-02"
  7574. loc, _ := time.LoadLocation("Local")
  7575. adminUser := c.GetAdminUserInfo()
  7576. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7577. fmt.Println(err)
  7578. if err != nil {
  7579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7580. return
  7581. }
  7582. recordDateTime := theTime.Unix()
  7583. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7584. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7585. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7586. //order, _ := service.GetHisOrderByID(order_id)
  7587. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7588. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7589. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7590. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7591. if count > 0 {
  7592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7593. return
  7594. }
  7595. if config.IsOpen == 1 { //对接了医保,走医保流程
  7596. var res2 ResultSix
  7597. var resSix10265 ResultSix10265
  7598. if miConfig.MdtrtareaAdmvs == "421300" {
  7599. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7600. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7601. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7602. resp3, requestErr3 := http.Get(api3)
  7603. if requestErr3 != nil {
  7604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7605. return
  7606. }
  7607. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7608. if ioErr3 != nil {
  7609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7611. return
  7612. }
  7613. var respJSON3 map[string]interface{}
  7614. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7617. return
  7618. }
  7619. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7620. userJSONBytes3, _ := json.Marshal(respJSON3)
  7621. fmt.Println("log")
  7622. fmt.Println(string(userJSONBytes3))
  7623. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7624. utils.ErrorLog("解析失败:%v", err)
  7625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7626. return
  7627. }
  7628. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7629. var api3 string
  7630. if miConfig.MdtrtareaAdmvs == "320921" {
  7631. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7632. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7633. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7634. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7635. } else {
  7636. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7637. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7638. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7639. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7640. }
  7641. resp3, requestErr3 := http.Get(api3)
  7642. if requestErr3 != nil {
  7643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7644. return
  7645. }
  7646. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7647. if ioErr3 != nil {
  7648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7650. return
  7651. }
  7652. var respJSON3 map[string]interface{}
  7653. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7656. return
  7657. }
  7658. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7659. userJSONBytes3, _ := json.Marshal(respJSON3)
  7660. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7661. utils.ErrorLog("解析失败:%v", err)
  7662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7663. return
  7664. }
  7665. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7666. res2.Output = resSix10265.Output
  7667. res2.ErrMsg = resSix10265.ErrMsg
  7668. res2.Cainfo = resSix10265.Cainfo
  7669. res2.WarnMsg = resSix10265.WarnMsg
  7670. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7671. res2.Infcode = infocode
  7672. } else {
  7673. var api3 string
  7674. if miConfig.Code == "H15049901371" {
  7675. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7676. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7677. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7678. } else {
  7679. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7680. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7681. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7682. }
  7683. resp3, requestErr3 := http.Get(api3)
  7684. if requestErr3 != nil {
  7685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7686. return
  7687. }
  7688. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7689. if ioErr3 != nil {
  7690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7692. return
  7693. }
  7694. var respJSON3 map[string]interface{}
  7695. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7698. return
  7699. }
  7700. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7701. userJSONBytes3, _ := json.Marshal(respJSON3)
  7702. if miConfig.Code == "H15049901371" {
  7703. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7704. utils.ErrorLog("解析失败:%v", err)
  7705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7706. return
  7707. }
  7708. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7709. res2.Output = resSix10265.Output
  7710. res2.ErrMsg = resSix10265.ErrMsg
  7711. res2.Cainfo = resSix10265.Cainfo
  7712. res2.WarnMsg = resSix10265.WarnMsg
  7713. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7714. res2.Infcode = infocode
  7715. } else {
  7716. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7717. utils.ErrorLog("解析失败:%v", err)
  7718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7719. return
  7720. }
  7721. }
  7722. }
  7723. if res2.Infcode == 0 {
  7724. if err == nil {
  7725. c.ServeSuccessJSON(map[string]interface{}{
  7726. "msg": "退号成功",
  7727. })
  7728. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7729. } else {
  7730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7731. return
  7732. }
  7733. } else {
  7734. c.ServeSuccessJSON(map[string]interface{}{
  7735. "code": -10,
  7736. "msg": res2.ErrMsg,
  7737. })
  7738. }
  7739. } else {
  7740. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7741. //if err == nil {
  7742. // c.ServeSuccessJSON(map[string]interface{}{
  7743. // "msg": "退费成功",
  7744. // })
  7745. //} else {
  7746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7747. // return
  7748. //}
  7749. }
  7750. }
  7751. func (c *HisApiController) RefundDetail() {
  7752. order_id, _ := c.GetInt64("order_id")
  7753. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7754. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7755. number := c.GetString("number")
  7756. record_time := c.GetString("record_time")
  7757. patient_id, _ := c.GetInt64("patient_id")
  7758. //med_type, _ := c.GetInt64("med_type")
  7759. timeLayout := "2006-01-02"
  7760. loc, _ := time.LoadLocation("Local")
  7761. adminUser := c.GetAdminUserInfo()
  7762. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7763. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7764. fmt.Println(err)
  7765. if err != nil {
  7766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7767. return
  7768. }
  7769. recordDateTime := theTime.Unix()
  7770. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7771. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7772. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7773. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7774. var order models.HisOrder
  7775. order, _ = service.GetHisOrderByID(order_id)
  7776. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7777. if config.IsOpen == 1 { //对接了医保,走医保流程
  7778. var res2 ResultSix
  7779. if miConfig.MdtrtareaAdmvs == "421300" {
  7780. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7781. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7782. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7783. resp3, requestErr3 := http.Get(api3)
  7784. if requestErr3 != nil {
  7785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7786. return
  7787. }
  7788. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7789. if ioErr3 != nil {
  7790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7792. return
  7793. }
  7794. var respJSON3 map[string]interface{}
  7795. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7798. return
  7799. }
  7800. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7801. userJSONBytes3, _ := json.Marshal(respJSON3)
  7802. fmt.Println("log")
  7803. fmt.Println(string(userJSONBytes3))
  7804. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7805. utils.ErrorLog("解析失败:%v", err)
  7806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7807. return
  7808. }
  7809. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7810. if err == nil {
  7811. c.ServeSuccessJSON(map[string]interface{}{
  7812. "msg": "撤销明细成功",
  7813. })
  7814. return
  7815. } else {
  7816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7817. return
  7818. }
  7819. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7820. var resSix10265 ResultSix10265
  7821. var api3 string
  7822. if miConfig.MdtrtareaAdmvs == "320921" {
  7823. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7824. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7825. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7826. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7827. } else {
  7828. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7829. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7830. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7831. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7832. }
  7833. resp3, requestErr3 := http.Get(api3)
  7834. if requestErr3 != nil {
  7835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7836. return
  7837. }
  7838. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7839. if ioErr3 != nil {
  7840. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7842. return
  7843. }
  7844. var respJSON3 map[string]interface{}
  7845. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7848. return
  7849. }
  7850. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7851. userJSONBytes3, _ := json.Marshal(respJSON3)
  7852. fmt.Println("log")
  7853. fmt.Println(string(userJSONBytes3))
  7854. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7855. utils.ErrorLog("解析失败:%v", err)
  7856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7857. return
  7858. }
  7859. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7860. res2.Output = resSix10265.Output
  7861. res2.ErrMsg = resSix10265.ErrMsg
  7862. res2.Cainfo = resSix10265.Cainfo
  7863. res2.WarnMsg = resSix10265.WarnMsg
  7864. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7865. res2.Infcode = infocode
  7866. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7867. if err == nil {
  7868. c.ServeSuccessJSON(map[string]interface{}{
  7869. "msg": "撤销明细成功",
  7870. })
  7871. return
  7872. } else {
  7873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7874. return
  7875. }
  7876. } else {
  7877. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7878. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7879. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7880. resp2, requestErr2 := http.Get(api2)
  7881. if requestErr2 != nil {
  7882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7883. return
  7884. }
  7885. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7886. if ioErr2 != nil {
  7887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7889. return
  7890. }
  7891. var respJSON2 map[string]interface{}
  7892. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7895. return
  7896. }
  7897. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7898. if err == nil {
  7899. c.ServeSuccessJSON(map[string]interface{}{
  7900. "msg": "撤销明细成功",
  7901. })
  7902. return
  7903. } else {
  7904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7905. return
  7906. }
  7907. }
  7908. } else {
  7909. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7910. if err == nil {
  7911. c.ServeSuccessJSON(map[string]interface{}{
  7912. "msg": "退费成功",
  7913. })
  7914. } else {
  7915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7916. return
  7917. }
  7918. }
  7919. }
  7920. //对账
  7921. func (c *HisApiController) GetCheckAccount() {
  7922. start_time := c.GetString("start_time")
  7923. end_time := c.GetString("end_time")
  7924. insutype := c.GetString("insutype")
  7925. clr_type := c.GetString("clr_type")
  7926. clr_org := c.GetString("clr_optins")
  7927. admin_user_id, _ := c.GetInt64("admin_user_id")
  7928. adminUser := c.GetAdminUserInfo()
  7929. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7930. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7931. if len(clr_org) == 0 {
  7932. clr_org = miConfig.MdtrtareaAdmvs
  7933. }
  7934. timeLayout := "2006-01-02"
  7935. loc, _ := time.LoadLocation("Local")
  7936. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7937. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7938. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7939. fixmedins_setl_cnt := int64(len(orders))
  7940. var medfee_sumamt float64
  7941. var acct_pay float64
  7942. var fund_pay_sumamt float64
  7943. for _, item := range orders {
  7944. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7945. acct_pay = acct_pay + item.AcctPay
  7946. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7947. }
  7948. var user_name string
  7949. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7950. if role.ID == 0 {
  7951. user_name = "xxx"
  7952. } else {
  7953. user_name = role.UserName
  7954. }
  7955. var res ResultEight
  7956. var res10188 ResultEightFor10188
  7957. if config.IsOpen == 1 {
  7958. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7959. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7960. "insutype=" + insutype +
  7961. "&clr_type=" + "11" +
  7962. "&setl_optins=" + clr_org +
  7963. "&stmt_begndate=" + start_time +
  7964. "&stm_enddate=" + end_time +
  7965. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7966. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7967. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7968. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7969. "&fixmedins_code=" + miConfig.Code +
  7970. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7971. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7972. "&secret_key=" + miConfig.SecretKey +
  7973. "&org_name=" + miConfig.OrgName +
  7974. "&doctor=" + user_name +
  7975. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7976. fmt.Println(api)
  7977. resp, requestErr := http.Get(api)
  7978. if requestErr != nil {
  7979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7980. return
  7981. }
  7982. body, ioErr := ioutil.ReadAll(resp.Body)
  7983. fmt.Println(body)
  7984. if ioErr != nil {
  7985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7987. return
  7988. }
  7989. var respJSON map[string]interface{}
  7990. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7993. return
  7994. }
  7995. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7996. userJSONBytes, _ := json.Marshal(respJSON)
  7997. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7998. utils.ErrorLog("解析失败:%v", err)
  7999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8000. return
  8001. }
  8002. res.InfRefmsgid = res10188.InfRefmsgid
  8003. res.Output = res10188.Output
  8004. res.ErrMsg = res10188.ErrMsg
  8005. res.Cainfo = res10188.Cainfo
  8006. res.WarnMsg = res10188.WarnMsg
  8007. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8008. res.Infcode = infocode
  8009. } else {
  8010. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8011. "insutype=" + insutype +
  8012. "&clr_type=" + clr_type +
  8013. "&setl_optins=" + clr_org +
  8014. "&stmt_begndate=" + start_time +
  8015. "&stm_enddate=" + end_time +
  8016. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8017. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8018. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8019. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8020. "&fixmedins_code=" + miConfig.Code +
  8021. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8022. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8023. "&secret_key=" + miConfig.SecretKey +
  8024. "&org_name=" + miConfig.OrgName +
  8025. "&doctor=" + user_name
  8026. fmt.Println(api)
  8027. resp, requestErr := http.Get(api)
  8028. if requestErr != nil {
  8029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8030. return
  8031. }
  8032. body, ioErr := ioutil.ReadAll(resp.Body)
  8033. fmt.Println(body)
  8034. if ioErr != nil {
  8035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8037. return
  8038. }
  8039. var respJSON map[string]interface{}
  8040. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8043. return
  8044. }
  8045. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8046. userJSONBytes, _ := json.Marshal(respJSON)
  8047. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8048. utils.ErrorLog("解析失败:%v", err)
  8049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8050. return
  8051. }
  8052. }
  8053. if res.Infcode == 0 {
  8054. if res.Output.Stmtinfo.StmtRslt == "0" {
  8055. micc := &models.MedicalInsuranceCostCompare{
  8056. StartTime: startime.Unix(),
  8057. EndTime: endtime.Unix(),
  8058. Insutype: insutype,
  8059. CheckType: 1,
  8060. Num: fixmedins_setl_cnt,
  8061. Mtime: time.Now().Unix(),
  8062. Status: 1,
  8063. UserOrgId: adminUser.CurrentOrgId,
  8064. CostTotal: medfee_sumamt,
  8065. FuncTotal: fund_pay_sumamt,
  8066. PsnPay: acct_pay,
  8067. Creator: admin_user_id,
  8068. Ctime: time.Now().Unix(),
  8069. ClrType: clr_type,
  8070. }
  8071. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8072. if err == nil {
  8073. c.ServeSuccessJSON(map[string]interface{}{
  8074. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8075. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8076. })
  8077. } else {
  8078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8079. }
  8080. } else {
  8081. c.ServeSuccessJSON(map[string]interface{}{
  8082. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8083. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8084. })
  8085. }
  8086. } else {
  8087. c.ServeSuccessJSON(map[string]interface{}{
  8088. "code": -10,
  8089. "msg": res.ErrMsg,
  8090. })
  8091. }
  8092. }
  8093. }
  8094. func (c *HisApiController) Check310() {
  8095. adminUser := c.GetAdminUserInfo()
  8096. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8097. var user_name string
  8098. user_name = "高慧裕"
  8099. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8100. "insutype=" + "310" +
  8101. "&clr_type=" + "" +
  8102. "&setl_optins=" + "441202" +
  8103. "&stmt_begndate=" + "2022-03-01" +
  8104. "&stm_enddate=" + "2022-03-31" +
  8105. "&medfee_sumamt=" + "194930.12" +
  8106. "&fund_pay_sumamt=" + "188741.46" +
  8107. "&acct_pay=" + "0" +
  8108. "&fixmedins_setl_cnt=" + "452" +
  8109. "&fixmedins_code=" + miConfig.Code +
  8110. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8111. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8112. "&secret_key=" + miConfig.SecretKey +
  8113. "&org_name=" + miConfig.OrgName +
  8114. "&doctor=" + user_name
  8115. fmt.Println(api)
  8116. resp, requestErr := http.Get(api)
  8117. if requestErr != nil {
  8118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8119. return
  8120. }
  8121. body, ioErr := ioutil.ReadAll(resp.Body)
  8122. fmt.Println(body)
  8123. if ioErr != nil {
  8124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8126. return
  8127. }
  8128. var respJSON map[string]interface{}
  8129. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8132. return
  8133. }
  8134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8135. userJSONBytes, _ := json.Marshal(respJSON)
  8136. var res ResultEight
  8137. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8138. utils.ErrorLog("解析失败:%v", err)
  8139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8140. return
  8141. }
  8142. }
  8143. func (c *HisApiController) Check390() {
  8144. adminUser := c.GetAdminUserInfo()
  8145. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8146. var user_name string
  8147. user_name = "高慧裕"
  8148. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8149. "insutype=" + "390" +
  8150. "&clr_type=" + "" +
  8151. "&setl_optins=" + "441202" +
  8152. "&stmt_begndate=" + "2022-03-01" +
  8153. "&stm_enddate=" + "2022-03-31" +
  8154. "&medfee_sumamt=" + "1068448.89" +
  8155. "&fund_pay_sumamt=" + "1014677.62" +
  8156. "&acct_pay=" + "0" +
  8157. "&fixmedins_setl_cnt=" + "1950" +
  8158. "&fixmedins_code=" + miConfig.Code +
  8159. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8160. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8161. "&secret_key=" + miConfig.SecretKey +
  8162. "&org_name=" + miConfig.OrgName +
  8163. "&doctor=" + user_name
  8164. fmt.Println(api)
  8165. resp, requestErr := http.Get(api)
  8166. if requestErr != nil {
  8167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8168. return
  8169. }
  8170. body, ioErr := ioutil.ReadAll(resp.Body)
  8171. fmt.Println(body)
  8172. if ioErr != nil {
  8173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8175. return
  8176. }
  8177. var respJSON map[string]interface{}
  8178. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8181. return
  8182. }
  8183. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8184. userJSONBytes, _ := json.Marshal(respJSON)
  8185. var res ResultEight
  8186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8187. utils.ErrorLog("解析失败:%v", err)
  8188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8189. return
  8190. }
  8191. }
  8192. //对账明细
  8193. func (c *HisApiController) GetCheckDetailAccount() {
  8194. start_time := c.GetString("start_time")
  8195. end_time := c.GetString("end_time")
  8196. admin_user_id, _ := c.GetInt64("admin_user_id")
  8197. adminUser := c.GetAdminUserInfo()
  8198. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8199. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8200. timeLayout := "2006-01-02"
  8201. loc, _ := time.LoadLocation("Local")
  8202. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8203. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8204. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8205. Mkdir(miConfig.OrgName)
  8206. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  8207. file_name := file + ".txt"
  8208. zip_name := file + ".zip"
  8209. zip_path := miConfig.OrgName + "/" + zip_name
  8210. file_path := miConfig.OrgName + "/" + file_name
  8211. decimal.DivisionPrecision = 2
  8212. var medfee_sumamt float64
  8213. var psn_cash_pay float64
  8214. var fund_pay_sumamt float64
  8215. fixmedins_setl_cnt := int64(len(orders))
  8216. for _, item := range orders {
  8217. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8218. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8219. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8220. }
  8221. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8222. defer f.Close()
  8223. if err != nil {
  8224. fmt.Println(err.Error())
  8225. } else {
  8226. for _, item := range orders {
  8227. var refd_setl_flag string
  8228. if item.OrderStatus == 2 {
  8229. refd_setl_flag = "0"
  8230. var str string
  8231. str = item.SetlId + " " +
  8232. item.MdtrtId + " " +
  8233. item.PsnNo + " " +
  8234. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8235. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8236. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8237. _, err = f.Write([]byte(str))
  8238. }
  8239. if item.OrderStatus == 3 {
  8240. var str string
  8241. str = item.SetlId + " " +
  8242. item.MdtrtId + " " +
  8243. item.PsnNo + " " +
  8244. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8245. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8246. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8247. _, err = f.Write([]byte(str))
  8248. var str2 string
  8249. str2 = item.SetlId + " " +
  8250. item.MdtrtId + " " +
  8251. item.PsnNo + " " +
  8252. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8253. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8254. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8255. _, err = f.Write([]byte(str2))
  8256. }
  8257. }
  8258. }
  8259. Zip(file_path, zip_path)
  8260. fmt.Println(ReadFile(zip_path))
  8261. fmt.Println(string(ReadFile(zip_path)))
  8262. if config.IsOpen == 1 {
  8263. var user_name string
  8264. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8265. if role.ID == 0 {
  8266. user_name = "管理员"
  8267. } else {
  8268. user_name = role.UserName
  8269. }
  8270. baseParams := models.BaseParams{
  8271. SecretKey: miConfig.SecretKey,
  8272. FixmedinsCode: miConfig.Code,
  8273. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8274. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8275. OrgName: miConfig.OrgName,
  8276. Doctor: user_name,
  8277. }
  8278. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  8279. var dat map[string]interface{}
  8280. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8281. fmt.Println(dat)
  8282. } else {
  8283. fmt.Println(err)
  8284. }
  8285. userJSONBytes, _ := json.Marshal(dat)
  8286. var res ResultNine
  8287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8288. utils.ErrorLog("解析失败:%v", err)
  8289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8290. return
  8291. }
  8292. if res.Infcode == 0 {
  8293. fileNo := res.Output.FileQuryNo
  8294. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8295. "file_qury_no=" + fileNo +
  8296. "&setl_optins=" + "定点医保中心" +
  8297. "&stmt_begndate=" + start_time +
  8298. "&stm_enddate=" + end_time +
  8299. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8300. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8301. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8302. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8303. "&fixmedins_code=" + miConfig.Code +
  8304. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8305. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8306. "&secret_key=" + miConfig.SecretKey +
  8307. "&org_name=" + miConfig.OrgName +
  8308. "&doctor=" + user_name
  8309. resp, requestErr := http.Get(api)
  8310. if requestErr != nil {
  8311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8312. return
  8313. }
  8314. body, ioErr := ioutil.ReadAll(resp.Body)
  8315. if ioErr != nil {
  8316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8318. return
  8319. }
  8320. var respJSON map[string]interface{}
  8321. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8324. return
  8325. }
  8326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8327. userJSONBytes, _ := json.Marshal(respJSON)
  8328. var res ResultTen
  8329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8330. utils.ErrorLog("解析失败:%v", err)
  8331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8332. return
  8333. }
  8334. if res.Infcode == 0 {
  8335. service.Gdyb9102(baseParams, zip_name, fileNo)
  8336. micc := &models.MedicalInsuranceCostCompare{
  8337. StartTime: startime.Unix(),
  8338. EndTime: endtime.Unix(),
  8339. Insutype: "0",
  8340. CheckType: 2,
  8341. Num: fixmedins_setl_cnt,
  8342. Mtime: time.Now().Unix(),
  8343. Status: 1,
  8344. UserOrgId: adminUser.CurrentOrgId,
  8345. CostTotal: medfee_sumamt,
  8346. FuncTotal: fund_pay_sumamt,
  8347. PsnPay: psn_cash_pay,
  8348. Creator: admin_user_id,
  8349. Ctime: time.Now().Unix(),
  8350. }
  8351. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8352. c.ServeSuccessJSON(map[string]interface{}{
  8353. "msg": "明细对账成功",
  8354. })
  8355. }
  8356. } else {
  8357. }
  8358. }
  8359. }
  8360. type CustomOrderInfo struct {
  8361. Name string
  8362. Spec string
  8363. Unit string
  8364. Count float64
  8365. Price float64
  8366. Total float64
  8367. }
  8368. func (c *HisApiController) GetSettleAccounts() {
  8369. //id, _ := c.GetInt64("id")
  8370. //record_time := c.GetString("record_time")
  8371. order_id, _ := c.GetInt64("order_id")
  8372. admin_user_id, _ := c.GetInt64("admin_user_id")
  8373. //timeLayout := "2006-01-02"
  8374. //loc, _ := time.LoadLocation("Local")
  8375. //
  8376. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8377. //if err != nil {
  8378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8379. // return
  8380. //}
  8381. //recordDateTime := theTime.Unix()
  8382. adminUser := c.GetAdminUserInfo()
  8383. order, _ := service.GetHisOrderByID(order_id)
  8384. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8385. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8386. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8387. orderInfos = append(orderInfos, orderInfos_two...)
  8388. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8389. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8390. var diagnosis_ids []string
  8391. if his.ID > 0 {
  8392. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8393. } else {
  8394. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8395. }
  8396. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8397. var dia_config []*models.HisXtDiagnoseConfig
  8398. var name string
  8399. for _, item := range diagnosis_ids {
  8400. id, _ := strconv.ParseInt(item, 10, 64)
  8401. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8402. dia_config = append(dia_config, &diagnosisConfig)
  8403. if len(name) == 0 {
  8404. name = diagnosisConfig.ClassName
  8405. } else {
  8406. name = name + "," + diagnosisConfig.ClassName
  8407. }
  8408. }
  8409. var bedCostTotal float64 = 0 //床位总费
  8410. var bedCostSelfTotal float64 = 0 //床位自费
  8411. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8412. var operationCostTotal float64 = 0 //手术费
  8413. var operationCostSelfTotal float64 = 0 //手术费
  8414. var operationCostPartSelfTotal float64 = 0 //手术费
  8415. var otherCostTotal float64 = 0 //其他费用
  8416. var otherCostSelfTotal float64 = 0 //其他费用
  8417. var otherCostPartSelfTotal float64 = 0 //其他费用
  8418. var materialCostTotal float64 = 0 //材料费
  8419. var materialCostSelfTotal float64 = 0 //材料费
  8420. var materialCostPartSelfTotal float64 = 0 //材料费
  8421. var westernMedicineCostTotal float64 = 0 //西药费
  8422. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8423. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8424. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8425. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8426. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8427. var checkCostTotal float64 = 0 //检查费
  8428. var checkCostSelfTotal float64 = 0 //检查费
  8429. var checkCostPartSelfTotal float64 = 0 //检查费
  8430. var laboratoryCostTotal float64 = 0 //化验费
  8431. var laboratoryCostSelfTotal float64 = 0 //化验费
  8432. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8433. var treatCostTotal float64 = 0 //治疗费用
  8434. var treatCostSelfTotal float64 = 0 //治疗费用
  8435. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8436. decimal.DivisionPrecision = 2
  8437. for _, item := range orderInfos {
  8438. if item.MedChrgitmType == "01" { //床位费
  8439. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8440. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8441. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8442. }
  8443. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8444. if item.MedChrgitmType == "03" { //检查费
  8445. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8446. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8447. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8448. }
  8449. } else {
  8450. if item.MedChrgitmType == "03" { //检查费
  8451. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8452. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8453. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8454. }
  8455. }
  8456. if item.MedChrgitmType == "04" { //化验费
  8457. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8458. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8459. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8460. }
  8461. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8462. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8463. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8464. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8465. }
  8466. if item.MedChrgitmType == "06" { //手术费
  8467. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8468. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8469. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8470. }
  8471. if item.MedChrgitmType == "08" { //材料费
  8472. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8473. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8474. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8475. }
  8476. if item.MedChrgitmType == "09" { //西药费
  8477. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8478. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8479. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8480. }
  8481. if item.MedChrgitmType == "11" { //中成费
  8482. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8483. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8484. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8485. }
  8486. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8487. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8488. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8489. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8490. }
  8491. }
  8492. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8493. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8494. var user_name string
  8495. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8496. if role.ID == 0 {
  8497. user_name = "管理员"
  8498. } else {
  8499. user_name = role.UserName
  8500. }
  8501. baseParams := models.BaseParams{
  8502. SecretKey: miConfig.SecretKey,
  8503. FixmedinsCode: miConfig.Code,
  8504. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8505. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8506. OrgName: miConfig.OrgName,
  8507. Doctor: user_name,
  8508. }
  8509. businessParams := models.BusinessParams{
  8510. PsnNo: order.PsnNo,
  8511. MdtrtId: order.MdtrtId,
  8512. SetlId: order.SetlId,
  8513. }
  8514. var res ResultEleven
  8515. var resEleven10265 ResultEleven10265
  8516. if config.IsOpen == 1 {
  8517. if miConfig.MdtrtareaAdmvs == "421300" {
  8518. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8519. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8520. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8521. resp, requestErr := http.Get(api)
  8522. if requestErr != nil {
  8523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8524. return
  8525. }
  8526. body, ioErr := ioutil.ReadAll(resp.Body)
  8527. if ioErr != nil {
  8528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8530. return
  8531. }
  8532. var respJSON map[string]interface{}
  8533. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8536. return
  8537. }
  8538. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8539. result, _ := json.Marshal(respJSON)
  8540. fmt.Println("log")
  8541. fmt.Println(string(result))
  8542. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8543. utils.ErrorLog("解析失败:%v", err)
  8544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8545. return
  8546. }
  8547. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8548. var api string
  8549. if miConfig.MdtrtareaAdmvs == "320921" {
  8550. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8551. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8552. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8553. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8554. } else {
  8555. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8556. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8557. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8558. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8559. }
  8560. resp, requestErr := http.Get(api)
  8561. if requestErr != nil {
  8562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8563. return
  8564. }
  8565. body, ioErr := ioutil.ReadAll(resp.Body)
  8566. if ioErr != nil {
  8567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8569. return
  8570. }
  8571. var respJSON map[string]interface{}
  8572. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8575. return
  8576. }
  8577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8578. result, _ := json.Marshal(respJSON)
  8579. fmt.Println("log")
  8580. fmt.Println(string(result))
  8581. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8582. utils.ErrorLog("解析失败:%v", err)
  8583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8584. return
  8585. }
  8586. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8587. res.Output = resEleven10265.Output
  8588. res.ErrMsg = resEleven10265.ErrMsg
  8589. res.Cainfo = resEleven10265.Cainfo
  8590. res.WarnMsg = resEleven10265.WarnMsg
  8591. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8592. res.Infcode = infocode
  8593. } else {
  8594. //result2 := service.Gdyb1101()
  8595. //result2 := service.Gdyb5204(baseParams, businessParams)
  8596. //saveLog(result2, "", "5204", "查询")
  8597. result := service.Gdyb5203(baseParams, businessParams)
  8598. var dat map[string]interface{}
  8599. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8600. fmt.Println(dat)
  8601. } else {
  8602. fmt.Println(err)
  8603. }
  8604. userJSONBytes, _ := json.Marshal(dat)
  8605. if miConfig.Code == "H15049901371" {
  8606. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8607. utils.ErrorLog("解析失败:%v", err)
  8608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8609. return
  8610. }
  8611. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8612. res.Output = resEleven10265.Output
  8613. res.ErrMsg = resEleven10265.ErrMsg
  8614. res.Cainfo = resEleven10265.Cainfo
  8615. res.WarnMsg = resEleven10265.WarnMsg
  8616. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8617. res.Infcode = infocode
  8618. } else {
  8619. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8620. utils.ErrorLog("解析失败:%v", err)
  8621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8622. return
  8623. }
  8624. }
  8625. }
  8626. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8627. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8628. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8629. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8630. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8631. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8632. var doctor_name string
  8633. if roles.ID == 0 {
  8634. doctor_name = "管理员"
  8635. } else {
  8636. doctor_name = roles.UserName
  8637. }
  8638. yiliao_leibie := ""
  8639. switch order.MedType {
  8640. case "11":
  8641. yiliao_leibie = "普通门诊"
  8642. break
  8643. case "12":
  8644. yiliao_leibie = "门诊挂号"
  8645. break
  8646. case "13":
  8647. yiliao_leibie = "急诊"
  8648. break
  8649. case "14":
  8650. yiliao_leibie = "门诊特殊病"
  8651. break
  8652. case "15":
  8653. yiliao_leibie = "门诊统筹"
  8654. break
  8655. case "16":
  8656. yiliao_leibie = "门诊慢性病"
  8657. break
  8658. case "21":
  8659. yiliao_leibie = "普通住院"
  8660. break
  8661. }
  8662. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8663. if res.Infcode == 0 {
  8664. c.ServeSuccessJSON(map[string]interface{}{
  8665. "diagnosis": name,
  8666. "order_infos": orderInfos,
  8667. "number": order.MdtrtId,
  8668. "date": order.SettleAccountsDate,
  8669. "charge_admin": charge_admin,
  8670. "printor_admin": printor_admin,
  8671. "info": res.Output.Setlinfo,
  8672. "order": order,
  8673. "bedCostTotal": bedCostTotal,
  8674. "bedCostSelfTotal": bedCostSelfTotal,
  8675. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8676. "operationCostTotal": operationCostTotal,
  8677. "operationCostSelfTotal": operationCostSelfTotal,
  8678. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8679. "otherCostTotal": otherCostTotal,
  8680. "otherCostSelfTotal": otherCostSelfTotal,
  8681. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8682. "materialCostTotal": materialCostTotal,
  8683. "materialCostSelfTotal": materialCostSelfTotal,
  8684. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8685. "westernMedicineCostTotal": westernMedicineCostTotal,
  8686. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8687. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8688. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8689. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8690. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8691. "checkCostTotal": checkCostTotal,
  8692. "checkCostSelfTotal": checkCostSelfTotal,
  8693. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8694. "laboratoryCostTotal": laboratoryCostTotal,
  8695. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8696. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8697. "treatCostTotal": treatCostTotal,
  8698. "treatCostSelfTotal": treatCostSelfTotal,
  8699. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8700. "doctor_info": doctor_info,
  8701. "doctor_code": adminRole_two.DoctorCode,
  8702. "doctor_name": doctor_name,
  8703. "health_card_no": order.PsnNo,
  8704. "department": departments.Name,
  8705. "yiliao_leibie": yiliao_leibie,
  8706. "after_money": order.AccountPrice,
  8707. "patient": patient,
  8708. "org_name": miConfig.OrgName,
  8709. "org_code": miConfig.Code,
  8710. "order_number": order.Number,
  8711. "his_hospital": his_hospital,
  8712. "his": his,
  8713. "dia_config": dia_config,
  8714. //"check_order_info": cus_slice,
  8715. })
  8716. }
  8717. }
  8718. }
  8719. func (c *HisApiController) CheckTreatment() {
  8720. patient_id, _ := c.GetInt64("patient_id")
  8721. id_card_no := c.GetString("id_card_no")
  8722. insutype := c.GetString("insutype")
  8723. med_type := c.GetString("med_type")
  8724. admin_user_id, _ := c.GetInt64("admin_user_id")
  8725. adminUser := c.GetAdminUserInfo()
  8726. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8727. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8728. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8729. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8730. if miConfig.MdtrtareaAdmvs == "421300" {
  8731. var res ResultTwo
  8732. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8733. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8734. "&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)
  8735. resp, requestErr := http.Get(api)
  8736. if requestErr != nil {
  8737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8738. return
  8739. }
  8740. body, ioErr := ioutil.ReadAll(resp.Body)
  8741. if ioErr != nil {
  8742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8744. return
  8745. }
  8746. var respJSON map[string]interface{}
  8747. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8750. return
  8751. }
  8752. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8753. result, _ := json.Marshal(respJSON)
  8754. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8755. utils.ErrorLog("解析失败:%v", err)
  8756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8757. return
  8758. }
  8759. if res.Infcode == 0 {
  8760. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8761. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8762. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8763. resp, requestErr := http.Get(api)
  8764. if requestErr != nil {
  8765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8766. return
  8767. }
  8768. body, ioErr := ioutil.ReadAll(resp.Body)
  8769. if ioErr != nil {
  8770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8772. return
  8773. }
  8774. var respJSON map[string]interface{}
  8775. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8776. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8778. return
  8779. }
  8780. var res Result2001
  8781. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8782. result2, _ := json.Marshal(respJSON)
  8783. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8784. utils.ErrorLog("解析失败:%v", err)
  8785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8786. return
  8787. }
  8788. if res.Infcode == 0 {
  8789. c.ServeSuccessJSON(map[string]interface{}{
  8790. "msg": res.Output.Trtinfo,
  8791. })
  8792. }
  8793. } else {
  8794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8795. return
  8796. }
  8797. } else {
  8798. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8799. var dat map[string]interface{}
  8800. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8801. fmt.Println(dat)
  8802. } else {
  8803. fmt.Println(err)
  8804. }
  8805. userJSONBytes, _ := json.Marshal(dat)
  8806. var res ResultTwo
  8807. var res10265 ResultTwo10265
  8808. if miConfig.Code == "H15049901371" {
  8809. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8810. utils.ErrorLog("解析失败:%v", err)
  8811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8812. return
  8813. }
  8814. res.ErrMsg = res10265.ErrMsg
  8815. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8816. res.Infcode = infocode
  8817. res.Output = res10265.Output
  8818. res.InfRefmsgid = res10265.InfRefmsgid
  8819. } else {
  8820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8821. utils.ErrorLog("解析失败:%v", err)
  8822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8823. return
  8824. }
  8825. }
  8826. var user_name string
  8827. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8828. if role.ID == 0 {
  8829. user_name = "xxx"
  8830. } else {
  8831. user_name = role.UserName
  8832. }
  8833. baseParams := models.BaseParams{
  8834. SecretKey: miConfig.SecretKey,
  8835. FixmedinsCode: miConfig.Code,
  8836. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8837. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8838. OrgName: miConfig.OrgName,
  8839. Doctor: user_name,
  8840. }
  8841. if config.IsOpen == 1 {
  8842. if miConfig.Code == "H15049901371" {
  8843. if med_type == "14" {
  8844. if insutype == "390" {
  8845. med_type = "9933"
  8846. } else if insutype == "310" {
  8847. med_type = "990502"
  8848. }
  8849. } else if med_type == "11" {
  8850. med_type = "11"
  8851. }
  8852. }
  8853. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8854. var dat map[string]interface{}
  8855. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8856. fmt.Println(dat)
  8857. } else {
  8858. fmt.Println(err)
  8859. }
  8860. var res Result2001
  8861. var res10265 Result2001Org10265
  8862. if miConfig.Code == "H15049901371" {
  8863. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8864. utils.ErrorLog("解析失败:%v", err)
  8865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8866. return
  8867. }
  8868. res.ErrMsg = res10265.ErrMsg
  8869. res.Output = res10265.Output
  8870. res.InfRefmsgid = res10265.InfRefmsgid
  8871. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8872. res.Infcode = infocode
  8873. } else {
  8874. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8875. utils.ErrorLog("解析失败:%v", err)
  8876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8877. return
  8878. }
  8879. }
  8880. if res.Infcode == 0 {
  8881. c.ServeSuccessJSON(map[string]interface{}{
  8882. "msg": res.Output.Trtinfo,
  8883. })
  8884. }
  8885. }
  8886. }
  8887. }
  8888. //func (c *HisApiController) PutRecord() {
  8889. // id, _ := c.GetInt64("id")
  8890. // record_time := c.GetString("record_time")
  8891. // timeLayout := "2006-01-02"
  8892. // loc, _ := time.LoadLocation("Local")
  8893. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8894. // if err != nil {
  8895. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8896. // return
  8897. // }
  8898. // recordDateTime := theTime.Unix()
  8899. //
  8900. // adminInfo := c.GetAdminUserInfo()
  8901. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8902. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8903. //
  8904. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8905. //
  8906. // fmt.Println(miConfig.SecretKey)
  8907. //
  8908. // if patient == nil {
  8909. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8910. // return
  8911. // }
  8912. // if len(patient.IdCardNo) == 0 {
  8913. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8914. // return
  8915. // }
  8916. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8917. // if config.IsOpen == 1 {
  8918. // 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
  8919. // resp, requestErr := http.Get(api)
  8920. // if requestErr != nil {
  8921. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8922. // return
  8923. // }
  8924. // defer resp.Body.Close()
  8925. // body, ioErr := ioutil.ReadAll(resp.Body)
  8926. // if ioErr != nil {
  8927. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8928. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8929. // return
  8930. // }
  8931. // var respJSON map[string]interface{}
  8932. //
  8933. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8934. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8935. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8936. // return
  8937. // }
  8938. //
  8939. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8940. // userJSONBytes, _ := json.Marshal(userJSON)
  8941. // var res ResultTwo
  8942. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8943. // utils.ErrorLog("解析失败:%v", err)
  8944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8945. // return
  8946. // }
  8947. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8948. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8949. // infoStr := string(Iinfos)
  8950. // idetinfoStr := string(Idetinfos)
  8951. //
  8952. // if res.Infcode == 0 {
  8953. // his := models.VMHisPatient{
  8954. // Status: 1,
  8955. // Ctime: time.Now().Unix(),
  8956. // Mtime: time.Now().Unix(),
  8957. // PsnNo: res.Output.Baseinfo.PsnNo,
  8958. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8959. // Certno: res.Output.Baseinfo.Certno,
  8960. // PsnName: res.Output.Baseinfo.PsnName,
  8961. // Gend: res.Output.Baseinfo.Gend,
  8962. // Naty: res.Output.Baseinfo.Naty,
  8963. // Brdy: res.Output.Baseinfo.Brdy,
  8964. // Age: res.Output.Baseinfo.Age,
  8965. // Iinfo: infoStr,
  8966. // Idetinfo: idetinfoStr,
  8967. // PatientId: patient.ID,
  8968. // RecordDate: theTime.Unix(),
  8969. // UserOrgId: adminInfo.CurrentOrgId,
  8970. // AdminUserId: adminInfo.AdminUser.Id,
  8971. // IsReturn: 1,
  8972. // }
  8973. //
  8974. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8975. // //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")
  8976. // //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")
  8977. //
  8978. // //var dat map[string]interface{}
  8979. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8980. // // fmt.Println(dat)
  8981. // //} else {
  8982. // // fmt.Println(err)
  8983. // //}
  8984. //
  8985. // var dat2 map[string]interface{}
  8986. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8987. // fmt.Println(dat2)
  8988. // } else {
  8989. // fmt.Println(err)
  8990. // }
  8991. //
  8992. // } else {
  8993. // adminUser := c.GetAdminUserInfo()
  8994. // errlog := &models.HisOrderError{
  8995. // UserOrgId: adminUser.CurrentOrgId,
  8996. // Ctime: time.Now().Unix(),
  8997. // Mtime: time.Now().Unix(),
  8998. // ErrMsg: res.ErrMsg,
  8999. // Status: 1,
  9000. // PatientId: id,
  9001. // RecordTime: recordDateTime,
  9002. // Stage: 1,
  9003. // }
  9004. // service.CreateErrMsgLog(errlog)
  9005. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9006. // return
  9007. // }
  9008. // }
  9009. //
  9010. //}
  9011. //func (c *HisApiController) GetUploadDiag() {
  9012. // id, _ := c.GetInt64("id")
  9013. // record_time := c.GetString("record_time")
  9014. //
  9015. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9016. // sick_type, _ := c.GetInt64("sick_type")
  9017. // reg_type, _ := c.GetInt64("reg_type")
  9018. //
  9019. // timeLayout := "2006-01-02"
  9020. // loc, _ := time.LoadLocation("Local")
  9021. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9022. // if err != nil {
  9023. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9024. // return
  9025. // }
  9026. //
  9027. // var patientPrescription models.HisPrescriptionInfo
  9028. // recordDateTime := theTime.Unix()
  9029. // adminInfo := c.GetAdminUserInfo()
  9030. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9031. //
  9032. // if patientPrescription.ID == 0 {
  9033. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9034. // }
  9035. //
  9036. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9037. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9038. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9039. // sickConfig, _ := service.FindSickById(sick_type)
  9040. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9041. //
  9042. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9043. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9044. // "&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 +
  9045. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9046. // resp2, requestErr2 := http.Get(api2)
  9047. // if requestErr2 != nil {
  9048. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9049. // return
  9050. // }
  9051. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9052. // if ioErr2 != nil {
  9053. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9054. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9055. // return
  9056. // }
  9057. // var respJSON2 map[string]interface{}
  9058. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9059. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9060. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9061. // return
  9062. // }
  9063. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9064. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9065. //
  9066. // var res2 ResultSix
  9067. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9068. // utils.ErrorLog("解析失败:%v", err)
  9069. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9070. // return
  9071. // }
  9072. // if res2.Infcode != 0 {
  9073. // adminUser := c.GetAdminUserInfo()
  9074. // errlog := &models.HisOrderError{
  9075. // UserOrgId: adminUser.CurrentOrgId,
  9076. // Ctime: time.Now().Unix(),
  9077. // Mtime: time.Now().Unix(),
  9078. // ErrMsg: res2.ErrMsg,
  9079. // Status: 1,
  9080. // PatientId: id,
  9081. // RecordTime: recordDateTime,
  9082. // Stage: 3,
  9083. // }
  9084. // service.CreateErrMsgLog(errlog)
  9085. //
  9086. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9087. // return
  9088. // }
  9089. //
  9090. // c.ServeSuccessJSON(map[string]interface{}{
  9091. // "msg": "上传成功",
  9092. // })
  9093. //
  9094. //}
  9095. type QueryResult struct {
  9096. ID int64
  9097. Name string
  9098. Code string
  9099. List_type_code string
  9100. }
  9101. func (c *HisApiController) GetCheckCode() {
  9102. ids_str := c.GetString("ids")
  9103. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9104. ids_arr := strings.Split(ids_str, ",")
  9105. var queryResult []QueryResult
  9106. ids := make([]int64, 0)
  9107. for _, item := range ids_arr {
  9108. id, _ := strconv.ParseInt(item, 10, 64)
  9109. ids = append(ids, id)
  9110. }
  9111. if record_type == 1 {
  9112. drugs, _ := service.GetBatchDrugList(ids)
  9113. for _, item := range drugs {
  9114. result := QueryResult{
  9115. ID: item.ID,
  9116. Name: item.DrugName,
  9117. Code: item.MedicalInsuranceNumber,
  9118. List_type_code: "101",
  9119. }
  9120. queryResult = append(queryResult, result)
  9121. }
  9122. } else if record_type == 2 {
  9123. goods, _ := service.GetBatchGoodInformationList(ids)
  9124. for _, item := range goods {
  9125. result := QueryResult{
  9126. ID: item.ID,
  9127. Name: item.GoodName,
  9128. Code: item.MedicalInsuranceNumber,
  9129. List_type_code: "301",
  9130. }
  9131. queryResult = append(queryResult, result)
  9132. }
  9133. } else if record_type == 3 {
  9134. projects, _ := service.GetBathchMyPorjecgList(ids)
  9135. for _, item := range projects {
  9136. result := QueryResult{
  9137. ID: item.ID,
  9138. Name: item.ProjectName,
  9139. Code: item.MedicalCode,
  9140. List_type_code: "201",
  9141. }
  9142. queryResult = append(queryResult, result)
  9143. }
  9144. }
  9145. admin_user_id, _ := c.GetInt64("admin_user_id")
  9146. adminUser := c.GetAdminUserInfo()
  9147. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9148. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9149. var user_name string
  9150. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9151. if role.ID == 0 {
  9152. user_name = "xxx"
  9153. } else {
  9154. user_name = role.UserName
  9155. }
  9156. baseParams := &models.BaseParams{
  9157. SecretKey: miConfig.SecretKey,
  9158. FixmedinsCode: miConfig.Code,
  9159. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9160. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9161. OrgName: miConfig.OrgName,
  9162. Doctor: user_name,
  9163. }
  9164. if config.IsOpen == 1 {
  9165. for _, item := range queryResult {
  9166. var result string
  9167. if record_type == 1 {
  9168. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9169. } else if record_type == 2 {
  9170. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9171. } else if record_type == 3 {
  9172. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9173. }
  9174. var dat map[string]interface{}
  9175. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9176. fmt.Println(dat)
  9177. } else {
  9178. fmt.Println(err)
  9179. }
  9180. userJSONBytes, _ := json.Marshal(dat)
  9181. var res ResultSix
  9182. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9183. utils.ErrorLog("解析失败:%v", err)
  9184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9185. return
  9186. }
  9187. if res.Infcode == 0 {
  9188. if record_type == 1 {
  9189. service.UpdateBaseDrugById(item.ID)
  9190. } else if record_type == 2 {
  9191. service.UpdateGoodInformaitonByDetail(item.ID)
  9192. } else if record_type == 3 {
  9193. service.UpdateProjectById(item.ID)
  9194. }
  9195. c.ServeSuccessJSON(map[string]interface{}{
  9196. "failed_code": 0,
  9197. "msg": "目录对照成功",
  9198. })
  9199. } else {
  9200. c.ServeSuccessJSON(map[string]interface{}{
  9201. "failed_code": -10,
  9202. "msg": res.ErrMsg,
  9203. })
  9204. }
  9205. }
  9206. }
  9207. }
  9208. func (c *HisApiController) UnCheckCode() {
  9209. ids_str := c.GetString("ids")
  9210. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9211. admin_user_id, _ := c.GetInt64("admin_user_id")
  9212. ids_arr := strings.Split(ids_str, ",")
  9213. var queryResult []QueryResult
  9214. ids := make([]int64, 0)
  9215. for _, item := range ids_arr {
  9216. id, _ := strconv.ParseInt(item, 10, 64)
  9217. ids = append(ids, id)
  9218. }
  9219. if record_type == 1 {
  9220. drugs, _ := service.GetBatchDrugList(ids)
  9221. for _, item := range drugs {
  9222. result := QueryResult{
  9223. ID: item.ID,
  9224. Name: item.DrugName,
  9225. Code: item.MedicalInsuranceNumber,
  9226. List_type_code: "101",
  9227. }
  9228. queryResult = append(queryResult, result)
  9229. }
  9230. } else if record_type == 2 {
  9231. goods, _ := service.GetBatchGoodInformationList(ids)
  9232. for _, item := range goods {
  9233. result := QueryResult{
  9234. ID: item.ID,
  9235. Name: item.GoodName,
  9236. Code: item.MedicalInsuranceNumber,
  9237. List_type_code: "301",
  9238. }
  9239. queryResult = append(queryResult, result)
  9240. }
  9241. } else if record_type == 3 {
  9242. projects, _ := service.GetBathchMyPorjecgList(ids)
  9243. for _, item := range projects {
  9244. result := QueryResult{
  9245. ID: item.ID,
  9246. Name: item.ProjectName,
  9247. Code: item.MedicalCode,
  9248. List_type_code: "201",
  9249. }
  9250. queryResult = append(queryResult, result)
  9251. }
  9252. }
  9253. adminUser := c.GetAdminUserInfo()
  9254. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9255. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9256. var user_name string
  9257. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9258. if role.ID == 0 {
  9259. user_name = "xxx"
  9260. } else {
  9261. user_name = role.UserName
  9262. }
  9263. baseParams := &models.BaseParams{
  9264. SecretKey: miConfig.SecretKey,
  9265. FixmedinsCode: miConfig.Code,
  9266. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9267. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9268. OrgName: miConfig.OrgName,
  9269. Doctor: user_name,
  9270. }
  9271. if config.IsOpen == 1 {
  9272. for _, item := range queryResult {
  9273. var result string
  9274. if record_type == 1 {
  9275. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9276. } else if record_type == 2 {
  9277. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9278. } else if record_type == 3 {
  9279. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9280. }
  9281. var dat2 map[string]interface{}
  9282. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9283. fmt.Println(dat2)
  9284. } else {
  9285. fmt.Println(err)
  9286. }
  9287. userJSONBytes, _ := json.Marshal(dat2)
  9288. var res ResultSix
  9289. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9290. utils.ErrorLog("解析失败:%v", err)
  9291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9292. return
  9293. }
  9294. if res.Infcode == 0 {
  9295. if record_type == 1 {
  9296. service.UpdateDrugByIdDetail(item.ID)
  9297. } else if record_type == 2 {
  9298. service.UpdateGoodInfoById(item.ID)
  9299. } else if record_type == 3 {
  9300. service.UpdateMyProjectById(item.ID)
  9301. }
  9302. c.ServeSuccessJSON(map[string]interface{}{
  9303. "failed_code": 0,
  9304. "msg": "撤销目录对照成功",
  9305. })
  9306. } else {
  9307. c.ServeSuccessJSON(map[string]interface{}{
  9308. "failed_code": -10,
  9309. "msg": res.ErrMsg,
  9310. })
  9311. }
  9312. }
  9313. }
  9314. }
  9315. func (c *HisApiController) GetPatientInfo() {
  9316. id_card_no := c.GetString("id_card_no")
  9317. admin_user_id, _ := c.GetInt64("admin_user_id")
  9318. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9319. if patient.ID == 0 {
  9320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9321. return
  9322. }
  9323. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9324. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9325. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9326. if config.IsOpen == 1 {
  9327. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9328. var dat map[string]interface{}
  9329. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9330. fmt.Println(dat)
  9331. } else {
  9332. fmt.Println(err)
  9333. }
  9334. userJSONBytes, _ := json.Marshal(dat)
  9335. var res ResultTwo
  9336. var res10265 ResultTwo10265
  9337. if miConfig.Code == "H15049901371" {
  9338. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9339. utils.ErrorLog("解析失败:%v", err)
  9340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9341. return
  9342. }
  9343. res.ErrMsg = res10265.ErrMsg
  9344. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9345. res.Infcode = infocode
  9346. res.Output = res10265.Output
  9347. res.InfRefmsgid = res10265.InfRefmsgid
  9348. } else {
  9349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9350. utils.ErrorLog("解析失败:%v", err)
  9351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9352. return
  9353. }
  9354. }
  9355. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9356. // utils.ErrorLog("解析失败:%v", err)
  9357. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9358. // return
  9359. //}
  9360. if res.Infcode != 0 {
  9361. c.ServeSuccessJSON(map[string]interface{}{
  9362. "failed_code": -10,
  9363. "msg": res.ErrMsg,
  9364. })
  9365. } else {
  9366. c.ServeSuccessJSON(map[string]interface{}{
  9367. "failed_code": 0,
  9368. "info": res,
  9369. })
  9370. }
  9371. }
  9372. }
  9373. func (c *HisApiController) PsnPutOnRecord() {
  9374. record_type, _ := c.GetInt64("type")
  9375. patient_id, _ := c.GetInt64("patient_id")
  9376. admin_user_id, _ := c.GetInt64("admin_user_id")
  9377. start_time := c.GetString("start_time")
  9378. end_time := c.GetString("end_time")
  9379. adminUser := c.GetAdminUserInfo()
  9380. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9381. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9382. var patients []*models.Patients
  9383. if record_type == 1 { //全部备案
  9384. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9385. patients = append(patients, patient...)
  9386. } else { //单个备案
  9387. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9388. patients = append(patients, patient)
  9389. }
  9390. var user_name string
  9391. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9392. if role.ID == 0 {
  9393. user_name = "xxx"
  9394. } else {
  9395. user_name = role.UserName
  9396. }
  9397. if config.IsOpen == 1 {
  9398. for _, item := range patients {
  9399. 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
  9400. resp, requestErr := http.Get(api)
  9401. if requestErr != nil {
  9402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9403. return
  9404. }
  9405. defer resp.Body.Close()
  9406. body, ioErr := ioutil.ReadAll(resp.Body)
  9407. if ioErr != nil {
  9408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9410. return
  9411. }
  9412. var respJSON map[string]interface{}
  9413. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9416. return
  9417. }
  9418. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9419. userJSONBytes, _ := json.Marshal(userJSON)
  9420. var res ResultTwo
  9421. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9422. utils.ErrorLog("解析失败:%v", err)
  9423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9424. return
  9425. }
  9426. if res.Infcode == 0 {
  9427. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9428. var dat map[string]interface{}
  9429. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9430. fmt.Println(dat)
  9431. } else {
  9432. fmt.Println(err)
  9433. }
  9434. userJSONBytes, _ := json.Marshal(dat)
  9435. var res2 ResultThirteen
  9436. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9437. utils.ErrorLog("解析失败:%v", err)
  9438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9439. return
  9440. }
  9441. if res2.Infcode == 0 {
  9442. psnResult := &models.GdybPsnRecord{
  9443. UserOrgId: adminUser.CurrentOrgId,
  9444. PatientId: item.ID,
  9445. PsnNo: res.Output.Baseinfo.PsnNo,
  9446. Ctime: time.Now().Unix(),
  9447. Mtime: time.Now().Unix(),
  9448. Status: 1,
  9449. IsCancel: 1,
  9450. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9451. }
  9452. service.CreatePsnRecord(psnResult)
  9453. } else {
  9454. c.ServeSuccessJSON(map[string]interface{}{
  9455. "failed_code": -10,
  9456. "msg": res2.ErrMsg,
  9457. })
  9458. return
  9459. }
  9460. }
  9461. }
  9462. }
  9463. }
  9464. func (c *HisApiController) PsnUnPutOnRecord() {
  9465. id, _ := c.GetInt64("id")
  9466. //record_type, _ := c.GetInt64("type")
  9467. admin_user_id, _ := c.GetInt64("admin_user_id")
  9468. adminUser := c.GetAdminUserInfo()
  9469. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9470. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9471. var user_name string
  9472. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9473. if role.ID == 0 {
  9474. user_name = "xxx"
  9475. } else {
  9476. user_name = role.UserName
  9477. }
  9478. psn_record, _ := service.GetPsnRecordById(id)
  9479. if psn_record.ID == 0 {
  9480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9481. return
  9482. }
  9483. if config.IsOpen == 1 {
  9484. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9485. var dat map[string]interface{}
  9486. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9487. fmt.Println(dat)
  9488. } else {
  9489. fmt.Println(err)
  9490. }
  9491. userJSONBytes, _ := json.Marshal(dat)
  9492. var res ResultFourteen
  9493. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9494. utils.ErrorLog("解析失败:%v", err)
  9495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9496. return
  9497. }
  9498. if res.Infcode == 0 {
  9499. psn_record.IsCancel = 2
  9500. service.CreatePsnRecord(&psn_record)
  9501. } else {
  9502. c.ServeSuccessJSON(map[string]interface{}{
  9503. "failed_code": -10,
  9504. "msg": res.ErrMsg,
  9505. })
  9506. return
  9507. }
  9508. }
  9509. }
  9510. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9511. patient_id, _ := c.GetInt64("patient_id")
  9512. insutype_two := c.GetString("insutype")
  9513. psn_no := c.GetString("psn_no")
  9514. doctor_id, _ := c.GetInt64("doctor_id")
  9515. sick_id, _ := c.GetInt64("sick_id")
  9516. department_id, _ := c.GetInt64("department_id")
  9517. start_time := c.GetString("start_time")
  9518. end_time := c.GetString("end_time")
  9519. check_time := c.GetString("check_time")
  9520. adminUser := c.GetAdminUserInfo()
  9521. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9522. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9523. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9524. sick, _ := service.FindSickById(sick_id)
  9525. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9526. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9527. var res ResultTwo
  9528. var res10265 ResultTwo10265
  9529. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9530. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9531. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9532. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9533. "&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
  9534. resp, requestErr := http.Get(api)
  9535. if requestErr != nil {
  9536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9537. return
  9538. }
  9539. body, ioErr := ioutil.ReadAll(resp.Body)
  9540. if ioErr != nil {
  9541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9543. return
  9544. }
  9545. var respJSON map[string]interface{}
  9546. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9549. return
  9550. }
  9551. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9552. result, _ := json.Marshal(respJSON)
  9553. fmt.Println("log")
  9554. fmt.Println(string(result))
  9555. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9556. utils.ErrorLog("解析失败:%v", err)
  9557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9558. return
  9559. }
  9560. res.ErrMsg = res10265.ErrMsg
  9561. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9562. res.Infcode = infocode
  9563. res.Output = res10265.Output
  9564. res.InfRefmsgid = res10265.InfRefmsgid
  9565. } else {
  9566. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9567. if miConfig.Code == "H15049901371" {
  9568. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9569. utils.ErrorLog("解析失败:%v", err)
  9570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9571. return
  9572. }
  9573. res.ErrMsg = res10265.ErrMsg
  9574. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9575. res.Infcode = infocode
  9576. res.Output = res10265.Output
  9577. res.InfRefmsgid = res10265.InfRefmsgid
  9578. } else {
  9579. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9580. utils.ErrorLog("解析失败:%v", err)
  9581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9582. return
  9583. }
  9584. }
  9585. }
  9586. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9587. infoStr := string(Iinfos)
  9588. var rf []*ResultFive
  9589. json.Unmarshal([]byte(infoStr), &rf)
  9590. var insuplc_admdvs string
  9591. var insutype string
  9592. var is390 int = 0
  9593. var is310 int = 0
  9594. var insutypes []*ResultFive
  9595. for _, item := range rf {
  9596. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9597. insutypes = append(insutypes, item)
  9598. }
  9599. }
  9600. if len(insutypes) == 1 {
  9601. insutype = insutypes[0].Insutype
  9602. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9603. } else {
  9604. for _, i := range insutypes {
  9605. if i.Insutype == "390" {
  9606. is390 = 1
  9607. }
  9608. if i.Insutype == "310" {
  9609. is310 = 1
  9610. }
  9611. }
  9612. }
  9613. if is390 == 1 {
  9614. insutype = "390"
  9615. }
  9616. if is310 == 1 {
  9617. insutype = "310"
  9618. }
  9619. if len(insutypes) == 2 {
  9620. insutype = insutype_two
  9621. }
  9622. if len(insutypes) == 0 {
  9623. insutype = "310"
  9624. }
  9625. insutype = insutype_two
  9626. fmt.Println(insutype)
  9627. for _, item := range rf {
  9628. fmt.Println(item.Insutype)
  9629. fmt.Println(insutype)
  9630. if item.Insutype == insutype {
  9631. fmt.Println(item.Insutype)
  9632. fmt.Println(insutype)
  9633. insuplc_admdvs = item.InsuplcAdmdvs
  9634. }
  9635. }
  9636. fmt.Println(insuplc_admdvs)
  9637. var res2 ResultThirteen
  9638. var res10265_2 ResultThirteen10265
  9639. if config.IsOpen == 1 {
  9640. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9641. } else {
  9642. 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)
  9643. var dat map[string]interface{}
  9644. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9645. fmt.Println(dat)
  9646. } else {
  9647. fmt.Println(err)
  9648. }
  9649. userJSONBytes, _ := json.Marshal(dat)
  9650. if miConfig.Code == "H15049901371" {
  9651. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9652. utils.ErrorLog("解析失败:%v", err)
  9653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9654. return
  9655. }
  9656. res2.ErrMsg = res10265_2.ErrMsg
  9657. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9658. res2.Infcode = infocode
  9659. res2.Output = res10265_2.Output
  9660. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9661. } else {
  9662. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9663. utils.ErrorLog("解析失败:%v", err)
  9664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9665. return
  9666. }
  9667. }
  9668. }
  9669. if res2.Infcode == 0 {
  9670. psnResult := &models.GdybPsnNcdsRecord{
  9671. UserOrgId: adminUser.CurrentOrgId,
  9672. PatientId: patient.ID,
  9673. PsnNo: psn_no,
  9674. DoctorId: doctor.AdminUserId,
  9675. DepartmentId: department_id,
  9676. SickType: sick_id,
  9677. Insutype: insutype,
  9678. Ctime: time.Now().Unix(),
  9679. Mtime: time.Now().Unix(),
  9680. Status: 1,
  9681. IsCancel: 1,
  9682. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9683. }
  9684. service.CreatePsnNCDSRecord(psnResult)
  9685. c.ServeSuccessJSON(map[string]interface{}{
  9686. "failed_code": 0,
  9687. "msg": "备案成功",
  9688. "result": psnResult,
  9689. })
  9690. } else {
  9691. c.ServeSuccessJSON(map[string]interface{}{
  9692. "failed_code": -10,
  9693. "msg": res2.ErrMsg,
  9694. })
  9695. return
  9696. }
  9697. }
  9698. }
  9699. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9700. id, _ := c.GetInt64("id")
  9701. admin_user_id, _ := c.GetInt64("admin_user_id")
  9702. adminUser := c.GetAdminUserInfo()
  9703. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9704. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9705. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9706. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9707. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9708. //var user_name string
  9709. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9710. //if role.ID == 0 {
  9711. // user_name = "xxx"
  9712. //} else {
  9713. // user_name = role.UserName
  9714. //}
  9715. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9716. if psn_record.ID == 0 {
  9717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9718. return
  9719. }
  9720. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9721. var res ResultTwo
  9722. var res10265 ResultTwo10265
  9723. if miConfig.Code == "H15049901371" {
  9724. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9725. utils.ErrorLog("解析失败:%v", err)
  9726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9727. return
  9728. }
  9729. res.ErrMsg = res10265.ErrMsg
  9730. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9731. res.Infcode = infocode
  9732. res.Output = res10265.Output
  9733. res.InfRefmsgid = res10265.InfRefmsgid
  9734. } else {
  9735. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9736. utils.ErrorLog("解析失败:%v", err)
  9737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9738. return
  9739. }
  9740. }
  9741. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9742. infoStr := string(Iinfos)
  9743. var rf []*ResultFive
  9744. json.Unmarshal([]byte(infoStr), &rf)
  9745. var insuplc_admdvs string
  9746. var insutype string
  9747. var is390 int = 0
  9748. var is310 int = 0
  9749. var insutypes []*ResultFive
  9750. for _, item := range rf {
  9751. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9752. insutypes = append(insutypes, item)
  9753. }
  9754. }
  9755. if len(insutypes) == 1 {
  9756. insutype = insutypes[0].Insutype
  9757. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9758. } else {
  9759. for _, i := range insutypes {
  9760. if i.Insutype == "390" {
  9761. is390 = 1
  9762. }
  9763. if i.Insutype == "310" {
  9764. is310 = 1
  9765. }
  9766. }
  9767. }
  9768. if is390 == 1 {
  9769. insutype = "390"
  9770. }
  9771. if is310 == 1 {
  9772. insutype = "310"
  9773. }
  9774. if len(insutypes) == 0 {
  9775. insutype = "310"
  9776. }
  9777. insutype = psn_record.Insutype
  9778. for _, item := range rf {
  9779. if item.Insutype == insutype {
  9780. insuplc_admdvs = item.InsuplcAdmdvs
  9781. }
  9782. }
  9783. if config.IsOpen == 1 {
  9784. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9785. var dat map[string]interface{}
  9786. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9787. fmt.Println(dat)
  9788. } else {
  9789. fmt.Println(err)
  9790. }
  9791. userJSONBytes, _ := json.Marshal(dat)
  9792. var res ResultFourteen
  9793. var res10265 ResultFourteen10265
  9794. if miConfig.Code == "H15049901371" {
  9795. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9796. utils.ErrorLog("解析失败:%v", err)
  9797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9798. return
  9799. }
  9800. res.ErrMsg = res10265.ErrMsg
  9801. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9802. res.Infcode = infocode
  9803. res.Output = res10265.Output
  9804. res.InfRefmsgid = res10265.InfRefmsgid
  9805. } else {
  9806. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9807. utils.ErrorLog("解析失败:%v", err)
  9808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9809. return
  9810. }
  9811. }
  9812. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9813. // utils.ErrorLog("解析失败:%v", err)
  9814. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9815. // return
  9816. //}
  9817. if res.Infcode == 0 {
  9818. psn_record.IsCancel = 2
  9819. service.CreatePsnNCDSRecord(&psn_record)
  9820. c.ServeSuccessJSON(map[string]interface{}{
  9821. "failed_code": 0,
  9822. "msg": "撤销备案成功",
  9823. })
  9824. } else {
  9825. c.ServeSuccessJSON(map[string]interface{}{
  9826. "failed_code": -10,
  9827. "msg": res.ErrMsg,
  9828. })
  9829. return
  9830. }
  9831. }
  9832. }
  9833. func (c *HisApiController) TestTest() {
  9834. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9835. fmt.Println(patient.Iinfo)
  9836. }
  9837. type CustomData struct {
  9838. MsgId string
  9839. PsnNo string
  9840. Info string
  9841. }
  9842. func (c *HisApiController) ReversalData() {
  9843. var customData []*CustomData
  9844. custom := &CustomData{
  9845. MsgId: "H44022900158202103301714472004",
  9846. PsnNo: "44020000001101329945",
  9847. Info: "2207",
  9848. }
  9849. customData = append(customData, custom)
  9850. custom1 := &CustomData{
  9851. MsgId: "H4402290015820210330172057803",
  9852. PsnNo: "44020000001101161813",
  9853. Info: "2207",
  9854. }
  9855. customData = append(customData, custom1)
  9856. custom2 := &CustomData{
  9857. MsgId: "H44022900158202103301705198813",
  9858. PsnNo: "44190000133097375417",
  9859. Info: "2207",
  9860. }
  9861. customData = append(customData, custom2)
  9862. custom3 := &CustomData{
  9863. MsgId: "H44022900158202103301715524756",
  9864. PsnNo: "44020000001100187221",
  9865. Info: "2207",
  9866. }
  9867. customData = append(customData, custom3)
  9868. custom4 := &CustomData{
  9869. MsgId: "H44022900158202103301730376224",
  9870. PsnNo: "44020000001101959155",
  9871. Info: "2207",
  9872. }
  9873. customData = append(customData, custom4)
  9874. custom5 := &CustomData{
  9875. MsgId: "H44022900158202103301748008725",
  9876. PsnNo: "44020000001104246641",
  9877. Info: "2207",
  9878. }
  9879. customData = append(customData, custom5)
  9880. custom6 := &CustomData{
  9881. MsgId: "H44022900158202103301718096755",
  9882. PsnNo: "44020000001102211860",
  9883. Info: "2207",
  9884. }
  9885. customData = append(customData, custom6)
  9886. custom7 := &CustomData{
  9887. MsgId: "H44022900158202103301736551640",
  9888. PsnNo: "44020000001102687718",
  9889. Info: "2207",
  9890. }
  9891. customData = append(customData, custom7)
  9892. custom8 := &CustomData{
  9893. MsgId: "H44022900158202103301743097676",
  9894. PsnNo: "44020000001102127785",
  9895. Info: "2207",
  9896. }
  9897. customData = append(customData, custom8)
  9898. custom9 := &CustomData{
  9899. MsgId: "H44022900158202103301712304203",
  9900. PsnNo: "44020000001101518097",
  9901. Info: "2207",
  9902. }
  9903. customData = append(customData, custom9)
  9904. custom10 := &CustomData{
  9905. MsgId: "H44022900158202103301738448785",
  9906. PsnNo: "44020000001100500813",
  9907. Info: "2207",
  9908. }
  9909. customData = append(customData, custom10)
  9910. custom11 := &CustomData{
  9911. MsgId: "H44022900158202103301732455843",
  9912. PsnNo: "44020000001102690557",
  9913. Info: "2207",
  9914. }
  9915. customData = append(customData, custom11)
  9916. custom12 := &CustomData{
  9917. MsgId: "H44022900158202103301745421708",
  9918. PsnNo: "44020000001102211928",
  9919. Info: "2207",
  9920. }
  9921. customData = append(customData, custom12)
  9922. custom1212 := &CustomData{
  9923. MsgId: "H440229001582021033017351627",
  9924. PsnNo: "44020000001102481733",
  9925. Info: "2207",
  9926. }
  9927. customData = append(customData, custom1212)
  9928. custom13 := &CustomData{
  9929. MsgId: "H44022900158202103301740327951",
  9930. PsnNo: "44020000001103174866",
  9931. Info: "2207",
  9932. }
  9933. customData = append(customData, custom13)
  9934. custom14 := &CustomData{
  9935. MsgId: "H4402290015820210330174922668",
  9936. PsnNo: "44020000001102927272",
  9937. Info: "2207",
  9938. }
  9939. customData = append(customData, custom14)
  9940. custom15 := &CustomData{
  9941. MsgId: "H44022900158202103301752362273",
  9942. PsnNo: "44020000001102942890",
  9943. Info: "2207",
  9944. }
  9945. customData = append(customData, custom15)
  9946. custom16 := &CustomData{
  9947. MsgId: "H44022900158202103301751082917",
  9948. PsnNo: "44020000001101662162",
  9949. Info: "2207",
  9950. }
  9951. customData = append(customData, custom16)
  9952. custom17 := &CustomData{
  9953. MsgId: "H44022900158202103301754147728",
  9954. PsnNo: "44020000000229014511",
  9955. Info: "2207",
  9956. }
  9957. customData = append(customData, custom17)
  9958. adminUser := c.GetAdminUserInfo()
  9959. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9960. for _, item := range customData {
  9961. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9962. fmt.Println(result)
  9963. }
  9964. }
  9965. func (c *HisApiController) GetAllopatry() {
  9966. year := c.GetString("year")
  9967. month := c.GetString("month")
  9968. admin_user_id, _ := c.GetInt64("admin_user_id")
  9969. adminUser := c.GetAdminUserInfo()
  9970. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9971. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9972. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9973. var dat map[string]interface{}
  9974. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9975. fmt.Println(dat)
  9976. } else {
  9977. fmt.Println(err)
  9978. }
  9979. userJSONBytes, _ := json.Marshal(dat)
  9980. var res models.Result9001
  9981. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9982. utils.ErrorLog("解析失败:%v", err)
  9983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9984. return
  9985. }
  9986. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9987. var dat2 map[string]interface{}
  9988. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9989. fmt.Println(dat)
  9990. } else {
  9991. fmt.Println(err)
  9992. }
  9993. userJSONBytes2, _ := json.Marshal(dat2)
  9994. var res2 models.Result3260
  9995. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9996. utils.ErrorLog("解析失败:%v", err)
  9997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9998. return
  9999. }
  10000. if res2.Infcode == 0 {
  10001. c.ServeSuccessJSON(map[string]interface{}{
  10002. "list": res2.Output.Data,
  10003. })
  10004. return
  10005. } else {
  10006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10007. return
  10008. }
  10009. }
  10010. func (c *HisApiController) ComfirmAllopatry() {
  10011. year := c.GetString("year")
  10012. month := c.GetString("month")
  10013. admin_user_id, _ := c.GetInt64("admin_user_id")
  10014. adminUser := c.GetAdminUserInfo()
  10015. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10016. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10017. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10018. var dat map[string]interface{}
  10019. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10020. fmt.Println(dat)
  10021. } else {
  10022. fmt.Println(err)
  10023. }
  10024. userJSONBytes, _ := json.Marshal(dat)
  10025. var res models.Result9001
  10026. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10027. utils.ErrorLog("解析失败:%v", err)
  10028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10029. return
  10030. }
  10031. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10032. var dat2 map[string]interface{}
  10033. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10034. fmt.Println(dat)
  10035. } else {
  10036. fmt.Println(err)
  10037. }
  10038. userJSONBytes2, _ := json.Marshal(dat2)
  10039. var res2 models.Result3260
  10040. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10041. utils.ErrorLog("解析失败:%v", err)
  10042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10043. return
  10044. }
  10045. if res2.Infcode == 0 {
  10046. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10047. var dat map[string]interface{}
  10048. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10049. fmt.Println(dat)
  10050. } else {
  10051. fmt.Println(err)
  10052. }
  10053. userJSONBytes, _ := json.Marshal(dat)
  10054. var res3 models.Result3261
  10055. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10056. utils.ErrorLog("解析失败:%v", err)
  10057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10058. return
  10059. }
  10060. if res3.Infcode == 0 {
  10061. record := &models.HisYidiClearRecord{
  10062. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10063. Ctime: time.Now().Unix(),
  10064. Mtime: time.Now().Unix(),
  10065. Status: 1,
  10066. MsgId: msgId,
  10067. }
  10068. service.SaveClearRecord(record)
  10069. c.ServeSuccessJSON(map[string]interface{}{
  10070. "msg": "提取成功",
  10071. })
  10072. }
  10073. }
  10074. }
  10075. func (c *HisApiController) RefundAllopatry() {
  10076. year := c.GetString("year")
  10077. month := c.GetString("month")
  10078. id, _ := c.GetInt64("id")
  10079. admin_user_id, _ := c.GetInt64("admin_user_id")
  10080. adminUser := c.GetAdminUserInfo()
  10081. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10082. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10083. record, _ := service.GetClearRecordById(id)
  10084. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10085. var dat map[string]interface{}
  10086. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10087. fmt.Println(dat)
  10088. } else {
  10089. fmt.Println(err)
  10090. }
  10091. userJSONBytes, _ := json.Marshal(dat)
  10092. var empty ResultFourteen
  10093. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10094. utils.ErrorLog("解析失败:%v", err)
  10095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10096. return
  10097. }
  10098. if empty.Infcode == 0 {
  10099. c.ServeSuccessJSON(map[string]interface{}{
  10100. "msg": "撤销成功",
  10101. })
  10102. return
  10103. }
  10104. }
  10105. func (c *HisApiController) ReversalOtherData() {
  10106. var customData []*CustomData
  10107. custom := &CustomData{
  10108. MsgId: "H44022900158202103301714472004",
  10109. PsnNo: "44020000001101329945",
  10110. Info: "2208",
  10111. }
  10112. customData = append(customData, custom)
  10113. custom1 := &CustomData{
  10114. MsgId: "H4402290015820210330172057803",
  10115. PsnNo: "44020000001101161813",
  10116. Info: "2208",
  10117. }
  10118. customData = append(customData, custom1)
  10119. custom2 := &CustomData{
  10120. MsgId: "H44022900158202103301705198813",
  10121. PsnNo: "44190000133097375417",
  10122. Info: "2208",
  10123. }
  10124. customData = append(customData, custom2)
  10125. custom3 := &CustomData{
  10126. MsgId: "H44022900158202103301715524756",
  10127. PsnNo: "44020000001100187221",
  10128. Info: "2208",
  10129. }
  10130. customData = append(customData, custom3)
  10131. custom4 := &CustomData{
  10132. MsgId: "H44022900158202103301730376224",
  10133. PsnNo: "44020000001101959155",
  10134. Info: "2208",
  10135. }
  10136. customData = append(customData, custom4)
  10137. custom5 := &CustomData{
  10138. MsgId: "H44022900158202103301748008725",
  10139. PsnNo: "44020000001104246641",
  10140. Info: "2208",
  10141. }
  10142. customData = append(customData, custom5)
  10143. custom6 := &CustomData{
  10144. MsgId: "H44022900158202103301718096755",
  10145. PsnNo: "44020000001102211860",
  10146. Info: "2208",
  10147. }
  10148. customData = append(customData, custom6)
  10149. custom7 := &CustomData{
  10150. MsgId: "H44022900158202103301736551640",
  10151. PsnNo: "44020000001102687718",
  10152. Info: "2208",
  10153. }
  10154. customData = append(customData, custom7)
  10155. custom8 := &CustomData{
  10156. MsgId: "H44022900158202103301743097676",
  10157. PsnNo: "44020000001102127785",
  10158. Info: "2208",
  10159. }
  10160. customData = append(customData, custom8)
  10161. custom9 := &CustomData{
  10162. MsgId: "H44022900158202103301712304203",
  10163. PsnNo: "44020000001101518097",
  10164. Info: "2208",
  10165. }
  10166. customData = append(customData, custom9)
  10167. custom10 := &CustomData{
  10168. MsgId: "H44022900158202103301738448785",
  10169. PsnNo: "44020000001100500813",
  10170. Info: "2208",
  10171. }
  10172. customData = append(customData, custom10)
  10173. custom11 := &CustomData{
  10174. MsgId: "H44022900158202103301732455843",
  10175. PsnNo: "44020000001102690557",
  10176. Info: "2208",
  10177. }
  10178. customData = append(customData, custom11)
  10179. custom12 := &CustomData{
  10180. MsgId: "H44022900158202103301745421708",
  10181. PsnNo: "44020000001102211928",
  10182. Info: "2208",
  10183. }
  10184. customData = append(customData, custom12)
  10185. custom1212 := &CustomData{
  10186. MsgId: "H440229001582021033017351627",
  10187. PsnNo: "44020000001102481733",
  10188. Info: "2208",
  10189. }
  10190. customData = append(customData, custom1212)
  10191. custom13 := &CustomData{
  10192. MsgId: "H44022900158202103301740327951",
  10193. PsnNo: "44020000001103174866",
  10194. Info: "2208",
  10195. }
  10196. customData = append(customData, custom13)
  10197. custom14 := &CustomData{
  10198. MsgId: "H4402290015820210330174922668",
  10199. PsnNo: "44020000001102927272",
  10200. Info: "2208",
  10201. }
  10202. customData = append(customData, custom14)
  10203. custom15 := &CustomData{
  10204. MsgId: "H44022900158202103301752362273",
  10205. PsnNo: "44020000001102942890",
  10206. Info: "2208",
  10207. }
  10208. customData = append(customData, custom15)
  10209. custom16 := &CustomData{
  10210. MsgId: "H44022900158202103301751082917",
  10211. PsnNo: "44020000001101662162",
  10212. Info: "2208",
  10213. }
  10214. customData = append(customData, custom16)
  10215. custom17 := &CustomData{
  10216. MsgId: "H44022900158202103301754147728",
  10217. PsnNo: "44020000000229014511",
  10218. Info: "2208",
  10219. }
  10220. customData = append(customData, custom17)
  10221. adminUser := c.GetAdminUserInfo()
  10222. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10223. for _, item := range customData {
  10224. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10225. fmt.Println(result)
  10226. }
  10227. }
  10228. func PathExists(path string) (bool, error) {
  10229. _, err := os.Stat(path)
  10230. if err == nil {
  10231. return true, nil
  10232. }
  10233. if os.IsNotExist(err) {
  10234. return false, nil
  10235. }
  10236. return false, err
  10237. }
  10238. //创建文件夹
  10239. func Mkdir(dir string) {
  10240. // 创建文件夹
  10241. exist, err := PathExists(dir)
  10242. if err != nil {
  10243. fmt.Println(err.Error())
  10244. } else {
  10245. if exist {
  10246. fmt.Println(dir + "文件夹已存在!")
  10247. } else {
  10248. // 文件夹名称,权限
  10249. err := os.Mkdir(dir, os.ModePerm)
  10250. if err != nil {
  10251. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10252. } else {
  10253. fmt.Println(dir + "文件夹创建成功!")
  10254. }
  10255. }
  10256. }
  10257. }
  10258. //压缩文件
  10259. func Zip(srcFile string, destZip string) error {
  10260. zipfile, err := os.Create(destZip)
  10261. if err != nil {
  10262. return err
  10263. }
  10264. defer zipfile.Close()
  10265. archive := zip.NewWriter(zipfile)
  10266. defer archive.Close()
  10267. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10268. if err != nil {
  10269. return err
  10270. }
  10271. header, err := zip.FileInfoHeader(info)
  10272. if err != nil {
  10273. return err
  10274. }
  10275. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10276. // header.Name = path
  10277. if info.IsDir() {
  10278. header.Name += "/"
  10279. } else {
  10280. header.Method = zip.Deflate
  10281. }
  10282. writer, err := archive.CreateHeader(header)
  10283. if err != nil {
  10284. return err
  10285. }
  10286. if !info.IsDir() {
  10287. file, err := os.Open(path)
  10288. if err != nil {
  10289. return err
  10290. }
  10291. defer file.Close()
  10292. _, err = io.Copy(writer, file)
  10293. }
  10294. return err
  10295. })
  10296. return err
  10297. }
  10298. func ReadFile(filePath string) []byte {
  10299. f, err := os.Open(filePath)
  10300. if err != nil {
  10301. fmt.Println("read file fail", err)
  10302. return nil
  10303. }
  10304. defer f.Close()
  10305. fd, err := ioutil.ReadAll(f)
  10306. if err != nil {
  10307. fmt.Println("read to fd fail", err)
  10308. return nil
  10309. }
  10310. return fd
  10311. }
  10312. func saveLog(result string, request string, infno string, desc string) {
  10313. org_id, _ := beego.AppConfig.Int64("org_id")
  10314. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10315. dir := miConfig.OrgName + "日志"
  10316. utils.Mkdir(dir)
  10317. month := time.Unix(1557042972, 0).Format("1")
  10318. year := time.Now().Format("2006")
  10319. month = time.Now().Format("01")
  10320. day := time.Now().Format("02")
  10321. hour := time.Now().Format("15")
  10322. min := time.Now().Format("04")
  10323. sec := time.Now().Format("05")
  10324. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10325. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10326. file_name := file + ".txt"
  10327. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10328. exist, _ := utils.PathExists(file_path)
  10329. if exist { //存在
  10330. fmt.Println("存在")
  10331. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10332. if err != nil {
  10333. fmt.Println("read fail")
  10334. }
  10335. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10336. n, _ := f.Seek(0, 2)
  10337. _, err = f.WriteAt([]byte(content), n)
  10338. } else { //不存在
  10339. fmt.Println("文件不存在,创建文件")
  10340. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10341. defer f.Close()
  10342. if err != nil {
  10343. } else {
  10344. _, err = f.Write([]byte("记录日志"))
  10345. }
  10346. }
  10347. }
  10348. type Charset string
  10349. const (
  10350. UTF8 = Charset("UTF-8")
  10351. GB18030 = Charset("GB18030")
  10352. )
  10353. func ConvertToString(src string, srcCode string, tagCode string) string {
  10354. srcCoder := mahonia.NewDecoder(srcCode)
  10355. srcResult := srcCoder.ConvertString(src)
  10356. tagCoder := mahonia.NewDecoder(tagCode)
  10357. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10358. result := string(cdata)
  10359. return result
  10360. }