his_api_controller.go 202KB

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