1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182 |
- package controllers
-
- import "C"
- import (
- "Xcx_New/enums"
- "Xcx_New/models"
- "Xcx_New/service"
- "Xcx_New/utils"
- "encoding/json"
- "fmt"
- "github.com/astaxie/beego"
- "github.com/jinzhu/gorm"
- "github.com/shopspring/decimal"
- "math/rand"
- "reflect"
- "strconv"
- "strings"
- "syscall"
- "time"
- "unsafe"
- )
-
- type HisApiController struct {
- BaseAuthAPIController
- }
-
- func HisManagerApiRegistRouters() {
-
- beego.Router("/api/hispatient/list", &HisApiController{}, "get:GetHisPatientList")
- //beego.Router("/api/hispatient/list", &HisApiController{}, "get:GetHisPatientList")
-
- beego.Router("/api/hispatient/get", &HisApiController{}, "get:GetHisPatientInfo")
- beego.Router("/api/hisprescription/config", &HisApiController{}, "get:GetHisPrescriptionConfig")
-
- beego.Router("/api/hisprescription/delete", &HisApiController{}, "post:DeletePrescription")
- beego.Router("/api/advice/delete", &HisApiController{}, "post:DeleteDoctorAdvice")
- beego.Router("/api/project/delete", &HisApiController{}, "post:DeleteProject")
- beego.Router("/api/addition_charge/delete", &HisApiController{}, "post:DeleteAddition")
-
- beego.Router("/api/hisprescription/list", &HisApiController{}, "get:GetHisPrescriptionList")
- beego.Router("/api/hisprescription/info", &HisApiController{}, "get:GetHisPrescriptionInfo")
-
- beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
- beego.Router("/api/hisprescription/edit", &HisApiController{}, "post:EditHisPrescription")
-
- beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
- beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
- beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "get:CreateHisPatientCaseHistory")
-
- beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "get:CreateCaseHistoryTemplate")
-
- beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
-
- beego.Router("/api/hisorder/list", &HisApiController{}, "get:GetHisOrderList")
-
- beego.Router("/api/hisorder/get", &HisApiController{}, "get:GetHisOrder")
-
- beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
- beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
- beego.Router("/api/presettle/get", &HisApiController{}, "get:PreSettle")
-
- beego.Router("/api/refund/post", &HisApiController{}, "post:Refund")
- beego.Router("/api/refundnumber/post", &HisApiController{}, "post:RefundNumber")
-
- beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
- beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
-
- //beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
- //新增附加费用
- //beego.Router("/api/his/additionalcharge", &HisApiController{}, "Post:AdditionalCharge")
- //beego.Router("/api/additionalcharge/get", &HisApiController{}, "Get:GetAdditionalcharge")
- beego.Router("/api/hisprescription/get", &HisApiController{}, "Get:GetLastOrNextHisPrescription")
- beego.Router("/api/callhisprescription/get", &HisApiController{}, "Get:GetCallHisPrescription")
- beego.Router("/api/dayprescription/get", &HisApiController{}, "get:GetHisDayPrescription")
- beego.Router("/api/charge/list", &HisApiController{}, "get:GetHisChargePatientList")
- beego.Router("/api/charge/info", &HisApiController{}, "get:GetHisChargePatientInfo")
- beego.Router("/api/unregister/list", &HisApiController{}, "get:GetHisUnRegisterPatientList")
- beego.Router("/api/orderdetail/get", &HisApiController{}, "get:GetAllOrderDetail")
- beego.Router("/api/orderdetaicollect/get", &HisApiController{}, "get:GetAllOrderDetailCollect")
- beego.Router("/api/cost/compare", &HisApiController{}, "get:GetMedicalInsuranceCostCompareList")
- beego.Router("/api/record/list", &HisApiController{}, "get:GetPutOnRecordList")
-
- beego.Router("/api/comparedata/get", &HisApiController{}, "get:GetCompareData")
- beego.Router("/api/fapiao/get", &HisApiController{}, "get:GetFaPiaoData")
-
- beego.Router("/api/incomestatistics/get", &HisApiController{}, "get:GetIncomeStatisticsData")
-
- beego.Router("/api/postprojectinformation", &HisApiController{}, "post:PostProjectInformation")
- //beego.Router("/api/editprojectinformation", &HisApiController{}, "post:EditProjectInformation")
-
- beego.Router("/api/hisprescriptiontemplate/create", &HisApiController{}, "post:CreateHisPrescriptionTemplate")
-
- beego.Router("/api/privateexpenses/get", &HisApiController{}, "get:GetPrivateExpensesInfo")
-
- beego.Router("/api/changemedtype/post", &HisApiController{}, "post:ChangeMedType")
-
- beego.Router("/api/refunddetail/post", &HisApiController{}, "post:RefudDetail")
-
- beego.Router("/api/privateexpensesorder/get", &HisApiController{}, "get:GetPrivateExpensesOrder")
-
- beego.Router("/api/uncharge/list", &HisApiController{}, "get:GetHisUnChargePatientList")
-
- beego.Router("/api/monthcharge/info", &HisApiController{}, "get:GetHisMonthChargePatientInfo")
- beego.Router("/api/monthhispatient/get", &HisApiController{}, "get:GetHisMonthPatientInfo")
-
- }
-
- func (c *HisApiController) GetHisUnChargePatientList() {
- record_date := c.GetString("record_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminInfo := c.GetAdminUserInfo()
- var tempPatients []*service.NewTempPatients
- //tempPatients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
- tempPatients, _ = service.GetNewAllUnChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
- var patients []*service.NewTempPatients
- var patients_two []*service.NewTempPatients
-
- for _, item := range tempPatients {
- //过滤掉没挂号的和没开处方的
- if len(item.HisPatient) > 0 || len(item.HisPrescription) > 0 {
- patients = append(patients, item)
- }
-
- //过滤掉没挂号的
- if len(item.HisPatient) > 0 {
- patients_two = append(patients_two, item)
- }
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "list": patients,
- "list_two": patients_two,
- })
- }
-
- func (c *HisApiController) GetPrivateExpensesOrder() {
- //id, _ := c.GetInt64("id")
- //record_time := c.GetString("record_time")
- order_id, _ := c.GetInt64("order_id")
- admin_user_id, _ := c.GetInt64("admin_user_id")
-
- //timeLayout := "2006-01-02"
- //loc, _ := time.LoadLocation("Local")
- //
- //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- //if err != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- //}
- //recordDateTime := theTime.Unix()
- adminUser := c.GetAdminUserInfo()
- order, _ := service.GetHisOrderByID(order_id)
- his, _ := service.GetHisPatientInfoThree(adminUser.CurrentOrgId, order.MdtrtId)
-
- orderInfos, _ := service.GetHisOrderDetailByNumber(order.Number, adminUser.CurrentOrgId)
-
- diagnosis_ids := strings.Split(his.Diagnosis, ",")
-
- //var config []*models.HisXtDiagnoseConfig
- var name string
- for _, item := range diagnosis_ids {
- id, _ := strconv.ParseInt(item, 10, 64)
- diagnosisConfig, _ := service.FindDiagnoseById(id)
- if len(name) == 0 {
- name = diagnosisConfig.ClassName
-
- } else {
- name = name + "," + diagnosisConfig.ClassName
- }
- }
-
- decimal.DivisionPrecision = 2
-
- for _, item := range orderInfos {
- item.FulamtOwnpayAmt = item.DetItemFeeSumamt
- if item.HisDoctorAdviceInfo.ID > 0 && item.HisPrescriptionProject.ID == 0 { //药品
- item.MedChrgitmType = "09"
-
- }
- if item.HisPrescriptionProject.ID > 0 && item.HisDoctorAdviceInfo.ID == 0 {
- if item.HisPrescriptionProject.Type == 2 {
- switch item.HisPrescriptionProject.VMHisProject.CostClassify {
-
- case 1:
- item.MedChrgitmType = "14"
- break
- case 2:
- item.MedChrgitmType = "05"
-
- break
- case 3:
- item.MedChrgitmType = "04"
-
- break
- case 4:
- item.MedChrgitmType = "14"
-
- break
- case 5:
- item.MedChrgitmType = "08"
-
- break
- case 6:
- item.MedChrgitmType = "14"
-
- break
- case 7:
- item.MedChrgitmType = "14"
-
- break
- case 8:
- item.MedChrgitmType = "03"
- break
- case 9:
- item.MedChrgitmType = "14"
- break
-
- }
-
- } else if item.HisPrescriptionProject.Type == 3 {
- item.MedChrgitmType = "08"
- }
- }
- }
- order.PsnCashPay = order.MedfeeSumamt
-
- //var user_name string
- //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
- //if role.ID == 0 {
- // user_name = "管理员"
- //} else {
- // user_name = role.UserName
- //}
-
- org, _ := service.GetOrgById(adminUser.CurrentOrgId)
- printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
- charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
-
- patient, _ := service.GetPatientByID(order.UserOrgId, order.PatientId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "org_name": org.OrgName,
- "name": patient.Name,
- "order_infos": orderInfos,
- "number": order.MdtrtId,
- "date": order.SettleAccountsDate,
- "charge_admin": charge_admin,
- "printor_admin": printor_admin,
- "info": order,
- })
-
- }
-
- func (c *HisApiController) RefudDetail() {
- order_id, _ := c.GetInt64("order_id")
- order, _ := service.GetHisOrderByID(order_id)
- adminUser := c.GetAdminUserInfo()
- service.UpdataOrderInfoStatus(order_id, order.Number, adminUser.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "撤销成功",
- })
- }
-
- func (c *HisApiController) Sscard() {
- //r := CardInit()
- //if r == 0 {
- // GetBaseInfo()
- //}
- //c.ServeSuccessJSON(map[string]interface{}{
- // "list": "11",
- //})
-
- }
-
- func GetBaseInfo() error {
- //handle := syscall.MustLoadDLL("SSCard.dll")
- //ReadCardBas := handle.MustFindProc("ReadCardBas")
- //
- //str := make([]byte, 256)
- //str1 := make([]byte, 256)
- //r, _, ferr := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
- //if ferr != nil {
- // fmt.Println("ReadCardBas 报错", ferr.Error())
- // return ferr
- //}
- //
- //fmt.Println(string(str))
- //
- //fmt.Println(r)
- return nil
- }
-
- func CardInit() int {
- //DllTestDef := syscall.MustLoadDLL("SSCard.dll")
- //add := DllTestDef.MustFindProc("Init")
- //ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
- //if err != nil {
- // fmt.Println("SSCard的运算结果为:", ret)
- //}
- //result := int(ret)
- return 0
- }
-
- func IntPtr(n int) uintptr {
- return uintptr(n)
- }
-
- func StrPtr(s string) uintptr {
- return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
- }
-
- func (c *HisApiController) GetHisPatientList() {
- //types, _ := c.GetInt64("type", 0)
- record_date := c.GetString("record_date")
- sch_type, _ := c.GetInt64("sch_type")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminInfo := c.GetAdminUserInfo()
- //patients, _ := service.GetHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
- patients, _ := service.GetNewHisPatientList(adminInfo.CurrentOrgId, recordDateTime)
- patients_two, _ := service.GetScheduleHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime, sch_type)
- //获取当前用户的信息
- adminUserInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
- doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
- //获取所有科室信息
- department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": patients,
- "list_two": patients_two,
- "info": adminUserInfo,
- "doctors": doctors,
- "department": department,
- })
- }
-
- func (c *HisApiController) GetHisPatientInfo() {
- patient_id, _ := c.GetInt64("patient_id")
- his_patient_id, _ := c.GetInt64("his_patient_id")
- record_date := c.GetString("record_date")
- number := c.GetString("number")
- //start_time := c.GetString("start_time")
- //end_time := c.GetString("end_time")
- p_type, _ := c.GetInt64("p_type")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- //startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- //if err != nil {
- //
- //}
- //startRecordDateTime := startTime.Unix()
- //endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- //if err != nil {
- //
- //}
- //endRecordDateTime := endTime.Unix()
- admin := c.GetAdminUserInfo()
- his_patient_info, _ := service.GetNewHisPatientInfoTwo(admin.CurrentOrgId, his_patient_id, recordDateTime)
- xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
-
- count, _ := service.GetHisPatientCount(admin.CurrentOrgId, patient_id, recordDateTime)
-
- var prescriptions []*models.HisPrescription
- var last_prescriptions []*models.HisPrescription
- var sch_prescriptions []*models.HisPrescriptionInfoTemplate
- last_p_info, _ := service.FindLastPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
- if p_type == 1 { //住院
- prescriptions, _ = service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
- last_prescriptions, _ = service.GetHisPrescription(admin.CurrentOrgId, patient_id, last_p_info.RecordDate, p_type)
- } else { //门诊
- prescriptions, _ = service.GetNewHisPrescription(admin.CurrentOrgId, patient_id, his_patient_id, recordDateTime, p_type)
- last_prescriptions, _ = service.GetHisPrescription(admin.CurrentOrgId, patient_id, last_p_info.RecordDate, p_type)
- }
-
- sch, _ := service.GetPatientSch(patient_id, recordDateTime, admin.CurrentOrgId)
- if sch.ID > 0 {
- mode_template, _ := service.GetHisPrescriptionBySchMode(sch.ModeId, patient_id, admin.CurrentOrgId)
- sch_prescriptions, _ = service.GetHisPrescriptionTemplate(mode_template.ID, admin.CurrentOrgId)
-
- }
- //prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, his_patient_id, recordDateTime)
- //monthPrescriptions, _ := service.GetMonthHisPrescriptionTwo(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
- case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
- patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
- lastPatientPrescriptionInfo, _ := service.FindLastPatientPrescriptionInfoTwo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
-
- order, _ := service.GetHisOrder(admin.CurrentOrgId, number, patient_id)
- doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
-
- _, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(admin.CurrentOrgId)
-
- //获取所有科室信息
- department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "his_info": his_patient_info,
- "xt_info": xt_patient_info,
- "prescription": prescriptions,
- "case_history": case_history,
- "info": patientPrescriptionInfo,
- //"month_prescriptions": monthPrescriptions,
- "order": order,
- "doctors": doctors,
- "department": department,
- "sch_prescriptions": sch_prescriptions,
- "last_prescriptions": last_prescriptions,
- "schedule": sch,
- "count": count,
- "drugStockConfig": drugStockConfig,
- "last_info": lastPatientPrescriptionInfo,
- })
- return
-
- }
- func (c *HisApiController) GetHisPrescriptionConfig() {
- adminInfo := c.GetAdminUserInfo()
- //获取医嘱模版
- advices, _ := service.FindAllHisAdviceTemplate(adminInfo.CurrentOrgId)
- //获取所有基础药
- drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
- drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
- efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
- doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
- //获取所有科室信息
- department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
-
- //获取诊断信息
-
- sick, _ := service.FindAllSick(adminInfo.CurrentOrgId)
-
- diagnose, _ := service.FindAllDiagnose(adminInfo.CurrentOrgId)
-
- additions, _ := service.FindAllAddition(adminInfo.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "drugs": drugs,
- "advices_template": advices,
- "drugways": drugways,
- "efs": efs,
- "doctors": doctors,
- "department": department,
- "sick": sick,
- "additions": additions,
- "diagnose": diagnose,
- })
- }
- func (c *HisApiController) CreateHisPrescription() {
- record_date := c.GetString("record_date")
- patient_id, _ := c.GetInt64("patient_id")
- reg_type, _ := c.GetInt64("reg_type")
- diagnose := c.GetString("diagnose")
- sick_type, _ := c.GetInt64("sick_type")
- sick_history := c.GetString("sick_history")
- doctor_id, _ := c.GetInt64("doctor", 0)
- department, _ := c.GetInt64("department", 0)
- his_patient_id, _ := c.GetInt64("his_patient_id")
- p_type, _ := c.GetInt64("p_type")
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminInfo := c.GetAdminUserInfo()
- recordDateTime := theTime.Unix()
-
- role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor_id)
-
- if his_patient_id == 0 { //前端传过来的挂号id为0时,进行多一步判断
- lists, _ := service.GetHisPatientInfoList(adminInfo.CurrentOrgId, patient_id, recordDateTime)
- if len(lists) == 1 {
- his_patient_id = lists[0].ID
- }
-
- }
-
- _, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
-
- _, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
-
- if drugStockConfig.IsOpen == 1 {
- //校验库存总量
- if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
- prescriptions, _ := dataBody["prescriptions"].([]interface{})
- if len(prescriptions) > 0 {
- for _, item := range prescriptions {
- items := item.(map[string]interface{})
- if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
- advices := items["advices"].([]interface{})
- if len(advices) > 0 {
- for _, advice := range advices {
- var drug_id int64
- var prescribing_number float64
- var prescribingNumberUnit string
-
- if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
- drug_id = int64(advice.(map[string]interface{})["id"].(float64))
- }
- if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
- //prescribing_number = advice.(map[string]interface{})["prescribing_number"].(string)
- prescribing_number_str := advice.(map[string]interface{})["prescribing_number"].(string)
- prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
-
- }
-
- if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
- prescribingNumberUnit, _ = advice.(map[string]interface{})["prescribing_number_unit"].(string)
- }
-
- drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, drug_id)
- if drug.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if prescribingNumberUnit == drug.MinUnit {
- if prescribing_number > drug.Total {
- c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
- //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
- return
- }
- } else {
- if prescribingNumberUnit == drug.MaxUnit {
- num := prescribing_number * float64(drug.MinNumber)
- if num > drug.Total {
- c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
- //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
- return
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- if stockConfig.IsOpen == 1 {
- if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
- prescriptions, _ := dataBody["prescriptions"].([]interface{})
- if len(prescriptions) > 0 {
- for _, item := range prescriptions {
- items := item.(map[string]interface{})
- if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
- projects := items["project"].([]interface{})
- if len(projects) > 0 {
- for _, project := range projects {
- var project_id int64
- var project_type int64
- var totals float64
- if project.(map[string]interface{})["project_id"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_id"]).String() == "float64" {
- project_id = int64(project.(map[string]interface{})["project_id"].(float64))
- }
- if project.(map[string]interface{})["type"] != nil || reflect.TypeOf(project.(map[string]interface{})["type"]).String() == "float64" {
- project_type = int64(project.(map[string]interface{})["type"].(float64))
- }
- if project.(map[string]interface{})["total"] != nil || reflect.TypeOf(project.(map[string]interface{})["total"]).String() == "string" {
- total, _ := project.(map[string]interface{})["total"].(string)
-
- totals, _ = strconv.ParseFloat(total, 64)
- }
- if project_type == 3 {
- good, _ := service.FindGoodInfoByIdTwo(project_id)
- if good.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- if totals > good.Total {
- c.ServeDynamicFailJsonSend(good.GoodName + "库存不足")
- //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
- return
- }
-
- }
-
- }
- }
- }
- }
- }
- }
-
- }
-
- info, _ := service.FindHisPatientPrescriptionInfo(adminInfo.CurrentOrgId, patient_id, recordDateTime, p_type, his_patient_id)
- var hpInfo models.HisPrescriptionInfo
- if info.ID == 0 {
- var randNum int
- randNum = rand.Intn(10000) + 1000
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- timeFormat := tempTime.Format("20060102150405")
- p_number := timeFormat + strconv.FormatInt(int64(randNum), 10) + strconv.FormatInt(int64(adminInfo.CurrentOrgId), 10) + strconv.FormatInt(int64(patient_id), 10)
-
- hpInfo = models.HisPrescriptionInfo{
- HisPatientId: his_patient_id,
- UserOrgId: adminInfo.CurrentOrgId,
- RecordDate: theTime.Unix(),
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Creator: adminInfo.AdminUser.Id,
- Modifier: adminInfo.AdminUser.Id,
- Diagnosis: diagnose,
- SickHistory: sick_history,
- Departments: department,
- RegisterType: reg_type,
- PrescriptionNumber: p_number,
- PrescriptionStatus: 1,
- Doctor: role.UserName,
- DoctorId: doctor_id,
- SickType: sick_type,
- PType: p_type,
- }
- service.SavePatientPrescriptionInfo(hpInfo)
-
- } else {
- hpInfo = models.HisPrescriptionInfo{
-
- ID: info.ID,
- UserOrgId: adminInfo.CurrentOrgId,
- RecordDate: info.RecordDate,
- PatientId: info.PatientId,
- Status: 1,
- Ctime: info.Ctime,
- Mtime: time.Now().Unix(),
- Creator: info.Creator,
- Modifier: adminInfo.AdminUser.Id,
- Diagnosis: diagnose,
- SickHistory: sick_history,
- Departments: department,
- RegisterType: reg_type,
- PrescriptionNumber: info.PrescriptionNumber,
- Doctor: role.UserName,
- PrescriptionStatus: info.PrescriptionStatus,
- DoctorId: doctor_id,
- SickType: sick_type,
- PType: info.PType,
- HisPatientId: info.HisPatientId,
- }
- service.SavePatientPrescriptionInfo(hpInfo)
- }
-
- if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
- prescriptions, _ := dataBody["prescriptions"].([]interface{})
-
- var tempPrescription *models.HisPrescription
- if len(prescriptions) > 0 {
- for _, item := range prescriptions {
- items := item.(map[string]interface{})
- if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
- utils.ErrorLog("id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- id := int64(items["id"].(float64))
-
- new_prescription, _ := service.GetPrescriptionById(id, adminInfo.CurrentOrgId)
- tempPrescription = &new_prescription
- if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
- utils.ErrorLog("type")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- types := int64(items["type"].(float64))
-
- if items["order_status"] == nil || reflect.TypeOf(items["order_status"]).String() != "float64" {
- utils.ErrorLog("order_status")
- }
- order_status := int64(items["order_status"].(float64))
-
- if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
- utils.ErrorLog("med_type")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- med_type := strconv.Itoa(int(items["med_type"].(float64)))
-
- if med_type == "0" {
- med_type = "14"
- }
-
- if order_status == 0 {
- order_status = 1
- }
-
- if items["pre_time"] == nil || reflect.TypeOf(items["pre_time"]).String() != "string" {
- utils.ErrorLog("pre_time")
- }
- preTime, _ := items["pre_time"].(string)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime2, err := time.ParseInLocation(timeLayout+" 15:04", preTime, loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- pTime := theTime2.Unix()
-
- ctime := time.Now().Unix()
-
- if tempPrescription.ID == 0 {
- prescription := &models.HisPrescription{
- ID: 0,
- PatientId: patient_id,
- UserOrgId: adminInfo.CurrentOrgId,
- RecordDate: recordDateTime,
- Ctime: ctime,
- Mtime: ctime,
- Type: types,
- Modifier: adminInfo.AdminUser.Id,
- Creator: adminInfo.AdminUser.Id,
- Status: 1,
- Doctor: role.UserName,
- HisPatientId: his_patient_id,
- OrderStatus: order_status,
- BatchNumber: "",
- PrescriptionNumber: hpInfo.PrescriptionNumber,
- PreTime: pTime,
- PType: p_type,
- MedType: med_type,
- }
- tempPrescription = prescription
- service.SaveHisPrescription(tempPrescription)
-
- } else {
- tempPrescription.ID = id
- tempPrescription.Type = types
- tempPrescription.Modifier = adminInfo.AdminUser.Id
- tempPrescription.Mtime = time.Now().Unix()
- tempPrescription.Doctor = role.UserName
- tempPrescription.OrderStatus = order_status
- tempPrescription.PreTime = pTime
- tempPrescription.MedType = med_type
- service.SaveHisPrescription(tempPrescription)
- }
- //service.SaveHisPrescription(prescription)
- //更改患者挂号状态
- _, err2 := service.UpdateHisPatientIsReturn(patient_id, recordDateTime, adminInfo.CurrentOrgId)
- fmt.Println("更改失败", err2)
- if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
- advices := items["advices"].([]interface{})
- //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
- groupNo := int64(0)
- ctime := time.Now().Unix()
- mtime := ctime
- if len(advices) > 0 {
- for _, advice := range advices {
- var s models.HisDoctorAdviceInfo
- s.PrescriptionId = tempPrescription.ID
- s.AdviceType = 2
- s.AdviceDoctor = doctor_id
- s.StopState = 2
- s.ExecutionState = 2
- s.AdviceDate = recordDateTime
- s.Status = 1
- s.UserOrgId = adminInfo.CurrentOrgId
- s.RecordDate = recordDateTime
- s.StartTime = tempPrescription.PreTime
- s.Groupno = groupNo
- s.CreatedTime = ctime
- s.UpdatedTime = mtime
- s.PatientId = patient_id
- s.HisPatientId = his_patient_id
- s.StartTime = pTime
- errcode := c.setAdviceWithJSON(&s, advice.(map[string]interface{}))
- if errcode > 0 {
- c.ServeFailJSONWithSGJErrorCode(errcode)
- return
- }
-
- s.StartTime = pTime
- service.CreateHisDoctorAdvice(&s)
- var randNum int
- randNum = rand.Intn(10000) + 1000
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- timeFormat := tempTime.Format("20060102150405")
- s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
- service.CreateHisDoctorAdvice(&s)
-
- }
- }
- }
- if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
- projects := items["project"].([]interface{})
- if len(projects) > 0 {
- for _, project := range projects {
- var p models.HisPrescriptionProject
- p.PrescriptionId = tempPrescription.ID
- p.Ctime = time.Now().Unix()
- p.Mtime = time.Now().Unix()
- p.PatientId = patient_id
- p.RecordDate = recordDateTime
- p.Doctor = doctor_id
- p.UserOrgId = adminInfo.CurrentOrgId
- p.HisPatientId = his_patient_id
- p.Status = 1
- p.StartTime = pTime
-
- errcode := c.setProjectWithJSON(&p, project.(map[string]interface{}))
- if errcode > 0 {
- c.ServeFailJSONWithSGJErrorCode(errcode)
- return
- }
- service.CreateHisProjectTwo(&p)
-
- var randNum int
- randNum = rand.Intn(10000) + 1000
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- timeFormat := tempTime.Format("20060102150405")
- p.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "2" + "-" + strconv.FormatInt(p.ID, 10)
- service.SaveHisProjectTwo(&p)
-
- if p.Type == 3 { //处理透前准备耗材数量数据
- consumables, _ := service.FindHisConsumablesByID(adminInfo.CurrentOrgId, patient_id, recordDateTime, p.ProjectId)
- if consumables.ID > 0 {
- consumables.Count = p.Count
- service.UpdateConsumables(&consumables)
- }
- }
- }
- }
- }
- if items["addition"] != nil && reflect.TypeOf(items["addition"]).String() == "[]interface {}" {
- addition := items["addition"].([]interface{})
- //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
- ctime := time.Now().Unix()
- mtime := ctime
- if len(addition) > 0 {
- for _, item := range addition {
- var s models.HisAdditionalCharge
- s.PrescriptionId = tempPrescription.ID
- s.Status = 1
- s.UserOrgId = adminInfo.CurrentOrgId
- s.RecordDate = recordDateTime
- s.CreatedTime = ctime
- s.UpdatedTime = mtime
- s.PatientId = patient_id
- s.HisPatientId = his_patient_id
- errcode := c.setAddtionWithJSON(&s, item.(map[string]interface{}), adminInfo.CurrentOrgId)
- if errcode > 0 {
- c.ServeFailJSONWithSGJErrorCode(errcode)
- return
- }
- service.CreateAdditionalCharge(&s)
- var randNum int
- randNum = rand.Intn(10000) + 1000
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- timeFormat := tempTime.Format("20060102150405")
- s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "3" + "-" + strconv.FormatInt(s.ID, 10)
- service.CreateAdditionalCharge(&s)
-
- }
- }
- }
-
- }
- }
- }
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "保存成功",
- })
- return
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
- func (c *HisApiController) EditHisPrescription() {
- record_date := c.GetString("record_date")
- patient_id, _ := c.GetInt64("patient_id")
- reg_type, _ := c.GetInt64("reg_type")
- //diagnose, _ := c.GetInt64("diagnose", 0)
- diagnose := c.GetString("diagnose")
- sick_type, _ := c.GetInt64("sick_type")
- sick_history := c.GetString("sick_history")
- doctor_id, _ := c.GetInt64("doctor", 0)
- department, _ := c.GetInt64("department", 0)
- his_patient_id, _ := c.GetInt64("his_patient_id")
- p_type, _ := c.GetInt64("p_type")
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminInfo := c.GetAdminUserInfo()
- recordDateTime := theTime.Unix()
-
- role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor_id)
-
- info, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, patient_id, recordDateTime, p_type)
- var hpInfo models.HisPrescriptionInfo
- if info.ID == 0 {
- var randNum int
- randNum = rand.Intn(10000) + 1000
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- timeFormat := tempTime.Format("20060102150405")
- p_number := timeFormat + strconv.FormatInt(int64(randNum), 10) + strconv.FormatInt(int64(adminInfo.CurrentOrgId), 10) + strconv.FormatInt(int64(patient_id), 10)
-
- hpInfo = models.HisPrescriptionInfo{
- UserOrgId: adminInfo.CurrentOrgId,
- RecordDate: theTime.Unix(),
- PatientId: patient_id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Creator: adminInfo.AdminUser.Id,
- Modifier: adminInfo.AdminUser.Id,
- Diagnosis: diagnose,
- SickHistory: sick_history,
- Departments: department,
- RegisterType: reg_type,
- PrescriptionNumber: p_number,
- PrescriptionStatus: 1,
- Doctor: role.UserName,
- DoctorId: doctor_id,
- SickType: sick_type,
- PType: p_type,
- }
- service.SavePatientPrescriptionInfo(hpInfo)
-
- } else {
- hpInfo = models.HisPrescriptionInfo{
- ID: info.ID,
- UserOrgId: adminInfo.CurrentOrgId,
- RecordDate: info.RecordDate,
- PatientId: info.PatientId,
- Status: 1,
- Ctime: info.Ctime,
- Mtime: time.Now().Unix(),
- Creator: info.Creator,
- Modifier: adminInfo.AdminUser.Id,
- Diagnosis: diagnose,
- SickHistory: sick_history,
- Departments: department,
- RegisterType: reg_type,
- PrescriptionNumber: info.PrescriptionNumber,
- Doctor: role.UserName,
- PrescriptionStatus: info.PrescriptionStatus,
- DoctorId: doctor_id,
- SickType: sick_type,
- PType: info.PType,
- }
- service.SavePatientPrescriptionInfo(hpInfo)
- }
-
- if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
- prescriptions, _ := dataBody["prescriptions"].([]interface{})
-
- if len(prescriptions) > 0 {
- for _, item := range prescriptions {
- items := item.(map[string]interface{})
- if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
- utils.ErrorLog("id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- id := int64(items["id"].(float64))
-
- if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
- utils.ErrorLog("type")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- types := int64(items["type"].(float64))
-
- if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
- utils.ErrorLog("med_type")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- med_type := strconv.Itoa(int(items["med_type"].(float64)))
-
- historyPrescription, _ := service.GetHisPrescriptionByID(adminInfo.CurrentOrgId, id)
-
- ctime := time.Now().Unix()
-
- prescription := &models.HisPrescription{
- ID: id,
- PatientId: patient_id,
- UserOrgId: adminInfo.CurrentOrgId,
- RecordDate: recordDateTime,
- Ctime: ctime,
- Mtime: ctime,
- Type: types,
- Modifier: adminInfo.AdminUser.Id,
- Creator: adminInfo.AdminUser.Id,
- Status: 1,
- Doctor: role.UserName,
- HisPatientId: his_patient_id,
- OrderStatus: 1,
- BatchNumber: "",
- PrescriptionNumber: hpInfo.PrescriptionNumber,
- PType: hpInfo.PType,
- MedType: med_type,
- }
-
- if historyPrescription.ID > 0 {
- prescription.PreTime = historyPrescription.PreTime
-
- }
-
- service.SaveHisPrescription(prescription)
-
- if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
- advices := items["advices"].([]interface{})
- //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
- groupNo := int64(0)
- ctime := time.Now().Unix()
- mtime := ctime
- if len(advices) > 0 {
- for _, advice := range advices {
- var s models.HisDoctorAdviceInfo
- s.PrescriptionId = prescription.ID
- s.AdviceType = 2
- s.AdviceDoctor = adminInfo.AdminUser.Id
- s.StopState = 2
- s.ExecutionState = 2
- s.AdviceDate = recordDateTime
- s.Status = 1
- s.UserOrgId = adminInfo.CurrentOrgId
- s.RecordDate = recordDateTime
- s.StartTime = prescription.PreTime
- s.Groupno = groupNo
- s.CreatedTime = ctime
- s.UpdatedTime = mtime
- s.PatientId = patient_id
- s.HisPatientId = his_patient_id
- errcode := c.setAdviceWithJSONTwo(&s, advice.(map[string]interface{}))
- if errcode > 0 {
- c.ServeFailJSONWithSGJErrorCode(errcode)
- return
- }
- service.CreateHisDoctorAdvice(&s)
-
- }
- }
- }
- if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
- projects := items["project"].([]interface{})
- if len(projects) > 0 {
- for _, project := range projects {
- var p models.HisPrescriptionProject
- p.PrescriptionId = prescription.ID
- p.Ctime = time.Now().Unix()
- p.Mtime = time.Now().Unix()
- p.PatientId = patient_id
- p.RecordDate = recordDateTime
- p.UserOrgId = adminInfo.CurrentOrgId
- p.HisPatientId = his_patient_id
- p.Status = 1
- errcode := c.setProjectWithJSONTwo(&p, project.(map[string]interface{}))
- if errcode > 0 {
- c.ServeFailJSONWithSGJErrorCode(errcode)
- return
- }
- service.CreateHisProjectTwo(&p)
-
- }
- }
- }
- if items["addition"] != nil && reflect.TypeOf(items["addition"]).String() == "[]interface {}" {
- addition := items["addition"].([]interface{})
- //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
- ctime := time.Now().Unix()
- mtime := ctime
- if len(addition) > 0 {
- for _, item := range addition {
- var s models.HisAdditionalCharge
- s.PrescriptionId = prescription.ID
- s.Status = 1
- s.UserOrgId = adminInfo.CurrentOrgId
- s.RecordDate = recordDateTime
- s.CreatedTime = ctime
- s.UpdatedTime = mtime
- s.PatientId = patient_id
- s.HisPatientId = his_patient_id
- errcode := c.setAddtionWithJSONTwo(&s, item.(map[string]interface{}), adminInfo.CurrentOrgId)
- if errcode > 0 {
- c.ServeFailJSONWithSGJErrorCode(errcode)
- return
- }
- service.CreateAdditionalCharge(&s)
- }
- }
- }
-
- }
- }
- }
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "保存成功",
- })
- return
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *HisApiController) DeletePrescription() {
- prescription_id, _ := c.GetInt64("id")
- projects, _ := service.GetHisPrescriptionProjectsByID(prescription_id)
- advices, _ := service.GetHisPrescriptionAdviceByID(prescription_id)
- _, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
-
- _, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
-
- err := service.DelelteHisPrescription(prescription_id, c.GetAdminUserInfo().CurrentOrgId)
- if err == nil {
- if len(projects) > 0 {
- for _, item := range projects {
- if stockConfig.IsOpen == 1 {
- if item.Type == 3 {
- good, _ := service.FindGoodInfoByIdTwo(item.ProjectId)
- f_count, _ := strconv.ParseFloat(strconv.FormatInt(item.Count, 10), 64)
- good.Total = good.Total + f_count
- service.UpdateGoodInfo(&good)
- }
- }
-
- if item.Type == 3 { //处理透前准备耗材数量数据
- consumables, _ := service.FindHisConsumablesByID(item.UserOrgId, item.PatientId, item.RecordDate, item.ProjectId)
- if consumables.ID > 0 {
- consumables.Count = 0
- service.UpdateConsumables(&consumables)
- }
- }
- }
- }
-
- if drugStockConfig.IsOpen == 1 {
- if len(advices) > 0 {
- for _, item := range advices {
- drug, _ := service.FindBaseDrugLibRecord(c.GetAdminUserInfo().CurrentOrgId, item.DrugId)
- if item.PrescribingNumberUnit == drug.MinUnit {
- drug.Total = drug.Total + item.PrescribingNumber
- service.UpdateBaseDrugLib(&drug)
- } else {
- if item.PrescribingNumberUnit == drug.MaxUnit {
- item.PrescribingNumber = item.PrescribingNumber * float64(drug.MinNumber)
- drug.Total = drug.Total + item.PrescribingNumber
- service.UpdateBaseDrugLib(&drug)
- }
- }
- }
- }
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *HisApiController) DeleteDoctorAdvice() {
- id, _ := c.GetInt64("id")
- advice, _ := service.GetHisDoctorAdvicesById(id)
- _, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
- err := service.DelelteDoctorAdvice(id, c.GetAdminUserInfo().CurrentOrgId)
- if err == nil {
- if drugStockConfig.IsOpen == 1 {
- drug, _ := service.FindBaseDrugLibRecord(c.GetAdminUserInfo().CurrentOrgId, advice.DrugId)
- if advice.PrescribingNumberUnit == drug.MinUnit {
- drug.Total = drug.Total + advice.PrescribingNumber
- service.UpdateBaseDrugLib(&drug)
- } else {
- if advice.PrescribingNumberUnit == drug.MaxUnit {
- advice.PrescribingNumber = advice.PrescribingNumber * float64(drug.MinNumber)
- drug.Total = drug.Total + advice.PrescribingNumber
- service.UpdateBaseDrugLib(&drug)
- }
- }
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *HisApiController) DeleteProject() {
- id, _ := c.GetInt64("id")
- adminInfo := c.GetAdminUserInfo()
- project, _ := service.GetHisProjectByID(id)
- var consumable models.DialysisBeforePrepare
- _, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
-
- if project.ID > 0 && project.Type == 3 {
- consumable, _ = service.FindHisConsumablesByID(adminInfo.CurrentOrgId, project.PatientId, project.RecordDate, project.ProjectId)
- }
- err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
- if err == nil {
- if stockConfig.IsOpen == 1 {
- if project.Type == 3 {
- good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
- f_count, _ := strconv.ParseFloat(strconv.FormatInt(project.Count, 10), 64)
- good.Total = good.Total + f_count
- service.UpdateGoodInfo(&good)
- }
- }
- if consumable.ID > 0 {
- consumable.Count = 0
- service.UpdateConsumables(&consumable)
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *HisApiController) CreateHisAdditionalCharge() {
- his_patient_id, _ := c.GetInt64("his_patient_id")
- patient_id, _ := c.GetInt64("patient_id")
- record_date := c.GetString("record_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminInfo := c.GetAdminUserInfo()
- recordDateTime := theTime.Unix()
- dataBody := make(map[string]interface{}, 0)
- err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- var additions []*models.HisAdditionalCharge
- if dataBody["addition"] != nil && reflect.TypeOf(dataBody["addition"]).String() == "[]interface {}" {
- additions, _ := dataBody["addition"].([]interface{})
- if len(additions) > 0 {
- for _, item := range additions {
- items := item.(map[string]interface{})
-
- if items["item_id"] == nil || reflect.TypeOf(items["item_id"]).String() != "float64" {
- utils.ErrorLog("item_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- item_id := int64(items["item_id"].(float64))
-
- if items["item_name"] == nil || reflect.TypeOf(items["item_name"]).String() != "string" {
- utils.ErrorLog("item_name")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- item_name := items["item_name"].(string)
-
- if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
- utils.ErrorLog("price")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- price, _ := strconv.ParseFloat(items["price"].(string), 64)
-
- ctime := time.Now().Unix()
- additional := &models.HisAdditionalCharge{
- PatientId: patient_id,
- HisPatientId: his_patient_id,
- UserOrgId: adminInfo.CurrentOrgId,
- RecordDate: recordDateTime,
- CreatedTime: ctime,
- UpdatedTime: ctime,
- Modifier: adminInfo.AdminUser.Id,
- Creator: adminInfo.AdminUser.Id,
- Price: price,
- ItemName: item_name,
- ItemId: item_id,
- Status: 1,
- }
- additions = append(additions, additional)
- }
- }
- }
- for _, item := range additions {
- service.CreateAddtionalCharge(item)
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "创建成功",
- })
- }
-
- func (c *HisApiController) CreateHisPatientCaseHistory() {
-
- blood_fat := c.GetString("blood_fat")
- bloodfatfloat, _ := strconv.ParseFloat(blood_fat, 64)
-
- blood_sugar := c.GetString("blood_sugar")
- bloodsugarfloat, _ := strconv.ParseFloat(blood_sugar, 64)
- fmt.Println(bloodsugarfloat)
- chief_conplaint := c.GetString("chief_conplaint")
-
- dbp := c.GetString("dbp")
- dbpfloat, _ := strconv.ParseFloat(dbp, 64)
- delivery_way, _ := c.GetInt64("delivery_way")
- diagnostic := c.GetString("diagnostic")
-
- family_history := c.GetString("family_history")
-
- height := c.GetString("height")
- history_of_present_illness := c.GetString("history_of_present_illness")
- is_infect, _ := c.GetInt64("is_infect")
- fmt.Println("is", is_infect)
- past_history := c.GetString("past_history")
- patient_id, _ := c.GetInt64("patient_id")
- his_patient_id, _ := c.GetInt64("his_patient_id")
- fmt.Println("patient_id", patient_id)
- personal_history := c.GetString("personal_history")
- pulse := c.GetString("pulse")
- pulsefloat, _ := strconv.ParseFloat(pulse, 64)
- sbp := c.GetString("sbp")
- sbpfloat, _ := strconv.ParseFloat(sbp, 64)
- heightfloat, _ := strconv.ParseFloat(height, 64)
- sicktype := c.GetString("sick_type")
- fmt.Println("sicketype", sicktype)
- sick_type, _ := strconv.ParseInt(sicktype, 10, 64)
- symptom := c.GetString("symptom")
- sick_date := c.GetString("sick_date")
- temperatures := c.GetString("temperature")
- fmt.Println("temperatures", temperatures)
- temperature, _ := strconv.ParseFloat(temperatures, 64)
- record_date := c.GetString("record_date")
- breathing := c.GetString("breathing")
- doctor_advice := c.GetString("doctor_advice")
- remark := c.GetString("remark")
- breathingfloat, _ := strconv.ParseFloat(breathing, 64)
-
- sick, _ := c.GetInt64("sick")
- diagnose, _ := c.GetInt64("diagnose")
- id, _ := c.GetInt64("id")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- allergic_history := c.GetString("allergic_history")
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- fmt.Println("recordDataTime", recordDateTime)
- sickTime, err := time.ParseInLocation(timeLayout+" 15:04:05", sick_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- sickTimes := sickTime.Unix()
- ctime := time.Now().Unix()
- caseHistory := models.HisPatientCaseHistory{
- HisPatientId: his_patient_id,
- PatientId: patient_id,
- Temperature: temperature,
- BloodSugar: bloodsugarfloat,
- Pulse: pulsefloat,
- Sbp: sbpfloat,
- Dbp: dbpfloat,
- Height: heightfloat,
- BloodFat: bloodfatfloat,
- SickType: sick_type,
- Symptom: symptom,
- SickDate: sickTimes,
- IsInfect: is_infect,
- HistoryOfPresentIllness: history_of_present_illness,
- PastHistory: past_history,
- Doctor: c.GetAdminUserInfo().AdminUser.Id,
- ChiefConplaint: chief_conplaint,
- PersonalHistory: personal_history,
- FamilyHistory: family_history,
- Diagnostic: diagnostic,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- Status: 1,
- Ctime: ctime,
- Mtime: ctime,
- RecordDate: recordDateTime,
- DeliveryWay: delivery_way,
- Breathing: breathingfloat,
- DoctorAdvice: doctor_advice,
- Remark: remark,
- Sick: sick,
- Diagnose: diagnose,
- AllergicHistory: allergic_history,
- }
- //查询该患者是否有病历
- _, errcodes := service.GetHisPatientCaseHistoryById(id)
- if errcodes == gorm.ErrRecordNotFound {
- err = service.SaveHisPatientCaseHistory(&caseHistory)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "caseHistory": caseHistory,
- })
- return
- } else if errcodes == nil {
- err := service.UpdatePatientCaseHistory(id, &caseHistory)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "caseHistory": caseHistory,
- })
- }
-
- //查询该患者是否有病历
- //_, errcode := service.GetHisPatientCaseHistoryById(his_patient_id)
- //if errcode == gorm.ErrRecordNotFound {
- // err = service.SaveHisPatientCaseHistory(caseHistory)
- // if err != nil {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "msg": "保存成功",
- // })
- // }
- //} else if errcode == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- // return
- //}
-
- }
- func (c *HisApiController) GetHisPatientCaseHistoryList() {
- patient_id, _ := c.GetInt64("patient_id", 0)
- adminUser := c.GetAdminUserInfo()
- caseHistorys, _ := service.GetHisPatientCaseHistoryList(adminUser.CurrentOrgId, patient_id)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": caseHistorys,
- })
-
- }
- func (c *HisApiController) GetHisPatientCaseHistory() {
- record_date, _ := c.GetInt64("record_date", 0)
- patient_id, _ := c.GetInt64("patient_id", 0)
- admin := c.GetAdminUserInfo()
- info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, record_date)
- case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, record_date)
- c.ServeSuccessJSON(map[string]interface{}{
- "info": info,
- "case_history": case_history,
- })
-
- }
- func (c *HisApiController) CreateCaseHistoryTemplate() {
- template_name := c.GetString("template_name")
- template_remark := c.GetString("template_remark")
- doctor := c.GetAdminUserInfo().AdminUser.Id
- diagnostic := c.GetString("diagnostic")
- chief_conplaint := c.GetString("chief_conplain")
- history_of_present_illness := c.GetString("history_of_present_illness")
- past_history := c.GetString("past_history")
- personal_history := c.GetString("personal_history")
- family_history := c.GetString("family_history")
- user_name := c.GetString("user_name")
- doctor_advice := c.GetString("doctor_advice")
- remark := c.GetString("remark")
- //record_date := c.GetString("record_date")
- //fmt.Println("record_date--------",record_date)
- //timeLayout := "2006-01-02"
- //loc, _ := time.LoadLocation("Local")
- //
- //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- //if err != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- //}
- //recordDateTime := theTime.Unix()
-
- ctime := time.Now().Unix()
-
- template := models.HisCaseHistoryTemplate{
- HistoryOfPresentIllness: history_of_present_illness,
- PastHistory: past_history,
- ChiefConplaint: chief_conplaint,
- PersonalHistory: personal_history,
- FamilyHistory: family_history,
- Diagnostic: diagnostic,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- Status: 1,
- Ctime: ctime,
- Mtime: ctime,
- RecordDate: time.Now().Unix(),
- TemplateName: template_name,
- TemplateRemark: template_remark,
- Creator: doctor,
- Modifier: doctor,
- UserName: user_name,
- DoctorAdvice: doctor_advice,
- Remark: remark,
- }
-
- err := service.SaveHisPatientCaseHistoryTemplate(template)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "保存成功",
- })
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- }
- func (c *HisApiController) GetCaseHistoryTemplate() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- keyword := c.GetString("keyword")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- admin := c.GetAdminUserInfo()
- template, _ := service.GetHisPatientCaseHistoryTemplate(admin.CurrentOrgId, startTime.Unix(), endTime.Unix(), keyword)
- //history, _ := service.GetHisPatientCaseHistory(admin.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- //"history": history,
- })
-
- }
-
- func (c *HisApiController) setAdviceWithJSONTwo(advice *models.HisDoctorAdviceInfo, json map[string]interface{}) int {
-
- if json["drug_name"] == nil || reflect.TypeOf(json["drug_name"]).String() != "string" {
- utils.ErrorLog("drug_name")
- return enums.ErrorCodeParamWrong
- }
- adviceName, _ := json["drug_name"].(string)
- if len(adviceName) == 0 {
- utils.ErrorLog("len(advice_name) == 0")
- return enums.ErrorCodeParamWrong
- }
- advice.AdviceName = adviceName
- adviceDesc, _ := json["advice_desc"].(string)
- advice.AdviceDesc = adviceDesc
- if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
- drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
- advice.DrugSpec = drugSpec
- }
- if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
- remark, _ := json["remark"].(string)
- advice.Remark = remark
- }
- if json["id"] == nil {
- advice.DrugId = 0
- } else {
- if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
- drug_id := int64(json["id"].(float64))
- advice.DrugId = drug_id
- }
- }
- if json["advice_id"] != nil && reflect.TypeOf(json["advice_id"]).String() == "float64" {
- advice_id := int64(json["advice_id"].(float64))
- advice.ID = advice_id
- if advice.ID > 0 {
- hisAdvice, err := service.GetHisDoctorAdvicesById(advice.ID)
- if err == nil {
- if hisAdvice.ID > 0 {
- advice.ExecutionTime = hisAdvice.ExecutionTime
- advice.ExecutionStaff = hisAdvice.ExecutionStaff
- advice.ExecutionState = hisAdvice.ExecutionState
- advice.CheckTime = hisAdvice.CheckTime
- advice.Checker = hisAdvice.Checker
- advice.CheckState = hisAdvice.CheckState
- advice.StartTime = hisAdvice.StartTime
- advice.FeedetlSn = hisAdvice.FeedetlSn
-
- }
- }
- }
- }
-
- //
- //if json["execution_time"] != nil && reflect.TypeOf(json["execution_time"]).String() == "string" {
- // execution_time, _ := strconv.ParseInt(json["execution_time"].(string), 10,64)
- // advice.ExecutionTime = execution_time
- //}
- //
- //
- //
- //if json["execution_staff"] != nil && reflect.TypeOf(json["execution_staff"]).String() == "string" {
- // execution_staff, _ := strconv.ParseInt(json["execution_staff"].(string), 10,64)
- // advice.ExecutionStaff = execution_staff
- //}
- //
- //
- //
- //if json["execution_state"] != nil && reflect.TypeOf(json["execution_state"]).String() == "string" {
- // execution_state, _ := strconv.ParseInt(json["execution_state"].(string), 10,64)
- // advice.ExecutionState = execution_state
- //}
- //
- //
- //if json["check_time"] != nil && reflect.TypeOf(json["check_time"]).String() == "string" {
- // check_time, _ := strconv.ParseInt(json["check_time"].(string), 10,64)
- // advice.CheckTime = check_time
- //}
- //
- //
- //if json["check_state"] != nil && reflect.TypeOf(json["check_state"]).String() == "string" {
- // check_state, _ := strconv.ParseInt(json["check_state"].(string), 10,64)
- // advice.CheckState = check_state
- //}
- //
- //
- //if json["checker"] != nil && reflect.TypeOf(json["checker"]).String() == "string" {
- // checker, _ := strconv.ParseInt(json["checker"].(string), 10,64)
- // advice.Checker = checker
- //}
- //
- //if json["start_time"] != nil && reflect.TypeOf(json["start_time"]).String() == "string" {
- // start_time, _ := strconv.ParseInt(json["start_time"].(string), 10,64)
- // advice.StartTime = start_time
- //}
-
- if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
- drugSpecUnit, _ := json["min_unit"].(string)
- advice.DrugSpecUnit = drugSpecUnit
- }
- if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
- singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
- advice.SingleDose = singleDose
- }
- if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
- singleDoseUnit, _ := json["single_dose_unit"].(string)
- advice.SingleDoseUnit = singleDoseUnit
- }
- if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
- prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
- advice.PrescribingNumber = prescribingNumber
- }
- if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
- prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
- advice.PrescribingNumberUnit = prescribingNumberUnit
- }
- if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
- deliveryWay, _ := json["delivery_way"].(string)
- advice.DeliveryWay = deliveryWay
- }
- if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
- executionFrequency, _ := json["execution_frequency"].(string)
- advice.ExecutionFrequency = executionFrequency
- }
-
- if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
- price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
- advice.Price = price
- }
- if json["medical_insurance_number"] != nil || reflect.TypeOf(json["medical_insurance_number"]).String() == "string" {
- med_list_codg, _ := json["medical_insurance_number"].(string)
- advice.MedListCodg = med_list_codg
- }
- if json["day"] != nil || reflect.TypeOf(json["day"]).String() == "float64" {
- day := int64(json["day"].(float64))
- advice.Day = day
- }
- return 0
- }
-
- func (c *HisApiController) setProjectWithJSONTwo(project *models.HisPrescriptionProject, json map[string]interface{}) int {
- if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
- id := int64(json["id"].(float64))
- project.ID = id
- historyProject, _ := service.GetHisProjectByID(id)
- project.FeedetlSn = historyProject.FeedetlSn
-
- }
- if json["project_id"] != nil || reflect.TypeOf(json["project_id"]).String() == "float64" {
- project_id := int64(json["project_id"].(float64))
- project.ProjectId = project_id
-
- }
- // if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
- // price := int64(json["price"].(float64))
- // formatInt_price := strconv.FormatInt(price, 10)
- // float_price, _ := strconv.ParseFloat(formatInt_price, 64)
- // project.Price = float_price
- // }
- if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "string" {
- price, _ := strconv.ParseFloat(json["price"].(string), 64)
- project.Price = price
- }
-
- if json["total"] != nil && reflect.TypeOf(json["total"]).String() == "string" {
- total, _ := json["total"].(string)
- totals, _ := strconv.ParseInt(total, 10, 64)
- project.Count = totals
- }
-
- if json["medical_code"] != nil && reflect.TypeOf(json["medical_code"]).String() == "string" {
- medical_code, _ := json["medical_code"].(string)
- project.MedListCodg = medical_code
- }
- if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
- single_dose, _ := json["single_dose"].(string)
- project.SingleDose = single_dose
- }
-
- if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
- delivery_way, _ := json["delivery_way"].(string)
- project.DeliveryWay = delivery_way
- }
- if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
- execution_frequency, _ := json["execution_frequency"].(string)
- project.ExecutionFrequency = execution_frequency
- }
- if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
- remark, _ := json["remark"].(string)
- project.Remark = remark
- }
- if json["number_days"] != nil && reflect.TypeOf(json["number_days"]).String() == "string" {
- day, _ := json["number_days"].(string)
- project.Day = day
- }
-
- if json["unit"] != nil && reflect.TypeOf(json["unit"]).String() == "string" {
- unit, _ := json["unit"].(string)
- project.Unit = unit
- }
- return 0
- }
-
- func (c *HisApiController) setAddtionWithJSONTwo(additionalCharge *models.HisAdditionalCharge, json map[string]interface{}, org_id int64) int {
- if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
- id := int64(json["id"].(float64))
- historyAddtions, _ := service.GetHisAdditionByID(id)
- additionalCharge.ID = id
- additionalCharge.FeedetlSn = historyAddtions.FeedetlSn
- }
- if json["item_id"] != nil || reflect.TypeOf(json["item_id"]).String() == "float64" {
- item_id := int64(json["item_id"].(float64))
- additionalCharge.ItemId = item_id
- config, _ := service.GetAdditionChargeByID(org_id, item_id)
- if config.ID > 0 {
- if len(config.Code) > 0 {
- additionalCharge.MedListCodg = config.Code
- }
- }
- }
- // if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
- // price := int64(json["price"].(float64))
- // formatInt_price := strconv.FormatInt(price, 10)
- // float_price, _ := strconv.ParseFloat(formatInt_price, 64)
- // additionalCharge.Price = float_price
- // }
-
- //if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
- // price := int64(json["price"].(float64))
- // formatInt_price := strconv.FormatInt(price, 10)
- // float_price, _ := strconv.ParseFloat(formatInt_price, 64)
- // additionalCharge.Price = float_price
- //}
-
- if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "string" {
- price, _ := strconv.ParseFloat(json["price"].(string), 64)
- additionalCharge.Price = price
- }
- if json["count"] != nil && reflect.TypeOf(json["count"]).String() == "string" {
- count, _ := json["count"].(string)
- counts, _ := strconv.ParseInt(count, 10, 64)
- additionalCharge.Count = counts
- }
- if json["item_name"] != nil && reflect.TypeOf(json["item_name"]).String() == "string" {
- item_name, _ := json["item_name"].(string)
- additionalCharge.ItemName = item_name
- }
-
- return 0
- }
-
- func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo, json map[string]interface{}) int {
-
- if json["drug_name"] == nil || reflect.TypeOf(json["drug_name"]).String() != "string" {
- utils.ErrorLog("drug_name")
- return enums.ErrorCodeParamWrong
- }
- adviceName, _ := json["drug_name"].(string)
- if len(adviceName) == 0 {
- utils.ErrorLog("len(advice_name) == 0")
- return enums.ErrorCodeParamWrong
- }
- advice.AdviceName = adviceName
- adviceDesc, _ := json["advice_desc"].(string)
- advice.AdviceDesc = adviceDesc
- if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
- drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
- advice.DrugSpec = drugSpec
- }
- if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
- remark, _ := json["remark"].(string)
- advice.Remark = remark
- }
- if json["id"] == nil {
- advice.DrugId = 0
- } else {
- if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
- drug_id := int64(json["id"].(float64))
- advice.DrugId = drug_id
- }
- }
-
- if json["groupno"] != nil || reflect.TypeOf(json["groupno"]).String() == "float64" {
- groupno := int64(json["groupno"].(float64))
- advice.Groupno = groupno
- }
-
- if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
- prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
- advice.PrescribingNumber = prescribingNumber
- }
-
- if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
- prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
- advice.PrescribingNumberUnit = prescribingNumberUnit
- }
-
- if json["advice_id"] != nil && reflect.TypeOf(json["advice_id"]).String() == "float64" {
- advice_id := int64(json["advice_id"].(float64))
- advice.ID = advice_id
- if advice.ID > 0 {
- hisAdvice, err := service.GetHisDoctorAdvicesById(advice.ID)
- if err == nil {
- if hisAdvice.ID > 0 {
- advice.ExecutionTime = hisAdvice.ExecutionTime
- advice.ExecutionStaff = hisAdvice.ExecutionStaff
- advice.ExecutionState = hisAdvice.ExecutionState
- advice.CheckTime = hisAdvice.CheckTime
- advice.Checker = hisAdvice.Checker
- advice.CheckState = hisAdvice.CheckState
- advice.StartTime = hisAdvice.StartTime
- //advice.Groupno = hisAdvice.Groupno
-
- }
- }
- }
- }
-
- _, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(advice.UserOrgId)
-
- if drugStockConfig.IsOpen == 1 {
-
- drug, _ := service.FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
- if advice.ID == 0 { //医嘱不存在
- if advice.PrescribingNumberUnit == drug.MinUnit { //当前数据单位与基础库一致为最小单位,直接计算
- drug.Total = drug.Total - advice.PrescribingNumber
- service.UpdateBaseDrugLib(&drug)
-
- } else if advice.PrescribingNumberUnit == drug.MaxUnit { //当前数据单位为最大单位,需要将最大单位转为最小单位
- num := advice.PrescribingNumber * float64(drug.MinNumber)
- drug.Total = drug.Total - num
- service.UpdateBaseDrugLib(&drug)
- }
-
- } else if advice.ID > 0 { //医嘱存在
- hisAdvice, _ := service.GetHisDoctorAdvicesById(advice.ID)
- var num float64
-
- if advice.PrescribingNumberUnit == drug.MinUnit { //当前数据为最小单位
- if hisAdvice.PrescribingNumberUnit == advice.PrescribingNumberUnit { //原数据为最小单位,三个单位一致为最小单位直接计算
- if hisAdvice.PrescribingNumber > advice.PrescribingNumber {
- num = hisAdvice.PrescribingNumber - advice.PrescribingNumber
- drug.Total = drug.Total + num
- service.UpdateBaseDrugLib(&drug)
- } else if hisAdvice.PrescribingNumber < advice.PrescribingNumber {
- num = advice.PrescribingNumber - hisAdvice.PrescribingNumber
- drug.Total = drug.Total - num
- service.UpdateBaseDrugLib(&drug)
- }
- } else { //原数据为最大单位,需要将最大单位数量转为最小单位数量
- num2 := hisAdvice.PrescribingNumber * float64(drug.MinNumber)
- if num2 > advice.PrescribingNumber {
- num = num2 - advice.PrescribingNumber
- drug.Total = drug.Total + num
- service.UpdateBaseDrugLib(&drug)
- } else if num2 < advice.PrescribingNumber {
- num = advice.PrescribingNumber - num2
- drug.Total = drug.Total - num
- service.UpdateBaseDrugLib(&drug)
- }
-
- }
-
- } else if advice.PrescribingNumberUnit == drug.MaxUnit { //当前数据为最大单位
- if advice.PrescribingNumberUnit == hisAdvice.PrescribingNumberUnit { //原数据为最大单位, 当前数据单位和原数据单位都为最大单位,需要将两个数据转成最小单位
- num1 := hisAdvice.PrescribingNumber * float64(drug.MinNumber)
- num2 := advice.PrescribingNumber * float64(drug.MinNumber)
- if num1 > num2 {
- num = num1 - num2
- drug.Total = drug.Total + num
- service.UpdateBaseDrugLib(&drug)
- } else if num1 < num2 {
- num = num2 - num1
- drug.Total = drug.Total - num
- service.UpdateBaseDrugLib(&drug)
- }
-
- } else { //原数据为最小单位,当前数据为最大单位,需要将当前数据数量转为最小单位数量
- num2 := advice.PrescribingNumber * float64(drug.MinNumber)
- //num2 := hisAdvice.PrescribingNumber * (drug.Dose / float64(drug.MinNumber))
- if hisAdvice.PrescribingNumber > num2 {
- num = hisAdvice.PrescribingNumber - num2
- drug.Total = drug.Total + num
- service.UpdateBaseDrugLib(&drug)
- } else if num2 < advice.PrescribingNumber {
- num = num2 - hisAdvice.PrescribingNumber
- drug.Total = drug.Total - num
- service.UpdateBaseDrugLib(&drug)
- }
-
- }
- }
- }
- }
-
- //
- //if json["execution_time"] != nil && reflect.TypeOf(json["execution_time"]).String() == "string" {
- // execution_time, _ := strconv.ParseInt(json["execution_time"].(string), 10,64)
- // advice.ExecutionTime = execution_time
- //}
- //
- //
- //
- //if json["execution_staff"] != nil && reflect.TypeOf(json["execution_staff"]).String() == "string" {
- // execution_staff, _ := strconv.ParseInt(json["execution_staff"].(string), 10,64)
- // advice.ExecutionStaff = execution_staff
- //}
- //
- //
- //
- //if json["execution_state"] != nil && reflect.TypeOf(json["execution_state"]).String() == "string" {
- // execution_state, _ := strconv.ParseInt(json["execution_state"].(string), 10,64)
- // advice.ExecutionState = execution_state
- //}
- //
- //
- //if json["check_time"] != nil && reflect.TypeOf(json["check_time"]).String() == "string" {
- // check_time, _ := strconv.ParseInt(json["check_time"].(string), 10,64)
- // advice.CheckTime = check_time
- //}
- //
- //
- //if json["check_state"] != nil && reflect.TypeOf(json["check_state"]).String() == "string" {
- // check_state, _ := strconv.ParseInt(json["check_state"].(string), 10,64)
- // advice.CheckState = check_state
- //}
- //
- //
- //if json["checker"] != nil && reflect.TypeOf(json["checker"]).String() == "string" {
- // checker, _ := strconv.ParseInt(json["checker"].(string), 10,64)
- // advice.Checker = checker
- //}
- //
- //if json["start_time"] != nil && reflect.TypeOf(json["start_time"]).String() == "string" {
- // start_time, _ := strconv.ParseInt(json["start_time"].(string), 10,64)
- // advice.StartTime = start_time
- //}
-
- if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
- drugSpecUnit, _ := json["min_unit"].(string)
- advice.DrugSpecUnit = drugSpecUnit
- }
- if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
- singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
- advice.SingleDose = singleDose
- }
- if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
- singleDoseUnit, _ := json["single_dose_unit"].(string)
- advice.SingleDoseUnit = singleDoseUnit
- }
-
- if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
- deliveryWay, _ := json["delivery_way"].(string)
- advice.DeliveryWay = deliveryWay
- }
- if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
- executionFrequency, _ := json["execution_frequency"].(string)
- advice.ExecutionFrequency = executionFrequency
- }
-
- if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
- price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
- advice.Price = price
- }
- if json["medical_insurance_number"] != nil || reflect.TypeOf(json["medical_insurance_number"]).String() == "string" {
- med_list_codg, _ := json["medical_insurance_number"].(string)
- advice.MedListCodg = med_list_codg
- }
- if json["day"] != nil || reflect.TypeOf(json["day"]).String() == "float64" {
- day := int64(json["day"].(float64))
- advice.Day = day
- }
- return 0
- }
-
- func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionProject, json map[string]interface{}) int {
- project.ExecutionStaff = 0
- project.ExecutionState = 2
- project.ExecutionTime = 0
- project.Checker = 0
- project.CheckState = 2
- project.CheckTime = 0
- if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
- id := int64(json["id"].(float64))
- project.ID = id
- temp_project, _ := service.GetHisPrescriptionProjectByID(id)
- project.ExecutionStaff = temp_project.ExecutionStaff
- project.ExecutionState = temp_project.ExecutionState
- project.ExecutionTime = temp_project.ExecutionTime
- project.Checker = temp_project.Checker
- project.CheckState = temp_project.CheckState
- project.CheckTime = temp_project.CheckTime
-
- }
- if json["type"] != nil || reflect.TypeOf(json["type"]).String() == "float64" {
- types := int64(json["type"].(float64))
- project.Type = types
- }
- if json["project_id"] != nil || reflect.TypeOf(json["project_id"]).String() == "float64" {
- project_id := int64(json["project_id"].(float64))
- project.ProjectId = project_id
- fmt.Println(project_id)
- fmt.Println(project.ProjectId)
- }
- // if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
- // price := int64(json["price"].(float64))
- // formatInt_price := strconv.FormatInt(price, 10)
- // float_price, _ := strconv.ParseFloat(formatInt_price, 64)
- // project.Price = float_price
- // }
- if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "string" {
- price, _ := strconv.ParseFloat(json["price"].(string), 64)
- project.Price = price
- }
-
- if json["total"] != nil && reflect.TypeOf(json["total"]).String() == "string" {
- total, _ := json["total"].(string)
- totals, _ := strconv.ParseInt(total, 10, 64)
- project.Count = totals
- }
-
- if json["medical_code"] != nil && reflect.TypeOf(json["medical_code"]).String() == "string" {
- medical_code, _ := json["medical_code"].(string)
- project.MedListCodg = medical_code
- }
- if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
- single_dose, _ := json["single_dose"].(string)
- project.SingleDose = single_dose
- }
-
- if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
- delivery_way, _ := json["delivery_way"].(string)
- project.DeliveryWay = delivery_way
- }
- if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
- execution_frequency, _ := json["execution_frequency"].(string)
- project.ExecutionFrequency = execution_frequency
- }
- if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
- remark, _ := json["remark"].(string)
- project.Remark = remark
- }
- if json["number_days"] != nil && reflect.TypeOf(json["number_days"]).String() == "string" {
- day, _ := json["number_days"].(string)
- project.Day = day
- }
-
- if json["unit"] != nil && reflect.TypeOf(json["unit"]).String() == "string" {
- unit, _ := json["unit"].(string)
- project.Unit = unit
- }
-
- _, stockConfig := service.FindAutomaticReduceRecordByOrgId(project.UserOrgId)
-
- if project.ID == 0 {
- if stockConfig.IsOpen == 1 {
- if project.Type == 3 {
- good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
- f_count, _ := strconv.ParseFloat(strconv.FormatInt(project.Count, 10), 64)
- good.Total = good.Total - f_count
- service.UpdateGoodInfo(&good)
- }
- }
-
- } else {
- temp_project, _ := service.GetHisPrescriptionProjectByID(project.ID)
-
- if stockConfig.IsOpen == 1 {
- if project.Type == 3 {
- good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
- if project.Count < temp_project.Count {
- other_count := temp_project.Count - project.Count
- other_count_two, _ := strconv.ParseFloat(strconv.FormatInt(other_count, 10), 64)
- good.Total = good.Total + other_count_two
- service.UpdateGoodInfo(&good)
- } else if project.Count > temp_project.Count {
- other_count := project.Count - temp_project.Count
- other_count_two, _ := strconv.ParseFloat(strconv.FormatInt(other_count, 10), 64)
- good.Total = good.Total - other_count_two
- service.UpdateGoodInfo(&good)
- }
-
- }
- }
-
- }
-
- return 0
- }
-
- func (c *HisApiController) setAddtionWithJSON(additionalCharge *models.HisAdditionalCharge, json map[string]interface{}, org_id int64) int {
- if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
- id := int64(json["id"].(float64))
- additionalCharge.ID = id
- }
-
- if json["item_id"] != nil || reflect.TypeOf(json["item_id"]).String() == "float64" {
- item_id := int64(json["item_id"].(float64))
- additionalCharge.ItemId = item_id
- config, _ := service.GetAdditionChargeByID(org_id, item_id)
- if config.ID > 0 {
- if len(config.Code) > 0 {
- additionalCharge.MedListCodg = config.Code
- }
- }
- }
- // if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
- // price := int64(json["price"].(float64))
- // formatInt_price := strconv.FormatInt(price, 10)
- // float_price, _ := strconv.ParseFloat(formatInt_price, 64)
- // additionalCharge.Price = float_price
- // }
-
- //if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "float64" {
- // price := int64(json["price"].(float64))
- // formatInt_price := strconv.FormatInt(price, 10)
- // float_price, _ := strconv.ParseFloat(formatInt_price, 64)
- // additionalCharge.Price = float_price
- //}
-
- if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "string" {
- price, _ := strconv.ParseFloat(json["price"].(string), 64)
- additionalCharge.Price = price
- }
- if json["count"] != nil && reflect.TypeOf(json["count"]).String() == "string" {
- count, _ := json["count"].(string)
- counts, _ := strconv.ParseInt(count, 10, 64)
- additionalCharge.Count = counts
- }
- if json["item_name"] != nil && reflect.TypeOf(json["item_name"]).String() == "string" {
- item_name, _ := json["item_name"].(string)
- additionalCharge.ItemName = item_name
- }
-
- return 0
- }
-
- func (c *HisApiController) setAdviceTemplateWithJSON(advice *models.HisPrescriptionAdviceTemplate, json map[string]interface{}) int {
-
- if json["drug_name"] == nil || reflect.TypeOf(json["drug_name"]).String() != "string" {
- utils.ErrorLog("drug_name")
- return enums.ErrorCodeParamWrong
- }
- adviceName, _ := json["drug_name"].(string)
- if len(adviceName) == 0 {
- utils.ErrorLog("len(advice_name) == 0")
- return enums.ErrorCodeParamWrong
- }
- advice.AdviceName = adviceName
- adviceDesc, _ := json["advice_desc"].(string)
- advice.AdviceDesc = adviceDesc
- if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
- drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
- advice.DrugSpec = drugSpec
- }
- if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
- remark, _ := json["remark"].(string)
- advice.Remark = remark
- }
- if json["id"] == nil {
- advice.DrugId = 0
- } else {
- if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
- drug_id := int64(json["id"].(float64))
- advice.DrugId = drug_id
- }
- }
-
- if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
- drugSpecUnit, _ := json["min_unit"].(string)
- advice.DrugSpecUnit = drugSpecUnit
- }
- if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
- singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
- advice.SingleDose = singleDose
- }
- if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
- singleDoseUnit, _ := json["single_dose_unit"].(string)
- advice.SingleDoseUnit = singleDoseUnit
- }
- if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
- prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
- advice.PrescribingNumber = prescribingNumber
- }
- if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
- prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
- advice.PrescribingNumberUnit = prescribingNumberUnit
- }
- if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
- deliveryWay, _ := json["delivery_way"].(string)
- advice.DeliveryWay = deliveryWay
- }
- if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
- executionFrequency, _ := json["execution_frequency"].(string)
- advice.ExecutionFrequency = executionFrequency
- }
-
- if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
- price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
- advice.Price = price
- }
- if json["medical_insurance_number"] != nil || reflect.TypeOf(json["medical_insurance_number"]).String() == "string" {
- med_list_codg, _ := json["medical_insurance_number"].(string)
- advice.MedListCodg = med_list_codg
- }
- if json["day"] != nil || reflect.TypeOf(json["day"]).String() == "float64" {
- day := int64(json["day"].(float64))
- advice.Day = day
- }
- return 0
- }
-
- func (c *HisApiController) setProjectTemplateWithJSON(project *models.HisPrescriptionProjectTemplate, json map[string]interface{}) int {
- if json["type"] != nil || reflect.TypeOf(json["type"]).String() == "float64" {
- types := int64(json["type"].(float64))
- project.Type = types
- }
- if json["project_id"] != nil || reflect.TypeOf(json["project_id"]).String() == "float64" {
- project_id := int64(json["project_id"].(float64))
- project.ProjectId = project_id
- }
-
- if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "string" {
- price, _ := strconv.ParseFloat(json["price"].(string), 64)
- project.Price = price
- }
-
- if json["total"] != nil && reflect.TypeOf(json["total"]).String() == "string" {
- total, _ := json["total"].(string)
- totals, _ := strconv.ParseInt(total, 10, 64)
- project.Count = totals
- }
-
- if json["medical_code"] != nil && reflect.TypeOf(json["medical_code"]).String() == "string" {
- medical_code, _ := json["medical_code"].(string)
- project.MedListCodg = medical_code
- }
- if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
- single_dose, _ := json["single_dose"].(string)
- project.SingleDose = single_dose
- }
-
- if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
- delivery_way, _ := json["delivery_way"].(string)
- project.DeliveryWay = delivery_way
- }
- if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
- execution_frequency, _ := json["execution_frequency"].(string)
- project.ExecutionFrequency = execution_frequency
- }
- if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
- remark, _ := json["remark"].(string)
- project.Remark = remark
- }
- if json["number_days"] != nil && reflect.TypeOf(json["number_days"]).String() == "string" {
- day, _ := json["number_days"].(string)
- project.Day = day
- }
-
- if json["unit"] != nil && reflect.TypeOf(json["unit"]).String() == "string" {
- unit, _ := json["unit"].(string)
- project.Unit = unit
- }
- return 0
- }
-
- func (c *HisApiController) GetHisOrderList() {
- page, _ := c.GetInt64("page", -1)
- limit, _ := c.GetInt64("limit", -1)
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- types, _ := c.GetInt64("type", 0)
- keywords := c.GetString("keywords")
- p_type, _ := c.GetInt64("p_type", 0)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
-
- adminUser := c.GetAdminUserInfo()
- org_id := adminUser.CurrentOrgId
- order, err, total := service.GetHisOrderList(org_id, page, limit, startTime, endTime, types, keywords, p_type)
-
- for _, item := range order {
- info, _ := service.GetHisPrescriptionByPatientID(item.PatientId, item.UserOrgId)
- item.DoctorName = info.Doctor
- item.DepartmentName = info.XtHisDepartment.Name
- }
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "order": order,
- "total": total,
- })
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- func (c *HisApiController) GetHisOrder() {
- patient_id, _ := c.GetInt64("patient_id", 0)
- number := c.GetString("number")
- adminInfo := c.GetAdminUserInfo()
- order, err := service.GetHisOrder(adminInfo.CurrentOrgId, number, patient_id)
- prescriptions, _ := service.GetHisPrescriptionThree(adminInfo.CurrentOrgId, patient_id, order.Number)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "order": order,
- "prescription": prescriptions,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- }
-
- func (c *HisApiController) GetHisPrescriptionList() {
- record_date := c.GetString("record_date")
- keywords := c.GetString("keywords")
- page, _ := c.GetInt64("page")
- limit, _ := c.GetInt64("limit")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminInfo := c.GetAdminUserInfo()
- prescriptionOrder, err, total := service.GetNewHisPatientPrescriptionList(adminInfo.CurrentOrgId, keywords, recordDateTime, page, limit)
-
- //adminInfo := c.GetAdminUserInfo()
- //prescriptionOrder, err := service.GetHisPrescriptionOrderList(adminInfo.CurrentOrgId)
- //fmt.Println(prescriptionOrder)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "order": prescriptionOrder,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- func (c *HisApiController) GetHisPrescriptionInfo() {
- id, _ := c.GetInt64("id")
- adminInfo := c.GetAdminUserInfo()
- prescriptionOrder, err := service.GetHisPrescriptionOrderInfo(id, adminInfo.CurrentOrgId)
- prescription, err := service.GetHisPrescriptionFour(adminInfo.CurrentOrgId, prescriptionOrder.PatientId, prescriptionOrder.RecordDate, prescriptionOrder.PrescriptionNumber)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "order": prescriptionOrder,
- "prescription": prescription,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- func (c *HisApiController) GetMedicalInsuranceConfig() {
- adminUser := c.GetAdminUserInfo()
- config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "config": config,
- })
-
- }
-
- type ResultTwo struct {
- ErrMsg interface{} `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Baseinfo struct {
- Age float64 `json:"age"`
- Brdy string `json:"brdy"`
- Certno string `json:"certno"`
- Gend string `json:"gend"`
- Naty string `json:"naty"`
- PsnCertType string `json:"psn_cert_type"`
- PsnName string `json:"psn_name"`
- PsnNo string `json:"psn_no"`
- } `json:"baseinfo"`
- Idetinfo []interface{} `json:"idetinfo"`
- Iinfo []struct {
- Balc float64 `json:"balc"`
- CvlservFlag string `json:"cvlserv_flag"`
- EmpName string `json:"emp_name"`
- InsuplcAdmdvs string `json:"insuplc_admdvs"`
- Insutype string `json:"insutype"`
- PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
- PausInsuDate interface{} `json:"paus_insu_date"`
- PsnInsuDate string `json:"psn_insu_date"`
- PsnInsuStas string `json:"psn_insu_stas"`
- PsnType string `json:"psn_type"`
- } `json:"insuinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnInfo interface{} `json:"warn_info"`
- }
- type ResultThree struct {
- Cainfo interface{} `json:"cainfo"`
- ErrMsg interface{} `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Data struct {
- IptOtpNo string `json:"ipt_otp_no"`
- MdtrtID string `json:"mdtrt_id"`
- PsnNo string `json:"psn_no"`
- } `json:"data"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
- type ResultFour struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Result []struct {
- BasMednFlag string `json:"bas_medn_flag"`
- ChldMedcFlag string `json:"chld_medc_flag"`
- ChrgitmLv string `json:"chrgitm_lv"`
- Cnt float64 `json:"cnt"`
- DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
- DrtReimFlag string `json:"drt_reim_flag"`
- FeedetlSn string `json:"feedetl_sn"`
- FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
- HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
- InscpScpAmt float64 `json:"inscp_scp_amt"`
- ListSpItemFlag string `json:"list_sp_item_flag"`
- LmtUsedFlag string `json:"lmt_used_flag"`
- MedChrgitmType string `json:"med_chrgitm_type"`
- Memo string `json:"memo"`
- OverlmtAmt float64 `json:"overlmt_amt"`
- PreselfpayAmt float64 `json:"preselfpay_amt"`
- Pric float64 `json:"pric"`
- PricUplmtAmt float64 `json:"pric_uplmt_amt"`
- SelfpayProp float64 `json:"selfpay_prop"`
- } `json:"result"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype string `json:"signtype"`
- WarnMsg string `json:"warn_msg"`
- }
- type ResultFive struct {
- Insutype string `json:"insutype"`
- }
- type ResultSix struct {
- Cainfo interface{} `json:"cainfo"`
- ErrMsg interface{} `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
- type ResultSeven struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Setldetail []interface{} `json:"setldetail"`
- Setlinfo struct {
- AcctMulaidPay float64 `json:"acct_mulaid_pay"`
- AcctPay float64 `json:"acct_pay"`
- ActPayDedc float64 `json:"act_pay_dedc"`
- Age float64 `json:"age"`
- Balc float64 `json:"balc"`
- Brdy string `json:"brdy"`
- Certno string `json:"certno"`
- ClrOptins string `json:"clr_optins"`
- ClrType string `json:"clr_type"`
- ClrWay string `json:"clr_way"`
- CvlservFlag string `json:"cvlserv_flag"`
- CvlservPay float64 `json:"cvlserv_pay"`
- FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
- FundPaySumamt float64 `json:"fund_pay_sumamt"`
- Gend string `json:"gend"`
- HifesPay float64 `json:"hifes_pay"`
- HifmiPay float64 `json:"hifmi_pay"`
- HifobPay float64 `json:"hifob_pay"`
- HifpPay float64 `json:"hifp_pay"`
- HospPartAmt float64 `json:"hosp_part_amt"`
- InscpScpAmt float64 `json:"inscp_scp_amt"`
- Insutype string `json:"insutype"`
- MafPay float64 `json:"maf_pay"`
- MdtrtCertType string `json:"mdtrt_cert_type"`
- MdtrtID string `json:"mdtrt_id"`
- MedType string `json:"med_type"`
- MedfeeSumamt float64 `json:"medfee_sumamt"`
- MedinsSetlID string `json:"medins_setl_id"`
- Naty string `json:"naty"`
- OthPay float64 `json:"oth_pay"`
- OverlmtSelfpay float64 `json:"overlmt_selfpay"`
- PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
- PreselfpayAmt float64 `json:"preselfpay_amt"`
- PsnCashPay float64 `json:"psn_cash_pay"`
- PsnCertType string `json:"psn_cert_type"`
- PsnName string `json:"psn_name"`
- PsnNo string `json:"psn_no"`
- PsnPartAmt float64 `json:"psn_part_amt"`
- PsnType string `json:"psn_type"`
- SetlID string `json:"setl_id"`
- SetlTime string `json:"setl_time"`
- } `json:"setlinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
-
- type ResultEight struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Stmtinfo struct {
- SetlOptins string `json:"setl_optins"`
- StmtRslt string `json:"stmt_rslt"`
- StmtRsltDscr string `json:"stmt_rslt_dscr"`
- } `json:"stmtinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
-
- type ResultNine struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- FileQuryNo string `json:"file_qury_no"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
-
- type ResultTen struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- DldEndtime string `json:"dld_endtime"`
- FileQuryNo string `json:"file_qury_no"`
- Filename string `json:"filename"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
-
- type ResultEleven struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Setlinfo struct {
- FixmedinsName string `json:"fixmedins_name"`
- FixmedinsCode string `json:"fixmedins_code"`
- PsnNo string `json:"psn_no"`
- PsnName string `json:"psn_name"`
- HifobPay float64 `json:"hifob_pay"`
- Gend string `json:"gend"`
- Brdy string `json:"brdy"`
- PsnCertType string `json:"psn_cert_type"`
- PsnType string `json:"psn_type"`
- EmpName string `json:"emp_name"`
- Certno string `json:"certno"`
- Insutype string `json:"insutype"`
- MedfeeSumamt float64 `json:"medfee_sumamt"`
- FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
- OverlmtSelfpay float64 `json:"overlmt_selfpay"`
- PreselfpayAmt float64 `json:"preselfpay_amt"`
- InscpScpAmt float64 `json:"inscp_scp_amt"`
- ActPayDedc float64 `json:"act_pay_dedc"`
- HifpPay float64 `json:"hifp_pay"`
- PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
- CvlservPay float64 `json:"cvlserv_pay"`
- HifesPay float64 `json:"hifes_pay"`
- HifmiPay float64 `json:"hifmi_pay"`
- MafPay float64 `json:"maf_pay"`
- OthPay float64 `json:"oth_pay"`
- FundPaySumamt float64 `json:"fund_pay_sumamt"`
- PsnPay float64 `json:"psn_pay"`
- AcctPay float64 `json:"acct_pay"`
- CashPayamt float64 `json:"cash_payamt"`
- Balc float64 `json:"balc"`
- AcctMulaidPay float64 `json:"acct_mulaid_pay"`
- MedinsSetlId string `json:"medins_setl_id"`
- RefdSetlFlag string `json:"refd_setl_flag"`
- SetlTime string `json:"setl_time"`
- MedType string `json:"med_type"`
- } `json:"setlinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
-
- type Custom struct {
- DetItemFeeSumamt string
- Cut string
- FeedetlSn string
- Price string
- MedListCodg string
- Type int64
- AdviceId int64
- ProjectId int64
- ItemId int64
- }
-
- //获取个人信息----挂号-----上传就诊信息
- func (c *HisApiController) GetRegisterInfo() {
- id, _ := c.GetInt64("id")
- record_time := c.GetString("record_time")
- settlementValue, _ := c.GetInt64("settlement_value")
- medical_insurance_card := c.GetString("medical_insurance_card")
- name := c.GetString("name")
- id_card_type, _ := c.GetInt64("id_card_type")
- certificates, _ := c.GetInt64("certificates")
- medical_care, _ := c.GetInt64("medical_care")
- birthday := c.GetString("birthday")
- age, _ := c.GetInt64("age")
- id_card := c.GetString("id_card")
- register_type, _ := c.GetInt64("register")
- doctor, _ := c.GetInt64("doctor")
- department, _ := c.GetInt64("department")
- gender, _ := c.GetInt64("sex")
- phone := c.GetString("phone")
- registration_fee, _ := c.GetFloat("registration_fee")
- medical_expenses, _ := c.GetFloat("medical_expenses")
- social_type, _ := c.GetInt64("social_type")
-
- //diagnosis_id, _ := c.GetInt64("diagnosis")
-
- diagnosis_ids := c.GetString("diagnosis")
-
- sick_type, _ := c.GetInt64("sick_type")
- reg_type := c.GetString("p_type")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
- birthUnix := birthdays.Unix()
-
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
-
- adminInfo := c.GetAdminUserInfo()
- tempPatient, _ := service.GetPatientByIDCardAndName(id_card, adminInfo.CurrentOrgId, name)
- if tempPatient.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoBloodPatientException)
- return
- }
- var patient service.Patients
- if id == 0 {
- patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
-
- } else {
- patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
-
- }
-
- if patient.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- if len(patient.IdCardNo) == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
- return
- }
-
- his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
- if len(his) >= 1 {
- order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
- if len(his) >= 1 && order.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
- return
- }
- }
-
- timeStr := time.Now().Format("2006-01-02 15:04:05")
- fmt.Println(timeStr)
- timeArr := strings.Split(timeStr, " ")
- fmt.Println(timeArr)
-
- timeArrTwo := strings.Split(timeArr[0], "-")
- timeArrThree := strings.Split(timeArr[1], ":")
- var str = timeArrTwo[0] + timeArrTwo[1] + timeArrTwo[2] + timeArrThree[0] + timeArrThree[1] + timeArrThree[2] + strconv.FormatInt(patient.ID, 10)
-
- lists, _ := service.GetHisPatientInfoList(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
-
- if len(lists) == 0 {
- var hisPatient models.XtHisPatient
- hisPatient = models.XtHisPatient{
- Name: name,
- Age: age,
- Gender: gender,
- Birthday: birthUnix,
- Phone: phone,
- MedicalTreatmentType: medical_care,
- IdType: certificates,
- IdCardNo: id_card,
- BalanceAccountsType: settlementValue,
- SocialType: social_type,
- MedicalInsuranceNumber: medical_insurance_card,
- RegisterType: register_type,
- RegisterCost: registration_fee,
- TreatmentCost: medical_expenses,
- AdminUserId: adminInfo.AdminUser.Id,
- UserOrgId: adminInfo.CurrentOrgId,
- Status: 1,
- RecordDate: recordDateTime,
- IsReturn: 1,
- PatientId: patient.ID,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Number: str,
- IdCardType: id_card_type,
- Departments: department,
- Doctor: doctor,
- PType: reg_type,
- Diagnosis: diagnosis_ids,
- SickType: sick_type,
- }
- service.CreateHisPatient(&hisPatient)
-
- service.UpdateHisPrescriptionHisID(hisPatient.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "his_info": hisPatient,
- })
- } else {
- //chrgBchno := rand.Intn(1000000) + 10000
- var hisPatient models.XtHisPatient
- hisPatient = models.XtHisPatient{
- Name: name,
- Age: age,
- Gender: gender,
- Birthday: birthUnix,
- Phone: phone,
- MedicalTreatmentType: medical_care,
- IdType: certificates,
- IdCardNo: id_card,
- BalanceAccountsType: settlementValue,
- SocialType: social_type,
- MedicalInsuranceNumber: medical_insurance_card,
- RegisterType: register_type,
- RegisterCost: registration_fee,
- TreatmentCost: medical_expenses,
- AdminUserId: adminInfo.AdminUser.Id,
- UserOrgId: adminInfo.CurrentOrgId,
- Status: 1,
- RecordDate: recordDateTime,
- IsReturn: 1,
- PatientId: patient.ID,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Number: str,
- IdCardType: id_card_type,
- Departments: department,
- Doctor: doctor,
- PType: reg_type,
- Diagnosis: diagnosis_ids,
- SickType: sick_type,
- }
- service.CreateHisPatient(&hisPatient)
-
- service.UpdateHisPrescriptionHisID(hisPatient.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "his_info": hisPatient,
- })
-
- }
-
- }
-
- //上传明细----结算
- func (c *HisApiController) GetUploadInfo() {
- id, _ := c.GetInt64("id")
- record_time := c.GetString("record_time")
- his_patient_id, _ := c.GetInt64("his_patient_id")
-
- pay_way, _ := c.GetInt64("pay_way")
- pay_price, _ := c.GetFloat("pay_price")
- pay_card_no := c.GetString("pay_card_no")
- discount_price, _ := c.GetFloat("discount_price")
- preferential_price, _ := c.GetFloat("preferential_price")
- reality_price, _ := c.GetFloat("reality_price")
- found_price, _ := c.GetFloat("found_price")
- medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
- private_price, _ := c.GetFloat("private_price")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
-
- fapiao_code := c.GetString("fapiao_code")
- fapiao_number := c.GetString("fapiao_number")
-
- diagnosis_id := c.GetString("diagnosis")
- sick_type, _ := c.GetInt64("sick_type")
- reg_type, _ := c.GetInt64("p_type")
- order_id, _ := c.GetInt64("order_id")
-
- his, _ := service.GetHisPatientByIdThree(his_patient_id)
-
- tempOrder, _ := service.GetHisOrderByID(order_id)
-
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminUser := c.GetAdminUserInfo()
- var prescriptions []*models.HisPrescription
- var start_time int64
- var end_time int64
-
- ids_str := c.GetString("ids")
- ids_arr := strings.Split(ids_str, ",")
- if tempOrder.ID == 0 {
- if settle_accounts_type == 1 { //日结
- fmt.Println(reg_type)
- if reg_type == 11 {
- fmt.Println(reg_type)
- prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
- } else {
- prescriptions, _ = service.GetSettleHisPrescription(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type)
- }
- } else { //月结
- start_time_str := c.GetString("start_time")
- end_time_str := c.GetString("end_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordStartTime := theStartTime.Unix()
- start_time = recordStartTime
- theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordEndTime := theEndTime.Unix()
- end_time = recordEndTime
- prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
- }
-
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- timeFormat := tempTime.Format("20060102150405")
- chrgBchno := rand.Intn(100000) + 10000
- chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
- strconv.FormatInt(his.PatientId, 10)
-
- var ids []int64
- fmt.Println(prescriptions)
- for _, item := range prescriptions {
- ids = append(ids, item.ID)
- }
- var total float64
- fmt.Println(prescriptions)
- for _, item := range prescriptions {
- fmt.Println(item)
- if item.Type == 1 { //药品
- for _, subItem := range item.HisDoctorAdviceInfo {
- total = total + (subItem.Price * subItem.PrescribingNumber)
- }
- }
- if item.Type == 2 { //项目
- for _, subItem := range item.HisPrescriptionProject {
- total = total + (subItem.Price * float64(subItem.Count))
- }
- }
-
- for _, subItem := range item.HisAdditionalCharge {
- total = total + (subItem.Price * float64(subItem.Count))
- }
- }
-
- allTotal := fmt.Sprintf("%.2f", total)
- totals, _ := strconv.ParseFloat(allTotal, 64)
- order := &models.HisOrder{
- UserOrgId: adminUser.CurrentOrgId,
- HisPatientId: his.ID,
- PatientId: id,
- SettleAccountsDate: recordDateTime,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Status: 1,
- OrderStatus: 2,
- MdtrtId: his.Number,
- Number: chrg_bchno,
- MedfeeSumamt: totals,
- PayWay: pay_way,
- PayPrice: pay_price,
- MedType: strconv.Itoa(int(reg_type)),
- PayCardNo: pay_card_no,
- DiscountPrice: discount_price,
- PreferentialPrice: preferential_price,
- RealityPrice: reality_price,
- FoundPrice: found_price,
- MedicalInsurancePrice: medical_insurance_price,
- PrivatePrice: private_price,
- SettleEndTime: end_time,
- SettleStartTime: start_time,
- SettleType: settle_accounts_type,
- FaPiaoCode: fapiao_code,
- FaPiaoNumber: fapiao_number,
- Diagnosis: diagnosis_id,
- PType: 2,
- }
- err = service.CreateOrder(order)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
- return
- }
-
- var customs []*Custom
- for _, item := range prescriptions {
- if item.Type == 1 { //药品
- for _, subItem := range item.HisDoctorAdviceInfo {
- cus := &Custom{
- AdviceId: subItem.ID,
- ProjectId: 0,
- DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
- Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.2f", subItem.Price),
- MedListCodg: subItem.MedListCodg,
- Type: 1,
- }
- customs = append(customs, cus)
- }
- }
- if item.Type == 2 { //项目
- for _, subItem := range item.HisPrescriptionProject {
- cus := &Custom{
- AdviceId: 0,
- ProjectId: subItem.ID,
- DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
- Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
- MedListCodg: subItem.MedListCodg,
- Type: 2,
- }
- customs = append(customs, cus)
- }
- }
- for _, item := range item.HisAdditionalCharge {
- cus := &Custom{
- ItemId: item.ID,
- AdviceId: 0,
- ProjectId: 0,
- DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
- Cut: fmt.Sprintf("%.2f", float64(item.Count)),
- FeedetlSn: item.FeedetlSn,
- Price: fmt.Sprintf("%.2f", float64(item.Price)),
- MedListCodg: item.XtHisAddtionConfig.Code,
- Type: 3,
- }
- customs = append(customs, cus)
- }
- }
- for _, item := range customs {
- var advice_id int64 = 0
- var project_id int64 = 0
- var item_id int64 = 0
-
- var types int64 = 0
-
- if item.Type == 1 {
- advice_id = item.AdviceId
- project_id = 0
- item_id = 0
- } else if item.Type == 2 {
- advice_id = 0
- item_id = 0
-
- project_id = item.ProjectId
- } else if item.Type == 3 {
- advice_id = 0
- item_id = item.ItemId
- project_id = 0
- }
- detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
- cut, _ := strconv.ParseFloat(item.Cut, 32)
- pric, _ := strconv.ParseFloat(item.Price, 32)
- info := &models.HisOrderInfo{
- OrderNumber: order.Number,
- UploadDate: time.Now().Unix(),
- AdviceId: advice_id,
- DetItemFeeSumamt: detItemFeeSumamt,
- Cnt: cut,
- Pric: pric,
- PatientId: id,
- Status: 1,
- Mtime: time.Now().Unix(),
- Ctime: time.Now().Unix(),
- UserOrgId: adminUser.CurrentOrgId,
- HisPatientId: his.ID,
- OrderId: order.ID,
- ProjectId: project_id,
- Type: types,
- ItemId: item_id,
- }
- service.CreateOrderInfo(info)
- }
- his.Diagnosis = diagnosis_id
- his.SickType = sick_type
- his.RegisterType = reg_type
- his.MedicalTreatmentType = reg_type
- service.UpdataHisPateint(&his)
- err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
- err = service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime, his_patient_id)
- err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "结算成功",
- })
- }
- } else {
- if tempOrder.IsPre > 0 {
- allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
- totals, _ := strconv.ParseFloat(allTotal, 64)
- tempOrder.OrderStatus = 2
- tempOrder.PayWay = pay_way
- tempOrder.PayPrice = pay_price
- tempOrder.PayCardNo = pay_card_no
- tempOrder.DiscountPrice = discount_price
- tempOrder.PreferentialPrice = preferential_price
- tempOrder.RealityPrice = reality_price
- tempOrder.FoundPrice = found_price
- tempOrder.MedicalInsurancePrice = medical_insurance_price
- tempOrder.PrivatePrice = private_price
- tempOrder.FaPiaoCode = fapiao_code
- tempOrder.FaPiaoNumber = fapiao_number
- tempOrder.PType = 2
- tempOrder.MedfeeSumamt = totals
- tempOrder.Diagnosis = diagnosis_id
- err = service.SaveHisOrder(&tempOrder)
- err = service.UpdataOrderStatusTwo(tempOrder.Number, adminUser.CurrentOrgId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
- return
- }
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "结算成功",
- })
- }
- }
- }
- }
-
- //退款
- func (c *HisApiController) Refund() {
- order_id, _ := c.GetInt64("order_id")
- order, _ := service.GetHisOrderByID(order_id)
- adminUser := c.GetAdminUserInfo()
- err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "退费成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- func (c *HisApiController) RefundNumber() {
- his_patient_id, _ := c.GetInt64("id")
- info, _ := service.GetNewHisPatientInfo(his_patient_id)
- info.Status = 0
- count, _ := service.GetOrderCountByNumber(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.RecordDate, info.Number)
- if count > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrongTwo)
- return
- }
-
- err := service.SaveHisPatient(info)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "退号成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- }
-
- func (this *HisApiController) AdditionalCharge() {
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- fmt.Println(err)
- his_patient_id := int64(dataBody["his_patient_id"].(float64))
- patient_id := int64(dataBody["patient_id"].(float64))
- medicineData, _ := dataBody["medicineData"].([]interface{})
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- admin_user_id := adminUserInfo.AdminUser.Id
- timeStr := time.Now().Format("2006-01-02")
- timeLayout := "2006-01-02 15:04:05"
- timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
- timenow := timeStringToTime.Unix()
- var additionalCharges []*models.HisAdditionalCharge
- for _, item := range medicineData {
-
- var randNum int
- randNum = rand.Intn(10000) + 1000
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- timeFormat := tempTime.Format("20060102150405")
- p_number := timeFormat + strconv.FormatInt(int64(randNum), 10) + strconv.FormatInt(int64(adminUserInfo.CurrentOrgId), 10) + strconv.FormatInt(int64(patient_id), 10)
-
- items := item.(map[string]interface{})
- money := items["price"].(string)
- item_id_str := items["item_id"].(string)
- name := items["name"].(string)
- id_str := items["id"].(string)
- moneys, _ := strconv.ParseInt(money, 10, 64)
- monStr := strconv.FormatInt(moneys, 10)
- monneyStr, _ := strconv.ParseFloat(monStr, 64)
- item_id, _ := strconv.ParseInt(item_id_str, 10, 64)
- id, _ := strconv.ParseInt(id_str, 10, 64)
- additionalCharge := &models.HisAdditionalCharge{
- ID: id,
- HisPatientId: his_patient_id,
- UserOrgId: orgId,
- PatientId: patient_id,
- RecordDate: timenow,
- Price: monneyStr,
- Status: 1,
- ItemName: name,
- ItemId: item_id,
- AdminUserId: admin_user_id,
- CreatedTime: time.Now().Unix(),
- OrderStatus: 0,
- PrescriptionNumber: "",
- BatchNumber: "",
- FeedetlSn: p_number,
- }
- service.CreateAdditionalCharge(additionalCharge)
-
- additionalCharges = append(additionalCharges, additionalCharge)
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "添加成功",
- "additional_charges": additionalCharges,
- })
- }
-
- func (this *HisApiController) DeleteAddition() {
- id, _ := this.GetInt64("id")
- //TODO 需要判断是否已经结算
- err := service.DelelteAddition(id, this.GetAdminUserInfo().CurrentOrgId)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "删除成功",
- })
- return
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- }
-
- func (this *HisApiController) GetAdminUsers() {
- adminUser := this.GetAdminUserInfo()
- doctors, _ := service.GetAllHisDoctor(adminUser.CurrentOrgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "doctors": doctors,
- })
- }
-
- func (this *HisApiController) GetLastOrNextHisPrescription() {
- change_type, _ := this.GetInt64("type", 0)
- record_date := this.GetString("record_time")
- patient_id, _ := this.GetInt64("patient_id", 0)
- p_type, _ := this.GetInt64("p_type", 0)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theAdviceRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
- record_time := theAdviceRecordTime.Unix()
- adminUserInfo := this.GetAdminUserInfo()
- prescriptions, err := service.GetHisPrescriptionByType(change_type, record_time, adminUserInfo.CurrentOrgId, patient_id, p_type)
- if err == nil {
- if len(prescriptions) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceEmpty)
- return
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "prescriptions": prescriptions,
- })
- return
- }
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *HisApiController) GetCallHisPrescription() {
- patient_id, _ := this.GetInt64("patient_id", 0)
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("start_time")
- startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- end_time := this.GetString("end_time")
- p_type, _ := this.GetInt64("p_type")
-
- endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- adminUserInfo := this.GetAdminUserInfo()
- prescriptions, err := service.GetCallHisPrescriptions(startime.Unix(), endtime.Unix(), adminUserInfo.CurrentOrgId, patient_id, p_type)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "prescriptions": prescriptions,
- })
- return
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *HisApiController) GetHisDayPrescription() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("start_time")
- patient_id, _ := this.GetInt64("patient_id", 0)
- startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- end_time := this.GetString("end_time")
- p_type, _ := this.GetInt64("p_type")
-
- order_status, _ := this.GetInt64("type")
-
- endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- adminUserInfo := this.GetAdminUserInfo()
-
- var dayHisPrescription []*models.HisPrescription
- var err error
- if order_status == 1 || order_status == 0 {
-
- dayHisPrescription, err = service.GetUnChargeMonthHisPrescriptionSix(adminUserInfo.CurrentOrgId, patient_id, startime.Unix(), endtime.Unix(), p_type)
-
- } else if order_status == 2 {
- dayHisPrescription, err = service.GetChargeMonthHisPrescriptionSix(adminUserInfo.CurrentOrgId, patient_id, startime.Unix(), endtime.Unix(), p_type)
-
- }
-
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "day_prescription": dayHisPrescription,
- })
- return
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *HisApiController) GetHisChargePatientList() {
- record_date := c.GetString("record_date")
- order_status, _ := c.GetInt64("type")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminInfo := c.GetAdminUserInfo()
- var tempPatients []*service.NewTempPatients
- //tempPatients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
- if order_status != 2 {
- tempPatients, _ = service.GetNewAllUnChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
- } else {
- tempPatients, _ = service.GetNewAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
- }
-
- var patients []*service.NewTempPatients
- var patients_two []*service.NewTempPatients
-
- for _, item := range tempPatients {
- //过滤掉没挂号的和没开处方的
- if len(item.HisPatient) > 0 || len(item.HisPrescription) > 0 {
- patients = append(patients, item)
- }
-
- //过滤掉没挂号的
- if len(item.HisPatient) > 0 {
- patients_two = append(patients_two, item)
- }
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "list": patients,
- "list_two": patients_two,
- })
- }
-
- func (c *HisApiController) GetHisUnRegisterPatientList() {
- record_date := c.GetString("record_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminUser := c.GetAdminUserInfo()
-
- tempPatients, _ := service.GetHisPatientList(adminUser.CurrentOrgId, "", recordDateTime)
-
- var patients []*service.Patients
- for _, item := range tempPatients {
- if item.HisPatient.ID == 0 {
- patients = append(patients, item)
- }
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "list": patients,
- //"list_two": patients_two,
- })
-
- }
-
- func RemoveRepeatedPatient(patient []*service.Patients) (newArr []*service.Patients) {
- newArr = make([]*service.Patients, 0)
- for i := 0; i < len(patient); i++ {
- repeat := false
- for j := i + 1; j < len(patient); j++ {
- if patient[i].ID == patient[j].ID {
- repeat = true
- break
- }
- }
- if !repeat {
- newArr = append(newArr, patient[i])
- }
- }
- return
- }
-
- func (c *HisApiController) GetHisChargePatientInfo() {
- patient_id, _ := c.GetInt64("patient_id")
- his_patient_id, _ := c.GetInt64("his_patient_id")
- record_date := c.GetString("record_date")
- //start_time := c.GetString("start_time")
- //end_time := c.GetString("end_time")
- order_status, _ := c.GetInt64("type", 0)
- p_type, _ := c.GetInt64("p_type", 0)
- order_id, _ := c.GetInt64("order_id", 0)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
-
- //startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- //if err != nil {
- //
- //}
- //startRecordDateTime := startTime.Unix()
- //
- //endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- //if err != nil {
- //
- //}
- //endRecordDateTime := endTime.Unix()
-
- admin := c.GetAdminUserInfo()
- his_patient_info, _ := service.GetNewHisPatientInfo(his_patient_id)
- xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
-
- var prescriptions []*models.HisPrescription
-
- order, _ := service.GetHisOrderByID(order_id)
-
- if order_status == 1 || order_status == 0 {
- prescriptions, _ = service.GetUnChargeHisPrescriptionFive(admin.CurrentOrgId, patient_id, his_patient_id, recordDateTime, p_type)
- } else if order_status == 2 {
- prescriptions, _ = service.GetChargeHisPrescriptionSeven(admin.CurrentOrgId, patient_id, order.Number, p_type)
- }
-
- //var monthPrescriptions []*models.HisPrescription
- //if order_status == 1 || order_status == 0 {
- // monthPrescriptions, _ = service.GetUnChargeMonthHisPrescriptionThree(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
- //} else if order_status == 2 {
- // monthPrescriptions, _ = service.GetChargeMonthHisPrescriptionFive(admin.CurrentOrgId, patient_id, order.Number, p_type)
- //}
-
- case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
- patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
-
- lastPatientPrescriptionInfo, _ := service.FindLastPatientPrescriptionInfoTwo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
-
- doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
- //获取所有科室信息
- department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "his_info": his_patient_info,
- "xt_info": xt_patient_info,
- "prescription": prescriptions,
- "case_history": case_history,
- "info": patientPrescriptionInfo,
- "last_info": lastPatientPrescriptionInfo,
- //"month_prescriptions": monthPrescriptions,
- "order": order,
- "doctors": doctors,
- "department": department,
- })
- return
-
- }
-
- func (c *HisApiController) GetAllOrderDetail() {
- order_id, _ := c.GetInt64("id", 0)
- order, _ := service.GetHisOrderByID(order_id)
- if order.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
- return
- }
- org_id := c.GetAdminUserInfo().CurrentOrgId
- adminInfo, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
- patient, _ := service.GetPatientByID(org_id, order.PatientId)
- order_info, _ := service.GetHisOrderDetailByNumber(order.Number, org_id)
- c.ServeSuccessJSON(map[string]interface{}{
- "order": order,
- "order_info": order_info,
- "patient": patient,
- "admin_info": adminInfo,
- })
- return
-
- }
-
- func (c *HisApiController) GetAllOrderDetailCollect() {
- order_id, _ := c.GetInt64("id", 0)
-
- order, _ := service.GetHisOrderByID(order_id)
- if order.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
- return
- }
-
- org_id := c.GetAdminUserInfo().CurrentOrgId
- adminInfo, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
- order_info, _ := service.GetHisOrderDetailByNumber(order.Number, org_id)
- patient, _ := service.GetPatientByID(org_id, order.PatientId)
-
- his, _ := service.GetHisPatientInfoThree(order.UserOrgId, order.MdtrtId)
-
- if his.BalanceAccountsType != 2 {
- c.ServeSuccessJSON(map[string]interface{}{
- "order": order,
- "order_info": order_info,
- "patient": patient,
- "admin_info": adminInfo,
- })
- } else {
-
- for _, item := range order_info {
- item.FulamtOwnpayAmt = item.DetItemFeeSumamt
- if item.HisDoctorAdviceInfo.ID > 0 && item.HisPrescriptionProject.ID == 0 { //药品
- item.MedChrgitmType = "09"
-
- }
- if item.HisPrescriptionProject.ID > 0 && item.HisDoctorAdviceInfo.ID == 0 {
- if item.HisPrescriptionProject.Type == 2 {
- switch item.HisPrescriptionProject.VMHisProject.CostClassify {
-
- case 1:
- item.MedChrgitmType = "14"
- break
- case 2:
- item.MedChrgitmType = "05"
-
- break
- case 3:
- item.MedChrgitmType = "04"
-
- break
- case 4:
- item.MedChrgitmType = "14"
-
- break
- case 5:
- item.MedChrgitmType = "08"
-
- break
- case 6:
- item.MedChrgitmType = "14"
-
- break
- case 7:
- item.MedChrgitmType = "14"
-
- break
- case 8:
- item.MedChrgitmType = "03"
- break
- case 9:
- item.MedChrgitmType = "14"
- break
- }
- } else if item.HisPrescriptionProject.Type == 3 {
- item.MedChrgitmType = "08"
- }
- }
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "order": order,
- "order_info": order_info,
- "patient": patient,
- "admin_info": adminInfo,
- })
-
- }
-
- return
- }
-
- func (c *HisApiController) GetMedicalInsuranceCostCompareList() {
- page, _ := c.GetInt64("page")
- limit, _ := c.GetInt64("limit")
- keywords := c.GetString("keywords")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- //clr_type := c.GetString("clr_type")
- insutype := c.GetString("insutype")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var theStartTIme int64
- if len(start_time) > 0 {
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- theStartTIme = theTime.Unix()
- }
- var theEndtTIme int64
- if len(end_time) > 0 {
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- theEndtTIme = theTime.Unix()
- }
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
- list, total, _ := service.GetMedicalInsuranceCostCompareList(c.GetAdminUserInfo().CurrentOrgId, page, limit, keywords, insutype, theStartTIme, theEndtTIme)
- c.ServeSuccessJSON(map[string]interface{}{
- "total": total,
- "list": list,
- })
- return
-
- }
-
- func (c *HisApiController) GetPutOnRecordList() {
- page, _ := c.GetInt64("page")
- limit, _ := c.GetInt64("limit")
- keywords := c.GetString("keywords")
- is_put_on_record, _ := c.GetInt64("is_put_on_record")
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
- list, total, _ := service.GetGdybPsnNcdsRecordList(c.GetAdminUserInfo().CurrentOrgId, page, limit, keywords, is_put_on_record)
- c.ServeSuccessJSON(map[string]interface{}{
- "total": total,
- "list": list,
- })
- return
-
- }
-
- func (c *HisApiController) GetCompareData() {
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- insutype := c.GetString("insutype")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var theStartTIme int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- theStartTIme = 0
- }
- theStartTIme = theTime.Unix()
- }
- var theEndtTIme int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- theEndtTIme = 0
- }
- theEndtTIme = theTime.Unix()
- }
- formData, err := service.GetCheckAccountFormData(theStartTIme, theEndtTIme, c.GetAdminUserInfo().CurrentOrgId, insutype)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": formData,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
-
- }
- }
-
- func (c *HisApiController) GetFaPiaoData() {
- order_id, _ := c.GetInt64("order_id")
- patient_id, _ := c.GetInt64("patient_id")
- number := c.GetString("number")
-
- adminUser := c.GetAdminUserInfo()
- order, _ := service.GetHisOrderByID(order_id)
- orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
-
- patientPrescription, _ := service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, order.SettleAccountsDate)
-
- department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
-
- his, _ := service.GetHisPatientInfoThree(adminUser.CurrentOrgId, number)
-
- //prescriptions, _ := service.GetHisPrescriptionThree(adminUser.CurrentOrgId, patient_id, order.Number)
-
- var bedCostTotal float64 = 0 //床位总费
- var bedCostSelfTotal float64 = 0 //床位自费
- var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
-
- var operationCostTotal float64 = 0 //手术费
- var operationCostSelfTotal float64 = 0 //手术费
- var operationCostPartSelfTotal float64 = 0 //手术费
-
- var otherCostTotal float64 = 0 //其他费用
- var otherCostSelfTotal float64 = 0 //其他费用
- var otherCostPartSelfTotal float64 = 0 //其他费用
-
- var materialCostTotal float64 = 0 //材料费
- var materialCostSelfTotal float64 = 0 //材料费
- var materialCostPartSelfTotal float64 = 0 //材料费
-
- var westernMedicineCostTotal float64 = 0 //西药费
- var westernMedicineCostSelfTotal float64 = 0 //西药费
- var westernMedicineCostPartSelfTotal float64 = 0 //西药费
-
- var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
- var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
- var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
-
- var checkCostTotal float64 = 0 //检查费
- var checkCostSelfTotal float64 = 0 //检查费
- var checkCostPartSelfTotal float64 = 0 //检查费
-
- var laboratoryCostTotal float64 = 0 //化验费
- var laboratoryCostSelfTotal float64 = 0 //化验费
- var laboratoryCostPartSelfTotal float64 = 0 //化验费
-
- var treatCostTotal float64 = 0 //治疗费用
- var treatCostSelfTotal float64 = 0 //治疗费用
- var treatCostPartSelfTotal float64 = 0 //治疗费用
-
- decimal.DivisionPrecision = 2
-
- if his.BalanceAccountsType == 2 {
-
- orderInfos_two, _ := service.GetHisOrderDetailByNumber(order.Number, adminUser.CurrentOrgId)
-
- for _, item := range orderInfos_two {
- item.FulamtOwnpayAmt = item.DetItemFeeSumamt
- if item.HisDoctorAdviceInfo.ID > 0 && item.HisPrescriptionProject.ID == 0 { //药品
- item.MedChrgitmType = "09"
-
- }
- if item.HisPrescriptionProject.ID > 0 && item.HisDoctorAdviceInfo.ID == 0 {
- if item.HisPrescriptionProject.Type == 2 {
- switch item.HisPrescriptionProject.VMHisProject.CostClassify {
-
- case 1:
- item.MedChrgitmType = "14"
- break
- case 2:
- item.MedChrgitmType = "05"
-
- break
- case 3:
- item.MedChrgitmType = "04"
-
- break
- case 4:
- item.MedChrgitmType = "14"
-
- break
- case 5:
- item.MedChrgitmType = "08"
-
- break
- case 6:
- item.MedChrgitmType = "14"
-
- break
- case 7:
- item.MedChrgitmType = "14"
-
- break
- case 8:
- item.MedChrgitmType = "03"
- break
- case 9:
- item.MedChrgitmType = "14"
- break
-
- }
-
- } else if item.HisPrescriptionProject.Type == 3 {
- item.MedChrgitmType = "08"
- }
- }
- }
-
- for _, item := range orderInfos_two {
- if item.MedChrgitmType == "01" { //床位费
- bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- bedCostSelfTotal = bedCostTotal
- }
-
- if item.MedChrgitmType == "03" { //检查费
- checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- checkCostSelfTotal = checkCostTotal
- }
-
- if item.MedChrgitmType == "04" { //化验费
- laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- laboratoryCostSelfTotal = laboratoryCostTotal
- }
-
- if item.MedChrgitmType == "05" { //治疗费
- treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- treatCostSelfTotal = treatCostTotal
- }
-
- if item.MedChrgitmType == "06" { //手术费
- treatCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- operationCostSelfTotal = treatCostTotal
- }
-
- if item.MedChrgitmType == "08" { //材料费
- materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- materialCostSelfTotal = materialCostTotal
- }
-
- if item.MedChrgitmType == "09" { //西药费
- westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- westernMedicineCostSelfTotal = westernMedicineCostTotal
- }
-
- if item.MedChrgitmType == "11" { //中成费
- chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- chineseTraditionalMedicineCostSelfTotal = chineseTraditionalMedicineCostTotal
- }
-
- if item.MedChrgitmType == "14" { //其他费
- otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- otherCostSelfTotal = otherCostTotal
- }
-
- }
-
- } else {
- for _, item := range orderInfos {
- if item.MedChrgitmType == "01" { //床位费
- bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
- bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
- }
-
- if item.MedChrgitmType == "03" { //检查费
- checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
- checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
- }
-
- if item.MedChrgitmType == "04" { //化验费
- laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
- laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
- }
-
- if item.MedChrgitmType == "05" { //治疗费
- treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
- treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
- }
-
- if item.MedChrgitmType == "06" { //手术费
- operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
- operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
- }
-
- if item.MedChrgitmType == "08" { //材料费
- materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
- materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
- }
-
- if item.MedChrgitmType == "09" { //西药费
- westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
- westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
- }
-
- if item.MedChrgitmType == "11" { //中成费
- chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
- chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
- }
-
- if item.MedChrgitmType == "14" { //其他费
- otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
- otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
- otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
- }
-
- }
-
- }
-
- admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "order_number": order.Number, //业务流水号
- "id_card_no": his.IdCardNo, //社会保障号
- "department_name": department.Name, //科室
- "number": his.Number, //门诊号
- "date": order.SettleEndTime, //结算日期
- "name": order.PsnName, //姓名
- "gender": order.Gend, //性别
- "psn_cash_money": order.PsnCashPay, //个人支付
- "pay_way": "门诊", //结算方式
- "medfee_sumamt": order.MedfeeSumamt, //总费用
- "admin_user_name": admin.UserName, //收款员
-
- "bedCostTotal": bedCostTotal,
- "bedCostSelfTotal": bedCostSelfTotal,
- "bedCostPartSelfTotal": bedCostPartSelfTotal,
- "operationCostTotal": operationCostTotal,
- "operationCostSelfTotal": operationCostSelfTotal,
- "operationCostPartSelfTotal": operationCostPartSelfTotal,
- "otherCostTotal": otherCostTotal,
- "otherCostSelfTotal": otherCostSelfTotal,
- "otherCostPartSelfTotal": otherCostPartSelfTotal,
- "materialCostTotal": materialCostTotal,
- "materialCostSelfTotal": materialCostSelfTotal,
- "materialCostPartSelfTotal": materialCostPartSelfTotal,
- "westernMedicineCostTotal": westernMedicineCostTotal,
- "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
- "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
- "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
- "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
- "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
- "checkCostTotal": checkCostTotal,
- "checkCostSelfTotal": checkCostSelfTotal,
- "checkCostPartSelfTotal": checkCostPartSelfTotal,
- "laboratoryCostTotal": laboratoryCostTotal,
- "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
- "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
- "treatCostTotal": treatCostTotal,
- "treatCostSelfTotal": treatCostSelfTotal,
- "treatCostPartSelfTotal": treatCostPartSelfTotal,
- })
-
- }
-
- func (this *HisApiController) GetIncomeStatisticsData() {
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- key_words := this.GetString("key_words")
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
- statistics_type, _ := this.GetInt64("statistics_type")
- admin := this.GetAdminUserInfo()
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var theStartTIme int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- theStartTIme = 0
- }
- theStartTIme = theTime.Unix()
- }
- var theEndtTIme int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- theEndtTIme = 0
- }
- theEndtTIme = theTime.Unix()
- }
-
- if statistics_type == 1 {
- list, total, _ := service.GetDayIncomeStatisticsData(admin.CurrentOrgId, key_words, theStartTIme, theEndtTIme, page, limit)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- })
- } else {
- list, total, _ := service.GetDayIncomeDetailStatisticsData(admin.CurrentOrgId, key_words, theStartTIme, theEndtTIme, page, limit)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- })
-
- }
-
- }
-
- func (c *HisApiController) PostProjectInformation() {
- adminUser := c.GetAdminUserInfo()
- orgId := adminUser.CurrentOrgId
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- return
- }
- utils.ErrorLog("%v", dataBody)
- var projectList []*models.HisProject
- var total_goods []interface{}
- tempProjects := dataBody["projects"].([]interface{})
-
- total_goods = tempProjects
- for index, projectMap := range tempProjects {
-
- projectM := projectMap.(map[string]interface{})
-
- var project models.HisProject
- if projectM["project_name"] == nil || reflect.TypeOf(projectM["project_name"]).String() != "string" {
- utils.ErrorLog("project_name")
- return
- }
-
- project_name, _ := projectM["project_name"].(string)
- if len(project_name) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 6,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+3) + "行" + "的项目名称不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- project.ProjectName = project_name
-
- prices := projectM["price"].(string)
-
- price, _ := strconv.ParseFloat(prices, 64)
- if price <= 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 6,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+3) + "行" + "的零价不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- project.Price = price
-
- if projectM["unit"] == nil || reflect.TypeOf(projectM["unit"]).String() != "string" {
- utils.ErrorLog("unit_id")
- return
- }
-
- unit := projectM["unit"].(string)
- if len(unit) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 6,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+3) + "行" + "的单位不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
- project.Unit = unit
-
- cost_classify := projectM["cost_classify"].(string)
- if len(cost_classify) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 6,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+3) + "行" + "的费用类别不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
- var costClassify = "费用类别"
- var cost_classify_id int64
-
- costClassifyConfig, _ := service.GetDrugDataConfig(0, costClassify)
-
- if len(cost_classify) != 0 {
- _, errcode := service.IsExistDicConfig(costClassifyConfig.ID, cost_classify, orgId)
- if errcode == gorm.ErrRecordNotFound {
- costConfig, _ := service.GetLastDicConfig(costClassifyConfig.ID, orgId)
- dataconfig := models.DictDataconfig{
- ParentId: costClassifyConfig.ID,
- Module: "system",
- OrgId: orgId,
- Name: cost_classify,
- FieldName: "",
- Value: costConfig.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUser.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- }
- service.CreatedDicConfig(&dataconfig)
- }
- }
-
- costClassList, _ := service.GetParentDataConfig(costClassifyConfig.ID, orgId)
-
- for _, it := range costClassList {
- if cost_classify == it.Name {
- cost_classify_id = int64(it.Value)
- }
- }
- project.CostClassify = cost_classify_id
-
- executive_section := projectM["executive_section"].(string)
- if len(executive_section) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 6,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+3) + "行" + "的费用类别不能为空或内容与系统不匹配",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- if len(executive_section) != 0 {
- //查找科室是否有内容
- _, errcodedepart := service.GetDepartMentByName(executive_section, orgId)
- if errcodedepart == gorm.ErrRecordNotFound {
- department := models.XtHisDepartment{
- Name: executive_section,
- Status: 1,
- UserOrgId: adminUser.CurrentOrgId,
- CreatedTime: time.Now().Unix(),
- }
- service.CreateDePartment(&department)
- }
- }
- var executive_section_id int64
- departMentList, _ := service.GetAllDepartMent(orgId)
- for _, it := range departMentList {
- if executive_section == it.Name {
- executive_section_id = it.ID
- }
- }
- project.ExecutiveSection = executive_section_id
-
- medical_coverage := projectM["medical_coverage"].(string)
-
- if len(medical_coverage) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 6,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.Itoa(index+3) + "行" + "的费用类别不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: time.Now().Unix(),
- }
- service.CreateExportErrLog(&err_log)
- continue
- }
-
- var medicalCoverage = "医保等级"
- var medical_coverage_id int64
-
- medicalCoverageConfig, _ := service.GetDrugDataConfig(0, medicalCoverage)
- if len(medical_coverage) != 0 {
-
- _, errormedicalcoverage := service.IsExistDicConfig(medicalCoverageConfig.ID, medical_coverage, orgId)
- if errormedicalcoverage == gorm.ErrRecordNotFound {
- medicalCoverageConfig, _ := service.GetLastDicConfig(medicalCoverageConfig.ID, orgId)
- dataconfig := models.DictDataconfig{
- ParentId: medicalCoverageConfig.ID,
- Module: "system",
- OrgId: orgId,
- Name: medical_coverage,
- FieldName: "",
- Value: medicalCoverageConfig.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUser.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- }
- service.CreatedDicConfig(&dataconfig)
- }
- }
- medicalCoverageList, _ := service.GetParentDataConfig(medicalCoverageConfig.ID, orgId)
- for _, it := range medicalCoverageList {
- if medical_coverage == it.Name {
- medical_coverage_id = int64(it.Value)
- }
- }
- project.MedicalCoverage = medical_coverage_id
-
- pinyin := projectM["pinyin"].(string)
- project.Pinyin = pinyin
-
- wubi := projectM["wubi"].(string)
-
- project.Wubi = wubi
-
- statistical_classification := projectM["statistical_classification"].(string)
-
- var statisticalClassification = "统计分类"
- var statistical_classification_id int64
- classiFication, _ := service.GetDrugDataConfig(0, statisticalClassification)
- if len(statistical_classification) != 0 {
-
- _, classificationerrcodes := service.IsExistDicConfig(classiFication.ID, statistical_classification, orgId)
-
- if classificationerrcodes == gorm.ErrRecordNotFound {
- classiFicationConfig, _ := service.GetLastDicConfig(classiFication.ID, orgId)
- dataconfig := models.DictDataconfig{
- ParentId: classiFication.ID,
- Module: "system",
- OrgId: orgId,
- Name: statistical_classification,
- FieldName: "",
- Value: classiFicationConfig.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUser.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- }
- service.CreatedDicConfig(&dataconfig)
- }
-
- }
- classiFicationList, _ := service.GetParentDataConfig(classiFication.ID, orgId)
-
- for _, it := range classiFicationList {
- if statistical_classification == it.Name {
-
- statistical_classification_id = int64(it.Value)
- }
- }
-
- project.StatisticalClassification = statistical_classification_id
-
- disease_directory := int64(projectM["disease_directory"].(float64))
- project.DiseaseDirectory = disease_directory
-
- is_record := int64(projectM["is_record"].(float64))
- project.IsRecord = is_record
-
- medical_code := projectM["medical_code"].(string)
- project.MedicalCode = medical_code
-
- tube_color := projectM["tube_color"].(string)
-
- var tubeColor = "试管颜色"
- var tube_color_id int64
- tubeColorConfig, _ := service.GetDrugDataConfig(0, tubeColor)
- if len(tube_color) != 0 {
- _, errcodetube := service.IsExistDicConfig(tubeColorConfig.ID, tube_color, orgId)
- if errcodetube == gorm.ErrRecordNotFound {
- tubeConfig, _ := service.GetLastDicConfig(tubeColorConfig.ID, orgId)
- dataconfig := models.DictDataconfig{
- ParentId: tubeColorConfig.ID,
- Module: "system",
- OrgId: orgId,
- Name: tube_color,
- FieldName: "",
- Value: tubeConfig.Value + 1,
- CreatedTime: "",
- UpdatedTime: "",
- CreateUserId: adminUser.AdminUser.Id,
- Status: 1,
- Remark: "",
- DeleteIdSystem: 0,
- Title: "",
- Content: "",
- Order: 0,
- Code: "",
- }
- service.CreatedDicConfig(&dataconfig)
- }
-
- }
-
- tubeColorList, _ := service.GetParentDataConfig(tubeColorConfig.ID, orgId)
- for _, it := range tubeColorList {
- if tube_color == it.Name {
- tube_color_id = int64(it.Value)
- }
- }
-
- project.TubeColor = tube_color_id
-
- single_dose := projectM["single_dose"].(string)
- project.SingleDose = single_dose
- execution_frequency := projectM["execution_frequency"].(string)
- project.ExecutionFrequency = execution_frequency
-
- delivery_way := projectM["delivery_way"].(string)
- project.DeliveryWay = delivery_way
-
- number_days := projectM["number_days"].(string)
- project.NumberDays = number_days
-
- total := projectM["total"].(string)
- project.Total = total
-
- medical_status := int64(projectM["medical_status"].(float64))
- project.MedicalStatus = medical_status
-
- category := int64(projectM["category"].(float64))
- project.Category = category
-
- specail_project := int64(projectM["specail_project"].(float64))
- project.SpecailProject = specail_project
-
- social_security_directory_code := projectM["social_security_directory_code"].(string)
-
- project.SocialSecurityDirectoryCode = social_security_directory_code
-
- remark := projectM["remark"].(string)
- project.Remark = remark
-
- record_date := projectM["record_date"].(string)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- project.RecordDate = theTime.Unix()
- projectList = append(projectList, &project)
- }
-
- export_time := time.Now().Unix()
-
- errLogs, _ := service.FindPatientExportLog(c.GetAdminUserInfo().CurrentOrgId, export_time)
- if len(projectList) > 0 {
- for _, item := range projectList {
- project := models.HisProject{
- ProjectName: item.ProjectName,
- Price: item.Price,
- Unit: item.Unit,
- CostClassify: item.CostClassify,
- ExecutiveSection: item.ExecutiveSection,
- MedicalCoverage: item.MedicalCoverage,
- UserOrgId: orgId,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- Pinyin: item.Pinyin,
- Wubi: item.Wubi,
- StatisticalClassification: item.StatisticalClassification,
- DiseaseDirectory: item.DiseaseDirectory,
- IsRecord: item.IsRecord,
- MedicalCode: item.MedicalCode,
- TubeColor: item.TubeColor,
- SingleDose: item.SingleDose,
- DeliveryWay: item.DeliveryWay,
- NumberDays: item.NumberDays,
- Total: item.Total,
- Category: item.Category,
- MedicalStatus: item.MedicalStatus,
- SpecailProject: item.SpecailProject,
- RecordDate: item.RecordDate,
- Remark: item.Remark,
- SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
- ExecutionFrequency: item.ExecutionFrequency,
- }
-
- _, errcodeproject := service.GetProjectByNameIsExsit(item.ProjectName, orgId)
- if errcodeproject == gorm.ErrRecordNotFound {
- service.CreateProjectInfomation(&project)
- } else if errcodeproject == nil {
- service.UpdateProjectByName(&project, item.ProjectName, orgId)
- }
-
- log := models.ExportLog{
- LogType: 6,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_goods)),
- FailNum: int64(len(errLogs)),
- SuccessNum: int64(len(projectList)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "导入成功",
- "total_num": len(total_goods),
- "success_num": len(projectList),
- "fail_num": int64(len(errLogs)),
- })
- }
- } else {
- log := models.ExportLog{
- LogType: 6,
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_goods)),
- FailNum: int64(len(errLogs)),
- SuccessNum: int64(len(projectList)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "导入成功",
- "total_num": len(total_goods),
- "success_num": len(projectList),
- "fail_num": int64(len(errLogs)),
- })
- }
- }
-
- //func (this *HisApiController) EditProjectInformation(){
- //
- // id, _ := this.GetInt64("id")
- // project_team := this.GetString("project_team")
- // price := this.GetString("price")
- // price_float, _ := strconv.ParseFloat(price, 64)
- // pinyin := this.GetString("pinyin")
- // wubi := this.GetString("wubi")
- // tube_color, _ := this.GetInt64("tube_color")
- // team_type, _ := this.GetInt64("team_type")
- // remark := this.GetString("remark")
- // ids := this.GetString("ids")
- // item_id := this.GetString("item_id")
- // projectTeam := models.XtHisProjectTeam{
- // ProjectTeam: project_team,
- // Price: price_float,
- // Pinyin: pinyin,
- // Wubi: wubi,
- // TubeColor: tube_color,
- // TeamType: team_type,
- // Remark: remark,
- // ProjectId: ids,
- // ItemId: item_id,
- // }
- //
- //
- // dataBody := make(map[string]interface{}, 0)
- // err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- // if err != nil {
- // utils.ErrorLog(err.Error())
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- // }
- //
- // err = service.UpdatedProjectTeam(id, &projectTeam)
- //
- //
- // if err != nil {
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
- // return
- // }
- //
- // if dataBody["info"] != nil && reflect.TypeOf(dataBody["info"]).String() == "[]interface {}" {
- // infos, _ := dataBody["info"].([]interface{})
- // if len(infos) > 0 {
- // var ids []string
- //
- // for _, item := range infos {
- // items := item.(map[string]interface{})
- // if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
- // utils.ErrorLog("id")
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- // }
- // id := int64(items["id"].(float64))
- //
- // if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
- // utils.ErrorLog("type")
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- // }
- // types := int64(items["type"].(float64))
- //
- // if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
- // utils.ErrorLog("number")
- // }
- //
- // number, _ := strconv.ParseInt(items["number"].(string), 10, 64)
- //
- // projectList := models.XtHisProjectList{
- // Number: number,
- // UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- // ProjectId: id,
- // Status: 1,
- // CreatedTime: time.Now().Unix(),
- // UpdatedTime: time.Now().Unix(),
- // TeamId: projectTeam.ID,
- // Type: types,
- // }
- // list := projectList
- //
- // service.CreateProjectList(&list)
- //
- // ids = append(ids, strconv.FormatInt(list.ID, 10))
- //
- // }
- // ids_str := strings.Join(ids, ",")
- // projectTeam.ProjectId = projectTeam.ProjectId+"," + ids_str
- // service.SaveProjectTeam(&projectTeam)
- // this.ServeSuccessJSON(map[string]interface{}{
- // "projectTeam": projectTeam,
- // })
- // }
- // }
- //}
-
- func (c *HisApiController) CreateHisPrescriptionTemplate() {
- name := c.GetString("name")
- mode_id, _ := c.GetInt64("mode", 0)
- types, _ := c.GetInt64("type", 0)
- patient_id, _ := c.GetInt64("patient_id", 0)
- types = 1
- adminInfo := c.GetAdminUserInfo()
- template := &models.HisPrescriptionTemplate{
- UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- PatientId: patient_id,
- Type: types,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Name: name,
- Mode: mode_id,
- }
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- err = service.CreateHisPrescriptionTemplate(template)
- if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
- prescriptions, _ := dataBody["prescriptions"].([]interface{})
- if len(prescriptions) > 0 {
- for _, item := range prescriptions {
- items := item.(map[string]interface{})
- if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
- utils.ErrorLog("type")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- types := int64(items["type"].(float64))
-
- if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
- utils.ErrorLog("med_type")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- med_type := strconv.Itoa(int(items["med_type"].(float64)))
-
- ctime := time.Now().Unix()
- prescription := &models.HisPrescriptionInfoTemplate{
- PatientId: patient_id,
- UserOrgId: adminInfo.CurrentOrgId,
- Ctime: ctime,
- Mtime: ctime,
- Type: types,
- Modifier: adminInfo.AdminUser.Id,
- Creator: adminInfo.AdminUser.Id,
- Status: 1,
- PTemplateId: template.ID,
- MedType: med_type,
- }
- service.CreateHisPrescriptionInfoTemplate(prescription)
-
- if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
- advices := items["advices"].([]interface{})
- //group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
- groupNo := int64(0)
- ctime := time.Now().Unix()
- mtime := ctime
- if len(advices) > 0 {
- for _, advice := range advices {
- var s models.HisPrescriptionAdviceTemplate
- s.PrescriptionId = prescription.ID
- s.AdviceType = 2
- s.StopState = 2
- s.ExecutionState = 2
- s.Status = 1
- s.UserOrgId = adminInfo.CurrentOrgId
- s.Groupno = groupNo
- s.CreatedTime = ctime
- s.UpdatedTime = mtime
- s.PatientId = patient_id
- errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
- if errcode > 0 {
- c.ServeFailJSONWithSGJErrorCode(errcode)
- return
- }
-
- service.CreateHisPrescriptionAdviceTemplate(&s)
-
- }
- }
- }
- if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
- projects := items["project"].([]interface{})
- if len(projects) > 0 {
- for _, project := range projects {
- var p models.HisPrescriptionProjectTemplate
- p.PrescriptionId = prescription.ID
- p.Ctime = time.Now().Unix()
- p.Mtime = time.Now().Unix()
- p.PatientId = patient_id
- p.UserOrgId = adminInfo.CurrentOrgId
- p.Status = 1
- errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
- if errcode > 0 {
- c.ServeFailJSONWithSGJErrorCode(errcode)
- return
- }
- service.CreateHisPrescriptionProjectTemplate(&p)
-
- }
- }
- }
-
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "创建成功",
- })
- }
- }
-
- }
-
- func (c *HisApiController) PreSettle() {
- id, _ := c.GetInt64("id")
- record_time := c.GetString("record_time")
- his_patient_id, _ := c.GetInt64("his_patient_id")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
- diagnosis_id := c.GetString("diagnosis")
- sick_type, _ := c.GetInt64("sick_type")
- reg_type, _ := c.GetInt64("p_type")
-
- his, _ := service.GetHisPatientByIdThree(his_patient_id)
-
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminUser := c.GetAdminUserInfo()
- var prescriptions []*models.HisPrescription
- var start_time int64
- var end_time int64
-
- ids_str := c.GetString("ids")
- ids_arr := strings.Split(ids_str, ",")
-
- fmt.Println(reg_type)
-
- if settle_accounts_type == 1 { //日结
-
- if reg_type == 11 {
-
- prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
- } else {
- prescriptions, _ = service.GetSettleHisPrescription(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type)
- }
-
- fmt.Println(prescriptions)
- } else { //月结
- start_time_str := c.GetString("start_time")
- end_time_str := c.GetString("end_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordStartTime := theStartTime.Unix()
- start_time = recordStartTime
- theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordEndTime := theEndTime.Unix()
- end_time = recordEndTime
- prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
- }
-
- if reg_type == 1111 || reg_type == 1112 {
- reg_type = 11
- }
-
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- timeFormat := tempTime.Format("20060102150405")
- chrgBchno := rand.Intn(100000) + 10000
- chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
- strconv.FormatInt(his.PatientId, 10)
-
- var ids []int64
-
- for _, item := range prescriptions {
- ids = append(ids, item.ID)
- }
-
- fmt.Println(ids)
-
- var total float64
- for _, item := range prescriptions {
- fmt.Println(item)
- if item.Type == 1 { //药品
- for _, subItem := range item.HisDoctorAdviceInfo {
- total = total + (subItem.Price * subItem.PrescribingNumber)
- }
- }
- if item.Type == 2 { //项目
- for _, subItem := range item.HisPrescriptionProject {
- total = total + (subItem.Price * float64(subItem.Count))
- }
- }
-
- for _, subItem := range item.HisAdditionalCharge {
- total = total + (subItem.Price * float64(subItem.Count))
- }
- }
-
- allTotal := fmt.Sprintf("%.2f", total)
- totals, _ := strconv.ParseFloat(allTotal, 64)
- order := &models.HisOrder{
- UserOrgId: adminUser.CurrentOrgId,
- HisPatientId: his.ID,
- PatientId: id,
- SettleAccountsDate: recordDateTime,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Status: 1,
- OrderStatus: 1,
- MdtrtId: his.Number,
- Number: chrg_bchno,
- MedfeeSumamt: totals,
- SettleEndTime: end_time,
- SettleStartTime: start_time,
- SettleType: settle_accounts_type,
- PType: 2,
- IsPre: 1,
- MedType: strconv.Itoa(int(reg_type)),
- Diagnosis: diagnosis_id,
- }
- err = service.CreateOrder(order)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
- return
- }
-
- var customs []*Custom
- for _, item := range prescriptions {
- fmt.Println(item.Type)
- if item.Type == 1 { //药品
- for _, subItem := range item.HisDoctorAdviceInfo {
- cus := &Custom{
- AdviceId: subItem.ID,
- ProjectId: 0,
- DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
- Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.2f", subItem.Price),
- MedListCodg: subItem.MedListCodg,
- Type: 1,
- }
- customs = append(customs, cus)
- }
- }
-
- if item.Type == 2 { //项目
- for _, subItem := range item.HisPrescriptionProject {
-
- cus := &Custom{
- AdviceId: 0,
- ProjectId: subItem.ID,
- DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
- Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
- MedListCodg: subItem.MedListCodg,
- Type: 2,
- }
-
- customs = append(customs, cus)
- }
- }
-
- for _, item := range item.HisAdditionalCharge {
- cus := &Custom{
- ItemId: item.ID,
- AdviceId: 0,
- ProjectId: 0,
- DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
- Cut: fmt.Sprintf("%.2f", float64(item.Count)),
- FeedetlSn: item.FeedetlSn,
- Price: fmt.Sprintf("%.2f", float64(item.Price)),
- MedListCodg: item.XtHisAddtionConfig.Code,
- Type: 3,
- }
-
- customs = append(customs, cus)
- }
-
- }
-
- fmt.Println(customs)
-
- for _, item := range customs {
- var advice_id int64 = 0
- var project_id int64 = 0
- var item_id int64 = 0
-
- var types int64 = 0
-
- if item.Type == 1 {
- advice_id = item.AdviceId
- project_id = 0
- item_id = 0
- } else if item.Type == 2 {
- advice_id = 0
- item_id = 0
-
- project_id = item.ProjectId
- } else if item.Type == 3 {
- advice_id = 0
- item_id = item.ItemId
- project_id = 0
- }
-
- detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
- cut, _ := strconv.ParseFloat(item.Cut, 32)
- pric, _ := strconv.ParseFloat(item.Price, 32)
-
- info := &models.HisOrderInfo{
- OrderNumber: order.Number,
- UploadDate: time.Now().Unix(),
- AdviceId: advice_id,
- DetItemFeeSumamt: detItemFeeSumamt,
- Cnt: cut,
- Pric: pric,
- PatientId: id,
- Status: 1,
- Mtime: time.Now().Unix(),
- Ctime: time.Now().Unix(),
- UserOrgId: adminUser.CurrentOrgId,
- HisPatientId: his.ID,
- OrderId: order.ID,
- ProjectId: project_id,
- Type: types,
- ItemId: item_id,
- }
- service.CreateOrderInfo(info)
- }
- his.SickType = sick_type
- service.UpdataHisPateint(&his)
- err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
- err = service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime, his_patient_id)
- //err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "结算成功",
- })
- }
- }
-
- func (c *HisApiController) GetPrivateExpensesInfo() {
- order_id, _ := c.GetInt64("id", 0)
- his_patient_id, _ := c.GetInt64("his_patient_id", 0)
- order, _ := service.GetHisOrderByID(order_id)
- role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, c.GetAdminUserInfo().AdminUser.Id)
- if order.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
- return
- }
- miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
- his, _ := service.GetHisPatientByIdThree(his_patient_id)
- org_id := c.GetAdminUserInfo().CurrentOrgId
- adminInfo, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
- order_info, _ := service.GetHisOrderDetailByNumber(order.Number, org_id)
- patient, _ := service.GetPatientByID(org_id, order.PatientId)
- c.ServeSuccessJSON(map[string]interface{}{
- "order": order,
- "order_info": order_info,
- "patient": patient,
- "admin_info": adminInfo,
- "his": his,
- "current_admin": role,
- "org_config": miConfig,
- })
-
- }
-
- func (this *HisApiController) ChangeMedType() {
- med_type := this.GetString("med_type")
- id, _ := this.GetInt64("id")
-
- prescription, _ := service.GetPrescriptionById(id, this.GetAdminUserInfo().CurrentOrgId)
- prescription.MedType = med_type
- err := service.SaveHisPrescription(&prescription)
-
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "修改成功",
- })
-
- } else {
-
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
-
- }
-
- func (c *HisApiController) GetHisMonthChargePatientInfo() {
- patient_id, _ := c.GetInt64("patient_id")
- his_patient_id, _ := c.GetInt64("his_patient_id")
- record_date := c.GetString("record_date")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- order_status, _ := c.GetInt64("type", 0)
- p_type, _ := c.GetInt64("p_type", 0)
- order_id, _ := c.GetInt64("order_id", 0)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
-
- startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
-
- }
- startRecordDateTime := startTime.Unix()
-
- endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
-
- }
- endRecordDateTime := endTime.Unix()
-
- admin := c.GetAdminUserInfo()
- his_patient_info, _ := service.GetNewHisPatientInfo(his_patient_id)
- xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
-
- order, _ := service.GetHisOrderByID(order_id)
-
- var monthPrescriptions []*models.HisPrescription
- if order_status == 1 || order_status == 0 {
- monthPrescriptions, _ = service.GetUnChargeMonthHisPrescriptionThree(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
- } else if order_status == 2 {
- monthPrescriptions, _ = service.GetChargeMonthHisPrescriptionFive(admin.CurrentOrgId, patient_id, order.Number, p_type)
- }
-
- case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
- patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
-
- lastPatientPrescriptionInfo, _ := service.FindLastPatientPrescriptionInfoTwo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
-
- doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
- //获取所有科室信息
- department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "his_info": his_patient_info,
- "xt_info": xt_patient_info,
- "case_history": case_history,
- "info": patientPrescriptionInfo,
- "last_info": lastPatientPrescriptionInfo,
- "month_prescriptions": monthPrescriptions,
- "order": order,
- "doctors": doctors,
- "department": department,
- })
- return
- }
-
- func (c *HisApiController) GetHisMonthPatientInfo() {
- patient_id, _ := c.GetInt64("patient_id")
- his_patient_id, _ := c.GetInt64("his_patient_id")
- record_date := c.GetString("record_date")
- number := c.GetString("number")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- p_type, _ := c.GetInt64("p_type")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
-
- }
- startRecordDateTime := startTime.Unix()
- endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
-
- }
- endRecordDateTime := endTime.Unix()
- admin := c.GetAdminUserInfo()
- his_patient_info, _ := service.GetNewHisPatientInfoTwo(admin.CurrentOrgId, his_patient_id, recordDateTime)
- xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
-
- count, _ := service.GetHisPatientCount(admin.CurrentOrgId, patient_id, recordDateTime)
-
- monthPrescriptions, _ := service.GetMonthHisPrescriptionTwo(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
- case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
- patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
- lastPatientPrescriptionInfo, _ := service.FindLastPatientPrescriptionInfoTwo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
-
- order, _ := service.GetHisOrder(admin.CurrentOrgId, number, patient_id)
- doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
-
- _, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(admin.CurrentOrgId)
- //获取所有科室信息
- department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "his_info": his_patient_info,
- "xt_info": xt_patient_info,
- "case_history": case_history,
- "info": patientPrescriptionInfo,
- "month_prescriptions": monthPrescriptions,
- "order": order,
- "doctors": doctors,
- "department": department,
- "count": count,
- "drugStockConfig": drugStockConfig,
- "last_info": lastPatientPrescriptionInfo,
- })
- return
-
- }
|