his_api_controller.go 187KB

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