his_api_controller.go 422KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. }
  76. func (c *HisApiController) Check3101() {
  77. patient_id, _ := c.GetInt64("patient_id")
  78. his_patient_id, _ := c.GetInt64("his_patient_id")
  79. admin_user_id, _ := c.GetInt64("admin_user_id")
  80. adminUser := c.GetAdminUserInfo()
  81. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  82. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  83. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  84. record_time := c.GetString("record_time")
  85. trig_scen := c.GetString("trig_scen")
  86. timeLayout := "2006-01-02"
  87. loc, _ := time.LoadLocation("Local")
  88. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  89. if err != nil {
  90. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  91. return
  92. }
  93. recordDateTime := theTime.Unix()
  94. var patientPrescription models.HisPrescriptionInfo
  95. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  96. if patientPrescription.ID == 0 {
  97. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  98. }
  99. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  100. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  101. //
  102. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  103. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  104. var pp models.PublicParams
  105. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  106. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  107. pp.FixmedinsName = miConfig.OrgName
  108. pp.FixmedinsCode = miConfig.Code
  109. pp.RequestUrl = miConfig.Url
  110. pp.Cainfo = miConfig.Cainfo
  111. pp.SecretKey = miConfig.SecretKey
  112. pp.AccessKey = miConfig.AccessKey
  113. pp.OpterName = roles.UserName
  114. var config []*models.HisXtDiagnoseConfig
  115. for _, item := range diagnosis_ids {
  116. id, _ := strconv.ParseInt(item, 10, 64)
  117. diagnosisConfig, _ := service.FindDiagnoseById(id)
  118. config = append(config, &diagnosisConfig)
  119. }
  120. var pd models.PatientDtos
  121. pd.PatnID = his.PsnNo
  122. pd.PatnName = his.Name
  123. pd.Gend = his.Gend
  124. pd.Brdy = his.Brdy
  125. pd.Poolarea = his.InsuplcAdmdvs
  126. pd.CurrMdtrtID = his.Number
  127. var fed models.FsiEncounterDtos
  128. fed.MdtrtID = his.Number
  129. fed.MedinsID = miConfig.Code
  130. fed.MedinsName = miConfig.OrgName
  131. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  132. fed.MedMdtrtType = "1"
  133. fed.MedinsType = "1"
  134. fed.MedinsLv = "11"
  135. tm := time.Unix(his.RecordDate, 0)
  136. s_tm := tm.Format("2006-01-02 15:04:05")
  137. fed.AdmDate = s_tm
  138. fed.DscgDate = s_tm
  139. fed.DscgMainDiseCodg = config[0].CountryCode
  140. fed.DscgMainDiseName = config[0].CountryContentName
  141. //诊断信息
  142. var fdds []*models.FsiDiagnoseDtos
  143. for index, item := range config {
  144. if index == 0 {
  145. var fdd models.FsiDiagnoseDtos
  146. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  147. fdd.InoutDiseType = "1"
  148. fdd.MaindiseFlag = "1"
  149. fdd.DiseDate = s_tm
  150. fdd.DiasSrtNo = "1"
  151. fdd.DiseName = item.CountryContentName
  152. fdd.DiseCodg = item.CountryCode
  153. fdds = append(fdds, &fdd)
  154. } else {
  155. var fdd models.FsiDiagnoseDtos
  156. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  157. fdd.InoutDiseType = "1"
  158. fdd.MaindiseFlag = "1"
  159. fdd.DiseDate = s_tm
  160. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  161. fdd.DiseName = item.CountryContentName
  162. fdd.DiseCodg = item.CountryCode
  163. fdds = append(fdds, &fdd)
  164. }
  165. }
  166. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  167. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  168. fed.AdmDeptName = department.Name
  169. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  170. fed.DscgDeptName = department.Name
  171. fed.MedMdtrtType = "1"
  172. if his.Insutype == "390" {
  173. fed.MedType = "1402"
  174. } else {
  175. fed.MedType = "9933"
  176. }
  177. var orders []*models.FsiOrderDtos
  178. if trig_scen == "2" {
  179. //处方医嘱信息
  180. for _, item := range prescriptions {
  181. for _, subItem := range item.HisDoctorAdviceInfo {
  182. var order models.FsiOrderDtos
  183. order.RxID = strconv.FormatInt(item.ID, 10)
  184. order.Rxno = strconv.FormatInt(item.ID, 10)
  185. order.LongDrordFlag = "0"
  186. order.HilistType = "1"
  187. order.ChrgType = "1"
  188. order.DrordBhvr = "-"
  189. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  190. order.HosplistName = subItem.BaseDrugLib.DrugName
  191. order.HilistLv = "1"
  192. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  193. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  194. order.HosplistName = subItem.BaseDrugLib.DrugName
  195. order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  196. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  197. order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  198. order.OwnpayAmt = ""
  199. order.SelfpayAmt = ""
  200. order.Spec = ""
  201. order.SpecUnt = ""
  202. order.DrordBegnDate = s_tm
  203. order.DrordStopDate = ""
  204. order.DrordDrCodg = "1"
  205. order.DrordDeptName = department.Name
  206. order.DrordDrCodg = "1"
  207. order.DrordDrName = doctor_info.UserName
  208. order.DrordDrProfttl = ""
  209. order.CurrDrordFlag = "1"
  210. orders = append(orders, &order)
  211. }
  212. for _, subItem := range item.HisPrescriptionProject {
  213. if subItem.Type == 2 {
  214. var order models.FsiOrderDtos
  215. order.RxID = strconv.FormatInt(item.ID, 10)
  216. order.Rxno = strconv.FormatInt(item.ID, 10)
  217. order.LongDrordFlag = "0"
  218. order.HilistType = "1"
  219. order.ChrgType = "1"
  220. order.DrordBhvr = "-"
  221. order.HilistCode = subItem.HisProject.MedicalCode
  222. order.HosplistName = subItem.HisProject.ProjectName
  223. order.HilistLv = "1"
  224. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  225. order.HosplistCode = subItem.HisProject.MedicalCode
  226. order.HosplistName = subItem.HisProject.ProjectName
  227. order.Cnt = subItem.Count
  228. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  229. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  230. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  231. order.OwnpayAmt = ""
  232. order.SelfpayAmt = ""
  233. order.Spec = ""
  234. order.SpecUnt = ""
  235. order.DrordBegnDate = s_tm
  236. order.DrordStopDate = ""
  237. order.DrordDrCodg = "1"
  238. order.DrordDeptName = department.Name
  239. order.DrordDrCodg = "1"
  240. order.DrordDrName = doctor_info.UserName
  241. order.DrordDrProfttl = ""
  242. order.CurrDrordFlag = "1"
  243. orders = append(orders, &order)
  244. }
  245. if subItem.Type == 3 {
  246. var order models.FsiOrderDtos
  247. order.RxID = strconv.FormatInt(item.ID, 10)
  248. order.Rxno = strconv.FormatInt(item.ID, 10)
  249. order.LongDrordFlag = "0"
  250. order.HilistType = "1"
  251. order.ChrgType = "1"
  252. order.DrordBhvr = "-"
  253. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  254. order.HosplistName = subItem.GoodInfo.GoodName
  255. order.HilistLv = "1"
  256. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  257. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  258. order.HosplistName = subItem.GoodInfo.GoodName
  259. order.Cnt = subItem.Count
  260. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  261. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  262. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  263. order.OwnpayAmt = ""
  264. order.SelfpayAmt = ""
  265. order.Spec = ""
  266. order.SpecUnt = ""
  267. order.DrordBegnDate = s_tm
  268. order.DrordStopDate = ""
  269. order.DrordDrCodg = "1"
  270. order.DrordDeptName = department.Name
  271. order.DrordDrCodg = "1"
  272. order.DrordDrName = doctor_info.UserName
  273. order.DrordDrProfttl = ""
  274. order.CurrDrordFlag = "1"
  275. orders = append(orders, &order)
  276. }
  277. }
  278. }
  279. //处方医嘱信息
  280. }
  281. fed.MatnStas = "0"
  282. fed.MedfeeSumamt = "0"
  283. fed.OwnpayAmt = "0"
  284. fed.SelfpayAmt = "0"
  285. fed.AcctPayamt = "0"
  286. fed.MaAmt = "0"
  287. fed.HifpPayamt = "0"
  288. fed.SetlTotlnum = "1"
  289. fed.Insutype = his.Insutype
  290. fed.ReimFlag = "0"
  291. fed.OutSetlFlag = "0"
  292. var fopd []*models.FsiOperationDtosData
  293. data := make(map[string]interface{})
  294. data["fed"] = fed
  295. data["fdd"] = fdds
  296. data["fod"] = orders
  297. data["pd"] = pd
  298. data["pp"] = pp
  299. data["fopd"] = fopd
  300. data["trig_scen"] = trig_scen
  301. fmt.Println(data)
  302. fmt.Println(fed)
  303. fmt.Println(fdds)
  304. fmt.Println(orders)
  305. fmt.Println(pd)
  306. fmt.Println(pp)
  307. fmt.Println(fopd)
  308. client := &http.Client{}
  309. bytesData, _ := json.Marshal(data)
  310. var req *http.Request
  311. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  312. resp, _ := client.Do(req)
  313. defer resp.Body.Close()
  314. body, ioErr := ioutil.ReadAll(resp.Body)
  315. if ioErr != nil {
  316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  318. return
  319. }
  320. var respJSON map[string]interface{}
  321. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  324. return
  325. }
  326. //手术操作集合
  327. //手术操作集合
  328. }
  329. func (c *HisApiController) Check3102() {
  330. patient_id, _ := c.GetInt64("patient_id")
  331. order_id, _ := c.GetInt64("order_id")
  332. his_patient_id, _ := c.GetInt64("his_patient_id")
  333. admin_user_id, _ := c.GetInt64("admin_user_id")
  334. trig_scen := c.GetString("trig_scen")
  335. adminUser := c.GetAdminUserInfo()
  336. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  337. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  338. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  339. record_time := c.GetString("record_time")
  340. order, _ := service.GetHisOrderByID(order_id)
  341. timeLayout := "2006-01-02"
  342. loc, _ := time.LoadLocation("Local")
  343. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  344. if err != nil {
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  346. return
  347. }
  348. recordDateTime := theTime.Unix()
  349. var patientPrescription models.HisPrescriptionInfo
  350. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  351. if patientPrescription.ID == 0 {
  352. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  353. }
  354. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  355. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  356. //
  357. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  358. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  359. var pp models.PublicParams
  360. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  361. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  362. pp.FixmedinsName = miConfig.OrgName
  363. pp.FixmedinsCode = miConfig.Code
  364. pp.RequestUrl = miConfig.Url
  365. pp.Cainfo = miConfig.Cainfo
  366. pp.SecretKey = miConfig.SecretKey
  367. pp.AccessKey = miConfig.AccessKey
  368. pp.OpterName = roles.UserName
  369. var config []*models.HisXtDiagnoseConfig
  370. for _, item := range diagnosis_ids {
  371. id, _ := strconv.ParseInt(item, 10, 64)
  372. diagnosisConfig, _ := service.FindDiagnoseById(id)
  373. config = append(config, &diagnosisConfig)
  374. }
  375. var pd models.PatientDtos
  376. pd.PatnID = his.PsnNo
  377. pd.PatnName = his.Name
  378. pd.Gend = his.Gend
  379. pd.Brdy = his.Brdy
  380. pd.Poolarea = his.InsuplcAdmdvs
  381. pd.CurrMdtrtID = his.Number
  382. var fed models.FsiEncounterDtos
  383. fed.MdtrtID = his.Number
  384. fed.MedinsID = miConfig.Code
  385. fed.MedinsName = miConfig.OrgName
  386. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  387. fed.MedMdtrtType = "1"
  388. fed.MedinsType = "1"
  389. fed.MedinsLv = "11"
  390. tm := time.Unix(his.RecordDate, 0)
  391. s_tm := tm.Format("2006-01-02 15:04:05")
  392. fed.AdmDate = s_tm
  393. fed.DscgDate = s_tm
  394. fed.DscgMainDiseCodg = config[0].CountryCode
  395. fed.DscgMainDiseName = config[0].CountryContentName
  396. //诊断信息
  397. var fdds []*models.FsiDiagnoseDtos
  398. for index, item := range config {
  399. if index == 0 {
  400. var fdd models.FsiDiagnoseDtos
  401. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  402. fdd.InoutDiseType = "1"
  403. fdd.MaindiseFlag = "1"
  404. fdd.DiseDate = s_tm
  405. fdd.DiasSrtNo = "1"
  406. fdd.DiseName = item.CountryContentName
  407. fdd.DiseCodg = item.CountryCode
  408. fdds = append(fdds, &fdd)
  409. } else {
  410. var fdd models.FsiDiagnoseDtos
  411. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  412. fdd.InoutDiseType = "1"
  413. fdd.MaindiseFlag = "1"
  414. fdd.DiseDate = s_tm
  415. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  416. fdd.DiseName = item.CountryContentName
  417. fdd.DiseCodg = item.CountryCode
  418. fdds = append(fdds, &fdd)
  419. }
  420. }
  421. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  422. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  423. fed.AdmDeptName = department.Name
  424. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  425. fed.DscgDeptName = department.Name
  426. fed.MedMdtrtType = ""
  427. fed.MedType = order.MedType
  428. //处方医嘱信息
  429. var orders []*models.FsiOrderDtos
  430. for _, item := range prescriptions {
  431. for _, subItem := range item.HisDoctorAdviceInfo {
  432. var order models.FsiOrderDtos
  433. order.RxID = strconv.FormatInt(item.ID, 10)
  434. order.Rxno = strconv.FormatInt(item.ID, 10)
  435. order.LongDrordFlag = "0"
  436. order.HilistType = "1"
  437. order.ChrgType = "1"
  438. order.DrordBhvr = "-"
  439. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  440. order.HosplistName = subItem.BaseDrugLib.DrugName
  441. order.HilistLv = "1"
  442. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  443. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  444. order.HosplistName = subItem.BaseDrugLib.DrugName
  445. order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  446. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  447. order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  448. order.OwnpayAmt = ""
  449. order.SelfpayAmt = ""
  450. order.Spec = ""
  451. order.SpecUnt = ""
  452. order.DrordBegnDate = s_tm
  453. order.DrordStopDate = ""
  454. order.DrordDrCodg = "1"
  455. order.DrordDeptName = department.Name
  456. order.DrordDrCodg = "1"
  457. order.DrordDrName = doctor_info.UserName
  458. order.DrordDrProfttl = ""
  459. order.CurrDrordFlag = "1"
  460. orders = append(orders, &order)
  461. }
  462. for _, subItem := range item.HisPrescriptionProject {
  463. if subItem.Type == 2 {
  464. var order models.FsiOrderDtos
  465. order.RxID = strconv.FormatInt(item.ID, 10)
  466. order.Rxno = strconv.FormatInt(item.ID, 10)
  467. order.LongDrordFlag = "0"
  468. order.HilistType = "1"
  469. order.ChrgType = "1"
  470. order.DrordBhvr = "-"
  471. order.HilistCode = subItem.HisProject.MedicalCode
  472. order.HosplistName = subItem.HisProject.ProjectName
  473. order.HilistLv = "1"
  474. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  475. order.HosplistCode = subItem.HisProject.MedicalCode
  476. order.HosplistName = subItem.HisProject.ProjectName
  477. order.Cnt = subItem.Count
  478. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  479. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  480. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  481. order.OwnpayAmt = ""
  482. order.SelfpayAmt = ""
  483. order.Spec = ""
  484. order.SpecUnt = ""
  485. order.DrordBegnDate = s_tm
  486. order.DrordStopDate = ""
  487. order.DrordDrCodg = "1"
  488. order.DrordDeptName = department.Name
  489. order.DrordDrCodg = "1"
  490. order.DrordDrName = doctor_info.UserName
  491. order.DrordDrProfttl = ""
  492. order.CurrDrordFlag = "1"
  493. orders = append(orders, &order)
  494. }
  495. if subItem.Type == 3 {
  496. var order models.FsiOrderDtos
  497. order.RxID = strconv.FormatInt(item.ID, 10)
  498. order.Rxno = strconv.FormatInt(item.ID, 10)
  499. order.LongDrordFlag = "0"
  500. order.HilistType = "1"
  501. order.ChrgType = "1"
  502. order.DrordBhvr = "-"
  503. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  504. order.HosplistName = subItem.GoodInfo.GoodName
  505. order.HilistLv = "1"
  506. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  507. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  508. order.HosplistName = subItem.GoodInfo.GoodName
  509. order.Cnt = subItem.Count
  510. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  511. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  512. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  513. order.OwnpayAmt = ""
  514. order.SelfpayAmt = ""
  515. order.Spec = ""
  516. order.SpecUnt = ""
  517. order.DrordBegnDate = s_tm
  518. order.DrordStopDate = ""
  519. order.DrordDrCodg = "1"
  520. order.DrordDeptName = department.Name
  521. order.DrordDrCodg = "1"
  522. order.DrordDrName = doctor_info.UserName
  523. order.DrordDrProfttl = ""
  524. order.CurrDrordFlag = "1"
  525. orders = append(orders, &order)
  526. }
  527. }
  528. }
  529. //处方医嘱信息
  530. fed.MatnStas = "0"
  531. fed.MedfeeSumamt = strconv.FormatFloat(order.MedfeeSumamt, 'E', -1, 64)
  532. fed.OwnpayAmt = strconv.FormatFloat(order.FulamtOwnpayAmt, 'E', -1, 64)
  533. fed.SelfpayAmt = strconv.FormatFloat(order.PreselfpayAmt, 'E', -1, 64)
  534. fed.AcctPayamt = strconv.FormatFloat(order.AcctPay, 'E', -1, 64)
  535. fed.MaAmt = strconv.FormatFloat(order.MafPay, 'E', -1, 64)
  536. fed.HifpPayamt = strconv.FormatFloat(order.HifpPay, 'E', -1, 64)
  537. fed.SetlTotlnum = "1"
  538. fed.Insutype = his.Insutype
  539. fed.ReimFlag = "0"
  540. fed.OutSetlFlag = "0"
  541. var fopd []*models.FsiOperationDtosData
  542. data := make(map[string]interface{})
  543. data["fed"] = fed
  544. data["fdd"] = fdds
  545. data["fod"] = orders
  546. data["pd"] = pd
  547. data["pp"] = pp
  548. data["fopd"] = fopd
  549. data["trig_scen"] = trig_scen
  550. fmt.Println(data)
  551. fmt.Println(fed)
  552. fmt.Println(fdds)
  553. fmt.Println(orders)
  554. fmt.Println(pd)
  555. fmt.Println(pp)
  556. fmt.Println(fopd)
  557. client := &http.Client{}
  558. bytesData, _ := json.Marshal(data)
  559. var req *http.Request
  560. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  561. resp, _ := client.Do(req)
  562. defer resp.Body.Close()
  563. body, ioErr := ioutil.ReadAll(resp.Body)
  564. if ioErr != nil {
  565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  567. return
  568. }
  569. var respJSON map[string]interface{}
  570. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  573. return
  574. }
  575. //手术操作集合
  576. //手术操作集合
  577. }
  578. func (c *HisApiController) Check() {
  579. psn_no := c.GetString("psn_no")
  580. in := c.GetString("in")
  581. mt := c.GetString("mt")
  582. baseParams := models.BaseParams{
  583. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  584. FixmedinsCode: "H15049901371",
  585. InsuplcAdmdvs: "150499",
  586. MdtrtareaAdmvs: "150499",
  587. OrgName: "赤峰费森血液透析中心",
  588. Doctor: "1111",
  589. }
  590. service.Gdyb2001(baseParams, psn_no, in, mt)
  591. }
  592. func (c *HisApiController) GetPsnNcdsInfo() {
  593. admin_user_id, _ := c.GetInt64("admin_user_id")
  594. patient_id, _ := c.GetInt64("patient_id")
  595. id, _ := c.GetInt64("id")
  596. adminUser := c.GetAdminUserInfo()
  597. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  598. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  599. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  600. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  601. psn_record, _ := service.GetPsnNCDSRecordById(id)
  602. //
  603. //if psn_record.ID == 0 {
  604. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  605. // return
  606. //}
  607. var res Result5301
  608. var res10265 Result5301For10265
  609. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  610. psn_info, _ := service.GetPsnByPatientId(patient_id)
  611. var api string
  612. if miConfig.MdtrtareaAdmvs == "320921" {
  613. 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 +
  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. } else {
  616. 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 +
  617. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  618. }
  619. resp, requestErr := http.Get(api)
  620. if requestErr != nil {
  621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  622. return
  623. }
  624. body, ioErr := ioutil.ReadAll(resp.Body)
  625. if ioErr != nil {
  626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  628. return
  629. }
  630. var respJSON map[string]interface{}
  631. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  634. return
  635. }
  636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  637. result, _ := json.Marshal(respJSON)
  638. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  639. utils.ErrorLog("解析失败:%v", err)
  640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  641. return
  642. }
  643. res.ErrMsg = res10265.ErrMsg
  644. res.Output = res10265.Output
  645. res.InfRefmsgid = res10265.InfRefmsgid
  646. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  647. res.Infcode = infocode
  648. } else {
  649. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  650. var dat map[string]interface{}
  651. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  652. fmt.Println(dat)
  653. } else {
  654. fmt.Println(err)
  655. }
  656. userJSONBytes, _ := json.Marshal(dat)
  657. if miConfig.Code == "H15049901371" {
  658. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  659. utils.ErrorLog("解析失败:%v", err)
  660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  661. return
  662. }
  663. res.InfRefmsgid = res10265.InfRefmsgid
  664. res.Output = res10265.Output
  665. res.ErrMsg = res10265.ErrMsg
  666. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  667. res.Infcode = infocode
  668. } else {
  669. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  670. utils.ErrorLog("解析失败:%v", err)
  671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  672. return
  673. }
  674. }
  675. }
  676. if res.Infcode == 0 {
  677. c.ServeSuccessJSON(map[string]interface{}{
  678. "result": res.Output.Result,
  679. })
  680. }
  681. }
  682. func (c *HisApiController) CheckInsutype() {
  683. his_patient_id, _ := c.GetInt64("his_patient_id")
  684. admin_user_id, _ := c.GetInt64("admin_user_id")
  685. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  686. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  687. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  688. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  689. var dat map[string]interface{}
  690. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  691. fmt.Println(dat)
  692. } else {
  693. fmt.Println(err)
  694. }
  695. userJSONBytes, _ := json.Marshal(dat)
  696. var res Result90100
  697. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  698. utils.ErrorLog("解析失败:%v", err)
  699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  700. return
  701. }
  702. if res.Infcode != 0 {
  703. c.ServeSuccessJSON(map[string]interface{}{
  704. "failed_code": -10,
  705. "msg": res.ErrMsg,
  706. })
  707. return
  708. } else {
  709. fmt.Println(res)
  710. }
  711. }
  712. func (c *HisApiController) CheckCardPWD() {
  713. card_pwd := c.GetString("card_pwd")
  714. his_patient_id, _ := c.GetInt64("his_patient_id")
  715. admin_user_id, _ := c.GetInt64("admin_user_id")
  716. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  717. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  718. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  719. psn, _ := service.GetPsnByPatientId(his.PatientId)
  720. bas := strings.Split(psn.CardInfo, "|")
  721. basNumber := bas[2]
  722. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  723. var dat map[string]interface{}
  724. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  725. fmt.Println(dat)
  726. } else {
  727. fmt.Println(err)
  728. }
  729. userJSONBytes, _ := json.Marshal(dat)
  730. var res Result90991
  731. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  732. utils.ErrorLog("解析失败:%v", err)
  733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  734. return
  735. }
  736. if res.Infcode != 0 {
  737. c.ServeSuccessJSON(map[string]interface{}{
  738. "failed_code": -10,
  739. "msg": res.ErrMsg,
  740. })
  741. return
  742. } else {
  743. if res.Output.Result.CheckStat == "0" {
  744. var msg string
  745. switch res.Output.Result.CardStat {
  746. case "00":
  747. msg = "未激活"
  748. break
  749. case "10":
  750. msg = "激活"
  751. break
  752. case "20":
  753. msg = "窗口挂失"
  754. break
  755. case "21":
  756. msg = "电话挂失"
  757. break
  758. case "22":
  759. msg = "单位网上申报挂失"
  760. break
  761. case "23":
  762. msg = "保健办挂失"
  763. break
  764. case "24":
  765. msg = "个人网上挂失"
  766. break
  767. case "25":
  768. msg = "网上服务大厅挂失"
  769. break
  770. case "30":
  771. msg = "注销"
  772. break
  773. case "40":
  774. msg = "回收"
  775. break
  776. case "99":
  777. msg = "制卡中(无效卡)"
  778. break
  779. }
  780. c.ServeSuccessJSON(map[string]interface{}{
  781. "failed_code": -10,
  782. "msg": msg,
  783. })
  784. return
  785. } else {
  786. c.ServeSuccessJSON(map[string]interface{}{
  787. "msg": "校验成功",
  788. })
  789. return
  790. }
  791. }
  792. }
  793. func (c *HisApiController) ReadCard() {
  794. id_card_type, _ := c.GetInt64("id_card_type")
  795. admin_user_id, _ := c.GetInt64("admin_user_id")
  796. certificates, _ := c.GetInt64("certificates")
  797. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  798. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  799. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  800. switch id_card_type {
  801. case 1:
  802. if miConfig.MdtrtareaAdmvs == "421300" {
  803. var res ResultTwo
  804. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  805. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  806. "&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)
  807. resp, requestErr := http.Get(api)
  808. if requestErr != nil {
  809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  810. return
  811. }
  812. body, ioErr := ioutil.ReadAll(resp.Body)
  813. if ioErr != nil {
  814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  816. return
  817. }
  818. var respJSON map[string]interface{}
  819. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  822. return
  823. }
  824. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  825. result, _ := json.Marshal(respJSON)
  826. fmt.Println("log")
  827. fmt.Println(string(result))
  828. if err := json.Unmarshal([]byte(result), &res); err != nil {
  829. utils.ErrorLog("解析失败:%v", err)
  830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  831. return
  832. }
  833. if res.Infcode == 0 {
  834. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  835. if err == gorm.ErrRecordNotFound {
  836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  837. return
  838. } else if err != nil {
  839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  840. return
  841. } else {
  842. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  843. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  844. infoStr := string(Iinfos)
  845. idetinfoStr := string(Idetinfos)
  846. psn := &models.HisPsn{
  847. PsnNo: res.Output.Baseinfo.PsnNo,
  848. Age: res.Output.Baseinfo.Age,
  849. PatientId: patient.ID,
  850. Certno: res.Output.Baseinfo.Certno,
  851. Brdy: res.Output.Baseinfo.Brdy,
  852. Gend: res.Output.Baseinfo.Gend,
  853. Naty: res.Output.Baseinfo.Naty,
  854. PsnCertType: res.Output.Baseinfo.PsnCertType,
  855. PsnName: res.Output.Baseinfo.PsnName,
  856. Idetinfo: idetinfoStr,
  857. Insuinfo: infoStr,
  858. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  859. }
  860. service.CreateHisPsn(psn)
  861. c.ServeSuccessJSON(map[string]interface{}{
  862. "patient": patient,
  863. "number": res.Output.Baseinfo.Certno,
  864. })
  865. }
  866. } else {
  867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  868. return
  869. }
  870. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  871. var api string
  872. if miConfig.MdtrtareaAdmvs == "320921" {
  873. 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 +
  874. "&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
  875. fmt.Println(api)
  876. } else {
  877. 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 +
  878. "&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)
  879. }
  880. resp, requestErr := http.Get(api)
  881. if requestErr != nil {
  882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  883. return
  884. }
  885. body, ioErr := ioutil.ReadAll(resp.Body)
  886. if ioErr != nil {
  887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  889. return
  890. }
  891. var respJSON map[string]interface{}
  892. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  895. return
  896. }
  897. var status string
  898. status = respJSON["data"].(map[string]interface{})["status"].(string)
  899. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  900. //console.log()
  901. fmt.Println("type===")
  902. fmt.Println(card_type)
  903. var token string
  904. var res ResultTwo //1101结果
  905. var res10265 ResultTwo10265 //1101结果
  906. var card_info string //卡信息
  907. var busi_card_info string
  908. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  909. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  910. if status == "0" { //读卡成功
  911. if card_type == "1" {
  912. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  913. result, _ := json.Marshal(respJSON)
  914. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  915. utils.ErrorLog("解析失败:%v", err)
  916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  917. return
  918. }
  919. res.ErrMsg = res10265.ErrMsg
  920. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  921. res.Infcode = infocode
  922. res.Output = res10265.Output
  923. res.InfRefmsgid = res10265.InfRefmsgid
  924. } else {
  925. //var card_info string //卡信息
  926. //var busi_card_info string
  927. token = respJSON["data"].(map[string]interface{})["token"].(string)
  928. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  929. //fmt.Println(card_info)
  930. //fmt.Println(busi_card_info)
  931. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  932. result, _ := json.Marshal(respJSON)
  933. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  934. utils.ErrorLog("解析失败:%v", err)
  935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  936. return
  937. }
  938. res.ErrMsg = res10265.ErrMsg
  939. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  940. res.Infcode = infocode
  941. res.Output = res10265.Output
  942. res.InfRefmsgid = res10265.InfRefmsgid
  943. }
  944. if res.Infcode == 0 {
  945. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  946. if err == gorm.ErrRecordNotFound {
  947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  948. return
  949. } else if err != nil {
  950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  951. return
  952. } else {
  953. if card_type == "1" {
  954. bas := strings.Split(card_info, "|")
  955. basNumber := bas[2]
  956. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  957. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  958. infoStr := string(Iinfos)
  959. idetinfoStr := string(Idetinfos)
  960. psn := &models.HisPsn{
  961. PsnNo: res.Output.Baseinfo.PsnNo,
  962. Age: res.Output.Baseinfo.Age,
  963. PatientId: patient.ID,
  964. Certno: res.Output.Baseinfo.Certno,
  965. Brdy: res.Output.Baseinfo.Brdy,
  966. Gend: res.Output.Baseinfo.Gend,
  967. Naty: res.Output.Baseinfo.Naty,
  968. PsnCertType: res.Output.Baseinfo.PsnCertType,
  969. PsnName: res.Output.Baseinfo.PsnName,
  970. Idetinfo: idetinfoStr,
  971. Insuinfo: infoStr,
  972. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  973. CardInfo: card_info,
  974. VerifyNumber: busi_card_info,
  975. }
  976. service.CreateHisPsn(psn)
  977. c.ServeSuccessJSON(map[string]interface{}{
  978. "patient": patient,
  979. "number": basNumber,
  980. })
  981. } else {
  982. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  983. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  984. infoStr := string(Iinfos)
  985. idetinfoStr := string(Idetinfos)
  986. psn := &models.HisPsn{
  987. PsnNo: res.Output.Baseinfo.PsnNo,
  988. Age: res.Output.Baseinfo.Age,
  989. PatientId: patient.ID,
  990. Certno: res.Output.Baseinfo.Certno,
  991. Brdy: res.Output.Baseinfo.Brdy,
  992. Gend: res.Output.Baseinfo.Gend,
  993. Naty: res.Output.Baseinfo.Naty,
  994. PsnCertType: res.Output.Baseinfo.PsnCertType,
  995. PsnName: res.Output.Baseinfo.PsnName,
  996. Idetinfo: idetinfoStr,
  997. Insuinfo: infoStr,
  998. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  999. CardInfo: card_info,
  1000. VerifyNumber: token,
  1001. }
  1002. service.CreateHisPsn(psn)
  1003. c.ServeSuccessJSON(map[string]interface{}{
  1004. "patient": patient,
  1005. "number": token,
  1006. })
  1007. }
  1008. }
  1009. } else {
  1010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1011. return
  1012. }
  1013. } else { //读卡失败
  1014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1015. return
  1016. }
  1017. } else {
  1018. if initFlag == 0 {
  1019. c.TestGetBasBaseInit()
  1020. }
  1021. basStr := c.GetBasBaseInfo()
  1022. if len(basStr) == 0 {
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1024. return
  1025. }
  1026. fmt.Println(basStr)
  1027. bas := strings.Split(basStr, "|")
  1028. basNumber := bas[1]
  1029. fmt.Println(basNumber)
  1030. card_sn := bas[3]
  1031. fmt.Println(card_sn)
  1032. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1033. var dat map[string]interface{}
  1034. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1035. fmt.Println(dat)
  1036. } else {
  1037. fmt.Println(err)
  1038. }
  1039. userJSONBytes, _ := json.Marshal(dat)
  1040. var res ResultTwo
  1041. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1042. utils.ErrorLog("解析失败:%v", err)
  1043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1044. return
  1045. }
  1046. if res.Infcode == 0 {
  1047. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1048. if err == gorm.ErrRecordNotFound {
  1049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1050. return
  1051. } else if err != nil {
  1052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1053. return
  1054. } else {
  1055. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1056. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1057. infoStr := string(Iinfos)
  1058. idetinfoStr := string(Idetinfos)
  1059. psn := &models.HisPsn{
  1060. PsnNo: res.Output.Baseinfo.PsnNo,
  1061. Age: res.Output.Baseinfo.Age,
  1062. PatientId: patient.ID,
  1063. Certno: res.Output.Baseinfo.Certno,
  1064. Brdy: res.Output.Baseinfo.Brdy,
  1065. Gend: res.Output.Baseinfo.Gend,
  1066. Naty: res.Output.Baseinfo.Naty,
  1067. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1068. PsnName: res.Output.Baseinfo.PsnName,
  1069. Idetinfo: idetinfoStr,
  1070. Insuinfo: infoStr,
  1071. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1072. CardInfo: basStr,
  1073. VerifyNumber: "",
  1074. }
  1075. service.CreateHisPsn(psn)
  1076. c.ServeSuccessJSON(map[string]interface{}{
  1077. "patient": patient,
  1078. "number": basNumber,
  1079. })
  1080. }
  1081. } else {
  1082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1083. return
  1084. }
  1085. break
  1086. }
  1087. case 2:
  1088. SFZStr := c.GetSFZBaseInfo()
  1089. id_card_str := strings.Split(SFZStr, "^")
  1090. id_card_number := id_card_str[0]
  1091. card_sn := ""
  1092. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1093. var dat map[string]interface{}
  1094. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1095. fmt.Println(dat)
  1096. } else {
  1097. fmt.Println(err)
  1098. }
  1099. userJSONBytes, _ := json.Marshal(dat)
  1100. var res ResultTwo
  1101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1102. utils.ErrorLog("解析失败:%v", err)
  1103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1104. return
  1105. }
  1106. if res.Infcode == 0 {
  1107. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1108. if err == gorm.ErrRecordNotFound {
  1109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1110. return
  1111. } else if err != nil {
  1112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1113. return
  1114. } else {
  1115. c.ServeSuccessJSON(map[string]interface{}{
  1116. "patient": patient,
  1117. "number": id_card_number,
  1118. })
  1119. }
  1120. } else {
  1121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1122. return
  1123. }
  1124. break
  1125. case 3:
  1126. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1127. var api string
  1128. if miConfig.MdtrtareaAdmvs == "320921" {
  1129. 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 +
  1130. "&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
  1131. fmt.Println(api)
  1132. } else {
  1133. 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 +
  1134. "&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)
  1135. }
  1136. resp, requestErr := http.Get(api)
  1137. if requestErr != nil {
  1138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1139. return
  1140. }
  1141. body, ioErr := ioutil.ReadAll(resp.Body)
  1142. if ioErr != nil {
  1143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1145. return
  1146. }
  1147. var respJSON map[string]interface{}
  1148. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1151. return
  1152. }
  1153. var status string
  1154. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1155. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1156. var token string
  1157. var res ResultTwo //1101结果
  1158. var res10265 ResultTwo10265 //1101结果
  1159. var card_info string //卡信息
  1160. var busi_card_info string
  1161. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1162. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1163. if status == "0" { //读卡成功
  1164. if card_type == "1" {
  1165. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1166. result, _ := json.Marshal(respJSON)
  1167. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1168. utils.ErrorLog("解析失败:%v", err)
  1169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1170. return
  1171. }
  1172. res.ErrMsg = res10265.ErrMsg
  1173. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1174. res.Infcode = infocode
  1175. res.Output = res10265.Output
  1176. res.InfRefmsgid = res10265.InfRefmsgid
  1177. } else {
  1178. //var card_info string //卡信息
  1179. //var busi_card_info string
  1180. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1181. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1182. //fmt.Println(card_info)
  1183. //fmt.Println(busi_card_info)
  1184. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1185. result, _ := json.Marshal(respJSON)
  1186. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1187. utils.ErrorLog("解析失败:%v", err)
  1188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1189. return
  1190. }
  1191. res.ErrMsg = res10265.ErrMsg
  1192. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1193. res.Infcode = infocode
  1194. res.Output = res10265.Output
  1195. res.InfRefmsgid = res10265.InfRefmsgid
  1196. }
  1197. if res.Infcode == 0 {
  1198. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1199. if err == gorm.ErrRecordNotFound {
  1200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1201. return
  1202. } else if err != nil {
  1203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1204. return
  1205. } else {
  1206. if card_type == "1" {
  1207. bas := strings.Split(card_info, "|")
  1208. basNumber := bas[2]
  1209. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1210. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1211. infoStr := string(Iinfos)
  1212. idetinfoStr := string(Idetinfos)
  1213. psn := &models.HisPsn{
  1214. PsnNo: res.Output.Baseinfo.PsnNo,
  1215. Age: res.Output.Baseinfo.Age,
  1216. PatientId: patient.ID,
  1217. Certno: res.Output.Baseinfo.Certno,
  1218. Brdy: res.Output.Baseinfo.Brdy,
  1219. Gend: res.Output.Baseinfo.Gend,
  1220. Naty: res.Output.Baseinfo.Naty,
  1221. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1222. PsnName: res.Output.Baseinfo.PsnName,
  1223. Idetinfo: idetinfoStr,
  1224. Insuinfo: infoStr,
  1225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1226. CardInfo: card_info,
  1227. VerifyNumber: busi_card_info,
  1228. }
  1229. service.CreateHisPsn(psn)
  1230. c.ServeSuccessJSON(map[string]interface{}{
  1231. "patient": patient,
  1232. "number": basNumber,
  1233. })
  1234. } else {
  1235. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1236. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1237. infoStr := string(Iinfos)
  1238. idetinfoStr := string(Idetinfos)
  1239. psn := &models.HisPsn{
  1240. PsnNo: res.Output.Baseinfo.PsnNo,
  1241. Age: res.Output.Baseinfo.Age,
  1242. PatientId: patient.ID,
  1243. Certno: res.Output.Baseinfo.Certno,
  1244. Brdy: res.Output.Baseinfo.Brdy,
  1245. Gend: res.Output.Baseinfo.Gend,
  1246. Naty: res.Output.Baseinfo.Naty,
  1247. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1248. PsnName: res.Output.Baseinfo.PsnName,
  1249. Idetinfo: idetinfoStr,
  1250. Insuinfo: infoStr,
  1251. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1252. CardInfo: card_info,
  1253. VerifyNumber: token,
  1254. }
  1255. service.CreateHisPsn(psn)
  1256. c.ServeSuccessJSON(map[string]interface{}{
  1257. "patient": patient,
  1258. "number": token,
  1259. })
  1260. }
  1261. }
  1262. } else {
  1263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1264. return
  1265. }
  1266. } else { //读卡失败
  1267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1268. return
  1269. }
  1270. }
  1271. break
  1272. case 4:
  1273. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1274. var api string
  1275. if miConfig.MdtrtareaAdmvs == "320921" {
  1276. 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 +
  1277. "&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
  1278. fmt.Println(api)
  1279. } else {
  1280. 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 +
  1281. "&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)
  1282. }
  1283. resp, requestErr := http.Get(api)
  1284. if requestErr != nil {
  1285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1286. return
  1287. }
  1288. body, ioErr := ioutil.ReadAll(resp.Body)
  1289. if ioErr != nil {
  1290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1292. return
  1293. }
  1294. var respJSON map[string]interface{}
  1295. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1298. return
  1299. }
  1300. var status string
  1301. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1302. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1303. var token string
  1304. var res ResultTwo //1101结果
  1305. var res10265 ResultTwo10265 //1101结果
  1306. if status == "0" { //读卡成功
  1307. var card_info string //卡信息
  1308. var busi_card_info string
  1309. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1310. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1311. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1312. fmt.Println(card_info)
  1313. fmt.Println(busi_card_info)
  1314. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1315. result, _ := json.Marshal(respJSON)
  1316. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1317. utils.ErrorLog("解析失败:%v", err)
  1318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1319. return
  1320. }
  1321. res.ErrMsg = res10265.ErrMsg
  1322. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1323. res.Infcode = infocode
  1324. res.Output = res10265.Output
  1325. res.InfRefmsgid = res10265.InfRefmsgid
  1326. if res.Infcode == 0 {
  1327. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1328. if err == gorm.ErrRecordNotFound {
  1329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1330. return
  1331. } else if err != nil {
  1332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1333. return
  1334. } else {
  1335. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1336. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1337. infoStr := string(Iinfos)
  1338. idetinfoStr := string(Idetinfos)
  1339. psn := &models.HisPsn{
  1340. PsnNo: res.Output.Baseinfo.PsnNo,
  1341. Age: res.Output.Baseinfo.Age,
  1342. PatientId: patient.ID,
  1343. Certno: res.Output.Baseinfo.Certno,
  1344. Brdy: res.Output.Baseinfo.Brdy,
  1345. Gend: res.Output.Baseinfo.Gend,
  1346. Naty: res.Output.Baseinfo.Naty,
  1347. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1348. PsnName: res.Output.Baseinfo.PsnName,
  1349. Idetinfo: idetinfoStr,
  1350. Insuinfo: infoStr,
  1351. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1352. CardInfo: card_info,
  1353. VerifyNumber: token,
  1354. }
  1355. service.CreateHisPsn(psn)
  1356. c.ServeSuccessJSON(map[string]interface{}{
  1357. "patient": patient,
  1358. "number": token,
  1359. })
  1360. }
  1361. } else {
  1362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1363. return
  1364. }
  1365. } else { //读卡失败
  1366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1367. return
  1368. }
  1369. }
  1370. break
  1371. }
  1372. }
  1373. var initFlag int64 = 0
  1374. func (c *HisApiController) TestGetBasBaseInit() {
  1375. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1376. Iinit := DllDef.MustFindProc("Init")
  1377. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1378. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1379. if ret != 0 {
  1380. fmt.Println("SSCard的报错原因:", err)
  1381. fmt.Println("SSCard的运算结果为:", ret)
  1382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1383. return
  1384. }
  1385. result := int(ret)
  1386. fmt.Println("SSCard的运算结果为1:", result)
  1387. initFlag = 1
  1388. return
  1389. }
  1390. func (c *HisApiController) GetSFZBaseInfo() string {
  1391. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1392. readCard := DllDef.MustFindProc("ReadSFZ")
  1393. if readCard == nil {
  1394. fmt.Println("readcard is nil")
  1395. readCard = DllDef.MustFindProc("ReadSFZ")
  1396. }
  1397. str := make([]byte, 256)
  1398. str1 := make([]byte, 256)
  1399. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1400. fmt.Println(r)
  1401. return string(str)
  1402. }
  1403. func (c *HisApiController) GetBasBaseInfo() string {
  1404. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1405. readCard := DllDef.MustFindProc("ReadCardBas")
  1406. if readCard == nil {
  1407. fmt.Println("readcard is nil")
  1408. readCard = DllDef.MustFindProc("ReadCardBas")
  1409. }
  1410. str := make([]byte, 1024)
  1411. str1 := make([]byte, 1024)
  1412. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1413. fmt.Println(string(str1))
  1414. fmt.Println(string(str))
  1415. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1416. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1417. if ret2 != 0 {
  1418. return ""
  1419. }
  1420. return string(str)
  1421. }
  1422. type CustomFundPay struct {
  1423. FundPayType string `json:"fund_pay_type"`
  1424. FundPayamt float64 `json:"fund_payamt"`
  1425. }
  1426. func (c *HisApiController) GetSettleList() {
  1427. order_id, _ := c.GetInt64("order_id")
  1428. admin_user_id, _ := c.GetInt64("admin_user_id")
  1429. order, _ := service.GetHisOrderByIDTwo(order_id)
  1430. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1431. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1432. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1433. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1434. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1435. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1436. if order.ID == 0 {
  1437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1438. return
  1439. }
  1440. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1441. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1442. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1443. fmt.Println(count)
  1444. var zero string
  1445. number := count + 1
  1446. if number >= 1000 {
  1447. zero = "0000" + strconv.FormatInt(number, 10)
  1448. } else if number >= 10000 {
  1449. zero = "000" + strconv.FormatInt(number, 10)
  1450. } else if number >= 100000 {
  1451. zero = "00" + strconv.FormatInt(number, 10)
  1452. } else if number >= 1000000 {
  1453. zero = "0" + strconv.FormatInt(number, 10)
  1454. } else {
  1455. zero = strconv.FormatInt(number, 10)
  1456. }
  1457. fmt.Println(zero)
  1458. struct4101 := service.Struct4101{
  1459. PsnNo: order.PsnNo,
  1460. MdtrtId: order.MdtrtId,
  1461. SetlId: order.SetlId,
  1462. PsnName: order.PsnName,
  1463. Gend: order.Gend,
  1464. Brdy: his.Brdy,
  1465. Age: his.Age,
  1466. Naty: order.Naty,
  1467. PatnCertType: "01",
  1468. Certno: order.Certno,
  1469. Prfs: "90",
  1470. ConerName: roles[0].UserName,
  1471. PatnRlts: "99",
  1472. ConerAddr: miConfig.OrgName,
  1473. ConerTel: admin.Mobile,
  1474. HiType: order.Insutype,
  1475. Insuplc: miConfig.InsuplcAdmdvs,
  1476. MaindiagFlag: "1",
  1477. BillCode: last_order.FaPiaoCode,
  1478. BillNo: zero,
  1479. BizSn: order.Number,
  1480. PsnSelfPay: order.PsnPartAmt,
  1481. PsnOwnPay: order.PsnPartAmt,
  1482. AcctPay: order.AcctPay,
  1483. PsnCashpay: order.PsnCashPay,
  1484. HiPaymtd: "1",
  1485. Hsorg: miConfig.InsuplcAdmdvs,
  1486. HsorgOpter: miConfig.InsuplcAdmdvs,
  1487. MedinsFillPsn: curRoles.UserName,
  1488. MedinsFillDept: depart.Name,
  1489. IptMedType: "2",
  1490. }
  1491. struct4101.SetlBegnDate = order.SetlTime
  1492. struct4101.SetlEndDate = order.SetlTime
  1493. time_arr := strings.Split(order.SetlTime, " ")
  1494. struct4101.AdmTime = time_arr[0]
  1495. struct4101.AdmEndTime = time_arr[0]
  1496. var rf []CustomFundPay
  1497. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1498. var tempFunPays []service.CustomStruct
  1499. for _, item := range rf {
  1500. var tempFunPay service.CustomStruct
  1501. tempFunPay.FundPayamt = item.FundPayamt
  1502. tempFunPay.FundPayType = item.FundPayType
  1503. tempFunPays = append(tempFunPays, tempFunPay)
  1504. }
  1505. struct4101.CustomStruct = tempFunPays
  1506. var tempDiaginfos []service.DiaginfoStructTwo
  1507. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1508. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1509. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1510. var config []*models.HisXtDiagnoseConfig
  1511. for _, item := range diagnosis_ids {
  1512. id, _ := strconv.ParseInt(item, 10, 64)
  1513. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1514. config = append(config, &diagnosisConfig)
  1515. }
  1516. for index, item := range config {
  1517. if index == 0 {
  1518. var tempDiaginfo service.DiaginfoStructTwo
  1519. tempDiaginfo.DiagCode = item.CountryCode
  1520. tempDiaginfo.DiagName = item.CountryContentName
  1521. tempDiaginfo.DiagType = "1"
  1522. tempDiaginfo.MaindiagFlag = "1"
  1523. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1524. } else {
  1525. var tempDiaginfo service.DiaginfoStructTwo
  1526. tempDiaginfo.DiagCode = item.CountryCode
  1527. tempDiaginfo.DiagName = item.CountryContentName
  1528. tempDiaginfo.DiagType = "2"
  1529. tempDiaginfo.MaindiagFlag = "0"
  1530. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1531. }
  1532. }
  1533. struct4101.Diseinfo = tempDiaginfos
  1534. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1535. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1536. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1537. tempOpspdiseinfo2.OprnOprtCode = ""
  1538. tempOpspdiseinfo2.OprnOprtName = ""
  1539. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1540. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1541. var iteminfo service.IteminfoStruct
  1542. var bedCostTotal float64 = 0 //床位总费
  1543. var bedCostSelfTotal float64 = 0 //床位自费
  1544. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1545. var operationCostTotal float64 = 0 //手术费
  1546. var operationCostSelfTotal float64 = 0 //手术费
  1547. var operationCostPartSelfTotal float64 = 0 //手术费
  1548. var otherCostTotal float64 = 0 //其他费用
  1549. var otherCostSelfTotal float64 = 0 //其他费用
  1550. var otherCostPartSelfTotal float64 = 0 //其他费用
  1551. var materialCostTotal float64 = 0 //材料费
  1552. var materialCostSelfTotal float64 = 0 //材料费
  1553. var materialCostPartSelfTotal float64 = 0 //材料费
  1554. var westernMedicineCostTotal float64 = 0 //西药费
  1555. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1556. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1557. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1558. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1559. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1560. var checkCostTotal float64 = 0 //检查费
  1561. var checkCostSelfTotal float64 = 0 //检查费
  1562. var checkCostPartSelfTotal float64 = 0 //检查费
  1563. var laboratoryCostTotal float64 = 0 //化验费
  1564. var laboratoryCostSelfTotal float64 = 0 //化验费
  1565. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1566. var treatCostTotal float64 = 0 //治疗费用
  1567. var treatCostSelfTotal float64 = 0 //治疗费用
  1568. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1569. decimal.DivisionPrecision = 2
  1570. var bed_fulamt_ownpay_amt float64 = 0
  1571. var operation_fulamt_ownpay_amt float64 = 0
  1572. var other_fulamt_ownpay_amt float64 = 0
  1573. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1574. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1575. var check_fulamt_ownpay_amt float64 = 0
  1576. var material_fulamt_ownpay_amt float64 = 0
  1577. var laboratory_fulamt_ownpay_amt float64 = 0
  1578. var treat_fulamt_ownpay_amt float64 = 0
  1579. var bed_claa_sunmfee float64 = 0
  1580. var bed_clab_amt float64 = 0
  1581. var bed_other_amt float64 = 0
  1582. var operation_claa_sunmfee float64 = 0
  1583. var operation_clab_amt float64 = 0
  1584. var operation_other_amt float64 = 0
  1585. var other_claa_sunmfee float64 = 0
  1586. var other_clab_amt float64 = 0
  1587. var other_other_amt float64 = 0
  1588. var westernMedicine_claa_sunmfee float64 = 0
  1589. var westernMedicine_clab_amt float64 = 0
  1590. var westernMedicine_other_amt float64 = 0
  1591. var chineseTraditional_claa_sunmfee float64 = 0
  1592. var chineseTraditional_clab_amt float64 = 0
  1593. var chineseTraditional_other_amt float64 = 0
  1594. var check_claa_sunmfee float64 = 0
  1595. var check_clab_amt float64 = 0
  1596. var check_other_amt float64 = 0
  1597. var material_claa_sunmfee float64 = 0
  1598. var material_clab_amt float64 = 0
  1599. var material_other_amt float64 = 0
  1600. var laboratory_claa_sunmfee float64 = 0
  1601. var laboratory_clab_amt float64 = 0
  1602. var laboratory_other_amt float64 = 0
  1603. var treat_claa_sunmfee float64 = 0
  1604. var treat_clab_amt float64 = 0
  1605. var treat_other_amt float64 = 0
  1606. for _, item := range order.HisOrderInfo {
  1607. if item.MedChrgitmType == "01" { //床位费
  1608. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1609. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1610. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1611. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1612. if item.ChrgitmLv == "1" {
  1613. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1614. }
  1615. if item.ChrgitmLv == "2" {
  1616. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1617. }
  1618. if item.ChrgitmLv == "3" {
  1619. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1620. }
  1621. }
  1622. if item.MedChrgitmType == "03" { //检查费
  1623. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1624. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1625. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1626. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1627. if item.ChrgitmLv == "1" {
  1628. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1629. }
  1630. if item.ChrgitmLv == "2" {
  1631. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1632. }
  1633. if item.ChrgitmLv == "3" {
  1634. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1635. }
  1636. }
  1637. if item.MedChrgitmType == "04" { //化验费
  1638. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1639. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1640. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1641. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1642. if item.ChrgitmLv == "1" {
  1643. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1644. }
  1645. if item.ChrgitmLv == "2" {
  1646. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1647. }
  1648. if item.ChrgitmLv == "3" {
  1649. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1650. }
  1651. }
  1652. if item.MedChrgitmType == "05" { //治疗费
  1653. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1654. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1655. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1656. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1657. if item.ChrgitmLv == "1" {
  1658. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1659. }
  1660. if item.ChrgitmLv == "2" {
  1661. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1662. }
  1663. if item.ChrgitmLv == "3" {
  1664. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1665. }
  1666. }
  1667. if item.MedChrgitmType == "06" { //手术费
  1668. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1669. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1670. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1671. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1672. if item.ChrgitmLv == "1" {
  1673. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1674. }
  1675. if item.ChrgitmLv == "2" {
  1676. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1677. }
  1678. if item.ChrgitmLv == "3" {
  1679. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1680. }
  1681. }
  1682. if item.MedChrgitmType == "08" { //材料费
  1683. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1684. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1685. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1686. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1687. if item.ChrgitmLv == "1" {
  1688. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1689. }
  1690. if item.ChrgitmLv == "2" {
  1691. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1692. }
  1693. if item.ChrgitmLv == "3" {
  1694. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1695. }
  1696. }
  1697. if item.MedChrgitmType == "09" { //西药费
  1698. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1699. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1700. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1701. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1702. if item.ChrgitmLv == "1" {
  1703. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1704. }
  1705. if item.ChrgitmLv == "2" {
  1706. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1707. }
  1708. if item.ChrgitmLv == "3" {
  1709. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1710. }
  1711. }
  1712. if item.MedChrgitmType == "11" { //中成费
  1713. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1714. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1715. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1716. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1717. if item.ChrgitmLv == "1" {
  1718. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1719. }
  1720. if item.ChrgitmLv == "2" {
  1721. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1722. }
  1723. if item.ChrgitmLv == "3" {
  1724. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1725. }
  1726. }
  1727. if item.MedChrgitmType == "14" { //其他费
  1728. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1729. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1730. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1731. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1732. if item.ChrgitmLv == "1" {
  1733. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1734. }
  1735. if item.ChrgitmLv == "2" {
  1736. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1737. }
  1738. if item.ChrgitmLv == "3" {
  1739. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1740. }
  1741. }
  1742. }
  1743. var iteminfoStructs []service.IteminfoStruct
  1744. if bedCostTotal != 0 {
  1745. iteminfo.MedChrgitm = "01"
  1746. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1747. iteminfo.Amt = bedCostTotal
  1748. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1749. iteminfo.ClabAmt = bed_clab_amt
  1750. iteminfo.OthAmt = bed_other_amt
  1751. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1752. }
  1753. if checkCostTotal != 0 {
  1754. iteminfo.MedChrgitm = "03"
  1755. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1756. iteminfo.Amt = checkCostTotal
  1757. iteminfo.ClaaSumfee = check_claa_sunmfee
  1758. iteminfo.ClabAmt = check_clab_amt
  1759. iteminfo.OthAmt = check_other_amt
  1760. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1761. }
  1762. if laboratoryCostTotal != 0 {
  1763. iteminfo.MedChrgitm = "04"
  1764. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1765. iteminfo.Amt = laboratoryCostTotal
  1766. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1767. iteminfo.ClabAmt = laboratory_clab_amt
  1768. iteminfo.OthAmt = laboratory_other_amt
  1769. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1770. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1771. }
  1772. if treatCostTotal != 0 {
  1773. iteminfo.MedChrgitm = "05"
  1774. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1775. iteminfo.Amt = treatCostTotal
  1776. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1777. iteminfo.ClabAmt = treat_clab_amt
  1778. iteminfo.OthAmt = treat_other_amt
  1779. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1780. //(struct4101.IteminfoStruct, iteminfo)
  1781. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1782. }
  1783. if operationCostTotal != 0 {
  1784. iteminfo.MedChrgitm = "06"
  1785. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1786. iteminfo.Amt = operationCostTotal
  1787. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1788. iteminfo.ClabAmt = operation_clab_amt
  1789. iteminfo.OthAmt = operation_other_amt
  1790. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1791. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1792. }
  1793. if materialCostTotal != 0 {
  1794. iteminfo.MedChrgitm = "08"
  1795. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1796. iteminfo.Amt = materialCostTotal
  1797. iteminfo.ClaaSumfee = material_claa_sunmfee
  1798. iteminfo.ClabAmt = material_clab_amt
  1799. iteminfo.OthAmt = material_other_amt
  1800. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1801. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1802. }
  1803. if westernMedicineCostTotal != 0 {
  1804. iteminfo.MedChrgitm = "09"
  1805. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1806. iteminfo.Amt = westernMedicineCostTotal
  1807. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1808. iteminfo.ClabAmt = westernMedicine_clab_amt
  1809. iteminfo.OthAmt = westernMedicine_other_amt
  1810. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1811. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1812. }
  1813. if chineseTraditionalMedicineCostTotal != 0 {
  1814. iteminfo.MedChrgitm = "11"
  1815. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1816. iteminfo.Amt = westernMedicineCostTotal
  1817. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1818. iteminfo.ClabAmt = westernMedicine_clab_amt
  1819. iteminfo.OthAmt = westernMedicine_other_amt
  1820. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1821. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1822. }
  1823. if otherCostTotal != 0 {
  1824. iteminfo.MedChrgitm = "14"
  1825. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1826. iteminfo.Amt = otherCostTotal
  1827. iteminfo.ClaaSumfee = other_claa_sunmfee
  1828. iteminfo.ClabAmt = other_clab_amt
  1829. iteminfo.OthAmt = other_other_amt
  1830. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1831. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1832. }
  1833. struct4101.IteminfoStruct = iteminfoStructs
  1834. struct4101.Ntly = "中国"
  1835. struct4101.AdmCaty = "A03.06"
  1836. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1837. fmt.Println(result)
  1838. var dat map[string]interface{}
  1839. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1840. fmt.Println(dat)
  1841. } else {
  1842. fmt.Println(err)
  1843. }
  1844. userJSONBytes, _ := json.Marshal(dat)
  1845. var res ResultSeventeen
  1846. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1847. utils.ErrorLog("解析失败:%v", err)
  1848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1849. return
  1850. }
  1851. if res.Infcode != 0 {
  1852. c.ServeSuccessJSON(map[string]interface{}{
  1853. "failed_code": -10,
  1854. "msg": res.ErrMsg,
  1855. })
  1856. return
  1857. } else {
  1858. order.FaPiaoNumber = zero
  1859. order.FaPiaoCode = last_order.FaPiaoCode
  1860. service.UpdateOrder(order)
  1861. hisFundSettleListResult := &models.HisFundSettleListResult{
  1862. Number: res.Output.SetlListId,
  1863. Status: 1,
  1864. Ctime: time.Now().Unix(),
  1865. Mtime: time.Now().Unix(),
  1866. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1867. IsUpload: 1,
  1868. OrderId: order_id,
  1869. }
  1870. service.CreateUploadRecord(hisFundSettleListResult)
  1871. c.ServeSuccessJSON(map[string]interface{}{
  1872. "msg": "上传成功",
  1873. "result": hisFundSettleListResult,
  1874. })
  1875. return
  1876. }
  1877. }
  1878. func (c *HisApiController) GetSettleListHospital() {
  1879. order_id, _ := c.GetInt64("order_id")
  1880. admin_user_id, _ := c.GetInt64("admin_user_id")
  1881. order, _ := service.GetHisOrderByIDTwo(order_id)
  1882. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1883. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1884. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1885. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1886. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1887. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1888. if order.ID == 0 {
  1889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1890. return
  1891. }
  1892. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1893. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1894. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1895. fmt.Println(count)
  1896. var zero string
  1897. number := count + 1
  1898. if number >= 1000 {
  1899. zero = "0000" + strconv.FormatInt(number, 10)
  1900. } else if number >= 10000 {
  1901. zero = "000" + strconv.FormatInt(number, 10)
  1902. } else if number >= 100000 {
  1903. zero = "00" + strconv.FormatInt(number, 10)
  1904. } else if number >= 1000000 {
  1905. zero = "0" + strconv.FormatInt(number, 10)
  1906. } else {
  1907. zero = strconv.FormatInt(number, 10)
  1908. }
  1909. fmt.Println(zero)
  1910. struct4101 := service.Struct4101{
  1911. PsnNo: order.PsnNo,
  1912. MdtrtId: order.MdtrtId,
  1913. SetlId: order.SetlId,
  1914. PsnName: order.PsnName,
  1915. Gend: order.Gend,
  1916. Brdy: his.Brdy,
  1917. Age: int64(order.Age),
  1918. Naty: order.Naty,
  1919. PatnCertType: "01",
  1920. Certno: order.Certno,
  1921. Prfs: "90",
  1922. ConerName: roles[0].UserName,
  1923. PatnRlts: "99",
  1924. ConerAddr: miConfig.OrgName,
  1925. ConerTel: admin.Mobile,
  1926. HiType: order.Insutype,
  1927. Insuplc: miConfig.InsuplcAdmdvs,
  1928. MaindiagFlag: "1",
  1929. BillCode: last_order.FaPiaoCode,
  1930. BillNo: zero,
  1931. BizSn: order.Number,
  1932. PsnSelfPay: order.PsnPartAmt,
  1933. PsnOwnPay: order.PsnPartAmt,
  1934. AcctPay: order.AcctPay,
  1935. PsnCashpay: order.PsnCashPay,
  1936. HiPaymtd: "1",
  1937. Hsorg: miConfig.InsuplcAdmdvs,
  1938. HsorgOpter: miConfig.InsuplcAdmdvs,
  1939. MedinsFillPsn: curRoles.UserName,
  1940. MedinsFillDept: depart.Name,
  1941. IptMedType: "2",
  1942. AdmTime: his.InHosptialTime,
  1943. AdmEndTime: his.OutHosptialTime,
  1944. }
  1945. struct4101.SetlBegnDate = order.SetlTime
  1946. struct4101.SetlEndDate = order.SetlTime
  1947. var rf []CustomFundPay
  1948. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1949. var tempFunPays []service.CustomStruct
  1950. for _, item := range rf {
  1951. var tempFunPay service.CustomStruct
  1952. tempFunPay.FundPayamt = item.FundPayamt
  1953. tempFunPay.FundPayType = item.FundPayType
  1954. tempFunPays = append(tempFunPays, tempFunPay)
  1955. }
  1956. struct4101.CustomStruct = tempFunPays
  1957. var tempDiaginfos []service.DiaginfoStructTwo
  1958. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1959. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1960. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1961. var config []*models.HisXtDiagnoseConfig
  1962. for _, item := range diagnosis_ids {
  1963. id, _ := strconv.ParseInt(item, 10, 64)
  1964. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1965. config = append(config, &diagnosisConfig)
  1966. }
  1967. for index, item := range config {
  1968. if index == 0 {
  1969. var tempDiaginfo service.DiaginfoStructTwo
  1970. tempDiaginfo.DiagCode = item.CountryCode
  1971. tempDiaginfo.DiagName = item.CountryContentName
  1972. tempDiaginfo.DiagType = "1"
  1973. tempDiaginfo.MaindiagFlag = "1"
  1974. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1975. } else {
  1976. var tempDiaginfo service.DiaginfoStructTwo
  1977. tempDiaginfo.DiagCode = item.CountryCode
  1978. tempDiaginfo.DiagName = item.CountryContentName
  1979. tempDiaginfo.DiagType = "2"
  1980. tempDiaginfo.MaindiagFlag = "0"
  1981. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1982. }
  1983. }
  1984. struct4101.Diseinfo = tempDiaginfos
  1985. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1986. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1987. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1988. tempOpspdiseinfo2.OprnOprtCode = ""
  1989. tempOpspdiseinfo2.OprnOprtName = ""
  1990. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1991. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1992. var iteminfo service.IteminfoStruct
  1993. var bedCostTotal float64 = 0 //床位总费
  1994. var bedCostSelfTotal float64 = 0 //床位自费
  1995. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1996. var operationCostTotal float64 = 0 //手术费
  1997. var operationCostSelfTotal float64 = 0 //手术费
  1998. var operationCostPartSelfTotal float64 = 0 //手术费
  1999. var otherCostTotal float64 = 0 //其他费用
  2000. var otherCostSelfTotal float64 = 0 //其他费用
  2001. var otherCostPartSelfTotal float64 = 0 //其他费用
  2002. var materialCostTotal float64 = 0 //材料费
  2003. var materialCostSelfTotal float64 = 0 //材料费
  2004. var materialCostPartSelfTotal float64 = 0 //材料费
  2005. var westernMedicineCostTotal float64 = 0 //西药费
  2006. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2007. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2008. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2009. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2010. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2011. var checkCostTotal float64 = 0 //检查费
  2012. var checkCostSelfTotal float64 = 0 //检查费
  2013. var checkCostPartSelfTotal float64 = 0 //检查费
  2014. var laboratoryCostTotal float64 = 0 //化验费
  2015. var laboratoryCostSelfTotal float64 = 0 //化验费
  2016. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2017. var treatCostTotal float64 = 0 //治疗费用
  2018. var treatCostSelfTotal float64 = 0 //治疗费用
  2019. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2020. decimal.DivisionPrecision = 2
  2021. var bed_fulamt_ownpay_amt float64 = 0
  2022. var operation_fulamt_ownpay_amt float64 = 0
  2023. var other_fulamt_ownpay_amt float64 = 0
  2024. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2025. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2026. var check_fulamt_ownpay_amt float64 = 0
  2027. var material_fulamt_ownpay_amt float64 = 0
  2028. var laboratory_fulamt_ownpay_amt float64 = 0
  2029. var treat_fulamt_ownpay_amt float64 = 0
  2030. var bed_claa_sunmfee float64 = 0
  2031. var bed_clab_amt float64 = 0
  2032. var bed_other_amt float64 = 0
  2033. var operation_claa_sunmfee float64 = 0
  2034. var operation_clab_amt float64 = 0
  2035. var operation_other_amt float64 = 0
  2036. var other_claa_sunmfee float64 = 0
  2037. var other_clab_amt float64 = 0
  2038. var other_other_amt float64 = 0
  2039. var westernMedicine_claa_sunmfee float64 = 0
  2040. var westernMedicine_clab_amt float64 = 0
  2041. var westernMedicine_other_amt float64 = 0
  2042. var chineseTraditional_claa_sunmfee float64 = 0
  2043. var chineseTraditional_clab_amt float64 = 0
  2044. var chineseTraditional_other_amt float64 = 0
  2045. var check_claa_sunmfee float64 = 0
  2046. var check_clab_amt float64 = 0
  2047. var check_other_amt float64 = 0
  2048. var material_claa_sunmfee float64 = 0
  2049. var material_clab_amt float64 = 0
  2050. var material_other_amt float64 = 0
  2051. var laboratory_claa_sunmfee float64 = 0
  2052. var laboratory_clab_amt float64 = 0
  2053. var laboratory_other_amt float64 = 0
  2054. var treat_claa_sunmfee float64 = 0
  2055. var treat_clab_amt float64 = 0
  2056. var treat_other_amt float64 = 0
  2057. for _, item := range order.HisOrderInfo {
  2058. if item.MedChrgitmType == "01" { //床位费
  2059. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2060. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2061. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2062. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2063. if item.ChrgitmLv == "1" {
  2064. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2065. }
  2066. if item.ChrgitmLv == "2" {
  2067. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2068. }
  2069. if item.ChrgitmLv == "3" {
  2070. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2071. }
  2072. }
  2073. if item.MedChrgitmType == "03" { //检查费
  2074. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2075. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2076. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2077. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2078. if item.ChrgitmLv == "1" {
  2079. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2080. }
  2081. if item.ChrgitmLv == "2" {
  2082. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2083. }
  2084. if item.ChrgitmLv == "3" {
  2085. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2086. }
  2087. }
  2088. if item.MedChrgitmType == "04" { //化验费
  2089. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2090. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2091. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2092. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2093. if item.ChrgitmLv == "1" {
  2094. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2095. }
  2096. if item.ChrgitmLv == "2" {
  2097. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2098. }
  2099. if item.ChrgitmLv == "3" {
  2100. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2101. }
  2102. }
  2103. if item.MedChrgitmType == "05" { //治疗费
  2104. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2105. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2106. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2107. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2108. if item.ChrgitmLv == "1" {
  2109. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2110. }
  2111. if item.ChrgitmLv == "2" {
  2112. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2113. }
  2114. if item.ChrgitmLv == "3" {
  2115. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2116. }
  2117. }
  2118. if item.MedChrgitmType == "06" { //手术费
  2119. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2120. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2121. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2122. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2123. if item.ChrgitmLv == "1" {
  2124. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2125. }
  2126. if item.ChrgitmLv == "2" {
  2127. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2128. }
  2129. if item.ChrgitmLv == "3" {
  2130. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2131. }
  2132. }
  2133. if item.MedChrgitmType == "08" { //材料费
  2134. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2135. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2136. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2137. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2138. if item.ChrgitmLv == "1" {
  2139. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2140. }
  2141. if item.ChrgitmLv == "2" {
  2142. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2143. }
  2144. if item.ChrgitmLv == "3" {
  2145. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2146. }
  2147. }
  2148. if item.MedChrgitmType == "09" { //西药费
  2149. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2150. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2151. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2152. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2153. if item.ChrgitmLv == "1" {
  2154. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2155. }
  2156. if item.ChrgitmLv == "2" {
  2157. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2158. }
  2159. if item.ChrgitmLv == "3" {
  2160. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2161. }
  2162. }
  2163. if item.MedChrgitmType == "11" { //中成费
  2164. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2165. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2166. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2167. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2168. if item.ChrgitmLv == "1" {
  2169. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2170. }
  2171. if item.ChrgitmLv == "2" {
  2172. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2173. }
  2174. if item.ChrgitmLv == "3" {
  2175. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2176. }
  2177. }
  2178. if item.MedChrgitmType == "14" { //其他费
  2179. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2180. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2181. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2182. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2183. if item.ChrgitmLv == "1" {
  2184. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2185. }
  2186. if item.ChrgitmLv == "2" {
  2187. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2188. }
  2189. if item.ChrgitmLv == "3" {
  2190. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2191. }
  2192. }
  2193. }
  2194. var iteminfoStructs []service.IteminfoStruct
  2195. if bedCostTotal != 0 {
  2196. iteminfo.MedChrgitm = "01"
  2197. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2198. iteminfo.Amt = bedCostTotal
  2199. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2200. iteminfo.ClabAmt = bed_clab_amt
  2201. iteminfo.OthAmt = bed_other_amt
  2202. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2203. }
  2204. if checkCostTotal != 0 {
  2205. iteminfo.MedChrgitm = "03"
  2206. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2207. iteminfo.Amt = checkCostTotal
  2208. iteminfo.ClaaSumfee = check_claa_sunmfee
  2209. iteminfo.ClabAmt = check_clab_amt
  2210. iteminfo.OthAmt = check_other_amt
  2211. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2212. }
  2213. if laboratoryCostTotal != 0 {
  2214. iteminfo.MedChrgitm = "04"
  2215. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2216. iteminfo.Amt = laboratoryCostTotal
  2217. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2218. iteminfo.ClabAmt = laboratory_clab_amt
  2219. iteminfo.OthAmt = laboratory_other_amt
  2220. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2221. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2222. }
  2223. if treatCostTotal != 0 {
  2224. iteminfo.MedChrgitm = "05"
  2225. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2226. iteminfo.Amt = treatCostTotal
  2227. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2228. iteminfo.ClabAmt = treat_clab_amt
  2229. iteminfo.OthAmt = treat_other_amt
  2230. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2231. //(struct4101.IteminfoStruct, iteminfo)
  2232. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2233. }
  2234. if operationCostTotal != 0 {
  2235. iteminfo.MedChrgitm = "06"
  2236. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2237. iteminfo.Amt = operationCostTotal
  2238. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2239. iteminfo.ClabAmt = operation_clab_amt
  2240. iteminfo.OthAmt = operation_other_amt
  2241. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2242. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2243. }
  2244. if materialCostTotal != 0 {
  2245. iteminfo.MedChrgitm = "08"
  2246. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2247. iteminfo.Amt = materialCostTotal
  2248. iteminfo.ClaaSumfee = material_claa_sunmfee
  2249. iteminfo.ClabAmt = material_clab_amt
  2250. iteminfo.OthAmt = material_other_amt
  2251. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2252. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2253. }
  2254. if westernMedicineCostTotal != 0 {
  2255. iteminfo.MedChrgitm = "09"
  2256. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2257. iteminfo.Amt = westernMedicineCostTotal
  2258. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2259. iteminfo.ClabAmt = westernMedicine_clab_amt
  2260. iteminfo.OthAmt = westernMedicine_other_amt
  2261. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2262. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2263. }
  2264. if chineseTraditionalMedicineCostTotal != 0 {
  2265. iteminfo.MedChrgitm = "11"
  2266. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2267. iteminfo.Amt = westernMedicineCostTotal
  2268. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2269. iteminfo.ClabAmt = westernMedicine_clab_amt
  2270. iteminfo.OthAmt = westernMedicine_other_amt
  2271. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2272. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2273. }
  2274. if otherCostTotal != 0 {
  2275. iteminfo.MedChrgitm = "14"
  2276. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2277. iteminfo.Amt = otherCostTotal
  2278. iteminfo.ClaaSumfee = other_claa_sunmfee
  2279. iteminfo.ClabAmt = other_clab_amt
  2280. iteminfo.OthAmt = other_other_amt
  2281. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2282. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2283. }
  2284. struct4101.IteminfoStruct = iteminfoStructs
  2285. struct4101.Ntly = "中国"
  2286. struct4101.AdmCaty = "A03.06"
  2287. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2288. fmt.Println(result)
  2289. var dat map[string]interface{}
  2290. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2291. fmt.Println(dat)
  2292. } else {
  2293. fmt.Println(err)
  2294. }
  2295. userJSONBytes, _ := json.Marshal(dat)
  2296. var res ResultSeventeen
  2297. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2298. utils.ErrorLog("解析失败:%v", err)
  2299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2300. return
  2301. }
  2302. if res.Infcode != 0 {
  2303. c.ServeSuccessJSON(map[string]interface{}{
  2304. "failed_code": -10,
  2305. "msg": res.ErrMsg,
  2306. })
  2307. return
  2308. } else {
  2309. order.FaPiaoNumber = zero
  2310. order.FaPiaoCode = last_order.FaPiaoCode
  2311. service.UpdateOrder(order)
  2312. hisFundSettleListResult := &models.HisFundSettleListResult{
  2313. Number: res.Output.SetlListId,
  2314. Status: 1,
  2315. Ctime: time.Now().Unix(),
  2316. Mtime: time.Now().Unix(),
  2317. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2318. IsUpload: 1,
  2319. OrderId: order_id,
  2320. }
  2321. service.CreateUploadRecord(hisFundSettleListResult)
  2322. c.ServeSuccessJSON(map[string]interface{}{
  2323. "msg": "上传成功",
  2324. "result": hisFundSettleListResult,
  2325. })
  2326. return
  2327. }
  2328. }
  2329. func (c *HisApiController) GetBatchSettleList() {
  2330. orders, _ := service.GetAllHisOrder(10106)
  2331. for _, item := range orders {
  2332. order_id := item.ID
  2333. order, _ := service.GetHisOrderByIDTwo(order_id)
  2334. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2335. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2336. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2337. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2338. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2339. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2340. if order.ID == 0 {
  2341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2342. return
  2343. }
  2344. if his.BalanceAccountsType == 2 {
  2345. continue
  2346. }
  2347. struct4101 := service.Struct4101{
  2348. PsnNo: order.PsnNo,
  2349. MdtrtId: order.MdtrtId,
  2350. SetlId: order.SetlId,
  2351. PsnName: order.PsnName,
  2352. Gend: order.Gend,
  2353. Brdy: his.Brdy,
  2354. Age: his.Age,
  2355. Naty: order.Naty,
  2356. PatnCertType: "01",
  2357. Certno: order.Certno,
  2358. Prfs: "90",
  2359. ConerName: roles[0].UserName,
  2360. PatnRlts: "99",
  2361. ConerAddr: miConfig.OrgName,
  2362. ConerTel: admin.Mobile,
  2363. HiType: order.Insutype,
  2364. Insuplc: his.InsuplcAdmdvs,
  2365. MaindiagFlag: "1",
  2366. BillCode: order.FaPiaoCode,
  2367. BillNo: order.FaPiaoNumber,
  2368. BizSn: order.Number,
  2369. PsnSelfPay: order.PsnPartAmt,
  2370. PsnOwnPay: order.PsnPartAmt,
  2371. AcctPay: order.AcctPay,
  2372. PsnCashpay: order.PsnCashPay,
  2373. HiPaymtd: "1",
  2374. Hsorg: his.InsuplcAdmdvs,
  2375. HsorgOpter: his.InsuplcAdmdvs,
  2376. MedinsFillPsn: curRoles.UserName,
  2377. MedinsFillDept: depart.Name,
  2378. IptMedType: "2",
  2379. }
  2380. struct4101.SetlBegnDate = order.SetlTime
  2381. struct4101.SetlEndDate = order.SetlTime
  2382. //if order.SettleType == 1 {
  2383. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2384. // dateStr := t.Format("2006-01-02")
  2385. // struct4101.SetlBegnDate = dateStr
  2386. // struct4101.SetlEndDate = dateStr
  2387. //} else {
  2388. // t := time.Unix(int64(order.SettleStartTime), 0)
  2389. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2390. // dateStartStr := t.Format("2006-01-02")
  2391. // dateEndStr := t2.Format("2006-01-02")
  2392. // struct4101.SetlBegnDate = dateStartStr
  2393. // struct4101.SetlEndDate = dateEndStr
  2394. //}
  2395. var rf []CustomFundPay
  2396. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2397. var tempFunPays []service.CustomStruct
  2398. var tempFunPay610100 service.CustomStruct
  2399. for _, item := range rf {
  2400. if item.FundPayType == "610100" {
  2401. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2402. tempFunPay610100.FundPayType = item.FundPayType
  2403. } else {
  2404. var tempFunPay service.CustomStruct
  2405. tempFunPay.FundPayamt = item.FundPayamt
  2406. tempFunPay.FundPayType = item.FundPayType
  2407. tempFunPays = append(tempFunPays, tempFunPay)
  2408. }
  2409. }
  2410. tempFunPays = append(tempFunPays, tempFunPay610100)
  2411. struct4101.CustomStruct = tempFunPays
  2412. var tempDiaginfos []service.DiaginfoStructTwo
  2413. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2414. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2415. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2416. var config []*models.HisXtDiagnoseConfig
  2417. for _, item := range diagnosis_ids {
  2418. id, _ := strconv.ParseInt(item, 10, 64)
  2419. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2420. config = append(config, &diagnosisConfig)
  2421. }
  2422. for index, item := range config {
  2423. if index == 0 {
  2424. var tempDiaginfo service.DiaginfoStructTwo
  2425. tempDiaginfo.DiagCode = item.CountryCode
  2426. tempDiaginfo.DiagName = item.CountryContentName
  2427. tempDiaginfo.DiagType = "1"
  2428. tempDiaginfo.MaindiagFlag = "1"
  2429. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2430. } else {
  2431. var tempDiaginfo service.DiaginfoStructTwo
  2432. tempDiaginfo.DiagCode = item.CountryCode
  2433. tempDiaginfo.DiagName = item.CountryContentName
  2434. tempDiaginfo.DiagType = "2"
  2435. tempDiaginfo.MaindiagFlag = "0"
  2436. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2437. }
  2438. }
  2439. struct4101.Diseinfo = tempDiaginfos
  2440. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2441. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2442. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2443. tempOpspdiseinfo2.OprnOprtCode = ""
  2444. tempOpspdiseinfo2.OprnOprtName = ""
  2445. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2446. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2447. var iteminfo service.IteminfoStruct
  2448. var bedCostTotal float64 = 0 //床位总费
  2449. var bedCostSelfTotal float64 = 0 //床位自费
  2450. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2451. var examineCostTotal float64 = 0 //诊查总费
  2452. var examineCostSelfTotal float64 = 0 //诊查自费
  2453. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2454. var nursingCostTotal float64 = 0 //护理总费
  2455. var nursingCostSelfTotal float64 = 0 //护理自费
  2456. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2457. var chineseMedicineCostTotal float64 = 0 //中成药
  2458. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2459. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2460. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2461. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2462. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2463. var registerCostTotal float64 = 0 //一般诊疗费
  2464. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2465. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2466. var operationCostTotal float64 = 0 //手术费
  2467. var operationCostSelfTotal float64 = 0 //手术费
  2468. var operationCostPartSelfTotal float64 = 0 //手术费
  2469. var otherCostTotal float64 = 0 //其他费用
  2470. var otherCostSelfTotal float64 = 0 //其他费用
  2471. var otherCostPartSelfTotal float64 = 0 //其他费用
  2472. var materialCostTotal float64 = 0 //材料费
  2473. var materialCostSelfTotal float64 = 0 //材料费
  2474. var materialCostPartSelfTotal float64 = 0 //材料费
  2475. var westernMedicineCostTotal float64 = 0 //西药费
  2476. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2477. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2478. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2479. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2480. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2481. var checkCostTotal float64 = 0 //检查费
  2482. var checkCostSelfTotal float64 = 0 //检查费
  2483. var checkCostPartSelfTotal float64 = 0 //检查费
  2484. var laboratoryCostTotal float64 = 0 //化验费
  2485. var laboratoryCostSelfTotal float64 = 0 //化验费
  2486. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2487. var treatCostTotal float64 = 0 //治疗费用
  2488. var treatCostSelfTotal float64 = 0 //治疗费用
  2489. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2490. decimal.DivisionPrecision = 2
  2491. var bed_fulamt_ownpay_amt float64 = 0
  2492. var examine_fulamt_ownpay_amt float64 = 0
  2493. var nursing_fulamt_ownpay_amt float64 = 0
  2494. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2495. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2496. var register_fulamt_ownpay_amt float64 = 0
  2497. var operation_fulamt_ownpay_amt float64 = 0
  2498. var other_fulamt_ownpay_amt float64 = 0
  2499. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2500. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2501. var check_fulamt_ownpay_amt float64 = 0
  2502. var material_fulamt_ownpay_amt float64 = 0
  2503. var laboratory_fulamt_ownpay_amt float64 = 0
  2504. var treat_fulamt_ownpay_amt float64 = 0
  2505. var bed_claa_sunmfee float64 = 0
  2506. var bed_clab_amt float64 = 0
  2507. var bed_other_amt float64 = 0
  2508. var examine_claa_sunmfee float64 = 0
  2509. var examine_clab_amt float64 = 0
  2510. var examine_other_amt float64 = 0
  2511. var nursing_claa_sunmfee float64 = 0
  2512. var nursing_clab_amt float64 = 0
  2513. var nursing_other_amt float64 = 0
  2514. var chinese_medicine_claa_sunmfee float64 = 0
  2515. var chinese_medicine_clab_amt float64 = 0
  2516. var chinese_medicine_other_amt float64 = 0
  2517. var commonly_treatment_claa_sunmfee float64 = 0
  2518. var commonly_treatment_clab_amt float64 = 0
  2519. var commonly_treatment_other_amt float64 = 0
  2520. var operation_claa_sunmfee float64 = 0
  2521. var operation_clab_amt float64 = 0
  2522. var operation_other_amt float64 = 0
  2523. var other_claa_sunmfee float64 = 0
  2524. var other_clab_amt float64 = 0
  2525. var other_other_amt float64 = 0
  2526. var westernMedicine_claa_sunmfee float64 = 0
  2527. var westernMedicine_clab_amt float64 = 0
  2528. var westernMedicine_other_amt float64 = 0
  2529. var chineseTraditional_claa_sunmfee float64 = 0
  2530. var chineseTraditional_clab_amt float64 = 0
  2531. var chineseTraditional_other_amt float64 = 0
  2532. var check_claa_sunmfee float64 = 0
  2533. var check_clab_amt float64 = 0
  2534. var check_other_amt float64 = 0
  2535. var material_claa_sunmfee float64 = 0
  2536. var material_clab_amt float64 = 0
  2537. var material_other_amt float64 = 0
  2538. var laboratory_claa_sunmfee float64 = 0
  2539. var laboratory_clab_amt float64 = 0
  2540. var laboratory_other_amt float64 = 0
  2541. var treat_claa_sunmfee float64 = 0
  2542. var treat_clab_amt float64 = 0
  2543. var treat_other_amt float64 = 0
  2544. var register_claa_sunmfee float64 = 0
  2545. var register_clab_amt float64 = 0
  2546. var register_other_amt float64 = 0
  2547. for _, item := range order.HisOrderInfo {
  2548. if item.MedChrgitmType == "01" { //床位费
  2549. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2550. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2551. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2552. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2553. if item.ChrgitmLv == "1" {
  2554. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2555. }
  2556. if item.ChrgitmLv == "2" {
  2557. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2558. }
  2559. if item.ChrgitmLv == "3" {
  2560. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2561. }
  2562. }
  2563. if item.MedChrgitmType == "02" { //诊查
  2564. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2565. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2566. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2567. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2568. if item.ChrgitmLv == "1" {
  2569. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2570. }
  2571. if item.ChrgitmLv == "2" {
  2572. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2573. }
  2574. if item.ChrgitmLv == "3" {
  2575. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2576. }
  2577. }
  2578. if item.MedChrgitmType == "03" { //检查费
  2579. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2580. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2581. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2582. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2583. if item.ChrgitmLv == "1" {
  2584. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2585. }
  2586. if item.ChrgitmLv == "2" {
  2587. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2588. }
  2589. if item.ChrgitmLv == "3" {
  2590. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2591. }
  2592. }
  2593. if item.MedChrgitmType == "04" { //化验费
  2594. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2595. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2596. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2597. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2598. if item.ChrgitmLv == "1" {
  2599. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2600. }
  2601. if item.ChrgitmLv == "2" {
  2602. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2603. }
  2604. if item.ChrgitmLv == "3" {
  2605. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2606. }
  2607. }
  2608. if item.MedChrgitmType == "05" { //治疗费
  2609. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2610. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2611. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2612. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2613. if item.ChrgitmLv == "1" {
  2614. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2615. }
  2616. if item.ChrgitmLv == "2" {
  2617. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2618. }
  2619. if item.ChrgitmLv == "3" {
  2620. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2621. }
  2622. }
  2623. if item.MedChrgitmType == "06" { //手术费
  2624. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2625. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2626. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2627. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2628. if item.ChrgitmLv == "1" {
  2629. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2630. }
  2631. if item.ChrgitmLv == "2" {
  2632. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2633. }
  2634. if item.ChrgitmLv == "3" {
  2635. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2636. }
  2637. }
  2638. if item.MedChrgitmType == "07" { //手术费
  2639. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2640. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2641. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2642. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2643. if item.ChrgitmLv == "1" {
  2644. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2645. }
  2646. if item.ChrgitmLv == "2" {
  2647. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2648. }
  2649. if item.ChrgitmLv == "3" {
  2650. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2651. }
  2652. }
  2653. if item.MedChrgitmType == "08" { //材料费
  2654. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2655. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2656. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2657. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2658. if item.ChrgitmLv == "1" {
  2659. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2660. }
  2661. if item.ChrgitmLv == "2" {
  2662. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2663. }
  2664. if item.ChrgitmLv == "3" {
  2665. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2666. }
  2667. }
  2668. if item.MedChrgitmType == "09" { //西药费
  2669. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2670. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2671. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2672. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2673. if item.ChrgitmLv == "1" {
  2674. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2675. }
  2676. if item.ChrgitmLv == "2" {
  2677. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2678. }
  2679. if item.ChrgitmLv == "3" {
  2680. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2681. }
  2682. }
  2683. if item.MedChrgitmType == "10" { //中药饮片
  2684. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2685. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2686. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2687. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2688. if item.ChrgitmLv == "1" {
  2689. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2690. }
  2691. if item.ChrgitmLv == "2" {
  2692. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2693. }
  2694. if item.ChrgitmLv == "3" {
  2695. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2696. }
  2697. }
  2698. if item.MedChrgitmType == "11" { //中成费
  2699. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2700. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2701. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2702. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2703. if item.ChrgitmLv == "1" {
  2704. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2705. }
  2706. if item.ChrgitmLv == "2" {
  2707. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2708. }
  2709. if item.ChrgitmLv == "3" {
  2710. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2711. }
  2712. }
  2713. if item.MedChrgitmType == "12" { //中成费
  2714. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2715. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2716. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2717. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2718. if item.ChrgitmLv == "1" {
  2719. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2720. }
  2721. if item.ChrgitmLv == "2" {
  2722. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2723. }
  2724. if item.ChrgitmLv == "3" {
  2725. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2726. }
  2727. }
  2728. if item.MedChrgitmType == "13" { //中成费
  2729. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2730. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2731. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2732. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2733. if item.ChrgitmLv == "1" {
  2734. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2735. }
  2736. if item.ChrgitmLv == "2" {
  2737. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2738. }
  2739. if item.ChrgitmLv == "3" {
  2740. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2741. }
  2742. }
  2743. if item.MedChrgitmType == "14" { //其他费
  2744. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2745. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2746. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2747. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2748. if item.ChrgitmLv == "1" {
  2749. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2750. }
  2751. if item.ChrgitmLv == "2" {
  2752. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2753. }
  2754. if item.ChrgitmLv == "3" {
  2755. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2756. }
  2757. }
  2758. }
  2759. var iteminfoStructs []service.IteminfoStruct
  2760. if bedCostTotal != 0 {
  2761. iteminfo.MedChrgitm = "01"
  2762. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2763. iteminfo.Amt = bedCostTotal
  2764. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2765. iteminfo.ClabAmt = bed_clab_amt
  2766. iteminfo.OthAmt = bed_other_amt
  2767. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2768. }
  2769. if examineCostTotal != 0 {
  2770. iteminfo.MedChrgitm = "02"
  2771. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2772. iteminfo.Amt = examineCostTotal
  2773. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2774. iteminfo.ClabAmt = examine_clab_amt
  2775. iteminfo.OthAmt = examine_other_amt
  2776. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2777. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2778. }
  2779. if checkCostTotal != 0 {
  2780. iteminfo.MedChrgitm = "03"
  2781. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2782. iteminfo.Amt = checkCostTotal
  2783. iteminfo.ClaaSumfee = check_claa_sunmfee
  2784. iteminfo.ClabAmt = check_clab_amt
  2785. iteminfo.OthAmt = check_other_amt
  2786. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2787. }
  2788. if laboratoryCostTotal != 0 {
  2789. iteminfo.MedChrgitm = "04"
  2790. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2791. iteminfo.Amt = laboratoryCostTotal
  2792. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2793. iteminfo.ClabAmt = laboratory_clab_amt
  2794. iteminfo.OthAmt = laboratory_other_amt
  2795. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2796. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2797. }
  2798. if treatCostTotal != 0 {
  2799. iteminfo.MedChrgitm = "05"
  2800. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2801. iteminfo.Amt = treatCostTotal
  2802. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2803. iteminfo.ClabAmt = treat_clab_amt
  2804. iteminfo.OthAmt = treat_other_amt
  2805. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2806. //(struct4101.IteminfoStruct, iteminfo)
  2807. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2808. }
  2809. if operationCostTotal != 0 {
  2810. iteminfo.MedChrgitm = "06"
  2811. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2812. iteminfo.Amt = operationCostTotal
  2813. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2814. iteminfo.ClabAmt = operation_clab_amt
  2815. iteminfo.OthAmt = operation_other_amt
  2816. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2817. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2818. }
  2819. if nursingCostTotal != 0 {
  2820. iteminfo.MedChrgitm = "07"
  2821. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2822. iteminfo.Amt = nursingCostTotal
  2823. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2824. iteminfo.ClabAmt = nursing_clab_amt
  2825. iteminfo.OthAmt = nursing_other_amt
  2826. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2827. }
  2828. if materialCostTotal != 0 {
  2829. iteminfo.MedChrgitm = "08"
  2830. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2831. iteminfo.Amt = materialCostTotal
  2832. iteminfo.ClaaSumfee = material_claa_sunmfee
  2833. iteminfo.ClabAmt = material_clab_amt
  2834. iteminfo.OthAmt = material_other_amt
  2835. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2836. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2837. }
  2838. if westernMedicineCostTotal != 0 {
  2839. iteminfo.MedChrgitm = "09"
  2840. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2841. iteminfo.Amt = westernMedicineCostTotal
  2842. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2843. iteminfo.ClabAmt = westernMedicine_clab_amt
  2844. iteminfo.OthAmt = westernMedicine_other_amt
  2845. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2846. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2847. }
  2848. if chineseMedicineCostTotal != 0 {
  2849. iteminfo.MedChrgitm = "10"
  2850. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2851. iteminfo.Amt = chineseMedicineCostTotal
  2852. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2853. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2854. iteminfo.OthAmt = chinese_medicine_other_amt
  2855. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2856. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2857. }
  2858. if chineseTraditionalMedicineCostTotal != 0 {
  2859. iteminfo.MedChrgitm = "11"
  2860. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2861. iteminfo.Amt = westernMedicineCostTotal
  2862. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2863. iteminfo.ClabAmt = westernMedicine_clab_amt
  2864. iteminfo.OthAmt = westernMedicine_other_amt
  2865. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2866. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2867. }
  2868. if commonlyTreatmentCostTotal != 0 {
  2869. iteminfo.MedChrgitm = "12"
  2870. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2871. iteminfo.Amt = commonlyTreatmentCostTotal
  2872. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2873. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2874. iteminfo.OthAmt = commonly_treatment_other_amt
  2875. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2876. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2877. }
  2878. if registerCostTotal != 0 {
  2879. iteminfo.MedChrgitm = "13"
  2880. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2881. iteminfo.Amt = registerCostTotal
  2882. iteminfo.ClaaSumfee = register_claa_sunmfee
  2883. iteminfo.ClabAmt = register_clab_amt
  2884. iteminfo.OthAmt = register_other_amt
  2885. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2886. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2887. }
  2888. if otherCostTotal != 0 {
  2889. iteminfo.MedChrgitm = "14"
  2890. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2891. iteminfo.Amt = otherCostTotal
  2892. iteminfo.ClaaSumfee = other_claa_sunmfee
  2893. iteminfo.ClabAmt = other_clab_amt
  2894. iteminfo.OthAmt = other_other_amt
  2895. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2896. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2897. }
  2898. struct4101.IteminfoStruct = iteminfoStructs
  2899. struct4101.Ntly = "中国"
  2900. struct4101.AdmCaty = "A03.06"
  2901. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2902. fmt.Println(result)
  2903. var dat map[string]interface{}
  2904. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2905. fmt.Println(dat)
  2906. } else {
  2907. fmt.Println(err)
  2908. }
  2909. userJSONBytes, _ := json.Marshal(dat)
  2910. var res ResultSeventeen
  2911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2912. utils.ErrorLog("解析失败:%v", err)
  2913. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2914. adminUser := c.GetAdminUserInfo()
  2915. errlog := &models.HisOrderError{
  2916. UserOrgId: adminUser.CurrentOrgId,
  2917. Ctime: time.Now().Unix(),
  2918. Mtime: time.Now().Unix(),
  2919. ErrMsg: res.ErrMsg + "解析失败",
  2920. Status: 1,
  2921. PatientId: order_id,
  2922. Stage: 10106,
  2923. }
  2924. service.CreateErrMsgLog(errlog)
  2925. continue
  2926. }
  2927. if res.Infcode != 0 {
  2928. adminUser := c.GetAdminUserInfo()
  2929. errlog := &models.HisOrderError{
  2930. UserOrgId: adminUser.CurrentOrgId,
  2931. Ctime: time.Now().Unix(),
  2932. Mtime: time.Now().Unix(),
  2933. ErrMsg: res.ErrMsg,
  2934. Status: 1,
  2935. PatientId: order_id,
  2936. Stage: 10106,
  2937. }
  2938. service.CreateErrMsgLog(errlog)
  2939. continue
  2940. } else {
  2941. hisFundSettleListResult := &models.HisFundSettleListResult{
  2942. Number: res.Output.SetlListId,
  2943. Status: 1,
  2944. Ctime: time.Now().Unix(),
  2945. Mtime: time.Now().Unix(),
  2946. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2947. IsUpload: 1,
  2948. OrderId: order_id,
  2949. }
  2950. service.CreateUploadRecord(hisFundSettleListResult)
  2951. continue
  2952. }
  2953. }
  2954. }
  2955. func (c *HisApiController) GetOrgInfo() {
  2956. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2957. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2958. }
  2959. func (c *HisApiController) GetHisPatientInfo() {
  2960. medical_insurance_card := c.GetString("medical_insurance_card")
  2961. id_card_type, _ := c.GetInt64("id_card_type")
  2962. id_card := c.GetString("id_card")
  2963. adminInfo := c.GetAdminUserInfo()
  2964. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2965. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2966. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2967. IdCardNo := ""
  2968. if id_card_type == 1 {
  2969. IdCardNo = medical_insurance_card
  2970. } else if id_card_type == 2 {
  2971. IdCardNo = id_card
  2972. }
  2973. if config.IsOpen == 1 {
  2974. 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
  2975. resp, requestErr := http.Get(api)
  2976. if requestErr != nil {
  2977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2978. return
  2979. }
  2980. defer resp.Body.Close()
  2981. body, ioErr := ioutil.ReadAll(resp.Body)
  2982. if ioErr != nil {
  2983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2985. return
  2986. }
  2987. var respJSON map[string]interface{}
  2988. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2991. return
  2992. }
  2993. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2994. userJSONBytes, _ := json.Marshal(userJSON)
  2995. var res ResultTwo
  2996. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2997. utils.ErrorLog("解析失败:%v", err)
  2998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2999. return
  3000. }
  3001. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3002. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3003. infoStr := string(Iinfos)
  3004. idetinfoStr := string(Idetinfos)
  3005. if res.Infcode == 0 {
  3006. his := models.VMHisPatient{
  3007. Status: 1,
  3008. Ctime: time.Now().Unix(),
  3009. Mtime: time.Now().Unix(),
  3010. PsnNo: res.Output.Baseinfo.PsnNo,
  3011. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3012. Certno: res.Output.Baseinfo.Certno,
  3013. PsnName: res.Output.Baseinfo.PsnName,
  3014. Gend: res.Output.Baseinfo.Gend,
  3015. Naty: res.Output.Baseinfo.Naty,
  3016. Brdy: res.Output.Baseinfo.Brdy,
  3017. Age: res.Output.Baseinfo.Age,
  3018. Iinfo: infoStr,
  3019. Idetinfo: idetinfoStr,
  3020. UserOrgId: adminInfo.CurrentOrgId,
  3021. IsReturn: 1,
  3022. IdCardType: id_card_type,
  3023. }
  3024. c.ServeSuccessJSON(map[string]interface{}{
  3025. "info": his,
  3026. })
  3027. } else {
  3028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3029. return
  3030. }
  3031. }
  3032. }
  3033. //func GetBasBaseInfo() (jsonStr string, err error) {
  3034. //
  3035. // handle := syscall.NewLazyDLL("SSCard.dll")
  3036. // add := handle.NewProc("ReadCardBas")
  3037. // str := make([]byte, 1024)
  3038. // str1 := make([]byte, 1024)
  3039. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3040. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3041. //
  3042. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3043. //
  3044. // fmt.Println("> Add(4,5)的结果为:", ret)
  3045. // handle.Release()
  3046. //
  3047. // return "", nil
  3048. //
  3049. //}
  3050. //func GetQRBaseInfo() (jsonStr string, err error) {
  3051. // handle := syscall.LoadDLL("SSCard.dll")
  3052. // ReadCardBas := handle.FindProc("GetQRBase")
  3053. //
  3054. // str := make([]byte, 256)
  3055. // str1 := make([]byte, 256)
  3056. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3057. //
  3058. // fmt.Println(string(str))
  3059. // fmt.Println(r)
  3060. // return string(str), nil
  3061. //}
  3062. //func CardInit() int {
  3063. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3064. // add := DllTestDef.MustFindProc("Init")
  3065. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3066. // if err != nil {
  3067. // fmt.Println("SSCard的运算结果为:", ret)
  3068. // }
  3069. // result := int(ret)
  3070. // return result
  3071. //}
  3072. //func CardInit() int {
  3073. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3074. // if err != nil {
  3075. // fmt.Println("SSCard的运算结果为:", ret)
  3076. // }
  3077. // fmt.Println(err)
  3078. // result := int(ret)
  3079. // return result
  3080. //}
  3081. func IntPtr(n int) uintptr {
  3082. return uintptr(n)
  3083. }
  3084. func StrPtr(s string) uintptr {
  3085. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3086. }
  3087. type Result2001 struct {
  3088. Cainfo interface{} `json:"cainfo"`
  3089. ErrMsg string `json:"err_msg"`
  3090. InfRefmsgid string `json:"inf_refmsgid"`
  3091. Infcode int64 `json:"infcode"`
  3092. Output struct {
  3093. Trtinfo struct {
  3094. PsnNo string `json:"psn_no"`
  3095. TrtChkType string `json:"trt_chk_type"`
  3096. FundPayType string `json:"fund_pay_type"`
  3097. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3098. Begndate string `json:"begndate"`
  3099. Enddate string `json:"enddate"`
  3100. TrtChkRslt string `json:"trt_chk_rslt"`
  3101. } `json:"trtinfo"`
  3102. } `json:"output"`
  3103. RefmsgTime string `json:"refmsg_time"`
  3104. RespondTime string `json:"respond_time"`
  3105. Signtype interface{} `json:"signtype"`
  3106. WarnMsg interface{} `json:"warn_msg"`
  3107. }
  3108. type Result2001Org10265 struct {
  3109. Cainfo interface{} `json:"cainfo"`
  3110. ErrMsg string `json:"err_msg"`
  3111. InfRefmsgid string `json:"inf_refmsgid"`
  3112. Infcode string `json:"infcode"`
  3113. Output struct {
  3114. Trtinfo struct {
  3115. PsnNo string `json:"psn_no"`
  3116. TrtChkType string `json:"trt_chk_type"`
  3117. FundPayType string `json:"fund_pay_type"`
  3118. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3119. Begndate string `json:"begndate"`
  3120. Enddate string `json:"enddate"`
  3121. TrtChkRslt string `json:"trt_chk_rslt"`
  3122. } `json:"trtinfo"`
  3123. } `json:"output"`
  3124. RefmsgTime string `json:"refmsg_time"`
  3125. RespondTime string `json:"respond_time"`
  3126. Signtype interface{} `json:"signtype"`
  3127. WarnMsg interface{} `json:"warn_msg"`
  3128. }
  3129. type ResultTwo struct {
  3130. ErrMsg string `json:"err_msg"`
  3131. InfRefmsgid string `json:"inf_refmsgid"`
  3132. Infcode int64 `json:"infcode"`
  3133. Output struct {
  3134. Baseinfo struct {
  3135. Age float64 `json:"age"`
  3136. Brdy string `json:"brdy"`
  3137. Certno string `json:"certno"`
  3138. Gend string `json:"gend"`
  3139. Naty string `json:"naty"`
  3140. PsnCertType string `json:"psn_cert_type"`
  3141. PsnName string `json:"psn_name"`
  3142. PsnNo string `json:"psn_no"`
  3143. } `json:"baseinfo"`
  3144. Idetinfo []interface{} `json:"idetinfo"`
  3145. Iinfo []struct {
  3146. Balc float64 `json:"balc"`
  3147. CvlservFlag string `json:"cvlserv_flag"`
  3148. EmpName string `json:"emp_name"`
  3149. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3150. Insutype string `json:"insutype"`
  3151. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3152. PausInsuDate string `json:"paus_insu_date"`
  3153. PsnInsuDate string `json:"psn_insu_date"`
  3154. PsnInsuStas string `json:"psn_insu_stas"`
  3155. PsnType string `json:"psn_type"`
  3156. } `json:"insuinfo"`
  3157. } `json:"output"`
  3158. RefmsgTime string `json:"refmsg_time"`
  3159. RespondTime string `json:"respond_time"`
  3160. Signtype interface{} `json:"signtype"`
  3161. WarnInfo interface{} `json:"warn_info"`
  3162. }
  3163. type ResultTwo10265 struct {
  3164. ErrMsg string `json:"err_msg"`
  3165. InfRefmsgid string `json:"inf_refmsgid"`
  3166. Infcode string `json:"infcode"`
  3167. Output struct {
  3168. Baseinfo struct {
  3169. Age float64 `json:"age"`
  3170. Brdy string `json:"brdy"`
  3171. Certno string `json:"certno"`
  3172. Gend string `json:"gend"`
  3173. Naty string `json:"naty"`
  3174. PsnCertType string `json:"psn_cert_type"`
  3175. PsnName string `json:"psn_name"`
  3176. PsnNo string `json:"psn_no"`
  3177. } `json:"baseinfo"`
  3178. Idetinfo []interface{} `json:"idetinfo"`
  3179. Iinfo []struct {
  3180. Balc float64 `json:"balc"`
  3181. CvlservFlag string `json:"cvlserv_flag"`
  3182. EmpName string `json:"emp_name"`
  3183. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3184. Insutype string `json:"insutype"`
  3185. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3186. PausInsuDate string `json:"paus_insu_date"`
  3187. PsnInsuDate string `json:"psn_insu_date"`
  3188. PsnInsuStas string `json:"psn_insu_stas"`
  3189. PsnType string `json:"psn_type"`
  3190. } `json:"insuinfo"`
  3191. } `json:"output"`
  3192. RefmsgTime string `json:"refmsg_time"`
  3193. RespondTime string `json:"respond_time"`
  3194. Signtype interface{} `json:"signtype"`
  3195. WarnInfo interface{} `json:"warn_info"`
  3196. }
  3197. type ResultThree struct {
  3198. Cainfo interface{} `json:"cainfo"`
  3199. ErrMsg string `json:"err_msg"`
  3200. InfRefmsgid string `json:"inf_refmsgid"`
  3201. Infcode int64 `json:"infcode"`
  3202. Output struct {
  3203. Data struct {
  3204. IptOtpNo string `json:"ipt_otp_no"`
  3205. MdtrtID string `json:"mdtrt_id"`
  3206. PsnNo string `json:"psn_no"`
  3207. } `json:"data"`
  3208. } `json:"output"`
  3209. RefmsgTime string `json:"refmsg_time"`
  3210. RespondTime string `json:"respond_time"`
  3211. Signtype interface{} `json:"signtype"`
  3212. WarnMsg interface{} `json:"warn_msg"`
  3213. }
  3214. type ResultThree10265 struct {
  3215. Cainfo interface{} `json:"cainfo"`
  3216. ErrMsg string `json:"err_msg"`
  3217. InfRefmsgid string `json:"inf_refmsgid"`
  3218. Infcode string `json:"infcode"`
  3219. Output struct {
  3220. Data struct {
  3221. IptOtpNo string `json:"ipt_otp_no"`
  3222. MdtrtID string `json:"mdtrt_id"`
  3223. PsnNo string `json:"psn_no"`
  3224. } `json:"data"`
  3225. } `json:"output"`
  3226. RefmsgTime string `json:"refmsg_time"`
  3227. RespondTime string `json:"respond_time"`
  3228. Signtype interface{} `json:"signtype"`
  3229. WarnMsg interface{} `json:"warn_msg"`
  3230. }
  3231. type ResultFour struct {
  3232. Cainfo string `json:"cainfo"`
  3233. ErrMsg string `json:"err_msg"`
  3234. InfRefmsgid string `json:"inf_refmsgid"`
  3235. Infcode int64 `json:"infcode"`
  3236. Output struct {
  3237. Result []struct {
  3238. BasMednFlag string `json:"bas_medn_flag"`
  3239. ChldMedcFlag string `json:"chld_medc_flag"`
  3240. ChrgitmLv string `json:"chrgitm_lv"`
  3241. Cnt float64 `json:"cnt"`
  3242. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3243. DrtReimFlag string `json:"drt_reim_flag"`
  3244. FeedetlSn string `json:"feedetl_sn"`
  3245. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3246. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3247. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3248. ListSpItemFlag string `json:"list_sp_item_flag"`
  3249. LmtUsedFlag string `json:"lmt_used_flag"`
  3250. MedChrgitmType string `json:"med_chrgitm_type"`
  3251. Memo string `json:"memo"`
  3252. OverlmtAmt float64 `json:"overlmt_amt"`
  3253. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3254. Pric float64 `json:"pric"`
  3255. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3256. SelfpayProp float64 `json:"selfpay_prop"`
  3257. } `json:"result"`
  3258. } `json:"output"`
  3259. RefmsgTime string `json:"refmsg_time"`
  3260. RespondTime string `json:"respond_time"`
  3261. Signtype string `json:"signtype"`
  3262. WarnMsg string `json:"warn_msg"`
  3263. }
  3264. type ResultFour10265 struct {
  3265. Cainfo string `json:"cainfo"`
  3266. ErrMsg string `json:"err_msg"`
  3267. InfRefmsgid string `json:"inf_refmsgid"`
  3268. Infcode string `json:"infcode"`
  3269. Output struct {
  3270. Result []struct {
  3271. BasMednFlag string `json:"bas_medn_flag"`
  3272. ChldMedcFlag string `json:"chld_medc_flag"`
  3273. ChrgitmLv string `json:"chrgitm_lv"`
  3274. Cnt float64 `json:"cnt"`
  3275. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3276. DrtReimFlag string `json:"drt_reim_flag"`
  3277. FeedetlSn string `json:"feedetl_sn"`
  3278. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3279. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3280. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3281. ListSpItemFlag string `json:"list_sp_item_flag"`
  3282. LmtUsedFlag string `json:"lmt_used_flag"`
  3283. MedChrgitmType string `json:"med_chrgitm_type"`
  3284. Memo string `json:"memo"`
  3285. OverlmtAmt float64 `json:"overlmt_amt"`
  3286. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3287. Pric float64 `json:"pric"`
  3288. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3289. SelfpayProp float64 `json:"selfpay_prop"`
  3290. } `json:"result"`
  3291. } `json:"output"`
  3292. RefmsgTime string `json:"refmsg_time"`
  3293. RespondTime string `json:"respond_time"`
  3294. Signtype string `json:"signtype"`
  3295. WarnMsg string `json:"warn_msg"`
  3296. }
  3297. type ResultFive struct {
  3298. Balc float64 `json:"balc"`
  3299. CvlservFlag string `json:"cvlserv_flag"`
  3300. EmpName string `json:"emp_name"`
  3301. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3302. Insutype string `json:"insutype"`
  3303. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3304. PausInsuDate string `json:"paus_insu_date"`
  3305. PsnInsuDate string `json:"psn_insu_date"`
  3306. PsnInsuStas string `json:"psn_insu_stas"`
  3307. PsnType string `json:"psn_type"`
  3308. }
  3309. type ResultSix struct {
  3310. Cainfo interface{} `json:"cainfo"`
  3311. ErrMsg string `json:"err_msg"`
  3312. InfRefmsgid string `json:"inf_refmsgid"`
  3313. Infcode int64 `json:"infcode"`
  3314. Output struct {
  3315. } `json:"output"`
  3316. RefmsgTime string `json:"refmsg_time"`
  3317. RespondTime string `json:"respond_time"`
  3318. Signtype interface{} `json:"signtype"`
  3319. WarnMsg interface{} `json:"warn_msg"`
  3320. }
  3321. type ResultSix10265 struct {
  3322. Cainfo interface{} `json:"cainfo"`
  3323. ErrMsg string `json:"err_msg"`
  3324. InfRefmsgid string `json:"inf_refmsgid"`
  3325. Infcode string `json:"infcode"`
  3326. Output struct {
  3327. } `json:"output"`
  3328. RefmsgTime string `json:"refmsg_time"`
  3329. RespondTime string `json:"respond_time"`
  3330. Signtype interface{} `json:"signtype"`
  3331. WarnMsg interface{} `json:"warn_msg"`
  3332. }
  3333. type ResultSeven struct {
  3334. Cainfo string `json:"cainfo"`
  3335. ErrMsg string `json:"err_msg"`
  3336. InfRefmsgid string `json:"inf_refmsgid"`
  3337. Infcode int64 `json:"infcode"`
  3338. Output struct {
  3339. Setldetail []interface{} `json:"setldetail"`
  3340. Setlinfo struct {
  3341. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3342. AcctPay float64 `json:"acct_pay"`
  3343. ActPayDedc float64 `json:"act_pay_dedc"`
  3344. Age float64 `json:"age"`
  3345. Balc float64 `json:"balc"`
  3346. Brdy string `json:"brdy"`
  3347. Certno string `json:"certno"`
  3348. ClrOptins string `json:"clr_optins"`
  3349. ClrType string `json:"clr_type"`
  3350. ClrWay string `json:"clr_way"`
  3351. CvlservFlag string `json:"cvlserv_flag"`
  3352. CvlservPay float64 `json:"cvlserv_pay"`
  3353. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3354. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3355. Gend string `json:"gend"`
  3356. HifesPay float64 `json:"hifes_pay"`
  3357. HifmiPay float64 `json:"hifmi_pay"`
  3358. HifpPay float64 `json:"hifp_pay"`
  3359. HospPartAmt float64 `json:"hosp_part_amt"`
  3360. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3361. Insutype string `json:"insutype"`
  3362. MafPay float64 `json:"maf_pay"`
  3363. MdtrtCertType string `json:"mdtrt_cert_type"`
  3364. HifobPay float64 `json:"hifob_pay"`
  3365. MdtrtID string `json:"mdtrt_id"`
  3366. MedType string `json:"med_type"`
  3367. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3368. MedinsSetlID string `json:"medins_setl_id"`
  3369. Naty string `json:"naty"`
  3370. OthPay float64 `json:"oth_pay"`
  3371. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3372. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3373. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3374. PsnCashPay float64 `json:"psn_cash_pay"`
  3375. PsnCertType string `json:"psn_cert_type"`
  3376. PsnName string `json:"psn_name"`
  3377. PsnNo string `json:"psn_no"`
  3378. PsnPartAmt float64 `json:"psn_part_amt"`
  3379. PsnType string `json:"psn_type"`
  3380. SetlID string `json:"setl_id"`
  3381. SetlTime string `json:"setl_time"`
  3382. } `json:"setlinfo"`
  3383. } `json:"output"`
  3384. RefmsgTime string `json:"refmsg_time"`
  3385. RespondTime string `json:"respond_time"`
  3386. Signtype interface{} `json:"signtype"`
  3387. WarnMsg interface{} `json:"warn_msg"`
  3388. }
  3389. type ResultSeven10265 struct {
  3390. Cainfo string `json:"cainfo"`
  3391. ErrMsg string `json:"err_msg"`
  3392. InfRefmsgid string `json:"inf_refmsgid"`
  3393. Infcode string `json:"infcode"`
  3394. Output struct {
  3395. Setldetail []interface{} `json:"setldetail"`
  3396. Setlinfo struct {
  3397. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3398. AcctPay float64 `json:"acct_pay"`
  3399. ActPayDedc float64 `json:"act_pay_dedc"`
  3400. Age float64 `json:"age"`
  3401. Balc float64 `json:"balc"`
  3402. Brdy string `json:"brdy"`
  3403. Certno string `json:"certno"`
  3404. ClrOptins string `json:"clr_optins"`
  3405. ClrType string `json:"clr_type"`
  3406. ClrWay string `json:"clr_way"`
  3407. CvlservFlag string `json:"cvlserv_flag"`
  3408. CvlservPay float64 `json:"cvlserv_pay"`
  3409. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3410. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3411. Gend string `json:"gend"`
  3412. HifesPay float64 `json:"hifes_pay"`
  3413. HifmiPay float64 `json:"hifmi_pay"`
  3414. HifpPay float64 `json:"hifp_pay"`
  3415. HospPartAmt float64 `json:"hosp_part_amt"`
  3416. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3417. Insutype string `json:"insutype"`
  3418. MafPay float64 `json:"maf_pay"`
  3419. MdtrtCertType string `json:"mdtrt_cert_type"`
  3420. HifobPay float64 `json:"hifob_pay"`
  3421. MdtrtID string `json:"mdtrt_id"`
  3422. MedType string `json:"med_type"`
  3423. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3424. MedinsSetlID string `json:"medins_setl_id"`
  3425. Naty string `json:"naty"`
  3426. OthPay float64 `json:"oth_pay"`
  3427. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3428. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3429. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3430. PsnCashPay float64 `json:"psn_cash_pay"`
  3431. PsnCertType string `json:"psn_cert_type"`
  3432. PsnName string `json:"psn_name"`
  3433. PsnNo string `json:"psn_no"`
  3434. PsnPartAmt float64 `json:"psn_part_amt"`
  3435. PsnType string `json:"psn_type"`
  3436. SetlID string `json:"setl_id"`
  3437. SetlTime string `json:"setl_time"`
  3438. } `json:"setlinfo"`
  3439. } `json:"output"`
  3440. RefmsgTime string `json:"refmsg_time"`
  3441. RespondTime string `json:"respond_time"`
  3442. Signtype interface{} `json:"signtype"`
  3443. WarnMsg interface{} `json:"warn_msg"`
  3444. }
  3445. type ResultEight struct {
  3446. Cainfo string `json:"cainfo"`
  3447. ErrMsg string `json:"err_msg"`
  3448. InfRefmsgid string `json:"inf_refmsgid"`
  3449. Infcode int64 `json:"infcode"`
  3450. Output struct {
  3451. Stmtinfo struct {
  3452. SetlOptins string `json:"setl_optins"`
  3453. StmtRslt string `json:"stmt_rslt"`
  3454. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3455. } `json:"stmtinfo"`
  3456. } `json:"output"`
  3457. RefmsgTime string `json:"refmsg_time"`
  3458. RespondTime string `json:"respond_time"`
  3459. Signtype interface{} `json:"signtype"`
  3460. WarnMsg interface{} `json:"warn_msg"`
  3461. }
  3462. type ResultEightFor10188 struct {
  3463. Cainfo string `json:"cainfo"`
  3464. ErrMsg string `json:"err_msg"`
  3465. InfRefmsgid string `json:"inf_refmsgid"`
  3466. Infcode string `json:"infcode"`
  3467. Output struct {
  3468. Stmtinfo struct {
  3469. SetlOptins string `json:"setl_optins"`
  3470. StmtRslt string `json:"stmt_rslt"`
  3471. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3472. } `json:"stmtinfo"`
  3473. } `json:"output"`
  3474. RefmsgTime string `json:"refmsg_time"`
  3475. RespondTime string `json:"respond_time"`
  3476. Signtype interface{} `json:"signtype"`
  3477. WarnMsg interface{} `json:"warn_msg"`
  3478. }
  3479. type ResultNine struct {
  3480. Cainfo string `json:"cainfo"`
  3481. ErrMsg string `json:"err_msg"`
  3482. InfRefmsgid string `json:"inf_refmsgid"`
  3483. Infcode int64 `json:"infcode"`
  3484. Output struct {
  3485. FileQuryNo string `json:"file_qury_no"`
  3486. } `json:"output"`
  3487. RefmsgTime string `json:"refmsg_time"`
  3488. RespondTime string `json:"respond_time"`
  3489. Signtype interface{} `json:"signtype"`
  3490. WarnMsg interface{} `json:"warn_msg"`
  3491. }
  3492. type ResultTen struct {
  3493. Cainfo string `json:"cainfo"`
  3494. ErrMsg string `json:"err_msg"`
  3495. InfRefmsgid string `json:"inf_refmsgid"`
  3496. Infcode int64 `json:"infcode"`
  3497. Output struct {
  3498. DldEndtime string `json:"dld_endtime"`
  3499. FileQuryNo string `json:"file_qury_no"`
  3500. Filename string `json:"filename"`
  3501. } `json:"output"`
  3502. RefmsgTime string `json:"refmsg_time"`
  3503. RespondTime string `json:"respond_time"`
  3504. Signtype interface{} `json:"signtype"`
  3505. WarnMsg interface{} `json:"warn_msg"`
  3506. }
  3507. //type Autogenerated struct {
  3508. // Output struct {
  3509. // Setlinfo struct {
  3510. // SetlTime string `json:"setl_time"`
  3511. // CvlservPay float64 `json:"cvlserv_pay"`
  3512. // Year string `json:"year"`
  3513. // MedType string `json:"med_type"`
  3514. // PsnPay float64 `json:"psn_pay"`
  3515. // OpterID string `json:"opter_id"`
  3516. // Begndate string `json:"begndate"`
  3517. // FlxempeFlag string `json:"flxempe_flag"`
  3518. // HifmiPay float64 `json:"hifmi_pay"`
  3519. // PsnNo string `json:"psn_no"`
  3520. // ActPayDedc float64 `json:"act_pay_dedc"`
  3521. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3522. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3523. // ClrWay string `json:"clr_way"`
  3524. // OthPay float64 `json:"oth_pay"`
  3525. // Gend string `json:"gend"`
  3526. // MdtrtID string `json:"mdtrt_id"`
  3527. // AcctPay float64 `json:"acct_pay"`
  3528. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3529. // Insutype string `json:"insutype"`
  3530. // Invono interface{} `json:"invono"`
  3531. // Enddate string `json:"enddate"`
  3532. // CashPayamt float64 `json:"cash_payamt"`
  3533. // PsnType string `json:"psn_type"`
  3534. // FixmedinsName string `json:"fixmedins_name"`
  3535. // HifpPay float64 `json:"hifp_pay"`
  3536. // NewFlag interface{} `json:"new_flag"`
  3537. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3538. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3539. // PayLoc string `json:"pay_loc"`
  3540. // ClrType string `json:"clr_type"`
  3541. // RefdSetlFlag string `json:"refd_setl_flag"`
  3542. // CvlservFlag string `json:"cvlserv_flag"`
  3543. // EmpName string `json:"emp_name"`
  3544. // Brdy string `json:"brdy"`
  3545. // Naty string `json:"naty"`
  3546. // Certno string `json:"certno"`
  3547. // DiseCode string `json:"dise_code"`
  3548. // FixmedinsCode string `json:"fixmedins_code"`
  3549. // DedcHospLv string `json:"dedc_hosp_lv"`
  3550. // OpterName string `json:"opter_name"`
  3551. // Balc float64 `json:"balc"`
  3552. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3553. // PsnCertType string `json:"psn_cert_type"`
  3554. // HifobPay float64 `json:"hifob_pay"`
  3555. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3556. // HifesPay float64 `json:"hifes_pay"`
  3557. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3558. // OptTime string `json:"opt_time"`
  3559. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3560. // SetlID string `json:"setl_id"`
  3561. // MafPay float64 `json:"maf_pay"`
  3562. // PsnName string `json:"psn_name"`
  3563. // InsuOptins interface{} `json:"insu_optins"`
  3564. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3565. // ClrOptins string `json:"clr_optins"`
  3566. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3567. // DiseName string `json:"dise_name"`
  3568. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3569. // Age float64 `json:"age"`
  3570. // DtrtCertType string `json:"dtrt_cert_type"`
  3571. // HospLv string `json:"hosp_lv"`
  3572. // } `json:"setlinfo"`
  3573. // Setldetail []struct {
  3574. // FundPayType string `json:"fund_pay_type"`
  3575. // FundPayamt float64 `json:"fund_payamt"`
  3576. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3577. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3578. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3579. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3580. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3581. // } `json:"setldetail"`
  3582. // } `json:"output"`
  3583. // Infcode int `json:"infcode"`
  3584. // WarnMsg interface{} `json:"warn_msg"`
  3585. // Cainfo interface{} `json:"cainfo"`
  3586. // ErrMsg interface{} `json:"err_msg"`
  3587. // RefmsgTime string `json:"refmsg_time"`
  3588. // Signtype interface{} `json:"signtype"`
  3589. // RespondTime string `json:"respond_time"`
  3590. // InfRefmsgid string `json:"inf_refmsgid"`
  3591. //}
  3592. type ResultEleven struct {
  3593. Cainfo string `json:"cainfo"`
  3594. ErrMsg string `json:"err_msg"`
  3595. InfRefmsgid string `json:"inf_refmsgid"`
  3596. Infcode int64 `json:"infcode"`
  3597. Output struct {
  3598. Setlinfo struct {
  3599. SetlTime string `json:"setl_time"`
  3600. CvlservPay float64 `json:"cvlserv_pay"`
  3601. Year string `json:"year"`
  3602. MedType string `json:"med_type"`
  3603. PsnPay float64 `json:"psn_pay"`
  3604. OpterID string `json:"opter_id"`
  3605. Begndate string `json:"begndate"`
  3606. FlxempeFlag string `json:"flxempe_flag"`
  3607. HifmiPay float64 `json:"hifmi_pay"`
  3608. PsnNo string `json:"psn_no"`
  3609. ActPayDedc float64 `json:"act_pay_dedc"`
  3610. MedinsSetlID interface{} `json:"medins_setl_id"`
  3611. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3612. ClrWay string `json:"clr_way"`
  3613. OthPay float64 `json:"oth_pay"`
  3614. Gend string `json:"gend"`
  3615. MdtrtID string `json:"mdtrt_id"`
  3616. AcctPay float64 `json:"acct_pay"`
  3617. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3618. Insutype string `json:"insutype"`
  3619. Invono interface{} `json:"invono"`
  3620. Enddate string `json:"enddate"`
  3621. CashPayamt float64 `json:"cash_payamt"`
  3622. PsnType string `json:"psn_type"`
  3623. FixmedinsName string `json:"fixmedins_name"`
  3624. HifpPay float64 `json:"hifp_pay"`
  3625. NewFlag interface{} `json:"new_flag"`
  3626. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3627. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3628. PayLoc string `json:"pay_loc"`
  3629. ClrType string `json:"clr_type"`
  3630. RefdSetlFlag string `json:"refd_setl_flag"`
  3631. CvlservFlag string `json:"cvlserv_flag"`
  3632. EmpName string `json:"emp_name"`
  3633. Brdy string `json:"brdy"`
  3634. Naty string `json:"naty"`
  3635. Certno string `json:"certno"`
  3636. DiseCode string `json:"dise_code"`
  3637. FixmedinsCode string `json:"fixmedins_code"`
  3638. DedcHospLv string `json:"dedc_hosp_lv"`
  3639. OpterName string `json:"opter_name"`
  3640. Balc float64 `json:"balc"`
  3641. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3642. PsnCertType string `json:"psn_cert_type"`
  3643. HifobPay float64 `json:"hifob_pay"`
  3644. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3645. HifesPay float64 `json:"hifes_pay"`
  3646. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3647. OptTime string `json:"opt_time"`
  3648. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3649. SetlID string `json:"setl_id"`
  3650. MafPay float64 `json:"maf_pay"`
  3651. PsnName string `json:"psn_name"`
  3652. InsuOptins interface{} `json:"insu_optins"`
  3653. PrefFundPay interface{} `json:"pref_fund_pay"`
  3654. ClrOptins string `json:"clr_optins"`
  3655. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3656. DiseName string `json:"dise_name"`
  3657. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3658. Age float64 `json:"age"`
  3659. DtrtCertType string `json:"dtrt_cert_type"`
  3660. HospLv string `json:"hosp_lv"`
  3661. } `json:"setlinfo"`
  3662. } `json:"output"`
  3663. RefmsgTime string `json:"refmsg_time"`
  3664. RespondTime string `json:"respond_time"`
  3665. Signtype interface{} `json:"signtype"`
  3666. WarnMsg interface{} `json:"warn_msg"`
  3667. }
  3668. type ResultEleven10265 struct {
  3669. Cainfo string `json:"cainfo"`
  3670. ErrMsg string `json:"err_msg"`
  3671. InfRefmsgid string `json:"inf_refmsgid"`
  3672. Infcode string `json:"infcode"`
  3673. Output struct {
  3674. Setlinfo struct {
  3675. SetlTime string `json:"setl_time"`
  3676. CvlservPay float64 `json:"cvlserv_pay"`
  3677. Year string `json:"year"`
  3678. MedType string `json:"med_type"`
  3679. PsnPay float64 `json:"psn_pay"`
  3680. OpterID string `json:"opter_id"`
  3681. Begndate string `json:"begndate"`
  3682. FlxempeFlag string `json:"flxempe_flag"`
  3683. HifmiPay float64 `json:"hifmi_pay"`
  3684. PsnNo string `json:"psn_no"`
  3685. ActPayDedc float64 `json:"act_pay_dedc"`
  3686. MedinsSetlID interface{} `json:"medins_setl_id"`
  3687. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3688. ClrWay string `json:"clr_way"`
  3689. OthPay float64 `json:"oth_pay"`
  3690. Gend string `json:"gend"`
  3691. MdtrtID string `json:"mdtrt_id"`
  3692. AcctPay float64 `json:"acct_pay"`
  3693. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3694. Insutype string `json:"insutype"`
  3695. Invono interface{} `json:"invono"`
  3696. Enddate string `json:"enddate"`
  3697. CashPayamt float64 `json:"cash_payamt"`
  3698. PsnType string `json:"psn_type"`
  3699. FixmedinsName string `json:"fixmedins_name"`
  3700. HifpPay float64 `json:"hifp_pay"`
  3701. NewFlag interface{} `json:"new_flag"`
  3702. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3703. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3704. PayLoc string `json:"pay_loc"`
  3705. ClrType string `json:"clr_type"`
  3706. RefdSetlFlag string `json:"refd_setl_flag"`
  3707. CvlservFlag string `json:"cvlserv_flag"`
  3708. EmpName string `json:"emp_name"`
  3709. Brdy string `json:"brdy"`
  3710. Naty string `json:"naty"`
  3711. Certno string `json:"certno"`
  3712. DiseCode string `json:"dise_code"`
  3713. FixmedinsCode string `json:"fixmedins_code"`
  3714. DedcHospLv string `json:"dedc_hosp_lv"`
  3715. OpterName string `json:"opter_name"`
  3716. Balc float64 `json:"balc"`
  3717. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3718. PsnCertType string `json:"psn_cert_type"`
  3719. HifobPay float64 `json:"hifob_pay"`
  3720. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3721. HifesPay float64 `json:"hifes_pay"`
  3722. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3723. OptTime string `json:"opt_time"`
  3724. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3725. SetlID string `json:"setl_id"`
  3726. MafPay float64 `json:"maf_pay"`
  3727. PsnName string `json:"psn_name"`
  3728. InsuOptins interface{} `json:"insu_optins"`
  3729. PrefFundPay interface{} `json:"pref_fund_pay"`
  3730. ClrOptins string `json:"clr_optins"`
  3731. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3732. DiseName string `json:"dise_name"`
  3733. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3734. Age float64 `json:"age"`
  3735. DtrtCertType string `json:"dtrt_cert_type"`
  3736. HospLv string `json:"hosp_lv"`
  3737. } `json:"setlinfo"`
  3738. } `json:"output"`
  3739. RefmsgTime string `json:"refmsg_time"`
  3740. RespondTime string `json:"respond_time"`
  3741. Signtype interface{} `json:"signtype"`
  3742. WarnMsg interface{} `json:"warn_msg"`
  3743. }
  3744. type ResultTwelve struct {
  3745. Cainfo string `json:"cainfo"`
  3746. ErrMsg string `json:"err_msg"`
  3747. InfRefmsgid string `json:"inf_refmsgid"`
  3748. Infcode int64 `json:"infcode"`
  3749. Output struct {
  3750. MdtrtId string `json:"mdtrt_id"`
  3751. ChrgBchno string `json:"chrg_bchno"`
  3752. PsnNo string `json:"psn_no"`
  3753. } `json:"output"`
  3754. RefmsgTime string `json:"refmsg_time"`
  3755. RespondTime string `json:"respond_time"`
  3756. Signtype interface{} `json:"signtype"`
  3757. WarnMsg interface{} `json:"warn_msg"`
  3758. }
  3759. type ResultThirteen struct {
  3760. ErrMsg string `json:"err_msg"`
  3761. InfRefmsgid string `json:"inf_refmsgid"`
  3762. Infcode int64 `json:"infcode"`
  3763. Output struct {
  3764. Result struct {
  3765. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3766. } `json:"result"`
  3767. } `json:"output"`
  3768. RefmsgTime string `json:"refmsg_time"`
  3769. RespondTime string `json:"respond_time"`
  3770. Signtype interface{} `json:"signtype"`
  3771. WarnInfo interface{} `json:"warn_info"`
  3772. }
  3773. type ResultThirteen10265 struct {
  3774. ErrMsg string `json:"err_msg"`
  3775. InfRefmsgid string `json:"inf_refmsgid"`
  3776. Infcode string `json:"infcode"`
  3777. Output struct {
  3778. Result struct {
  3779. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3780. } `json:"result"`
  3781. } `json:"output"`
  3782. RefmsgTime string `json:"refmsg_time"`
  3783. RespondTime string `json:"respond_time"`
  3784. Signtype interface{} `json:"signtype"`
  3785. WarnInfo interface{} `json:"warn_info"`
  3786. }
  3787. type ResultFourteen struct {
  3788. ErrMsg string `json:"err_msg"`
  3789. InfRefmsgid string `json:"inf_refmsgid"`
  3790. Infcode int64 `json:"infcode"`
  3791. Output struct {
  3792. } `json:"output"`
  3793. RefmsgTime string `json:"refmsg_time"`
  3794. RespondTime string `json:"respond_time"`
  3795. Signtype interface{} `json:"signtype"`
  3796. WarnInfo interface{} `json:"warn_info"`
  3797. }
  3798. type ResultFourteen10265 struct {
  3799. ErrMsg string `json:"err_msg"`
  3800. InfRefmsgid string `json:"inf_refmsgid"`
  3801. Infcode string `json:"infcode"`
  3802. Output struct {
  3803. } `json:"output"`
  3804. RefmsgTime string `json:"refmsg_time"`
  3805. RespondTime string `json:"respond_time"`
  3806. Signtype interface{} `json:"signtype"`
  3807. WarnInfo interface{} `json:"warn_info"`
  3808. }
  3809. type ResultSixteen struct {
  3810. Cainfo string `json:"cainfo"`
  3811. ErrMsg string `json:"err_msg"`
  3812. InfRefmsgid string `json:"inf_refmsgid"`
  3813. Infcode int64 `json:"infcode"`
  3814. Output struct {
  3815. Setldetail []interface{} `json:"setldetail"`
  3816. Setlinfo struct {
  3817. MdtrtID string `json:"mdtrt_id"`
  3818. SetlID string `json:"setl_id"`
  3819. ClrOptins string `json:"clr_optins"`
  3820. SetlTime string `json:"setl_time"`
  3821. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3822. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3823. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3824. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3825. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3826. ActPayDedc float64 `json:"act_pay_dedc"`
  3827. HifpPay float64 `json:"hifp_pay"`
  3828. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3829. Lfpay float64 `json:"selfpay"`
  3830. CvlservPay float64 `json:"cvlserv_pay"`
  3831. HifesPay float64 `json:"hifes_pay"`
  3832. HifmiPay float64 `json:"hifmi_pay"`
  3833. HifobPay float64 `json:"hifob_pay"`
  3834. MafPay float64 `json:"maf_pay"`
  3835. OthPay float64 `json:"oth_pay"`
  3836. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3837. PsnPartAmt float64 `json:"psn_part_amt"`
  3838. AcctPay float64 `json:"acct_pay"`
  3839. Balc float64 `json:"balc"`
  3840. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3841. HospPartAmt float64 `json:"hosp_part_amt"`
  3842. MedinsSetlID string `json:"medins_setl_id"`
  3843. PdnCashPay string `json:"pdn_cash_pay"`
  3844. } `json:"setlinfo"`
  3845. } `json:"output"`
  3846. RefmsgTime string `json:"refmsg_time"`
  3847. RespondTime string `json:"respond_time"`
  3848. Signtype interface{} `json:"signtype"`
  3849. WarnMsg interface{} `json:"warn_msg"`
  3850. }
  3851. type ResultSixteen10265 struct {
  3852. Cainfo string `json:"cainfo"`
  3853. ErrMsg string `json:"err_msg"`
  3854. InfRefmsgid string `json:"inf_refmsgid"`
  3855. Infcode string `json:"infcode"`
  3856. Output struct {
  3857. Setldetail []interface{} `json:"setldetail"`
  3858. Setlinfo struct {
  3859. MdtrtID string `json:"mdtrt_id"`
  3860. SetlID string `json:"setl_id"`
  3861. ClrOptins string `json:"clr_optins"`
  3862. SetlTime string `json:"setl_time"`
  3863. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3864. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3865. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3866. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3867. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3868. ActPayDedc float64 `json:"act_pay_dedc"`
  3869. HifpPay float64 `json:"hifp_pay"`
  3870. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3871. Lfpay float64 `json:"selfpay"`
  3872. CvlservPay float64 `json:"cvlserv_pay"`
  3873. HifesPay float64 `json:"hifes_pay"`
  3874. HifmiPay float64 `json:"hifmi_pay"`
  3875. HifobPay float64 `json:"hifob_pay"`
  3876. MafPay float64 `json:"maf_pay"`
  3877. OthPay float64 `json:"oth_pay"`
  3878. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3879. PsnPartAmt float64 `json:"psn_part_amt"`
  3880. AcctPay float64 `json:"acct_pay"`
  3881. Balc float64 `json:"balc"`
  3882. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3883. HospPartAmt float64 `json:"hosp_part_amt"`
  3884. MedinsSetlID string `json:"medins_setl_id"`
  3885. PdnCashPay string `json:"pdn_cash_pay"`
  3886. } `json:"setlinfo"`
  3887. } `json:"output"`
  3888. RefmsgTime string `json:"refmsg_time"`
  3889. RespondTime string `json:"respond_time"`
  3890. Signtype interface{} `json:"signtype"`
  3891. WarnMsg interface{} `json:"warn_msg"`
  3892. }
  3893. type ResultSeventeen struct {
  3894. ErrMsg string `json:"err_msg"`
  3895. InfRefmsgid string `json:"inf_refmsgid"`
  3896. Infcode int64 `json:"infcode"`
  3897. Output struct {
  3898. SetlListId string `json:"setl_list_id"`
  3899. } `json:"output"`
  3900. RefmsgTime string `json:"refmsg_time"`
  3901. RespondTime string `json:"respond_time"`
  3902. Signtype string `json:"signtype"`
  3903. WarnInfo string `json:"warn_info"`
  3904. }
  3905. type Result90991 struct {
  3906. ErrMsg string `json:"err_msg"`
  3907. InfRefmsgid string `json:"inf_refmsgid"`
  3908. Infcode int64 `json:"infcode"`
  3909. Output struct {
  3910. Result struct {
  3911. PsnNo string `json:"psn_no"`
  3912. CardStat string `json:"card_stat"`
  3913. Certno string `json:"certno"`
  3914. PsnName string `json:"psn_name"`
  3915. CheckStat string `json:"check_stat"`
  3916. } `json:"result"`
  3917. } `json:"output"`
  3918. RefmsgTime string `json:"refmsg_time"`
  3919. RespondTime string `json:"respond_time"`
  3920. Signtype interface{} `json:"signtype"`
  3921. WarnInfo interface{} `json:"warn_info"`
  3922. }
  3923. type Result90100 struct {
  3924. ErrMsg string `json:"err_msg"`
  3925. InfRefmsgid string `json:"inf_refmsgid"`
  3926. Infcode int64 `json:"infcode"`
  3927. Output struct {
  3928. PoolareaNo string `json:"poolarea_no"`
  3929. PoolareaNoName string `json:"poolarea_no_name"`
  3930. Insutype string `json:"insutype"`
  3931. InsutypeName string `json:"insutype_name"`
  3932. ClctType string `json:"clct_type"`
  3933. ClctTypeName string `json:"clct_type_name"`
  3934. ClctFlag string `json:"clct_flag"`
  3935. ClctFlagName string `json:"clct_flag_name"`
  3936. AccrymBegn string `json:"accrym_begn"`
  3937. AccrymEnd string `json:"accrym_end"`
  3938. ClctTime string `json:"clct_time"`
  3939. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3940. } `json:"output"`
  3941. RefmsgTime string `json:"refmsg_time"`
  3942. RespondTime string `json:"respond_time"`
  3943. Signtype interface{} `json:"signtype"`
  3944. WarnInfo interface{} `json:"warn_info"`
  3945. }
  3946. type Custom struct {
  3947. DetItemFeeSumamt string
  3948. Cut string
  3949. FeedetlSn string
  3950. Price string
  3951. MedListCodg string
  3952. Type int64
  3953. AdviceId int64
  3954. ProjectId int64
  3955. ItemId int64
  3956. }
  3957. type Result5301 struct {
  3958. ErrMsg string `json:"err_msg"`
  3959. InfRefmsgid string `json:"inf_refmsgid"`
  3960. Infcode int64 `json:"infcode"`
  3961. Output struct {
  3962. Result []struct {
  3963. OpspDiseCode string `json:"opsp_dise_code"`
  3964. OpspDiseName string `json:"opsp_dise_name"`
  3965. Begndate string `json:"begndate"`
  3966. Enddate string `json:"enddate"`
  3967. } `json:"feedetail"`
  3968. } `json:"output"`
  3969. RefmsgTime string `json:"refmsg_time"`
  3970. RespondTime string `json:"respond_time"`
  3971. Signtype interface{} `json:"signtype"`
  3972. WarnInfo interface{} `json:"warn_info"`
  3973. }
  3974. type Result5301For10265 struct {
  3975. ErrMsg string `json:"err_msg"`
  3976. InfRefmsgid string `json:"inf_refmsgid"`
  3977. Infcode string `json:"infcode"`
  3978. Output struct {
  3979. Result []struct {
  3980. OpspDiseCode string `json:"opsp_dise_code"`
  3981. OpspDiseName string `json:"opsp_dise_name"`
  3982. Begndate string `json:"begndate"`
  3983. Enddate string `json:"enddate"`
  3984. } `json:"feedetail"`
  3985. } `json:"output"`
  3986. RefmsgTime string `json:"refmsg_time"`
  3987. RespondTime string `json:"respond_time"`
  3988. Signtype interface{} `json:"signtype"`
  3989. WarnInfo interface{} `json:"warn_info"`
  3990. }
  3991. //获取个人信息----挂号-----上传就诊信息
  3992. func (c *HisApiController) GetRegisterInfo() {
  3993. id, _ := c.GetInt64("id")
  3994. record_time := c.GetString("record_time")
  3995. settlementValue, _ := c.GetInt64("settlement_value")
  3996. medical_insurance_card := c.GetString("medical_insurance_card")
  3997. name := c.GetString("name")
  3998. id_card_type, _ := c.GetInt64("id_card_type")
  3999. certificates, _ := c.GetInt64("certificates")
  4000. medical_care, _ := c.GetInt64("medical_care")
  4001. birthday := c.GetString("birthday")
  4002. id_card := c.GetString("id_card")
  4003. register_type, _ := c.GetInt64("register")
  4004. doctor, _ := c.GetInt64("doctor")
  4005. department, _ := c.GetInt64("department")
  4006. gender, _ := c.GetInt64("sex")
  4007. registration_fee, _ := c.GetFloat("registration_fee")
  4008. medical_expenses, _ := c.GetFloat("medical_expenses")
  4009. social_type, _ := c.GetInt64("social_type")
  4010. med_type := c.GetString("social_type")
  4011. admin_user_id, _ := c.GetInt64("admin_user_id")
  4012. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4013. timeLayout := "2006-01-02"
  4014. loc, _ := time.LoadLocation("Local")
  4015. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4016. birthUnix := birthdays.Unix()
  4017. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4018. if err != nil {
  4019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4020. return
  4021. }
  4022. recordDateTime := theTime.Unix()
  4023. adminInfo := c.GetAdminUserInfo()
  4024. var patient service.Patients
  4025. if id == 0 {
  4026. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4027. } else {
  4028. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4029. }
  4030. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4031. if patientPrescription.ID == 0 {
  4032. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4033. }
  4034. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4035. if patient.ID == 0 {
  4036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4037. return
  4038. }
  4039. if len(patient.IdCardNo) == 0 {
  4040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4041. return
  4042. }
  4043. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4044. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4045. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4046. //就诊结算未完成,不能进行二次挂号
  4047. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4048. if len(his) >= 1 {
  4049. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4050. if len(his) >= 1 && order.ID == 0 {
  4051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4052. return
  4053. }
  4054. }
  4055. //var register_log string
  4056. if config.IsOpen == 1 {
  4057. var res ResultTwo
  4058. var res10265 ResultTwo10265
  4059. var PsnNo string
  4060. var PsnCertType string
  4061. var Certno string
  4062. var PsnName string
  4063. var Gend string
  4064. var Naty string
  4065. var Brdy string
  4066. var Age float64
  4067. var infoStr string
  4068. var idetinfoStr string
  4069. var infocode int64
  4070. var verify_number string
  4071. fmt.Println(verify_number)
  4072. if miConfig.MdtrtareaAdmvs == "421300" {
  4073. psn_info, _ := service.GetPsnByPatientId(id)
  4074. PsnNo = psn_info.PsnNo
  4075. PsnCertType = psn_info.PsnCertType
  4076. Certno = psn_info.Certno
  4077. PsnName = psn_info.PsnName
  4078. Gend = psn_info.Gend
  4079. Naty = psn_info.Naty
  4080. Brdy = psn_info.Brdy
  4081. Age = psn_info.Age
  4082. infoStr = psn_info.Insuinfo
  4083. idetinfoStr = psn_info.Idetinfo
  4084. infocode = 0
  4085. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4086. psn_info, _ := service.GetPsnByPatientId(id)
  4087. PsnNo = psn_info.PsnNo
  4088. PsnCertType = psn_info.PsnCertType
  4089. Certno = psn_info.Certno
  4090. PsnName = psn_info.PsnName
  4091. Gend = psn_info.Gend
  4092. Naty = psn_info.Naty
  4093. Brdy = psn_info.Brdy
  4094. Age = psn_info.Age
  4095. infoStr = psn_info.Insuinfo
  4096. idetinfoStr = psn_info.Idetinfo
  4097. infocode = 0
  4098. verify_number = psn_info.VerifyNumber
  4099. } else {
  4100. var result string
  4101. var requestLog string
  4102. if miConfig.UserOrgId == 10138 {
  4103. 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)
  4104. } else {
  4105. 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)
  4106. }
  4107. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4108. if miConfig.Code == "H15049901371" {
  4109. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4110. utils.ErrorLog("解析失败:%v", err)
  4111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4112. return
  4113. }
  4114. res.ErrMsg = res10265.ErrMsg
  4115. res.Output = res10265.Output
  4116. res.InfRefmsgid = res10265.InfRefmsgid
  4117. } else {
  4118. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4119. utils.ErrorLog("解析失败:%v", err)
  4120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4121. return
  4122. }
  4123. }
  4124. PsnNo = res.Output.Baseinfo.PsnNo
  4125. PsnCertType = res.Output.Baseinfo.PsnCertType
  4126. Certno = res.Output.Baseinfo.Certno
  4127. PsnName = res.Output.Baseinfo.PsnName
  4128. Gend = res.Output.Baseinfo.Gend
  4129. Naty = res.Output.Baseinfo.Naty
  4130. Brdy = res.Output.Baseinfo.Brdy
  4131. Age = res.Output.Baseinfo.Age
  4132. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4133. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4134. infoStr = string(Iinfos)
  4135. idetinfoStr = string(Idetinfos)
  4136. if miConfig.Code == "H15049901371" {
  4137. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4138. } else {
  4139. infocode = res.Infcode
  4140. }
  4141. }
  4142. if infocode == 0 {
  4143. his := models.VMHisPatient{
  4144. Name: name,
  4145. Gender: gender,
  4146. Birthday: birthUnix,
  4147. MedicalTreatmentType: medical_care,
  4148. IdType: certificates,
  4149. IdCardNo: id_card,
  4150. BalanceAccountsType: settlementValue,
  4151. SocialType: social_type,
  4152. MedicalInsuranceNumber: medical_insurance_card,
  4153. RegisterType: register_type,
  4154. RegisterCost: registration_fee,
  4155. TreatmentCost: medical_expenses,
  4156. Status: 1,
  4157. Ctime: time.Now().Unix(),
  4158. Mtime: time.Now().Unix(),
  4159. PsnNo: PsnNo,
  4160. PsnCertType: PsnCertType,
  4161. Certno: Certno,
  4162. PsnName: PsnName,
  4163. Gend: Gend,
  4164. Naty: Naty,
  4165. Brdy: Brdy,
  4166. Age: Age,
  4167. Iinfo: infoStr,
  4168. Idetinfo: idetinfoStr,
  4169. PatientId: patient.ID,
  4170. RecordDate: theTime.Unix(),
  4171. UserOrgId: adminInfo.CurrentOrgId,
  4172. AdminUserId: admin_user_id,
  4173. IsReturn: 1,
  4174. IdCardType: id_card_type,
  4175. Doctor: doctor,
  4176. Departments: department,
  4177. }
  4178. timestamp := time.Now().Unix()
  4179. tempTime := time.Unix(timestamp, 0)
  4180. timeFormat := tempTime.Format("20060102150405")
  4181. chrgBchno := rand.Intn(100000) + 10000
  4182. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4183. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4184. department, _ := service.GetDepartMentDetail(department)
  4185. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4186. IdCardNo := ""
  4187. if id_card_type == 1 {
  4188. // IdCardNo = medical_insurance_card
  4189. IdCardNo = patient.IdCardNo
  4190. } else {
  4191. IdCardNo = patient.IdCardNo
  4192. }
  4193. var rf []*ResultFive
  4194. json.Unmarshal([]byte(his.Iinfo), &rf)
  4195. var insutypes []*ResultFive
  4196. var insutype string
  4197. var insuplc_admdvs_temp string
  4198. var is390 int = 0
  4199. var is310 int = 0
  4200. for _, item := range rf {
  4201. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4202. insutypes = append(insutypes, item)
  4203. }
  4204. }
  4205. if len(insutypes) == 1 {
  4206. insutype = insutypes[0].Insutype
  4207. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4208. } else {
  4209. for _, i := range insutypes {
  4210. if i.Insutype == "390" {
  4211. is390 = 1
  4212. }
  4213. if i.Insutype == "310" {
  4214. is310 = 1
  4215. }
  4216. }
  4217. }
  4218. if is390 == 1 {
  4219. insutype = "390"
  4220. }
  4221. if is310 == 1 {
  4222. insutype = "310"
  4223. }
  4224. if len(insutypes) == 0 {
  4225. insutype = "310"
  4226. }
  4227. if len(insutypes) == 2 {
  4228. insutype = med_type
  4229. }
  4230. if len(med_type) > 0 {
  4231. insutype = med_type
  4232. }
  4233. //for _, item := range rf {
  4234. // if item.Insutype == insutype {
  4235. // insuplc_admdvs = item.InsuplcAdmdvs
  4236. // }
  4237. //}
  4238. var infocode int64
  4239. var resThree ResultThree
  4240. var resThree10265 ResultThree10265
  4241. if len(insuplc_admdvs) == 0 {
  4242. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4243. } else {
  4244. insuplc_admdvs_temp = insuplc_admdvs
  4245. }
  4246. if miConfig.MdtrtareaAdmvs == "421300" {
  4247. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4248. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4249. "&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
  4250. resp, requestErr := http.Get(api)
  4251. if requestErr != nil {
  4252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4253. return
  4254. }
  4255. body, ioErr := ioutil.ReadAll(resp.Body)
  4256. if ioErr != nil {
  4257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4259. return
  4260. }
  4261. var respJSON map[string]interface{}
  4262. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4265. return
  4266. }
  4267. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4268. result, _ := json.Marshal(respJSON)
  4269. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4270. utils.ErrorLog("解析失败:%v", err)
  4271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4272. return
  4273. }
  4274. infocode = resThree.Infcode
  4275. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4276. psn_info, _ := service.GetPsnByPatientId(id)
  4277. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4278. var cert_no string
  4279. if id_card_type == 3 {
  4280. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4281. cert_no = IdCardNo
  4282. } else {
  4283. bas := strings.Split(psn_info.CardInfo, "|")
  4284. cert_no = bas[2]
  4285. }
  4286. var api string
  4287. if miConfig.MdtrtareaAdmvs == "320921" {
  4288. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4289. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4290. "&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
  4291. } else {
  4292. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4293. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4294. "&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
  4295. }
  4296. resp, requestErr := http.Get(api)
  4297. if requestErr != nil {
  4298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4299. return
  4300. }
  4301. body, ioErr := ioutil.ReadAll(resp.Body)
  4302. if ioErr != nil {
  4303. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4305. return
  4306. }
  4307. var respJSON map[string]interface{}
  4308. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4311. return
  4312. }
  4313. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4314. result, _ := json.Marshal(respJSON)
  4315. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4316. utils.ErrorLog("解析失败:%v", err)
  4317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4318. return
  4319. }
  4320. resThree.ErrMsg = resThree10265.ErrMsg
  4321. resThree.Output = resThree10265.Output
  4322. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4323. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4324. } else {
  4325. 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)
  4326. saveLog(result, requestLog, "2201A", "挂号")
  4327. if miConfig.Code == "H15049901371" {
  4328. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4329. utils.ErrorLog("解析失败:%v", err)
  4330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4331. return
  4332. }
  4333. resThree.ErrMsg = resThree10265.ErrMsg
  4334. resThree.Output = resThree10265.Output
  4335. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4336. } else {
  4337. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4338. utils.ErrorLog("解析失败:%v", err)
  4339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4340. return
  4341. }
  4342. }
  4343. if miConfig.Code == "H15049901371" {
  4344. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4345. } else {
  4346. infocode = resThree.Infcode
  4347. }
  4348. }
  4349. if infocode != 0 {
  4350. adminUser := c.GetAdminUserInfo()
  4351. errlog := &models.HisOrderError{
  4352. UserOrgId: adminUser.CurrentOrgId,
  4353. Ctime: time.Now().Unix(),
  4354. Mtime: time.Now().Unix(),
  4355. ErrMsg: resThree.ErrMsg,
  4356. Status: 1,
  4357. PatientId: id,
  4358. RecordTime: recordDateTime,
  4359. Stage: 2,
  4360. }
  4361. service.CreateErrMsgLog(errlog)
  4362. c.ServeSuccessJSON(map[string]interface{}{
  4363. "failed_code": -10,
  4364. "msg": resThree.ErrMsg,
  4365. })
  4366. return
  4367. }
  4368. his.Number = resThree.Output.Data.MdtrtID
  4369. his.PsnNo = resThree.Output.Data.PsnNo
  4370. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4371. his.IdCardNo = patient.IdCardNo
  4372. his.PhoneNumber = patient.Phone
  4373. his.UserOrgId = adminInfo.CurrentOrgId
  4374. his.Insutype = insutype
  4375. his.Ctime = time.Now().Unix()
  4376. his.Mtime = time.Now().Unix()
  4377. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4378. his.Status = 1
  4379. service.UpdateHisPatientStatus(&his)
  4380. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4381. c.ServeSuccessJSON(map[string]interface{}{
  4382. "his_info": his,
  4383. })
  4384. } else {
  4385. adminUser := c.GetAdminUserInfo()
  4386. errlog := &models.HisOrderError{
  4387. UserOrgId: adminUser.CurrentOrgId,
  4388. Ctime: time.Now().Unix(),
  4389. Mtime: time.Now().Unix(),
  4390. ErrMsg: res.ErrMsg,
  4391. Status: 1,
  4392. PatientId: id,
  4393. RecordTime: recordDateTime,
  4394. Stage: 1,
  4395. }
  4396. service.CreateErrMsgLog(errlog)
  4397. c.ServeSuccessJSON(map[string]interface{}{
  4398. "failed_code": -10,
  4399. "msg": res.ErrMsg,
  4400. })
  4401. return
  4402. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4403. }
  4404. }
  4405. }
  4406. //上传明细----预结算----确认订单
  4407. func (c *HisApiController) GetUploadInfo() {
  4408. id, _ := c.GetInt64("id")
  4409. record_time := c.GetString("record_time")
  4410. his_patient_id, _ := c.GetInt64("his_patient_id")
  4411. order_id, _ := c.GetInt64("order_id")
  4412. pay_way, _ := c.GetInt64("pay_way")
  4413. pay_price, _ := c.GetFloat("pay_price")
  4414. pay_card_no := c.GetString("pay_card_no")
  4415. discount_price, _ := c.GetFloat("discount_price")
  4416. preferential_price, _ := c.GetFloat("preferential_price")
  4417. reality_price, _ := c.GetFloat("reality_price")
  4418. found_price, _ := c.GetFloat("found_price")
  4419. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4420. private_price, _ := c.GetFloat("private_price")
  4421. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4422. admin_user_id, _ := c.GetInt64("admin_user_id")
  4423. fapiao_code := c.GetString("fapiao_code")
  4424. fapiao_number := c.GetString("fapiao_number")
  4425. diagnosis_id := c.GetString("diagnosis")
  4426. sick_type, _ := c.GetInt64("sick_type")
  4427. reg_type, _ := c.GetInt64("p_type")
  4428. begin_time := c.GetString("begin_time")
  4429. id_str := c.GetString("ids")
  4430. ids_arr := strings.Split(id_str, ",")
  4431. timeLayout := "2006-01-02"
  4432. loc, _ := time.LoadLocation("Local")
  4433. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4434. if err != nil {
  4435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4436. return
  4437. }
  4438. recordDateTime := theTime.Unix()
  4439. adminUser := c.GetAdminUserInfo()
  4440. var tempOrder models.HisOrder
  4441. tempOrder, _ = service.GetHisOrderByID(order_id)
  4442. var prescriptions []*models.HisPrescription
  4443. var start_time int64
  4444. var end_time int64
  4445. //if adminUser.CurrentOrgId == 10106{
  4446. // if len(fapiao_code) == 0{
  4447. // fapiao_code = "144072080589"
  4448. // }
  4449. // if len(fapiao_number) == 0{
  4450. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4451. // if order.ID == 0{
  4452. // fapiao_number = "00001520"
  4453. // }else{
  4454. // //fapiao_code = "00001520"
  4455. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4456. // var zero string
  4457. // if fpNumber >= 1000{
  4458. // zero = "0000" + strconv.Itoa(fpNumber)
  4459. // }else if fpNumber >= 10000{
  4460. // zero = "000" + strconv.Itoa(fpNumber)
  4461. // } else if fpNumber >= 100000{
  4462. // zero = "00" + strconv.Itoa(fpNumber)
  4463. // } else if fpNumber >= 1000000{
  4464. // zero = "0" + strconv.Itoa(fpNumber)
  4465. // }else {
  4466. // zero = strconv.Itoa(fpNumber)
  4467. // }
  4468. // fapiao_number = zero
  4469. // }
  4470. // }
  4471. //}
  4472. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4473. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4474. var patientPrescription models.HisPrescriptionInfo
  4475. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4476. if patientPrescription.ID == 0 {
  4477. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4478. }
  4479. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4480. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4481. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4482. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4483. var config []*models.HisXtDiagnoseConfig
  4484. for _, item := range diagnosis_ids {
  4485. id, _ := strconv.ParseInt(item, 10, 64)
  4486. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4487. config = append(config, &diagnosisConfig)
  4488. }
  4489. sickConfig, _ := service.FindSickById(sick_type)
  4490. //if tempOrder.ID == 0 {
  4491. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4492. //}
  4493. if tempOrder.ID == 0 {
  4494. var result string
  4495. var requestLog string
  4496. var res2 ResultSix
  4497. var ressix10265 ResultSix10265
  4498. if miConfig.MdtrtareaAdmvs == "421300" {
  4499. data := make(map[string]interface{})
  4500. client := &http.Client{}
  4501. data["psn_no"] = his.PsnNo
  4502. data["mdtrt_id"] = his.Number
  4503. data["doctor"] = roles.UserName
  4504. data["department"] = department.Name
  4505. data["org_name"] = miConfig.OrgName
  4506. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4507. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4508. data["fixmedins_code"] = miConfig.Code
  4509. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4510. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4511. data["secret_key"] = miConfig.SecretKey
  4512. data["sick_code"] = sickConfig.CountryCode
  4513. data["sick_name"] = sickConfig.ClassName
  4514. data["dept"] = strconv.FormatInt(department.ID, 10)
  4515. data["config"] = config
  4516. data["begin_time"] = begin_time
  4517. bytesData, _ := json.Marshal(data)
  4518. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4519. resp, _ := client.Do(req)
  4520. defer resp.Body.Close()
  4521. body, ioErr := ioutil.ReadAll(resp.Body)
  4522. if ioErr != nil {
  4523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4525. return
  4526. }
  4527. var respJSON map[string]interface{}
  4528. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4531. return
  4532. }
  4533. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4534. userJSONBytes, _ := json.Marshal(respJSON)
  4535. fmt.Println("log")
  4536. fmt.Println(string(userJSONBytes))
  4537. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4538. utils.ErrorLog("解析失败:%v", err)
  4539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4540. return
  4541. }
  4542. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4543. //江苏地区国家医保医疗类别
  4544. //职工透析:医疗类别选特殊情况门诊9933
  4545. //居民血透门慢: 医疗类别选门诊慢病1402
  4546. //var med_type string
  4547. //if his.Insutype == "310" {
  4548. // if reg_type == 14 {
  4549. // med_type = "9933"
  4550. // } else if reg_type == 11 {
  4551. // med_type = "11"
  4552. //
  4553. // }
  4554. //} else if his.Insutype == "390" {
  4555. // if reg_type == 14 {
  4556. // med_type = "1402"
  4557. // } else if reg_type == 11 {
  4558. // med_type = "11"
  4559. // }
  4560. //}
  4561. data := make(map[string]interface{})
  4562. client := &http.Client{}
  4563. data["psn_no"] = his.PsnNo
  4564. data["mdtrt_id"] = his.Number
  4565. data["doctor"] = roles.UserName
  4566. data["department"] = department.Name
  4567. data["org_name"] = miConfig.OrgName
  4568. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4569. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4570. data["fixmedins_code"] = miConfig.Code
  4571. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4572. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4573. data["secret_key"] = miConfig.SecretKey
  4574. data["sick_code"] = sickConfig.CountryCode
  4575. data["sick_name"] = sickConfig.ClassName
  4576. data["url"] = miConfig.Url
  4577. data["ak"] = miConfig.AccessKey
  4578. data["begin_time"] = begin_time
  4579. data["cainfo"] = miConfig.Cainfo
  4580. data["dept"] = strconv.FormatInt(department.ID, 10)
  4581. data["config"] = config
  4582. bytesData, _ := json.Marshal(data)
  4583. var req *http.Request
  4584. if miConfig.MdtrtareaAdmvs == "320921" {
  4585. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4586. //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 +
  4587. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4588. } else {
  4589. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4590. }
  4591. resp, _ := client.Do(req)
  4592. defer resp.Body.Close()
  4593. body, ioErr := ioutil.ReadAll(resp.Body)
  4594. if ioErr != nil {
  4595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4597. return
  4598. }
  4599. var respJSON map[string]interface{}
  4600. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4603. return
  4604. }
  4605. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4606. userJSONBytes, _ := json.Marshal(respJSON)
  4607. fmt.Println("log")
  4608. fmt.Println(string(userJSONBytes))
  4609. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4610. utils.ErrorLog("解析失败:%v", err)
  4611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4612. return
  4613. }
  4614. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4615. res2.Output = ressix10265.Output
  4616. res2.ErrMsg = ressix10265.ErrMsg
  4617. res2.Cainfo = ressix10265.Cainfo
  4618. res2.WarnMsg = ressix10265.WarnMsg
  4619. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4620. res2.Infcode = infocode
  4621. } else {
  4622. if miConfig.MdtrtareaAdmvs == "440781" { //
  4623. 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)
  4624. } else {
  4625. if miConfig.Code == "H15049901371" {
  4626. //赤峰地区国家医保医疗类别
  4627. //职工透析:医疗类别选特殊情况门诊990502
  4628. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4629. var med_type string
  4630. if his.Insutype == "390" {
  4631. if reg_type == 14 {
  4632. med_type = "9933"
  4633. } else if reg_type == 11 {
  4634. med_type = "11"
  4635. }
  4636. } else if his.Insutype == "310" {
  4637. if reg_type == 14 {
  4638. med_type = "990502"
  4639. } else if reg_type == 11 {
  4640. med_type = "11"
  4641. }
  4642. }
  4643. 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)
  4644. } else {
  4645. 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)
  4646. }
  4647. }
  4648. saveLog(result, requestLog, "2203", "上传就诊信息")
  4649. var respJSON2 map[string]interface{}
  4650. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4653. return
  4654. }
  4655. userJSONBytes2, _ := json.Marshal(respJSON2)
  4656. if miConfig.Code == "H15049901371" {
  4657. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4658. utils.ErrorLog("解析失败:%v", err)
  4659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4660. return
  4661. }
  4662. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4663. res2.Output = ressix10265.Output
  4664. res2.ErrMsg = ressix10265.ErrMsg
  4665. res2.Cainfo = ressix10265.Cainfo
  4666. res2.WarnMsg = ressix10265.WarnMsg
  4667. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4668. res2.Infcode = infocode
  4669. } else {
  4670. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4671. utils.ErrorLog("解析失败:%v", err)
  4672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4673. return
  4674. }
  4675. }
  4676. }
  4677. if res2.Infcode != 0 {
  4678. adminUser := c.GetAdminUserInfo()
  4679. errlog := &models.HisOrderError{
  4680. UserOrgId: adminUser.CurrentOrgId,
  4681. Ctime: time.Now().Unix(),
  4682. Mtime: time.Now().Unix(),
  4683. ErrMsg: res2.ErrMsg,
  4684. Status: 1,
  4685. PatientId: id,
  4686. RecordTime: recordDateTime,
  4687. Stage: 3,
  4688. }
  4689. service.CreateErrMsgLog(errlog)
  4690. c.ServeSuccessJSON(map[string]interface{}{
  4691. "failed_code": -10,
  4692. "msg": res2.ErrMsg,
  4693. })
  4694. return
  4695. } else {
  4696. his.Diagnosis = diagnosis_id
  4697. his.SickType = sickConfig.ID
  4698. //var p_type int64
  4699. //if reg_type == 1111 || reg_type == 1112 {
  4700. // p_type = 11
  4701. //
  4702. //}
  4703. his.PType = fmt.Sprintf("%d", reg_type)
  4704. service.UpdateHisPatientThree(&his)
  4705. data := make(map[string]interface{})
  4706. if settle_accounts_type == 1 { //日结
  4707. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4708. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4709. } else {
  4710. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4711. }
  4712. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4713. data["pre"] = prescriptions
  4714. } else { //月结
  4715. start_time_str := c.GetString("start_time")
  4716. end_time_str := c.GetString("end_time")
  4717. timeLayout := "2006-01-02"
  4718. loc, _ := time.LoadLocation("Local")
  4719. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4720. if err != nil {
  4721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4722. return
  4723. }
  4724. recordStartTime := theStartTime.Unix()
  4725. start_time = recordStartTime
  4726. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4727. if err != nil {
  4728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4729. return
  4730. }
  4731. recordEndTime := theEndTime.Unix()
  4732. end_time = recordEndTime
  4733. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4734. data["pre"] = prescriptions
  4735. }
  4736. timestamp := time.Now().Unix()
  4737. tempTime := time.Unix(timestamp, 0)
  4738. timeFormat := tempTime.Format("20060102150405")
  4739. chrgBchno := rand.Intn(100000) + 10000
  4740. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4741. strconv.FormatInt(his.PatientId, 10)
  4742. client := &http.Client{}
  4743. data["psn_no"] = his.PsnNo
  4744. data["mdtrt_id"] = his.Number
  4745. data["chrg_bchno"] = chrg_bchno
  4746. data["org_name"] = miConfig.OrgName
  4747. data["doctor"] = roles.UserName
  4748. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4749. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4750. data["fixmedins_code"] = miConfig.Code
  4751. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4752. // data["dept_code"] = "15"
  4753. //} else {
  4754. data["dept_code"] = department.Number
  4755. //}
  4756. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4757. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4758. data["secret_key"] = miConfig.SecretKey
  4759. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4760. data["url"] = miConfig.Url
  4761. data["ak"] = miConfig.AccessKey
  4762. data["new_doctor_name"] = patientPrescription.Doctor
  4763. data["diag_code"] = sickConfig.CountryCode
  4764. data["cainfo"] = miConfig.Cainfo
  4765. var ids []int64
  4766. for _, item := range prescriptions {
  4767. ids = append(ids, item.ID)
  4768. }
  4769. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4770. if config.IsOpen == 1 { //对接了医保,走医保流程
  4771. var res ResultFour
  4772. var resFour10265 ResultFour10265
  4773. if miConfig.MdtrtareaAdmvs == "421300" {
  4774. bytesData, _ := json.Marshal(data)
  4775. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4776. resp, _ := client.Do(req)
  4777. defer resp.Body.Close()
  4778. body, ioErr := ioutil.ReadAll(resp.Body)
  4779. if ioErr != nil {
  4780. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4782. return
  4783. }
  4784. var respJSON map[string]interface{}
  4785. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4788. return
  4789. }
  4790. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4791. userJSONBytes, _ := json.Marshal(respJSON)
  4792. fmt.Println("log")
  4793. fmt.Println(string(userJSONBytes))
  4794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4795. utils.ErrorLog("解析失败:%v", err)
  4796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4797. return
  4798. }
  4799. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4800. bytesData, _ := json.Marshal(data)
  4801. var req *http.Request
  4802. if miConfig.MdtrtareaAdmvs == "320921" {
  4803. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4804. } else {
  4805. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4806. }
  4807. resp, _ := client.Do(req)
  4808. defer resp.Body.Close()
  4809. body, ioErr := ioutil.ReadAll(resp.Body)
  4810. if ioErr != nil {
  4811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4813. return
  4814. }
  4815. var respJSON map[string]interface{}
  4816. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4819. return
  4820. }
  4821. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4822. userJSONBytes, _ := json.Marshal(respJSON)
  4823. fmt.Println("log")
  4824. fmt.Println(string(userJSONBytes))
  4825. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4826. utils.ErrorLog("解析失败:%v", err)
  4827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4828. return
  4829. }
  4830. res.InfRefmsgid = resFour10265.InfRefmsgid
  4831. res.Output = resFour10265.Output
  4832. res.ErrMsg = resFour10265.ErrMsg
  4833. res.Cainfo = resFour10265.Cainfo
  4834. res.WarnMsg = resFour10265.WarnMsg
  4835. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4836. res.Infcode = infocode
  4837. } else {
  4838. if miConfig.Code == "H15049901371" {
  4839. 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)
  4840. var dat map[string]interface{}
  4841. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4842. fmt.Println(dat)
  4843. } else {
  4844. fmt.Println(err)
  4845. }
  4846. saveLog(result, request_log, "2204", "上传费用明细")
  4847. userJSONBytes, _ := json.Marshal(dat)
  4848. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4849. utils.ErrorLog("解析失败:%v", err)
  4850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4851. return
  4852. }
  4853. res.InfRefmsgid = resFour10265.InfRefmsgid
  4854. res.Output = resFour10265.Output
  4855. res.ErrMsg = resFour10265.ErrMsg
  4856. res.Cainfo = resFour10265.Cainfo
  4857. res.WarnMsg = resFour10265.WarnMsg
  4858. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4859. res.Infcode = infocode
  4860. } else {
  4861. 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)
  4862. var dat map[string]interface{}
  4863. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4864. fmt.Println(dat)
  4865. } else {
  4866. fmt.Println(err)
  4867. }
  4868. saveLog(result, request_log, "2204", "上传费用明细")
  4869. userJSONBytes, _ := json.Marshal(dat)
  4870. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4871. utils.ErrorLog("解析失败:%v", err)
  4872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4873. return
  4874. }
  4875. }
  4876. }
  4877. if res.Infcode == 0 {
  4878. order := &models.HisOrder{
  4879. UserOrgId: adminUser.CurrentOrgId,
  4880. HisPatientId: his.ID,
  4881. PatientId: his.PatientId,
  4882. SettleAccountsDate: recordDateTime,
  4883. MdtrtId: his.Number,
  4884. PsnNo: his.PsnNo,
  4885. MedType: strconv.FormatInt(reg_type, 10),
  4886. Ctime: time.Now().Unix(),
  4887. Mtime: time.Now().Unix(),
  4888. Status: 1,
  4889. Number: chrg_bchno,
  4890. Infcode: res.Infcode,
  4891. WarnMsg: res.WarnMsg,
  4892. Cainfo: res.Cainfo,
  4893. ErrMsg: res.ErrMsg,
  4894. RespondTime: res.RefmsgTime,
  4895. InfRefmsgid: res.InfRefmsgid,
  4896. OrderStatus: 1,
  4897. PayWay: pay_way,
  4898. PayPrice: pay_price,
  4899. PayCardNo: pay_card_no,
  4900. DiscountPrice: discount_price,
  4901. PreferentialPrice: preferential_price,
  4902. RealityPrice: reality_price,
  4903. FoundPrice: found_price,
  4904. MedicalInsurancePrice: medical_insurance_price,
  4905. PrivatePrice: private_price,
  4906. IsMedicineInsurance: 1,
  4907. SettleType: settle_accounts_type,
  4908. SettleStartTime: start_time,
  4909. SettleEndTime: end_time,
  4910. Creator: roles.AdminUserId,
  4911. Modify: roles.AdminUserId,
  4912. FaPiaoNumber: fapiao_number,
  4913. FaPiaoCode: fapiao_code,
  4914. PType: 2,
  4915. Diagnosis: diagnosis_id,
  4916. }
  4917. err = service.CreateOrder(order)
  4918. if err != nil {
  4919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4920. return
  4921. }
  4922. for _, item := range res.Output.Result {
  4923. temp := strings.Split(item.FeedetlSn, "-")
  4924. var advice_id int64 = 0
  4925. var project_id int64 = 0
  4926. var types int64 = 0
  4927. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4928. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4929. if temp[1] == "1" {
  4930. advice_id = id
  4931. project_id = 0
  4932. } else if temp[1] == "2" {
  4933. advice_id = 0
  4934. project_id = id
  4935. }
  4936. info := &models.HisOrderInfo{
  4937. OrderNumber: order.Number,
  4938. FeedetlSn: item.FeedetlSn,
  4939. UploadDate: time.Now().Unix(),
  4940. AdviceId: advice_id,
  4941. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4942. Cnt: item.Cnt,
  4943. Pric: float64(item.Pric),
  4944. PatientId: his.PatientId,
  4945. PricUplmtAmt: item.PricUplmtAmt,
  4946. SelfpayProp: item.SelfpayProp,
  4947. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4948. OverlmtAmt: item.OverlmtAmt,
  4949. PreselfpayAmt: item.PreselfpayAmt,
  4950. BasMednFlag: item.BasMednFlag,
  4951. MedChrgitmType: item.MedChrgitmType,
  4952. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4953. Status: 1,
  4954. Memo: item.Memo,
  4955. Mtime: time.Now().Unix(),
  4956. InscpScpAmt: item.InscpScpAmt,
  4957. DrtReimFlag: item.DrtReimFlag,
  4958. Ctime: time.Now().Unix(),
  4959. ListSpItemFlag: item.ListSpItemFlag,
  4960. ChldMedcFlag: item.ChldMedcFlag,
  4961. LmtUsedFlag: item.LmtUsedFlag,
  4962. ChrgitmLv: item.ChrgitmLv,
  4963. UserOrgId: adminUser.CurrentOrgId,
  4964. HisPatientId: his.ID,
  4965. OrderId: order.ID,
  4966. ProjectId: project_id,
  4967. Type: types,
  4968. }
  4969. service.CreateOrderInfo(info)
  4970. }
  4971. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4972. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4973. var total float64
  4974. for _, item := range prescriptions {
  4975. if item.Type == 1 { //药品
  4976. for _, subItem := range item.HisDoctorAdviceInfo {
  4977. total = total + (subItem.Price * subItem.PrescribingNumber)
  4978. }
  4979. }
  4980. if item.Type == 2 { //项目
  4981. for _, subItem := range item.HisPrescriptionProject {
  4982. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4983. total = total + (subItem.Price * cnt)
  4984. }
  4985. }
  4986. }
  4987. for _, item := range prescriptions {
  4988. for _, subItem := range item.HisAdditionalCharge {
  4989. total = total + (subItem.Price * float64(subItem.Count))
  4990. }
  4991. }
  4992. var allTotal string
  4993. if adminUser.CurrentOrgId == 9919 {
  4994. allTotal = fmt.Sprintf("%.4f", total)
  4995. } else {
  4996. allTotal = fmt.Sprintf("%.4f", total)
  4997. }
  4998. if res.Infcode == 0 {
  4999. var rf []*ResultFive
  5000. json.Unmarshal([]byte(his.Iinfo), &rf)
  5001. chrg_bchno := chrg_bchno
  5002. cert_no := his.Certno
  5003. var insutypes []string
  5004. var insutype string
  5005. var is390 int = 0
  5006. var is310 int = 0
  5007. for _, item := range rf {
  5008. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5009. insutypes = append(insutypes, item.Insutype)
  5010. }
  5011. }
  5012. if len(insutypes) == 1 {
  5013. insutype = insutypes[0]
  5014. } else {
  5015. for _, i := range insutypes {
  5016. if i == "390" {
  5017. is390 = 1
  5018. }
  5019. if i == "310" {
  5020. is310 = 1
  5021. }
  5022. }
  5023. }
  5024. if is390 == 1 {
  5025. insutype = "390"
  5026. }
  5027. if is310 == 1 {
  5028. insutype = "310"
  5029. }
  5030. if len(insutypes) == 0 {
  5031. insutype = "310"
  5032. }
  5033. if len(insutypes) == 2 {
  5034. insutype = strconv.FormatInt(his.SocialType, 10)
  5035. }
  5036. insutype = strconv.FormatInt(his.SocialType, 10)
  5037. //insutype = "390"
  5038. if his.IdCardType == 1 {
  5039. // cert_no = his.MedicalInsuranceNumber
  5040. cert_no = his.Certno
  5041. } else {
  5042. cert_no = his.Certno
  5043. }
  5044. var res ResultSeven
  5045. var resSeven10265 ResultSeven10265
  5046. var src_resquest string
  5047. var result2 string
  5048. var acct_used_flag string
  5049. fmt.Println("pay_way")
  5050. fmt.Println(pay_way)
  5051. fmt.Println("pay_way")
  5052. if pay_way == 4 {
  5053. acct_used_flag = "1"
  5054. } else {
  5055. acct_used_flag = "0"
  5056. }
  5057. if miConfig.MdtrtareaAdmvs == "421300" {
  5058. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5059. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5060. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5061. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5062. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5063. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5064. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5065. resp, requestErr := http.Get(api)
  5066. if requestErr != nil {
  5067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5068. return
  5069. }
  5070. body, ioErr := ioutil.ReadAll(resp.Body)
  5071. if ioErr != nil {
  5072. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5074. return
  5075. }
  5076. var respJSON map[string]interface{}
  5077. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5078. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5080. return
  5081. }
  5082. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5083. result, _ := json.Marshal(respJSON)
  5084. if miConfig.Code == "H15049901371" {
  5085. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5086. utils.ErrorLog("解析失败:%v", err)
  5087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5088. return
  5089. }
  5090. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5091. res.Output = resSeven10265.Output
  5092. res.ErrMsg = resSeven10265.ErrMsg
  5093. res.Cainfo = resSeven10265.Cainfo
  5094. res.WarnMsg = resSeven10265.WarnMsg
  5095. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5096. res.Infcode = infocode
  5097. } else {
  5098. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5099. utils.ErrorLog("解析失败:%v", err)
  5100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5101. return
  5102. }
  5103. }
  5104. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5105. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5106. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5107. //psn_info, _ := service.GetPsnByPatientId(id)
  5108. bas := strings.Split(psn_info.CardInfo, "|")
  5109. if his.IdCardType == 1 {
  5110. cert_no = bas[2]
  5111. } else if his.IdCardType == 3 {
  5112. cert_no = his.Certno
  5113. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5114. } else {
  5115. cert_no = bas[1]
  5116. }
  5117. //江苏地区国家医保医疗类别
  5118. //职工透析:医疗类别选特殊情况门诊9933
  5119. //居民血透门慢: 医疗类别选门诊慢病1402
  5120. //var med_type string
  5121. //if his.Insutype == "310" {
  5122. // if reg_type == 14 {
  5123. // med_type = "9933"
  5124. // } else if reg_type == 11 {
  5125. // med_type = "11"
  5126. //
  5127. // }
  5128. //} else if his.Insutype == "390" {
  5129. // if reg_type == 14 {
  5130. // med_type = "1402"
  5131. // } else if reg_type == 11 {
  5132. // med_type = "11"
  5133. // }
  5134. //}
  5135. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5136. var api string
  5137. if miConfig.MdtrtareaAdmvs == "320921" {
  5138. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5139. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5140. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5141. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5142. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5143. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5144. "&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
  5145. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5146. } else {
  5147. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5148. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5149. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5150. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5151. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5152. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5153. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5154. "&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
  5155. }
  5156. resp, requestErr := http.Get(api)
  5157. if requestErr != nil {
  5158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5159. return
  5160. }
  5161. body, ioErr := ioutil.ReadAll(resp.Body)
  5162. if ioErr != nil {
  5163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5165. return
  5166. }
  5167. var respJSON map[string]interface{}
  5168. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5171. return
  5172. }
  5173. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5174. result, _ := json.Marshal(respJSON)
  5175. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5176. utils.ErrorLog("解析失败:%v", err)
  5177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5178. return
  5179. }
  5180. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5181. res.Output = resSeven10265.Output
  5182. res.ErrMsg = resSeven10265.ErrMsg
  5183. res.Cainfo = resSeven10265.Cainfo
  5184. res.WarnMsg = resSeven10265.WarnMsg
  5185. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5186. res.Infcode = infocode
  5187. } else {
  5188. if miConfig.Code == "H15049901371" {
  5189. //赤峰地区国家医保医疗类别
  5190. //职工透析:医疗类别选特殊情况门诊990502
  5191. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5192. var med_type string
  5193. if his.Insutype == "390" {
  5194. if reg_type == 14 {
  5195. med_type = "9933"
  5196. } else if reg_type == 11 {
  5197. med_type = "11"
  5198. }
  5199. } else if his.Insutype == "310" {
  5200. if reg_type == 14 {
  5201. med_type = "990502"
  5202. } else if reg_type == 11 {
  5203. med_type = "11"
  5204. }
  5205. }
  5206. 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)
  5207. } else {
  5208. 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)
  5209. }
  5210. //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)
  5211. var dat map[string]interface{}
  5212. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5213. fmt.Println(dat)
  5214. } else {
  5215. fmt.Println(err)
  5216. }
  5217. saveLog(result2, src_resquest, "2207", "结算")
  5218. userJSONBytes, _ := json.Marshal(dat)
  5219. if miConfig.Code == "H15049901371" {
  5220. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5221. utils.ErrorLog("解析失败:%v", err)
  5222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5223. return
  5224. }
  5225. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5226. res.Output = resSeven10265.Output
  5227. res.ErrMsg = resSeven10265.ErrMsg
  5228. res.Cainfo = resSeven10265.Cainfo
  5229. res.WarnMsg = resSeven10265.WarnMsg
  5230. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5231. res.Infcode = infocode
  5232. } else {
  5233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5234. utils.ErrorLog("解析失败:%v", err)
  5235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5236. return
  5237. }
  5238. }
  5239. }
  5240. if res.Infcode != 0 {
  5241. errlog := &models.HisOrderError{
  5242. UserOrgId: adminUser.CurrentOrgId,
  5243. Ctime: time.Now().Unix(),
  5244. Mtime: time.Now().Unix(),
  5245. Number: chrg_bchno,
  5246. ErrMsg: res.ErrMsg,
  5247. Status: 1,
  5248. PatientId: id,
  5249. RecordTime: recordDateTime,
  5250. Stage: 6,
  5251. }
  5252. service.CreateErrMsgLog(errlog)
  5253. c.ServeSuccessJSON(map[string]interface{}{
  5254. "failed_code": -10,
  5255. "msg": res.ErrMsg,
  5256. })
  5257. return
  5258. } else {
  5259. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5260. order.OrderStatus = 2
  5261. order.Status = 1
  5262. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5263. order.SetlId = res.Output.Setlinfo.SetlID
  5264. order.PsnNo = res.Output.Setlinfo.PsnNo
  5265. order.PsnName = res.Output.Setlinfo.PsnName
  5266. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5267. order.Certno = res.Output.Setlinfo.Certno
  5268. order.Gend = res.Output.Setlinfo.Gend
  5269. order.Naty = res.Output.Setlinfo.Naty
  5270. order.Age = res.Output.Setlinfo.Age
  5271. order.Insutype = res.Output.Setlinfo.Insutype
  5272. order.PsnType = res.Output.Setlinfo.PsnType
  5273. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5274. order.SetlTime = res.Output.Setlinfo.SetlTime
  5275. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5276. if res.Output.Setlinfo.MedType == "140101" {
  5277. order.MedType = "14"
  5278. } else {
  5279. order.MedType = res.Output.Setlinfo.MedType
  5280. }
  5281. if reg_type == 1112 {
  5282. order.MedType = "1112"
  5283. }
  5284. if reg_type == 1111 {
  5285. order.MedType = "1111"
  5286. }
  5287. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5288. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5289. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5290. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5291. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5292. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5293. order.HifpPay = res.Output.Setlinfo.HifpPay
  5294. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5295. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5296. order.HifesPay = res.Output.Setlinfo.HifesPay
  5297. order.HifobPay = res.Output.Setlinfo.HifobPay
  5298. order.MafPay = res.Output.Setlinfo.MafPay
  5299. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5300. order.OthPay = res.Output.Setlinfo.OthPay
  5301. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5302. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5303. order.AcctPay = res.Output.Setlinfo.AcctPay
  5304. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5305. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5306. order.Balc = res.Output.Setlinfo.Balc
  5307. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5308. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5309. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5310. order.ClrType = res.Output.Setlinfo.ClrType
  5311. order.ClrWay = res.Output.Setlinfo.ClrWay
  5312. order.Creator = order.Creator
  5313. order.Modify = roles.AdminUserId
  5314. order.RequestLog = src_resquest
  5315. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5316. detailStr := string(setlDetail)
  5317. order.SetlDetail = detailStr
  5318. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5319. err = service.UpDateOrder(order)
  5320. if err == nil {
  5321. c.ServeSuccessJSON(map[string]interface{}{
  5322. "msg": "结算成功",
  5323. })
  5324. } else {
  5325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5326. return
  5327. }
  5328. }
  5329. } else {
  5330. adminUser := c.GetAdminUserInfo()
  5331. errlog := &models.HisOrderError{
  5332. UserOrgId: adminUser.CurrentOrgId,
  5333. Ctime: time.Now().Unix(),
  5334. Mtime: time.Now().Unix(),
  5335. ErrMsg: res.ErrMsg,
  5336. Status: 1,
  5337. PatientId: id,
  5338. RecordTime: recordDateTime,
  5339. Stage: 4,
  5340. }
  5341. service.CreateErrMsgLog(errlog)
  5342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5343. return
  5344. }
  5345. } else {
  5346. adminUser := c.GetAdminUserInfo()
  5347. errlog := &models.HisOrderError{
  5348. UserOrgId: adminUser.CurrentOrgId,
  5349. Ctime: time.Now().Unix(),
  5350. Mtime: time.Now().Unix(),
  5351. ErrMsg: res.ErrMsg,
  5352. Status: 1,
  5353. PatientId: id,
  5354. RecordTime: recordDateTime,
  5355. Stage: 4,
  5356. }
  5357. service.CreateErrMsgLog(errlog)
  5358. c.ServeSuccessJSON(map[string]interface{}{
  5359. "failed_code": -10,
  5360. "msg": res.ErrMsg,
  5361. })
  5362. return
  5363. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5364. //return
  5365. }
  5366. }
  5367. }
  5368. } else if tempOrder.ID > 0 {
  5369. if tempOrder.IsPre == 1 {
  5370. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5371. var rf []*ResultFive
  5372. json.Unmarshal([]byte(his.Iinfo), &rf)
  5373. chrg_bchno := tempOrder.Number
  5374. cert_no := his.Certno
  5375. var insutypes []string
  5376. var insutype string
  5377. var is390 int = 0
  5378. var is310 int = 0
  5379. for _, item := range rf {
  5380. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5381. insutypes = append(insutypes, item.Insutype)
  5382. }
  5383. }
  5384. if len(insutypes) == 1 {
  5385. insutype = insutypes[0]
  5386. } else {
  5387. for _, i := range insutypes {
  5388. if i == "390" {
  5389. is390 = 1
  5390. }
  5391. if i == "310" {
  5392. is310 = 1
  5393. }
  5394. }
  5395. }
  5396. if is390 == 1 {
  5397. insutype = "390"
  5398. }
  5399. if is310 == 1 {
  5400. insutype = "310"
  5401. }
  5402. if len(insutypes) == 0 {
  5403. insutype = "310"
  5404. }
  5405. if len(insutypes) == 2 {
  5406. insutype = strconv.FormatInt(his.SocialType, 64)
  5407. }
  5408. //insutype = "390"
  5409. if his.IdCardType == 1 {
  5410. // cert_no = his.MedicalInsuranceNumber
  5411. cert_no = his.Certno
  5412. } else {
  5413. cert_no = his.Certno
  5414. }
  5415. var res ResultSeven
  5416. var resSeven10265 ResultSeven10265
  5417. var src_resquest string
  5418. var result2 string
  5419. var acct_used_flag string
  5420. fmt.Println("pay_way")
  5421. fmt.Println(pay_way)
  5422. fmt.Println("pay_way")
  5423. if pay_way == 4 {
  5424. acct_used_flag = "1"
  5425. } else {
  5426. acct_used_flag = "0"
  5427. }
  5428. if miConfig.MdtrtareaAdmvs == "421300" {
  5429. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5430. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5431. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5432. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5433. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5434. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5435. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5436. resp, requestErr := http.Get(api)
  5437. if requestErr != nil {
  5438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5439. return
  5440. }
  5441. body, ioErr := ioutil.ReadAll(resp.Body)
  5442. if ioErr != nil {
  5443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5445. return
  5446. }
  5447. var respJSON map[string]interface{}
  5448. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5451. return
  5452. }
  5453. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5454. result, _ := json.Marshal(respJSON)
  5455. fmt.Println("log")
  5456. fmt.Println(string(result))
  5457. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5458. utils.ErrorLog("解析失败:%v", err)
  5459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5460. return
  5461. }
  5462. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5463. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5464. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5465. //psn_info, _ := service.GetPsnByPatientId(id)
  5466. bas := strings.Split(psn_info.CardInfo, "|")
  5467. if his.IdCardType == 1 {
  5468. cert_no = bas[2]
  5469. } else {
  5470. cert_no = bas[1]
  5471. }
  5472. //江苏地区国家医保医疗类别
  5473. //职工透析:医疗类别选特殊情况门诊9933
  5474. //居民血透门慢: 医疗类别选门诊慢病1402
  5475. //var med_type string
  5476. //if his.Insutype == "310" {
  5477. // if reg_type == 14 {
  5478. // med_type = "9933"
  5479. // } else if reg_type == 11 {
  5480. // med_type = "11"
  5481. //
  5482. // }
  5483. //} else if his.Insutype == "390" {
  5484. // if reg_type == 14 {
  5485. // med_type = "1402"
  5486. // } else if reg_type == 11 {
  5487. // med_type = "11"
  5488. // }
  5489. //}
  5490. var api string
  5491. if miConfig.MdtrtareaAdmvs == "320921" {
  5492. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5493. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5494. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5495. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5496. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5497. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5498. "&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
  5499. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5500. } else {
  5501. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5502. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5503. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5504. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5505. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5506. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5507. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5508. "&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
  5509. }
  5510. resp, requestErr := http.Get(api)
  5511. if requestErr != nil {
  5512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5513. return
  5514. }
  5515. body, ioErr := ioutil.ReadAll(resp.Body)
  5516. if ioErr != nil {
  5517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5519. return
  5520. }
  5521. var respJSON map[string]interface{}
  5522. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5525. return
  5526. }
  5527. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5528. result, _ := json.Marshal(respJSON)
  5529. fmt.Println("log")
  5530. fmt.Println(string(result))
  5531. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5532. utils.ErrorLog("解析失败:%v", err)
  5533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5534. return
  5535. }
  5536. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5537. res.Output = resSeven10265.Output
  5538. res.ErrMsg = resSeven10265.ErrMsg
  5539. res.Cainfo = resSeven10265.Cainfo
  5540. res.WarnMsg = resSeven10265.WarnMsg
  5541. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5542. res.Infcode = infocode
  5543. } else {
  5544. var src_resquest string
  5545. if miConfig.Code == "H15049901371" {
  5546. //赤峰地区国家医保医疗类别
  5547. //职工透析:医疗类别选特殊情况门诊990502
  5548. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5549. var med_type string
  5550. if his.Insutype == "390" {
  5551. if reg_type == 14 {
  5552. med_type = "9933"
  5553. } else if reg_type == 11 {
  5554. med_type = "11"
  5555. }
  5556. } else if his.Insutype == "310" {
  5557. if reg_type == 14 {
  5558. med_type = "990502"
  5559. } else if reg_type == 11 {
  5560. med_type = "11"
  5561. }
  5562. }
  5563. 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)
  5564. } else {
  5565. 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)
  5566. }
  5567. var dat map[string]interface{}
  5568. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5569. fmt.Println(dat)
  5570. } else {
  5571. fmt.Println(err)
  5572. }
  5573. saveLog(result2, src_resquest, "2207", "结算")
  5574. userJSONBytes, _ := json.Marshal(dat)
  5575. if miConfig.Code == "H15049901371" {
  5576. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5577. utils.ErrorLog("解析失败:%v", err)
  5578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5579. return
  5580. }
  5581. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5582. res.Output = resSeven10265.Output
  5583. res.ErrMsg = resSeven10265.ErrMsg
  5584. res.Cainfo = resSeven10265.Cainfo
  5585. res.WarnMsg = resSeven10265.WarnMsg
  5586. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5587. res.Infcode = infocode
  5588. } else {
  5589. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5590. utils.ErrorLog("解析失败:%v", err)
  5591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5592. return
  5593. }
  5594. }
  5595. }
  5596. if res.Infcode != 0 {
  5597. errlog := &models.HisOrderError{
  5598. UserOrgId: adminUser.CurrentOrgId,
  5599. Ctime: time.Now().Unix(),
  5600. Mtime: time.Now().Unix(),
  5601. Number: chrg_bchno,
  5602. ErrMsg: res.ErrMsg,
  5603. Status: 1,
  5604. PatientId: id,
  5605. RecordTime: recordDateTime,
  5606. Stage: 6,
  5607. }
  5608. service.CreateErrMsgLog(errlog)
  5609. c.ServeSuccessJSON(map[string]interface{}{
  5610. "failed_code": -10,
  5611. "msg": res.ErrMsg,
  5612. })
  5613. return
  5614. } else {
  5615. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5616. order.OrderStatus = 2
  5617. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5618. order.SetlId = res.Output.Setlinfo.SetlID
  5619. order.PsnNo = res.Output.Setlinfo.PsnNo
  5620. order.PsnName = res.Output.Setlinfo.PsnName
  5621. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5622. order.Certno = res.Output.Setlinfo.Certno
  5623. order.Gend = res.Output.Setlinfo.Gend
  5624. order.Naty = res.Output.Setlinfo.Naty
  5625. order.Age = res.Output.Setlinfo.Age
  5626. order.Insutype = res.Output.Setlinfo.Insutype
  5627. order.PsnType = res.Output.Setlinfo.PsnType
  5628. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5629. order.SetlTime = res.Output.Setlinfo.SetlTime
  5630. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5631. //order.MedType = res.Output.Setlinfo.MedType
  5632. if reg_type == 1112 {
  5633. order.MedType = "1112"
  5634. }
  5635. if reg_type == 1111 {
  5636. order.MedType = "1111"
  5637. }
  5638. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5639. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5640. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5641. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5642. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5643. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5644. order.HifpPay = res.Output.Setlinfo.HifpPay
  5645. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5646. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5647. order.HifesPay = res.Output.Setlinfo.HifesPay
  5648. order.HifobPay = res.Output.Setlinfo.HifobPay
  5649. order.MafPay = res.Output.Setlinfo.MafPay
  5650. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5651. order.OthPay = res.Output.Setlinfo.OthPay
  5652. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5653. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5654. order.AcctPay = res.Output.Setlinfo.AcctPay
  5655. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5656. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5657. order.Balc = res.Output.Setlinfo.Balc
  5658. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5659. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5660. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5661. order.ClrWay = res.Output.Setlinfo.ClrWay
  5662. order.Creator = order.Creator
  5663. order.Modify = roles.AdminUserId
  5664. order.RequestLog = src_resquest
  5665. order.Diagnosis = diagnosis_id
  5666. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5667. detailStr := string(setlDetail)
  5668. order.SetlDetail = detailStr
  5669. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5670. err = service.UpDateOrder(order)
  5671. if err == nil {
  5672. c.ServeSuccessJSON(map[string]interface{}{
  5673. "msg": "结算成功",
  5674. })
  5675. } else {
  5676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5677. return
  5678. }
  5679. }
  5680. }
  5681. }
  5682. }
  5683. //func (c *HisApiController) GetPreUploadInfo() {
  5684. // id, _ := c.GetInt64("id")
  5685. // record_time := c.GetString("record_time")
  5686. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5687. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5688. //
  5689. // timeLayout := "2006-01-02"
  5690. // loc, _ := time.LoadLocation("Local")
  5691. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5692. // if err != nil {
  5693. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5694. // return
  5695. // }
  5696. // recordDateTime := theTime.Unix()
  5697. // adminUser := c.GetAdminUserInfo()
  5698. //
  5699. // var prescriptions []*models.HisPrescription
  5700. //
  5701. // var start_time int64
  5702. // var end_time int64
  5703. //
  5704. // data := make(map[string]interface{})
  5705. // if settle_accounts_type == 1 { //日结
  5706. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5707. // data["pre"] = prescriptions
  5708. //
  5709. // } else { //月结
  5710. // start_time_str := c.GetString("start_time")
  5711. // end_time_str := c.GetString("end_time")
  5712. // timeLayout := "2006-01-02"
  5713. // loc, _ := time.LoadLocation("Local")
  5714. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5715. // if err != nil {
  5716. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5717. // return
  5718. // }
  5719. // recordStartTime := theStartTime.Unix()
  5720. // start_time = recordStartTime
  5721. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5722. // if err != nil {
  5723. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5724. // return
  5725. // }
  5726. // recordEndTime := theEndTime.Unix()
  5727. // end_time = recordEndTime
  5728. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5729. // data["pre"] = prescriptions
  5730. //
  5731. // }
  5732. //
  5733. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5734. //
  5735. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5736. // timestamp := time.Now().Unix()
  5737. // tempTime := time.Unix(timestamp, 0)
  5738. // timeFormat := tempTime.Format("20060102150405")
  5739. // chrgBchno := rand.Intn(100000) + 10000
  5740. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5741. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5742. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5743. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5744. // strconv.FormatInt(his.PatientId, 10)
  5745. // client := &http.Client{}
  5746. // data["psn_no"] = his.PsnNo
  5747. // data["mdtrt_id"] = his.Number
  5748. // data["chrg_bchno"] = chrg_bchno
  5749. // data["org_name"] = miConfig.OrgName
  5750. // data["doctor"] = roles.UserName
  5751. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5752. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5753. // data["fixmedins_code"] = miConfig.Code
  5754. // data["dept_code"] = department.Number
  5755. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5756. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5757. // data["secret_key"] = miConfig.SecretKey
  5758. // var ids []int64
  5759. //
  5760. // for _, item := range prescriptions {
  5761. // ids = append(ids, item.ID)
  5762. // }
  5763. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5764. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5765. // bytesData, _ := json.Marshal(data)
  5766. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5767. // resp, _ := client.Do(req)
  5768. // defer resp.Body.Close()
  5769. // body, ioErr := ioutil.ReadAll(resp.Body)
  5770. // if ioErr != nil {
  5771. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5772. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5773. // return
  5774. // }
  5775. // var respJSON map[string]interface{}
  5776. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5777. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5779. // return
  5780. // }
  5781. //
  5782. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5783. // userJSONBytes, _ := json.Marshal(respJSON)
  5784. // var res ResultFour
  5785. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5786. // utils.ErrorLog("解析失败:%v", err)
  5787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5788. // return
  5789. // }
  5790. //
  5791. // if res.Infcode == 0 {
  5792. // order := &models.HisOrder{
  5793. // UserOrgId: adminUser.CurrentOrgId,
  5794. // HisPatientId: his.ID,
  5795. // PatientId: his.PatientId,
  5796. // SettleAccountsDate: recordDateTime,
  5797. // Ctime: time.Now().Unix(),
  5798. // Mtime: time.Now().Unix(),
  5799. // Status: 1,
  5800. // Number: chrg_bchno,
  5801. // Infcode: res.Infcode,
  5802. // WarnMsg: res.WarnMsg,
  5803. // Cainfo: res.Cainfo,
  5804. // ErrMsg: res.ErrMsg,
  5805. // RespondTime: res.RefmsgTime,
  5806. // InfRefmsgid: res.InfRefmsgid,
  5807. // OrderStatus: 1,
  5808. // IsMedicineInsurance: 1,
  5809. // SettleType: settle_accounts_type,
  5810. // SettleStartTime: start_time,
  5811. // SettleEndTime: end_time,
  5812. // Creator: roles.ID,
  5813. // Modify: roles.ID,
  5814. // PType: 2,
  5815. // }
  5816. // err = service.CreateOrder(order)
  5817. // if err != nil {
  5818. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5819. // return
  5820. // }
  5821. //
  5822. // for _, item := range res.Output.Result {
  5823. // temp := strings.Split(item.FeedetlSn, "-")
  5824. // var advice_id int64 = 0
  5825. // var project_id int64 = 0
  5826. // var types int64 = 0
  5827. //
  5828. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5829. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5830. //
  5831. // if temp[1] == "1" {
  5832. // advice_id = id
  5833. // project_id = 0
  5834. // } else if temp[1] == "2" {
  5835. // advice_id = 0
  5836. // project_id = id
  5837. // }
  5838. //
  5839. // info := &models.HisOrderInfo{
  5840. // OrderNumber: order.Number,
  5841. // FeedetlSn: item.FeedetlSn,
  5842. // UploadDate: time.Now().Unix(),
  5843. // AdviceId: advice_id,
  5844. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5845. // Cnt: item.Cnt,
  5846. // Pric: float64(item.Pric),
  5847. // PatientId: his.PatientId,
  5848. // PricUplmtAmt: item.PricUplmtAmt,
  5849. // SelfpayProp: item.SelfpayProp,
  5850. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5851. // OverlmtAmt: item.OverlmtAmt,
  5852. // PreselfpayAmt: item.PreselfpayAmt,
  5853. // BasMednFlag: item.BasMednFlag,
  5854. // MedChrgitmType: item.MedChrgitmType,
  5855. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5856. // Status: 1,
  5857. // Memo: item.Memo,
  5858. // Mtime: time.Now().Unix(),
  5859. // InscpScpAmt: item.InscpScpAmt,
  5860. // DrtReimFlag: item.DrtReimFlag,
  5861. // Ctime: time.Now().Unix(),
  5862. // ListSpItemFlag: item.ListSpItemFlag,
  5863. // ChldMedcFlag: item.ChldMedcFlag,
  5864. // LmtUsedFlag: item.LmtUsedFlag,
  5865. // ChrgitmLv: item.ChrgitmLv,
  5866. // UserOrgId: adminUser.CurrentOrgId,
  5867. // HisPatientId: his.ID,
  5868. // OrderId: order.ID,
  5869. // ProjectId: project_id,
  5870. // Type: types,
  5871. // }
  5872. // service.CreateOrderInfo(info)
  5873. //
  5874. // }
  5875. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5876. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5877. //
  5878. // var total float64
  5879. // for _, item := range prescriptions {
  5880. // if item.Type == 1 { //药品
  5881. // for _, subItem := range item.HisDoctorAdviceInfo {
  5882. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5883. // }
  5884. // }
  5885. // if item.Type == 2 { //项目
  5886. // for _, subItem := range item.HisPrescriptionProject {
  5887. // total = total + (subItem.Price * float64(subItem.Count))
  5888. // }
  5889. // }
  5890. // }
  5891. //
  5892. // for _, item := range prescriptions {
  5893. // for _, subItem := range item.HisAdditionalCharge {
  5894. // total = total + (subItem.Price * float64(subItem.Count))
  5895. // }
  5896. // }
  5897. //
  5898. // allTotal := fmt.Sprintf("%.2f", total)
  5899. // if res.Infcode == 0 {
  5900. // var rf []*ResultFive
  5901. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5902. // psn_no := his.PsnNo
  5903. // mdtrt_id := his.Number
  5904. // chrg_bchno := chrg_bchno
  5905. // cert_no := his.Certno
  5906. // insutype := rf[0].Insutype
  5907. //
  5908. // if his.IdCardType == 1 {
  5909. // cert_no = his.MedicalInsuranceNumber
  5910. //
  5911. // } else {
  5912. //
  5913. // cert_no = his.Certno
  5914. //
  5915. // }
  5916. //
  5917. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5918. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5919. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5920. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5921. // resp, requestErr := http.Get(api)
  5922. // if requestErr != nil {
  5923. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5924. // return
  5925. // }
  5926. // defer resp.Body.Close()
  5927. // body, ioErr := ioutil.ReadAll(resp.Body)
  5928. // if ioErr != nil {
  5929. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5930. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5931. // return
  5932. // }
  5933. // var respJSON map[string]interface{}
  5934. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5935. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5937. // return
  5938. // }
  5939. // fmt.Println(respJSON)
  5940. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5941. // userJSONBytes, _ := json.Marshal(respJSON)
  5942. // var res ResultSeven
  5943. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5944. // utils.ErrorLog("解析失败:%v", err)
  5945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5946. // return
  5947. // }
  5948. // if res.Infcode != 0 {
  5949. // errlog := &models.HisOrderError{
  5950. // UserOrgId: adminUser.CurrentOrgId,
  5951. // Ctime: time.Now().Unix(),
  5952. // Mtime: time.Now().Unix(),
  5953. // Number: chrg_bchno,
  5954. // ErrMsg: res.ErrMsg,
  5955. // Status: 1,
  5956. // PatientId: id,
  5957. // RecordTime: recordDateTime,
  5958. // Stage: 7,
  5959. // }
  5960. // service.CreateErrMsgLog(errlog)
  5961. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5962. // return
  5963. // } else {
  5964. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5965. // order.OrderStatus = 1
  5966. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5967. // order.SetlId = res.Output.Setlinfo.SetlID
  5968. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5969. // order.PsnName = res.Output.Setlinfo.PsnName
  5970. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5971. // order.Certno = res.Output.Setlinfo.Certno
  5972. // order.Gend = res.Output.Setlinfo.Gend
  5973. // order.Naty = res.Output.Setlinfo.Naty
  5974. // order.Age = res.Output.Setlinfo.Age
  5975. // order.Insutype = res.Output.Setlinfo.Insutype
  5976. // order.PsnType = res.Output.Setlinfo.PsnType
  5977. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5978. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5979. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5980. // order.MedType = res.Output.Setlinfo.MedType
  5981. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5982. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5983. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5984. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5985. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5986. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5987. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5988. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5989. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5990. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5991. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5992. // order.MafPay = res.Output.Setlinfo.MafPay
  5993. // order.OthPay = res.Output.Setlinfo.OthPay
  5994. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5995. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5996. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5997. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5998. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5999. // order.Balc = res.Output.Setlinfo.Balc
  6000. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6001. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6002. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6003. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6004. // order.Creator = order.Creator
  6005. // order.Modify = roles.ID
  6006. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6007. // detailStr := string(setlDetail)
  6008. // order.SetlDetail = detailStr
  6009. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6010. // err = service.UpDateOrder(order)
  6011. // if err == nil {
  6012. // c.ServeSuccessJSON(map[string]interface{}{
  6013. // "msg": "预结算成功",
  6014. // })
  6015. // } else {
  6016. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6017. // return
  6018. // }
  6019. // }
  6020. // } else {
  6021. // adminUser := c.GetAdminUserInfo()
  6022. // errlog := &models.HisOrderError{
  6023. // UserOrgId: adminUser.CurrentOrgId,
  6024. // Ctime: time.Now().Unix(),
  6025. // Mtime: time.Now().Unix(),
  6026. // ErrMsg: res.ErrMsg,
  6027. // Status: 1,
  6028. // PatientId: id,
  6029. // RecordTime: recordDateTime,
  6030. // Stage: 4,
  6031. // }
  6032. // service.CreateErrMsgLog(errlog)
  6033. //
  6034. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6035. // return
  6036. // }
  6037. // } else {
  6038. // adminUser := c.GetAdminUserInfo()
  6039. // errlog := &models.HisOrderError{
  6040. // UserOrgId: adminUser.CurrentOrgId,
  6041. // Ctime: time.Now().Unix(),
  6042. // Mtime: time.Now().Unix(),
  6043. // ErrMsg: res.ErrMsg,
  6044. // Status: 1,
  6045. // PatientId: id,
  6046. // RecordTime: recordDateTime,
  6047. // Stage: 4,
  6048. // }
  6049. // service.CreateErrMsgLog(errlog)
  6050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6051. // return
  6052. // }
  6053. //
  6054. // } else {
  6055. // var total float64
  6056. // for _, item := range prescriptions {
  6057. // if item.Type == 1 { //药品
  6058. // for _, subItem := range item.HisDoctorAdviceInfo {
  6059. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6060. // }
  6061. // }
  6062. // if item.Type == 2 { //项目
  6063. // for _, subItem := range item.HisPrescriptionProject {
  6064. // total = total + (subItem.Price * float64(subItem.Count))
  6065. // }
  6066. // }
  6067. //
  6068. // for _, subItem := range item.HisAdditionalCharge {
  6069. // total = total + (subItem.Price * float64(subItem.Count))
  6070. // }
  6071. // }
  6072. //
  6073. // allTotal := fmt.Sprintf("%.2f", total)
  6074. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6075. // order := &models.HisOrder{
  6076. // UserOrgId: adminUser.CurrentOrgId,
  6077. // HisPatientId: his.ID,
  6078. // PatientId: id,
  6079. // SettleAccountsDate: recordDateTime,
  6080. // Ctime: time.Now().Unix(),
  6081. // Mtime: time.Now().Unix(),
  6082. // Status: 1,
  6083. // OrderStatus: 2,
  6084. // Number: chrg_bchno,
  6085. // MedfeeSumamt: totals,
  6086. // }
  6087. // err = service.CreateOrder(order)
  6088. // if err != nil {
  6089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6090. // return
  6091. // }
  6092. //
  6093. // var customs []*Custom
  6094. // for _, item := range prescriptions {
  6095. //
  6096. // if item.Type == 1 { //药品
  6097. // for _, subItem := range item.HisDoctorAdviceInfo {
  6098. // cus := &Custom{
  6099. // AdviceId: subItem.ID,
  6100. // ProjectId: 0,
  6101. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6102. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6103. // FeedetlSn: subItem.FeedetlSn,
  6104. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6105. // MedListCodg: subItem.MedListCodg,
  6106. // Type: 1,
  6107. // }
  6108. // customs = append(customs, cus)
  6109. // }
  6110. // }
  6111. //
  6112. // if item.Type == 2 { //项目
  6113. // for _, subItem := range item.HisPrescriptionProject {
  6114. //
  6115. // cus := &Custom{
  6116. // AdviceId: 0,
  6117. // ProjectId: subItem.ID,
  6118. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6119. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6120. // FeedetlSn: subItem.FeedetlSn,
  6121. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6122. // MedListCodg: subItem.MedListCodg,
  6123. // Type: 2,
  6124. // }
  6125. //
  6126. // customs = append(customs, cus)
  6127. // }
  6128. // }
  6129. //
  6130. // for _, item := range item.HisAdditionalCharge {
  6131. // cus := &Custom{
  6132. // ItemId: item.ID,
  6133. // AdviceId: 0,
  6134. // ProjectId: 0,
  6135. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6136. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6137. // FeedetlSn: item.FeedetlSn,
  6138. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6139. // MedListCodg: item.XtHisAddtionConfig.Code,
  6140. // Type: 3,
  6141. // }
  6142. //
  6143. // customs = append(customs, cus)
  6144. // }
  6145. //
  6146. // }
  6147. //
  6148. // for _, item := range customs {
  6149. // var advice_id int64 = 0
  6150. // var project_id int64 = 0
  6151. // var item_id int64 = 0
  6152. //
  6153. // var types int64 = 0
  6154. //
  6155. // if item.Type == 1 {
  6156. // advice_id = item.AdviceId
  6157. // project_id = 0
  6158. // item_id = 0
  6159. // } else if item.Type == 2 {
  6160. // advice_id = 0
  6161. // item_id = 0
  6162. //
  6163. // project_id = item.ProjectId
  6164. // } else if item.Type == 3 {
  6165. // advice_id = 0
  6166. // item_id = item.ItemId
  6167. // project_id = 0
  6168. // }
  6169. //
  6170. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6171. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6172. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6173. //
  6174. // info := &models.HisOrderInfo{
  6175. // OrderNumber: order.Number,
  6176. // UploadDate: time.Now().Unix(),
  6177. // AdviceId: advice_id,
  6178. // DetItemFeeSumamt: detItemFeeSumamt,
  6179. // Cnt: cut,
  6180. // Pric: pric,
  6181. // PatientId: id,
  6182. // Status: 1,
  6183. // Mtime: time.Now().Unix(),
  6184. // Ctime: time.Now().Unix(),
  6185. // UserOrgId: adminUser.CurrentOrgId,
  6186. // HisPatientId: his.ID,
  6187. // OrderId: order.ID,
  6188. // ProjectId: project_id,
  6189. // Type: types,
  6190. // ItemId: item_id,
  6191. // }
  6192. // service.CreateOrderInfo(info)
  6193. // }
  6194. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6195. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6196. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6197. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6198. // if err == nil {
  6199. // c.ServeSuccessJSON(map[string]interface{}{
  6200. // "msg": "结算成功",
  6201. // })
  6202. // } else {
  6203. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6204. // return
  6205. // }
  6206. // }
  6207. //}
  6208. //上传明细-预结算-
  6209. func (c *HisApiController) GetPreUploadInfo() {
  6210. id, _ := c.GetInt64("id")
  6211. record_time := c.GetString("record_time")
  6212. his_patient_id, _ := c.GetInt64("his_patient_id")
  6213. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6214. admin_user_id, _ := c.GetInt64("admin_user_id")
  6215. diagnosis_id := c.GetString("diagnosis")
  6216. sick_type, _ := c.GetInt64("sick_type")
  6217. reg_type, _ := c.GetInt64("p_type")
  6218. begin_time := c.GetString("begin_time")
  6219. id_str := c.GetString("ids")
  6220. ids_arr := strings.Split(id_str, ",")
  6221. timeLayout := "2006-01-02"
  6222. loc, _ := time.LoadLocation("Local")
  6223. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6224. if err != nil {
  6225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6226. return
  6227. }
  6228. recordDateTime := theTime.Unix()
  6229. adminUser := c.GetAdminUserInfo()
  6230. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6231. var config []*models.HisXtDiagnoseConfig
  6232. for _, item := range diagnosis_ids {
  6233. id, _ := strconv.ParseInt(item, 10, 64)
  6234. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6235. config = append(config, &diagnosisConfig)
  6236. }
  6237. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6238. sickConfig, _ := service.FindSickById(sick_type)
  6239. var prescriptions []*models.HisPrescription
  6240. var start_time int64
  6241. var end_time int64
  6242. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6243. fmt.Println(his_patient_id)
  6244. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6245. timestamp := time.Now().Unix()
  6246. tempTime := time.Unix(timestamp, 0)
  6247. timeFormat := tempTime.Format("20060102150405")
  6248. chrgBchno := rand.Intn(100000) + 10000
  6249. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6250. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6251. var patientPrescription models.HisPrescriptionInfo
  6252. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6253. if patientPrescription.ID == 0 {
  6254. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6255. }
  6256. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6257. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6258. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6259. strconv.FormatInt(his.PatientId, 10)
  6260. var res2 ResultSix
  6261. var resSix10265 ResultSix10265
  6262. var time_stamp string
  6263. if miConfig.MdtrtareaAdmvs == "421300" {
  6264. data := make(map[string]interface{})
  6265. client := &http.Client{}
  6266. data["psn_no"] = his.PsnNo
  6267. data["mdtrt_id"] = his.Number
  6268. data["doctor"] = roles.UserName
  6269. data["department"] = department.Name
  6270. data["org_name"] = miConfig.OrgName
  6271. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6272. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6273. data["fixmedins_code"] = miConfig.Code
  6274. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6275. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6276. data["secret_key"] = miConfig.SecretKey
  6277. data["sick_code"] = sickConfig.CountryCode
  6278. data["sick_name"] = sickConfig.ClassName
  6279. data["begin_time"] = begin_time
  6280. data["dept"] = strconv.FormatInt(department.ID, 10)
  6281. data["config"] = config
  6282. fmt.Println(data)
  6283. bytesData, _ := json.Marshal(data)
  6284. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6285. resp, _ := client.Do(req)
  6286. defer resp.Body.Close()
  6287. body, ioErr := ioutil.ReadAll(resp.Body)
  6288. if ioErr != nil {
  6289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6291. return
  6292. }
  6293. var respJSON map[string]interface{}
  6294. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6297. return
  6298. }
  6299. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6300. userJSONBytes, _ := json.Marshal(respJSON)
  6301. fmt.Println("log")
  6302. fmt.Println(string(userJSONBytes))
  6303. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6304. utils.ErrorLog("解析失败:%v", err)
  6305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6306. return
  6307. }
  6308. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6309. //江苏地区国家医保医疗类别
  6310. //职工透析:医疗类别选特殊情况门诊9933
  6311. //居民血透门慢: 医疗类别选门诊慢病1402
  6312. //var med_type string
  6313. //if his.Insutype == "310" {
  6314. // if reg_type == 14 {
  6315. // med_type = "9933"
  6316. // } else if reg_type == 11 {
  6317. // med_type = "11"
  6318. //
  6319. // }
  6320. //} else if his.Insutype == "390" {
  6321. // if reg_type == 14 {
  6322. // med_type = "1402"
  6323. // } else if reg_type == 11 {
  6324. // med_type = "11"
  6325. // }
  6326. //}
  6327. data := make(map[string]interface{})
  6328. client := &http.Client{}
  6329. data["psn_no"] = his.PsnNo
  6330. data["mdtrt_id"] = his.Number
  6331. data["doctor"] = roles.UserName
  6332. data["department"] = department.Name
  6333. data["org_name"] = miConfig.OrgName
  6334. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6335. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6336. data["fixmedins_code"] = miConfig.Code
  6337. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6338. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6339. data["secret_key"] = miConfig.SecretKey
  6340. data["sick_code"] = sickConfig.CountryCode
  6341. data["sick_name"] = sickConfig.ClassName
  6342. data["begin_time"] = begin_time
  6343. data["dept"] = strconv.FormatInt(department.ID, 10)
  6344. data["config"] = config
  6345. data["url"] = miConfig.Url
  6346. data["ak"] = miConfig.AccessKey
  6347. data["cainfo"] = miConfig.Cainfo
  6348. bytesData, _ := json.Marshal(data)
  6349. var req *http.Request
  6350. if miConfig.MdtrtareaAdmvs == "320921" {
  6351. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6352. //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 +
  6353. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6354. } else {
  6355. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6356. }
  6357. resp, _ := client.Do(req)
  6358. defer resp.Body.Close()
  6359. body, ioErr := ioutil.ReadAll(resp.Body)
  6360. if ioErr != nil {
  6361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6363. return
  6364. }
  6365. var respJSON map[string]interface{}
  6366. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6369. return
  6370. }
  6371. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6372. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6373. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6374. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6375. userJSONBytes, _ := json.Marshal(respJSON)
  6376. fmt.Println("log")
  6377. fmt.Println(string(userJSONBytes))
  6378. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6379. utils.ErrorLog("解析失败:%v", err)
  6380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6381. return
  6382. }
  6383. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6384. res2.Output = resSix10265.Output
  6385. res2.ErrMsg = resSix10265.ErrMsg
  6386. res2.Cainfo = resSix10265.Cainfo
  6387. res2.WarnMsg = resSix10265.WarnMsg
  6388. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6389. res2.Infcode = infocode
  6390. } else {
  6391. var result string
  6392. var requestLog string
  6393. if miConfig.MdtrtareaAdmvs == "440781" { //
  6394. 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)
  6395. } else {
  6396. if miConfig.Code == "H15049901371" {
  6397. //赤峰地区国家医保医疗类别
  6398. //职工透析:医疗类别选特殊情况门诊990502
  6399. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6400. var med_type string
  6401. if his.Insutype == "390" {
  6402. if reg_type == 14 {
  6403. med_type = "9933"
  6404. } else if reg_type == 11 {
  6405. med_type = "11"
  6406. }
  6407. } else if his.Insutype == "310" {
  6408. if reg_type == 14 {
  6409. med_type = "990502"
  6410. } else if reg_type == 11 {
  6411. med_type = "11"
  6412. }
  6413. }
  6414. 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)
  6415. } else {
  6416. 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)
  6417. }
  6418. saveLog(result, requestLog, "2203", "上传就诊信息")
  6419. var respJSON2 map[string]interface{}
  6420. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6423. return
  6424. }
  6425. userJSONBytes2, _ := json.Marshal(respJSON2)
  6426. if miConfig.Code == "H15049901371" {
  6427. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6428. utils.ErrorLog("解析失败:%v", err)
  6429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6430. return
  6431. }
  6432. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6433. res2.Output = resSix10265.Output
  6434. res2.ErrMsg = resSix10265.ErrMsg
  6435. res2.Cainfo = resSix10265.Cainfo
  6436. res2.WarnMsg = resSix10265.WarnMsg
  6437. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6438. res2.Infcode = infocode
  6439. } else {
  6440. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6441. utils.ErrorLog("解析失败:%v", err)
  6442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6443. return
  6444. }
  6445. }
  6446. }
  6447. }
  6448. if res2.Infcode != 0 {
  6449. adminUser := c.GetAdminUserInfo()
  6450. errlog := &models.HisOrderError{
  6451. UserOrgId: adminUser.CurrentOrgId,
  6452. Ctime: time.Now().Unix(),
  6453. Mtime: time.Now().Unix(),
  6454. ErrMsg: res2.ErrMsg,
  6455. Status: 1,
  6456. PatientId: id,
  6457. RecordTime: recordDateTime,
  6458. Stage: 3,
  6459. }
  6460. service.CreateErrMsgLog(errlog)
  6461. c.ServeSuccessJSON(map[string]interface{}{
  6462. "failed_code": -10,
  6463. "msg": res2.ErrMsg,
  6464. })
  6465. return
  6466. } else {
  6467. his.Diagnosis = diagnosis_id
  6468. his.SickType = sickConfig.ID
  6469. his.PType = fmt.Sprintf("%d", reg_type)
  6470. service.UpdateHisPatientThree(&his)
  6471. data := make(map[string]interface{})
  6472. if settle_accounts_type == 1 { //日结
  6473. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6474. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6475. } else {
  6476. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6477. }
  6478. data["pre"] = prescriptions
  6479. } else { //月结
  6480. start_time_str := c.GetString("start_time")
  6481. end_time_str := c.GetString("end_time")
  6482. timeLayout := "2006-01-02"
  6483. loc, _ := time.LoadLocation("Local")
  6484. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6485. if err != nil {
  6486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6487. return
  6488. }
  6489. recordStartTime := theStartTime.Unix()
  6490. start_time = recordStartTime
  6491. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6492. if err != nil {
  6493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6494. return
  6495. }
  6496. recordEndTime := theEndTime.Unix()
  6497. end_time = recordEndTime
  6498. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6499. data["pre"] = prescriptions
  6500. }
  6501. client := &http.Client{}
  6502. data["psn_no"] = his.PsnNo
  6503. data["mdtrt_id"] = his.Number
  6504. data["chrg_bchno"] = chrg_bchno
  6505. data["org_name"] = miConfig.OrgName
  6506. data["doctor"] = roles.UserName
  6507. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6508. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6509. data["fixmedins_code"] = miConfig.Code
  6510. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6511. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6512. data["dept_code"] = "15"
  6513. } else {
  6514. data["dept_code"] = department.Number
  6515. }
  6516. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6517. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6518. data["secret_key"] = miConfig.SecretKey
  6519. data["url"] = miConfig.Url
  6520. data["ak"] = miConfig.AccessKey
  6521. data["new_doctor_name"] = patientPrescription.Doctor
  6522. data["diag_code"] = sickConfig.CountryCode
  6523. data["time_stamp"] = time_stamp
  6524. data["cainfo"] = miConfig.Cainfo
  6525. var ids []int64
  6526. for _, item := range prescriptions {
  6527. ids = append(ids, item.ID)
  6528. }
  6529. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6530. if config.IsOpen == 1 { //对接了医保,走医保流程
  6531. var res ResultFour
  6532. var resFour10265 ResultFour10265
  6533. if miConfig.MdtrtareaAdmvs == "421300" {
  6534. bytesData, _ := json.Marshal(data)
  6535. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6536. resp, _ := client.Do(req)
  6537. defer resp.Body.Close()
  6538. body, ioErr := ioutil.ReadAll(resp.Body)
  6539. if ioErr != nil {
  6540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6542. return
  6543. }
  6544. var respJSON map[string]interface{}
  6545. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6548. return
  6549. }
  6550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6551. userJSONBytes, _ := json.Marshal(respJSON)
  6552. fmt.Println("log")
  6553. fmt.Println(string(userJSONBytes))
  6554. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6555. utils.ErrorLog("解析失败:%v", err)
  6556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6557. return
  6558. }
  6559. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6560. bytesData, _ := json.Marshal(data)
  6561. var req *http.Request
  6562. if miConfig.MdtrtareaAdmvs == "320921" {
  6563. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6564. } else {
  6565. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6566. }
  6567. resp, _ := client.Do(req)
  6568. defer resp.Body.Close()
  6569. body, ioErr := ioutil.ReadAll(resp.Body)
  6570. if ioErr != nil {
  6571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6573. return
  6574. }
  6575. var respJSON map[string]interface{}
  6576. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6579. return
  6580. }
  6581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6582. userJSONBytes, _ := json.Marshal(respJSON)
  6583. fmt.Println("log")
  6584. fmt.Println(string(userJSONBytes))
  6585. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6586. utils.ErrorLog("解析失败:%v", err)
  6587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6588. return
  6589. }
  6590. res.InfRefmsgid = resFour10265.InfRefmsgid
  6591. res.Output = resFour10265.Output
  6592. res.ErrMsg = resFour10265.ErrMsg
  6593. res.Cainfo = resFour10265.Cainfo
  6594. res.WarnMsg = resFour10265.WarnMsg
  6595. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6596. res.Infcode = infocode
  6597. } else {
  6598. if miConfig.Code == "H15049901371" {
  6599. 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)
  6600. var dat map[string]interface{}
  6601. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6602. fmt.Println(dat)
  6603. } else {
  6604. fmt.Println(err)
  6605. }
  6606. saveLog(result, request_log, "2204", "上传费用明细")
  6607. userJSONBytes, _ := json.Marshal(dat)
  6608. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6609. utils.ErrorLog("解析失败:%v", err)
  6610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6611. return
  6612. }
  6613. res.InfRefmsgid = resFour10265.InfRefmsgid
  6614. res.Output = resFour10265.Output
  6615. res.ErrMsg = resFour10265.ErrMsg
  6616. res.Cainfo = resFour10265.Cainfo
  6617. res.WarnMsg = resFour10265.WarnMsg
  6618. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6619. res.Infcode = infocode
  6620. } else {
  6621. 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)
  6622. var dat map[string]interface{}
  6623. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6624. fmt.Println(dat)
  6625. } else {
  6626. fmt.Println(err)
  6627. }
  6628. saveLog(result, request_log, "2204", "上传费用明细")
  6629. userJSONBytes, _ := json.Marshal(dat)
  6630. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6631. utils.ErrorLog("解析失败:%v", err)
  6632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6633. return
  6634. }
  6635. }
  6636. }
  6637. if res.Infcode == 0 {
  6638. order := &models.HisOrder{
  6639. UserOrgId: adminUser.CurrentOrgId,
  6640. HisPatientId: his.ID,
  6641. PatientId: his.PatientId,
  6642. SettleAccountsDate: recordDateTime,
  6643. Ctime: time.Now().Unix(),
  6644. Mtime: time.Now().Unix(),
  6645. MdtrtId: his.Number,
  6646. PsnNo: his.PsnNo,
  6647. MedType: strconv.FormatInt(reg_type, 10),
  6648. Status: 1,
  6649. Number: chrg_bchno,
  6650. Infcode: res.Infcode,
  6651. WarnMsg: res.WarnMsg,
  6652. Cainfo: res.Cainfo,
  6653. ErrMsg: res.ErrMsg,
  6654. RespondTime: res.RefmsgTime,
  6655. InfRefmsgid: res.InfRefmsgid,
  6656. OrderStatus: 1,
  6657. IsMedicineInsurance: 1,
  6658. SettleType: settle_accounts_type,
  6659. SettleStartTime: start_time,
  6660. SettleEndTime: end_time,
  6661. Creator: roles.AdminUserId,
  6662. Modify: roles.AdminUserId,
  6663. PType: 2,
  6664. Diagnosis: diagnosis_id,
  6665. }
  6666. err = service.CreateOrder(order)
  6667. if err != nil {
  6668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6669. return
  6670. }
  6671. for _, item := range res.Output.Result {
  6672. temp := strings.Split(item.FeedetlSn, "-")
  6673. var advice_id int64 = 0
  6674. var project_id int64 = 0
  6675. var types int64 = 0
  6676. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6677. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6678. if temp[1] == "1" {
  6679. advice_id = id
  6680. project_id = 0
  6681. } else if temp[1] == "2" {
  6682. advice_id = 0
  6683. project_id = id
  6684. }
  6685. info := &models.HisOrderInfo{
  6686. OrderNumber: order.Number,
  6687. FeedetlSn: item.FeedetlSn,
  6688. UploadDate: time.Now().Unix(),
  6689. AdviceId: advice_id,
  6690. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6691. Cnt: item.Cnt,
  6692. Pric: float64(item.Pric),
  6693. PatientId: his.PatientId,
  6694. PricUplmtAmt: item.PricUplmtAmt,
  6695. SelfpayProp: item.SelfpayProp,
  6696. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6697. OverlmtAmt: item.OverlmtAmt,
  6698. PreselfpayAmt: item.PreselfpayAmt,
  6699. BasMednFlag: item.BasMednFlag,
  6700. MedChrgitmType: item.MedChrgitmType,
  6701. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6702. Status: 1,
  6703. Memo: item.Memo,
  6704. Mtime: time.Now().Unix(),
  6705. InscpScpAmt: item.InscpScpAmt,
  6706. DrtReimFlag: item.DrtReimFlag,
  6707. Ctime: time.Now().Unix(),
  6708. ListSpItemFlag: item.ListSpItemFlag,
  6709. ChldMedcFlag: item.ChldMedcFlag,
  6710. LmtUsedFlag: item.LmtUsedFlag,
  6711. ChrgitmLv: item.ChrgitmLv,
  6712. UserOrgId: adminUser.CurrentOrgId,
  6713. HisPatientId: his.ID,
  6714. OrderId: order.ID,
  6715. ProjectId: project_id,
  6716. Type: types,
  6717. }
  6718. service.CreateOrderInfo(info)
  6719. }
  6720. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6721. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6722. var total float64
  6723. for _, item := range prescriptions {
  6724. if item.Type == 1 { //药品
  6725. for _, subItem := range item.HisDoctorAdviceInfo {
  6726. total = total + (subItem.Price * subItem.PrescribingNumber)
  6727. }
  6728. }
  6729. if item.Type == 2 { //项目
  6730. for _, subItem := range item.HisPrescriptionProject {
  6731. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6732. total = total + (subItem.Price * cnt)
  6733. }
  6734. }
  6735. }
  6736. for _, item := range prescriptions {
  6737. for _, subItem := range item.HisAdditionalCharge {
  6738. total = total + (subItem.Price * float64(subItem.Count))
  6739. }
  6740. }
  6741. allTotal := fmt.Sprintf("%.4f", total)
  6742. if res.Infcode == 0 {
  6743. var rf []*ResultFive
  6744. json.Unmarshal([]byte(his.Iinfo), &rf)
  6745. chrg_bchno := chrg_bchno
  6746. cert_no := his.Certno
  6747. var insutypes []string
  6748. var insutype string
  6749. var is390 int = 0
  6750. var is310 int = 0
  6751. for _, item := range rf {
  6752. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6753. insutypes = append(insutypes, item.Insutype)
  6754. }
  6755. }
  6756. if len(insutypes) == 1 {
  6757. insutype = insutypes[0]
  6758. } else {
  6759. for _, i := range insutypes {
  6760. if i == "390" {
  6761. is390 = 1
  6762. }
  6763. if i == "310" {
  6764. is310 = 1
  6765. }
  6766. }
  6767. }
  6768. if is390 == 1 {
  6769. insutype = "390"
  6770. }
  6771. if is310 == 1 {
  6772. insutype = "310"
  6773. }
  6774. if len(insutypes) == 0 {
  6775. insutype = "310"
  6776. }
  6777. if len(insutypes) == 2 {
  6778. insutype = strconv.FormatInt(his.SocialType, 64)
  6779. }
  6780. //insutype = "390"
  6781. if his.IdCardType == 1 {
  6782. cert_no = his.MedicalInsuranceNumber
  6783. } else {
  6784. cert_no = his.Certno
  6785. }
  6786. var res ResultSeven
  6787. var resSeven10265 ResultSeven10265
  6788. if miConfig.MdtrtareaAdmvs == "421300" {
  6789. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6790. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6791. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6792. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6793. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6794. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6795. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6796. resp, requestErr := http.Get(api)
  6797. if requestErr != nil {
  6798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6799. return
  6800. }
  6801. body, ioErr := ioutil.ReadAll(resp.Body)
  6802. if ioErr != nil {
  6803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6805. return
  6806. }
  6807. var respJSON map[string]interface{}
  6808. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6811. return
  6812. }
  6813. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6814. result, _ := json.Marshal(respJSON)
  6815. fmt.Println("log")
  6816. fmt.Println(string(result))
  6817. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6818. utils.ErrorLog("解析失败:%v", err)
  6819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6820. return
  6821. }
  6822. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6823. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6824. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6825. bas := strings.Split(psn_info.CardInfo, "|")
  6826. if his.IdCardType == 1 {
  6827. cert_no = bas[2]
  6828. } else {
  6829. cert_no = bas[1]
  6830. }
  6831. //江苏地区国家医保医疗类别
  6832. //职工透析:医疗类别选特殊情况门诊9933
  6833. //居民血透门慢: 医疗类别选门诊慢病1402
  6834. //var med_type string
  6835. //if his.Insutype == "310" {
  6836. // if reg_type == 14 {
  6837. // med_type = "9933"
  6838. // } else if reg_type == 11 {
  6839. // med_type = "11"
  6840. //
  6841. // }
  6842. //} else if his.Insutype == "390" {
  6843. // if reg_type == 14 {
  6844. // med_type = "1402"
  6845. // } else if reg_type == 11 {
  6846. // med_type = "11"
  6847. // }
  6848. //}
  6849. var api string
  6850. if miConfig.MdtrtareaAdmvs == "320921" {
  6851. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6852. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6853. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6854. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6855. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6856. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6857. "&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
  6858. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6859. } else {
  6860. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6861. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6862. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6863. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6864. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6865. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6866. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6867. "&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
  6868. }
  6869. resp, requestErr := http.Get(api)
  6870. if requestErr != nil {
  6871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6872. return
  6873. }
  6874. body, ioErr := ioutil.ReadAll(resp.Body)
  6875. if ioErr != nil {
  6876. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6878. return
  6879. }
  6880. var respJSON map[string]interface{}
  6881. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6884. return
  6885. }
  6886. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6887. result, _ := json.Marshal(respJSON)
  6888. fmt.Println("log")
  6889. fmt.Println(string(result))
  6890. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6891. utils.ErrorLog("解析失败:%v", err)
  6892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6893. return
  6894. }
  6895. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6896. res.Output = resSeven10265.Output
  6897. res.ErrMsg = resSeven10265.ErrMsg
  6898. res.Cainfo = resSeven10265.Cainfo
  6899. res.WarnMsg = resSeven10265.WarnMsg
  6900. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6901. res.Infcode = infocode
  6902. } else {
  6903. var result string
  6904. var request_log string
  6905. if miConfig.Code == "H15049901371" {
  6906. //赤峰地区国家医保医疗类别
  6907. //职工透析:医疗类别选特殊情况门诊990502
  6908. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6909. var med_type string
  6910. if his.Insutype == "390" {
  6911. if reg_type == 14 {
  6912. med_type = "9933"
  6913. } else if reg_type == 11 {
  6914. med_type = "11"
  6915. }
  6916. } else if his.Insutype == "310" {
  6917. if reg_type == 14 {
  6918. med_type = "990502"
  6919. } else if reg_type == 11 {
  6920. med_type = "11"
  6921. }
  6922. }
  6923. 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)
  6924. } else {
  6925. 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)
  6926. }
  6927. var dat map[string]interface{}
  6928. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6929. fmt.Println(dat)
  6930. } else {
  6931. fmt.Println(err)
  6932. }
  6933. saveLog(result, request_log, "2206", "预结算")
  6934. //userJSONBytes, _ := json.Marshal(dat)
  6935. //
  6936. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6937. // utils.ErrorLog("解析失败:%v", err)
  6938. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6939. // return
  6940. //}
  6941. userJSONBytes, _ := json.Marshal(dat)
  6942. if miConfig.Code == "H15049901371" {
  6943. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6944. utils.ErrorLog("解析失败:%v", err)
  6945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6946. return
  6947. }
  6948. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6949. res.Output = resSeven10265.Output
  6950. res.ErrMsg = resSeven10265.ErrMsg
  6951. res.Cainfo = resSeven10265.Cainfo
  6952. res.WarnMsg = resSeven10265.WarnMsg
  6953. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6954. res.Infcode = infocode
  6955. } else {
  6956. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6957. utils.ErrorLog("解析失败:%v", err)
  6958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6959. return
  6960. }
  6961. }
  6962. }
  6963. if res.Infcode != 0 {
  6964. errlog := &models.HisOrderError{
  6965. UserOrgId: adminUser.CurrentOrgId,
  6966. Ctime: time.Now().Unix(),
  6967. Mtime: time.Now().Unix(),
  6968. Number: chrg_bchno,
  6969. ErrMsg: res.ErrMsg,
  6970. Status: 1,
  6971. PatientId: id,
  6972. RecordTime: recordDateTime,
  6973. Stage: 20,
  6974. }
  6975. service.CreateErrMsgLog(errlog)
  6976. c.ServeSuccessJSON(map[string]interface{}{
  6977. "failed_code": -10,
  6978. "msg": res.ErrMsg,
  6979. })
  6980. return
  6981. } else {
  6982. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6983. order.OrderStatus = 1
  6984. order.IsPre = 1
  6985. order.Status = 1
  6986. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6987. order.SetlId = res.Output.Setlinfo.SetlID
  6988. order.PsnNo = res.Output.Setlinfo.PsnNo
  6989. order.PsnName = res.Output.Setlinfo.PsnName
  6990. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6991. order.Certno = res.Output.Setlinfo.Certno
  6992. order.Gend = res.Output.Setlinfo.Gend
  6993. order.Naty = res.Output.Setlinfo.Naty
  6994. order.Age = res.Output.Setlinfo.Age
  6995. order.Insutype = res.Output.Setlinfo.Insutype
  6996. order.PsnType = res.Output.Setlinfo.PsnType
  6997. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6998. order.SetlTime = res.Output.Setlinfo.SetlTime
  6999. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7000. if res.Output.Setlinfo.MedType == "140101" {
  7001. order.MedType = "14"
  7002. } else {
  7003. order.MedType = res.Output.Setlinfo.MedType
  7004. }
  7005. if reg_type == 1112 {
  7006. order.MedType = "1112"
  7007. }
  7008. if reg_type == 1111 {
  7009. order.MedType = "1111"
  7010. }
  7011. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7012. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7013. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7014. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7015. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7016. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7017. order.HifpPay = res.Output.Setlinfo.HifpPay
  7018. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7019. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7020. order.HifesPay = res.Output.Setlinfo.HifesPay
  7021. order.HifobPay = res.Output.Setlinfo.HifobPay
  7022. order.MafPay = res.Output.Setlinfo.MafPay
  7023. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7024. order.OthPay = res.Output.Setlinfo.OthPay
  7025. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7026. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7027. order.AcctPay = res.Output.Setlinfo.AcctPay
  7028. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7029. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7030. order.Balc = res.Output.Setlinfo.Balc
  7031. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7032. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7033. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7034. order.ClrWay = res.Output.Setlinfo.ClrWay
  7035. order.Creator = order.Creator
  7036. order.Modify = roles.AdminUserId
  7037. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7038. detailStr := string(setlDetail)
  7039. order.SetlDetail = detailStr
  7040. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7041. err = service.UpDateOrder(order)
  7042. if err == nil {
  7043. c.ServeSuccessJSON(map[string]interface{}{
  7044. "msg": "预结算成功",
  7045. })
  7046. } else {
  7047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7048. return
  7049. }
  7050. }
  7051. } else {
  7052. adminUser := c.GetAdminUserInfo()
  7053. errlog := &models.HisOrderError{
  7054. UserOrgId: adminUser.CurrentOrgId,
  7055. Ctime: time.Now().Unix(),
  7056. Mtime: time.Now().Unix(),
  7057. ErrMsg: res.ErrMsg,
  7058. Status: 1,
  7059. PatientId: id,
  7060. RecordTime: recordDateTime,
  7061. Stage: 4,
  7062. }
  7063. service.CreateErrMsgLog(errlog)
  7064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7065. return
  7066. }
  7067. } else {
  7068. adminUser := c.GetAdminUserInfo()
  7069. errlog := &models.HisOrderError{
  7070. UserOrgId: adminUser.CurrentOrgId,
  7071. Ctime: time.Now().Unix(),
  7072. Mtime: time.Now().Unix(),
  7073. ErrMsg: res.ErrMsg,
  7074. Status: 1,
  7075. PatientId: id,
  7076. RecordTime: recordDateTime,
  7077. Stage: 4,
  7078. }
  7079. service.CreateErrMsgLog(errlog)
  7080. c.ServeSuccessJSON(map[string]interface{}{
  7081. "failed_code": -10,
  7082. "msg": res.ErrMsg,
  7083. })
  7084. return
  7085. }
  7086. }
  7087. }
  7088. }
  7089. //func (c *HisApiController) GetSettleInfo() {
  7090. // id, _ := c.GetInt64("id")
  7091. // order_id, _ := c.GetInt64("order_id")
  7092. //
  7093. // record_time := c.GetString("record_time")
  7094. // pay_way, _ := c.GetInt64("pay_way")
  7095. // pay_price, _ := c.GetFloat("pay_price")
  7096. // pay_card_no := c.GetString("pay_card_no")
  7097. // discount_price, _ := c.GetFloat("discount_price")
  7098. // preferential_price, _ := c.GetFloat("preferential_price")
  7099. // reality_price, _ := c.GetFloat("reality_price")
  7100. // found_price, _ := c.GetFloat("found_price")
  7101. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7102. // private_price, _ := c.GetFloat("private_price")
  7103. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7104. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7105. //
  7106. // timeLayout := "2006-01-02"
  7107. // loc, _ := time.LoadLocation("Local")
  7108. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7109. // if err != nil {
  7110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7111. // return
  7112. // }
  7113. // recordDateTime := theTime.Unix()
  7114. // adminUser := c.GetAdminUserInfo()
  7115. //
  7116. // var prescriptions []*models.HisPrescription
  7117. //
  7118. // data := make(map[string]interface{})
  7119. // if settle_accounts_type == 1 { //日结
  7120. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7121. // data["pre"] = prescriptions
  7122. //
  7123. // } else { //月结
  7124. // start_time_str := c.GetString("start_time")
  7125. // end_time_str := c.GetString("end_time")
  7126. // timeLayout := "2006-01-02"
  7127. // loc, _ := time.LoadLocation("Local")
  7128. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7129. // if err != nil {
  7130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7131. // return
  7132. // }
  7133. // recordStartTime := theStartTime.Unix()
  7134. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7135. // if err != nil {
  7136. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7137. // return
  7138. // }
  7139. // recordEndTime := theEndTime.Unix()
  7140. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7141. // data["pre"] = prescriptions
  7142. //
  7143. // }
  7144. //
  7145. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7146. //
  7147. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7148. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7149. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7150. // strconv.FormatInt(his.PatientId, 10)
  7151. //
  7152. // order_src, _ := service.GetHisOrderByID(order_id)
  7153. //
  7154. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7155. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7156. //
  7157. // var total float64
  7158. // for _, item := range prescriptions {
  7159. // if item.Type == 1 { //药品
  7160. // for _, subItem := range item.HisDoctorAdviceInfo {
  7161. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7162. // }
  7163. // }
  7164. // if item.Type == 2 { //项目
  7165. // for _, subItem := range item.HisPrescriptionProject {
  7166. // total = total + (subItem.Price * float64(subItem.Count))
  7167. // }
  7168. // }
  7169. // }
  7170. //
  7171. // for _, item := range prescriptions {
  7172. // for _, subItem := range item.HisAdditionalCharge {
  7173. // total = total + (subItem.Price * float64(subItem.Count))
  7174. // }
  7175. // }
  7176. //
  7177. // allTotal := fmt.Sprintf("%.2f", total)
  7178. // var rf []*ResultFive
  7179. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7180. // psn_no := order_src.PsnNo
  7181. // mdtrt_id := order_src.MdtrtId
  7182. // chrg_bchno := order_src.Number
  7183. // cert_no := order_src.Certno
  7184. // insutype := rf[0].Insutype
  7185. //
  7186. // if his.IdCardType == 1 {
  7187. // cert_no = his.MedicalInsuranceNumber
  7188. // } else {
  7189. // cert_no = his.Certno
  7190. // }
  7191. //
  7192. // 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)
  7193. // var dat map[string]interface{}
  7194. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7195. // fmt.Println(dat)
  7196. // } else {
  7197. // fmt.Println(err)
  7198. // }
  7199. //
  7200. // userJSONBytes, _ := json.Marshal(dat)
  7201. //
  7202. //
  7203. //
  7204. // var res ResultSeven
  7205. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7206. // utils.ErrorLog("解析失败:%v", err)
  7207. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7208. // return
  7209. // }
  7210. // if res.Infcode == -1 {
  7211. // errlog := &models.HisOrderError{
  7212. // UserOrgId: adminUser.CurrentOrgId,
  7213. // Ctime: time.Now().Unix(),
  7214. // Mtime: time.Now().Unix(),
  7215. // Number: chrg_bchno,
  7216. // ErrMsg: res.ErrMsg,
  7217. // Status: 1,
  7218. // PatientId: id,
  7219. // RecordTime: recordDateTime,
  7220. // Stage: 6,
  7221. // }
  7222. // service.CreateErrMsgLog(errlog)
  7223. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7224. // return
  7225. // } else {
  7226. // order_src.OrderStatus = 2
  7227. // order_src.PayWay = pay_way
  7228. // order_src.PayPrice = pay_price
  7229. // order_src.PayCardNo = pay_card_no
  7230. // order_src.DiscountPrice = discount_price
  7231. // order_src.PreferentialPrice = preferential_price
  7232. // order_src.RealityPrice = reality_price
  7233. // order_src.FoundPrice = found_price
  7234. // order_src.MedicalInsurancePrice = medical_insurance_price
  7235. // order_src.PrivatePrice = private_price
  7236. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7237. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7238. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7239. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7240. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7241. // order_src.Certno = res.Output.Setlinfo.Certno
  7242. // order_src.Gend = res.Output.Setlinfo.Gend
  7243. // order_src.Naty = res.Output.Setlinfo.Naty
  7244. // order_src.Age = res.Output.Setlinfo.Age
  7245. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7246. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7247. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7248. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7249. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7250. // order_src.MedType = res.Output.Setlinfo.MedType
  7251. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7252. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7253. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7254. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7255. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7256. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7257. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7258. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7259. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7260. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7261. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7262. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7263. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7264. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7265. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7266. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7267. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7268. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7269. // order_src.Balc = res.Output.Setlinfo.Balc
  7270. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7271. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7272. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7273. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7274. // order_src.Creator = order_src.Creator
  7275. // order_src.Modify = roles.ID
  7276. // order_src.RequestLog = src_resquest
  7277. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7278. // detailStr := string(setlDetail)
  7279. // order_src.SetlDetail = detailStr
  7280. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7281. // err = service.UpDateOrder(order_src)
  7282. //
  7283. // if err == nil {
  7284. // c.ServeSuccessJSON(map[string]interface{}{
  7285. // "msg": "结算成功",
  7286. // })
  7287. // } else {
  7288. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7289. // return
  7290. // }
  7291. // }
  7292. // }
  7293. //}
  7294. //退款
  7295. func (c *HisApiController) Refund() {
  7296. order_id, _ := c.GetInt64("order_id")
  7297. admin_user_id, _ := c.GetInt64("admin_user_id")
  7298. adminUser := c.GetAdminUserInfo()
  7299. var order models.HisOrder
  7300. order, _ = service.GetHisOrderByID(order_id)
  7301. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7302. if order.ID == 0 {
  7303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7304. return
  7305. }
  7306. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7307. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7308. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7309. if config.IsOpen == 1 { //对接了医保,走医保流程
  7310. var res ResultSixteen
  7311. var resSixteen10265 ResultSixteen10265
  7312. var src_resquest string
  7313. var result string
  7314. if miConfig.MdtrtareaAdmvs == "421300" {
  7315. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7316. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7317. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7318. resp3, requestErr3 := http.Get(api3)
  7319. if requestErr3 != nil {
  7320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7321. return
  7322. }
  7323. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7324. if ioErr3 != nil {
  7325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7327. return
  7328. }
  7329. var respJSON3 map[string]interface{}
  7330. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7333. return
  7334. }
  7335. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7336. userJSONBytes3, _ := json.Marshal(respJSON3)
  7337. fmt.Println("log")
  7338. fmt.Println(string(userJSONBytes3))
  7339. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7340. utils.ErrorLog("解析失败:%v", err)
  7341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7342. return
  7343. }
  7344. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7345. var api3 string
  7346. if miConfig.MdtrtareaAdmvs == "320921" {
  7347. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7348. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7349. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7350. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7351. } else {
  7352. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7353. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7354. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7355. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7356. }
  7357. resp3, requestErr3 := http.Get(api3)
  7358. if requestErr3 != nil {
  7359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7360. return
  7361. }
  7362. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7363. if ioErr3 != nil {
  7364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7366. return
  7367. }
  7368. var respJSON3 map[string]interface{}
  7369. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7372. return
  7373. }
  7374. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7375. userJSONBytes3, _ := json.Marshal(respJSON3)
  7376. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7377. utils.ErrorLog("解析失败:%v", err)
  7378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7379. return
  7380. }
  7381. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7382. res.Output = resSixteen10265.Output
  7383. res.ErrMsg = resSixteen10265.ErrMsg
  7384. res.Cainfo = resSixteen10265.Cainfo
  7385. res.WarnMsg = resSixteen10265.WarnMsg
  7386. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7387. res.Infcode = infocode
  7388. } else {
  7389. if miConfig.Code == "H15049901371" {
  7390. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7391. var dat map[string]interface{}
  7392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7393. fmt.Println(dat)
  7394. } else {
  7395. fmt.Println(err)
  7396. }
  7397. saveLog(result, src_resquest, "2208", "退费")
  7398. userJSONBytes, _ := json.Marshal(dat)
  7399. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7400. utils.ErrorLog("解析失败:%v", err)
  7401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7402. return
  7403. }
  7404. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7405. res.Output = resSixteen10265.Output
  7406. res.ErrMsg = resSixteen10265.ErrMsg
  7407. res.Cainfo = resSixteen10265.Cainfo
  7408. res.WarnMsg = resSixteen10265.WarnMsg
  7409. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7410. res.Infcode = infocode
  7411. } else {
  7412. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7413. var dat map[string]interface{}
  7414. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7415. fmt.Println(dat)
  7416. } else {
  7417. fmt.Println(err)
  7418. }
  7419. saveLog(result, src_resquest, "2208", "退费")
  7420. userJSONBytes, _ := json.Marshal(dat)
  7421. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7422. utils.ErrorLog("解析失败:%v", err)
  7423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7424. return
  7425. }
  7426. }
  7427. }
  7428. if res.Infcode == 0 {
  7429. var res2 ResultSix
  7430. var resSix10265 ResultSix10265
  7431. if miConfig.MdtrtareaAdmvs == "421300" {
  7432. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7433. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7434. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7435. resp3, requestErr3 := http.Get(api3)
  7436. if requestErr3 != nil {
  7437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7438. return
  7439. }
  7440. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7441. if ioErr3 != nil {
  7442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7444. return
  7445. }
  7446. var respJSON3 map[string]interface{}
  7447. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7450. return
  7451. }
  7452. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7453. userJSONBytes3, _ := json.Marshal(respJSON3)
  7454. fmt.Println("log")
  7455. fmt.Println(string(userJSONBytes3))
  7456. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7457. utils.ErrorLog("解析失败:%v", err)
  7458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7459. return
  7460. }
  7461. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7462. var api3 string
  7463. if miConfig.MdtrtareaAdmvs == "320921" {
  7464. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7465. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7466. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7467. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7468. } else {
  7469. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7470. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7471. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7472. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7473. }
  7474. resp3, requestErr3 := http.Get(api3)
  7475. if requestErr3 != nil {
  7476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7477. return
  7478. }
  7479. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7480. if ioErr3 != nil {
  7481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7483. return
  7484. }
  7485. var respJSON3 map[string]interface{}
  7486. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7489. return
  7490. }
  7491. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7492. userJSONBytes3, _ := json.Marshal(respJSON3)
  7493. fmt.Println("log")
  7494. fmt.Println(string(userJSONBytes3))
  7495. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7496. utils.ErrorLog("解析失败:%v", err)
  7497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7498. return
  7499. }
  7500. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7501. res2.Output = resSix10265.Output
  7502. res2.ErrMsg = resSix10265.ErrMsg
  7503. res2.Cainfo = resSix10265.Cainfo
  7504. res2.WarnMsg = resSix10265.WarnMsg
  7505. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7506. res2.Infcode = infocode
  7507. } else {
  7508. if miConfig.Code == "H15049901371" {
  7509. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7510. var dat map[string]interface{}
  7511. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7512. fmt.Println(dat)
  7513. } else {
  7514. fmt.Println(err)
  7515. }
  7516. saveLog(result2, src_request, "2205", "撤销明细")
  7517. userJSONBytes, _ := json.Marshal(dat)
  7518. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7519. utils.ErrorLog("解析失败:%v", err)
  7520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7521. return
  7522. }
  7523. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7524. res2.Output = resSix10265.Output
  7525. res2.ErrMsg = resSix10265.ErrMsg
  7526. res2.Cainfo = resSix10265.Cainfo
  7527. res2.WarnMsg = resSix10265.WarnMsg
  7528. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7529. res2.Infcode = infocode
  7530. } else {
  7531. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7532. var dat map[string]interface{}
  7533. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7534. fmt.Println(dat)
  7535. } else {
  7536. fmt.Println(err)
  7537. }
  7538. saveLog(result2, src_request, "2205", "撤销明细")
  7539. userJSONBytes, _ := json.Marshal(dat)
  7540. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7541. utils.ErrorLog("解析失败:%v", err)
  7542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7543. return
  7544. }
  7545. }
  7546. }
  7547. if res2.Infcode == 0 {
  7548. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7549. if err == nil {
  7550. c.ServeSuccessJSON(map[string]interface{}{
  7551. "msg": "退费成功",
  7552. })
  7553. } else {
  7554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7555. return
  7556. }
  7557. } else {
  7558. c.ServeSuccessJSON(map[string]interface{}{
  7559. "code": -10,
  7560. "msg": res2.ErrMsg,
  7561. })
  7562. }
  7563. } else {
  7564. c.ServeSuccessJSON(map[string]interface{}{
  7565. "code": -10,
  7566. "msg": res.ErrMsg,
  7567. })
  7568. }
  7569. }
  7570. }
  7571. func (c *HisApiController) RefundNumber() {
  7572. record_time := c.GetString("record_time")
  7573. //patient_id, _ := c.GetInt64("patient_id")
  7574. admin_user_id, _ := c.GetInt64("admin_user_id")
  7575. his_patient_id, _ := c.GetInt64("id")
  7576. timeLayout := "2006-01-02"
  7577. loc, _ := time.LoadLocation("Local")
  7578. adminUser := c.GetAdminUserInfo()
  7579. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7580. fmt.Println(err)
  7581. if err != nil {
  7582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7583. return
  7584. }
  7585. recordDateTime := theTime.Unix()
  7586. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7587. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7588. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7589. //order, _ := service.GetHisOrderByID(order_id)
  7590. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7591. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7592. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7593. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7594. if count > 0 {
  7595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7596. return
  7597. }
  7598. if config.IsOpen == 1 { //对接了医保,走医保流程
  7599. var res2 ResultSix
  7600. var resSix10265 ResultSix10265
  7601. if miConfig.MdtrtareaAdmvs == "421300" {
  7602. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7603. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7604. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7605. resp3, requestErr3 := http.Get(api3)
  7606. if requestErr3 != nil {
  7607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7608. return
  7609. }
  7610. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7611. if ioErr3 != nil {
  7612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7614. return
  7615. }
  7616. var respJSON3 map[string]interface{}
  7617. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7620. return
  7621. }
  7622. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7623. userJSONBytes3, _ := json.Marshal(respJSON3)
  7624. fmt.Println("log")
  7625. fmt.Println(string(userJSONBytes3))
  7626. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7627. utils.ErrorLog("解析失败:%v", err)
  7628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7629. return
  7630. }
  7631. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7632. var api3 string
  7633. if miConfig.MdtrtareaAdmvs == "320921" {
  7634. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7635. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7636. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7637. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7638. } else {
  7639. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7640. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7641. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7642. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7643. }
  7644. resp3, requestErr3 := http.Get(api3)
  7645. if requestErr3 != nil {
  7646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7647. return
  7648. }
  7649. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7650. if ioErr3 != nil {
  7651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7653. return
  7654. }
  7655. var respJSON3 map[string]interface{}
  7656. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7659. return
  7660. }
  7661. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7662. userJSONBytes3, _ := json.Marshal(respJSON3)
  7663. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7664. utils.ErrorLog("解析失败:%v", err)
  7665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7666. return
  7667. }
  7668. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7669. res2.Output = resSix10265.Output
  7670. res2.ErrMsg = resSix10265.ErrMsg
  7671. res2.Cainfo = resSix10265.Cainfo
  7672. res2.WarnMsg = resSix10265.WarnMsg
  7673. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7674. res2.Infcode = infocode
  7675. } else {
  7676. var api3 string
  7677. if miConfig.Code == "H15049901371" {
  7678. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7679. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7680. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7681. } else {
  7682. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7683. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7684. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7685. }
  7686. resp3, requestErr3 := http.Get(api3)
  7687. if requestErr3 != nil {
  7688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7689. return
  7690. }
  7691. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7692. if ioErr3 != nil {
  7693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7695. return
  7696. }
  7697. var respJSON3 map[string]interface{}
  7698. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7701. return
  7702. }
  7703. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7704. userJSONBytes3, _ := json.Marshal(respJSON3)
  7705. if miConfig.Code == "H15049901371" {
  7706. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7707. utils.ErrorLog("解析失败:%v", err)
  7708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7709. return
  7710. }
  7711. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7712. res2.Output = resSix10265.Output
  7713. res2.ErrMsg = resSix10265.ErrMsg
  7714. res2.Cainfo = resSix10265.Cainfo
  7715. res2.WarnMsg = resSix10265.WarnMsg
  7716. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7717. res2.Infcode = infocode
  7718. } else {
  7719. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7720. utils.ErrorLog("解析失败:%v", err)
  7721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7722. return
  7723. }
  7724. }
  7725. }
  7726. if res2.Infcode == 0 {
  7727. if err == nil {
  7728. c.ServeSuccessJSON(map[string]interface{}{
  7729. "msg": "退号成功",
  7730. })
  7731. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7732. } else {
  7733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7734. return
  7735. }
  7736. } else {
  7737. c.ServeSuccessJSON(map[string]interface{}{
  7738. "code": -10,
  7739. "msg": res2.ErrMsg,
  7740. })
  7741. }
  7742. } else {
  7743. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7744. //if err == nil {
  7745. // c.ServeSuccessJSON(map[string]interface{}{
  7746. // "msg": "退费成功",
  7747. // })
  7748. //} else {
  7749. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7750. // return
  7751. //}
  7752. }
  7753. }
  7754. func (c *HisApiController) RefundDetail() {
  7755. order_id, _ := c.GetInt64("order_id")
  7756. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7757. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7758. number := c.GetString("number")
  7759. record_time := c.GetString("record_time")
  7760. patient_id, _ := c.GetInt64("patient_id")
  7761. //med_type, _ := c.GetInt64("med_type")
  7762. timeLayout := "2006-01-02"
  7763. loc, _ := time.LoadLocation("Local")
  7764. adminUser := c.GetAdminUserInfo()
  7765. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7766. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7767. fmt.Println(err)
  7768. if err != nil {
  7769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7770. return
  7771. }
  7772. recordDateTime := theTime.Unix()
  7773. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7774. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7775. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7776. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7777. var order models.HisOrder
  7778. order, _ = service.GetHisOrderByID(order_id)
  7779. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7780. if config.IsOpen == 1 { //对接了医保,走医保流程
  7781. var res2 ResultSix
  7782. if miConfig.MdtrtareaAdmvs == "421300" {
  7783. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7784. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7785. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7786. resp3, requestErr3 := http.Get(api3)
  7787. if requestErr3 != nil {
  7788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7789. return
  7790. }
  7791. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7792. if ioErr3 != nil {
  7793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7795. return
  7796. }
  7797. var respJSON3 map[string]interface{}
  7798. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7801. return
  7802. }
  7803. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7804. userJSONBytes3, _ := json.Marshal(respJSON3)
  7805. fmt.Println("log")
  7806. fmt.Println(string(userJSONBytes3))
  7807. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7808. utils.ErrorLog("解析失败:%v", err)
  7809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7810. return
  7811. }
  7812. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7813. if err == nil {
  7814. c.ServeSuccessJSON(map[string]interface{}{
  7815. "msg": "撤销明细成功",
  7816. })
  7817. return
  7818. } else {
  7819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7820. return
  7821. }
  7822. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7823. var resSix10265 ResultSix10265
  7824. var api3 string
  7825. if miConfig.MdtrtareaAdmvs == "320921" {
  7826. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7827. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7828. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7829. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7830. } else {
  7831. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7832. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7833. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7834. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7835. }
  7836. resp3, requestErr3 := http.Get(api3)
  7837. if requestErr3 != nil {
  7838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7839. return
  7840. }
  7841. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7842. if ioErr3 != nil {
  7843. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7845. return
  7846. }
  7847. var respJSON3 map[string]interface{}
  7848. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7849. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7851. return
  7852. }
  7853. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7854. userJSONBytes3, _ := json.Marshal(respJSON3)
  7855. fmt.Println("log")
  7856. fmt.Println(string(userJSONBytes3))
  7857. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7858. utils.ErrorLog("解析失败:%v", err)
  7859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7860. return
  7861. }
  7862. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7863. res2.Output = resSix10265.Output
  7864. res2.ErrMsg = resSix10265.ErrMsg
  7865. res2.Cainfo = resSix10265.Cainfo
  7866. res2.WarnMsg = resSix10265.WarnMsg
  7867. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7868. res2.Infcode = infocode
  7869. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7870. if err == nil {
  7871. c.ServeSuccessJSON(map[string]interface{}{
  7872. "msg": "撤销明细成功",
  7873. })
  7874. return
  7875. } else {
  7876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7877. return
  7878. }
  7879. } else {
  7880. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7881. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7882. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7883. resp2, requestErr2 := http.Get(api2)
  7884. if requestErr2 != nil {
  7885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7886. return
  7887. }
  7888. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7889. if ioErr2 != nil {
  7890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7892. return
  7893. }
  7894. var respJSON2 map[string]interface{}
  7895. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7898. return
  7899. }
  7900. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7901. if err == nil {
  7902. c.ServeSuccessJSON(map[string]interface{}{
  7903. "msg": "撤销明细成功",
  7904. })
  7905. return
  7906. } else {
  7907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7908. return
  7909. }
  7910. }
  7911. } else {
  7912. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7913. if err == nil {
  7914. c.ServeSuccessJSON(map[string]interface{}{
  7915. "msg": "退费成功",
  7916. })
  7917. } else {
  7918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7919. return
  7920. }
  7921. }
  7922. }
  7923. //对账
  7924. func (c *HisApiController) GetCheckAccount() {
  7925. start_time := c.GetString("start_time")
  7926. end_time := c.GetString("end_time")
  7927. insutype := c.GetString("insutype")
  7928. clr_type := c.GetString("clr_type")
  7929. clr_org := c.GetString("clr_optins")
  7930. admin_user_id, _ := c.GetInt64("admin_user_id")
  7931. adminUser := c.GetAdminUserInfo()
  7932. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7933. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7934. if len(clr_org) == 0 {
  7935. clr_org = miConfig.MdtrtareaAdmvs
  7936. }
  7937. timeLayout := "2006-01-02"
  7938. loc, _ := time.LoadLocation("Local")
  7939. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7940. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7941. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7942. fixmedins_setl_cnt := int64(len(orders))
  7943. var medfee_sumamt float64
  7944. var acct_pay float64
  7945. var fund_pay_sumamt float64
  7946. for _, item := range orders {
  7947. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7948. acct_pay = acct_pay + item.AcctPay
  7949. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7950. }
  7951. var user_name string
  7952. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7953. if role.ID == 0 {
  7954. user_name = "xxx"
  7955. } else {
  7956. user_name = role.UserName
  7957. }
  7958. var res ResultEight
  7959. var res10188 ResultEightFor10188
  7960. if config.IsOpen == 1 {
  7961. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7962. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7963. "insutype=" + insutype +
  7964. "&clr_type=" + "11" +
  7965. "&setl_optins=" + clr_org +
  7966. "&stmt_begndate=" + start_time +
  7967. "&stm_enddate=" + end_time +
  7968. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7969. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7970. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7971. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7972. "&fixmedins_code=" + miConfig.Code +
  7973. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7974. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7975. "&secret_key=" + miConfig.SecretKey +
  7976. "&org_name=" + miConfig.OrgName +
  7977. "&doctor=" + user_name +
  7978. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7979. fmt.Println(api)
  7980. resp, requestErr := http.Get(api)
  7981. if requestErr != nil {
  7982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7983. return
  7984. }
  7985. body, ioErr := ioutil.ReadAll(resp.Body)
  7986. fmt.Println(body)
  7987. if ioErr != nil {
  7988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7990. return
  7991. }
  7992. var respJSON map[string]interface{}
  7993. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7996. return
  7997. }
  7998. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7999. userJSONBytes, _ := json.Marshal(respJSON)
  8000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8001. utils.ErrorLog("解析失败:%v", err)
  8002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8003. return
  8004. }
  8005. res.InfRefmsgid = res10188.InfRefmsgid
  8006. res.Output = res10188.Output
  8007. res.ErrMsg = res10188.ErrMsg
  8008. res.Cainfo = res10188.Cainfo
  8009. res.WarnMsg = res10188.WarnMsg
  8010. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8011. res.Infcode = infocode
  8012. } else {
  8013. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8014. "insutype=" + insutype +
  8015. "&clr_type=" + clr_type +
  8016. "&setl_optins=" + clr_org +
  8017. "&stmt_begndate=" + start_time +
  8018. "&stm_enddate=" + end_time +
  8019. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8020. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8021. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8022. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8023. "&fixmedins_code=" + miConfig.Code +
  8024. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8025. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8026. "&secret_key=" + miConfig.SecretKey +
  8027. "&org_name=" + miConfig.OrgName +
  8028. "&doctor=" + user_name
  8029. fmt.Println(api)
  8030. resp, requestErr := http.Get(api)
  8031. if requestErr != nil {
  8032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8033. return
  8034. }
  8035. body, ioErr := ioutil.ReadAll(resp.Body)
  8036. fmt.Println(body)
  8037. if ioErr != nil {
  8038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8040. return
  8041. }
  8042. var respJSON map[string]interface{}
  8043. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8046. return
  8047. }
  8048. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8049. userJSONBytes, _ := json.Marshal(respJSON)
  8050. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8051. utils.ErrorLog("解析失败:%v", err)
  8052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8053. return
  8054. }
  8055. }
  8056. if res.Infcode == 0 {
  8057. if res.Output.Stmtinfo.StmtRslt == "0" {
  8058. micc := &models.MedicalInsuranceCostCompare{
  8059. StartTime: startime.Unix(),
  8060. EndTime: endtime.Unix(),
  8061. Insutype: insutype,
  8062. CheckType: 1,
  8063. Num: fixmedins_setl_cnt,
  8064. Mtime: time.Now().Unix(),
  8065. Status: 1,
  8066. UserOrgId: adminUser.CurrentOrgId,
  8067. CostTotal: medfee_sumamt,
  8068. FuncTotal: fund_pay_sumamt,
  8069. PsnPay: acct_pay,
  8070. Creator: admin_user_id,
  8071. Ctime: time.Now().Unix(),
  8072. ClrType: clr_type,
  8073. }
  8074. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8075. if err == nil {
  8076. c.ServeSuccessJSON(map[string]interface{}{
  8077. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8078. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8079. })
  8080. } else {
  8081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8082. }
  8083. } else {
  8084. c.ServeSuccessJSON(map[string]interface{}{
  8085. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8086. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8087. })
  8088. }
  8089. } else {
  8090. c.ServeSuccessJSON(map[string]interface{}{
  8091. "code": -10,
  8092. "msg": res.ErrMsg,
  8093. })
  8094. }
  8095. }
  8096. }
  8097. func (c *HisApiController) Check310() {
  8098. adminUser := c.GetAdminUserInfo()
  8099. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8100. var user_name string
  8101. user_name = "高慧裕"
  8102. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8103. "insutype=" + "310" +
  8104. "&clr_type=" + "" +
  8105. "&setl_optins=" + "441202" +
  8106. "&stmt_begndate=" + "2022-03-01" +
  8107. "&stm_enddate=" + "2022-03-31" +
  8108. "&medfee_sumamt=" + "194930.12" +
  8109. "&fund_pay_sumamt=" + "188741.46" +
  8110. "&acct_pay=" + "0" +
  8111. "&fixmedins_setl_cnt=" + "452" +
  8112. "&fixmedins_code=" + miConfig.Code +
  8113. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8114. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8115. "&secret_key=" + miConfig.SecretKey +
  8116. "&org_name=" + miConfig.OrgName +
  8117. "&doctor=" + user_name
  8118. fmt.Println(api)
  8119. resp, requestErr := http.Get(api)
  8120. if requestErr != nil {
  8121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8122. return
  8123. }
  8124. body, ioErr := ioutil.ReadAll(resp.Body)
  8125. fmt.Println(body)
  8126. if ioErr != nil {
  8127. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8129. return
  8130. }
  8131. var respJSON map[string]interface{}
  8132. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8135. return
  8136. }
  8137. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8138. userJSONBytes, _ := json.Marshal(respJSON)
  8139. var res ResultEight
  8140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8141. utils.ErrorLog("解析失败:%v", err)
  8142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8143. return
  8144. }
  8145. }
  8146. func (c *HisApiController) Check390() {
  8147. adminUser := c.GetAdminUserInfo()
  8148. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8149. var user_name string
  8150. user_name = "高慧裕"
  8151. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8152. "insutype=" + "390" +
  8153. "&clr_type=" + "" +
  8154. "&setl_optins=" + "441202" +
  8155. "&stmt_begndate=" + "2022-03-01" +
  8156. "&stm_enddate=" + "2022-03-31" +
  8157. "&medfee_sumamt=" + "1068448.89" +
  8158. "&fund_pay_sumamt=" + "1014677.62" +
  8159. "&acct_pay=" + "0" +
  8160. "&fixmedins_setl_cnt=" + "1950" +
  8161. "&fixmedins_code=" + miConfig.Code +
  8162. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8163. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8164. "&secret_key=" + miConfig.SecretKey +
  8165. "&org_name=" + miConfig.OrgName +
  8166. "&doctor=" + user_name
  8167. fmt.Println(api)
  8168. resp, requestErr := http.Get(api)
  8169. if requestErr != nil {
  8170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8171. return
  8172. }
  8173. body, ioErr := ioutil.ReadAll(resp.Body)
  8174. fmt.Println(body)
  8175. if ioErr != nil {
  8176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8178. return
  8179. }
  8180. var respJSON map[string]interface{}
  8181. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8184. return
  8185. }
  8186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8187. userJSONBytes, _ := json.Marshal(respJSON)
  8188. var res ResultEight
  8189. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8190. utils.ErrorLog("解析失败:%v", err)
  8191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8192. return
  8193. }
  8194. }
  8195. //对账明细
  8196. func (c *HisApiController) GetCheckDetailAccount() {
  8197. start_time := c.GetString("start_time")
  8198. end_time := c.GetString("end_time")
  8199. admin_user_id, _ := c.GetInt64("admin_user_id")
  8200. adminUser := c.GetAdminUserInfo()
  8201. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8202. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8203. timeLayout := "2006-01-02"
  8204. loc, _ := time.LoadLocation("Local")
  8205. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8206. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8207. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8208. Mkdir(miConfig.OrgName)
  8209. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  8210. file_name := file + ".txt"
  8211. zip_name := file + ".zip"
  8212. zip_path := miConfig.OrgName + "/" + zip_name
  8213. file_path := miConfig.OrgName + "/" + file_name
  8214. decimal.DivisionPrecision = 2
  8215. var medfee_sumamt float64
  8216. var psn_cash_pay float64
  8217. var fund_pay_sumamt float64
  8218. fixmedins_setl_cnt := int64(len(orders))
  8219. for _, item := range orders {
  8220. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8221. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8222. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8223. }
  8224. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8225. defer f.Close()
  8226. if err != nil {
  8227. fmt.Println(err.Error())
  8228. } else {
  8229. for _, item := range orders {
  8230. var refd_setl_flag string
  8231. if item.OrderStatus == 2 {
  8232. refd_setl_flag = "0"
  8233. var str string
  8234. str = item.SetlId + " " +
  8235. item.MdtrtId + " " +
  8236. item.PsnNo + " " +
  8237. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8238. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8239. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8240. _, err = f.Write([]byte(str))
  8241. }
  8242. if item.OrderStatus == 3 {
  8243. var str string
  8244. str = item.SetlId + " " +
  8245. item.MdtrtId + " " +
  8246. item.PsnNo + " " +
  8247. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8248. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8249. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8250. _, err = f.Write([]byte(str))
  8251. var str2 string
  8252. str2 = item.SetlId + " " +
  8253. item.MdtrtId + " " +
  8254. item.PsnNo + " " +
  8255. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8256. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8257. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8258. _, err = f.Write([]byte(str2))
  8259. }
  8260. }
  8261. }
  8262. Zip(file_path, zip_path)
  8263. fmt.Println(ReadFile(zip_path))
  8264. fmt.Println(string(ReadFile(zip_path)))
  8265. if config.IsOpen == 1 {
  8266. var user_name string
  8267. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8268. if role.ID == 0 {
  8269. user_name = "管理员"
  8270. } else {
  8271. user_name = role.UserName
  8272. }
  8273. baseParams := models.BaseParams{
  8274. SecretKey: miConfig.SecretKey,
  8275. FixmedinsCode: miConfig.Code,
  8276. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8277. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8278. OrgName: miConfig.OrgName,
  8279. Doctor: user_name,
  8280. }
  8281. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  8282. var dat map[string]interface{}
  8283. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8284. fmt.Println(dat)
  8285. } else {
  8286. fmt.Println(err)
  8287. }
  8288. userJSONBytes, _ := json.Marshal(dat)
  8289. var res ResultNine
  8290. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8291. utils.ErrorLog("解析失败:%v", err)
  8292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8293. return
  8294. }
  8295. if res.Infcode == 0 {
  8296. fileNo := res.Output.FileQuryNo
  8297. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8298. "file_qury_no=" + fileNo +
  8299. "&setl_optins=" + "定点医保中心" +
  8300. "&stmt_begndate=" + start_time +
  8301. "&stm_enddate=" + end_time +
  8302. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8303. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8304. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8305. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8306. "&fixmedins_code=" + miConfig.Code +
  8307. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8308. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8309. "&secret_key=" + miConfig.SecretKey +
  8310. "&org_name=" + miConfig.OrgName +
  8311. "&doctor=" + user_name
  8312. resp, requestErr := http.Get(api)
  8313. if requestErr != nil {
  8314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8315. return
  8316. }
  8317. body, ioErr := ioutil.ReadAll(resp.Body)
  8318. if ioErr != nil {
  8319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8321. return
  8322. }
  8323. var respJSON map[string]interface{}
  8324. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8327. return
  8328. }
  8329. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8330. userJSONBytes, _ := json.Marshal(respJSON)
  8331. var res ResultTen
  8332. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8333. utils.ErrorLog("解析失败:%v", err)
  8334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8335. return
  8336. }
  8337. if res.Infcode == 0 {
  8338. service.Gdyb9102(baseParams, zip_name, fileNo)
  8339. micc := &models.MedicalInsuranceCostCompare{
  8340. StartTime: startime.Unix(),
  8341. EndTime: endtime.Unix(),
  8342. Insutype: "0",
  8343. CheckType: 2,
  8344. Num: fixmedins_setl_cnt,
  8345. Mtime: time.Now().Unix(),
  8346. Status: 1,
  8347. UserOrgId: adminUser.CurrentOrgId,
  8348. CostTotal: medfee_sumamt,
  8349. FuncTotal: fund_pay_sumamt,
  8350. PsnPay: psn_cash_pay,
  8351. Creator: admin_user_id,
  8352. Ctime: time.Now().Unix(),
  8353. }
  8354. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8355. c.ServeSuccessJSON(map[string]interface{}{
  8356. "msg": "明细对账成功",
  8357. })
  8358. }
  8359. } else {
  8360. }
  8361. }
  8362. }
  8363. type CustomOrderInfo struct {
  8364. Name string
  8365. Spec string
  8366. Unit string
  8367. Count float64
  8368. Price float64
  8369. Total float64
  8370. }
  8371. func (c *HisApiController) GetSettleAccounts() {
  8372. //id, _ := c.GetInt64("id")
  8373. //record_time := c.GetString("record_time")
  8374. order_id, _ := c.GetInt64("order_id")
  8375. admin_user_id, _ := c.GetInt64("admin_user_id")
  8376. //timeLayout := "2006-01-02"
  8377. //loc, _ := time.LoadLocation("Local")
  8378. //
  8379. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8380. //if err != nil {
  8381. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8382. // return
  8383. //}
  8384. //recordDateTime := theTime.Unix()
  8385. adminUser := c.GetAdminUserInfo()
  8386. order, _ := service.GetHisOrderByID(order_id)
  8387. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8388. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8389. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8390. orderInfos = append(orderInfos, orderInfos_two...)
  8391. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8392. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8393. var diagnosis_ids []string
  8394. if his.ID > 0 {
  8395. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8396. } else {
  8397. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8398. }
  8399. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8400. var dia_config []*models.HisXtDiagnoseConfig
  8401. var name string
  8402. for _, item := range diagnosis_ids {
  8403. id, _ := strconv.ParseInt(item, 10, 64)
  8404. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8405. dia_config = append(dia_config, &diagnosisConfig)
  8406. if len(name) == 0 {
  8407. name = diagnosisConfig.ClassName
  8408. } else {
  8409. name = name + "," + diagnosisConfig.ClassName
  8410. }
  8411. }
  8412. var bedCostTotal float64 = 0 //床位总费
  8413. var bedCostSelfTotal float64 = 0 //床位自费
  8414. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8415. var operationCostTotal float64 = 0 //手术费
  8416. var operationCostSelfTotal float64 = 0 //手术费
  8417. var operationCostPartSelfTotal float64 = 0 //手术费
  8418. var otherCostTotal float64 = 0 //其他费用
  8419. var otherCostSelfTotal float64 = 0 //其他费用
  8420. var otherCostPartSelfTotal float64 = 0 //其他费用
  8421. var materialCostTotal float64 = 0 //材料费
  8422. var materialCostSelfTotal float64 = 0 //材料费
  8423. var materialCostPartSelfTotal float64 = 0 //材料费
  8424. var westernMedicineCostTotal float64 = 0 //西药费
  8425. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8426. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8427. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8428. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8429. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8430. var checkCostTotal float64 = 0 //检查费
  8431. var checkCostSelfTotal float64 = 0 //检查费
  8432. var checkCostPartSelfTotal float64 = 0 //检查费
  8433. var laboratoryCostTotal float64 = 0 //化验费
  8434. var laboratoryCostSelfTotal float64 = 0 //化验费
  8435. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8436. var treatCostTotal float64 = 0 //治疗费用
  8437. var treatCostSelfTotal float64 = 0 //治疗费用
  8438. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8439. decimal.DivisionPrecision = 2
  8440. for _, item := range orderInfos {
  8441. if item.MedChrgitmType == "01" { //床位费
  8442. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8443. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8444. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8445. }
  8446. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8447. if item.MedChrgitmType == "03" { //检查费
  8448. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8449. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8450. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8451. }
  8452. } else {
  8453. if item.MedChrgitmType == "03" { //检查费
  8454. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8455. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8456. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8457. }
  8458. }
  8459. if item.MedChrgitmType == "04" { //化验费
  8460. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8461. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8462. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8463. }
  8464. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8465. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8466. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8467. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8468. }
  8469. if item.MedChrgitmType == "06" { //手术费
  8470. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8471. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8472. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8473. }
  8474. if item.MedChrgitmType == "08" { //材料费
  8475. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8476. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8477. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8478. }
  8479. if item.MedChrgitmType == "09" { //西药费
  8480. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8481. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8482. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8483. }
  8484. if item.MedChrgitmType == "11" { //中成费
  8485. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8486. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8487. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8488. }
  8489. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8490. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8491. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8492. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8493. }
  8494. }
  8495. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8496. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8497. var user_name string
  8498. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8499. if role.ID == 0 {
  8500. user_name = "管理员"
  8501. } else {
  8502. user_name = role.UserName
  8503. }
  8504. baseParams := models.BaseParams{
  8505. SecretKey: miConfig.SecretKey,
  8506. FixmedinsCode: miConfig.Code,
  8507. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8508. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8509. OrgName: miConfig.OrgName,
  8510. Doctor: user_name,
  8511. }
  8512. businessParams := models.BusinessParams{
  8513. PsnNo: order.PsnNo,
  8514. MdtrtId: order.MdtrtId,
  8515. SetlId: order.SetlId,
  8516. }
  8517. var res ResultEleven
  8518. var resEleven10265 ResultEleven10265
  8519. if config.IsOpen == 1 {
  8520. if miConfig.MdtrtareaAdmvs == "421300" {
  8521. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8522. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8523. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8524. resp, requestErr := http.Get(api)
  8525. if requestErr != nil {
  8526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8527. return
  8528. }
  8529. body, ioErr := ioutil.ReadAll(resp.Body)
  8530. if ioErr != nil {
  8531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8533. return
  8534. }
  8535. var respJSON map[string]interface{}
  8536. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8539. return
  8540. }
  8541. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8542. result, _ := json.Marshal(respJSON)
  8543. fmt.Println("log")
  8544. fmt.Println(string(result))
  8545. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8546. utils.ErrorLog("解析失败:%v", err)
  8547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8548. return
  8549. }
  8550. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8551. var api string
  8552. if miConfig.MdtrtareaAdmvs == "320921" {
  8553. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8554. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8555. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8556. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8557. } else {
  8558. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8559. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8560. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8561. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8562. }
  8563. resp, requestErr := http.Get(api)
  8564. if requestErr != nil {
  8565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8566. return
  8567. }
  8568. body, ioErr := ioutil.ReadAll(resp.Body)
  8569. if ioErr != nil {
  8570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8572. return
  8573. }
  8574. var respJSON map[string]interface{}
  8575. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8578. return
  8579. }
  8580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8581. result, _ := json.Marshal(respJSON)
  8582. fmt.Println("log")
  8583. fmt.Println(string(result))
  8584. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8585. utils.ErrorLog("解析失败:%v", err)
  8586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8587. return
  8588. }
  8589. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8590. res.Output = resEleven10265.Output
  8591. res.ErrMsg = resEleven10265.ErrMsg
  8592. res.Cainfo = resEleven10265.Cainfo
  8593. res.WarnMsg = resEleven10265.WarnMsg
  8594. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8595. res.Infcode = infocode
  8596. } else {
  8597. //result2 := service.Gdyb1101()
  8598. //result2 := service.Gdyb5204(baseParams, businessParams)
  8599. //saveLog(result2, "", "5204", "查询")
  8600. result := service.Gdyb5203(baseParams, businessParams)
  8601. var dat map[string]interface{}
  8602. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8603. fmt.Println(dat)
  8604. } else {
  8605. fmt.Println(err)
  8606. }
  8607. userJSONBytes, _ := json.Marshal(dat)
  8608. if miConfig.Code == "H15049901371" {
  8609. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8610. utils.ErrorLog("解析失败:%v", err)
  8611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8612. return
  8613. }
  8614. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8615. res.Output = resEleven10265.Output
  8616. res.ErrMsg = resEleven10265.ErrMsg
  8617. res.Cainfo = resEleven10265.Cainfo
  8618. res.WarnMsg = resEleven10265.WarnMsg
  8619. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8620. res.Infcode = infocode
  8621. } else {
  8622. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8623. utils.ErrorLog("解析失败:%v", err)
  8624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8625. return
  8626. }
  8627. }
  8628. }
  8629. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8630. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8631. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8632. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8633. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8634. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8635. var doctor_name string
  8636. if roles.ID == 0 {
  8637. doctor_name = "管理员"
  8638. } else {
  8639. doctor_name = roles.UserName
  8640. }
  8641. yiliao_leibie := ""
  8642. switch order.MedType {
  8643. case "11":
  8644. yiliao_leibie = "普通门诊"
  8645. break
  8646. case "12":
  8647. yiliao_leibie = "门诊挂号"
  8648. break
  8649. case "13":
  8650. yiliao_leibie = "急诊"
  8651. break
  8652. case "14":
  8653. yiliao_leibie = "门诊特殊病"
  8654. break
  8655. case "15":
  8656. yiliao_leibie = "门诊统筹"
  8657. break
  8658. case "16":
  8659. yiliao_leibie = "门诊慢性病"
  8660. break
  8661. case "21":
  8662. yiliao_leibie = "普通住院"
  8663. break
  8664. }
  8665. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8666. if res.Infcode == 0 {
  8667. c.ServeSuccessJSON(map[string]interface{}{
  8668. "diagnosis": name,
  8669. "order_infos": orderInfos,
  8670. "number": order.MdtrtId,
  8671. "date": order.SettleAccountsDate,
  8672. "charge_admin": charge_admin,
  8673. "printor_admin": printor_admin,
  8674. "info": res.Output.Setlinfo,
  8675. "order": order,
  8676. "bedCostTotal": bedCostTotal,
  8677. "bedCostSelfTotal": bedCostSelfTotal,
  8678. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8679. "operationCostTotal": operationCostTotal,
  8680. "operationCostSelfTotal": operationCostSelfTotal,
  8681. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8682. "otherCostTotal": otherCostTotal,
  8683. "otherCostSelfTotal": otherCostSelfTotal,
  8684. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8685. "materialCostTotal": materialCostTotal,
  8686. "materialCostSelfTotal": materialCostSelfTotal,
  8687. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8688. "westernMedicineCostTotal": westernMedicineCostTotal,
  8689. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8690. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8691. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8692. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8693. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8694. "checkCostTotal": checkCostTotal,
  8695. "checkCostSelfTotal": checkCostSelfTotal,
  8696. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8697. "laboratoryCostTotal": laboratoryCostTotal,
  8698. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8699. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8700. "treatCostTotal": treatCostTotal,
  8701. "treatCostSelfTotal": treatCostSelfTotal,
  8702. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8703. "doctor_info": doctor_info,
  8704. "doctor_code": adminRole_two.DoctorCode,
  8705. "doctor_name": doctor_name,
  8706. "health_card_no": order.PsnNo,
  8707. "department": departments.Name,
  8708. "yiliao_leibie": yiliao_leibie,
  8709. "after_money": order.AccountPrice,
  8710. "patient": patient,
  8711. "org_name": miConfig.OrgName,
  8712. "org_code": miConfig.Code,
  8713. "order_number": order.Number,
  8714. "his_hospital": his_hospital,
  8715. "his": his,
  8716. "dia_config": dia_config,
  8717. //"check_order_info": cus_slice,
  8718. })
  8719. }
  8720. }
  8721. }
  8722. func (c *HisApiController) CheckTreatment() {
  8723. patient_id, _ := c.GetInt64("patient_id")
  8724. id_card_no := c.GetString("id_card_no")
  8725. insutype := c.GetString("insutype")
  8726. med_type := c.GetString("med_type")
  8727. admin_user_id, _ := c.GetInt64("admin_user_id")
  8728. adminUser := c.GetAdminUserInfo()
  8729. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8730. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8731. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8732. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8733. if miConfig.MdtrtareaAdmvs == "421300" {
  8734. var res ResultTwo
  8735. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8736. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8737. "&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)
  8738. resp, requestErr := http.Get(api)
  8739. if requestErr != nil {
  8740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8741. return
  8742. }
  8743. body, ioErr := ioutil.ReadAll(resp.Body)
  8744. if ioErr != nil {
  8745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8747. return
  8748. }
  8749. var respJSON map[string]interface{}
  8750. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8753. return
  8754. }
  8755. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8756. result, _ := json.Marshal(respJSON)
  8757. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8758. utils.ErrorLog("解析失败:%v", err)
  8759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8760. return
  8761. }
  8762. if res.Infcode == 0 {
  8763. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8764. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8765. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8766. resp, requestErr := http.Get(api)
  8767. if requestErr != nil {
  8768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8769. return
  8770. }
  8771. body, ioErr := ioutil.ReadAll(resp.Body)
  8772. if ioErr != nil {
  8773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8775. return
  8776. }
  8777. var respJSON map[string]interface{}
  8778. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8781. return
  8782. }
  8783. var res Result2001
  8784. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8785. result2, _ := json.Marshal(respJSON)
  8786. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8787. utils.ErrorLog("解析失败:%v", err)
  8788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8789. return
  8790. }
  8791. if res.Infcode == 0 {
  8792. c.ServeSuccessJSON(map[string]interface{}{
  8793. "msg": res.Output.Trtinfo,
  8794. })
  8795. }
  8796. } else {
  8797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8798. return
  8799. }
  8800. } else {
  8801. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8802. var dat map[string]interface{}
  8803. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8804. fmt.Println(dat)
  8805. } else {
  8806. fmt.Println(err)
  8807. }
  8808. userJSONBytes, _ := json.Marshal(dat)
  8809. var res ResultTwo
  8810. var res10265 ResultTwo10265
  8811. if miConfig.Code == "H15049901371" {
  8812. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8813. utils.ErrorLog("解析失败:%v", err)
  8814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8815. return
  8816. }
  8817. res.ErrMsg = res10265.ErrMsg
  8818. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8819. res.Infcode = infocode
  8820. res.Output = res10265.Output
  8821. res.InfRefmsgid = res10265.InfRefmsgid
  8822. } else {
  8823. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8824. utils.ErrorLog("解析失败:%v", err)
  8825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8826. return
  8827. }
  8828. }
  8829. var user_name string
  8830. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8831. if role.ID == 0 {
  8832. user_name = "xxx"
  8833. } else {
  8834. user_name = role.UserName
  8835. }
  8836. baseParams := models.BaseParams{
  8837. SecretKey: miConfig.SecretKey,
  8838. FixmedinsCode: miConfig.Code,
  8839. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8840. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8841. OrgName: miConfig.OrgName,
  8842. Doctor: user_name,
  8843. }
  8844. if config.IsOpen == 1 {
  8845. if miConfig.Code == "H15049901371" {
  8846. if med_type == "14" {
  8847. if insutype == "390" {
  8848. med_type = "9933"
  8849. } else if insutype == "310" {
  8850. med_type = "990502"
  8851. }
  8852. } else if med_type == "11" {
  8853. med_type = "11"
  8854. }
  8855. }
  8856. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8857. var dat map[string]interface{}
  8858. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8859. fmt.Println(dat)
  8860. } else {
  8861. fmt.Println(err)
  8862. }
  8863. var res Result2001
  8864. var res10265 Result2001Org10265
  8865. if miConfig.Code == "H15049901371" {
  8866. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8867. utils.ErrorLog("解析失败:%v", err)
  8868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8869. return
  8870. }
  8871. res.ErrMsg = res10265.ErrMsg
  8872. res.Output = res10265.Output
  8873. res.InfRefmsgid = res10265.InfRefmsgid
  8874. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8875. res.Infcode = infocode
  8876. } else {
  8877. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8878. utils.ErrorLog("解析失败:%v", err)
  8879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8880. return
  8881. }
  8882. }
  8883. if res.Infcode == 0 {
  8884. c.ServeSuccessJSON(map[string]interface{}{
  8885. "msg": res.Output.Trtinfo,
  8886. })
  8887. }
  8888. }
  8889. }
  8890. }
  8891. //func (c *HisApiController) PutRecord() {
  8892. // id, _ := c.GetInt64("id")
  8893. // record_time := c.GetString("record_time")
  8894. // timeLayout := "2006-01-02"
  8895. // loc, _ := time.LoadLocation("Local")
  8896. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8897. // if err != nil {
  8898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8899. // return
  8900. // }
  8901. // recordDateTime := theTime.Unix()
  8902. //
  8903. // adminInfo := c.GetAdminUserInfo()
  8904. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8905. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8906. //
  8907. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8908. //
  8909. // fmt.Println(miConfig.SecretKey)
  8910. //
  8911. // if patient == nil {
  8912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8913. // return
  8914. // }
  8915. // if len(patient.IdCardNo) == 0 {
  8916. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8917. // return
  8918. // }
  8919. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8920. // if config.IsOpen == 1 {
  8921. // 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
  8922. // resp, requestErr := http.Get(api)
  8923. // if requestErr != nil {
  8924. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8925. // return
  8926. // }
  8927. // defer resp.Body.Close()
  8928. // body, ioErr := ioutil.ReadAll(resp.Body)
  8929. // if ioErr != nil {
  8930. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8931. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8932. // return
  8933. // }
  8934. // var respJSON map[string]interface{}
  8935. //
  8936. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8937. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8938. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8939. // return
  8940. // }
  8941. //
  8942. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8943. // userJSONBytes, _ := json.Marshal(userJSON)
  8944. // var res ResultTwo
  8945. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8946. // utils.ErrorLog("解析失败:%v", err)
  8947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8948. // return
  8949. // }
  8950. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8951. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8952. // infoStr := string(Iinfos)
  8953. // idetinfoStr := string(Idetinfos)
  8954. //
  8955. // if res.Infcode == 0 {
  8956. // his := models.VMHisPatient{
  8957. // Status: 1,
  8958. // Ctime: time.Now().Unix(),
  8959. // Mtime: time.Now().Unix(),
  8960. // PsnNo: res.Output.Baseinfo.PsnNo,
  8961. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8962. // Certno: res.Output.Baseinfo.Certno,
  8963. // PsnName: res.Output.Baseinfo.PsnName,
  8964. // Gend: res.Output.Baseinfo.Gend,
  8965. // Naty: res.Output.Baseinfo.Naty,
  8966. // Brdy: res.Output.Baseinfo.Brdy,
  8967. // Age: res.Output.Baseinfo.Age,
  8968. // Iinfo: infoStr,
  8969. // Idetinfo: idetinfoStr,
  8970. // PatientId: patient.ID,
  8971. // RecordDate: theTime.Unix(),
  8972. // UserOrgId: adminInfo.CurrentOrgId,
  8973. // AdminUserId: adminInfo.AdminUser.Id,
  8974. // IsReturn: 1,
  8975. // }
  8976. //
  8977. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8978. // //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")
  8979. // //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")
  8980. //
  8981. // //var dat map[string]interface{}
  8982. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8983. // // fmt.Println(dat)
  8984. // //} else {
  8985. // // fmt.Println(err)
  8986. // //}
  8987. //
  8988. // var dat2 map[string]interface{}
  8989. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8990. // fmt.Println(dat2)
  8991. // } else {
  8992. // fmt.Println(err)
  8993. // }
  8994. //
  8995. // } else {
  8996. // adminUser := c.GetAdminUserInfo()
  8997. // errlog := &models.HisOrderError{
  8998. // UserOrgId: adminUser.CurrentOrgId,
  8999. // Ctime: time.Now().Unix(),
  9000. // Mtime: time.Now().Unix(),
  9001. // ErrMsg: res.ErrMsg,
  9002. // Status: 1,
  9003. // PatientId: id,
  9004. // RecordTime: recordDateTime,
  9005. // Stage: 1,
  9006. // }
  9007. // service.CreateErrMsgLog(errlog)
  9008. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9009. // return
  9010. // }
  9011. // }
  9012. //
  9013. //}
  9014. //func (c *HisApiController) GetUploadDiag() {
  9015. // id, _ := c.GetInt64("id")
  9016. // record_time := c.GetString("record_time")
  9017. //
  9018. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9019. // sick_type, _ := c.GetInt64("sick_type")
  9020. // reg_type, _ := c.GetInt64("reg_type")
  9021. //
  9022. // timeLayout := "2006-01-02"
  9023. // loc, _ := time.LoadLocation("Local")
  9024. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9025. // if err != nil {
  9026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9027. // return
  9028. // }
  9029. //
  9030. // var patientPrescription models.HisPrescriptionInfo
  9031. // recordDateTime := theTime.Unix()
  9032. // adminInfo := c.GetAdminUserInfo()
  9033. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9034. //
  9035. // if patientPrescription.ID == 0 {
  9036. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9037. // }
  9038. //
  9039. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9040. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9041. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9042. // sickConfig, _ := service.FindSickById(sick_type)
  9043. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9044. //
  9045. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9046. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9047. // "&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 +
  9048. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9049. // resp2, requestErr2 := http.Get(api2)
  9050. // if requestErr2 != nil {
  9051. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9052. // return
  9053. // }
  9054. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9055. // if ioErr2 != nil {
  9056. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9057. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9058. // return
  9059. // }
  9060. // var respJSON2 map[string]interface{}
  9061. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9062. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9064. // return
  9065. // }
  9066. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9067. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9068. //
  9069. // var res2 ResultSix
  9070. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9071. // utils.ErrorLog("解析失败:%v", err)
  9072. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9073. // return
  9074. // }
  9075. // if res2.Infcode != 0 {
  9076. // adminUser := c.GetAdminUserInfo()
  9077. // errlog := &models.HisOrderError{
  9078. // UserOrgId: adminUser.CurrentOrgId,
  9079. // Ctime: time.Now().Unix(),
  9080. // Mtime: time.Now().Unix(),
  9081. // ErrMsg: res2.ErrMsg,
  9082. // Status: 1,
  9083. // PatientId: id,
  9084. // RecordTime: recordDateTime,
  9085. // Stage: 3,
  9086. // }
  9087. // service.CreateErrMsgLog(errlog)
  9088. //
  9089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9090. // return
  9091. // }
  9092. //
  9093. // c.ServeSuccessJSON(map[string]interface{}{
  9094. // "msg": "上传成功",
  9095. // })
  9096. //
  9097. //}
  9098. type QueryResult struct {
  9099. ID int64
  9100. Name string
  9101. Code string
  9102. List_type_code string
  9103. }
  9104. func (c *HisApiController) GetCheckCode() {
  9105. ids_str := c.GetString("ids")
  9106. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9107. ids_arr := strings.Split(ids_str, ",")
  9108. var queryResult []QueryResult
  9109. ids := make([]int64, 0)
  9110. for _, item := range ids_arr {
  9111. id, _ := strconv.ParseInt(item, 10, 64)
  9112. ids = append(ids, id)
  9113. }
  9114. if record_type == 1 {
  9115. drugs, _ := service.GetBatchDrugList(ids)
  9116. for _, item := range drugs {
  9117. result := QueryResult{
  9118. ID: item.ID,
  9119. Name: item.DrugName,
  9120. Code: item.MedicalInsuranceNumber,
  9121. List_type_code: "101",
  9122. }
  9123. queryResult = append(queryResult, result)
  9124. }
  9125. } else if record_type == 2 {
  9126. goods, _ := service.GetBatchGoodInformationList(ids)
  9127. for _, item := range goods {
  9128. result := QueryResult{
  9129. ID: item.ID,
  9130. Name: item.GoodName,
  9131. Code: item.MedicalInsuranceNumber,
  9132. List_type_code: "301",
  9133. }
  9134. queryResult = append(queryResult, result)
  9135. }
  9136. } else if record_type == 3 {
  9137. projects, _ := service.GetBathchMyPorjecgList(ids)
  9138. for _, item := range projects {
  9139. result := QueryResult{
  9140. ID: item.ID,
  9141. Name: item.ProjectName,
  9142. Code: item.MedicalCode,
  9143. List_type_code: "201",
  9144. }
  9145. queryResult = append(queryResult, result)
  9146. }
  9147. }
  9148. admin_user_id, _ := c.GetInt64("admin_user_id")
  9149. adminUser := c.GetAdminUserInfo()
  9150. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9151. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9152. var user_name string
  9153. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9154. if role.ID == 0 {
  9155. user_name = "xxx"
  9156. } else {
  9157. user_name = role.UserName
  9158. }
  9159. baseParams := &models.BaseParams{
  9160. SecretKey: miConfig.SecretKey,
  9161. FixmedinsCode: miConfig.Code,
  9162. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9163. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9164. OrgName: miConfig.OrgName,
  9165. Doctor: user_name,
  9166. }
  9167. if config.IsOpen == 1 {
  9168. for _, item := range queryResult {
  9169. var result string
  9170. if record_type == 1 {
  9171. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9172. } else if record_type == 2 {
  9173. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9174. } else if record_type == 3 {
  9175. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9176. }
  9177. var dat map[string]interface{}
  9178. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9179. fmt.Println(dat)
  9180. } else {
  9181. fmt.Println(err)
  9182. }
  9183. userJSONBytes, _ := json.Marshal(dat)
  9184. var res ResultSix
  9185. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9186. utils.ErrorLog("解析失败:%v", err)
  9187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9188. return
  9189. }
  9190. if res.Infcode == 0 {
  9191. if record_type == 1 {
  9192. service.UpdateBaseDrugById(item.ID)
  9193. } else if record_type == 2 {
  9194. service.UpdateGoodInformaitonByDetail(item.ID)
  9195. } else if record_type == 3 {
  9196. service.UpdateProjectById(item.ID)
  9197. }
  9198. c.ServeSuccessJSON(map[string]interface{}{
  9199. "failed_code": 0,
  9200. "msg": "目录对照成功",
  9201. })
  9202. } else {
  9203. c.ServeSuccessJSON(map[string]interface{}{
  9204. "failed_code": -10,
  9205. "msg": res.ErrMsg,
  9206. })
  9207. }
  9208. }
  9209. }
  9210. }
  9211. func (c *HisApiController) UnCheckCode() {
  9212. ids_str := c.GetString("ids")
  9213. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9214. admin_user_id, _ := c.GetInt64("admin_user_id")
  9215. ids_arr := strings.Split(ids_str, ",")
  9216. var queryResult []QueryResult
  9217. ids := make([]int64, 0)
  9218. for _, item := range ids_arr {
  9219. id, _ := strconv.ParseInt(item, 10, 64)
  9220. ids = append(ids, id)
  9221. }
  9222. if record_type == 1 {
  9223. drugs, _ := service.GetBatchDrugList(ids)
  9224. for _, item := range drugs {
  9225. result := QueryResult{
  9226. ID: item.ID,
  9227. Name: item.DrugName,
  9228. Code: item.MedicalInsuranceNumber,
  9229. List_type_code: "101",
  9230. }
  9231. queryResult = append(queryResult, result)
  9232. }
  9233. } else if record_type == 2 {
  9234. goods, _ := service.GetBatchGoodInformationList(ids)
  9235. for _, item := range goods {
  9236. result := QueryResult{
  9237. ID: item.ID,
  9238. Name: item.GoodName,
  9239. Code: item.MedicalInsuranceNumber,
  9240. List_type_code: "301",
  9241. }
  9242. queryResult = append(queryResult, result)
  9243. }
  9244. } else if record_type == 3 {
  9245. projects, _ := service.GetBathchMyPorjecgList(ids)
  9246. for _, item := range projects {
  9247. result := QueryResult{
  9248. ID: item.ID,
  9249. Name: item.ProjectName,
  9250. Code: item.MedicalCode,
  9251. List_type_code: "201",
  9252. }
  9253. queryResult = append(queryResult, result)
  9254. }
  9255. }
  9256. adminUser := c.GetAdminUserInfo()
  9257. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9258. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9259. var user_name string
  9260. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9261. if role.ID == 0 {
  9262. user_name = "xxx"
  9263. } else {
  9264. user_name = role.UserName
  9265. }
  9266. baseParams := &models.BaseParams{
  9267. SecretKey: miConfig.SecretKey,
  9268. FixmedinsCode: miConfig.Code,
  9269. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9270. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9271. OrgName: miConfig.OrgName,
  9272. Doctor: user_name,
  9273. }
  9274. if config.IsOpen == 1 {
  9275. for _, item := range queryResult {
  9276. var result string
  9277. if record_type == 1 {
  9278. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9279. } else if record_type == 2 {
  9280. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9281. } else if record_type == 3 {
  9282. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9283. }
  9284. var dat2 map[string]interface{}
  9285. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9286. fmt.Println(dat2)
  9287. } else {
  9288. fmt.Println(err)
  9289. }
  9290. userJSONBytes, _ := json.Marshal(dat2)
  9291. var res ResultSix
  9292. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9293. utils.ErrorLog("解析失败:%v", err)
  9294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9295. return
  9296. }
  9297. if res.Infcode == 0 {
  9298. if record_type == 1 {
  9299. service.UpdateDrugByIdDetail(item.ID)
  9300. } else if record_type == 2 {
  9301. service.UpdateGoodInfoById(item.ID)
  9302. } else if record_type == 3 {
  9303. service.UpdateMyProjectById(item.ID)
  9304. }
  9305. c.ServeSuccessJSON(map[string]interface{}{
  9306. "failed_code": 0,
  9307. "msg": "撤销目录对照成功",
  9308. })
  9309. } else {
  9310. c.ServeSuccessJSON(map[string]interface{}{
  9311. "failed_code": -10,
  9312. "msg": res.ErrMsg,
  9313. })
  9314. }
  9315. }
  9316. }
  9317. }
  9318. func (c *HisApiController) GetPatientInfo() {
  9319. id_card_no := c.GetString("id_card_no")
  9320. admin_user_id, _ := c.GetInt64("admin_user_id")
  9321. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9322. if patient.ID == 0 {
  9323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9324. return
  9325. }
  9326. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9327. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9328. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9329. if config.IsOpen == 1 {
  9330. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9331. var dat map[string]interface{}
  9332. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9333. fmt.Println(dat)
  9334. } else {
  9335. fmt.Println(err)
  9336. }
  9337. userJSONBytes, _ := json.Marshal(dat)
  9338. var res ResultTwo
  9339. var res10265 ResultTwo10265
  9340. if miConfig.Code == "H15049901371" {
  9341. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9342. utils.ErrorLog("解析失败:%v", err)
  9343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9344. return
  9345. }
  9346. res.ErrMsg = res10265.ErrMsg
  9347. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9348. res.Infcode = infocode
  9349. res.Output = res10265.Output
  9350. res.InfRefmsgid = res10265.InfRefmsgid
  9351. } else {
  9352. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9353. utils.ErrorLog("解析失败:%v", err)
  9354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9355. return
  9356. }
  9357. }
  9358. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9359. // utils.ErrorLog("解析失败:%v", err)
  9360. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9361. // return
  9362. //}
  9363. if res.Infcode != 0 {
  9364. c.ServeSuccessJSON(map[string]interface{}{
  9365. "failed_code": -10,
  9366. "msg": res.ErrMsg,
  9367. })
  9368. } else {
  9369. c.ServeSuccessJSON(map[string]interface{}{
  9370. "failed_code": 0,
  9371. "info": res,
  9372. })
  9373. }
  9374. }
  9375. }
  9376. func (c *HisApiController) PsnPutOnRecord() {
  9377. record_type, _ := c.GetInt64("type")
  9378. patient_id, _ := c.GetInt64("patient_id")
  9379. admin_user_id, _ := c.GetInt64("admin_user_id")
  9380. start_time := c.GetString("start_time")
  9381. end_time := c.GetString("end_time")
  9382. adminUser := c.GetAdminUserInfo()
  9383. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9384. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9385. var patients []*models.Patients
  9386. if record_type == 1 { //全部备案
  9387. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9388. patients = append(patients, patient...)
  9389. } else { //单个备案
  9390. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9391. patients = append(patients, patient)
  9392. }
  9393. var user_name string
  9394. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9395. if role.ID == 0 {
  9396. user_name = "xxx"
  9397. } else {
  9398. user_name = role.UserName
  9399. }
  9400. if config.IsOpen == 1 {
  9401. for _, item := range patients {
  9402. 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
  9403. resp, requestErr := http.Get(api)
  9404. if requestErr != nil {
  9405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9406. return
  9407. }
  9408. defer resp.Body.Close()
  9409. body, ioErr := ioutil.ReadAll(resp.Body)
  9410. if ioErr != nil {
  9411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9413. return
  9414. }
  9415. var respJSON map[string]interface{}
  9416. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9419. return
  9420. }
  9421. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9422. userJSONBytes, _ := json.Marshal(userJSON)
  9423. var res ResultTwo
  9424. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9425. utils.ErrorLog("解析失败:%v", err)
  9426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9427. return
  9428. }
  9429. if res.Infcode == 0 {
  9430. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9431. var dat map[string]interface{}
  9432. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9433. fmt.Println(dat)
  9434. } else {
  9435. fmt.Println(err)
  9436. }
  9437. userJSONBytes, _ := json.Marshal(dat)
  9438. var res2 ResultThirteen
  9439. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9440. utils.ErrorLog("解析失败:%v", err)
  9441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9442. return
  9443. }
  9444. if res2.Infcode == 0 {
  9445. psnResult := &models.GdybPsnRecord{
  9446. UserOrgId: adminUser.CurrentOrgId,
  9447. PatientId: item.ID,
  9448. PsnNo: res.Output.Baseinfo.PsnNo,
  9449. Ctime: time.Now().Unix(),
  9450. Mtime: time.Now().Unix(),
  9451. Status: 1,
  9452. IsCancel: 1,
  9453. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9454. }
  9455. service.CreatePsnRecord(psnResult)
  9456. } else {
  9457. c.ServeSuccessJSON(map[string]interface{}{
  9458. "failed_code": -10,
  9459. "msg": res2.ErrMsg,
  9460. })
  9461. return
  9462. }
  9463. }
  9464. }
  9465. }
  9466. }
  9467. func (c *HisApiController) PsnUnPutOnRecord() {
  9468. id, _ := c.GetInt64("id")
  9469. //record_type, _ := c.GetInt64("type")
  9470. admin_user_id, _ := c.GetInt64("admin_user_id")
  9471. adminUser := c.GetAdminUserInfo()
  9472. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9473. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9474. var user_name string
  9475. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9476. if role.ID == 0 {
  9477. user_name = "xxx"
  9478. } else {
  9479. user_name = role.UserName
  9480. }
  9481. psn_record, _ := service.GetPsnRecordById(id)
  9482. if psn_record.ID == 0 {
  9483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9484. return
  9485. }
  9486. if config.IsOpen == 1 {
  9487. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9488. var dat map[string]interface{}
  9489. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9490. fmt.Println(dat)
  9491. } else {
  9492. fmt.Println(err)
  9493. }
  9494. userJSONBytes, _ := json.Marshal(dat)
  9495. var res ResultFourteen
  9496. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9497. utils.ErrorLog("解析失败:%v", err)
  9498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9499. return
  9500. }
  9501. if res.Infcode == 0 {
  9502. psn_record.IsCancel = 2
  9503. service.CreatePsnRecord(&psn_record)
  9504. } else {
  9505. c.ServeSuccessJSON(map[string]interface{}{
  9506. "failed_code": -10,
  9507. "msg": res.ErrMsg,
  9508. })
  9509. return
  9510. }
  9511. }
  9512. }
  9513. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9514. patient_id, _ := c.GetInt64("patient_id")
  9515. insutype_two := c.GetString("insutype")
  9516. psn_no := c.GetString("psn_no")
  9517. doctor_id, _ := c.GetInt64("doctor_id")
  9518. sick_id, _ := c.GetInt64("sick_id")
  9519. department_id, _ := c.GetInt64("department_id")
  9520. start_time := c.GetString("start_time")
  9521. end_time := c.GetString("end_time")
  9522. check_time := c.GetString("check_time")
  9523. adminUser := c.GetAdminUserInfo()
  9524. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9525. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9526. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9527. sick, _ := service.FindSickById(sick_id)
  9528. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9529. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9530. var res ResultTwo
  9531. var res10265 ResultTwo10265
  9532. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9533. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9534. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9535. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9536. "&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
  9537. resp, requestErr := http.Get(api)
  9538. if requestErr != nil {
  9539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9540. return
  9541. }
  9542. body, ioErr := ioutil.ReadAll(resp.Body)
  9543. if ioErr != nil {
  9544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9546. return
  9547. }
  9548. var respJSON map[string]interface{}
  9549. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9552. return
  9553. }
  9554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9555. result, _ := json.Marshal(respJSON)
  9556. fmt.Println("log")
  9557. fmt.Println(string(result))
  9558. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9559. utils.ErrorLog("解析失败:%v", err)
  9560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9561. return
  9562. }
  9563. res.ErrMsg = res10265.ErrMsg
  9564. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9565. res.Infcode = infocode
  9566. res.Output = res10265.Output
  9567. res.InfRefmsgid = res10265.InfRefmsgid
  9568. } else {
  9569. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9570. if miConfig.Code == "H15049901371" {
  9571. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9572. utils.ErrorLog("解析失败:%v", err)
  9573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9574. return
  9575. }
  9576. res.ErrMsg = res10265.ErrMsg
  9577. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9578. res.Infcode = infocode
  9579. res.Output = res10265.Output
  9580. res.InfRefmsgid = res10265.InfRefmsgid
  9581. } else {
  9582. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9583. utils.ErrorLog("解析失败:%v", err)
  9584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9585. return
  9586. }
  9587. }
  9588. }
  9589. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9590. infoStr := string(Iinfos)
  9591. var rf []*ResultFive
  9592. json.Unmarshal([]byte(infoStr), &rf)
  9593. var insuplc_admdvs string
  9594. var insutype string
  9595. var is390 int = 0
  9596. var is310 int = 0
  9597. var insutypes []*ResultFive
  9598. for _, item := range rf {
  9599. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9600. insutypes = append(insutypes, item)
  9601. }
  9602. }
  9603. if len(insutypes) == 1 {
  9604. insutype = insutypes[0].Insutype
  9605. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9606. } else {
  9607. for _, i := range insutypes {
  9608. if i.Insutype == "390" {
  9609. is390 = 1
  9610. }
  9611. if i.Insutype == "310" {
  9612. is310 = 1
  9613. }
  9614. }
  9615. }
  9616. if is390 == 1 {
  9617. insutype = "390"
  9618. }
  9619. if is310 == 1 {
  9620. insutype = "310"
  9621. }
  9622. if len(insutypes) == 2 {
  9623. insutype = insutype_two
  9624. }
  9625. if len(insutypes) == 0 {
  9626. insutype = "310"
  9627. }
  9628. insutype = insutype_two
  9629. fmt.Println(insutype)
  9630. for _, item := range rf {
  9631. fmt.Println(item.Insutype)
  9632. fmt.Println(insutype)
  9633. if item.Insutype == insutype {
  9634. fmt.Println(item.Insutype)
  9635. fmt.Println(insutype)
  9636. insuplc_admdvs = item.InsuplcAdmdvs
  9637. }
  9638. }
  9639. fmt.Println(insuplc_admdvs)
  9640. var res2 ResultThirteen
  9641. var res10265_2 ResultThirteen10265
  9642. if config.IsOpen == 1 {
  9643. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9644. } else {
  9645. 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)
  9646. var dat map[string]interface{}
  9647. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9648. fmt.Println(dat)
  9649. } else {
  9650. fmt.Println(err)
  9651. }
  9652. userJSONBytes, _ := json.Marshal(dat)
  9653. if miConfig.Code == "H15049901371" {
  9654. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9655. utils.ErrorLog("解析失败:%v", err)
  9656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9657. return
  9658. }
  9659. res2.ErrMsg = res10265_2.ErrMsg
  9660. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9661. res2.Infcode = infocode
  9662. res2.Output = res10265_2.Output
  9663. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9664. } else {
  9665. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9666. utils.ErrorLog("解析失败:%v", err)
  9667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9668. return
  9669. }
  9670. }
  9671. }
  9672. if res2.Infcode == 0 {
  9673. psnResult := &models.GdybPsnNcdsRecord{
  9674. UserOrgId: adminUser.CurrentOrgId,
  9675. PatientId: patient.ID,
  9676. PsnNo: psn_no,
  9677. DoctorId: doctor.AdminUserId,
  9678. DepartmentId: department_id,
  9679. SickType: sick_id,
  9680. Insutype: insutype,
  9681. Ctime: time.Now().Unix(),
  9682. Mtime: time.Now().Unix(),
  9683. Status: 1,
  9684. IsCancel: 1,
  9685. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9686. }
  9687. service.CreatePsnNCDSRecord(psnResult)
  9688. c.ServeSuccessJSON(map[string]interface{}{
  9689. "failed_code": 0,
  9690. "msg": "备案成功",
  9691. "result": psnResult,
  9692. })
  9693. } else {
  9694. c.ServeSuccessJSON(map[string]interface{}{
  9695. "failed_code": -10,
  9696. "msg": res2.ErrMsg,
  9697. })
  9698. return
  9699. }
  9700. }
  9701. }
  9702. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9703. id, _ := c.GetInt64("id")
  9704. admin_user_id, _ := c.GetInt64("admin_user_id")
  9705. adminUser := c.GetAdminUserInfo()
  9706. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9707. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9708. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9709. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9710. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9711. //var user_name string
  9712. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9713. //if role.ID == 0 {
  9714. // user_name = "xxx"
  9715. //} else {
  9716. // user_name = role.UserName
  9717. //}
  9718. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9719. if psn_record.ID == 0 {
  9720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9721. return
  9722. }
  9723. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9724. var res ResultTwo
  9725. var res10265 ResultTwo10265
  9726. if miConfig.Code == "H15049901371" {
  9727. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9728. utils.ErrorLog("解析失败:%v", err)
  9729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9730. return
  9731. }
  9732. res.ErrMsg = res10265.ErrMsg
  9733. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9734. res.Infcode = infocode
  9735. res.Output = res10265.Output
  9736. res.InfRefmsgid = res10265.InfRefmsgid
  9737. } else {
  9738. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9739. utils.ErrorLog("解析失败:%v", err)
  9740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9741. return
  9742. }
  9743. }
  9744. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9745. infoStr := string(Iinfos)
  9746. var rf []*ResultFive
  9747. json.Unmarshal([]byte(infoStr), &rf)
  9748. var insuplc_admdvs string
  9749. var insutype string
  9750. var is390 int = 0
  9751. var is310 int = 0
  9752. var insutypes []*ResultFive
  9753. for _, item := range rf {
  9754. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9755. insutypes = append(insutypes, item)
  9756. }
  9757. }
  9758. if len(insutypes) == 1 {
  9759. insutype = insutypes[0].Insutype
  9760. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9761. } else {
  9762. for _, i := range insutypes {
  9763. if i.Insutype == "390" {
  9764. is390 = 1
  9765. }
  9766. if i.Insutype == "310" {
  9767. is310 = 1
  9768. }
  9769. }
  9770. }
  9771. if is390 == 1 {
  9772. insutype = "390"
  9773. }
  9774. if is310 == 1 {
  9775. insutype = "310"
  9776. }
  9777. if len(insutypes) == 0 {
  9778. insutype = "310"
  9779. }
  9780. insutype = psn_record.Insutype
  9781. for _, item := range rf {
  9782. if item.Insutype == insutype {
  9783. insuplc_admdvs = item.InsuplcAdmdvs
  9784. }
  9785. }
  9786. if config.IsOpen == 1 {
  9787. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9788. var dat map[string]interface{}
  9789. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9790. fmt.Println(dat)
  9791. } else {
  9792. fmt.Println(err)
  9793. }
  9794. userJSONBytes, _ := json.Marshal(dat)
  9795. var res ResultFourteen
  9796. var res10265 ResultFourteen10265
  9797. if miConfig.Code == "H15049901371" {
  9798. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9799. utils.ErrorLog("解析失败:%v", err)
  9800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9801. return
  9802. }
  9803. res.ErrMsg = res10265.ErrMsg
  9804. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9805. res.Infcode = infocode
  9806. res.Output = res10265.Output
  9807. res.InfRefmsgid = res10265.InfRefmsgid
  9808. } else {
  9809. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9810. utils.ErrorLog("解析失败:%v", err)
  9811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9812. return
  9813. }
  9814. }
  9815. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9816. // utils.ErrorLog("解析失败:%v", err)
  9817. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9818. // return
  9819. //}
  9820. if res.Infcode == 0 {
  9821. psn_record.IsCancel = 2
  9822. service.CreatePsnNCDSRecord(&psn_record)
  9823. c.ServeSuccessJSON(map[string]interface{}{
  9824. "failed_code": 0,
  9825. "msg": "撤销备案成功",
  9826. })
  9827. } else {
  9828. c.ServeSuccessJSON(map[string]interface{}{
  9829. "failed_code": -10,
  9830. "msg": res.ErrMsg,
  9831. })
  9832. return
  9833. }
  9834. }
  9835. }
  9836. func (c *HisApiController) TestTest() {
  9837. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9838. fmt.Println(patient.Iinfo)
  9839. }
  9840. type CustomData struct {
  9841. MsgId string
  9842. PsnNo string
  9843. Info string
  9844. }
  9845. func (c *HisApiController) ReversalData() {
  9846. var customData []*CustomData
  9847. custom := &CustomData{
  9848. MsgId: "H44022900158202103301714472004",
  9849. PsnNo: "44020000001101329945",
  9850. Info: "2207",
  9851. }
  9852. customData = append(customData, custom)
  9853. custom1 := &CustomData{
  9854. MsgId: "H4402290015820210330172057803",
  9855. PsnNo: "44020000001101161813",
  9856. Info: "2207",
  9857. }
  9858. customData = append(customData, custom1)
  9859. custom2 := &CustomData{
  9860. MsgId: "H44022900158202103301705198813",
  9861. PsnNo: "44190000133097375417",
  9862. Info: "2207",
  9863. }
  9864. customData = append(customData, custom2)
  9865. custom3 := &CustomData{
  9866. MsgId: "H44022900158202103301715524756",
  9867. PsnNo: "44020000001100187221",
  9868. Info: "2207",
  9869. }
  9870. customData = append(customData, custom3)
  9871. custom4 := &CustomData{
  9872. MsgId: "H44022900158202103301730376224",
  9873. PsnNo: "44020000001101959155",
  9874. Info: "2207",
  9875. }
  9876. customData = append(customData, custom4)
  9877. custom5 := &CustomData{
  9878. MsgId: "H44022900158202103301748008725",
  9879. PsnNo: "44020000001104246641",
  9880. Info: "2207",
  9881. }
  9882. customData = append(customData, custom5)
  9883. custom6 := &CustomData{
  9884. MsgId: "H44022900158202103301718096755",
  9885. PsnNo: "44020000001102211860",
  9886. Info: "2207",
  9887. }
  9888. customData = append(customData, custom6)
  9889. custom7 := &CustomData{
  9890. MsgId: "H44022900158202103301736551640",
  9891. PsnNo: "44020000001102687718",
  9892. Info: "2207",
  9893. }
  9894. customData = append(customData, custom7)
  9895. custom8 := &CustomData{
  9896. MsgId: "H44022900158202103301743097676",
  9897. PsnNo: "44020000001102127785",
  9898. Info: "2207",
  9899. }
  9900. customData = append(customData, custom8)
  9901. custom9 := &CustomData{
  9902. MsgId: "H44022900158202103301712304203",
  9903. PsnNo: "44020000001101518097",
  9904. Info: "2207",
  9905. }
  9906. customData = append(customData, custom9)
  9907. custom10 := &CustomData{
  9908. MsgId: "H44022900158202103301738448785",
  9909. PsnNo: "44020000001100500813",
  9910. Info: "2207",
  9911. }
  9912. customData = append(customData, custom10)
  9913. custom11 := &CustomData{
  9914. MsgId: "H44022900158202103301732455843",
  9915. PsnNo: "44020000001102690557",
  9916. Info: "2207",
  9917. }
  9918. customData = append(customData, custom11)
  9919. custom12 := &CustomData{
  9920. MsgId: "H44022900158202103301745421708",
  9921. PsnNo: "44020000001102211928",
  9922. Info: "2207",
  9923. }
  9924. customData = append(customData, custom12)
  9925. custom1212 := &CustomData{
  9926. MsgId: "H440229001582021033017351627",
  9927. PsnNo: "44020000001102481733",
  9928. Info: "2207",
  9929. }
  9930. customData = append(customData, custom1212)
  9931. custom13 := &CustomData{
  9932. MsgId: "H44022900158202103301740327951",
  9933. PsnNo: "44020000001103174866",
  9934. Info: "2207",
  9935. }
  9936. customData = append(customData, custom13)
  9937. custom14 := &CustomData{
  9938. MsgId: "H4402290015820210330174922668",
  9939. PsnNo: "44020000001102927272",
  9940. Info: "2207",
  9941. }
  9942. customData = append(customData, custom14)
  9943. custom15 := &CustomData{
  9944. MsgId: "H44022900158202103301752362273",
  9945. PsnNo: "44020000001102942890",
  9946. Info: "2207",
  9947. }
  9948. customData = append(customData, custom15)
  9949. custom16 := &CustomData{
  9950. MsgId: "H44022900158202103301751082917",
  9951. PsnNo: "44020000001101662162",
  9952. Info: "2207",
  9953. }
  9954. customData = append(customData, custom16)
  9955. custom17 := &CustomData{
  9956. MsgId: "H44022900158202103301754147728",
  9957. PsnNo: "44020000000229014511",
  9958. Info: "2207",
  9959. }
  9960. customData = append(customData, custom17)
  9961. adminUser := c.GetAdminUserInfo()
  9962. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9963. for _, item := range customData {
  9964. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9965. fmt.Println(result)
  9966. }
  9967. }
  9968. func (c *HisApiController) GetAllopatry() {
  9969. year := c.GetString("year")
  9970. month := c.GetString("month")
  9971. admin_user_id, _ := c.GetInt64("admin_user_id")
  9972. adminUser := c.GetAdminUserInfo()
  9973. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9974. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9975. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9976. var dat map[string]interface{}
  9977. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9978. fmt.Println(dat)
  9979. } else {
  9980. fmt.Println(err)
  9981. }
  9982. userJSONBytes, _ := json.Marshal(dat)
  9983. var res models.Result9001
  9984. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9985. utils.ErrorLog("解析失败:%v", err)
  9986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9987. return
  9988. }
  9989. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9990. var dat2 map[string]interface{}
  9991. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9992. fmt.Println(dat)
  9993. } else {
  9994. fmt.Println(err)
  9995. }
  9996. userJSONBytes2, _ := json.Marshal(dat2)
  9997. var res2 models.Result3260
  9998. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9999. utils.ErrorLog("解析失败:%v", err)
  10000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10001. return
  10002. }
  10003. if res2.Infcode == 0 {
  10004. c.ServeSuccessJSON(map[string]interface{}{
  10005. "list": res2.Output.Data,
  10006. })
  10007. return
  10008. } else {
  10009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10010. return
  10011. }
  10012. }
  10013. func (c *HisApiController) ComfirmAllopatry() {
  10014. year := c.GetString("year")
  10015. month := c.GetString("month")
  10016. admin_user_id, _ := c.GetInt64("admin_user_id")
  10017. adminUser := c.GetAdminUserInfo()
  10018. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10019. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10020. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10021. var dat map[string]interface{}
  10022. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10023. fmt.Println(dat)
  10024. } else {
  10025. fmt.Println(err)
  10026. }
  10027. userJSONBytes, _ := json.Marshal(dat)
  10028. var res models.Result9001
  10029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10030. utils.ErrorLog("解析失败:%v", err)
  10031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10032. return
  10033. }
  10034. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10035. var dat2 map[string]interface{}
  10036. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10037. fmt.Println(dat)
  10038. } else {
  10039. fmt.Println(err)
  10040. }
  10041. userJSONBytes2, _ := json.Marshal(dat2)
  10042. var res2 models.Result3260
  10043. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10044. utils.ErrorLog("解析失败:%v", err)
  10045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10046. return
  10047. }
  10048. if res2.Infcode == 0 {
  10049. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10050. var dat map[string]interface{}
  10051. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10052. fmt.Println(dat)
  10053. } else {
  10054. fmt.Println(err)
  10055. }
  10056. userJSONBytes, _ := json.Marshal(dat)
  10057. var res3 models.Result3261
  10058. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10059. utils.ErrorLog("解析失败:%v", err)
  10060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10061. return
  10062. }
  10063. if res3.Infcode == 0 {
  10064. record := &models.HisYidiClearRecord{
  10065. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10066. Ctime: time.Now().Unix(),
  10067. Mtime: time.Now().Unix(),
  10068. Status: 1,
  10069. MsgId: msgId,
  10070. }
  10071. service.SaveClearRecord(record)
  10072. c.ServeSuccessJSON(map[string]interface{}{
  10073. "msg": "提取成功",
  10074. })
  10075. }
  10076. }
  10077. }
  10078. func (c *HisApiController) RefundAllopatry() {
  10079. year := c.GetString("year")
  10080. month := c.GetString("month")
  10081. id, _ := c.GetInt64("id")
  10082. admin_user_id, _ := c.GetInt64("admin_user_id")
  10083. adminUser := c.GetAdminUserInfo()
  10084. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10085. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10086. record, _ := service.GetClearRecordById(id)
  10087. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10088. var dat map[string]interface{}
  10089. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10090. fmt.Println(dat)
  10091. } else {
  10092. fmt.Println(err)
  10093. }
  10094. userJSONBytes, _ := json.Marshal(dat)
  10095. var empty ResultFourteen
  10096. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10097. utils.ErrorLog("解析失败:%v", err)
  10098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10099. return
  10100. }
  10101. if empty.Infcode == 0 {
  10102. c.ServeSuccessJSON(map[string]interface{}{
  10103. "msg": "撤销成功",
  10104. })
  10105. return
  10106. }
  10107. }
  10108. func (c *HisApiController) ReversalOtherData() {
  10109. var customData []*CustomData
  10110. custom := &CustomData{
  10111. MsgId: "H44022900158202103301714472004",
  10112. PsnNo: "44020000001101329945",
  10113. Info: "2208",
  10114. }
  10115. customData = append(customData, custom)
  10116. custom1 := &CustomData{
  10117. MsgId: "H4402290015820210330172057803",
  10118. PsnNo: "44020000001101161813",
  10119. Info: "2208",
  10120. }
  10121. customData = append(customData, custom1)
  10122. custom2 := &CustomData{
  10123. MsgId: "H44022900158202103301705198813",
  10124. PsnNo: "44190000133097375417",
  10125. Info: "2208",
  10126. }
  10127. customData = append(customData, custom2)
  10128. custom3 := &CustomData{
  10129. MsgId: "H44022900158202103301715524756",
  10130. PsnNo: "44020000001100187221",
  10131. Info: "2208",
  10132. }
  10133. customData = append(customData, custom3)
  10134. custom4 := &CustomData{
  10135. MsgId: "H44022900158202103301730376224",
  10136. PsnNo: "44020000001101959155",
  10137. Info: "2208",
  10138. }
  10139. customData = append(customData, custom4)
  10140. custom5 := &CustomData{
  10141. MsgId: "H44022900158202103301748008725",
  10142. PsnNo: "44020000001104246641",
  10143. Info: "2208",
  10144. }
  10145. customData = append(customData, custom5)
  10146. custom6 := &CustomData{
  10147. MsgId: "H44022900158202103301718096755",
  10148. PsnNo: "44020000001102211860",
  10149. Info: "2208",
  10150. }
  10151. customData = append(customData, custom6)
  10152. custom7 := &CustomData{
  10153. MsgId: "H44022900158202103301736551640",
  10154. PsnNo: "44020000001102687718",
  10155. Info: "2208",
  10156. }
  10157. customData = append(customData, custom7)
  10158. custom8 := &CustomData{
  10159. MsgId: "H44022900158202103301743097676",
  10160. PsnNo: "44020000001102127785",
  10161. Info: "2208",
  10162. }
  10163. customData = append(customData, custom8)
  10164. custom9 := &CustomData{
  10165. MsgId: "H44022900158202103301712304203",
  10166. PsnNo: "44020000001101518097",
  10167. Info: "2208",
  10168. }
  10169. customData = append(customData, custom9)
  10170. custom10 := &CustomData{
  10171. MsgId: "H44022900158202103301738448785",
  10172. PsnNo: "44020000001100500813",
  10173. Info: "2208",
  10174. }
  10175. customData = append(customData, custom10)
  10176. custom11 := &CustomData{
  10177. MsgId: "H44022900158202103301732455843",
  10178. PsnNo: "44020000001102690557",
  10179. Info: "2208",
  10180. }
  10181. customData = append(customData, custom11)
  10182. custom12 := &CustomData{
  10183. MsgId: "H44022900158202103301745421708",
  10184. PsnNo: "44020000001102211928",
  10185. Info: "2208",
  10186. }
  10187. customData = append(customData, custom12)
  10188. custom1212 := &CustomData{
  10189. MsgId: "H440229001582021033017351627",
  10190. PsnNo: "44020000001102481733",
  10191. Info: "2208",
  10192. }
  10193. customData = append(customData, custom1212)
  10194. custom13 := &CustomData{
  10195. MsgId: "H44022900158202103301740327951",
  10196. PsnNo: "44020000001103174866",
  10197. Info: "2208",
  10198. }
  10199. customData = append(customData, custom13)
  10200. custom14 := &CustomData{
  10201. MsgId: "H4402290015820210330174922668",
  10202. PsnNo: "44020000001102927272",
  10203. Info: "2208",
  10204. }
  10205. customData = append(customData, custom14)
  10206. custom15 := &CustomData{
  10207. MsgId: "H44022900158202103301752362273",
  10208. PsnNo: "44020000001102942890",
  10209. Info: "2208",
  10210. }
  10211. customData = append(customData, custom15)
  10212. custom16 := &CustomData{
  10213. MsgId: "H44022900158202103301751082917",
  10214. PsnNo: "44020000001101662162",
  10215. Info: "2208",
  10216. }
  10217. customData = append(customData, custom16)
  10218. custom17 := &CustomData{
  10219. MsgId: "H44022900158202103301754147728",
  10220. PsnNo: "44020000000229014511",
  10221. Info: "2208",
  10222. }
  10223. customData = append(customData, custom17)
  10224. adminUser := c.GetAdminUserInfo()
  10225. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10226. for _, item := range customData {
  10227. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10228. fmt.Println(result)
  10229. }
  10230. }
  10231. func PathExists(path string) (bool, error) {
  10232. _, err := os.Stat(path)
  10233. if err == nil {
  10234. return true, nil
  10235. }
  10236. if os.IsNotExist(err) {
  10237. return false, nil
  10238. }
  10239. return false, err
  10240. }
  10241. //创建文件夹
  10242. func Mkdir(dir string) {
  10243. // 创建文件夹
  10244. exist, err := PathExists(dir)
  10245. if err != nil {
  10246. fmt.Println(err.Error())
  10247. } else {
  10248. if exist {
  10249. fmt.Println(dir + "文件夹已存在!")
  10250. } else {
  10251. // 文件夹名称,权限
  10252. err := os.Mkdir(dir, os.ModePerm)
  10253. if err != nil {
  10254. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10255. } else {
  10256. fmt.Println(dir + "文件夹创建成功!")
  10257. }
  10258. }
  10259. }
  10260. }
  10261. //压缩文件
  10262. func Zip(srcFile string, destZip string) error {
  10263. zipfile, err := os.Create(destZip)
  10264. if err != nil {
  10265. return err
  10266. }
  10267. defer zipfile.Close()
  10268. archive := zip.NewWriter(zipfile)
  10269. defer archive.Close()
  10270. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10271. if err != nil {
  10272. return err
  10273. }
  10274. header, err := zip.FileInfoHeader(info)
  10275. if err != nil {
  10276. return err
  10277. }
  10278. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10279. // header.Name = path
  10280. if info.IsDir() {
  10281. header.Name += "/"
  10282. } else {
  10283. header.Method = zip.Deflate
  10284. }
  10285. writer, err := archive.CreateHeader(header)
  10286. if err != nil {
  10287. return err
  10288. }
  10289. if !info.IsDir() {
  10290. file, err := os.Open(path)
  10291. if err != nil {
  10292. return err
  10293. }
  10294. defer file.Close()
  10295. _, err = io.Copy(writer, file)
  10296. }
  10297. return err
  10298. })
  10299. return err
  10300. }
  10301. func ReadFile(filePath string) []byte {
  10302. f, err := os.Open(filePath)
  10303. if err != nil {
  10304. fmt.Println("read file fail", err)
  10305. return nil
  10306. }
  10307. defer f.Close()
  10308. fd, err := ioutil.ReadAll(f)
  10309. if err != nil {
  10310. fmt.Println("read to fd fail", err)
  10311. return nil
  10312. }
  10313. return fd
  10314. }
  10315. func saveLog(result string, request string, infno string, desc string) {
  10316. org_id, _ := beego.AppConfig.Int64("org_id")
  10317. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10318. dir := miConfig.OrgName + "日志"
  10319. utils.Mkdir(dir)
  10320. month := time.Unix(1557042972, 0).Format("1")
  10321. year := time.Now().Format("2006")
  10322. month = time.Now().Format("01")
  10323. day := time.Now().Format("02")
  10324. hour := time.Now().Format("15")
  10325. min := time.Now().Format("04")
  10326. sec := time.Now().Format("05")
  10327. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10328. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10329. file_name := file + ".txt"
  10330. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10331. exist, _ := utils.PathExists(file_path)
  10332. if exist { //存在
  10333. fmt.Println("存在")
  10334. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10335. if err != nil {
  10336. fmt.Println("read fail")
  10337. }
  10338. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10339. n, _ := f.Seek(0, 2)
  10340. _, err = f.WriteAt([]byte(content), n)
  10341. } else { //不存在
  10342. fmt.Println("文件不存在,创建文件")
  10343. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10344. defer f.Close()
  10345. if err != nil {
  10346. } else {
  10347. _, err = f.Write([]byte("记录日志"))
  10348. }
  10349. }
  10350. }
  10351. type Charset string
  10352. const (
  10353. UTF8 = Charset("UTF-8")
  10354. GB18030 = Charset("GB18030")
  10355. )
  10356. func ConvertToString(src string, srcCode string, tagCode string) string {
  10357. srcCoder := mahonia.NewDecoder(srcCode)
  10358. srcResult := srcCoder.ConvertString(src)
  10359. tagCoder := mahonia.NewDecoder(tagCode)
  10360. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10361. result := string(cdata)
  10362. return result
  10363. }