his_api_controller.go 202KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828
  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/jinzhu/gorm"
  14. "github.com/shopspring/decimal"
  15. "io"
  16. "io/ioutil"
  17. "math/rand"
  18. "net/http"
  19. "os"
  20. "path/filepath"
  21. "strconv"
  22. "strings"
  23. "syscall"
  24. "time"
  25. "unsafe"
  26. )
  27. type HisApiController struct {
  28. controllers.BaseAuthAPIController
  29. }
  30. func HisManagerApiRegistRouters() {
  31. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  32. beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
  33. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  34. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  35. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  36. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  37. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  38. //beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
  39. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  40. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  41. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  42. beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
  43. //beego.Router("/api/patient/info", &HisApiController{}, "get:GetHisPatientInfo")
  44. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  45. //beego.Router("/api/testcard", &HisApiController{}, "get:TestGetBasBaseInfo")
  46. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  47. //beego.Router("/api/testpay", &HisApiController{}, "get:TestPay")
  48. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  49. //beego.Router("/api/settle/get", &HisApiController{}, "get:GetSettleInfo")
  50. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  51. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  52. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  53. //备案撤销相关接口
  54. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  55. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  56. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  57. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  58. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  59. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  60. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  61. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  62. //beego.Router("/api/reversal/one", &HisApiController{}, "get:ReversalOtherOneData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. //beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  65. //beego.Router("/api/testinit", &HisApiController{}, "get:TestGetBasBaseInit")
  66. //beego.Router("/api/test", &HisApiController{}, "get:TestGetBasBaseInfo")
  67. }
  68. func (c *HisApiController) ReadCard() {
  69. id_card_type, _ := c.GetInt64("id_card_type")
  70. admin_user_id, _ := c.GetInt64("admin_user_id")
  71. certificates, _ := c.GetInt64("certificates")
  72. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  73. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  74. if initFlag == 0 {
  75. c.TestGetBasBaseInit()
  76. }
  77. switch id_card_type {
  78. case 1:
  79. basStr := c.GetBasBaseInfo()
  80. if len(basStr) == 0 {
  81. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  82. return
  83. }
  84. fmt.Println(basStr)
  85. bas := strings.Split(basStr, "|")
  86. basNumber := bas[2]
  87. fmt.Println(basNumber)
  88. card_sn := bas[3]
  89. fmt.Println(card_sn)
  90. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  91. var dat map[string]interface{}
  92. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  93. fmt.Println(dat)
  94. } else {
  95. fmt.Println(err)
  96. }
  97. userJSONBytes, _ := json.Marshal(dat)
  98. var res ResultTwo
  99. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  100. utils.ErrorLog("解析失败:%v", err)
  101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  102. return
  103. }
  104. if res.Infcode == 0 {
  105. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  106. if err == gorm.ErrRecordNotFound {
  107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  108. return
  109. } else if err != nil {
  110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  111. return
  112. } else {
  113. c.ServeSuccessJSON(map[string]interface{}{
  114. "patient": patient,
  115. "number": basNumber,
  116. })
  117. }
  118. } else {
  119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  120. return
  121. }
  122. break
  123. case 2:
  124. SFZStr := c.GetSFZBaseInfo()
  125. id_card_str := strings.Split(SFZStr, "^")
  126. id_card_number := id_card_str[0]
  127. card_sn := ""
  128. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  129. var dat map[string]interface{}
  130. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  131. fmt.Println(dat)
  132. } else {
  133. fmt.Println(err)
  134. }
  135. userJSONBytes, _ := json.Marshal(dat)
  136. var res ResultTwo
  137. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  138. utils.ErrorLog("解析失败:%v", err)
  139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  140. return
  141. }
  142. if res.Infcode == 0 {
  143. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  144. if err == gorm.ErrRecordNotFound {
  145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  146. return
  147. } else if err != nil {
  148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  149. return
  150. } else {
  151. c.ServeSuccessJSON(map[string]interface{}{
  152. "patient": patient,
  153. "number": id_card_number,
  154. })
  155. }
  156. } else {
  157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  158. return
  159. }
  160. break
  161. case 3:
  162. break
  163. }
  164. }
  165. var initFlag int64 = 0
  166. func (c *HisApiController) TestGetBasBaseInit() {
  167. DllDef := syscall.MustLoadDLL("SSCard.dll")
  168. Iinit := DllDef.MustFindProc("Init")
  169. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  170. if ret != 0 {
  171. fmt.Println("SSCard的报错原因:", err)
  172. fmt.Println("SSCard的运算结果为:", ret)
  173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  174. return
  175. }
  176. result := int(ret)
  177. fmt.Println("SSCard的运算结果为1:", result)
  178. initFlag = 1
  179. return
  180. }
  181. func (c *HisApiController) GetSFZBaseInfo() string {
  182. DllDef := syscall.MustLoadDLL("SSCard.dll")
  183. readCard := DllDef.MustFindProc("ReadSFZ")
  184. if readCard == nil {
  185. fmt.Println("readcard is nil")
  186. readCard = DllDef.MustFindProc("ReadSFZ")
  187. }
  188. str := make([]byte, 256)
  189. str1 := make([]byte, 256)
  190. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  191. fmt.Println(r)
  192. return string(str)
  193. }
  194. func (c *HisApiController) GetBasBaseInfo() string {
  195. DllDef := syscall.MustLoadDLL("SSCard.dll")
  196. readCard := DllDef.MustFindProc("ReadCardBas")
  197. if readCard == nil {
  198. fmt.Println("readcard is nil")
  199. readCard = DllDef.MustFindProc("ReadCardBas")
  200. }
  201. str := make([]byte, 1024)
  202. str1 := make([]byte, 1024)
  203. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  204. fmt.Println(string(str1))
  205. fmt.Println(string(str))
  206. if ret2 != 0 {
  207. return ""
  208. }
  209. return string(str)
  210. }
  211. func prttostr(vcode uintptr) string {
  212. var vbyte []byte
  213. for i := 0; i < 10; i++ {
  214. sbyte := *((*byte)(unsafe.Pointer(vcode)))
  215. if sbyte == 0 {
  216. break
  217. }
  218. vbyte = append(vbyte, sbyte)
  219. vcode += 1
  220. }
  221. return string(vbyte)
  222. }
  223. type CustomFundPay struct {
  224. FundPayType string `json:"fund_pay_type"`
  225. FundPayamt float64 `json:"fund_payamt"`
  226. }
  227. func (c *HisApiController) GetSettleList() {
  228. order_id, _ := c.GetInt64("order_id")
  229. admin_user_id, _ := c.GetInt64("admin_user_id")
  230. order, _ := service.GetHisOrderByIDTwo(order_id)
  231. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  232. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  233. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  234. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  235. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  236. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  237. if order.ID == 0 {
  238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  239. return
  240. }
  241. struct4101 := service.Struct4101{
  242. PsnNo: order.PsnNo,
  243. MdtrtId: order.MdtrtId,
  244. SetlId: order.SetlId,
  245. PsnName: order.PsnName,
  246. Gend: order.Gend,
  247. Brdy: his.Brdy,
  248. Age: his.Age,
  249. Naty: order.Naty,
  250. PatnCertType: "01",
  251. Certno: order.Certno,
  252. Prfs: "90",
  253. ConerName: roles[0].UserName,
  254. PatnRlts: "99",
  255. ConerAddr: miConfig.OrgName,
  256. ConerTel: admin.Mobile,
  257. HiType: order.Insutype,
  258. Insuplc: miConfig.InsuplcAdmdvs,
  259. MaindiagFlag: "1",
  260. BillCode: order.FaPiaoCode,
  261. BillNo: order.FaPiaoNumber,
  262. BizSn: order.Number,
  263. PsnSelfPay: order.PsnPartAmt,
  264. PsnOwnPay: order.PsnPartAmt,
  265. AcctPay: order.AcctPay,
  266. PsnCashpay: order.PsnCashPay,
  267. HiPaymtd: "1",
  268. Hsorg: miConfig.InsuplcAdmdvs,
  269. HsorgOpter: miConfig.InsuplcAdmdvs,
  270. MedinsFillPsn: curRoles.UserName,
  271. MedinsFillDept: depart.Name,
  272. IptMedType: "2",
  273. }
  274. if order.SettleType == 1 {
  275. t := time.Unix(int64(order.SettleAccountsDate), 0)
  276. dateStr := t.Format("2006-01-02")
  277. struct4101.SetlBegnDate = dateStr
  278. struct4101.SetlEndDate = dateStr
  279. } else {
  280. t := time.Unix(int64(order.SettleStartTime), 0)
  281. t2 := time.Unix(int64(order.SettleEndTime), 0)
  282. dateStartStr := t.Format("2006-01-02")
  283. dateEndStr := t2.Format("2006-01-02")
  284. struct4101.SetlBegnDate = dateStartStr
  285. struct4101.SetlEndDate = dateEndStr
  286. }
  287. var rf []CustomFundPay
  288. json.Unmarshal([]byte(order.SetlDetail), &rf)
  289. var tempFunPays []service.CustomStruct
  290. for _, item := range rf {
  291. var tempFunPay service.CustomStruct
  292. tempFunPay.FundPayamt = item.FundPayamt
  293. tempFunPay.FundPayType = item.FundPayType
  294. tempFunPays = append(tempFunPays, tempFunPay)
  295. }
  296. struct4101.CustomStruct = tempFunPays
  297. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  298. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  299. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  300. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  301. var config []*models.HisXtDiagnoseConfig
  302. for _, item := range diagnosis_ids {
  303. id, _ := strconv.ParseInt(item, 10, 64)
  304. diagnosisConfig, _ := service.FindDiagnoseById(id)
  305. config = append(config, diagnosisConfig)
  306. }
  307. for _, item := range config {
  308. var tempOpspdiseinfo service.OpspdiseinfoStruct
  309. tempOpspdiseinfo.DiagCode = item.CountryCode
  310. tempOpspdiseinfo.DiagName = item.CountryContentName
  311. tempOpspdiseinfo.MaindiagFlag = "1"
  312. tempOpspdiseinfo.OprnOprtCode = ""
  313. tempOpspdiseinfo.OprnOprtName = ""
  314. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  315. }
  316. sickConfigTwo, _ := service.FindSickById(his.SickType)
  317. tempOpspdiseinfo2.DiagCode = sickConfigTwo.CountryCode
  318. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  319. tempOpspdiseinfo2.MaindiagFlag = "2"
  320. tempOpspdiseinfo2.OprnOprtCode = ""
  321. tempOpspdiseinfo2.OprnOprtName = ""
  322. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  323. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  324. var iteminfo service.IteminfoStruct
  325. var bedCostTotal float64 = 0 //床位总费
  326. var bedCostSelfTotal float64 = 0 //床位自费
  327. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  328. var operationCostTotal float64 = 0 //手术费
  329. var operationCostSelfTotal float64 = 0 //手术费
  330. var operationCostPartSelfTotal float64 = 0 //手术费
  331. var otherCostTotal float64 = 0 //其他费用
  332. var otherCostSelfTotal float64 = 0 //其他费用
  333. var otherCostPartSelfTotal float64 = 0 //其他费用
  334. var materialCostTotal float64 = 0 //材料费
  335. var materialCostSelfTotal float64 = 0 //材料费
  336. var materialCostPartSelfTotal float64 = 0 //材料费
  337. var westernMedicineCostTotal float64 = 0 //西药费
  338. var westernMedicineCostSelfTotal float64 = 0 //西药费
  339. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  340. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  341. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  342. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  343. var checkCostTotal float64 = 0 //检查费
  344. var checkCostSelfTotal float64 = 0 //检查费
  345. var checkCostPartSelfTotal float64 = 0 //检查费
  346. var laboratoryCostTotal float64 = 0 //化验费
  347. var laboratoryCostSelfTotal float64 = 0 //化验费
  348. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  349. var treatCostTotal float64 = 0 //治疗费用
  350. var treatCostSelfTotal float64 = 0 //治疗费用
  351. var treatCostPartSelfTotal float64 = 0 //治疗费用
  352. decimal.DivisionPrecision = 2
  353. var bed_fulamt_ownpay_amt float64 = 0
  354. var operation_fulamt_ownpay_amt float64 = 0
  355. var other_fulamt_ownpay_amt float64 = 0
  356. var westernMedicine_fulamt_ownpay_amt float64 = 0
  357. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  358. var check_fulamt_ownpay_amt float64 = 0
  359. var material_fulamt_ownpay_amt float64 = 0
  360. var laboratory_fulamt_ownpay_amt float64 = 0
  361. var treat_fulamt_ownpay_amt float64 = 0
  362. var bed_claa_sunmfee float64 = 0
  363. var bed_clab_amt float64 = 0
  364. var bed_other_amt float64 = 0
  365. var operation_claa_sunmfee float64 = 0
  366. var operation_clab_amt float64 = 0
  367. var operation_other_amt float64 = 0
  368. var other_claa_sunmfee float64 = 0
  369. var other_clab_amt float64 = 0
  370. var other_other_amt float64 = 0
  371. var westernMedicine_claa_sunmfee float64 = 0
  372. var westernMedicine_clab_amt float64 = 0
  373. var westernMedicine_other_amt float64 = 0
  374. var chineseTraditional_claa_sunmfee float64 = 0
  375. var chineseTraditional_clab_amt float64 = 0
  376. var chineseTraditional_other_amt float64 = 0
  377. var check_claa_sunmfee float64 = 0
  378. var check_clab_amt float64 = 0
  379. var check_other_amt float64 = 0
  380. var material_claa_sunmfee float64 = 0
  381. var material_clab_amt float64 = 0
  382. var material_other_amt float64 = 0
  383. var laboratory_claa_sunmfee float64 = 0
  384. var laboratory_clab_amt float64 = 0
  385. var laboratory_other_amt float64 = 0
  386. var treat_claa_sunmfee float64 = 0
  387. var treat_clab_amt float64 = 0
  388. var treat_other_amt float64 = 0
  389. for _, item := range order.HisOrderInfo {
  390. if item.MedChrgitmType == "01" { //床位费
  391. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  392. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  393. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  394. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  395. if item.ChrgitmLv == "1" {
  396. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  397. }
  398. if item.ChrgitmLv == "2" {
  399. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  400. }
  401. if item.ChrgitmLv == "3" {
  402. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  403. }
  404. }
  405. if item.MedChrgitmType == "03" { //检查费
  406. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  407. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  408. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  409. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  410. if item.ChrgitmLv == "1" {
  411. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  412. }
  413. if item.ChrgitmLv == "2" {
  414. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  415. }
  416. if item.ChrgitmLv == "3" {
  417. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  418. }
  419. }
  420. if item.MedChrgitmType == "04" { //化验费
  421. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  422. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  423. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  424. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  425. if item.ChrgitmLv == "1" {
  426. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  427. }
  428. if item.ChrgitmLv == "2" {
  429. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  430. }
  431. if item.ChrgitmLv == "3" {
  432. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  433. }
  434. }
  435. if item.MedChrgitmType == "05" { //治疗费
  436. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  437. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  438. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  439. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  440. if item.ChrgitmLv == "1" {
  441. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  442. }
  443. if item.ChrgitmLv == "2" {
  444. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  445. }
  446. if item.ChrgitmLv == "3" {
  447. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  448. }
  449. }
  450. if item.MedChrgitmType == "06" { //手术费
  451. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  452. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  453. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  454. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  455. if item.ChrgitmLv == "1" {
  456. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  457. }
  458. if item.ChrgitmLv == "2" {
  459. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  460. }
  461. if item.ChrgitmLv == "3" {
  462. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  463. }
  464. }
  465. if item.MedChrgitmType == "08" { //材料费
  466. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  467. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  468. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  469. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  470. if item.ChrgitmLv == "1" {
  471. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  472. }
  473. if item.ChrgitmLv == "2" {
  474. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  475. }
  476. if item.ChrgitmLv == "3" {
  477. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  478. }
  479. }
  480. if item.MedChrgitmType == "09" { //西药费
  481. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  482. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  483. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  484. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  485. if item.ChrgitmLv == "1" {
  486. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  487. }
  488. if item.ChrgitmLv == "2" {
  489. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  490. }
  491. if item.ChrgitmLv == "3" {
  492. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  493. }
  494. }
  495. if item.MedChrgitmType == "11" { //中成费
  496. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  497. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  498. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  499. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  500. if item.ChrgitmLv == "1" {
  501. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  502. }
  503. if item.ChrgitmLv == "2" {
  504. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  505. }
  506. if item.ChrgitmLv == "3" {
  507. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  508. }
  509. }
  510. if item.MedChrgitmType == "14" { //其他费
  511. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  512. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  513. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  514. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  515. if item.ChrgitmLv == "1" {
  516. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  517. }
  518. if item.ChrgitmLv == "2" {
  519. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  520. }
  521. if item.ChrgitmLv == "3" {
  522. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  523. }
  524. }
  525. }
  526. var iteminfoStructs []service.IteminfoStruct
  527. if bedCostTotal != 0 {
  528. iteminfo.MedChrgitm = "01"
  529. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  530. iteminfo.Amt = bedCostTotal
  531. iteminfo.ClaaSumfee = bed_claa_sunmfee
  532. iteminfo.ClabAmt = bed_clab_amt
  533. iteminfo.OthAmt = bed_other_amt
  534. iteminfoStructs = append(iteminfoStructs, iteminfo)
  535. }
  536. if checkCostTotal != 0 {
  537. iteminfo.MedChrgitm = "03"
  538. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  539. iteminfo.Amt = checkCostTotal
  540. iteminfo.ClaaSumfee = check_claa_sunmfee
  541. iteminfo.ClabAmt = check_clab_amt
  542. iteminfo.OthAmt = check_other_amt
  543. iteminfoStructs = append(iteminfoStructs, iteminfo)
  544. }
  545. if laboratoryCostTotal != 0 {
  546. iteminfo.MedChrgitm = "04"
  547. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  548. iteminfo.Amt = laboratoryCostTotal
  549. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  550. iteminfo.ClabAmt = laboratory_clab_amt
  551. iteminfo.OthAmt = laboratory_other_amt
  552. iteminfoStructs = append(iteminfoStructs, iteminfo)
  553. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  554. }
  555. if treatCostTotal != 0 {
  556. iteminfo.MedChrgitm = "05"
  557. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  558. iteminfo.Amt = treatCostTotal
  559. iteminfo.ClaaSumfee = treat_claa_sunmfee
  560. iteminfo.ClabAmt = treat_clab_amt
  561. iteminfo.OthAmt = treat_other_amt
  562. iteminfoStructs = append(iteminfoStructs, iteminfo)
  563. // (struct4101.IteminfoStruct, iteminfo)
  564. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  565. }
  566. if operationCostTotal != 0 {
  567. iteminfo.MedChrgitm = "06"
  568. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  569. iteminfo.Amt = operationCostTotal
  570. iteminfo.ClaaSumfee = operation_claa_sunmfee
  571. iteminfo.ClabAmt = operation_clab_amt
  572. iteminfo.OthAmt = operation_other_amt
  573. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  574. iteminfoStructs = append(iteminfoStructs, iteminfo)
  575. }
  576. if materialCostTotal != 0 {
  577. iteminfo.MedChrgitm = "08"
  578. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  579. iteminfo.Amt = materialCostTotal
  580. iteminfo.ClaaSumfee = material_claa_sunmfee
  581. iteminfo.ClabAmt = material_clab_amt
  582. iteminfo.OthAmt = material_other_amt
  583. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  584. iteminfoStructs = append(iteminfoStructs, iteminfo)
  585. }
  586. if westernMedicineCostTotal != 0 {
  587. iteminfo.MedChrgitm = "09"
  588. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  589. iteminfo.Amt = westernMedicineCostTotal
  590. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  591. iteminfo.ClabAmt = westernMedicine_clab_amt
  592. iteminfo.OthAmt = westernMedicine_other_amt
  593. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  594. iteminfoStructs = append(iteminfoStructs, iteminfo)
  595. }
  596. if chineseTraditionalMedicineCostTotal != 0 {
  597. iteminfo.MedChrgitm = "11"
  598. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  599. iteminfo.Amt = westernMedicineCostTotal
  600. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  601. iteminfo.ClabAmt = westernMedicine_clab_amt
  602. iteminfo.OthAmt = westernMedicine_other_amt
  603. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  604. iteminfoStructs = append(iteminfoStructs, iteminfo)
  605. }
  606. if otherCostTotal != 0 {
  607. iteminfo.MedChrgitm = "14"
  608. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  609. iteminfo.Amt = otherCostTotal
  610. iteminfo.ClaaSumfee = other_claa_sunmfee
  611. iteminfo.ClabAmt = other_clab_amt
  612. iteminfo.OthAmt = other_other_amt
  613. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  614. iteminfoStructs = append(iteminfoStructs, iteminfo)
  615. }
  616. struct4101.IteminfoStruct = iteminfoStructs
  617. struct4101.Ntly = "中国"
  618. struct4101.AdmCaty = "A03.06"
  619. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  620. fmt.Println(result)
  621. var dat map[string]interface{}
  622. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  623. fmt.Println(dat)
  624. } else {
  625. fmt.Println(err)
  626. }
  627. userJSONBytes, _ := json.Marshal(dat)
  628. var res ResultSeventeen
  629. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  630. utils.ErrorLog("解析失败:%v", err)
  631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  632. return
  633. }
  634. if res.Infcode != 0 {
  635. c.ServeSuccessJSON(map[string]interface{}{
  636. "failed_code": -10,
  637. "msg": res.ErrMsg,
  638. })
  639. return
  640. } else {
  641. hisFundSettleListResult := &models.HisFundSettleListResult{
  642. Number: res.Output.SetlListId,
  643. Status: 1,
  644. Ctime: time.Now().Unix(),
  645. Mtime: time.Now().Unix(),
  646. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  647. IsUpload: 1,
  648. OrderId: order_id,
  649. }
  650. service.CreateUploadRecord(hisFundSettleListResult)
  651. c.ServeSuccessJSON(map[string]interface{}{
  652. "msg": "上传成功",
  653. "result": hisFundSettleListResult,
  654. })
  655. return
  656. }
  657. }
  658. //func (c *HisApiController) TestPay() {
  659. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  660. // readCards := DllDef2.MustFindProc("BankTrans")
  661. // inputData := make(map[string]interface{})
  662. // inputData["transId"] = "05"
  663. // inputData["amount"] = "0.01"
  664. // inputData["traceNo"] = "20210227093601325405377"
  665. // inputData["cardNo"] = "F36084348"
  666. // inputData["id"] = "44022919620927046X"
  667. // //jsonStr := `
  668. // // {
  669. // // "transId": "05",
  670. // // "amount":"1.00",
  671. // // "traceNo":"20210227093601325405377",
  672. // // "cardNo":"F36084348",
  673. // // "id":"44022919620927046X"
  674. // //
  675. // // }
  676. // //`
  677. //
  678. // bytes_arr, _ := json.Marshal(inputData)
  679. // str3 := make([]byte, 256)
  680. // ret4, _, err4 := readCards.Call(StrPtr(string(bytes_arr)), (uintptr)(unsafe.Pointer(&str3[0])))
  681. // fmt.Println(":", string(str3))
  682. //
  683. // if err4 != nil {
  684. // fmt.Println("SSCard的运算结果为:", ret4)
  685. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  686. // return
  687. // }
  688. //
  689. //}
  690. //func (c *HisApiController) TestGetBasBaseInfo() {
  691. //
  692. // //result := C.Init(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  693. // //fmt.Println(result)
  694. // //cs1 := C.CString("")
  695. // //cs2 := C.CString("")
  696. // //C.ReadCardBas(cs1, IntPtr(1024), cs2, IntPtr(1024))
  697. // //fmt.Println(cs1)
  698. // //fmt.Println(cs2)
  699. // //C.free(unsafe.Pointer(cs1))
  700. // //C.free(unsafe.Pointer(cs2))
  701. //
  702. // //
  703. //
  704. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  705. // Iinit := DllDef.MustFindProc("Init")
  706. // readCard := DllDef.MustFindProc("ReadCardBas")
  707. // ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  708. // if ret != 0 {
  709. // fmt.Println("SSCard的报错原因:", err)
  710. // fmt.Println("SSCard的运算结果为:", ret)
  711. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  712. // return
  713. // }
  714. //
  715. // result := int(ret)
  716. // fmt.Println("SSCard的运算结果为1:", result)
  717. //
  718. // //path := ""
  719. // //bytePath := []byte( "\x00")
  720. // //bytePath2 := []byte( "\x00")
  721. // //ssss
  722. //
  723. // str := make([]byte, 256)
  724. // str1 := make([]byte, 256)
  725. // s2 := []byte(string(str))
  726. // s3 := []byte(string(str1))
  727. // ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&s2[0])), IntPtr(256), (uintptr)(unsafe.Pointer(&s3[0])), IntPtr(256))
  728. // fmt.Println(" Add(4,5)的结果为:", ret2)
  729. // fmt.Println(" str:", s2)
  730. // fmt.Println(" str1:", s3)
  731. // if err2 != nil {
  732. // fmt.Println("SSCard的运算结果为:", ret2)
  733. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  734. // return
  735. // }
  736. //
  737. // //DllDef := syscall.MustLoadDLL("SSCard.dll")
  738. //
  739. //}
  740. func (c *HisApiController) GetOrgInfo() {
  741. miConfig, _ := service.FindMedicalInsuranceInfo(9919)
  742. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  743. }
  744. func (c *HisApiController) GetHisPatientInfo() {
  745. medical_insurance_card := c.GetString("medical_insurance_card")
  746. id_card_type, _ := c.GetInt64("id_card_type")
  747. id_card := c.GetString("id_card")
  748. adminInfo := c.GetAdminUserInfo()
  749. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  750. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  751. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  752. IdCardNo := ""
  753. if id_card_type == 1 {
  754. IdCardNo = medical_insurance_card
  755. } else if id_card_type == 2 {
  756. IdCardNo = id_card
  757. }
  758. if config.IsOpen == 1 {
  759. 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
  760. resp, requestErr := http.Get(api)
  761. if requestErr != nil {
  762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  763. return
  764. }
  765. defer resp.Body.Close()
  766. body, ioErr := ioutil.ReadAll(resp.Body)
  767. if ioErr != nil {
  768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  770. return
  771. }
  772. var respJSON map[string]interface{}
  773. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  776. return
  777. }
  778. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  779. userJSONBytes, _ := json.Marshal(userJSON)
  780. var res ResultTwo
  781. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  782. utils.ErrorLog("解析失败:%v", err)
  783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  784. return
  785. }
  786. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  787. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  788. infoStr := string(Iinfos)
  789. idetinfoStr := string(Idetinfos)
  790. if res.Infcode == 0 {
  791. his := models.VMHisPatient{
  792. Status: 1,
  793. Ctime: time.Now().Unix(),
  794. Mtime: time.Now().Unix(),
  795. PsnNo: res.Output.Baseinfo.PsnNo,
  796. PsnCertType: res.Output.Baseinfo.PsnCertType,
  797. Certno: res.Output.Baseinfo.Certno,
  798. PsnName: res.Output.Baseinfo.PsnName,
  799. Gend: res.Output.Baseinfo.Gend,
  800. Naty: res.Output.Baseinfo.Naty,
  801. Brdy: res.Output.Baseinfo.Brdy,
  802. Age: res.Output.Baseinfo.Age,
  803. Iinfo: infoStr,
  804. Idetinfo: idetinfoStr,
  805. UserOrgId: adminInfo.CurrentOrgId,
  806. IsReturn: 1,
  807. IdCardType: id_card_type,
  808. }
  809. c.ServeSuccessJSON(map[string]interface{}{
  810. "info": his,
  811. })
  812. } else {
  813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  814. return
  815. }
  816. }
  817. }
  818. //func GetBasBaseInfo() (jsonStr string, err error) {
  819. //
  820. // handle := syscall.NewLazyDLL("SSCard.dll")
  821. // add := handle.NewProc("ReadCardBas")
  822. // str := make([]byte, 1024)
  823. // str1 := make([]byte, 1024)
  824. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  825. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  826. //
  827. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  828. //
  829. // fmt.Println("> Add(4,5)的结果为:", ret)
  830. // handle.Release()
  831. //
  832. // return "", nil
  833. //
  834. //}
  835. //func GetQRBaseInfo() (jsonStr string, err error) {
  836. // handle := syscall.LoadDLL("SSCard.dll")
  837. // ReadCardBas := handle.FindProc("GetQRBase")
  838. //
  839. // str := make([]byte, 256)
  840. // str1 := make([]byte, 256)
  841. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  842. //
  843. // fmt.Println(string(str))
  844. // fmt.Println(r)
  845. // return string(str), nil
  846. //}
  847. func CardInit() int {
  848. DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  849. add := DllTestDef.MustFindProc("Init")
  850. ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  851. if err != nil {
  852. fmt.Println("SSCard的运算结果为:", ret)
  853. }
  854. result := int(ret)
  855. return result
  856. }
  857. //func CardInit() int {
  858. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  859. // if err != nil {
  860. // fmt.Println("SSCard的运算结果为:", ret)
  861. // }
  862. // fmt.Println(err)
  863. // result := int(ret)
  864. // return result
  865. //}
  866. func IntPtr(n int) uintptr {
  867. return uintptr(n)
  868. }
  869. func StrPtr(s string) uintptr {
  870. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  871. }
  872. type ResultTwo struct {
  873. ErrMsg string `json:"err_msg"`
  874. InfRefmsgid string `json:"inf_refmsgid"`
  875. Infcode int64 `json:"infcode"`
  876. Output struct {
  877. Baseinfo struct {
  878. Age float64 `json:"age"`
  879. Brdy string `json:"brdy"`
  880. Certno string `json:"certno"`
  881. Gend string `json:"gend"`
  882. Naty string `json:"naty"`
  883. PsnCertType string `json:"psn_cert_type"`
  884. PsnName string `json:"psn_name"`
  885. PsnNo string `json:"psn_no"`
  886. } `json:"baseinfo"`
  887. Idetinfo []interface{} `json:"idetinfo"`
  888. Iinfo []struct {
  889. Balc float64 `json:"balc"`
  890. CvlservFlag string `json:"cvlserv_flag"`
  891. EmpName string `json:"emp_name"`
  892. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  893. Insutype string `json:"insutype"`
  894. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  895. PausInsuDate string `json:"paus_insu_date"`
  896. PsnInsuDate string `json:"psn_insu_date"`
  897. PsnInsuStas string `json:"psn_insu_stas"`
  898. PsnType string `json:"psn_type"`
  899. } `json:"insuinfo"`
  900. } `json:"output"`
  901. RefmsgTime string `json:"refmsg_time"`
  902. RespondTime string `json:"respond_time"`
  903. Signtype interface{} `json:"signtype"`
  904. WarnInfo interface{} `json:"warn_info"`
  905. }
  906. type ResultThree struct {
  907. Cainfo interface{} `json:"cainfo"`
  908. ErrMsg string `json:"err_msg"`
  909. InfRefmsgid string `json:"inf_refmsgid"`
  910. Infcode int64 `json:"infcode"`
  911. Output struct {
  912. Data struct {
  913. IptOtpNo string `json:"ipt_otp_no"`
  914. MdtrtID string `json:"mdtrt_id"`
  915. PsnNo string `json:"psn_no"`
  916. } `json:"data"`
  917. } `json:"output"`
  918. RefmsgTime string `json:"refmsg_time"`
  919. RespondTime string `json:"respond_time"`
  920. Signtype interface{} `json:"signtype"`
  921. WarnMsg interface{} `json:"warn_msg"`
  922. }
  923. type ResultFour struct {
  924. Cainfo string `json:"cainfo"`
  925. ErrMsg string `json:"err_msg"`
  926. InfRefmsgid string `json:"inf_refmsgid"`
  927. Infcode int64 `json:"infcode"`
  928. Output struct {
  929. Result []struct {
  930. BasMednFlag string `json:"bas_medn_flag"`
  931. ChldMedcFlag string `json:"chld_medc_flag"`
  932. ChrgitmLv string `json:"chrgitm_lv"`
  933. Cnt float64 `json:"cnt"`
  934. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  935. DrtReimFlag string `json:"drt_reim_flag"`
  936. FeedetlSn string `json:"feedetl_sn"`
  937. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  938. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  939. InscpScpAmt float64 `json:"inscp_scp_amt"`
  940. ListSpItemFlag string `json:"list_sp_item_flag"`
  941. LmtUsedFlag string `json:"lmt_used_flag"`
  942. MedChrgitmType string `json:"med_chrgitm_type"`
  943. Memo string `json:"memo"`
  944. OverlmtAmt float64 `json:"overlmt_amt"`
  945. PreselfpayAmt float64 `json:"preselfpay_amt"`
  946. Pric float64 `json:"pric"`
  947. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  948. SelfpayProp float64 `json:"selfpay_prop"`
  949. } `json:"result"`
  950. } `json:"output"`
  951. RefmsgTime string `json:"refmsg_time"`
  952. RespondTime string `json:"respond_time"`
  953. Signtype string `json:"signtype"`
  954. WarnMsg string `json:"warn_msg"`
  955. }
  956. type ResultFive struct {
  957. Balc float64 `json:"balc"`
  958. CvlservFlag string `json:"cvlserv_flag"`
  959. EmpName string `json:"emp_name"`
  960. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  961. Insutype string `json:"insutype"`
  962. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  963. PausInsuDate string `json:"paus_insu_date"`
  964. PsnInsuDate string `json:"psn_insu_date"`
  965. PsnInsuStas string `json:"psn_insu_stas"`
  966. PsnType string `json:"psn_type"`
  967. }
  968. type ResultSix struct {
  969. Cainfo interface{} `json:"cainfo"`
  970. ErrMsg string `json:"err_msg"`
  971. InfRefmsgid string `json:"inf_refmsgid"`
  972. Infcode int64 `json:"infcode"`
  973. Output struct {
  974. } `json:"output"`
  975. RefmsgTime string `json:"refmsg_time"`
  976. RespondTime string `json:"respond_time"`
  977. Signtype interface{} `json:"signtype"`
  978. WarnMsg interface{} `json:"warn_msg"`
  979. }
  980. type ResultSeven struct {
  981. Cainfo string `json:"cainfo"`
  982. ErrMsg string `json:"err_msg"`
  983. InfRefmsgid string `json:"inf_refmsgid"`
  984. Infcode int64 `json:"infcode"`
  985. Output struct {
  986. Setldetail []interface{} `json:"setldetail"`
  987. Setlinfo struct {
  988. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  989. AcctPay float64 `json:"acct_pay"`
  990. ActPayDedc float64 `json:"act_pay_dedc"`
  991. Age float64 `json:"age"`
  992. Balc float64 `json:"balc"`
  993. Brdy string `json:"brdy"`
  994. Certno string `json:"certno"`
  995. ClrOptins string `json:"clr_optins"`
  996. ClrType string `json:"clr_type"`
  997. ClrWay string `json:"clr_way"`
  998. CvlservFlag string `json:"cvlserv_flag"`
  999. CvlservPay float64 `json:"cvlserv_pay"`
  1000. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1001. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1002. Gend string `json:"gend"`
  1003. HifesPay float64 `json:"hifes_pay"`
  1004. HifmiPay float64 `json:"hifmi_pay"`
  1005. HifpPay float64 `json:"hifp_pay"`
  1006. HospPartAmt float64 `json:"hosp_part_amt"`
  1007. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1008. Insutype string `json:"insutype"`
  1009. MafPay float64 `json:"maf_pay"`
  1010. MdtrtCertType string `json:"mdtrt_cert_type"`
  1011. HifobPay float64 `json:"hifob_pay"`
  1012. MdtrtID string `json:"mdtrt_id"`
  1013. MedType string `json:"med_type"`
  1014. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1015. MedinsSetlID string `json:"medins_setl_id"`
  1016. Naty string `json:"naty"`
  1017. OthPay float64 `json:"oth_pay"`
  1018. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1019. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1020. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1021. PsnCashPay float64 `json:"psn_cash_pay"`
  1022. PsnCertType string `json:"psn_cert_type"`
  1023. PsnName string `json:"psn_name"`
  1024. PsnNo string `json:"psn_no"`
  1025. PsnPartAmt float64 `json:"psn_part_amt"`
  1026. PsnType string `json:"psn_type"`
  1027. SetlID string `json:"setl_id"`
  1028. SetlTime string `json:"setl_time"`
  1029. } `json:"setlinfo"`
  1030. } `json:"output"`
  1031. RefmsgTime string `json:"refmsg_time"`
  1032. RespondTime string `json:"respond_time"`
  1033. Signtype interface{} `json:"signtype"`
  1034. WarnMsg interface{} `json:"warn_msg"`
  1035. }
  1036. type ResultEight struct {
  1037. Cainfo string `json:"cainfo"`
  1038. ErrMsg string `json:"err_msg"`
  1039. InfRefmsgid string `json:"inf_refmsgid"`
  1040. Infcode int64 `json:"infcode"`
  1041. Output struct {
  1042. Stmtinfo struct {
  1043. SetlOptins string `json:"setl_optins"`
  1044. StmtRslt string `json:"stmt_rslt"`
  1045. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  1046. } `json:"stmtinfo"`
  1047. } `json:"output"`
  1048. RefmsgTime string `json:"refmsg_time"`
  1049. RespondTime string `json:"respond_time"`
  1050. Signtype interface{} `json:"signtype"`
  1051. WarnMsg interface{} `json:"warn_msg"`
  1052. }
  1053. type ResultNine struct {
  1054. Cainfo string `json:"cainfo"`
  1055. ErrMsg string `json:"err_msg"`
  1056. InfRefmsgid string `json:"inf_refmsgid"`
  1057. Infcode int64 `json:"infcode"`
  1058. Output struct {
  1059. FileQuryNo string `json:"file_qury_no"`
  1060. } `json:"output"`
  1061. RefmsgTime string `json:"refmsg_time"`
  1062. RespondTime string `json:"respond_time"`
  1063. Signtype interface{} `json:"signtype"`
  1064. WarnMsg interface{} `json:"warn_msg"`
  1065. }
  1066. type ResultTen struct {
  1067. Cainfo string `json:"cainfo"`
  1068. ErrMsg string `json:"err_msg"`
  1069. InfRefmsgid string `json:"inf_refmsgid"`
  1070. Infcode int64 `json:"infcode"`
  1071. Output struct {
  1072. DldEndtime string `json:"dld_endtime"`
  1073. FileQuryNo string `json:"file_qury_no"`
  1074. Filename string `json:"filename"`
  1075. } `json:"output"`
  1076. RefmsgTime string `json:"refmsg_time"`
  1077. RespondTime string `json:"respond_time"`
  1078. Signtype interface{} `json:"signtype"`
  1079. WarnMsg interface{} `json:"warn_msg"`
  1080. }
  1081. //type Autogenerated struct {
  1082. // Output struct {
  1083. // Setlinfo struct {
  1084. // SetlTime string `json:"setl_time"`
  1085. // CvlservPay float64 `json:"cvlserv_pay"`
  1086. // Year string `json:"year"`
  1087. // MedType string `json:"med_type"`
  1088. // PsnPay float64 `json:"psn_pay"`
  1089. // OpterID string `json:"opter_id"`
  1090. // Begndate string `json:"begndate"`
  1091. // FlxempeFlag string `json:"flxempe_flag"`
  1092. // HifmiPay float64 `json:"hifmi_pay"`
  1093. // PsnNo string `json:"psn_no"`
  1094. // ActPayDedc float64 `json:"act_pay_dedc"`
  1095. // MedinsSetlID interface{} `json:"medins_setl_id"`
  1096. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  1097. // ClrWay string `json:"clr_way"`
  1098. // OthPay float64 `json:"oth_pay"`
  1099. // Gend string `json:"gend"`
  1100. // MdtrtID string `json:"mdtrt_id"`
  1101. // AcctPay float64 `json:"acct_pay"`
  1102. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  1103. // Insutype string `json:"insutype"`
  1104. // Invono interface{} `json:"invono"`
  1105. // Enddate string `json:"enddate"`
  1106. // CashPayamt float64 `json:"cash_payamt"`
  1107. // PsnType string `json:"psn_type"`
  1108. // FixmedinsName string `json:"fixmedins_name"`
  1109. // HifpPay float64 `json:"hifp_pay"`
  1110. // NewFlag interface{} `json:"new_flag"`
  1111. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1112. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  1113. // PayLoc string `json:"pay_loc"`
  1114. // ClrType string `json:"clr_type"`
  1115. // RefdSetlFlag string `json:"refd_setl_flag"`
  1116. // CvlservFlag string `json:"cvlserv_flag"`
  1117. // EmpName string `json:"emp_name"`
  1118. // Brdy string `json:"brdy"`
  1119. // Naty string `json:"naty"`
  1120. // Certno string `json:"certno"`
  1121. // DiseCode string `json:"dise_code"`
  1122. // FixmedinsCode string `json:"fixmedins_code"`
  1123. // DedcHospLv string `json:"dedc_hosp_lv"`
  1124. // OpterName string `json:"opter_name"`
  1125. // Balc float64 `json:"balc"`
  1126. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  1127. // PsnCertType string `json:"psn_cert_type"`
  1128. // HifobPay float64 `json:"hifob_pay"`
  1129. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  1130. // HifesPay float64 `json:"hifes_pay"`
  1131. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1132. // OptTime string `json:"opt_time"`
  1133. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1134. // SetlID string `json:"setl_id"`
  1135. // MafPay float64 `json:"maf_pay"`
  1136. // PsnName string `json:"psn_name"`
  1137. // InsuOptins interface{} `json:"insu_optins"`
  1138. // PrefFundPay interface{} `json:"pref_fund_pay"`
  1139. // ClrOptins string `json:"clr_optins"`
  1140. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1141. // DiseName string `json:"dise_name"`
  1142. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  1143. // Age float64 `json:"age"`
  1144. // DtrtCertType string `json:"dtrt_cert_type"`
  1145. // HospLv string `json:"hosp_lv"`
  1146. // } `json:"setlinfo"`
  1147. // Setldetail []struct {
  1148. // FundPayType string `json:"fund_pay_type"`
  1149. // FundPayamt float64 `json:"fund_payamt"`
  1150. // SetlProcInfo interface{} `json:"setl_proc_info"`
  1151. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  1152. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  1153. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  1154. // PrefFundPay interface{} `json:"pref_fund_pay"`
  1155. // } `json:"setldetail"`
  1156. // } `json:"output"`
  1157. // Infcode int `json:"infcode"`
  1158. // WarnMsg interface{} `json:"warn_msg"`
  1159. // Cainfo interface{} `json:"cainfo"`
  1160. // ErrMsg interface{} `json:"err_msg"`
  1161. // RefmsgTime string `json:"refmsg_time"`
  1162. // Signtype interface{} `json:"signtype"`
  1163. // RespondTime string `json:"respond_time"`
  1164. // InfRefmsgid string `json:"inf_refmsgid"`
  1165. //}
  1166. type ResultEleven struct {
  1167. Cainfo string `json:"cainfo"`
  1168. ErrMsg string `json:"err_msg"`
  1169. InfRefmsgid string `json:"inf_refmsgid"`
  1170. Infcode int64 `json:"infcode"`
  1171. Output struct {
  1172. Setlinfo struct {
  1173. SetlTime string `json:"setl_time"`
  1174. CvlservPay float64 `json:"cvlserv_pay"`
  1175. Year string `json:"year"`
  1176. MedType string `json:"med_type"`
  1177. PsnPay float64 `json:"psn_pay"`
  1178. OpterID string `json:"opter_id"`
  1179. Begndate string `json:"begndate"`
  1180. FlxempeFlag string `json:"flxempe_flag"`
  1181. HifmiPay float64 `json:"hifmi_pay"`
  1182. PsnNo string `json:"psn_no"`
  1183. ActPayDedc float64 `json:"act_pay_dedc"`
  1184. MedinsSetlID interface{} `json:"medins_setl_id"`
  1185. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  1186. ClrWay string `json:"clr_way"`
  1187. OthPay float64 `json:"oth_pay"`
  1188. Gend string `json:"gend"`
  1189. MdtrtID string `json:"mdtrt_id"`
  1190. AcctPay float64 `json:"acct_pay"`
  1191. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1192. Insutype string `json:"insutype"`
  1193. Invono interface{} `json:"invono"`
  1194. Enddate string `json:"enddate"`
  1195. CashPayamt float64 `json:"cash_payamt"`
  1196. PsnType string `json:"psn_type"`
  1197. FixmedinsName string `json:"fixmedins_name"`
  1198. HifpPay float64 `json:"hifp_pay"`
  1199. NewFlag interface{} `json:"new_flag"`
  1200. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1201. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1202. PayLoc string `json:"pay_loc"`
  1203. ClrType string `json:"clr_type"`
  1204. RefdSetlFlag string `json:"refd_setl_flag"`
  1205. CvlservFlag string `json:"cvlserv_flag"`
  1206. EmpName string `json:"emp_name"`
  1207. Brdy string `json:"brdy"`
  1208. Naty string `json:"naty"`
  1209. Certno string `json:"certno"`
  1210. DiseCode string `json:"dise_code"`
  1211. FixmedinsCode string `json:"fixmedins_code"`
  1212. DedcHospLv string `json:"dedc_hosp_lv"`
  1213. OpterName string `json:"opter_name"`
  1214. Balc float64 `json:"balc"`
  1215. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  1216. PsnCertType string `json:"psn_cert_type"`
  1217. HifobPay float64 `json:"hifob_pay"`
  1218. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1219. HifesPay float64 `json:"hifes_pay"`
  1220. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1221. OptTime string `json:"opt_time"`
  1222. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1223. SetlID string `json:"setl_id"`
  1224. MafPay float64 `json:"maf_pay"`
  1225. PsnName string `json:"psn_name"`
  1226. InsuOptins interface{} `json:"insu_optins"`
  1227. PrefFundPay interface{} `json:"pref_fund_pay"`
  1228. ClrOptins string `json:"clr_optins"`
  1229. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1230. DiseName string `json:"dise_name"`
  1231. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  1232. Age float64 `json:"age"`
  1233. DtrtCertType string `json:"dtrt_cert_type"`
  1234. HospLv string `json:"hosp_lv"`
  1235. } `json:"setlinfo"`
  1236. } `json:"output"`
  1237. RefmsgTime string `json:"refmsg_time"`
  1238. RespondTime string `json:"respond_time"`
  1239. Signtype interface{} `json:"signtype"`
  1240. WarnMsg interface{} `json:"warn_msg"`
  1241. }
  1242. type ResultTwelve struct {
  1243. Cainfo string `json:"cainfo"`
  1244. ErrMsg string `json:"err_msg"`
  1245. InfRefmsgid string `json:"inf_refmsgid"`
  1246. Infcode int64 `json:"infcode"`
  1247. Output struct {
  1248. MdtrtId string `json:"mdtrt_id"`
  1249. ChrgBchno string `json:"chrg_bchno"`
  1250. PsnNo string `json:"psn_no"`
  1251. } `json:"output"`
  1252. RefmsgTime string `json:"refmsg_time"`
  1253. RespondTime string `json:"respond_time"`
  1254. Signtype interface{} `json:"signtype"`
  1255. WarnMsg interface{} `json:"warn_msg"`
  1256. }
  1257. type ResultThirteen struct {
  1258. ErrMsg string `json:"err_msg"`
  1259. InfRefmsgid string `json:"inf_refmsgid"`
  1260. Infcode int64 `json:"infcode"`
  1261. Output struct {
  1262. Result struct {
  1263. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  1264. } `json:"result"`
  1265. } `json:"output"`
  1266. RefmsgTime string `json:"refmsg_time"`
  1267. RespondTime string `json:"respond_time"`
  1268. Signtype interface{} `json:"signtype"`
  1269. WarnInfo interface{} `json:"warn_info"`
  1270. }
  1271. type ResultFourteen struct {
  1272. ErrMsg string `json:"err_msg"`
  1273. InfRefmsgid string `json:"inf_refmsgid"`
  1274. Infcode int64 `json:"infcode"`
  1275. Output struct {
  1276. } `json:"output"`
  1277. RefmsgTime string `json:"refmsg_time"`
  1278. RespondTime string `json:"respond_time"`
  1279. Signtype interface{} `json:"signtype"`
  1280. WarnInfo interface{} `json:"warn_info"`
  1281. }
  1282. type ResultSixteen struct {
  1283. Cainfo string `json:"cainfo"`
  1284. ErrMsg string `json:"err_msg"`
  1285. InfRefmsgid string `json:"inf_refmsgid"`
  1286. Infcode int64 `json:"infcode"`
  1287. Output struct {
  1288. Setldetail []interface{} `json:"setldetail"`
  1289. Setlinfo struct {
  1290. MdtrtID string `json:"mdtrt_id"`
  1291. SetlID string `json:"setl_id"`
  1292. ClrOptins string `json:"clr_optins"`
  1293. SetlTime string `json:"setl_time"`
  1294. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1295. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1296. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1297. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1298. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1299. ActPayDedc float64 `json:"act_pay_dedc"`
  1300. HifpPay float64 `json:"hifp_pay"`
  1301. PoolPropSe float64 `json:"pool_prop_selfpay"`
  1302. Lfpay float64 `json:"selfpay"`
  1303. CvlservPay float64 `json:"cvlserv_pay"`
  1304. HifesPay float64 `json:"hifes_pay"`
  1305. HifmiPay float64 `json:"hifmi_pay"`
  1306. HifobPay float64 `json:"hifob_pay"`
  1307. MafPay float64 `json:"maf_pay"`
  1308. OthPay float64 `json:"oth_pay"`
  1309. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1310. PsnPartAmt float64 `json:"psn_part_amt"`
  1311. AcctPay float64 `json:"acct_pay"`
  1312. Balc float64 `json:"balc"`
  1313. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1314. HospPartAmt float64 `json:"hosp_part_amt"`
  1315. MedinsSetlID string `json:"medins_setl_id"`
  1316. PdnCashPay string `json:"pdn_cash_pay"`
  1317. } `json:"setlinfo"`
  1318. } `json:"output"`
  1319. RefmsgTime string `json:"refmsg_time"`
  1320. RespondTime string `json:"respond_time"`
  1321. Signtype interface{} `json:"signtype"`
  1322. WarnMsg interface{} `json:"warn_msg"`
  1323. }
  1324. type ResultSeventeen struct {
  1325. ErrMsg string `json:"err_msg"`
  1326. InfRefmsgid string `json:"inf_refmsgid"`
  1327. Infcode int64 `json:"infcode"`
  1328. Output struct {
  1329. SetlListId string `json:"setl_list_id"`
  1330. } `json:"output"`
  1331. RefmsgTime string `json:"refmsg_time"`
  1332. RespondTime string `json:"respond_time"`
  1333. Signtype string `json:"signtype"`
  1334. WarnInfo string `json:"warn_info"`
  1335. }
  1336. type Custom struct {
  1337. DetItemFeeSumamt string
  1338. Cut string
  1339. FeedetlSn string
  1340. Price string
  1341. MedListCodg string
  1342. Type int64
  1343. AdviceId int64
  1344. ProjectId int64
  1345. ItemId int64
  1346. }
  1347. //获取个人信息----挂号-----上传就诊信息
  1348. func (c *HisApiController) GetRegisterInfo() {
  1349. id, _ := c.GetInt64("id")
  1350. record_time := c.GetString("record_time")
  1351. settlementValue, _ := c.GetInt64("settlement_value")
  1352. medical_insurance_card := c.GetString("medical_insurance_card")
  1353. name := c.GetString("name")
  1354. id_card_type, _ := c.GetInt64("id_card_type")
  1355. certificates, _ := c.GetInt64("certificates")
  1356. medical_care, _ := c.GetInt64("medical_care")
  1357. birthday := c.GetString("birthday")
  1358. //age, _ := c.GetInt64("age")
  1359. id_card := c.GetString("id_card")
  1360. register_type, _ := c.GetInt64("register")
  1361. doctor, _ := c.GetInt64("doctor")
  1362. department, _ := c.GetInt64("department")
  1363. gender, _ := c.GetInt64("sex")
  1364. //phone := c.GetString("phone")
  1365. registration_fee, _ := c.GetFloat("registration_fee")
  1366. medical_expenses, _ := c.GetFloat("medical_expenses")
  1367. social_type, _ := c.GetInt64("social_type")
  1368. admin_user_id, _ := c.GetInt64("admin_user_id")
  1369. timeLayout := "2006-01-02"
  1370. loc, _ := time.LoadLocation("Local")
  1371. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  1372. birthUnix := birthdays.Unix()
  1373. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1374. if err != nil {
  1375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1376. return
  1377. }
  1378. recordDateTime := theTime.Unix()
  1379. adminInfo := c.GetAdminUserInfo()
  1380. var patient service.Patients
  1381. if id == 0 {
  1382. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  1383. } else {
  1384. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  1385. }
  1386. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  1387. if patientPrescription.ID == 0 {
  1388. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  1389. }
  1390. //adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  1391. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  1392. //sickConfig, _ := service.FindSickById(sick_type)
  1393. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1394. if patient.ID == 0 {
  1395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1396. return
  1397. }
  1398. if len(patient.IdCardNo) == 0 {
  1399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  1400. return
  1401. }
  1402. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  1403. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1404. //就诊结算未完成,不能进行二次挂号
  1405. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  1406. if len(his) >= 1 {
  1407. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  1408. if len(his) >= 1 && order.ID == 0 {
  1409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  1410. return
  1411. }
  1412. }
  1413. if config.IsOpen == 1 {
  1414. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&certificates=" + strconv.FormatInt(certificates, 10)
  1415. resp, requestErr := http.Get(api)
  1416. if requestErr != nil {
  1417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1418. return
  1419. }
  1420. defer resp.Body.Close()
  1421. body, ioErr := ioutil.ReadAll(resp.Body)
  1422. if ioErr != nil {
  1423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1425. return
  1426. }
  1427. var respJSON map[string]interface{}
  1428. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1431. return
  1432. }
  1433. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1434. userJSONBytes, _ := json.Marshal(userJSON)
  1435. var res ResultTwo
  1436. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1437. utils.ErrorLog("解析失败:%v", err)
  1438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1439. return
  1440. }
  1441. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1442. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1443. infoStr := string(Iinfos)
  1444. idetinfoStr := string(Idetinfos)
  1445. if res.Infcode == 0 {
  1446. his := models.VMHisPatient{
  1447. Name: name,
  1448. Gender: gender,
  1449. Birthday: birthUnix,
  1450. MedicalTreatmentType: medical_care,
  1451. IdType: certificates,
  1452. IdCardNo: id_card,
  1453. BalanceAccountsType: settlementValue,
  1454. SocialType: social_type,
  1455. MedicalInsuranceNumber: medical_insurance_card,
  1456. RegisterType: register_type,
  1457. RegisterCost: registration_fee,
  1458. TreatmentCost: medical_expenses,
  1459. Status: 1,
  1460. Ctime: time.Now().Unix(),
  1461. Mtime: time.Now().Unix(),
  1462. PsnNo: res.Output.Baseinfo.PsnNo,
  1463. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1464. Certno: res.Output.Baseinfo.Certno,
  1465. PsnName: res.Output.Baseinfo.PsnName,
  1466. Gend: res.Output.Baseinfo.Gend,
  1467. Naty: res.Output.Baseinfo.Naty,
  1468. Brdy: res.Output.Baseinfo.Brdy,
  1469. Age: res.Output.Baseinfo.Age,
  1470. Iinfo: infoStr,
  1471. Idetinfo: idetinfoStr,
  1472. PatientId: patient.ID,
  1473. RecordDate: theTime.Unix(),
  1474. UserOrgId: adminInfo.CurrentOrgId,
  1475. AdminUserId: admin_user_id,
  1476. IsReturn: 1,
  1477. IdCardType: id_card_type,
  1478. Doctor: doctor,
  1479. Departments: department,
  1480. }
  1481. timestamp := time.Now().Unix()
  1482. tempTime := time.Unix(timestamp, 0)
  1483. timeFormat := tempTime.Format("20060102150405")
  1484. chrgBchno := rand.Intn(100000) + 10000
  1485. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1486. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  1487. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1488. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  1489. IdCardNo := ""
  1490. if id_card_type == 1 {
  1491. IdCardNo = medical_insurance_card
  1492. } else {
  1493. IdCardNo = patient.IdCardNo
  1494. }
  1495. var insutypes []string
  1496. var insutype string
  1497. var is390 int = 0
  1498. var is310 int = 0
  1499. for _, item := range res.Output.Iinfo {
  1500. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1501. insutypes = append(insutypes, item.Insutype)
  1502. }
  1503. }
  1504. if len(insutypes) == 1 {
  1505. insutype = insutypes[0]
  1506. } else {
  1507. for _, i := range insutypes {
  1508. if i == "390" {
  1509. is390 = 1
  1510. }
  1511. if i == "310" {
  1512. is310 = 1
  1513. }
  1514. }
  1515. }
  1516. if is390 == 1 {
  1517. insutype = "390"
  1518. }
  1519. if is310 == 1 {
  1520. insutype = "310"
  1521. }
  1522. if len(insutypes) == 0 {
  1523. insutype = "310"
  1524. }
  1525. //insutype = "390"
  1526. //if count == 1 {
  1527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1528. // return
  1529. //}
  1530. api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + IdCardNo + "&insutype=" +
  1531. insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
  1532. "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
  1533. "&dept=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
  1534. resp, requestErr := http.Get(api)
  1535. if requestErr != nil {
  1536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1537. return
  1538. }
  1539. defer resp.Body.Close()
  1540. body, ioErr := ioutil.ReadAll(resp.Body)
  1541. if ioErr != nil {
  1542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1544. return
  1545. }
  1546. var respJSON map[string]interface{}
  1547. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1550. return
  1551. }
  1552. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1553. userJSONBytes, _ := json.Marshal(respJSON)
  1554. var res ResultThree
  1555. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1556. utils.ErrorLog("解析失败:%v", err)
  1557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1558. return
  1559. }
  1560. if res.Infcode != 0 {
  1561. adminUser := c.GetAdminUserInfo()
  1562. errlog := &models.HisOrderError{
  1563. UserOrgId: adminUser.CurrentOrgId,
  1564. Ctime: time.Now().Unix(),
  1565. Mtime: time.Now().Unix(),
  1566. ErrMsg: res.ErrMsg,
  1567. Status: 1,
  1568. PatientId: id,
  1569. RecordTime: recordDateTime,
  1570. Stage: 2,
  1571. }
  1572. service.CreateErrMsgLog(errlog)
  1573. c.ServeSuccessJSON(map[string]interface{}{
  1574. "failed_code": -10,
  1575. "msg": res.ErrMsg,
  1576. })
  1577. return
  1578. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
  1579. //return
  1580. }
  1581. his.Number = res.Output.Data.MdtrtID
  1582. his.PsnNo = res.Output.Data.PsnNo
  1583. his.IptOtpNo = res.Output.Data.IptOtpNo
  1584. his.IdCardNo = patient.IdCardNo
  1585. his.PhoneNumber = patient.Phone
  1586. his.UserOrgId = adminInfo.CurrentOrgId
  1587. his.Ctime = time.Now().Unix()
  1588. his.Mtime = time.Now().Unix()
  1589. his.Status = 1
  1590. service.UpdateHisPatientStatus(&his)
  1591. lists, _ := service.GetHisPatientInfoList(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  1592. if len(lists) == 1 {
  1593. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  1594. }
  1595. c.ServeSuccessJSON(map[string]interface{}{
  1596. "his_info": his,
  1597. })
  1598. } else {
  1599. adminUser := c.GetAdminUserInfo()
  1600. errlog := &models.HisOrderError{
  1601. UserOrgId: adminUser.CurrentOrgId,
  1602. Ctime: time.Now().Unix(),
  1603. Mtime: time.Now().Unix(),
  1604. ErrMsg: res.ErrMsg,
  1605. Status: 1,
  1606. PatientId: id,
  1607. RecordTime: recordDateTime,
  1608. Stage: 1,
  1609. }
  1610. service.CreateErrMsgLog(errlog)
  1611. c.ServeSuccessJSON(map[string]interface{}{
  1612. "failed_code": -10,
  1613. "msg": res.ErrMsg,
  1614. })
  1615. return
  1616. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  1617. }
  1618. }
  1619. }
  1620. //上传明细----预结算----确认订单
  1621. func (c *HisApiController) GetUploadInfo() {
  1622. id, _ := c.GetInt64("id")
  1623. record_time := c.GetString("record_time")
  1624. his_patient_id, _ := c.GetInt64("his_patient_id")
  1625. order_id, _ := c.GetInt64("order_id")
  1626. pay_way, _ := c.GetInt64("pay_way")
  1627. pay_price, _ := c.GetFloat("pay_price")
  1628. pay_card_no := c.GetString("pay_card_no")
  1629. discount_price, _ := c.GetFloat("discount_price")
  1630. preferential_price, _ := c.GetFloat("preferential_price")
  1631. reality_price, _ := c.GetFloat("reality_price")
  1632. found_price, _ := c.GetFloat("found_price")
  1633. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1634. private_price, _ := c.GetFloat("private_price")
  1635. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1636. admin_user_id, _ := c.GetInt64("admin_user_id")
  1637. fapiao_code := c.GetString("fapiao_code")
  1638. fapiao_number := c.GetString("fapiao_number")
  1639. diagnosis_id := c.GetString("diagnosis")
  1640. sick_type, _ := c.GetInt64("sick_type")
  1641. reg_type, _ := c.GetInt64("p_type")
  1642. timeLayout := "2006-01-02"
  1643. loc, _ := time.LoadLocation("Local")
  1644. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1645. if err != nil {
  1646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1647. return
  1648. }
  1649. recordDateTime := theTime.Unix()
  1650. adminUser := c.GetAdminUserInfo()
  1651. tempOrder, _ := service.GetHisOrderByID(order_id)
  1652. var prescriptions []*models.HisPrescription
  1653. var start_time int64
  1654. var end_time int64
  1655. //if adminUser.CurrentOrgId == 10106{
  1656. // if len(fapiao_code) == 0{
  1657. // fapiao_code = "144072080589"
  1658. // }
  1659. // if len(fapiao_number) == 0{
  1660. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  1661. // if order.ID == 0{
  1662. // fapiao_number = "00001520"
  1663. // }else{
  1664. // //fapiao_code = "00001520"
  1665. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  1666. // var zero string
  1667. // if fpNumber >= 1000{
  1668. // zero = "0000" + strconv.Itoa(fpNumber)
  1669. // }else if fpNumber >= 10000{
  1670. // zero = "000" + strconv.Itoa(fpNumber)
  1671. // } else if fpNumber >= 100000{
  1672. // zero = "00" + strconv.Itoa(fpNumber)
  1673. // } else if fpNumber >= 1000000{
  1674. // zero = "0" + strconv.Itoa(fpNumber)
  1675. // }else {
  1676. // zero = strconv.Itoa(fpNumber)
  1677. // }
  1678. // fapiao_number = zero
  1679. // }
  1680. // }
  1681. //}
  1682. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1683. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1684. var patientPrescription models.HisPrescriptionInfo
  1685. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1686. if patientPrescription.ID == 0 {
  1687. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1688. }
  1689. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1690. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1691. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1692. diagnosis_ids := strings.Split(diagnosis_id, ",")
  1693. var config []*models.HisXtDiagnoseConfig
  1694. for _, item := range diagnosis_ids {
  1695. id, _ := strconv.ParseInt(item, 10, 64)
  1696. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1697. config = append(config, diagnosisConfig)
  1698. }
  1699. sickConfig, _ := service.FindSickById(sick_type)
  1700. if tempOrder.ID == 0 {
  1701. var result string
  1702. if miConfig.InsuplcAdmdvs == "440781" { //
  1703. result = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.AdminUserId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  1704. } else {
  1705. result = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.AdminUserId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  1706. }
  1707. var respJSON2 map[string]interface{}
  1708. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1711. return
  1712. }
  1713. userJSONBytes2, _ := json.Marshal(respJSON2)
  1714. var res2 ResultSix
  1715. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1716. utils.ErrorLog("解析失败:%v", err)
  1717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1718. return
  1719. }
  1720. if res2.Infcode != 0 {
  1721. adminUser := c.GetAdminUserInfo()
  1722. errlog := &models.HisOrderError{
  1723. UserOrgId: adminUser.CurrentOrgId,
  1724. Ctime: time.Now().Unix(),
  1725. Mtime: time.Now().Unix(),
  1726. ErrMsg: res2.ErrMsg,
  1727. Status: 1,
  1728. PatientId: id,
  1729. RecordTime: recordDateTime,
  1730. Stage: 3,
  1731. }
  1732. service.CreateErrMsgLog(errlog)
  1733. c.ServeSuccessJSON(map[string]interface{}{
  1734. "failed_code": -10,
  1735. "msg": res2.ErrMsg,
  1736. })
  1737. return
  1738. } else {
  1739. his.Diagnosis = diagnosis_id
  1740. his.SickType = sickConfig.ID
  1741. his.PType = fmt.Sprintf("%d", reg_type)
  1742. service.UpdateHisPatientThree(&his)
  1743. data := make(map[string]interface{})
  1744. if settle_accounts_type == 1 { //日结
  1745. prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  1746. data["pre"] = prescriptions
  1747. } else { //月结
  1748. start_time_str := c.GetString("start_time")
  1749. end_time_str := c.GetString("end_time")
  1750. timeLayout := "2006-01-02"
  1751. loc, _ := time.LoadLocation("Local")
  1752. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1753. if err != nil {
  1754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1755. return
  1756. }
  1757. recordStartTime := theStartTime.Unix()
  1758. start_time = recordStartTime
  1759. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1760. if err != nil {
  1761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1762. return
  1763. }
  1764. recordEndTime := theEndTime.Unix()
  1765. end_time = recordEndTime
  1766. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  1767. data["pre"] = prescriptions
  1768. }
  1769. timestamp := time.Now().Unix()
  1770. tempTime := time.Unix(timestamp, 0)
  1771. timeFormat := tempTime.Format("20060102150405")
  1772. chrgBchno := rand.Intn(100000) + 10000
  1773. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1774. strconv.FormatInt(his.PatientId, 10)
  1775. client := &http.Client{}
  1776. data["psn_no"] = his.PsnNo
  1777. data["mdtrt_id"] = his.Number
  1778. data["chrg_bchno"] = chrg_bchno
  1779. data["org_name"] = miConfig.OrgName
  1780. data["doctor"] = roles.UserName
  1781. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  1782. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  1783. data["fixmedins_code"] = miConfig.Code
  1784. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  1785. data["dept_code"] = "15"
  1786. } else {
  1787. data["dept_code"] = department.Number
  1788. }
  1789. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1790. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1791. data["secret_key"] = miConfig.SecretKey
  1792. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  1793. var ids []int64
  1794. for _, item := range prescriptions {
  1795. ids = append(ids, item.ID)
  1796. }
  1797. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1798. if config.IsOpen == 1 { //对接了医保,走医保流程
  1799. bytesData, _ := json.Marshal(data)
  1800. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  1801. resp, _ := client.Do(req)
  1802. defer resp.Body.Close()
  1803. body, ioErr := ioutil.ReadAll(resp.Body)
  1804. if ioErr != nil {
  1805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1807. return
  1808. }
  1809. var respJSON map[string]interface{}
  1810. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1813. return
  1814. }
  1815. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1816. userJSONBytes, _ := json.Marshal(respJSON)
  1817. var res ResultFour
  1818. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1819. utils.ErrorLog("解析失败:%v", err)
  1820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1821. return
  1822. }
  1823. if res.Infcode == 0 {
  1824. order := &models.HisOrder{
  1825. UserOrgId: adminUser.CurrentOrgId,
  1826. HisPatientId: his.ID,
  1827. PatientId: his.PatientId,
  1828. SettleAccountsDate: recordDateTime,
  1829. Ctime: time.Now().Unix(),
  1830. Mtime: time.Now().Unix(),
  1831. Status: 1,
  1832. Number: chrg_bchno,
  1833. Infcode: res.Infcode,
  1834. WarnMsg: res.WarnMsg,
  1835. Cainfo: res.Cainfo,
  1836. ErrMsg: res.ErrMsg,
  1837. RespondTime: res.RefmsgTime,
  1838. InfRefmsgid: res.InfRefmsgid,
  1839. OrderStatus: 1,
  1840. PayWay: pay_way,
  1841. PayPrice: pay_price,
  1842. PayCardNo: pay_card_no,
  1843. DiscountPrice: discount_price,
  1844. PreferentialPrice: preferential_price,
  1845. RealityPrice: reality_price,
  1846. FoundPrice: found_price,
  1847. MedicalInsurancePrice: medical_insurance_price,
  1848. PrivatePrice: private_price,
  1849. IsMedicineInsurance: 1,
  1850. SettleType: settle_accounts_type,
  1851. SettleStartTime: start_time,
  1852. SettleEndTime: end_time,
  1853. Creator: roles.AdminUserId,
  1854. Modify: roles.AdminUserId,
  1855. FaPiaoNumber: fapiao_number,
  1856. FaPiaoCode: fapiao_code,
  1857. PType: 2,
  1858. Diagnosis: diagnosis_id,
  1859. }
  1860. err = service.CreateOrder(order)
  1861. if err != nil {
  1862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  1863. return
  1864. }
  1865. for _, item := range res.Output.Result {
  1866. temp := strings.Split(item.FeedetlSn, "-")
  1867. var advice_id int64 = 0
  1868. var project_id int64 = 0
  1869. var types int64 = 0
  1870. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1871. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1872. if temp[1] == "1" {
  1873. advice_id = id
  1874. project_id = 0
  1875. } else if temp[1] == "2" {
  1876. advice_id = 0
  1877. project_id = id
  1878. }
  1879. info := &models.HisOrderInfo{
  1880. OrderNumber: order.Number,
  1881. FeedetlSn: item.FeedetlSn,
  1882. UploadDate: time.Now().Unix(),
  1883. AdviceId: advice_id,
  1884. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1885. Cnt: item.Cnt,
  1886. Pric: float64(item.Pric),
  1887. PatientId: his.PatientId,
  1888. PricUplmtAmt: item.PricUplmtAmt,
  1889. SelfpayProp: item.SelfpayProp,
  1890. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1891. OverlmtAmt: item.OverlmtAmt,
  1892. PreselfpayAmt: item.PreselfpayAmt,
  1893. BasMednFlag: item.BasMednFlag,
  1894. MedChrgitmType: item.MedChrgitmType,
  1895. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1896. Status: 1,
  1897. Memo: item.Memo,
  1898. Mtime: time.Now().Unix(),
  1899. InscpScpAmt: item.InscpScpAmt,
  1900. DrtReimFlag: item.DrtReimFlag,
  1901. Ctime: time.Now().Unix(),
  1902. ListSpItemFlag: item.ListSpItemFlag,
  1903. ChldMedcFlag: item.ChldMedcFlag,
  1904. LmtUsedFlag: item.LmtUsedFlag,
  1905. ChrgitmLv: item.ChrgitmLv,
  1906. UserOrgId: adminUser.CurrentOrgId,
  1907. HisPatientId: his.ID,
  1908. OrderId: order.ID,
  1909. ProjectId: project_id,
  1910. Type: types,
  1911. }
  1912. service.CreateOrderInfo(info)
  1913. }
  1914. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  1915. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  1916. var total float64
  1917. for _, item := range prescriptions {
  1918. if item.Type == 1 { //药品
  1919. for _, subItem := range item.HisDoctorAdviceInfo {
  1920. total = total + (subItem.Price * subItem.PrescribingNumber)
  1921. }
  1922. }
  1923. if item.Type == 2 { //项目
  1924. for _, subItem := range item.HisPrescriptionProject {
  1925. total = total + (subItem.Price * float64(subItem.Count))
  1926. }
  1927. }
  1928. }
  1929. for _, item := range prescriptions {
  1930. for _, subItem := range item.HisAdditionalCharge {
  1931. total = total + (subItem.Price * float64(subItem.Count))
  1932. }
  1933. }
  1934. allTotal := fmt.Sprintf("%.2f", total)
  1935. if res.Infcode == 0 {
  1936. var rf []*ResultFive
  1937. json.Unmarshal([]byte(his.Iinfo), &rf)
  1938. chrg_bchno := chrg_bchno
  1939. cert_no := his.Certno
  1940. var insutypes []string
  1941. var insutype string
  1942. var is390 int = 0
  1943. var is310 int = 0
  1944. for _, item := range rf {
  1945. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1946. insutypes = append(insutypes, item.Insutype)
  1947. }
  1948. }
  1949. if len(insutypes) == 1 {
  1950. insutype = insutypes[0]
  1951. } else {
  1952. for _, i := range insutypes {
  1953. if i == "390" {
  1954. is390 = 1
  1955. }
  1956. if i == "310" {
  1957. is310 = 1
  1958. }
  1959. }
  1960. }
  1961. if is390 == 1 {
  1962. insutype = "390"
  1963. }
  1964. if is310 == 1 {
  1965. insutype = "310"
  1966. }
  1967. if len(insutypes) == 0 {
  1968. insutype = "310"
  1969. }
  1970. //insutype = "390"
  1971. if his.IdCardType == 1 {
  1972. cert_no = his.MedicalInsuranceNumber
  1973. } else {
  1974. cert_no = his.Certno
  1975. }
  1976. result, 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)
  1977. var dat map[string]interface{}
  1978. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1979. fmt.Println(dat)
  1980. } else {
  1981. fmt.Println(err)
  1982. }
  1983. userJSONBytes, _ := json.Marshal(dat)
  1984. var res ResultSeven
  1985. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1986. utils.ErrorLog("解析失败:%v", err)
  1987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1988. return
  1989. }
  1990. if res.Infcode != 0 {
  1991. errlog := &models.HisOrderError{
  1992. UserOrgId: adminUser.CurrentOrgId,
  1993. Ctime: time.Now().Unix(),
  1994. Mtime: time.Now().Unix(),
  1995. Number: chrg_bchno,
  1996. ErrMsg: res.ErrMsg,
  1997. Status: 1,
  1998. PatientId: id,
  1999. RecordTime: recordDateTime,
  2000. Stage: 6,
  2001. }
  2002. service.CreateErrMsgLog(errlog)
  2003. c.ServeSuccessJSON(map[string]interface{}{
  2004. "failed_code": -10,
  2005. "msg": res.ErrMsg,
  2006. })
  2007. return
  2008. } else {
  2009. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2010. order.OrderStatus = 2
  2011. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2012. order.SetlId = res.Output.Setlinfo.SetlID
  2013. order.PsnNo = res.Output.Setlinfo.PsnNo
  2014. order.PsnName = res.Output.Setlinfo.PsnName
  2015. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2016. order.Certno = res.Output.Setlinfo.Certno
  2017. order.Gend = res.Output.Setlinfo.Gend
  2018. order.Naty = res.Output.Setlinfo.Naty
  2019. order.Age = res.Output.Setlinfo.Age
  2020. order.Insutype = res.Output.Setlinfo.Insutype
  2021. order.PsnType = res.Output.Setlinfo.PsnType
  2022. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2023. order.SetlTime = res.Output.Setlinfo.SetlTime
  2024. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2025. order.MedType = res.Output.Setlinfo.MedType
  2026. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2027. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2028. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2029. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2030. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2031. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2032. order.HifpPay = res.Output.Setlinfo.HifpPay
  2033. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2034. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2035. order.HifesPay = res.Output.Setlinfo.HifesPay
  2036. order.HifobPay = res.Output.Setlinfo.HifobPay
  2037. order.MafPay = res.Output.Setlinfo.MafPay
  2038. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  2039. order.OthPay = res.Output.Setlinfo.OthPay
  2040. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2041. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2042. order.AcctPay = res.Output.Setlinfo.AcctPay
  2043. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2044. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2045. order.Balc = res.Output.Setlinfo.Balc
  2046. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2047. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2048. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2049. order.ClrWay = res.Output.Setlinfo.ClrWay
  2050. order.Creator = order.Creator
  2051. order.Modify = roles.AdminUserId
  2052. order.RequestLog = src_resquest
  2053. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2054. detailStr := string(setlDetail)
  2055. order.SetlDetail = detailStr
  2056. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2057. err = service.UpDateOrder(order)
  2058. if err == nil {
  2059. c.ServeSuccessJSON(map[string]interface{}{
  2060. "msg": "结算成功",
  2061. })
  2062. } else {
  2063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2064. return
  2065. }
  2066. }
  2067. } else {
  2068. adminUser := c.GetAdminUserInfo()
  2069. errlog := &models.HisOrderError{
  2070. UserOrgId: adminUser.CurrentOrgId,
  2071. Ctime: time.Now().Unix(),
  2072. Mtime: time.Now().Unix(),
  2073. ErrMsg: res.ErrMsg,
  2074. Status: 1,
  2075. PatientId: id,
  2076. RecordTime: recordDateTime,
  2077. Stage: 4,
  2078. }
  2079. service.CreateErrMsgLog(errlog)
  2080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2081. return
  2082. }
  2083. } else {
  2084. adminUser := c.GetAdminUserInfo()
  2085. errlog := &models.HisOrderError{
  2086. UserOrgId: adminUser.CurrentOrgId,
  2087. Ctime: time.Now().Unix(),
  2088. Mtime: time.Now().Unix(),
  2089. ErrMsg: res.ErrMsg,
  2090. Status: 1,
  2091. PatientId: id,
  2092. RecordTime: recordDateTime,
  2093. Stage: 4,
  2094. }
  2095. service.CreateErrMsgLog(errlog)
  2096. c.ServeSuccessJSON(map[string]interface{}{
  2097. "failed_code": -10,
  2098. "msg": res.ErrMsg,
  2099. })
  2100. return
  2101. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  2102. //return
  2103. }
  2104. }
  2105. }
  2106. } else if tempOrder.ID > 0 {
  2107. if tempOrder.IsPre == 1 {
  2108. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  2109. var rf []*ResultFive
  2110. json.Unmarshal([]byte(his.Iinfo), &rf)
  2111. chrg_bchno := tempOrder.Number
  2112. cert_no := his.Certno
  2113. var insutypes []string
  2114. var insutype string
  2115. var is390 int = 0
  2116. var is310 int = 0
  2117. for _, item := range rf {
  2118. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2119. insutypes = append(insutypes, item.Insutype)
  2120. }
  2121. }
  2122. if len(insutypes) == 1 {
  2123. insutype = insutypes[0]
  2124. } else {
  2125. for _, i := range insutypes {
  2126. if i == "390" {
  2127. is390 = 1
  2128. }
  2129. if i == "310" {
  2130. is310 = 1
  2131. }
  2132. }
  2133. }
  2134. if is390 == 1 {
  2135. insutype = "390"
  2136. }
  2137. if is310 == 1 {
  2138. insutype = "310"
  2139. }
  2140. if len(insutypes) == 0 {
  2141. insutype = "310"
  2142. }
  2143. //insutype = "390"
  2144. if his.IdCardType == 1 {
  2145. cert_no = his.MedicalInsuranceNumber
  2146. } else {
  2147. cert_no = his.Certno
  2148. }
  2149. result, 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, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType)
  2150. var dat map[string]interface{}
  2151. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2152. fmt.Println(dat)
  2153. } else {
  2154. fmt.Println(err)
  2155. }
  2156. userJSONBytes, _ := json.Marshal(dat)
  2157. var res ResultSeven
  2158. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2159. utils.ErrorLog("解析失败:%v", err)
  2160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2161. return
  2162. }
  2163. if res.Infcode != 0 {
  2164. errlog := &models.HisOrderError{
  2165. UserOrgId: adminUser.CurrentOrgId,
  2166. Ctime: time.Now().Unix(),
  2167. Mtime: time.Now().Unix(),
  2168. Number: chrg_bchno,
  2169. ErrMsg: res.ErrMsg,
  2170. Status: 1,
  2171. PatientId: id,
  2172. RecordTime: recordDateTime,
  2173. Stage: 6,
  2174. }
  2175. service.CreateErrMsgLog(errlog)
  2176. c.ServeSuccessJSON(map[string]interface{}{
  2177. "failed_code": -10,
  2178. "msg": res.ErrMsg,
  2179. })
  2180. return
  2181. } else {
  2182. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2183. order.OrderStatus = 2
  2184. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2185. order.SetlId = res.Output.Setlinfo.SetlID
  2186. order.PsnNo = res.Output.Setlinfo.PsnNo
  2187. order.PsnName = res.Output.Setlinfo.PsnName
  2188. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2189. order.Certno = res.Output.Setlinfo.Certno
  2190. order.Gend = res.Output.Setlinfo.Gend
  2191. order.Naty = res.Output.Setlinfo.Naty
  2192. order.Age = res.Output.Setlinfo.Age
  2193. order.Insutype = res.Output.Setlinfo.Insutype
  2194. order.PsnType = res.Output.Setlinfo.PsnType
  2195. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2196. order.SetlTime = res.Output.Setlinfo.SetlTime
  2197. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2198. order.MedType = res.Output.Setlinfo.MedType
  2199. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2200. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2201. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2202. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2203. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2204. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2205. order.HifpPay = res.Output.Setlinfo.HifpPay
  2206. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2207. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2208. order.HifesPay = res.Output.Setlinfo.HifesPay
  2209. order.HifobPay = res.Output.Setlinfo.HifobPay
  2210. order.MafPay = res.Output.Setlinfo.MafPay
  2211. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  2212. order.OthPay = res.Output.Setlinfo.OthPay
  2213. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2214. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2215. order.AcctPay = res.Output.Setlinfo.AcctPay
  2216. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2217. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2218. order.Balc = res.Output.Setlinfo.Balc
  2219. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2220. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2221. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2222. order.ClrWay = res.Output.Setlinfo.ClrWay
  2223. order.Creator = order.Creator
  2224. order.Modify = roles.AdminUserId
  2225. order.RequestLog = src_resquest
  2226. order.Diagnosis = diagnosis_id
  2227. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2228. detailStr := string(setlDetail)
  2229. order.SetlDetail = detailStr
  2230. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2231. err = service.UpDateOrder(order)
  2232. if err == nil {
  2233. c.ServeSuccessJSON(map[string]interface{}{
  2234. "msg": "结算成功",
  2235. })
  2236. } else {
  2237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2238. return
  2239. }
  2240. }
  2241. }
  2242. }
  2243. }
  2244. //func (c *HisApiController) GetPreUploadInfo() {
  2245. // id, _ := c.GetInt64("id")
  2246. // record_time := c.GetString("record_time")
  2247. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2248. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2249. //
  2250. // timeLayout := "2006-01-02"
  2251. // loc, _ := time.LoadLocation("Local")
  2252. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2253. // if err != nil {
  2254. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2255. // return
  2256. // }
  2257. // recordDateTime := theTime.Unix()
  2258. // adminUser := c.GetAdminUserInfo()
  2259. //
  2260. // var prescriptions []*models.HisPrescription
  2261. //
  2262. // var start_time int64
  2263. // var end_time int64
  2264. //
  2265. // data := make(map[string]interface{})
  2266. // if settle_accounts_type == 1 { //日结
  2267. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  2268. // data["pre"] = prescriptions
  2269. //
  2270. // } else { //月结
  2271. // start_time_str := c.GetString("start_time")
  2272. // end_time_str := c.GetString("end_time")
  2273. // timeLayout := "2006-01-02"
  2274. // loc, _ := time.LoadLocation("Local")
  2275. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2276. // if err != nil {
  2277. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2278. // return
  2279. // }
  2280. // recordStartTime := theStartTime.Unix()
  2281. // start_time = recordStartTime
  2282. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2283. // if err != nil {
  2284. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2285. // return
  2286. // }
  2287. // recordEndTime := theEndTime.Unix()
  2288. // end_time = recordEndTime
  2289. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  2290. // data["pre"] = prescriptions
  2291. //
  2292. // }
  2293. //
  2294. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2295. //
  2296. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2297. // timestamp := time.Now().Unix()
  2298. // tempTime := time.Unix(timestamp, 0)
  2299. // timeFormat := tempTime.Format("20060102150405")
  2300. // chrgBchno := rand.Intn(100000) + 10000
  2301. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2302. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2303. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2304. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2305. // strconv.FormatInt(his.PatientId, 10)
  2306. // client := &http.Client{}
  2307. // data["psn_no"] = his.PsnNo
  2308. // data["mdtrt_id"] = his.Number
  2309. // data["chrg_bchno"] = chrg_bchno
  2310. // data["org_name"] = miConfig.OrgName
  2311. // data["doctor"] = roles.UserName
  2312. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  2313. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  2314. // data["fixmedins_code"] = miConfig.Code
  2315. // data["dept_code"] = department.Number
  2316. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2317. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2318. // data["secret_key"] = miConfig.SecretKey
  2319. // var ids []int64
  2320. //
  2321. // for _, item := range prescriptions {
  2322. // ids = append(ids, item.ID)
  2323. // }
  2324. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2325. // if config.IsOpen == 1 { //对接了医保,走医保流程
  2326. // bytesData, _ := json.Marshal(data)
  2327. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  2328. // resp, _ := client.Do(req)
  2329. // defer resp.Body.Close()
  2330. // body, ioErr := ioutil.ReadAll(resp.Body)
  2331. // if ioErr != nil {
  2332. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2333. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2334. // return
  2335. // }
  2336. // var respJSON map[string]interface{}
  2337. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2338. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2339. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2340. // return
  2341. // }
  2342. //
  2343. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2344. // userJSONBytes, _ := json.Marshal(respJSON)
  2345. // var res ResultFour
  2346. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2347. // utils.ErrorLog("解析失败:%v", err)
  2348. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2349. // return
  2350. // }
  2351. //
  2352. // if res.Infcode == 0 {
  2353. // order := &models.HisOrder{
  2354. // UserOrgId: adminUser.CurrentOrgId,
  2355. // HisPatientId: his.ID,
  2356. // PatientId: his.PatientId,
  2357. // SettleAccountsDate: recordDateTime,
  2358. // Ctime: time.Now().Unix(),
  2359. // Mtime: time.Now().Unix(),
  2360. // Status: 1,
  2361. // Number: chrg_bchno,
  2362. // Infcode: res.Infcode,
  2363. // WarnMsg: res.WarnMsg,
  2364. // Cainfo: res.Cainfo,
  2365. // ErrMsg: res.ErrMsg,
  2366. // RespondTime: res.RefmsgTime,
  2367. // InfRefmsgid: res.InfRefmsgid,
  2368. // OrderStatus: 1,
  2369. // IsMedicineInsurance: 1,
  2370. // SettleType: settle_accounts_type,
  2371. // SettleStartTime: start_time,
  2372. // SettleEndTime: end_time,
  2373. // Creator: roles.ID,
  2374. // Modify: roles.ID,
  2375. // PType: 2,
  2376. // }
  2377. // err = service.CreateOrder(order)
  2378. // if err != nil {
  2379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2380. // return
  2381. // }
  2382. //
  2383. // for _, item := range res.Output.Result {
  2384. // temp := strings.Split(item.FeedetlSn, "-")
  2385. // var advice_id int64 = 0
  2386. // var project_id int64 = 0
  2387. // var types int64 = 0
  2388. //
  2389. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  2390. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  2391. //
  2392. // if temp[1] == "1" {
  2393. // advice_id = id
  2394. // project_id = 0
  2395. // } else if temp[1] == "2" {
  2396. // advice_id = 0
  2397. // project_id = id
  2398. // }
  2399. //
  2400. // info := &models.HisOrderInfo{
  2401. // OrderNumber: order.Number,
  2402. // FeedetlSn: item.FeedetlSn,
  2403. // UploadDate: time.Now().Unix(),
  2404. // AdviceId: advice_id,
  2405. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  2406. // Cnt: item.Cnt,
  2407. // Pric: float64(item.Pric),
  2408. // PatientId: his.PatientId,
  2409. // PricUplmtAmt: item.PricUplmtAmt,
  2410. // SelfpayProp: item.SelfpayProp,
  2411. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2412. // OverlmtAmt: item.OverlmtAmt,
  2413. // PreselfpayAmt: item.PreselfpayAmt,
  2414. // BasMednFlag: item.BasMednFlag,
  2415. // MedChrgitmType: item.MedChrgitmType,
  2416. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  2417. // Status: 1,
  2418. // Memo: item.Memo,
  2419. // Mtime: time.Now().Unix(),
  2420. // InscpScpAmt: item.InscpScpAmt,
  2421. // DrtReimFlag: item.DrtReimFlag,
  2422. // Ctime: time.Now().Unix(),
  2423. // ListSpItemFlag: item.ListSpItemFlag,
  2424. // ChldMedcFlag: item.ChldMedcFlag,
  2425. // LmtUsedFlag: item.LmtUsedFlag,
  2426. // ChrgitmLv: item.ChrgitmLv,
  2427. // UserOrgId: adminUser.CurrentOrgId,
  2428. // HisPatientId: his.ID,
  2429. // OrderId: order.ID,
  2430. // ProjectId: project_id,
  2431. // Type: types,
  2432. // }
  2433. // service.CreateOrderInfo(info)
  2434. //
  2435. // }
  2436. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2437. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  2438. //
  2439. // var total float64
  2440. // for _, item := range prescriptions {
  2441. // if item.Type == 1 { //药品
  2442. // for _, subItem := range item.HisDoctorAdviceInfo {
  2443. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2444. // }
  2445. // }
  2446. // if item.Type == 2 { //项目
  2447. // for _, subItem := range item.HisPrescriptionProject {
  2448. // total = total + (subItem.Price * float64(subItem.Count))
  2449. // }
  2450. // }
  2451. // }
  2452. //
  2453. // for _, item := range prescriptions {
  2454. // for _, subItem := range item.HisAdditionalCharge {
  2455. // total = total + (subItem.Price * float64(subItem.Count))
  2456. // }
  2457. // }
  2458. //
  2459. // allTotal := fmt.Sprintf("%.2f", total)
  2460. // if res.Infcode == 0 {
  2461. // var rf []*ResultFive
  2462. // json.Unmarshal([]byte(his.Iinfo), &rf)
  2463. // psn_no := his.PsnNo
  2464. // mdtrt_id := his.Number
  2465. // chrg_bchno := chrg_bchno
  2466. // cert_no := his.Certno
  2467. // insutype := rf[0].Insutype
  2468. //
  2469. // if his.IdCardType == 1 {
  2470. // cert_no = his.MedicalInsuranceNumber
  2471. //
  2472. // } else {
  2473. //
  2474. // cert_no = his.Certno
  2475. //
  2476. // }
  2477. //
  2478. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  2479. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  2480. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  2481. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  2482. // resp, requestErr := http.Get(api)
  2483. // if requestErr != nil {
  2484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2485. // return
  2486. // }
  2487. // defer resp.Body.Close()
  2488. // body, ioErr := ioutil.ReadAll(resp.Body)
  2489. // if ioErr != nil {
  2490. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2491. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2492. // return
  2493. // }
  2494. // var respJSON map[string]interface{}
  2495. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2496. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2497. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2498. // return
  2499. // }
  2500. // fmt.Println(respJSON)
  2501. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2502. // userJSONBytes, _ := json.Marshal(respJSON)
  2503. // var res ResultSeven
  2504. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2505. // utils.ErrorLog("解析失败:%v", err)
  2506. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2507. // return
  2508. // }
  2509. // if res.Infcode != 0 {
  2510. // errlog := &models.HisOrderError{
  2511. // UserOrgId: adminUser.CurrentOrgId,
  2512. // Ctime: time.Now().Unix(),
  2513. // Mtime: time.Now().Unix(),
  2514. // Number: chrg_bchno,
  2515. // ErrMsg: res.ErrMsg,
  2516. // Status: 1,
  2517. // PatientId: id,
  2518. // RecordTime: recordDateTime,
  2519. // Stage: 7,
  2520. // }
  2521. // service.CreateErrMsgLog(errlog)
  2522. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2523. // return
  2524. // } else {
  2525. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2526. // order.OrderStatus = 1
  2527. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2528. // order.SetlId = res.Output.Setlinfo.SetlID
  2529. // order.PsnNo = res.Output.Setlinfo.PsnNo
  2530. // order.PsnName = res.Output.Setlinfo.PsnName
  2531. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2532. // order.Certno = res.Output.Setlinfo.Certno
  2533. // order.Gend = res.Output.Setlinfo.Gend
  2534. // order.Naty = res.Output.Setlinfo.Naty
  2535. // order.Age = res.Output.Setlinfo.Age
  2536. // order.Insutype = res.Output.Setlinfo.Insutype
  2537. // order.PsnType = res.Output.Setlinfo.PsnType
  2538. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2539. // order.SetlTime = res.Output.Setlinfo.SetlTime
  2540. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2541. // order.MedType = res.Output.Setlinfo.MedType
  2542. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2543. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2544. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2545. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2546. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2547. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2548. // order.HifpPay = res.Output.Setlinfo.HifpPay
  2549. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2550. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2551. // order.HifesPay = res.Output.Setlinfo.HifesPay
  2552. // order.HifobPay = res.Output.Setlinfo.HifobPay
  2553. // order.MafPay = res.Output.Setlinfo.MafPay
  2554. // order.OthPay = res.Output.Setlinfo.OthPay
  2555. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2556. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2557. // order.AcctPay = res.Output.Setlinfo.AcctPay
  2558. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2559. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2560. // order.Balc = res.Output.Setlinfo.Balc
  2561. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2562. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2563. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2564. // order.ClrWay = res.Output.Setlinfo.ClrWay
  2565. // order.Creator = order.Creator
  2566. // order.Modify = roles.ID
  2567. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2568. // detailStr := string(setlDetail)
  2569. // order.SetlDetail = detailStr
  2570. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2571. // err = service.UpDateOrder(order)
  2572. // if err == nil {
  2573. // c.ServeSuccessJSON(map[string]interface{}{
  2574. // "msg": "预结算成功",
  2575. // })
  2576. // } else {
  2577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2578. // return
  2579. // }
  2580. // }
  2581. // } else {
  2582. // adminUser := c.GetAdminUserInfo()
  2583. // errlog := &models.HisOrderError{
  2584. // UserOrgId: adminUser.CurrentOrgId,
  2585. // Ctime: time.Now().Unix(),
  2586. // Mtime: time.Now().Unix(),
  2587. // ErrMsg: res.ErrMsg,
  2588. // Status: 1,
  2589. // PatientId: id,
  2590. // RecordTime: recordDateTime,
  2591. // Stage: 4,
  2592. // }
  2593. // service.CreateErrMsgLog(errlog)
  2594. //
  2595. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2596. // return
  2597. // }
  2598. // } else {
  2599. // adminUser := c.GetAdminUserInfo()
  2600. // errlog := &models.HisOrderError{
  2601. // UserOrgId: adminUser.CurrentOrgId,
  2602. // Ctime: time.Now().Unix(),
  2603. // Mtime: time.Now().Unix(),
  2604. // ErrMsg: res.ErrMsg,
  2605. // Status: 1,
  2606. // PatientId: id,
  2607. // RecordTime: recordDateTime,
  2608. // Stage: 4,
  2609. // }
  2610. // service.CreateErrMsgLog(errlog)
  2611. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  2612. // return
  2613. // }
  2614. //
  2615. // } else {
  2616. // var total float64
  2617. // for _, item := range prescriptions {
  2618. // if item.Type == 1 { //药品
  2619. // for _, subItem := range item.HisDoctorAdviceInfo {
  2620. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2621. // }
  2622. // }
  2623. // if item.Type == 2 { //项目
  2624. // for _, subItem := range item.HisPrescriptionProject {
  2625. // total = total + (subItem.Price * float64(subItem.Count))
  2626. // }
  2627. // }
  2628. //
  2629. // for _, subItem := range item.HisAdditionalCharge {
  2630. // total = total + (subItem.Price * float64(subItem.Count))
  2631. // }
  2632. // }
  2633. //
  2634. // allTotal := fmt.Sprintf("%.2f", total)
  2635. // totals, _ := strconv.ParseFloat(allTotal, 64)
  2636. // order := &models.HisOrder{
  2637. // UserOrgId: adminUser.CurrentOrgId,
  2638. // HisPatientId: his.ID,
  2639. // PatientId: id,
  2640. // SettleAccountsDate: recordDateTime,
  2641. // Ctime: time.Now().Unix(),
  2642. // Mtime: time.Now().Unix(),
  2643. // Status: 1,
  2644. // OrderStatus: 2,
  2645. // Number: chrg_bchno,
  2646. // MedfeeSumamt: totals,
  2647. // }
  2648. // err = service.CreateOrder(order)
  2649. // if err != nil {
  2650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2651. // return
  2652. // }
  2653. //
  2654. // var customs []*Custom
  2655. // for _, item := range prescriptions {
  2656. //
  2657. // if item.Type == 1 { //药品
  2658. // for _, subItem := range item.HisDoctorAdviceInfo {
  2659. // cus := &Custom{
  2660. // AdviceId: subItem.ID,
  2661. // ProjectId: 0,
  2662. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  2663. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  2664. // FeedetlSn: subItem.FeedetlSn,
  2665. // Price: fmt.Sprintf("%.2f", subItem.Price),
  2666. // MedListCodg: subItem.MedListCodg,
  2667. // Type: 1,
  2668. // }
  2669. // customs = append(customs, cus)
  2670. // }
  2671. // }
  2672. //
  2673. // if item.Type == 2 { //项目
  2674. // for _, subItem := range item.HisPrescriptionProject {
  2675. //
  2676. // cus := &Custom{
  2677. // AdviceId: 0,
  2678. // ProjectId: subItem.ID,
  2679. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  2680. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  2681. // FeedetlSn: subItem.FeedetlSn,
  2682. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  2683. // MedListCodg: subItem.MedListCodg,
  2684. // Type: 2,
  2685. // }
  2686. //
  2687. // customs = append(customs, cus)
  2688. // }
  2689. // }
  2690. //
  2691. // for _, item := range item.HisAdditionalCharge {
  2692. // cus := &Custom{
  2693. // ItemId: item.ID,
  2694. // AdviceId: 0,
  2695. // ProjectId: 0,
  2696. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  2697. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  2698. // FeedetlSn: item.FeedetlSn,
  2699. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  2700. // MedListCodg: item.XtHisAddtionConfig.Code,
  2701. // Type: 3,
  2702. // }
  2703. //
  2704. // customs = append(customs, cus)
  2705. // }
  2706. //
  2707. // }
  2708. //
  2709. // for _, item := range customs {
  2710. // var advice_id int64 = 0
  2711. // var project_id int64 = 0
  2712. // var item_id int64 = 0
  2713. //
  2714. // var types int64 = 0
  2715. //
  2716. // if item.Type == 1 {
  2717. // advice_id = item.AdviceId
  2718. // project_id = 0
  2719. // item_id = 0
  2720. // } else if item.Type == 2 {
  2721. // advice_id = 0
  2722. // item_id = 0
  2723. //
  2724. // project_id = item.ProjectId
  2725. // } else if item.Type == 3 {
  2726. // advice_id = 0
  2727. // item_id = item.ItemId
  2728. // project_id = 0
  2729. // }
  2730. //
  2731. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  2732. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  2733. // pric, _ := strconv.ParseFloat(item.Price, 32)
  2734. //
  2735. // info := &models.HisOrderInfo{
  2736. // OrderNumber: order.Number,
  2737. // UploadDate: time.Now().Unix(),
  2738. // AdviceId: advice_id,
  2739. // DetItemFeeSumamt: detItemFeeSumamt,
  2740. // Cnt: cut,
  2741. // Pric: pric,
  2742. // PatientId: id,
  2743. // Status: 1,
  2744. // Mtime: time.Now().Unix(),
  2745. // Ctime: time.Now().Unix(),
  2746. // UserOrgId: adminUser.CurrentOrgId,
  2747. // HisPatientId: his.ID,
  2748. // OrderId: order.ID,
  2749. // ProjectId: project_id,
  2750. // Type: types,
  2751. // ItemId: item_id,
  2752. // }
  2753. // service.CreateOrderInfo(info)
  2754. // }
  2755. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2756. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2757. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  2758. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2759. // if err == nil {
  2760. // c.ServeSuccessJSON(map[string]interface{}{
  2761. // "msg": "结算成功",
  2762. // })
  2763. // } else {
  2764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2765. // return
  2766. // }
  2767. // }
  2768. //}
  2769. //上传明细-预结算-
  2770. func (c *HisApiController) GetPreUploadInfo() {
  2771. id, _ := c.GetInt64("id")
  2772. record_time := c.GetString("record_time")
  2773. his_patient_id, _ := c.GetInt64("his_patient_id")
  2774. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2775. admin_user_id, _ := c.GetInt64("admin_user_id")
  2776. diagnosis_id := c.GetString("diagnosis")
  2777. sick_type, _ := c.GetInt64("sick_type")
  2778. reg_type, _ := c.GetInt64("p_type")
  2779. timeLayout := "2006-01-02"
  2780. loc, _ := time.LoadLocation("Local")
  2781. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2782. if err != nil {
  2783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2784. return
  2785. }
  2786. recordDateTime := theTime.Unix()
  2787. adminUser := c.GetAdminUserInfo()
  2788. diagnosis_ids := strings.Split(diagnosis_id, ",")
  2789. var config []*models.HisXtDiagnoseConfig
  2790. for _, item := range diagnosis_ids {
  2791. id, _ := strconv.ParseInt(item, 10, 64)
  2792. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2793. config = append(config, diagnosisConfig)
  2794. }
  2795. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  2796. sickConfig, _ := service.FindSickById(sick_type)
  2797. var prescriptions []*models.HisPrescription
  2798. var start_time int64
  2799. var end_time int64
  2800. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2801. fmt.Println(his_patient_id)
  2802. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2803. timestamp := time.Now().Unix()
  2804. tempTime := time.Unix(timestamp, 0)
  2805. timeFormat := tempTime.Format("20060102150405")
  2806. chrgBchno := rand.Intn(100000) + 10000
  2807. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2808. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2809. patientPrescription, _ := service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2810. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2811. strconv.FormatInt(his.PatientId, 10)
  2812. var result string
  2813. if miConfig.InsuplcAdmdvs == "440781" { //
  2814. result = service.Gdyb2203A(his.PsnNo, his.Number, patientPrescription.Doctor, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), patientPrescription.DoctorId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  2815. } else {
  2816. result = service.Gdyb2203(his.PsnNo, his.Number, patientPrescription.Doctor, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), patientPrescription.DoctorId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  2817. }
  2818. var respJSON2 map[string]interface{}
  2819. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2822. return
  2823. }
  2824. userJSONBytes2, _ := json.Marshal(respJSON2)
  2825. var res2 ResultSix
  2826. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2827. utils.ErrorLog("解析失败:%v", err)
  2828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2829. return
  2830. }
  2831. if res2.Infcode != 0 {
  2832. adminUser := c.GetAdminUserInfo()
  2833. errlog := &models.HisOrderError{
  2834. UserOrgId: adminUser.CurrentOrgId,
  2835. Ctime: time.Now().Unix(),
  2836. Mtime: time.Now().Unix(),
  2837. ErrMsg: res2.ErrMsg,
  2838. Status: 1,
  2839. PatientId: id,
  2840. RecordTime: recordDateTime,
  2841. Stage: 3,
  2842. }
  2843. service.CreateErrMsgLog(errlog)
  2844. c.ServeSuccessJSON(map[string]interface{}{
  2845. "failed_code": -10,
  2846. "msg": res2.ErrMsg,
  2847. })
  2848. return
  2849. } else {
  2850. his.Diagnosis = diagnosis_id
  2851. his.SickType = sickConfig.ID
  2852. his.PType = fmt.Sprintf("%d", reg_type)
  2853. service.UpdateHisPatientThree(&his)
  2854. data := make(map[string]interface{})
  2855. if settle_accounts_type == 1 { //日结
  2856. prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  2857. data["pre"] = prescriptions
  2858. } else { //月结
  2859. start_time_str := c.GetString("start_time")
  2860. end_time_str := c.GetString("end_time")
  2861. timeLayout := "2006-01-02"
  2862. loc, _ := time.LoadLocation("Local")
  2863. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2864. if err != nil {
  2865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2866. return
  2867. }
  2868. recordStartTime := theStartTime.Unix()
  2869. start_time = recordStartTime
  2870. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2871. if err != nil {
  2872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2873. return
  2874. }
  2875. recordEndTime := theEndTime.Unix()
  2876. end_time = recordEndTime
  2877. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  2878. data["pre"] = prescriptions
  2879. }
  2880. client := &http.Client{}
  2881. data["psn_no"] = his.PsnNo
  2882. data["mdtrt_id"] = his.Number
  2883. data["chrg_bchno"] = chrg_bchno
  2884. data["org_name"] = miConfig.OrgName
  2885. data["doctor"] = roles.UserName
  2886. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  2887. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  2888. data["fixmedins_code"] = miConfig.Code
  2889. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  2890. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  2891. data["dept_code"] = "15"
  2892. } else {
  2893. data["dept_code"] = department.Number
  2894. }
  2895. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2896. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2897. data["secret_key"] = miConfig.SecretKey
  2898. var ids []int64
  2899. for _, item := range prescriptions {
  2900. ids = append(ids, item.ID)
  2901. }
  2902. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2903. if config.IsOpen == 1 { //对接了医保,走医保流程
  2904. bytesData, _ := json.Marshal(data)
  2905. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  2906. resp, _ := client.Do(req)
  2907. defer resp.Body.Close()
  2908. body, ioErr := ioutil.ReadAll(resp.Body)
  2909. if ioErr != nil {
  2910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2912. return
  2913. }
  2914. var respJSON map[string]interface{}
  2915. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2918. return
  2919. }
  2920. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2921. userJSONBytes, _ := json.Marshal(respJSON)
  2922. var res ResultFour
  2923. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2924. utils.ErrorLog("解析失败:%v", err)
  2925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2926. return
  2927. }
  2928. if res.Infcode == 0 {
  2929. order := &models.HisOrder{
  2930. UserOrgId: adminUser.CurrentOrgId,
  2931. HisPatientId: his.ID,
  2932. PatientId: his.PatientId,
  2933. SettleAccountsDate: recordDateTime,
  2934. Ctime: time.Now().Unix(),
  2935. Mtime: time.Now().Unix(),
  2936. Status: 1,
  2937. Number: chrg_bchno,
  2938. Infcode: res.Infcode,
  2939. WarnMsg: res.WarnMsg,
  2940. Cainfo: res.Cainfo,
  2941. ErrMsg: res.ErrMsg,
  2942. RespondTime: res.RefmsgTime,
  2943. InfRefmsgid: res.InfRefmsgid,
  2944. OrderStatus: 1,
  2945. IsMedicineInsurance: 1,
  2946. SettleType: settle_accounts_type,
  2947. SettleStartTime: start_time,
  2948. SettleEndTime: end_time,
  2949. Creator: roles.AdminUserId,
  2950. Modify: roles.AdminUserId,
  2951. PType: 2,
  2952. Diagnosis: diagnosis_id,
  2953. }
  2954. err = service.CreateOrder(order)
  2955. if err != nil {
  2956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2957. return
  2958. }
  2959. for _, item := range res.Output.Result {
  2960. temp := strings.Split(item.FeedetlSn, "-")
  2961. var advice_id int64 = 0
  2962. var project_id int64 = 0
  2963. var types int64 = 0
  2964. id, _ := strconv.ParseInt(temp[2], 10, 64)
  2965. types, _ = strconv.ParseInt(temp[1], 10, 64)
  2966. if temp[1] == "1" {
  2967. advice_id = id
  2968. project_id = 0
  2969. } else if temp[1] == "2" {
  2970. advice_id = 0
  2971. project_id = id
  2972. }
  2973. info := &models.HisOrderInfo{
  2974. OrderNumber: order.Number,
  2975. FeedetlSn: item.FeedetlSn,
  2976. UploadDate: time.Now().Unix(),
  2977. AdviceId: advice_id,
  2978. DetItemFeeSumamt: item.DetItemFeeSumamt,
  2979. Cnt: item.Cnt,
  2980. Pric: float64(item.Pric),
  2981. PatientId: his.PatientId,
  2982. PricUplmtAmt: item.PricUplmtAmt,
  2983. SelfpayProp: item.SelfpayProp,
  2984. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2985. OverlmtAmt: item.OverlmtAmt,
  2986. PreselfpayAmt: item.PreselfpayAmt,
  2987. BasMednFlag: item.BasMednFlag,
  2988. MedChrgitmType: item.MedChrgitmType,
  2989. HiNegoDrugFlag: item.HiNegoDrugFlag,
  2990. Status: 1,
  2991. Memo: item.Memo,
  2992. Mtime: time.Now().Unix(),
  2993. InscpScpAmt: item.InscpScpAmt,
  2994. DrtReimFlag: item.DrtReimFlag,
  2995. Ctime: time.Now().Unix(),
  2996. ListSpItemFlag: item.ListSpItemFlag,
  2997. ChldMedcFlag: item.ChldMedcFlag,
  2998. LmtUsedFlag: item.LmtUsedFlag,
  2999. ChrgitmLv: item.ChrgitmLv,
  3000. UserOrgId: adminUser.CurrentOrgId,
  3001. HisPatientId: his.ID,
  3002. OrderId: order.ID,
  3003. ProjectId: project_id,
  3004. Type: types,
  3005. }
  3006. service.CreateOrderInfo(info)
  3007. }
  3008. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3009. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3010. var total float64
  3011. for _, item := range prescriptions {
  3012. if item.Type == 1 { //药品
  3013. for _, subItem := range item.HisDoctorAdviceInfo {
  3014. total = total + (subItem.Price * subItem.PrescribingNumber)
  3015. }
  3016. }
  3017. if item.Type == 2 { //项目
  3018. for _, subItem := range item.HisPrescriptionProject {
  3019. total = total + (subItem.Price * float64(subItem.Count))
  3020. }
  3021. }
  3022. }
  3023. for _, item := range prescriptions {
  3024. for _, subItem := range item.HisAdditionalCharge {
  3025. total = total + (subItem.Price * float64(subItem.Count))
  3026. }
  3027. }
  3028. allTotal := fmt.Sprintf("%.2f", total)
  3029. if res.Infcode == 0 {
  3030. var rf []*ResultFive
  3031. json.Unmarshal([]byte(his.Iinfo), &rf)
  3032. chrg_bchno := chrg_bchno
  3033. cert_no := his.Certno
  3034. var insutypes []string
  3035. var insutype string
  3036. var is390 int = 0
  3037. var is310 int = 0
  3038. for _, item := range rf {
  3039. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3040. insutypes = append(insutypes, item.Insutype)
  3041. }
  3042. }
  3043. if len(insutypes) == 1 {
  3044. insutype = insutypes[0]
  3045. } else {
  3046. for _, i := range insutypes {
  3047. if i == "390" {
  3048. is390 = 1
  3049. }
  3050. if i == "310" {
  3051. is310 = 1
  3052. }
  3053. }
  3054. }
  3055. if is390 == 1 {
  3056. insutype = "390"
  3057. }
  3058. if is310 == 1 {
  3059. insutype = "310"
  3060. }
  3061. if len(insutypes) == 0 {
  3062. insutype = "310"
  3063. }
  3064. //insutype = "390"
  3065. if his.IdCardType == 1 {
  3066. cert_no = his.MedicalInsuranceNumber
  3067. } else {
  3068. cert_no = his.Certno
  3069. }
  3070. result := service.Gdyb2206(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)
  3071. var dat map[string]interface{}
  3072. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3073. fmt.Println(dat)
  3074. } else {
  3075. fmt.Println(err)
  3076. }
  3077. userJSONBytes, _ := json.Marshal(dat)
  3078. var res ResultSeven
  3079. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3080. utils.ErrorLog("解析失败:%v", err)
  3081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3082. return
  3083. }
  3084. if res.Infcode != 0 {
  3085. errlog := &models.HisOrderError{
  3086. UserOrgId: adminUser.CurrentOrgId,
  3087. Ctime: time.Now().Unix(),
  3088. Mtime: time.Now().Unix(),
  3089. Number: chrg_bchno,
  3090. ErrMsg: res.ErrMsg,
  3091. Status: 1,
  3092. PatientId: id,
  3093. RecordTime: recordDateTime,
  3094. Stage: 20,
  3095. }
  3096. service.CreateErrMsgLog(errlog)
  3097. c.ServeSuccessJSON(map[string]interface{}{
  3098. "failed_code": -10,
  3099. "msg": res.ErrMsg,
  3100. })
  3101. return
  3102. } else {
  3103. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3104. order.OrderStatus = 1
  3105. order.IsPre = 1
  3106. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3107. order.SetlId = res.Output.Setlinfo.SetlID
  3108. order.PsnNo = res.Output.Setlinfo.PsnNo
  3109. order.PsnName = res.Output.Setlinfo.PsnName
  3110. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3111. order.Certno = res.Output.Setlinfo.Certno
  3112. order.Gend = res.Output.Setlinfo.Gend
  3113. order.Naty = res.Output.Setlinfo.Naty
  3114. order.Age = res.Output.Setlinfo.Age
  3115. order.Insutype = res.Output.Setlinfo.Insutype
  3116. order.PsnType = res.Output.Setlinfo.PsnType
  3117. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3118. order.SetlTime = res.Output.Setlinfo.SetlTime
  3119. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3120. order.MedType = res.Output.Setlinfo.MedType
  3121. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3122. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3123. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3124. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3125. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3126. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3127. order.HifpPay = res.Output.Setlinfo.HifpPay
  3128. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3129. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3130. order.HifesPay = res.Output.Setlinfo.HifesPay
  3131. order.HifobPay = res.Output.Setlinfo.HifobPay
  3132. order.MafPay = res.Output.Setlinfo.MafPay
  3133. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3134. order.OthPay = res.Output.Setlinfo.OthPay
  3135. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3136. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3137. order.AcctPay = res.Output.Setlinfo.AcctPay
  3138. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3139. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3140. order.Balc = res.Output.Setlinfo.Balc
  3141. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3142. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3143. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3144. order.ClrWay = res.Output.Setlinfo.ClrWay
  3145. order.Creator = order.Creator
  3146. order.Modify = roles.AdminUserId
  3147. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3148. detailStr := string(setlDetail)
  3149. order.SetlDetail = detailStr
  3150. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3151. err = service.UpDateOrder(order)
  3152. if err == nil {
  3153. c.ServeSuccessJSON(map[string]interface{}{
  3154. "msg": "预结算成功",
  3155. })
  3156. } else {
  3157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3158. return
  3159. }
  3160. }
  3161. } else {
  3162. adminUser := c.GetAdminUserInfo()
  3163. errlog := &models.HisOrderError{
  3164. UserOrgId: adminUser.CurrentOrgId,
  3165. Ctime: time.Now().Unix(),
  3166. Mtime: time.Now().Unix(),
  3167. ErrMsg: res.ErrMsg,
  3168. Status: 1,
  3169. PatientId: id,
  3170. RecordTime: recordDateTime,
  3171. Stage: 4,
  3172. }
  3173. service.CreateErrMsgLog(errlog)
  3174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3175. return
  3176. }
  3177. } else {
  3178. adminUser := c.GetAdminUserInfo()
  3179. errlog := &models.HisOrderError{
  3180. UserOrgId: adminUser.CurrentOrgId,
  3181. Ctime: time.Now().Unix(),
  3182. Mtime: time.Now().Unix(),
  3183. ErrMsg: res.ErrMsg,
  3184. Status: 1,
  3185. PatientId: id,
  3186. RecordTime: recordDateTime,
  3187. Stage: 4,
  3188. }
  3189. service.CreateErrMsgLog(errlog)
  3190. c.ServeSuccessJSON(map[string]interface{}{
  3191. "failed_code": -10,
  3192. "msg": res.ErrMsg,
  3193. })
  3194. return
  3195. }
  3196. }
  3197. }
  3198. }
  3199. //func (c *HisApiController) GetSettleInfo() {
  3200. // id, _ := c.GetInt64("id")
  3201. // order_id, _ := c.GetInt64("order_id")
  3202. //
  3203. // record_time := c.GetString("record_time")
  3204. // pay_way, _ := c.GetInt64("pay_way")
  3205. // pay_price, _ := c.GetFloat("pay_price")
  3206. // pay_card_no := c.GetString("pay_card_no")
  3207. // discount_price, _ := c.GetFloat("discount_price")
  3208. // preferential_price, _ := c.GetFloat("preferential_price")
  3209. // reality_price, _ := c.GetFloat("reality_price")
  3210. // found_price, _ := c.GetFloat("found_price")
  3211. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3212. // private_price, _ := c.GetFloat("private_price")
  3213. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3214. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3215. //
  3216. // timeLayout := "2006-01-02"
  3217. // loc, _ := time.LoadLocation("Local")
  3218. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3219. // if err != nil {
  3220. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3221. // return
  3222. // }
  3223. // recordDateTime := theTime.Unix()
  3224. // adminUser := c.GetAdminUserInfo()
  3225. //
  3226. // var prescriptions []*models.HisPrescription
  3227. //
  3228. // data := make(map[string]interface{})
  3229. // if settle_accounts_type == 1 { //日结
  3230. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  3231. // data["pre"] = prescriptions
  3232. //
  3233. // } else { //月结
  3234. // start_time_str := c.GetString("start_time")
  3235. // end_time_str := c.GetString("end_time")
  3236. // timeLayout := "2006-01-02"
  3237. // loc, _ := time.LoadLocation("Local")
  3238. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3239. // if err != nil {
  3240. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3241. // return
  3242. // }
  3243. // recordStartTime := theStartTime.Unix()
  3244. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3245. // if err != nil {
  3246. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3247. // return
  3248. // }
  3249. // recordEndTime := theEndTime.Unix()
  3250. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  3251. // data["pre"] = prescriptions
  3252. //
  3253. // }
  3254. //
  3255. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3256. //
  3257. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3258. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3259. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3260. // strconv.FormatInt(his.PatientId, 10)
  3261. //
  3262. // order_src, _ := service.GetHisOrderByID(order_id)
  3263. //
  3264. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3265. // if config.IsOpen == 1 { //对接了医保,走医保流程
  3266. //
  3267. // var total float64
  3268. // for _, item := range prescriptions {
  3269. // if item.Type == 1 { //药品
  3270. // for _, subItem := range item.HisDoctorAdviceInfo {
  3271. // total = total + (subItem.Price * subItem.PrescribingNumber)
  3272. // }
  3273. // }
  3274. // if item.Type == 2 { //项目
  3275. // for _, subItem := range item.HisPrescriptionProject {
  3276. // total = total + (subItem.Price * float64(subItem.Count))
  3277. // }
  3278. // }
  3279. // }
  3280. //
  3281. // for _, item := range prescriptions {
  3282. // for _, subItem := range item.HisAdditionalCharge {
  3283. // total = total + (subItem.Price * float64(subItem.Count))
  3284. // }
  3285. // }
  3286. //
  3287. // allTotal := fmt.Sprintf("%.2f", total)
  3288. // var rf []*ResultFive
  3289. // json.Unmarshal([]byte(his.Iinfo), &rf)
  3290. // psn_no := order_src.PsnNo
  3291. // mdtrt_id := order_src.MdtrtId
  3292. // chrg_bchno := order_src.Number
  3293. // cert_no := order_src.Certno
  3294. // insutype := rf[0].Insutype
  3295. //
  3296. // if his.IdCardType == 1 {
  3297. // cert_no = his.MedicalInsuranceNumber
  3298. // } else {
  3299. // cert_no = his.Certno
  3300. // }
  3301. //
  3302. // 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)
  3303. // var dat map[string]interface{}
  3304. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3305. // fmt.Println(dat)
  3306. // } else {
  3307. // fmt.Println(err)
  3308. // }
  3309. //
  3310. // userJSONBytes, _ := json.Marshal(dat)
  3311. //
  3312. //
  3313. //
  3314. // var res ResultSeven
  3315. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3316. // utils.ErrorLog("解析失败:%v", err)
  3317. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3318. // return
  3319. // }
  3320. // if res.Infcode == -1 {
  3321. // errlog := &models.HisOrderError{
  3322. // UserOrgId: adminUser.CurrentOrgId,
  3323. // Ctime: time.Now().Unix(),
  3324. // Mtime: time.Now().Unix(),
  3325. // Number: chrg_bchno,
  3326. // ErrMsg: res.ErrMsg,
  3327. // Status: 1,
  3328. // PatientId: id,
  3329. // RecordTime: recordDateTime,
  3330. // Stage: 6,
  3331. // }
  3332. // service.CreateErrMsgLog(errlog)
  3333. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3334. // return
  3335. // } else {
  3336. // order_src.OrderStatus = 2
  3337. // order_src.PayWay = pay_way
  3338. // order_src.PayPrice = pay_price
  3339. // order_src.PayCardNo = pay_card_no
  3340. // order_src.DiscountPrice = discount_price
  3341. // order_src.PreferentialPrice = preferential_price
  3342. // order_src.RealityPrice = reality_price
  3343. // order_src.FoundPrice = found_price
  3344. // order_src.MedicalInsurancePrice = medical_insurance_price
  3345. // order_src.PrivatePrice = private_price
  3346. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  3347. // order_src.SetlId = res.Output.Setlinfo.SetlID
  3348. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  3349. // order_src.PsnName = res.Output.Setlinfo.PsnName
  3350. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  3351. // order_src.Certno = res.Output.Setlinfo.Certno
  3352. // order_src.Gend = res.Output.Setlinfo.Gend
  3353. // order_src.Naty = res.Output.Setlinfo.Naty
  3354. // order_src.Age = res.Output.Setlinfo.Age
  3355. // order_src.Insutype = res.Output.Setlinfo.Insutype
  3356. // order_src.PsnType = res.Output.Setlinfo.PsnType
  3357. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3358. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  3359. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3360. // order_src.MedType = res.Output.Setlinfo.MedType
  3361. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3362. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3363. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3364. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3365. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3366. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3367. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  3368. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  3369. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3370. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  3371. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  3372. // order_src.MafPay = res.Output.Setlinfo.MafPay
  3373. // order_src.OthPay = res.Output.Setlinfo.OthPay
  3374. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3375. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3376. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  3377. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3378. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3379. // order_src.Balc = res.Output.Setlinfo.Balc
  3380. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3381. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3382. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  3383. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  3384. // order_src.Creator = order_src.Creator
  3385. // order_src.Modify = roles.ID
  3386. // order_src.RequestLog = src_resquest
  3387. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3388. // detailStr := string(setlDetail)
  3389. // order_src.SetlDetail = detailStr
  3390. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3391. // err = service.UpDateOrder(order_src)
  3392. //
  3393. // if err == nil {
  3394. // c.ServeSuccessJSON(map[string]interface{}{
  3395. // "msg": "结算成功",
  3396. // })
  3397. // } else {
  3398. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3399. // return
  3400. // }
  3401. // }
  3402. // }
  3403. //}
  3404. //退款
  3405. func (c *HisApiController) Refund() {
  3406. order_id, _ := c.GetInt64("order_id")
  3407. admin_user_id, _ := c.GetInt64("admin_user_id")
  3408. //record_time := c.GetString("record_time")
  3409. //patient_id, _ := c.GetInt64("patient_id")
  3410. //timeLayout := "2006-01-02"
  3411. //loc, _ := time.LoadLocation("Local")
  3412. adminUser := c.GetAdminUserInfo()
  3413. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3414. //if err != nil {
  3415. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3416. // return
  3417. //}
  3418. //recordDateTime := theTime.Unix()
  3419. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3420. var order models.HisOrder
  3421. order, _ = service.GetHisOrderByID(order_id)
  3422. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3423. if order.ID == 0 {
  3424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3425. return
  3426. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3427. }
  3428. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3429. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3430. if config.IsOpen == 1 { //对接了医保,走医保流程
  3431. result, src_resquest := service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  3432. var dat map[string]interface{}
  3433. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3434. fmt.Println(dat)
  3435. } else {
  3436. fmt.Println(err)
  3437. }
  3438. userJSONBytes, _ := json.Marshal(dat)
  3439. var res ResultSixteen
  3440. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3441. utils.ErrorLog("解析失败:%v", err)
  3442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3443. return
  3444. }
  3445. if res.Infcode == 0 {
  3446. result := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  3447. var dat map[string]interface{}
  3448. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3449. fmt.Println(dat)
  3450. } else {
  3451. fmt.Println(err)
  3452. }
  3453. userJSONBytes, _ := json.Marshal(dat)
  3454. var res2 ResultSix
  3455. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3456. utils.ErrorLog("解析失败:%v", err)
  3457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3458. return
  3459. }
  3460. if res2.Infcode == 0 {
  3461. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  3462. if err == nil {
  3463. c.ServeSuccessJSON(map[string]interface{}{
  3464. "msg": "退费成功",
  3465. })
  3466. } else {
  3467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3468. return
  3469. }
  3470. } else {
  3471. c.ServeSuccessJSON(map[string]interface{}{
  3472. "code": -10,
  3473. "msg": res2.ErrMsg,
  3474. })
  3475. }
  3476. } else {
  3477. c.ServeSuccessJSON(map[string]interface{}{
  3478. "code": -10,
  3479. "msg": res.ErrMsg,
  3480. })
  3481. }
  3482. }
  3483. }
  3484. func (c *HisApiController) RefundNumber() {
  3485. record_time := c.GetString("record_time")
  3486. //patient_id, _ := c.GetInt64("patient_id")
  3487. admin_user_id, _ := c.GetInt64("admin_user_id")
  3488. his_patient_id, _ := c.GetInt64("id")
  3489. timeLayout := "2006-01-02"
  3490. loc, _ := time.LoadLocation("Local")
  3491. adminUser := c.GetAdminUserInfo()
  3492. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3493. fmt.Println(err)
  3494. if err != nil {
  3495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3496. return
  3497. }
  3498. recordDateTime := theTime.Unix()
  3499. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3500. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  3501. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3502. //order, _ := service.GetHisOrderByID(order_id)
  3503. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3504. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3505. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3506. if config.IsOpen == 1 { //对接了医保,走医保流程
  3507. api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  3508. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  3509. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3510. resp3, requestErr3 := http.Get(api3)
  3511. if requestErr3 != nil {
  3512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3513. return
  3514. }
  3515. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  3516. if ioErr3 != nil {
  3517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  3518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3519. return
  3520. }
  3521. var respJSON3 map[string]interface{}
  3522. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  3523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3525. return
  3526. }
  3527. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3528. userJSONBytes3, _ := json.Marshal(respJSON3)
  3529. var res2 ResultSix
  3530. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  3531. utils.ErrorLog("解析失败:%v", err)
  3532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3533. return
  3534. }
  3535. if res2.Infcode == 0 {
  3536. if err == nil {
  3537. c.ServeSuccessJSON(map[string]interface{}{
  3538. "msg": "退号成功",
  3539. })
  3540. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  3541. } else {
  3542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3543. return
  3544. }
  3545. } else {
  3546. c.ServeSuccessJSON(map[string]interface{}{
  3547. "code": -10,
  3548. "msg": res2.ErrMsg,
  3549. })
  3550. }
  3551. } else {
  3552. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  3553. //if err == nil {
  3554. // c.ServeSuccessJSON(map[string]interface{}{
  3555. // "msg": "退费成功",
  3556. // })
  3557. //} else {
  3558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3559. // return
  3560. //}
  3561. }
  3562. }
  3563. func (c *HisApiController) RefundDetail() {
  3564. order_id, _ := c.GetInt64("order_id")
  3565. his_patient_id, _ := c.GetInt64("his_patient_id")
  3566. number := c.GetString("number")
  3567. record_time := c.GetString("record_time")
  3568. patient_id, _ := c.GetInt64("patient_id")
  3569. timeLayout := "2006-01-02"
  3570. loc, _ := time.LoadLocation("Local")
  3571. adminUser := c.GetAdminUserInfo()
  3572. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3573. fmt.Println(err)
  3574. if err != nil {
  3575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3576. return
  3577. }
  3578. recordDateTime := theTime.Unix()
  3579. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3580. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3581. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3582. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3583. var order models.HisOrder
  3584. order, _ = service.GetHisOrderByID(order_id)
  3585. if order.ID == 0 {
  3586. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3587. }
  3588. if config.IsOpen == 1 { //对接了医保,走医保流程
  3589. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  3590. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  3591. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3592. resp2, requestErr2 := http.Get(api2)
  3593. if requestErr2 != nil {
  3594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3595. return
  3596. }
  3597. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  3598. if ioErr2 != nil {
  3599. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  3600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3601. return
  3602. }
  3603. var respJSON2 map[string]interface{}
  3604. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  3605. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3607. return
  3608. }
  3609. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  3610. if err == nil {
  3611. c.ServeSuccessJSON(map[string]interface{}{
  3612. "msg": "退费成功",
  3613. })
  3614. } else {
  3615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3616. return
  3617. }
  3618. } else {
  3619. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  3620. if err == nil {
  3621. c.ServeSuccessJSON(map[string]interface{}{
  3622. "msg": "退费成功",
  3623. })
  3624. } else {
  3625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3626. return
  3627. }
  3628. }
  3629. }
  3630. //对账
  3631. func (c *HisApiController) GetCheckAccount() {
  3632. start_time := c.GetString("start_time")
  3633. end_time := c.GetString("end_time")
  3634. insutype := c.GetString("insutype")
  3635. clr_type := c.GetString("clr_type")
  3636. admin_user_id, _ := c.GetInt64("admin_user_id")
  3637. adminUser := c.GetAdminUserInfo()
  3638. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3639. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3640. timeLayout := "2006-01-02"
  3641. loc, _ := time.LoadLocation("Local")
  3642. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3643. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  3644. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  3645. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  3646. fixmedins_setl_cnt := int64(len(orders))
  3647. //
  3648. ////撤销的算2条数据为一笔
  3649. //for _, item := range orders_two {
  3650. // if item.OrderStatus == 3 {
  3651. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  3652. // }
  3653. //}
  3654. var medfee_sumamt float64
  3655. var acct_pay float64
  3656. var fund_pay_sumamt float64
  3657. for _, item := range orders {
  3658. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  3659. acct_pay = acct_pay + item.AcctPay
  3660. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  3661. }
  3662. var user_name string
  3663. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3664. if role.ID == 0 {
  3665. user_name = "xxx"
  3666. } else {
  3667. user_name = role.UserName
  3668. }
  3669. if config.IsOpen == 1 {
  3670. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3671. "insutype=" + insutype +
  3672. "&clr_type=" + clr_type +
  3673. "&setl_optins=" + "定点医保中心" +
  3674. "&stmt_begndate=" + start_time +
  3675. "&stm_enddate=" + end_time +
  3676. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  3677. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  3678. "&acct_pay=" + fmt.Sprintf("%.2f", acct_pay) +
  3679. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  3680. "&fixmedins_code=" + miConfig.Code +
  3681. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3682. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3683. "&secret_key=" + miConfig.SecretKey +
  3684. "&org_name=" + miConfig.OrgName +
  3685. "&doctor=" + user_name
  3686. fmt.Println(api)
  3687. resp, requestErr := http.Get(api)
  3688. if requestErr != nil {
  3689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3690. return
  3691. }
  3692. body, ioErr := ioutil.ReadAll(resp.Body)
  3693. fmt.Println(body)
  3694. if ioErr != nil {
  3695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3697. return
  3698. }
  3699. var respJSON map[string]interface{}
  3700. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3703. return
  3704. }
  3705. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3706. userJSONBytes, _ := json.Marshal(respJSON)
  3707. var res ResultEight
  3708. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3709. utils.ErrorLog("解析失败:%v", err)
  3710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3711. return
  3712. }
  3713. if res.Infcode == 0 {
  3714. if res.Output.Stmtinfo.StmtRslt == "0" {
  3715. micc := &models.MedicalInsuranceCostCompare{
  3716. StartTime: startime.Unix(),
  3717. EndTime: endtime.Unix(),
  3718. Insutype: insutype,
  3719. CheckType: 1,
  3720. Num: fixmedins_setl_cnt,
  3721. Mtime: time.Now().Unix(),
  3722. Status: 1,
  3723. UserOrgId: adminUser.CurrentOrgId,
  3724. CostTotal: medfee_sumamt,
  3725. FuncTotal: fund_pay_sumamt,
  3726. PsnPay: acct_pay,
  3727. Creator: admin_user_id,
  3728. Ctime: time.Now().Unix(),
  3729. }
  3730. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  3731. if err == nil {
  3732. c.ServeSuccessJSON(map[string]interface{}{
  3733. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  3734. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  3735. })
  3736. } else {
  3737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3738. }
  3739. } else {
  3740. c.ServeSuccessJSON(map[string]interface{}{
  3741. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  3742. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  3743. })
  3744. }
  3745. } else {
  3746. c.ServeSuccessJSON(map[string]interface{}{
  3747. "code": -10,
  3748. "msg": res.ErrMsg,
  3749. })
  3750. }
  3751. }
  3752. }
  3753. func (c *HisApiController) Check310() {
  3754. adminUser := c.GetAdminUserInfo()
  3755. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3756. var user_name string
  3757. user_name = "xxx"
  3758. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3759. "insutype=" + "310" +
  3760. "&clr_type=" + "11" +
  3761. "&setl_optins=" + "定点医保中心" +
  3762. "&stmt_begndate=" + "2021-03-01" +
  3763. "&stm_enddate=" + "2021-03-31" +
  3764. "&medfee_sumamt=" + "11521" +
  3765. "&fund_pay_sumamt=" + "10166.66" +
  3766. "&acct_pay=" + "0" +
  3767. "&fixmedins_setl_cnt=" + "7" +
  3768. "&fixmedins_code=" + miConfig.Code +
  3769. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3770. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3771. "&secret_key=" + miConfig.SecretKey +
  3772. "&org_name=" + miConfig.OrgName +
  3773. "&doctor=" + user_name
  3774. fmt.Println(api)
  3775. resp, requestErr := http.Get(api)
  3776. if requestErr != nil {
  3777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3778. return
  3779. }
  3780. body, ioErr := ioutil.ReadAll(resp.Body)
  3781. fmt.Println(body)
  3782. if ioErr != nil {
  3783. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3785. return
  3786. }
  3787. var respJSON map[string]interface{}
  3788. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3791. return
  3792. }
  3793. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3794. userJSONBytes, _ := json.Marshal(respJSON)
  3795. var res ResultEight
  3796. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3797. utils.ErrorLog("解析失败:%v", err)
  3798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3799. return
  3800. }
  3801. }
  3802. func (c *HisApiController) Check390() {
  3803. adminUser := c.GetAdminUserInfo()
  3804. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3805. var user_name string
  3806. user_name = "张俊杰"
  3807. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3808. "insutype=" + "390" +
  3809. "&clr_type=" + "11" +
  3810. "&setl_optins=" + "定点医保中心" +
  3811. "&stmt_begndate=" + "2021-03-01" +
  3812. "&stm_enddate=" + "2021-03-31" +
  3813. "&medfee_sumamt=" + "209318.43" +
  3814. "&fund_pay_sumamt=" + "188029.12" +
  3815. "&acct_pay=" + "0" +
  3816. "&fixmedins_setl_cnt=" + "48" +
  3817. "&fixmedins_code=" + miConfig.Code +
  3818. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3819. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3820. "&secret_key=" + miConfig.SecretKey +
  3821. "&org_name=" + miConfig.OrgName +
  3822. "&doctor=" + user_name
  3823. fmt.Println(api)
  3824. resp, requestErr := http.Get(api)
  3825. if requestErr != nil {
  3826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3827. return
  3828. }
  3829. body, ioErr := ioutil.ReadAll(resp.Body)
  3830. fmt.Println(body)
  3831. if ioErr != nil {
  3832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3834. return
  3835. }
  3836. var respJSON map[string]interface{}
  3837. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3840. return
  3841. }
  3842. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3843. userJSONBytes, _ := json.Marshal(respJSON)
  3844. var res ResultEight
  3845. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3846. utils.ErrorLog("解析失败:%v", err)
  3847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3848. return
  3849. }
  3850. }
  3851. //对账明细
  3852. func (c *HisApiController) GetCheckDetailAccount() {
  3853. start_time := c.GetString("start_time")
  3854. end_time := c.GetString("end_time")
  3855. admin_user_id, _ := c.GetInt64("admin_user_id")
  3856. adminUser := c.GetAdminUserInfo()
  3857. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3858. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3859. timeLayout := "2006-01-02"
  3860. loc, _ := time.LoadLocation("Local")
  3861. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3862. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  3863. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  3864. Mkdir(miConfig.OrgName)
  3865. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  3866. file_name := file + ".txt"
  3867. zip_name := file + ".zip"
  3868. zip_path := miConfig.OrgName + "/" + zip_name
  3869. file_path := miConfig.OrgName + "/" + file_name
  3870. decimal.DivisionPrecision = 2
  3871. var medfee_sumamt float64
  3872. var psn_cash_pay float64
  3873. var fund_pay_sumamt float64
  3874. fixmedins_setl_cnt := int64(len(orders))
  3875. for _, item := range orders {
  3876. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  3877. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  3878. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  3879. }
  3880. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  3881. defer f.Close()
  3882. if err != nil {
  3883. fmt.Println(err.Error())
  3884. } else {
  3885. for _, item := range orders {
  3886. var refd_setl_flag string
  3887. if item.OrderStatus == 2 {
  3888. refd_setl_flag = "0"
  3889. var str string
  3890. str = item.SetlId + " " +
  3891. item.MdtrtId + " " +
  3892. item.PsnNo + " " +
  3893. fmt.Sprintf("%.2f", item.MedfeeSumamt) + " " +
  3894. fmt.Sprintf("%.2f", item.FundPaySumamt) + " " +
  3895. fmt.Sprintf("%.2f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  3896. _, err = f.Write([]byte(str))
  3897. }
  3898. if item.OrderStatus == 3 {
  3899. var str string
  3900. str = item.SetlId + " " +
  3901. item.MdtrtId + " " +
  3902. item.PsnNo + " " +
  3903. fmt.Sprintf("%.2f", item.MedfeeSumamt) + " " +
  3904. fmt.Sprintf("%.2f", item.FundPaySumamt) + " " +
  3905. fmt.Sprintf("%.2f", item.AcctPay) + " " + "1" + "\r\n"
  3906. _, err = f.Write([]byte(str))
  3907. var str2 string
  3908. str2 = item.SetlId + " " +
  3909. item.MdtrtId + " " +
  3910. item.PsnNo + " " +
  3911. fmt.Sprintf("%.2f", 0-item.MedfeeSumamt) + " " +
  3912. fmt.Sprintf("%.2f", 0-item.FundPaySumamt) + " " +
  3913. fmt.Sprintf("%.2f", 0-item.AcctPay) + " " + "1" + "\r\n"
  3914. _, err = f.Write([]byte(str2))
  3915. }
  3916. }
  3917. }
  3918. Zip(file_path, zip_path)
  3919. fmt.Println(ReadFile(zip_path))
  3920. fmt.Println(string(ReadFile(zip_path)))
  3921. if config.IsOpen == 1 {
  3922. var user_name string
  3923. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3924. if role.ID == 0 {
  3925. user_name = "管理员"
  3926. } else {
  3927. user_name = role.UserName
  3928. }
  3929. baseParams := models.BaseParams{
  3930. SecretKey: miConfig.SecretKey,
  3931. FixmedinsCode: miConfig.Code,
  3932. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  3933. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  3934. OrgName: miConfig.OrgName,
  3935. Doctor: user_name,
  3936. }
  3937. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  3938. var dat map[string]interface{}
  3939. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3940. fmt.Println(dat)
  3941. } else {
  3942. fmt.Println(err)
  3943. }
  3944. userJSONBytes, _ := json.Marshal(dat)
  3945. var res ResultNine
  3946. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3947. utils.ErrorLog("解析失败:%v", err)
  3948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3949. return
  3950. }
  3951. if res.Infcode == 0 {
  3952. fileNo := res.Output.FileQuryNo
  3953. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  3954. "file_qury_no=" + fileNo +
  3955. "&setl_optins=" + "定点医保中心" +
  3956. "&stmt_begndate=" + start_time +
  3957. "&stm_enddate=" + end_time +
  3958. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  3959. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  3960. "&cash_payamt=" + fmt.Sprintf("%.2f", psn_cash_pay) +
  3961. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  3962. "&fixmedins_code=" + miConfig.Code +
  3963. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3964. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3965. "&secret_key=" + miConfig.SecretKey +
  3966. "&org_name=" + miConfig.OrgName +
  3967. "&doctor=" + user_name
  3968. resp, requestErr := http.Get(api)
  3969. if requestErr != nil {
  3970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3971. return
  3972. }
  3973. body, ioErr := ioutil.ReadAll(resp.Body)
  3974. if ioErr != nil {
  3975. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3977. return
  3978. }
  3979. var respJSON map[string]interface{}
  3980. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3983. return
  3984. }
  3985. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3986. userJSONBytes, _ := json.Marshal(respJSON)
  3987. var res ResultTen
  3988. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3989. utils.ErrorLog("解析失败:%v", err)
  3990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3991. return
  3992. }
  3993. if res.Infcode == 0 {
  3994. service.Gdyb9102(baseParams, zip_name, fileNo)
  3995. micc := &models.MedicalInsuranceCostCompare{
  3996. StartTime: startime.Unix(),
  3997. EndTime: endtime.Unix(),
  3998. Insutype: "0",
  3999. CheckType: 2,
  4000. Num: fixmedins_setl_cnt,
  4001. Mtime: time.Now().Unix(),
  4002. Status: 1,
  4003. UserOrgId: adminUser.CurrentOrgId,
  4004. CostTotal: medfee_sumamt,
  4005. FuncTotal: fund_pay_sumamt,
  4006. PsnPay: psn_cash_pay,
  4007. Creator: admin_user_id,
  4008. Ctime: time.Now().Unix(),
  4009. }
  4010. service.CreateMedicalInsuranceCostCompareRecord(micc)
  4011. c.ServeSuccessJSON(map[string]interface{}{
  4012. "msg": "明细对账成功",
  4013. })
  4014. }
  4015. } else {
  4016. }
  4017. }
  4018. }
  4019. func (c *HisApiController) GetSettleAccounts() {
  4020. //id, _ := c.GetInt64("id")
  4021. //record_time := c.GetString("record_time")
  4022. order_id, _ := c.GetInt64("order_id")
  4023. admin_user_id, _ := c.GetInt64("admin_user_id")
  4024. //timeLayout := "2006-01-02"
  4025. //loc, _ := time.LoadLocation("Local")
  4026. //
  4027. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4028. //if err != nil {
  4029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4030. // return
  4031. //}
  4032. //recordDateTime := theTime.Unix()
  4033. adminUser := c.GetAdminUserInfo()
  4034. order, _ := service.GetHisOrderByID(order_id)
  4035. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4036. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  4037. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  4038. orderInfos = append(orderInfos, orderInfos_two...)
  4039. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  4040. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4041. //var config []*models.HisXtDiagnoseConfig
  4042. var name string
  4043. for _, item := range diagnosis_ids {
  4044. id, _ := strconv.ParseInt(item, 10, 64)
  4045. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4046. if len(name) == 0 {
  4047. name = diagnosisConfig.ClassName
  4048. } else {
  4049. name = name + "," + diagnosisConfig.ClassName
  4050. }
  4051. }
  4052. var bedCostTotal float64 = 0 //床位总费
  4053. var bedCostSelfTotal float64 = 0 //床位自费
  4054. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4055. var operationCostTotal float64 = 0 //手术费
  4056. var operationCostSelfTotal float64 = 0 //手术费
  4057. var operationCostPartSelfTotal float64 = 0 //手术费
  4058. var otherCostTotal float64 = 0 //其他费用
  4059. var otherCostSelfTotal float64 = 0 //其他费用
  4060. var otherCostPartSelfTotal float64 = 0 //其他费用
  4061. var materialCostTotal float64 = 0 //材料费
  4062. var materialCostSelfTotal float64 = 0 //材料费
  4063. var materialCostPartSelfTotal float64 = 0 //材料费
  4064. var westernMedicineCostTotal float64 = 0 //西药费
  4065. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4066. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4067. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4068. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4069. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4070. var checkCostTotal float64 = 0 //检查费
  4071. var checkCostSelfTotal float64 = 0 //检查费
  4072. var checkCostPartSelfTotal float64 = 0 //检查费
  4073. var laboratoryCostTotal float64 = 0 //化验费
  4074. var laboratoryCostSelfTotal float64 = 0 //化验费
  4075. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4076. var treatCostTotal float64 = 0 //治疗费用
  4077. var treatCostSelfTotal float64 = 0 //治疗费用
  4078. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4079. decimal.DivisionPrecision = 2
  4080. for _, item := range orderInfos {
  4081. if item.MedChrgitmType == "01" { //床位费
  4082. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4083. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4084. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4085. }
  4086. if item.MedChrgitmType == "03" { //检查费
  4087. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4088. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4089. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4090. }
  4091. if item.MedChrgitmType == "04" { //化验费
  4092. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4093. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4094. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4095. }
  4096. if item.MedChrgitmType == "05" { //治疗费
  4097. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4098. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4099. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4100. }
  4101. if item.MedChrgitmType == "06" { //手术费
  4102. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4103. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4104. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4105. }
  4106. if item.MedChrgitmType == "08" { //材料费
  4107. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4108. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4109. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4110. }
  4111. if item.MedChrgitmType == "09" { //西药费
  4112. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4113. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4114. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4115. }
  4116. if item.MedChrgitmType == "11" { //中成费
  4117. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4118. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4119. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4120. }
  4121. if item.MedChrgitmType == "14" { //其他费
  4122. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4123. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4124. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4125. }
  4126. }
  4127. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4128. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4129. var user_name string
  4130. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4131. if role.ID == 0 {
  4132. user_name = "管理员"
  4133. } else {
  4134. user_name = role.UserName
  4135. }
  4136. baseParams := models.BaseParams{
  4137. SecretKey: miConfig.SecretKey,
  4138. FixmedinsCode: miConfig.Code,
  4139. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4140. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4141. OrgName: miConfig.OrgName,
  4142. Doctor: user_name,
  4143. }
  4144. businessParams := models.BusinessParams{
  4145. PsnNo: order.PsnNo,
  4146. MdtrtId: order.MdtrtId,
  4147. SetlId: order.SetlId,
  4148. }
  4149. if config.IsOpen == 1 {
  4150. result := service.Gdyb5203(baseParams, businessParams)
  4151. var dat map[string]interface{}
  4152. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4153. fmt.Println(dat)
  4154. } else {
  4155. fmt.Println(err)
  4156. }
  4157. userJSONBytes, _ := json.Marshal(dat)
  4158. var res ResultEleven
  4159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4160. utils.ErrorLog("解析失败:%v", err)
  4161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4162. return
  4163. }
  4164. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4165. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  4166. if res.Infcode == 0 {
  4167. c.ServeSuccessJSON(map[string]interface{}{
  4168. "diagnosis": name,
  4169. "order_infos": orderInfos,
  4170. "number": order.MdtrtId,
  4171. "date": order.SettleAccountsDate,
  4172. "charge_admin": charge_admin,
  4173. "printor_admin": printor_admin,
  4174. "info": res.Output.Setlinfo,
  4175. "bedCostTotal": bedCostTotal,
  4176. "bedCostSelfTotal": bedCostSelfTotal,
  4177. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  4178. "operationCostTotal": operationCostTotal,
  4179. "operationCostSelfTotal": operationCostSelfTotal,
  4180. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  4181. "otherCostTotal": otherCostTotal,
  4182. "otherCostSelfTotal": otherCostSelfTotal,
  4183. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  4184. "materialCostTotal": materialCostTotal,
  4185. "materialCostSelfTotal": materialCostSelfTotal,
  4186. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  4187. "westernMedicineCostTotal": westernMedicineCostTotal,
  4188. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  4189. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  4190. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  4191. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  4192. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  4193. "checkCostTotal": checkCostTotal,
  4194. "checkCostSelfTotal": checkCostSelfTotal,
  4195. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  4196. "laboratoryCostTotal": laboratoryCostTotal,
  4197. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  4198. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  4199. "treatCostTotal": treatCostTotal,
  4200. "treatCostSelfTotal": treatCostSelfTotal,
  4201. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  4202. })
  4203. }
  4204. }
  4205. }
  4206. func (c *HisApiController) CheckTreatment() {
  4207. patient_id, _ := c.GetInt64("patient_id", 0)
  4208. record_time := c.GetString("record_time")
  4209. insutype := c.GetString("insutype")
  4210. timeLayout := "2006-01-02"
  4211. loc, _ := time.LoadLocation("Local")
  4212. adminUser := c.GetAdminUserInfo()
  4213. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4214. fmt.Println(err)
  4215. if err != nil {
  4216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4217. return
  4218. }
  4219. recordDateTime := theTime.Unix()
  4220. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4221. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4222. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4223. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4224. var user_name string
  4225. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  4226. if role.ID == 0 {
  4227. user_name = "xxx"
  4228. } else {
  4229. user_name = role.UserName
  4230. }
  4231. baseParams := models.BaseParams{
  4232. SecretKey: miConfig.SecretKey,
  4233. FixmedinsCode: miConfig.Code,
  4234. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4235. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4236. OrgName: miConfig.OrgName,
  4237. Doctor: user_name,
  4238. }
  4239. if config.IsOpen == 1 {
  4240. result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
  4241. var dat map[string]interface{}
  4242. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4243. fmt.Println(dat)
  4244. } else {
  4245. fmt.Println(err)
  4246. }
  4247. }
  4248. }
  4249. func (c *HisApiController) PutRecord() {
  4250. id, _ := c.GetInt64("id")
  4251. record_time := c.GetString("record_time")
  4252. timeLayout := "2006-01-02"
  4253. loc, _ := time.LoadLocation("Local")
  4254. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4255. if err != nil {
  4256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4257. return
  4258. }
  4259. recordDateTime := theTime.Unix()
  4260. adminInfo := c.GetAdminUserInfo()
  4261. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  4262. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4263. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4264. fmt.Println(miConfig.SecretKey)
  4265. if patient == nil {
  4266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4267. return
  4268. }
  4269. if len(patient.IdCardNo) == 0 {
  4270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4271. return
  4272. }
  4273. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4274. if config.IsOpen == 1 {
  4275. 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
  4276. resp, requestErr := http.Get(api)
  4277. if requestErr != nil {
  4278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4279. return
  4280. }
  4281. defer resp.Body.Close()
  4282. body, ioErr := ioutil.ReadAll(resp.Body)
  4283. if ioErr != nil {
  4284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4286. return
  4287. }
  4288. var respJSON map[string]interface{}
  4289. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4292. return
  4293. }
  4294. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4295. userJSONBytes, _ := json.Marshal(userJSON)
  4296. var res ResultTwo
  4297. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4298. utils.ErrorLog("解析失败:%v", err)
  4299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4300. return
  4301. }
  4302. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4303. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4304. infoStr := string(Iinfos)
  4305. idetinfoStr := string(Idetinfos)
  4306. if res.Infcode == 0 {
  4307. his := models.VMHisPatient{
  4308. Status: 1,
  4309. Ctime: time.Now().Unix(),
  4310. Mtime: time.Now().Unix(),
  4311. PsnNo: res.Output.Baseinfo.PsnNo,
  4312. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4313. Certno: res.Output.Baseinfo.Certno,
  4314. PsnName: res.Output.Baseinfo.PsnName,
  4315. Gend: res.Output.Baseinfo.Gend,
  4316. Naty: res.Output.Baseinfo.Naty,
  4317. Brdy: res.Output.Baseinfo.Brdy,
  4318. Age: res.Output.Baseinfo.Age,
  4319. Iinfo: infoStr,
  4320. Idetinfo: idetinfoStr,
  4321. PatientId: patient.ID,
  4322. RecordDate: theTime.Unix(),
  4323. UserOrgId: adminInfo.CurrentOrgId,
  4324. AdminUserId: adminInfo.AdminUser.Id,
  4325. IsReturn: 1,
  4326. }
  4327. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4328. 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")
  4329. 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")
  4330. var dat map[string]interface{}
  4331. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4332. fmt.Println(dat)
  4333. } else {
  4334. fmt.Println(err)
  4335. }
  4336. var dat2 map[string]interface{}
  4337. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  4338. fmt.Println(dat2)
  4339. } else {
  4340. fmt.Println(err)
  4341. }
  4342. } else {
  4343. adminUser := c.GetAdminUserInfo()
  4344. errlog := &models.HisOrderError{
  4345. UserOrgId: adminUser.CurrentOrgId,
  4346. Ctime: time.Now().Unix(),
  4347. Mtime: time.Now().Unix(),
  4348. ErrMsg: res.ErrMsg,
  4349. Status: 1,
  4350. PatientId: id,
  4351. RecordTime: recordDateTime,
  4352. Stage: 1,
  4353. }
  4354. service.CreateErrMsgLog(errlog)
  4355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4356. return
  4357. }
  4358. }
  4359. }
  4360. func (c *HisApiController) GetUploadDiag() {
  4361. id, _ := c.GetInt64("id")
  4362. record_time := c.GetString("record_time")
  4363. diagnosis_id, _ := c.GetInt64("diagnosis")
  4364. sick_type, _ := c.GetInt64("sick_type")
  4365. reg_type, _ := c.GetInt64("reg_type")
  4366. timeLayout := "2006-01-02"
  4367. loc, _ := time.LoadLocation("Local")
  4368. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4369. if err != nil {
  4370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4371. return
  4372. }
  4373. var patientPrescription models.HisPrescriptionInfo
  4374. recordDateTime := theTime.Unix()
  4375. adminInfo := c.GetAdminUserInfo()
  4376. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4377. if patientPrescription.ID == 0 {
  4378. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4379. }
  4380. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4381. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4382. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4383. sickConfig, _ := service.FindSickById(sick_type)
  4384. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4385. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  4386. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  4387. "&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 +
  4388. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
  4389. resp2, requestErr2 := http.Get(api2)
  4390. if requestErr2 != nil {
  4391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4392. return
  4393. }
  4394. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  4395. if ioErr2 != nil {
  4396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  4397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4398. return
  4399. }
  4400. var respJSON2 map[string]interface{}
  4401. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  4402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4404. return
  4405. }
  4406. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4407. userJSONBytes2, _ := json.Marshal(respJSON2)
  4408. var res2 ResultSix
  4409. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4410. utils.ErrorLog("解析失败:%v", err)
  4411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4412. return
  4413. }
  4414. if res2.Infcode != 0 {
  4415. adminUser := c.GetAdminUserInfo()
  4416. errlog := &models.HisOrderError{
  4417. UserOrgId: adminUser.CurrentOrgId,
  4418. Ctime: time.Now().Unix(),
  4419. Mtime: time.Now().Unix(),
  4420. ErrMsg: res2.ErrMsg,
  4421. Status: 1,
  4422. PatientId: id,
  4423. RecordTime: recordDateTime,
  4424. Stage: 3,
  4425. }
  4426. service.CreateErrMsgLog(errlog)
  4427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  4428. return
  4429. }
  4430. c.ServeSuccessJSON(map[string]interface{}{
  4431. "msg": "上传成功",
  4432. })
  4433. }
  4434. type QueryResult struct {
  4435. ID int64
  4436. Name string
  4437. Code string
  4438. List_type_code string
  4439. }
  4440. func (c *HisApiController) GetCheckCode() {
  4441. ids_str := c.GetString("ids")
  4442. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  4443. ids_arr := strings.Split(ids_str, ",")
  4444. var queryResult []QueryResult
  4445. ids := make([]int64, 0)
  4446. for _, item := range ids_arr {
  4447. id, _ := strconv.ParseInt(item, 10, 64)
  4448. ids = append(ids, id)
  4449. }
  4450. if record_type == 1 {
  4451. drugs, _ := service.GetBatchDrugList(ids)
  4452. for _, item := range drugs {
  4453. result := QueryResult{
  4454. ID: item.ID,
  4455. Name: item.DrugName,
  4456. Code: item.MedicalInsuranceNumber,
  4457. List_type_code: "101",
  4458. }
  4459. queryResult = append(queryResult, result)
  4460. }
  4461. } else if record_type == 2 {
  4462. goods, _ := service.GetBatchGoodInformationList(ids)
  4463. for _, item := range goods {
  4464. result := QueryResult{
  4465. ID: item.ID,
  4466. Name: item.GoodName,
  4467. Code: item.MedicalInsuranceNumber,
  4468. List_type_code: "301",
  4469. }
  4470. queryResult = append(queryResult, result)
  4471. }
  4472. } else if record_type == 3 {
  4473. projects, _ := service.GetBathchMyPorjecgList(ids)
  4474. for _, item := range projects {
  4475. result := QueryResult{
  4476. ID: item.ID,
  4477. Name: item.ProjectName,
  4478. Code: item.MedicalCode,
  4479. List_type_code: "201",
  4480. }
  4481. queryResult = append(queryResult, result)
  4482. }
  4483. }
  4484. admin_user_id, _ := c.GetInt64("admin_user_id")
  4485. adminUser := c.GetAdminUserInfo()
  4486. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4487. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4488. var user_name string
  4489. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4490. if role.ID == 0 {
  4491. user_name = "xxx"
  4492. } else {
  4493. user_name = role.UserName
  4494. }
  4495. baseParams := &models.BaseParams{
  4496. SecretKey: miConfig.SecretKey,
  4497. FixmedinsCode: miConfig.Code,
  4498. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4499. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4500. OrgName: miConfig.OrgName,
  4501. Doctor: user_name,
  4502. }
  4503. if config.IsOpen == 1 {
  4504. for _, item := range queryResult {
  4505. var result string
  4506. if record_type == 1 {
  4507. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4508. } else if record_type == 2 {
  4509. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4510. } else if record_type == 3 {
  4511. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4512. }
  4513. var dat map[string]interface{}
  4514. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4515. fmt.Println(dat)
  4516. } else {
  4517. fmt.Println(err)
  4518. }
  4519. userJSONBytes, _ := json.Marshal(dat)
  4520. var res ResultSix
  4521. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4522. utils.ErrorLog("解析失败:%v", err)
  4523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4524. return
  4525. }
  4526. if res.Infcode == 0 {
  4527. if record_type == 1 {
  4528. service.UpdateBaseDrugById(item.ID)
  4529. } else if record_type == 2 {
  4530. service.UpdateGoodInformaitonByDetail(item.ID)
  4531. } else if record_type == 3 {
  4532. service.UpdateProjectById(item.ID)
  4533. }
  4534. c.ServeSuccessJSON(map[string]interface{}{
  4535. "failed_code": 0,
  4536. "msg": "目录对照成功",
  4537. })
  4538. } else {
  4539. c.ServeSuccessJSON(map[string]interface{}{
  4540. "failed_code": -10,
  4541. "msg": res.ErrMsg,
  4542. })
  4543. }
  4544. }
  4545. }
  4546. }
  4547. func (c *HisApiController) UnCheckCode() {
  4548. ids_str := c.GetString("ids")
  4549. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  4550. admin_user_id, _ := c.GetInt64("admin_user_id")
  4551. ids_arr := strings.Split(ids_str, ",")
  4552. var queryResult []QueryResult
  4553. ids := make([]int64, 0)
  4554. for _, item := range ids_arr {
  4555. id, _ := strconv.ParseInt(item, 10, 64)
  4556. ids = append(ids, id)
  4557. }
  4558. if record_type == 1 {
  4559. drugs, _ := service.GetBatchDrugList(ids)
  4560. for _, item := range drugs {
  4561. result := QueryResult{
  4562. ID: item.ID,
  4563. Name: item.DrugName,
  4564. Code: item.MedicalInsuranceNumber,
  4565. List_type_code: "101",
  4566. }
  4567. queryResult = append(queryResult, result)
  4568. }
  4569. } else if record_type == 2 {
  4570. goods, _ := service.GetBatchGoodInformationList(ids)
  4571. for _, item := range goods {
  4572. result := QueryResult{
  4573. ID: item.ID,
  4574. Name: item.GoodName,
  4575. Code: item.MedicalInsuranceNumber,
  4576. List_type_code: "301",
  4577. }
  4578. queryResult = append(queryResult, result)
  4579. }
  4580. } else if record_type == 3 {
  4581. projects, _ := service.GetBathchMyPorjecgList(ids)
  4582. for _, item := range projects {
  4583. result := QueryResult{
  4584. ID: item.ID,
  4585. Name: item.ProjectName,
  4586. Code: item.MedicalCode,
  4587. List_type_code: "201",
  4588. }
  4589. queryResult = append(queryResult, result)
  4590. }
  4591. }
  4592. adminUser := c.GetAdminUserInfo()
  4593. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4594. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4595. var user_name string
  4596. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4597. if role.ID == 0 {
  4598. user_name = "xxx"
  4599. } else {
  4600. user_name = role.UserName
  4601. }
  4602. baseParams := &models.BaseParams{
  4603. SecretKey: miConfig.SecretKey,
  4604. FixmedinsCode: miConfig.Code,
  4605. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4606. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4607. OrgName: miConfig.OrgName,
  4608. Doctor: user_name,
  4609. }
  4610. if config.IsOpen == 1 {
  4611. for _, item := range queryResult {
  4612. var result string
  4613. if record_type == 1 {
  4614. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4615. } else if record_type == 2 {
  4616. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4617. } else if record_type == 3 {
  4618. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4619. }
  4620. var dat2 map[string]interface{}
  4621. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  4622. fmt.Println(dat2)
  4623. } else {
  4624. fmt.Println(err)
  4625. }
  4626. userJSONBytes, _ := json.Marshal(dat2)
  4627. var res ResultSix
  4628. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4629. utils.ErrorLog("解析失败:%v", err)
  4630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4631. return
  4632. }
  4633. if res.Infcode == 0 {
  4634. if record_type == 1 {
  4635. service.UpdateDrugByIdDetail(item.ID)
  4636. } else if record_type == 2 {
  4637. service.UpdateGoodInfoById(item.ID)
  4638. } else if record_type == 3 {
  4639. service.UpdateMyProjectById(item.ID)
  4640. }
  4641. c.ServeSuccessJSON(map[string]interface{}{
  4642. "failed_code": 0,
  4643. "msg": "撤销目录对照成功",
  4644. })
  4645. } else {
  4646. c.ServeSuccessJSON(map[string]interface{}{
  4647. "failed_code": -10,
  4648. "msg": res.ErrMsg,
  4649. })
  4650. }
  4651. }
  4652. }
  4653. }
  4654. func (c *HisApiController) GetPatientInfo() {
  4655. id_card_no := c.GetString("id_card_no")
  4656. admin_user_id, _ := c.GetInt64("admin_user_id")
  4657. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  4658. if patient.ID == 0 {
  4659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4660. return
  4661. }
  4662. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4663. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4664. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  4665. if config.IsOpen == 1 {
  4666. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4667. var dat map[string]interface{}
  4668. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4669. fmt.Println(dat)
  4670. } else {
  4671. fmt.Println(err)
  4672. }
  4673. userJSONBytes, _ := json.Marshal(dat)
  4674. var res ResultTwo
  4675. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4676. utils.ErrorLog("解析失败:%v", err)
  4677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4678. return
  4679. }
  4680. if res.Infcode != 0 {
  4681. c.ServeSuccessJSON(map[string]interface{}{
  4682. "failed_code": -10,
  4683. "msg": res.ErrMsg,
  4684. })
  4685. } else {
  4686. c.ServeSuccessJSON(map[string]interface{}{
  4687. "failed_code": 0,
  4688. "info": res,
  4689. })
  4690. }
  4691. }
  4692. }
  4693. func (c *HisApiController) PsnPutOnRecord() {
  4694. record_type, _ := c.GetInt64("type")
  4695. patient_id, _ := c.GetInt64("patient_id")
  4696. admin_user_id, _ := c.GetInt64("admin_user_id")
  4697. start_time := c.GetString("start_time")
  4698. end_time := c.GetString("end_time")
  4699. adminUser := c.GetAdminUserInfo()
  4700. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4701. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4702. var patients []*models.Patients
  4703. if record_type == 1 { //全部备案
  4704. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  4705. patients = append(patients, patient...)
  4706. } else { //单个备案
  4707. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  4708. patients = append(patients, patient)
  4709. }
  4710. var user_name string
  4711. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4712. if role.ID == 0 {
  4713. user_name = "xxx"
  4714. } else {
  4715. user_name = role.UserName
  4716. }
  4717. if config.IsOpen == 1 {
  4718. for _, item := range patients {
  4719. 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
  4720. resp, requestErr := http.Get(api)
  4721. if requestErr != nil {
  4722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4723. return
  4724. }
  4725. defer resp.Body.Close()
  4726. body, ioErr := ioutil.ReadAll(resp.Body)
  4727. if ioErr != nil {
  4728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4730. return
  4731. }
  4732. var respJSON map[string]interface{}
  4733. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4736. return
  4737. }
  4738. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4739. userJSONBytes, _ := json.Marshal(userJSON)
  4740. var res ResultTwo
  4741. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4742. utils.ErrorLog("解析失败:%v", err)
  4743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4744. return
  4745. }
  4746. if res.Infcode == 0 {
  4747. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  4748. var dat map[string]interface{}
  4749. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4750. fmt.Println(dat)
  4751. } else {
  4752. fmt.Println(err)
  4753. }
  4754. userJSONBytes, _ := json.Marshal(dat)
  4755. var res2 ResultThirteen
  4756. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4757. utils.ErrorLog("解析失败:%v", err)
  4758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4759. return
  4760. }
  4761. if res2.Infcode == 0 {
  4762. psnResult := &models.GdybPsnRecord{
  4763. UserOrgId: adminUser.CurrentOrgId,
  4764. PatientId: item.ID,
  4765. PsnNo: res.Output.Baseinfo.PsnNo,
  4766. Ctime: time.Now().Unix(),
  4767. Mtime: time.Now().Unix(),
  4768. Status: 1,
  4769. IsCancel: 1,
  4770. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  4771. }
  4772. service.CreatePsnRecord(psnResult)
  4773. } else {
  4774. c.ServeSuccessJSON(map[string]interface{}{
  4775. "failed_code": -10,
  4776. "msg": res2.ErrMsg,
  4777. })
  4778. return
  4779. }
  4780. }
  4781. }
  4782. }
  4783. }
  4784. func (c *HisApiController) PsnUnPutOnRecord() {
  4785. id, _ := c.GetInt64("id")
  4786. //record_type, _ := c.GetInt64("type")
  4787. admin_user_id, _ := c.GetInt64("admin_user_id")
  4788. adminUser := c.GetAdminUserInfo()
  4789. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4790. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4791. var user_name string
  4792. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4793. if role.ID == 0 {
  4794. user_name = "xxx"
  4795. } else {
  4796. user_name = role.UserName
  4797. }
  4798. psn_record, _ := service.GetPsnRecordById(id)
  4799. if psn_record.ID == 0 {
  4800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  4801. return
  4802. }
  4803. if config.IsOpen == 1 {
  4804. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  4805. var dat map[string]interface{}
  4806. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4807. fmt.Println(dat)
  4808. } else {
  4809. fmt.Println(err)
  4810. }
  4811. userJSONBytes, _ := json.Marshal(dat)
  4812. var res ResultFourteen
  4813. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4814. utils.ErrorLog("解析失败:%v", err)
  4815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4816. return
  4817. }
  4818. if res.Infcode == 0 {
  4819. psn_record.IsCancel = 2
  4820. service.CreatePsnRecord(&psn_record)
  4821. } else {
  4822. c.ServeSuccessJSON(map[string]interface{}{
  4823. "failed_code": -10,
  4824. "msg": res.ErrMsg,
  4825. })
  4826. return
  4827. }
  4828. }
  4829. }
  4830. func (c *HisApiController) PsnPutNCDSOnRecord() {
  4831. patient_id, _ := c.GetInt64("patient_id")
  4832. insutype := c.GetString("insutype")
  4833. psn_no := c.GetString("psn_no")
  4834. doctor_id, _ := c.GetInt64("doctor_id")
  4835. sick_id, _ := c.GetInt64("sick_id")
  4836. department_id, _ := c.GetInt64("department_id")
  4837. adminUser := c.GetAdminUserInfo()
  4838. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  4839. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4840. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4841. sick, _ := service.FindSickById(sick_id)
  4842. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  4843. if config.IsOpen == 1 {
  4844. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.CountryCode)
  4845. var dat map[string]interface{}
  4846. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4847. fmt.Println(dat)
  4848. } else {
  4849. fmt.Println(err)
  4850. }
  4851. userJSONBytes, _ := json.Marshal(dat)
  4852. var res2 ResultThirteen
  4853. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4854. utils.ErrorLog("解析失败:%v", err)
  4855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4856. return
  4857. }
  4858. if res2.Infcode == 0 {
  4859. psnResult := &models.GdybPsnNcdsRecord{
  4860. UserOrgId: adminUser.CurrentOrgId,
  4861. PatientId: patient.ID,
  4862. PsnNo: psn_no,
  4863. DoctorId: doctor.AdminUserId,
  4864. DepartmentId: department_id,
  4865. SickType: sick_id,
  4866. Insutype: insutype,
  4867. Ctime: time.Now().Unix(),
  4868. Mtime: time.Now().Unix(),
  4869. Status: 1,
  4870. IsCancel: 1,
  4871. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  4872. }
  4873. service.CreatePsnNCDSRecord(psnResult)
  4874. c.ServeSuccessJSON(map[string]interface{}{
  4875. "failed_code": 0,
  4876. "msg": "备案成功",
  4877. "result": psnResult,
  4878. })
  4879. } else {
  4880. c.ServeSuccessJSON(map[string]interface{}{
  4881. "failed_code": -10,
  4882. "msg": res2.ErrMsg,
  4883. })
  4884. return
  4885. }
  4886. }
  4887. }
  4888. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  4889. id, _ := c.GetInt64("id")
  4890. admin_user_id, _ := c.GetInt64("admin_user_id")
  4891. adminUser := c.GetAdminUserInfo()
  4892. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4893. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4894. var user_name string
  4895. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4896. if role.ID == 0 {
  4897. user_name = "xxx"
  4898. } else {
  4899. user_name = role.UserName
  4900. }
  4901. psn_record, _ := service.GetPsnNCDSRecordById(id)
  4902. if psn_record.ID == 0 {
  4903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  4904. return
  4905. }
  4906. if config.IsOpen == 1 {
  4907. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, user_name, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  4908. var dat map[string]interface{}
  4909. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4910. fmt.Println(dat)
  4911. } else {
  4912. fmt.Println(err)
  4913. }
  4914. userJSONBytes, _ := json.Marshal(dat)
  4915. var res ResultFourteen
  4916. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4917. utils.ErrorLog("解析失败:%v", err)
  4918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4919. return
  4920. }
  4921. if res.Infcode == 0 {
  4922. psn_record.IsCancel = 2
  4923. service.CreatePsnNCDSRecord(&psn_record)
  4924. c.ServeSuccessJSON(map[string]interface{}{
  4925. "failed_code": 0,
  4926. "msg": "撤销备案成功",
  4927. })
  4928. } else {
  4929. c.ServeSuccessJSON(map[string]interface{}{
  4930. "failed_code": -10,
  4931. "msg": res.ErrMsg,
  4932. })
  4933. return
  4934. }
  4935. }
  4936. }
  4937. func (c *HisApiController) TestTest() {
  4938. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  4939. fmt.Println(patient.Iinfo)
  4940. }
  4941. type CustomData struct {
  4942. MsgId string
  4943. PsnNo string
  4944. Info string
  4945. }
  4946. func (c *HisApiController) ReversalData() {
  4947. var customData []*CustomData
  4948. custom := &CustomData{
  4949. MsgId: "H44022900158202103301714472004",
  4950. PsnNo: "44020000001101329945",
  4951. Info: "2207",
  4952. }
  4953. customData = append(customData, custom)
  4954. custom1 := &CustomData{
  4955. MsgId: "H4402290015820210330172057803",
  4956. PsnNo: "44020000001101161813",
  4957. Info: "2207",
  4958. }
  4959. customData = append(customData, custom1)
  4960. custom2 := &CustomData{
  4961. MsgId: "H44022900158202103301705198813",
  4962. PsnNo: "44190000133097375417",
  4963. Info: "2207",
  4964. }
  4965. customData = append(customData, custom2)
  4966. custom3 := &CustomData{
  4967. MsgId: "H44022900158202103301715524756",
  4968. PsnNo: "44020000001100187221",
  4969. Info: "2207",
  4970. }
  4971. customData = append(customData, custom3)
  4972. custom4 := &CustomData{
  4973. MsgId: "H44022900158202103301730376224",
  4974. PsnNo: "44020000001101959155",
  4975. Info: "2207",
  4976. }
  4977. customData = append(customData, custom4)
  4978. custom5 := &CustomData{
  4979. MsgId: "H44022900158202103301748008725",
  4980. PsnNo: "44020000001104246641",
  4981. Info: "2207",
  4982. }
  4983. customData = append(customData, custom5)
  4984. custom6 := &CustomData{
  4985. MsgId: "H44022900158202103301718096755",
  4986. PsnNo: "44020000001102211860",
  4987. Info: "2207",
  4988. }
  4989. customData = append(customData, custom6)
  4990. custom7 := &CustomData{
  4991. MsgId: "H44022900158202103301736551640",
  4992. PsnNo: "44020000001102687718",
  4993. Info: "2207",
  4994. }
  4995. customData = append(customData, custom7)
  4996. custom8 := &CustomData{
  4997. MsgId: "H44022900158202103301743097676",
  4998. PsnNo: "44020000001102127785",
  4999. Info: "2207",
  5000. }
  5001. customData = append(customData, custom8)
  5002. custom9 := &CustomData{
  5003. MsgId: "H44022900158202103301712304203",
  5004. PsnNo: "44020000001101518097",
  5005. Info: "2207",
  5006. }
  5007. customData = append(customData, custom9)
  5008. custom10 := &CustomData{
  5009. MsgId: "H44022900158202103301738448785",
  5010. PsnNo: "44020000001100500813",
  5011. Info: "2207",
  5012. }
  5013. customData = append(customData, custom10)
  5014. custom11 := &CustomData{
  5015. MsgId: "H44022900158202103301732455843",
  5016. PsnNo: "44020000001102690557",
  5017. Info: "2207",
  5018. }
  5019. customData = append(customData, custom11)
  5020. custom12 := &CustomData{
  5021. MsgId: "H44022900158202103301745421708",
  5022. PsnNo: "44020000001102211928",
  5023. Info: "2207",
  5024. }
  5025. customData = append(customData, custom12)
  5026. custom1212 := &CustomData{
  5027. MsgId: "H440229001582021033017351627",
  5028. PsnNo: "44020000001102481733",
  5029. Info: "2207",
  5030. }
  5031. customData = append(customData, custom1212)
  5032. custom13 := &CustomData{
  5033. MsgId: "H44022900158202103301740327951",
  5034. PsnNo: "44020000001103174866",
  5035. Info: "2207",
  5036. }
  5037. customData = append(customData, custom13)
  5038. custom14 := &CustomData{
  5039. MsgId: "H4402290015820210330174922668",
  5040. PsnNo: "44020000001102927272",
  5041. Info: "2207",
  5042. }
  5043. customData = append(customData, custom14)
  5044. custom15 := &CustomData{
  5045. MsgId: "H44022900158202103301752362273",
  5046. PsnNo: "44020000001102942890",
  5047. Info: "2207",
  5048. }
  5049. customData = append(customData, custom15)
  5050. custom16 := &CustomData{
  5051. MsgId: "H44022900158202103301751082917",
  5052. PsnNo: "44020000001101662162",
  5053. Info: "2207",
  5054. }
  5055. customData = append(customData, custom16)
  5056. custom17 := &CustomData{
  5057. MsgId: "H44022900158202103301754147728",
  5058. PsnNo: "44020000000229014511",
  5059. Info: "2207",
  5060. }
  5061. customData = append(customData, custom17)
  5062. adminUser := c.GetAdminUserInfo()
  5063. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5064. for _, item := range customData {
  5065. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  5066. fmt.Println(result)
  5067. }
  5068. }
  5069. func (c *HisApiController) ReversalOtherData() {
  5070. var customData []*CustomData
  5071. custom := &CustomData{
  5072. MsgId: "H44022900158202103301714472004",
  5073. PsnNo: "44020000001101329945",
  5074. Info: "2208",
  5075. }
  5076. customData = append(customData, custom)
  5077. custom1 := &CustomData{
  5078. MsgId: "H4402290015820210330172057803",
  5079. PsnNo: "44020000001101161813",
  5080. Info: "2208",
  5081. }
  5082. customData = append(customData, custom1)
  5083. custom2 := &CustomData{
  5084. MsgId: "H44022900158202103301705198813",
  5085. PsnNo: "44190000133097375417",
  5086. Info: "2208",
  5087. }
  5088. customData = append(customData, custom2)
  5089. custom3 := &CustomData{
  5090. MsgId: "H44022900158202103301715524756",
  5091. PsnNo: "44020000001100187221",
  5092. Info: "2208",
  5093. }
  5094. customData = append(customData, custom3)
  5095. custom4 := &CustomData{
  5096. MsgId: "H44022900158202103301730376224",
  5097. PsnNo: "44020000001101959155",
  5098. Info: "2208",
  5099. }
  5100. customData = append(customData, custom4)
  5101. custom5 := &CustomData{
  5102. MsgId: "H44022900158202103301748008725",
  5103. PsnNo: "44020000001104246641",
  5104. Info: "2208",
  5105. }
  5106. customData = append(customData, custom5)
  5107. custom6 := &CustomData{
  5108. MsgId: "H44022900158202103301718096755",
  5109. PsnNo: "44020000001102211860",
  5110. Info: "2208",
  5111. }
  5112. customData = append(customData, custom6)
  5113. custom7 := &CustomData{
  5114. MsgId: "H44022900158202103301736551640",
  5115. PsnNo: "44020000001102687718",
  5116. Info: "2208",
  5117. }
  5118. customData = append(customData, custom7)
  5119. custom8 := &CustomData{
  5120. MsgId: "H44022900158202103301743097676",
  5121. PsnNo: "44020000001102127785",
  5122. Info: "2208",
  5123. }
  5124. customData = append(customData, custom8)
  5125. custom9 := &CustomData{
  5126. MsgId: "H44022900158202103301712304203",
  5127. PsnNo: "44020000001101518097",
  5128. Info: "2208",
  5129. }
  5130. customData = append(customData, custom9)
  5131. custom10 := &CustomData{
  5132. MsgId: "H44022900158202103301738448785",
  5133. PsnNo: "44020000001100500813",
  5134. Info: "2208",
  5135. }
  5136. customData = append(customData, custom10)
  5137. custom11 := &CustomData{
  5138. MsgId: "H44022900158202103301732455843",
  5139. PsnNo: "44020000001102690557",
  5140. Info: "2208",
  5141. }
  5142. customData = append(customData, custom11)
  5143. custom12 := &CustomData{
  5144. MsgId: "H44022900158202103301745421708",
  5145. PsnNo: "44020000001102211928",
  5146. Info: "2208",
  5147. }
  5148. customData = append(customData, custom12)
  5149. custom1212 := &CustomData{
  5150. MsgId: "H440229001582021033017351627",
  5151. PsnNo: "44020000001102481733",
  5152. Info: "2208",
  5153. }
  5154. customData = append(customData, custom1212)
  5155. custom13 := &CustomData{
  5156. MsgId: "H44022900158202103301740327951",
  5157. PsnNo: "44020000001103174866",
  5158. Info: "2208",
  5159. }
  5160. customData = append(customData, custom13)
  5161. custom14 := &CustomData{
  5162. MsgId: "H4402290015820210330174922668",
  5163. PsnNo: "44020000001102927272",
  5164. Info: "2208",
  5165. }
  5166. customData = append(customData, custom14)
  5167. custom15 := &CustomData{
  5168. MsgId: "H44022900158202103301752362273",
  5169. PsnNo: "44020000001102942890",
  5170. Info: "2208",
  5171. }
  5172. customData = append(customData, custom15)
  5173. custom16 := &CustomData{
  5174. MsgId: "H44022900158202103301751082917",
  5175. PsnNo: "44020000001101662162",
  5176. Info: "2208",
  5177. }
  5178. customData = append(customData, custom16)
  5179. custom17 := &CustomData{
  5180. MsgId: "H44022900158202103301754147728",
  5181. PsnNo: "44020000000229014511",
  5182. Info: "2208",
  5183. }
  5184. customData = append(customData, custom17)
  5185. adminUser := c.GetAdminUserInfo()
  5186. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5187. for _, item := range customData {
  5188. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  5189. fmt.Println(result)
  5190. }
  5191. }
  5192. func PathExists(path string) (bool, error) {
  5193. _, err := os.Stat(path)
  5194. if err == nil {
  5195. return true, nil
  5196. }
  5197. if os.IsNotExist(err) {
  5198. return false, nil
  5199. }
  5200. return false, err
  5201. }
  5202. //创建文件夹
  5203. func Mkdir(dir string) {
  5204. // 创建文件夹
  5205. exist, err := PathExists(dir)
  5206. if err != nil {
  5207. fmt.Println(err.Error())
  5208. } else {
  5209. if exist {
  5210. fmt.Println(dir + "文件夹已存在!")
  5211. } else {
  5212. // 文件夹名称,权限
  5213. err := os.Mkdir(dir, os.ModePerm)
  5214. if err != nil {
  5215. fmt.Println(dir+"文件夹创建失败:", err.Error())
  5216. } else {
  5217. fmt.Println(dir + "文件夹创建成功!")
  5218. }
  5219. }
  5220. }
  5221. }
  5222. //压缩文件
  5223. func Zip(srcFile string, destZip string) error {
  5224. zipfile, err := os.Create(destZip)
  5225. if err != nil {
  5226. return err
  5227. }
  5228. defer zipfile.Close()
  5229. archive := zip.NewWriter(zipfile)
  5230. defer archive.Close()
  5231. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  5232. if err != nil {
  5233. return err
  5234. }
  5235. header, err := zip.FileInfoHeader(info)
  5236. if err != nil {
  5237. return err
  5238. }
  5239. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  5240. // header.Name = path
  5241. if info.IsDir() {
  5242. header.Name += "/"
  5243. } else {
  5244. header.Method = zip.Deflate
  5245. }
  5246. writer, err := archive.CreateHeader(header)
  5247. if err != nil {
  5248. return err
  5249. }
  5250. if !info.IsDir() {
  5251. file, err := os.Open(path)
  5252. if err != nil {
  5253. return err
  5254. }
  5255. defer file.Close()
  5256. _, err = io.Copy(writer, file)
  5257. }
  5258. return err
  5259. })
  5260. return err
  5261. }
  5262. func ReadFile(filePath string) []byte {
  5263. f, err := os.Open(filePath)
  5264. if err != nil {
  5265. fmt.Println("read file fail", err)
  5266. return nil
  5267. }
  5268. defer f.Close()
  5269. fd, err := ioutil.ReadAll(f)
  5270. if err != nil {
  5271. fmt.Println("read to fd fail", err)
  5272. return nil
  5273. }
  5274. return fd
  5275. }
  5276. func RemoveRepeatedCode(arr []string) (newArr []string) {
  5277. newArr = make([]string, 0)
  5278. for i := 0; i < len(arr); i++ {
  5279. repeat := false
  5280. for j := i + 1; j < len(arr); j++ {
  5281. if arr[i] == arr[j] {
  5282. repeat = true
  5283. break
  5284. }
  5285. }
  5286. if !repeat {
  5287. newArr = append(newArr, arr[i])
  5288. }
  5289. }
  5290. return
  5291. }