public_api_controller.go 70KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "encoding/json"
  7. "fmt"
  8. "os"
  9. "path"
  10. "runtime"
  11. "strconv"
  12. "strings"
  13. "time"
  14. "github.com/astaxie/beego"
  15. )
  16. type PublicApiController struct {
  17. BaseAPIController
  18. }
  19. //var f_a *os.File
  20. //
  21. //
  22. // func init() {
  23. // org_id, _ := beego.AppConfig.Int64("org_id")
  24. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  25. // Mkdir(miConfig.OrgName+"日志")
  26. // month := time.Unix(1557042972, 0).Format("1")
  27. // year := time.Now().Format("2006")
  28. // month = time.Now().Format("01")
  29. // day := time.Now().Format("02")
  30. // file := strconv.FormatInt( org_id, 10) + "_"+ year + month + day + "_log"
  31. // file_name := file + ".txt"
  32. // file_path := miConfig.OrgName+"日志" + "/" + file_name
  33. // exist, _ := PathExists(file_path)
  34. // if exist {//存在
  35. // f_a, _ := os.OpenFile(file_path,os.O_WRONLY,0644)
  36. // content := "新的日志内容吧"
  37. // n, _ := f_a.Seek(0,2)
  38. // f_a.WriteAt([]byte(content),n)
  39. //
  40. // } else { //不存在
  41. // fmt.Println("文件不存在,创建文件")
  42. // f, err := os.Create(miConfig.OrgName+"日志" + "/" + file_name)
  43. // defer f.Close()
  44. // if err !=nil {
  45. // } else {
  46. // _,err=f.Write([]byte("记录日志"))
  47. // }
  48. // }
  49. //
  50. // }
  51. func PublicApiRegistRouters() {
  52. beego.Router("/api/public/getadviceconfig", &PublicApiController{}, "Get:GetDoctorAdviceConfig")
  53. beego.Router("/api/public/servertime", &PublicApiController{}, "Get:GetServerTime")
  54. beego.Router("/api/app/release", &PublicApiController{}, "Get:AppRelease")
  55. beego.Router("/api/get", &PublicApiController{}, "Get:GetJson")
  56. beego.Router("/api/public/handledata", &PublicApiController{}, "get:HandleData")
  57. beego.Router("/api/public/handlestockdata", &PublicApiController{}, "get:HandleStockData")
  58. beego.Router("/api/public/handlecomdata", &PublicApiController{}, "get:HandleComData")
  59. beego.Router("/hello", &PublicApiController{}, "get:HandleComData")
  60. beego.Router("/handel", &PublicApiController{}, "get:HandleHIS")
  61. beego.Router("/groupno", &PublicApiController{}, "get:HandleGroupNo")
  62. beego.Router("/handle10215", &PublicApiController{}, "get:Handle10215")
  63. beego.Router("/handelOrder", &PublicApiController{}, "get:HandleOrder")
  64. beego.Router("/handelHis", &PublicApiController{}, "get:HandleHisTwo")
  65. beego.Router("/handelProject", &PublicApiController{}, "get:HandleProject")
  66. beego.Router("/handelsettledata", &PublicApiController{}, "get:HandleSettleData")
  67. beego.Router("/handelhispatient", &PublicApiController{}, "get:HandleHisPatient")
  68. //beego.Router("/handelOrder", &PublicApiController{}, "get:HandleOrder")
  69. beego.Router("/handleExportData", &PublicApiController{}, "get:HandleExportAllData")
  70. beego.Router("/handleExportData10138", &PublicApiController{}, "get:HandleExportData10138")
  71. beego.Router("/handleData10265", &PublicApiController{}, "get:HandleData10265")
  72. beego.Router("/handleData10265two", &PublicApiController{}, "get:HandleData10265two")
  73. beego.Router("/handleData10106", &PublicApiController{}, "get:HandleData10106")
  74. beego.Router("/handleData10318", &PublicApiController{}, "get:HandleData10318")
  75. beego.Router("/handleOne", &PublicApiController{}, "get:HandleOne")
  76. beego.Router("/handelschedule", &PublicApiController{}, "get:HandleSchedule")
  77. //beego.Router("/handelscheduleTwo", &PublicApiController{}, "get:HandleScheduleTwo")
  78. //
  79. //
  80. //
  81. //beego.Router("/handelhispatienttwo", &PublicApiController{}, "get:HandleHisPatientTwo")
  82. //beego.Router("/handleorderinfo", &PublicApiController{}, "get:HandleOrderInfoData")
  83. //
  84. //beego.Router("/hande10138", &PublicApiController{}, "get:HandleOrderInfoData10138")
  85. //935887
  86. beego.Router("/handle10210", &PublicApiController{}, "get:Handle10210")
  87. beego.Router("/handle10210", &PublicApiController{}, "get:Handle10210")
  88. //beego.Router("/handle10028", &PublicApiController{}, "get:Handle10028")
  89. beego.Router("/handleTeamData", &PublicApiController{}, "get:HandleTeamData")
  90. beego.Router("/handleHisPatientTwo", &PublicApiController{}, "get:HandleHisPatientTwo")
  91. }
  92. func (c *PublicApiController) HandleTeamData() {
  93. teams, _ := service.GetAllProjectTeam(10191)
  94. var hisProjectList []*models.XtHisProjectList
  95. for _, item := range teams {
  96. ids := strings.Split(item.ItemId, ",")
  97. project, _ := service.GetProjectHisListByIds(ids)
  98. for _, sp := range project {
  99. sp.PN = item.ProjectTeam
  100. }
  101. hisProjectList = append(hisProjectList, project...)
  102. }
  103. c.ServeSuccessJSON(map[string]interface{}{
  104. "ps": hisProjectList,
  105. })
  106. }
  107. type ResultFiveT struct {
  108. Balc float64 `json:"balc"`
  109. CvlservFlag string `json:"cvlserv_flag"`
  110. EmpName string `json:"emp_name"`
  111. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  112. Insutype string `json:"insutype"`
  113. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  114. PausInsuDate string `json:"paus_insu_date"`
  115. PsnInsuDate string `json:"psn_insu_date"`
  116. PsnInsuStas string `json:"psn_insu_stas"`
  117. PsnType string `json:"psn_type"`
  118. }
  119. func (c *PublicApiController) HandleSchedule() {
  120. //fmt.Println("~~~~~~")
  121. service.GetLongSolution()
  122. }
  123. //func (c *PublicApiController) Handle10028() {
  124. // HisPrescriptionTemplates, _ := service.GetHisPrescriptionTemplatesListTwo()
  125. // for _, item := range HisPrescriptionTemplates {
  126. // prescription, _ := service.GetHisPrescriptionTemplatetwo(item.ID)
  127. // for _, subitem := range prescription {
  128. // subitem.Status = 1
  129. // service.CreateHisPrescriptionInfoTemplate(subitem)
  130. // }
  131. // }
  132. //
  133. //}
  134. func (c *PublicApiController) Handle10210() {
  135. doctor_advices, _ := service.GetHisDoctorAdviceInfothree(10210, 1683561600)
  136. for _, item := range doctor_advices {
  137. strs := strings.Split(item.FeedetlSn, "-")
  138. news := strs[0] + "-" + strs[1] + "-" + strconv.FormatInt(item.ID, 10)
  139. item.FeedetlSn = news
  140. service.SaveHisDoctorAdvice(item)
  141. }
  142. projects, _ := service.GetHisPrescriptionProjectByIDFour(10210, 1683561600)
  143. for _, item := range projects {
  144. strs := strings.Split(item.FeedetlSn, "-")
  145. news := strs[0] + "-" + strs[1] + "-" + strconv.FormatInt(item.ID, 10)
  146. item.FeedetlSn = news
  147. service.SaveHisProject(item)
  148. }
  149. //doctor, _ := service.GetHisDoctorAdviceInfotwo(935886)
  150. //index := 0
  151. //total := 100
  152. //for index = 0; index < total; index++ {
  153. // doctor.ID = 0
  154. // service.SaveHisDoctorAdvice(&doctor)
  155. //}
  156. //doctor2, _ := service.GetHisDoctorAdviceInfotwo(935887)
  157. //index2 := 0
  158. //total2 := 100
  159. //for index2 = 0; index2 < total2; index2++ {
  160. // doctor2.ID = 0
  161. // service.SaveHisDoctorAdvice(&doctor2)
  162. //}
  163. //p, _ := service.GetHisPrescriptionProjectByID(2242486)
  164. //index3 := 0
  165. //total3 := 50
  166. //for index3 = 0; index3 < total3; index3++ {
  167. // p.ID = 0
  168. // service.SaveHisProject(&p)
  169. //}
  170. //p2, _ := service.GetHisPrescriptionProjectByIDThree(2242487)
  171. //index4 := 0
  172. //total4 := 100
  173. //for index4 = 0; index4 < total4; index4++ {
  174. // p2.ID = 0
  175. // service.SaveHisProject(&p2)
  176. //}
  177. //
  178. //p3, _ := service.GetHisPrescriptionProjectByIDThree(2242488)
  179. //index5 := 0
  180. //total5 := 100
  181. //for index5 = 0; index5 < total5; index5++ {
  182. // p3.ID = 0
  183. // service.SaveHisProject(&p3)
  184. //}
  185. //
  186. //p4, _ := service.GetHisPrescriptionProjectByIDThree(2242489)
  187. //index6 := 0
  188. //total6 := 100
  189. //for index6 = 0; index6 < total6; index6++ {
  190. // p4.ID = 0
  191. // service.SaveHisProject(&p4)
  192. //}
  193. }
  194. func (c *PublicApiController) HandleOne() {
  195. //fmt.Println("~~~~~~")
  196. //start_time := c.GetString("start_time")
  197. //end_time := c.GetString("end_time")
  198. //
  199. //timeLayout := "2006-01-02"
  200. //loc, _ := time.LoadLocation("Local")
  201. //startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  202. //if err != nil {
  203. //}
  204. //startRecordDateTime := startTime.Unix()
  205. //endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  206. //if err != nil {
  207. //}
  208. //endRecordDateTime := endTime.Unix()
  209. //orders, _ := service.GetHisOrderDetailOne(startRecordDateTime, endRecordDateTime)
  210. //c.ServeSuccessJSON(map[string]interface{}{
  211. // "order": orders,
  212. //})
  213. }
  214. //func (c *PublicApiController) HandleScheduleTwo() {
  215. // models, _ := service.GetAllSchMode()
  216. // for _, item := range models {
  217. // if item.Mode == 1 {
  218. // templates, _ := service.GetOrgPatientScheduleTemplateIDs(item.OrgID)
  219. // thisTime := time.Now()
  220. // _, theWeek := thisTime.ISOWeek()
  221. // templates[0].Week = theWeek
  222. // service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
  223. // } else if item.Mode == 2 {
  224. // templates, _ := service.GetOrgPatientScheduleTemplateIDs(item.OrgID)
  225. // now := time.Now()
  226. // nextSecWeek := now.AddDate(0, 0, 14)
  227. // nextWeek := now.AddDate(0, 0, 7)
  228. // if item.ExecuteTimes%2 == 0 { //下第二周生成的是
  229. // templates[0].Week = service.GetWeeks(nextWeek.Format("2006-01-02 15:04:05"))
  230. // templates[1].Week = service.GetWeeks(nextSecWeek.Format("2006-01-02 15:04:05"))
  231. // service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
  232. // service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, int8(templates[1].Week))
  233. //
  234. // } else if item.ExecuteTimes%2 == 1 {
  235. // templates[0].Week = service.GetWeeks(nextSecWeek.Format("2006-01-02 15:04:05"))
  236. // templates[1].Week = service.GetWeeks(nextWeek.Format("2006-01-02 15:04:05"))
  237. // service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, int8(templates[0].Week))
  238. // service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, int8(templates[1].Week))
  239. //
  240. // }
  241. //
  242. // }
  243. // }
  244. //
  245. //}
  246. func (c *PublicApiController) HandleHisPatientTwo() {
  247. ps, _ := service.GetHisPatient4444555()
  248. for _, item := range ps {
  249. var rf []*ResultFiveT
  250. json.Unmarshal([]byte(item.Iinfo), &rf)
  251. var insuplc_admdvs string
  252. var emp_name string
  253. var insutype string
  254. var is390 int = 0
  255. var is310 int = 0
  256. var insutypes []*ResultFiveT
  257. for _, item := range rf {
  258. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  259. insutypes = append(insutypes, item)
  260. }
  261. }
  262. fmt.Println(insutypes)
  263. if len(insutypes) == 1 {
  264. insutype = insutypes[0].Insutype
  265. is390 = 1
  266. fmt.Println("111111")
  267. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  268. } else {
  269. fmt.Println("222222")
  270. for _, i := range insutypes {
  271. if i.Insutype == "390" {
  272. is390 = 1
  273. }
  274. if i.Insutype == "310" {
  275. is310 = 1
  276. }
  277. }
  278. }
  279. if is390 == 1 {
  280. insutype = "390"
  281. }
  282. if is310 == 1 {
  283. insutype = "310"
  284. }
  285. if len(insutypes) == 0 {
  286. insutype = "390"
  287. }
  288. for _, item := range rf {
  289. if item.Insutype == insutype {
  290. insuplc_admdvs = item.InsuplcAdmdvs
  291. emp_name = item.EmpName
  292. }
  293. }
  294. item.InsuplcAdmdvs = insuplc_admdvs
  295. item.Emp = emp_name
  296. service.Savehis(item)
  297. //service.SaveHisTwo(item)
  298. }
  299. }
  300. func (c *PublicApiController) HandleHisPatient() {
  301. ps, _ := service.GetHisPatient11111(10215)
  302. for _, item := range ps {
  303. var rf []*ResultFiveT
  304. json.Unmarshal([]byte(item.Iinfo), &rf)
  305. var insuplc_admdvs string
  306. var insutype string
  307. var is390 int = 0
  308. var is310 int = 0
  309. var insutypes []*ResultFiveT
  310. for _, item := range rf {
  311. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  312. insutypes = append(insutypes, item)
  313. }
  314. }
  315. fmt.Println(insutypes)
  316. if len(insutypes) == 1 {
  317. insutype = insutypes[0].Insutype
  318. is390 = 1
  319. fmt.Println("111111")
  320. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  321. } else {
  322. fmt.Println("222222")
  323. for _, i := range insutypes {
  324. if i.Insutype == "390" {
  325. is390 = 1
  326. }
  327. if i.Insutype == "310" {
  328. is310 = 1
  329. }
  330. }
  331. }
  332. if is390 == 1 {
  333. insutype = "390"
  334. }
  335. if is310 == 1 {
  336. insutype = "310"
  337. }
  338. if len(insutypes) == 0 {
  339. insutype = "390"
  340. }
  341. for _, item := range rf {
  342. if item.Insutype == insutype {
  343. insuplc_admdvs = item.InsuplcAdmdvs
  344. }
  345. }
  346. item.InsuplcAdmdvs = insuplc_admdvs
  347. service.SaveHP(item)
  348. }
  349. }
  350. //func (c *PublicApiController) HandleHisPatientTwo() {
  351. //
  352. // ps, _ := service.GetHisPatient2222(10188)
  353. // for _, item := range ps {
  354. // var rf []*ResultFiveT
  355. // json.Unmarshal([]byte(item.Iinfo), &rf)
  356. // var insuplc_admdvs string
  357. //
  358. // for _, subItem := range rf {
  359. // if subItem.Insutype == item.Insutype {
  360. // insuplc_admdvs = subItem.InsuplcAdmdvs
  361. // }
  362. // }
  363. // item.InsuplcAdmdvs = insuplc_admdvs
  364. // service.SaveHPtWO(item)
  365. // }
  366. //}
  367. func (c *PublicApiController) HandleSettleData() {
  368. orders, _ := service.GetHisOrderDetailThree()
  369. c.ServeSuccessJSON(map[string]interface{}{
  370. "order": orders,
  371. })
  372. }
  373. //func (c *PublicApiController) HandleData10106() {
  374. // start_time := c.GetString("start_time")
  375. // end_time := c.GetString("end_time")
  376. //
  377. // timeLayout := "2006-01-02"
  378. // loc, _ := time.LoadLocation("Local")
  379. // startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  380. // if err != nil {
  381. //
  382. // }
  383. // startRecordDateTime := startTime.Unix()
  384. //
  385. // endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  386. // if err != nil {
  387. //
  388. // }
  389. // endRecordDateTime := endTime.Unix()
  390. // fmt.Println(startRecordDateTime)
  391. // fmt.Println(endRecordDateTime)
  392. //
  393. // orders, _ := service.GetHisOrderDetail10106(startRecordDateTime, endRecordDateTime)
  394. // c.ServeSuccessJSON(map[string]interface{}{
  395. // "order": orders,
  396. // })
  397. //}
  398. func (c *PublicApiController) HandleData10106() {
  399. start_time := c.GetString("start_time")
  400. end_time := c.GetString("end_time")
  401. timeLayout := "2006-01-02"
  402. loc, _ := time.LoadLocation("Local")
  403. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  404. if err != nil {
  405. }
  406. startRecordDateTime := startTime.Unix()
  407. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  408. if err != nil {
  409. }
  410. endRecordDateTime := endTime.Unix()
  411. fmt.Println(startRecordDateTime)
  412. fmt.Println(endRecordDateTime)
  413. orders, _ := service.GetHisOrderDetail10106(startRecordDateTime, endRecordDateTime)
  414. c.ServeSuccessJSON(map[string]interface{}{
  415. "order": orders,
  416. })
  417. }
  418. func (c *PublicApiController) HandleData10318() {
  419. start_time := c.GetString("start_time")
  420. end_time := c.GetString("end_time")
  421. timeLayout := "2006-01-02"
  422. loc, _ := time.LoadLocation("Local")
  423. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  424. if err != nil {
  425. }
  426. startRecordDateTime := startTime.Unix()
  427. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  428. if err != nil {
  429. }
  430. endRecordDateTime := endTime.Unix()
  431. fmt.Println(startRecordDateTime)
  432. fmt.Println(endRecordDateTime)
  433. orders, _ := service.GetHisOrderDetail10318(startRecordDateTime, endRecordDateTime)
  434. c.ServeSuccessJSON(map[string]interface{}{
  435. "order": orders,
  436. })
  437. }
  438. func (c *PublicApiController) HandleProject() {
  439. prescriptions := service.GetAllProjectPrescription()
  440. for _, item := range prescriptions {
  441. ps := service.GetAllProject(item.ID)
  442. for _, subItem := range ps {
  443. subItem.Status = 0
  444. service.SaveHisProject(subItem)
  445. }
  446. }
  447. }
  448. func (c *PublicApiController) HandleHisTwo() {
  449. hiss := service.GetAllPrivateHis(10215)
  450. for _, item := range hiss {
  451. patient, _ := service.GetPatientByID(10215, item.PatientId)
  452. item.Gender = patient.Gender
  453. service.SaveHis(item)
  454. }
  455. }
  456. func (c *PublicApiController) GetDoctorAdviceConfig() {
  457. drugs, _, _ := service.GetPublicDrugDics()
  458. drugways, _, _ := service.GetPublicDrugWayDics()
  459. efs, _, _ := service.GetPublicExecutionFrequencyDics()
  460. c.ServeSuccessJSON(map[string]interface{}{
  461. "drugs": drugs,
  462. "drugways": drugways,
  463. "efs": efs,
  464. })
  465. }
  466. func (c *PublicApiController) GetServerTime() {
  467. timeNow := time.Now()
  468. timeNowStamp := timeNow.Unix()
  469. timeNowStr := timeNow.Format("2006-01-02 15:04:05")
  470. c.ServeSuccessJSON(map[string]interface{}{
  471. "time": timeNowStr,
  472. "timestamp": timeNowStamp,
  473. })
  474. }
  475. func (c *PublicApiController) AppRelease() {
  476. // appId := c.GetString("appid")
  477. version := c.GetString("version")
  478. appType, _ := c.GetInt64("app_type", 0)
  479. appVersion, err := service.GetAppVersionByAppType(appType)
  480. if err != nil {
  481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  482. return
  483. }
  484. if appVersion == nil {
  485. c.ServeSuccessJSON(map[string]interface{}{
  486. "version": nil,
  487. "state": 2,
  488. })
  489. return
  490. }
  491. state := strings.Compare(version, appVersion.Version)
  492. // state := 1
  493. if state < 0 {
  494. c.ServeSuccessJSON(map[string]interface{}{
  495. "version": appVersion,
  496. "state": appVersion.Status,
  497. })
  498. return
  499. }
  500. c.ServeSuccessJSON(map[string]interface{}{
  501. "version": nil,
  502. "state": 2,
  503. })
  504. return
  505. }
  506. func (this *PublicApiController) GetJson() {
  507. type Global struct {
  508. DeviceSN string
  509. Version string
  510. Timestamp string
  511. InterfaceSource string
  512. }
  513. type RBPResultModel struct {
  514. Sys string
  515. Dia string
  516. HR string
  517. MeasureTime string
  518. }
  519. type ScannerResultModel struct {
  520. Code string
  521. }
  522. type IDCardResultModel struct {
  523. IDCardNo string
  524. UserName string
  525. Age string
  526. Female string
  527. Male string
  528. SocialSecurityNo string
  529. }
  530. type JsonTemp struct {
  531. Global Global
  532. RBPResultModel RBPResultModel
  533. ScannerResultModel ScannerResultModel
  534. IDCardResultModel IDCardResultModel
  535. }
  536. var person JsonTemp
  537. err3 := json.Unmarshal([]byte(this.GetString("params")), &person)
  538. fmt.Println(err3)
  539. fmt.Println(person.Global)
  540. //temp := JsonTemp{
  541. // Global:Global{
  542. // DeviceSN:"1122",
  543. // Version:"1122",
  544. // Timestamp:"1222",
  545. // InterfaceSource:"1233",
  546. // },
  547. // RBPResultModel: RBPResultModel{
  548. // Sys:"12",
  549. // Dia:"22",
  550. // HR:"23",
  551. // MeasureTime:"123",
  552. // },
  553. // ScannerResultModel:ScannerResultModel{
  554. // Code:"1233",
  555. // },
  556. // IDCardResultModel:IDCardResultModel{
  557. // IDCardNo:"123",
  558. // UserName:"123",
  559. // Age:"123",
  560. // Female:"123",
  561. // Male:"123",
  562. // SocialSecurityNo:"123",
  563. // },
  564. //}
  565. //
  566. //jsonBytes, err := json.Marshal(temp)
  567. //if err != nil {
  568. // fmt.Println(err)
  569. //}
  570. //fmt.Println(string(jsonBytes))
  571. }
  572. func (c *PublicApiController) HandleData() {
  573. //service.HandleData()
  574. org_app, _ := service.GetAllAppOrg()
  575. //org_role, _ := service.GetAllRole()
  576. //
  577. //var org_ids []int64
  578. for _, apps := range org_app {
  579. xt_org_app, _ := service.GetAppByType(int64(apps.OrgId), 3)
  580. //org_app_6, _ := service.GetAppByType(int64(apps.OrgId), 6)
  581. //org_app_7, _ := service.GetAppByType(int64(apps.OrgId), 7)
  582. //org_app_8, _ := service.GetAppByType(int64(apps.OrgId), 8)
  583. //org_app_9, _ := service.GetAppByType(int64(apps.OrgId), 9)
  584. //org_app_10, _ := service.GetAppByType(int64(apps.OrgId), 10)
  585. //org_app_11, _ := service.GetAppByType(int64(apps.OrgId), 11)
  586. //org_app_12, _ := service.GetAppByType(int64(apps.OrgId), 12)
  587. //org_app_13, _ := service.GetAppByType(int64(apps.OrgId), 13)
  588. //org_app_14, _ := service.GetAppByType(int64(apps.OrgId), 14)
  589. //org_app_15, _ := service.GetAppByType(int64(apps.OrgId), 15)
  590. //org_app_16, _ := service.GetAppByType(int64(apps.OrgId), 16)
  591. //org_app_17, _ := service.GetAppByType(int64(apps.OrgId), 17)
  592. org_app_18, _ := service.GetAppByType(int64(apps.OrgId), 18)
  593. var xt_temp_org_app *models.OrgApp
  594. //var mall_temp_org_app *models.OrgApp
  595. if xt_org_app == nil || xt_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  596. app, _ := service.GetOrgAppA(0, 3)
  597. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  598. if org == nil || org.Id == 0 {
  599. continue
  600. }
  601. app.Id = 0
  602. app.OrgId = apps.OrgId
  603. app.Creator = int(org.Creator)
  604. app.Number = 0
  605. app.Status = 1
  606. app.ModifyTime = time.Now().Unix()
  607. app.CreateTime = time.Now().Unix()
  608. service.CreateOrgApp(app)
  609. xt_temp_org_app = app
  610. } else {
  611. xt_temp_org_app = xt_org_app
  612. }
  613. //if scrm_org_app == nil || scrm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  614. //
  615. // app, _ := service.GetOrgAppA(0, 1)
  616. // //org, _ := service.GetOrgById(int64(12))
  617. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  618. // if org == nil || org.Id == 0 {
  619. // continue
  620. // }
  621. //
  622. //
  623. // app.OrgId = apps.OrgId
  624. // app.Id = 0
  625. //
  626. // app.Creator = int(org.Creator)
  627. // app.Number = 0
  628. // app.Status = 1
  629. // app.ModifyTime = time.Now().Unix()
  630. // app.CreateTime = time.Now().Unix()
  631. // service.CreateOrgApp(app)
  632. //
  633. //}
  634. //
  635. //if cdm_org_app == nil || cdm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  636. // app, _ := service.GetOrgAppA(0, 4)
  637. // //org, _ := service.GetOrgById(int64(12))
  638. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  639. // if org == nil || org.Id == 0 {
  640. // continue
  641. // }
  642. //
  643. //
  644. // app.OrgId = apps.OrgId
  645. // app.Creator = int(org.Creator)
  646. // app.Number = 0
  647. // app.Id = 0
  648. //
  649. // app.Status = 1
  650. // app.ModifyTime = time.Now().Unix()
  651. // app.CreateTime = time.Now().Unix()
  652. // service.CreateOrgApp(app)
  653. //}
  654. //
  655. //if mall_org_app == nil || mall_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  656. // app, _ := service.GetOrgAppA(0, 5)
  657. // //org, _ := service.GetOrgById(int64(12))
  658. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  659. //
  660. // if org == nil || org.Id == 0 {
  661. // continue
  662. // }
  663. //
  664. // app.OrgId = apps.OrgId
  665. // app.Creator = int(org.Creator)
  666. // app.Number = 0
  667. // app.Id = 0
  668. //
  669. // app.Status = 1
  670. // app.ModifyTime = time.Now().Unix()
  671. // app.CreateTime = time.Now().Unix()
  672. // service.CreateOrgApp(app)
  673. // mall_temp_org_app = app
  674. //} else {
  675. // mall_temp_org_app = mall_org_app
  676. //}
  677. //
  678. //if org_app_16 == nil || org_app_16.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  679. // app, _ := service.GetOrgAppA(0, 16)
  680. // //org, _ := service.GetOrgById(int64(12))
  681. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  682. // if org == nil || org.Id == 0 {
  683. // continue
  684. // }
  685. //
  686. // app.OrgId = apps.OrgId
  687. // app.Creator = int(org.Creator)
  688. // app.Number = 11
  689. // app.Id = 0
  690. // app.Status = 1
  691. // app.ModifyTime = time.Now().Unix()
  692. // app.CreateTime = time.Now().Unix()
  693. // app.Pid = xt_temp_org_app.Id
  694. // service.CreateOrgApp(app)
  695. //
  696. //}
  697. //
  698. //if org_app_17 == nil || org_app_17.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  699. // app, _ := service.GetOrgAppA(0, 17)
  700. // //org, _ := service.GetOrgById(int64(12))
  701. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  702. // if org == nil || org.Id == 0 {
  703. // continue
  704. // }
  705. //
  706. // app.OrgId = apps.OrgId
  707. // app.Creator = int(org.Creator)
  708. // app.Number = 12
  709. // app.Id = 0
  710. // app.Status = 1
  711. // app.ModifyTime = time.Now().Unix()
  712. // app.CreateTime = time.Now().Unix()
  713. // app.Pid = xt_temp_org_app.Id
  714. // service.CreateOrgApp(app)
  715. //
  716. //}
  717. if org_app_18 == nil || org_app_18.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  718. app, _ := service.GetOrgAppA(0, 18)
  719. //org, _ := service.GetOrgById(int64(12))
  720. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  721. if org == nil || org.Id == 0 {
  722. continue
  723. }
  724. app.OrgId = apps.OrgId
  725. app.Creator = int(org.Creator)
  726. app.Number = 5
  727. app.Id = 0
  728. app.Status = 1
  729. app.ModifyTime = time.Now().Unix()
  730. app.CreateTime = time.Now().Unix()
  731. app.Pid = xt_temp_org_app.Id
  732. service.CreateOrgApp(app)
  733. }
  734. //if org_app_7 == nil || org_app_7.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  735. // app, _ := service.GetOrgAppA(0, 7)
  736. // //org, _ := service.GetOrgById(int64(12))
  737. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  738. // if org == nil || org.Id == 0 {
  739. // continue
  740. // }
  741. //
  742. //
  743. // app.OrgId = apps.OrgId
  744. // app.Creator = int(org.Creator)
  745. // app.Number = 2
  746. // app.Status = 2
  747. // app.Id = 0
  748. //
  749. // app.ModifyTime = time.Now().Unix()
  750. // app.CreateTime = time.Now().Unix()
  751. // app.Pid = xt_temp_org_app.Id
  752. //
  753. // service.CreateOrgApp(app)
  754. //}
  755. //if org_app_8 == nil || org_app_8.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  756. // app, _ := service.GetOrgAppA(0, 8)
  757. // //org, _ := service.GetOrgById(int64(12))
  758. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  759. // if org == nil || org.Id == 0 {
  760. // continue
  761. // }
  762. //
  763. //
  764. // app.OrgId = apps.OrgId
  765. // app.Creator = int(org.Creator)
  766. // app.Number = 3
  767. // app.Id = 0
  768. //
  769. // app.Pid = mall_temp_org_app.Id
  770. //
  771. // app.Status = 1
  772. // app.ModifyTime = time.Now().Unix()
  773. // app.CreateTime = time.Now().Unix()
  774. // service.CreateOrgApp(app)
  775. //}
  776. //if org_app_9 == nil || org_app_9.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  777. // app, _ := service.GetOrgAppA(0, 9)
  778. // //org, _ := service.GetOrgById(int64(12))
  779. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  780. // if org == nil || org.Id == 0 {
  781. // continue
  782. // }
  783. //
  784. //
  785. // app.OrgId = apps.OrgId
  786. // app.Pid = xt_temp_org_app.Id
  787. //
  788. // app.Creator = int(org.Creator)
  789. // app.Number = 4
  790. // app.Id = 0
  791. //
  792. // app.Status = 1
  793. // app.ModifyTime = time.Now().Unix()
  794. // app.CreateTime = time.Now().Unix()
  795. // service.CreateOrgApp(app)
  796. //
  797. //}
  798. //if org_app_10 == nil || org_app_10.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  799. // app, _ := service.GetOrgAppA(0, 10)
  800. // //org, _ := service.GetOrgById(int64(12))
  801. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  802. // if org == nil || org.Id == 0 {
  803. // continue
  804. // }
  805. //
  806. //
  807. // app.OrgId = apps.OrgId
  808. // app.Creator = int(org.Creator)
  809. // app.Pid = xt_temp_org_app.Id
  810. //
  811. // app.Number = 5
  812. // app.Id = 0
  813. //
  814. // app.Status = 1
  815. // app.ModifyTime = time.Now().Unix()
  816. // app.CreateTime = time.Now().Unix()
  817. // service.CreateOrgApp(app)
  818. //}
  819. //if org_app_11 == nil || org_app_11.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  820. // app, _ := service.GetOrgAppA(0, 11)
  821. // //org, _ := service.GetOrgById(int64(12))
  822. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  823. // if org == nil || org.Id == 0 {
  824. // continue
  825. // }
  826. //
  827. //
  828. // app.OrgId = apps.OrgId
  829. // app.Creator = int(org.Creator)
  830. // app.Pid = xt_temp_org_app.Id
  831. // app.Id = 0
  832. //
  833. // app.Number = 6
  834. // app.Status = 1
  835. // app.ModifyTime = time.Now().Unix()
  836. // app.CreateTime = time.Now().Unix()
  837. // service.CreateOrgApp(app)
  838. //}
  839. //if org_app_12 == nil || org_app_12.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  840. // app, _ := service.GetOrgAppA(0, 12)
  841. // //org, _ := service.GetOrgById(int64(12))
  842. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  843. // if org == nil || org.Id == 0 {
  844. // continue
  845. // }
  846. //
  847. //
  848. // app.OrgId = apps.OrgId
  849. // app.Creator = int(org.Creator)
  850. // app.Pid = xt_temp_org_app.Id
  851. // app.Number = 7
  852. // app.Status = 1
  853. // app.Id = 0
  854. //
  855. // app.ModifyTime = time.Now().Unix()
  856. // app.CreateTime = time.Now().Unix()
  857. // service.CreateOrgApp(app)
  858. //}
  859. //if org_app_13 == nil || org_app_13.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  860. // app, _ := service.GetOrgAppA(0, 13)
  861. // //org, _ := service.GetOrgById(int64(12))
  862. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  863. // if org == nil || org.Id == 0 {
  864. // continue
  865. // }
  866. //
  867. //
  868. // app.OrgId = apps.OrgId
  869. // app.Creator = int(org.Creator)
  870. // app.Pid = xt_temp_org_app.Id
  871. // app.Number = 8
  872. // app.Id = 0
  873. // app.Status = 1
  874. // app.ModifyTime = time.Now().Unix()
  875. // app.CreateTime = time.Now().Unix()
  876. // service.CreateOrgApp(app)
  877. //}
  878. //if org_app_14 == nil || org_app_14.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  879. // app, _ := service.GetOrgAppA(0, 14)
  880. // //org, _ := service.GetOrgById(int64(12))
  881. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  882. // if org == nil || org.Id == 0 {
  883. // continue
  884. // }
  885. //
  886. //
  887. // app.OrgId = apps.OrgId
  888. // app.Creator = int(org.Creator)
  889. // app.Pid = xt_temp_org_app.Id
  890. // app.Id = 0
  891. // app.Number = 9
  892. // app.Status = 1
  893. // app.ModifyTime = time.Now().Unix()
  894. // app.CreateTime = time.Now().Unix()
  895. // service.CreateOrgApp(app)
  896. //}
  897. //if org_app_15 == nil || org_app_15.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  898. // app, _ := service.GetOrgAppA(0, 15)
  899. // //org, _ := service.GetOrgById(int64(12))
  900. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  901. // if org == nil || org.Id == 0 {
  902. // continue
  903. // }
  904. //
  905. // app.OrgId = apps.OrgId
  906. // app.Creator = int(org.Creator)
  907. // app.Pid = xt_temp_org_app.Id
  908. // app.Number = 10
  909. // app.Status = 1
  910. // app.Id = 0
  911. // app.ModifyTime = time.Now().Unix()
  912. // app.CreateTime = time.Now().Unix()
  913. // service.CreateOrgApp(app)
  914. //}
  915. }
  916. //for _, role := range org_role {
  917. // org_ids = append(org_ids, role.OrgId)
  918. //}
  919. //
  920. //
  921. ////创建内置角色
  922. //InitRoleAndPurviews(org_ids)
  923. //var org_id int = 0
  924. //管理员
  925. //app_roles := service.GetAllUserRoleByUserTypeOne(org_id)
  926. //for _, item := range app_roles{
  927. // var ids string
  928. // if len(item.RoleIds) == 0{
  929. // ids = strconv.FormatInt( item.RoleId,10)
  930. // }else{
  931. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  932. // }
  933. // service.UpdateRoleIds(item.Id, ids)
  934. //}
  935. //护士医生
  936. //app_roles2 := service.GetAllUserRoleByUserTypeOther()
  937. // for _, item := range app_roles2{
  938. // var ids string
  939. // if len(item.RoleIds) == 0{
  940. // ids = strconv.FormatInt( item.RoleId,10)
  941. // }else{
  942. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  943. // }
  944. // if item.UserType == 2{
  945. // role := service.FindRoleByUserTypeOne(item.OrgId)
  946. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  947. //
  948. // } else if item.UserType == 3{
  949. // role := service.FindRoleByUserTypeTwo(item.OrgId)
  950. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  951. // }
  952. // service.UpdateRoleIds(item.Id, ids)
  953. // }
  954. //c.ServeSuccessJSON(map[string]interface{}{
  955. // "msg": "ok",
  956. //})
  957. }
  958. func (c *PublicApiController) HandleGroupNo() {
  959. //service.GetAllPatientChargeDetails(10138, 1634054400)
  960. //pts, _ := service.GetHisPrescriptionTemplateTwo()
  961. //for _, item := range pts {
  962. // if len(item.HisPrescriptionAdviceTemplate) > 0 {
  963. // for index, subItem := range item.HisPrescriptionAdviceTemplate {
  964. // subItem.Groupno = int64(index + 1)
  965. // service.SaveAdviceTemplate(subItem)
  966. // }
  967. // }
  968. //}
  969. }
  970. func InitRoleAndPurviews(org_ids []int64) {
  971. roles := LoadRoleConfig("./role.json").Roles
  972. for _, org_id := range org_ids {
  973. app, _ := service.GetOrgAppB(org_id, 3)
  974. role, _ := service.GetSystemRole(org_id)
  975. if app == nil || app.Id == 0 {
  976. continue
  977. }
  978. if len(role) == 0 {
  979. for _, item := range roles {
  980. role := &models.Role{
  981. RoleName: item.RoleName,
  982. RoleIntro: item.RoleIntroduction,
  983. Creator: 0,
  984. OrgId: org_id,
  985. AppId: app.Id,
  986. IsSuperAdmin: false,
  987. Status: 1,
  988. CreateTime: time.Now().Unix(),
  989. ModifyTime: time.Now().Unix(),
  990. Number: item.Number,
  991. IsSystem: item.IsSystem,
  992. }
  993. err := service.CreateOrgRoleB(role)
  994. if err == nil {
  995. purview := &models.RolePurview{
  996. RoleId: role.Id,
  997. OrgId: org_id,
  998. AppId: role.AppId,
  999. PurviewIds: item.PurviewIds,
  1000. Status: 1,
  1001. CreateTime: time.Now().Unix(),
  1002. ModifyTime: time.Now().Unix(),
  1003. }
  1004. func_purview := &models.SgjUserRoleFuncPurview{
  1005. RoleId: role.Id,
  1006. OrgId: org_id,
  1007. AppId: role.AppId,
  1008. PurviewIds: item.FuncIds,
  1009. Status: 1,
  1010. Ctime: time.Now().Unix(),
  1011. Mtime: time.Now().Unix(),
  1012. }
  1013. service.CreateRolePurviewB(purview)
  1014. service.CreateFuncRolePurviewB(func_purview)
  1015. }
  1016. }
  1017. }
  1018. }
  1019. }
  1020. type RoleConfig struct {
  1021. Roles []*models.VMUserRoleAndPurview "json:roles"
  1022. }
  1023. func LoadRoleConfig(dataFile string) *RoleConfig {
  1024. var config RoleConfig
  1025. _, filename, _, _ := runtime.Caller(1)
  1026. datapath := path.Join(path.Dir(filename), dataFile)
  1027. config_file, err := os.Open(datapath)
  1028. if err != nil {
  1029. emit("Failed to open config file '%s': %s\n", datapath, err)
  1030. return &config
  1031. }
  1032. fi, _ := config_file.Stat()
  1033. buffer := make([]byte, fi.Size())
  1034. _, err = config_file.Read(buffer)
  1035. buffer, err = StripComments(buffer) //去掉注释
  1036. if err != nil {
  1037. emit("Failed to strip comments from json: %s\n", err)
  1038. return &config
  1039. }
  1040. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  1041. err = json.Unmarshal(buffer, &config) //解析json格式数据
  1042. if err != nil {
  1043. emit("Failed unmarshalling json: %s\n", err)
  1044. return &config
  1045. }
  1046. return &config
  1047. }
  1048. type GoodTypesConfig struct {
  1049. GoodTypes []*models.VMGoodsType "json:list"
  1050. }
  1051. func LoadGoodTypeConfig(dataFile string) *GoodTypesConfig {
  1052. var config GoodTypesConfig
  1053. _, filename, _, _ := runtime.Caller(1)
  1054. datapath := path.Join(path.Dir(filename), dataFile)
  1055. config_file, err := os.Open(datapath)
  1056. if err != nil {
  1057. emit("Failed to open config file '%s': %s\n", datapath, err)
  1058. return &config
  1059. }
  1060. fi, _ := config_file.Stat()
  1061. buffer := make([]byte, fi.Size())
  1062. _, err = config_file.Read(buffer)
  1063. buffer, err = StripComments(buffer) //去掉注释
  1064. if err != nil {
  1065. emit("Failed to strip comments from json: %s\n", err)
  1066. return &config
  1067. }
  1068. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  1069. err = json.Unmarshal(buffer, &config) //解析json格式数据
  1070. if err != nil {
  1071. emit("Failed unmarshalling json: %s\n", err)
  1072. return &config
  1073. }
  1074. return &config
  1075. }
  1076. func (c *PublicApiController) HandleStockData() {
  1077. org, _ := service.FindAllOrgByImportType()
  1078. for _, item := range org {
  1079. if item.Id != 3907 || item.Id != 9779 || item.Id != 9883 {
  1080. goodTypes := &models.GoodsType{
  1081. TypeCode: "14000000",
  1082. TypeName: "穿刺针",
  1083. Remark: "",
  1084. Ctime: time.Now().Unix(),
  1085. Mtime: time.Now().Unix(),
  1086. Creater: 0,
  1087. Modifier: 0,
  1088. OrgId: item.Id,
  1089. Status: 1,
  1090. Type: 1,
  1091. Number: 1,
  1092. }
  1093. service.AddSigleGoodType(goodTypes)
  1094. goodTypes1 := &models.GoodsType{
  1095. TypeCode: "14000001",
  1096. TypeName: "透析器",
  1097. Remark: "",
  1098. Ctime: time.Now().Unix(),
  1099. Mtime: time.Now().Unix(),
  1100. Creater: 0,
  1101. Modifier: 0,
  1102. OrgId: item.Id,
  1103. Status: 1,
  1104. Type: 1,
  1105. Number: 2,
  1106. }
  1107. service.AddSigleGoodType(goodTypes1)
  1108. goodTypes2 := &models.GoodsType{
  1109. TypeCode: "14000002",
  1110. TypeName: "灌流器",
  1111. Remark: "",
  1112. Ctime: time.Now().Unix(),
  1113. Mtime: time.Now().Unix(),
  1114. Creater: 0,
  1115. Modifier: 0,
  1116. OrgId: item.Id,
  1117. Status: 1,
  1118. Type: 1,
  1119. Number: 3,
  1120. }
  1121. service.AddSigleGoodType(goodTypes2)
  1122. goodTypes3 := &models.GoodsType{
  1123. TypeCode: "14000003",
  1124. TypeName: "血路管",
  1125. Remark: "",
  1126. Ctime: time.Now().Unix(),
  1127. Mtime: time.Now().Unix(),
  1128. Creater: 0,
  1129. Modifier: 0,
  1130. OrgId: item.Id,
  1131. Status: 1,
  1132. Type: 1,
  1133. Number: 4,
  1134. }
  1135. service.AddSigleGoodType(goodTypes3)
  1136. goodTypes4 := &models.GoodsType{
  1137. TypeCode: "14000004",
  1138. TypeName: "血滤补液管",
  1139. Remark: "",
  1140. Ctime: time.Now().Unix(),
  1141. Mtime: time.Now().Unix(),
  1142. Creater: 0,
  1143. Modifier: 0,
  1144. OrgId: item.Id,
  1145. Status: 1,
  1146. Type: 1,
  1147. Number: 5,
  1148. }
  1149. service.AddSigleGoodType(goodTypes4)
  1150. goodTypes5 := &models.GoodsType{
  1151. TypeCode: "14000005",
  1152. TypeName: "注射器",
  1153. Remark: "",
  1154. Ctime: time.Now().Unix(),
  1155. Mtime: time.Now().Unix(),
  1156. Creater: 0,
  1157. Modifier: 0,
  1158. OrgId: item.Id,
  1159. Status: 1,
  1160. Type: 1,
  1161. Number: 6,
  1162. }
  1163. service.AddSigleGoodType(goodTypes5)
  1164. goodTypes6 := &models.GoodsType{
  1165. TypeCode: "14000006",
  1166. TypeName: "护理包(内瘘穿刺包)",
  1167. Remark: "",
  1168. Ctime: time.Now().Unix(),
  1169. Mtime: time.Now().Unix(),
  1170. Creater: 0,
  1171. Modifier: 0,
  1172. OrgId: item.Id,
  1173. Status: 1,
  1174. Type: 1,
  1175. Number: 7,
  1176. }
  1177. service.AddSigleGoodType(goodTypes6)
  1178. goodTypes7 := &models.GoodsType{
  1179. TypeCode: "14000007",
  1180. TypeName: "细菌过滤器",
  1181. Remark: "",
  1182. Ctime: time.Now().Unix(),
  1183. Mtime: time.Now().Unix(),
  1184. Creater: 0,
  1185. Modifier: 0,
  1186. OrgId: item.Id,
  1187. Status: 1,
  1188. Type: 1,
  1189. Number: 8,
  1190. }
  1191. service.AddSigleGoodType(goodTypes7)
  1192. goodTypes8 := &models.GoodsType{
  1193. TypeCode: "14000008",
  1194. TypeName: "血液透析干粉",
  1195. Remark: "",
  1196. Ctime: time.Now().Unix(),
  1197. Mtime: time.Now().Unix(),
  1198. Creater: 0,
  1199. Modifier: 0,
  1200. OrgId: item.Id,
  1201. Status: 1,
  1202. Type: 1,
  1203. Number: 9,
  1204. }
  1205. service.AddSigleGoodType(goodTypes8)
  1206. goodTypes9 := &models.GoodsType{
  1207. TypeCode: "14000009",
  1208. TypeName: "A液",
  1209. Remark: "",
  1210. Ctime: time.Now().Unix(),
  1211. Mtime: time.Now().Unix(),
  1212. Creater: 0,
  1213. Modifier: 0,
  1214. OrgId: item.Id,
  1215. Status: 1,
  1216. Type: 1,
  1217. Number: 10,
  1218. }
  1219. service.AddSigleGoodType(goodTypes9)
  1220. goodTypes10 := &models.GoodsType{
  1221. TypeCode: "14000010",
  1222. TypeName: "B液",
  1223. Remark: "",
  1224. Ctime: time.Now().Unix(),
  1225. Mtime: time.Now().Unix(),
  1226. Creater: 0,
  1227. Modifier: 0,
  1228. OrgId: item.Id,
  1229. Status: 1,
  1230. Type: 1,
  1231. Number: 11,
  1232. }
  1233. service.AddSigleGoodType(goodTypes10)
  1234. goodTypes11 := &models.GoodsType{
  1235. TypeCode: "14000011",
  1236. TypeName: "导管包",
  1237. Remark: "",
  1238. Ctime: time.Now().Unix(),
  1239. Mtime: time.Now().Unix(),
  1240. Creater: 0,
  1241. Modifier: 0,
  1242. OrgId: item.Id,
  1243. Status: 1,
  1244. Type: 1,
  1245. Number: 12,
  1246. }
  1247. service.AddSigleGoodType(goodTypes11)
  1248. goodTypes12 := &models.GoodsType{
  1249. TypeCode: "14000012",
  1250. TypeName: "血液透析导管",
  1251. Remark: "",
  1252. Ctime: time.Now().Unix(),
  1253. Mtime: time.Now().Unix(),
  1254. Creater: 0,
  1255. Modifier: 0,
  1256. OrgId: item.Id,
  1257. Status: 1,
  1258. Type: 1,
  1259. Number: 13,
  1260. }
  1261. service.AddSigleGoodType(goodTypes12)
  1262. }
  1263. }
  1264. }
  1265. func (c *PublicApiController) HandleComData() {
  1266. org_ids := []int64{3907, 9779, 9883}
  1267. for _, id := range org_ids {
  1268. //查处所有处方记录
  1269. prescriptions, _ := service.FindAllPrescription(id)
  1270. if id == 3907 {
  1271. for _, item := range prescriptions {
  1272. if item.Niprocart > 0 {
  1273. before := &models.DialysisBeforePrepare{
  1274. UserOrgId: id,
  1275. PatientId: item.PatientId,
  1276. RecordDate: item.RecordDate,
  1277. Count: 1,
  1278. Ctime: item.RecordDate,
  1279. Mtime: item.RecordDate,
  1280. Creater: item.Creater,
  1281. Modifier: item.Creater,
  1282. Status: 1,
  1283. }
  1284. before.GoodId = item.Niprocart
  1285. before.GoodTypeId = 241
  1286. service.AddSigleDialysisBeforePre(before)
  1287. }
  1288. if item.Jms > 0 {
  1289. before := &models.DialysisBeforePrepare{
  1290. UserOrgId: id,
  1291. PatientId: item.PatientId,
  1292. RecordDate: item.RecordDate,
  1293. Count: 1,
  1294. Ctime: item.RecordDate,
  1295. Mtime: item.RecordDate,
  1296. Creater: item.Creater,
  1297. Modifier: item.Creater,
  1298. Status: 1,
  1299. }
  1300. before.GoodId = item.Jms
  1301. before.GoodTypeId = 233
  1302. service.AddSigleDialysisBeforePre(before)
  1303. }
  1304. if item.FistulaNeedleSet > 0 {
  1305. before := &models.DialysisBeforePrepare{
  1306. UserOrgId: id,
  1307. PatientId: item.PatientId,
  1308. RecordDate: item.RecordDate,
  1309. Count: 1,
  1310. Ctime: item.RecordDate,
  1311. Mtime: item.RecordDate,
  1312. Creater: item.Creater,
  1313. Modifier: item.Creater,
  1314. Status: 1,
  1315. }
  1316. before.GoodId = item.FistulaNeedleSet
  1317. before.GoodTypeId = 233
  1318. service.AddSigleDialysisBeforePre(before)
  1319. }
  1320. if item.FistulaNeedleSet16 > 0 {
  1321. before := &models.DialysisBeforePrepare{
  1322. UserOrgId: id,
  1323. PatientId: item.PatientId,
  1324. RecordDate: item.RecordDate,
  1325. Count: 1,
  1326. Ctime: item.RecordDate,
  1327. Mtime: item.RecordDate,
  1328. Creater: item.Creater,
  1329. Modifier: item.Creater,
  1330. Status: 1,
  1331. }
  1332. before.GoodId = item.FistulaNeedleSet16
  1333. before.GoodTypeId = 233
  1334. service.AddSigleDialysisBeforePre(before)
  1335. }
  1336. if item.Hemoperfusion > 0 {
  1337. before := &models.DialysisBeforePrepare{
  1338. UserOrgId: id,
  1339. PatientId: item.PatientId,
  1340. RecordDate: item.RecordDate,
  1341. Count: 1,
  1342. Ctime: item.RecordDate,
  1343. Mtime: item.RecordDate,
  1344. Creater: item.Creater,
  1345. Modifier: item.Creater,
  1346. Status: 1,
  1347. }
  1348. before.GoodId = item.Hemoperfusion
  1349. before.GoodTypeId = 235
  1350. service.AddSigleDialysisBeforePre(before)
  1351. }
  1352. if item.DialyserSterilised > 0 {
  1353. before := &models.DialysisBeforePrepare{
  1354. UserOrgId: id,
  1355. PatientId: item.PatientId,
  1356. RecordDate: item.RecordDate,
  1357. Count: 1,
  1358. Ctime: item.RecordDate,
  1359. Mtime: item.RecordDate,
  1360. Creater: item.Creater,
  1361. Modifier: item.Creater,
  1362. Status: 1,
  1363. }
  1364. before.GoodId = item.DialyserSterilised
  1365. before.GoodTypeId = 234
  1366. service.AddSigleDialysisBeforePre(before)
  1367. }
  1368. if item.Filtryzer > 0 {
  1369. before := &models.DialysisBeforePrepare{
  1370. UserOrgId: id,
  1371. PatientId: item.PatientId,
  1372. RecordDate: item.RecordDate,
  1373. Count: 1,
  1374. Ctime: item.RecordDate,
  1375. Mtime: item.RecordDate,
  1376. Creater: item.Creater,
  1377. Modifier: item.Creater,
  1378. Status: 1,
  1379. }
  1380. before.GoodId = item.Filtryzer
  1381. before.GoodTypeId = 234
  1382. service.AddSigleDialysisBeforePre(before)
  1383. }
  1384. if item.Dialyzers > 0 {
  1385. before := &models.DialysisBeforePrepare{
  1386. UserOrgId: id,
  1387. PatientId: item.PatientId,
  1388. RecordDate: item.RecordDate,
  1389. Count: 1,
  1390. Ctime: item.RecordDate,
  1391. Mtime: item.RecordDate,
  1392. Creater: item.Creater,
  1393. Modifier: item.Creater,
  1394. Status: 1,
  1395. }
  1396. before.GoodId = item.Dialyzers
  1397. before.GoodTypeId = 234
  1398. service.AddSigleDialysisBeforePre(before)
  1399. }
  1400. if item.Injector > 0 {
  1401. before := &models.DialysisBeforePrepare{
  1402. UserOrgId: id,
  1403. PatientId: item.PatientId,
  1404. RecordDate: item.RecordDate,
  1405. Count: 1,
  1406. Ctime: item.RecordDate,
  1407. Mtime: item.RecordDate,
  1408. Creater: item.Creater,
  1409. Modifier: item.Creater,
  1410. Status: 1,
  1411. }
  1412. before.GoodId = item.Injector
  1413. before.GoodTypeId = 238
  1414. service.AddSigleDialysisBeforePre(before)
  1415. }
  1416. if item.Bloodlines > 0 {
  1417. before := &models.DialysisBeforePrepare{
  1418. UserOrgId: id,
  1419. PatientId: item.PatientId,
  1420. RecordDate: item.RecordDate,
  1421. Count: 1,
  1422. Ctime: item.RecordDate,
  1423. Mtime: item.RecordDate,
  1424. Creater: item.Creater,
  1425. Modifier: item.Creater,
  1426. Status: 1,
  1427. }
  1428. before.GoodId = item.Bloodlines
  1429. before.GoodTypeId = 236
  1430. service.AddSigleDialysisBeforePre(before)
  1431. }
  1432. if item.TubingHemodialysis > 0 {
  1433. before := &models.DialysisBeforePrepare{
  1434. UserOrgId: id,
  1435. PatientId: item.PatientId,
  1436. RecordDate: item.RecordDate,
  1437. Count: 1,
  1438. Ctime: item.RecordDate,
  1439. Mtime: item.RecordDate,
  1440. Creater: item.Creater,
  1441. Modifier: item.Creater,
  1442. Status: 1,
  1443. }
  1444. before.GoodId = item.TubingHemodialysis
  1445. before.GoodTypeId = 237
  1446. service.AddSigleDialysisBeforePre(before)
  1447. }
  1448. if item.Package > 0 {
  1449. before := &models.DialysisBeforePrepare{
  1450. UserOrgId: id,
  1451. PatientId: item.PatientId,
  1452. RecordDate: item.RecordDate,
  1453. Count: 1,
  1454. Ctime: item.RecordDate,
  1455. Mtime: item.RecordDate,
  1456. Creater: item.Creater,
  1457. Modifier: item.Creater,
  1458. Status: 1,
  1459. }
  1460. before.GoodId = item.Package
  1461. before.GoodTypeId = 239
  1462. service.AddSigleDialysisBeforePre(before)
  1463. }
  1464. if item.ALiquid > 0 {
  1465. before := &models.DialysisBeforePrepare{
  1466. UserOrgId: id,
  1467. PatientId: item.PatientId,
  1468. RecordDate: item.RecordDate,
  1469. Count: 1,
  1470. Ctime: item.RecordDate,
  1471. Mtime: item.RecordDate,
  1472. Creater: item.Creater,
  1473. Modifier: item.Creater,
  1474. Status: 1,
  1475. }
  1476. before.GoodId = item.ALiquid
  1477. before.GoodTypeId = 242
  1478. service.AddSigleDialysisBeforePre(before)
  1479. }
  1480. }
  1481. } else if id == 9779 {
  1482. for _, item := range prescriptions {
  1483. if item.Niprocart > 0 {
  1484. before := &models.DialysisBeforePrepare{
  1485. UserOrgId: id,
  1486. PatientId: item.PatientId,
  1487. RecordDate: item.RecordDate,
  1488. Count: 1,
  1489. Ctime: item.RecordDate,
  1490. Mtime: item.RecordDate,
  1491. Creater: item.Creater,
  1492. Modifier: item.Creater,
  1493. Status: 1,
  1494. }
  1495. before.GoodId = item.Niprocart
  1496. before.GoodTypeId = 254
  1497. service.AddSigleDialysisBeforePre(before)
  1498. }
  1499. if item.Jms > 0 {
  1500. before := &models.DialysisBeforePrepare{
  1501. UserOrgId: id,
  1502. PatientId: item.PatientId,
  1503. RecordDate: item.RecordDate,
  1504. Count: 1,
  1505. Ctime: item.RecordDate,
  1506. Mtime: item.RecordDate,
  1507. Creater: item.Creater,
  1508. Modifier: item.Creater,
  1509. Status: 1,
  1510. }
  1511. before.GoodId = item.Jms
  1512. before.GoodTypeId = 246
  1513. service.AddSigleDialysisBeforePre(before)
  1514. }
  1515. if item.FistulaNeedleSet > 0 {
  1516. before := &models.DialysisBeforePrepare{
  1517. UserOrgId: id,
  1518. PatientId: item.PatientId,
  1519. RecordDate: item.RecordDate,
  1520. Count: 1,
  1521. Ctime: item.RecordDate,
  1522. Mtime: item.RecordDate,
  1523. Creater: item.Creater,
  1524. Modifier: item.Creater,
  1525. Status: 1,
  1526. }
  1527. before.GoodId = item.FistulaNeedleSet
  1528. before.GoodTypeId = 246
  1529. service.AddSigleDialysisBeforePre(before)
  1530. }
  1531. if item.FistulaNeedleSet16 > 0 {
  1532. before := &models.DialysisBeforePrepare{
  1533. UserOrgId: id,
  1534. PatientId: item.PatientId,
  1535. RecordDate: item.RecordDate,
  1536. Count: 1,
  1537. Ctime: item.RecordDate,
  1538. Mtime: item.RecordDate,
  1539. Creater: item.Creater,
  1540. Modifier: item.Creater,
  1541. Status: 1,
  1542. }
  1543. before.GoodId = item.FistulaNeedleSet16
  1544. before.GoodTypeId = 246
  1545. service.AddSigleDialysisBeforePre(before)
  1546. }
  1547. if item.Hemoperfusion > 0 {
  1548. before := &models.DialysisBeforePrepare{
  1549. UserOrgId: id,
  1550. PatientId: item.PatientId,
  1551. RecordDate: item.RecordDate,
  1552. Count: 1,
  1553. Ctime: item.RecordDate,
  1554. Mtime: item.RecordDate,
  1555. Creater: item.Creater,
  1556. Modifier: item.Creater,
  1557. Status: 1,
  1558. }
  1559. before.GoodId = item.Hemoperfusion
  1560. before.GoodTypeId = 248
  1561. service.AddSigleDialysisBeforePre(before)
  1562. }
  1563. if item.DialyserSterilised > 0 {
  1564. before := &models.DialysisBeforePrepare{
  1565. UserOrgId: id,
  1566. PatientId: item.PatientId,
  1567. RecordDate: item.RecordDate,
  1568. Count: 1,
  1569. Ctime: item.RecordDate,
  1570. Mtime: item.RecordDate,
  1571. Creater: item.Creater,
  1572. Modifier: item.Creater,
  1573. Status: 1,
  1574. }
  1575. before.GoodId = item.DialyserSterilised
  1576. before.GoodTypeId = 247
  1577. service.AddSigleDialysisBeforePre(before)
  1578. }
  1579. if item.Filtryzer > 0 {
  1580. before := &models.DialysisBeforePrepare{
  1581. UserOrgId: id,
  1582. PatientId: item.PatientId,
  1583. RecordDate: item.RecordDate,
  1584. Count: 1,
  1585. Ctime: item.RecordDate,
  1586. Mtime: item.RecordDate,
  1587. Creater: item.Creater,
  1588. Modifier: item.Creater,
  1589. Status: 1,
  1590. }
  1591. before.GoodId = item.Filtryzer
  1592. before.GoodTypeId = 247
  1593. service.AddSigleDialysisBeforePre(before)
  1594. }
  1595. if item.Dialyzers > 0 {
  1596. before := &models.DialysisBeforePrepare{
  1597. UserOrgId: id,
  1598. PatientId: item.PatientId,
  1599. RecordDate: item.RecordDate,
  1600. Count: 1,
  1601. Ctime: item.RecordDate,
  1602. Mtime: item.RecordDate,
  1603. Creater: item.Creater,
  1604. Modifier: item.Creater,
  1605. Status: 1,
  1606. }
  1607. before.GoodId = item.Dialyzers
  1608. before.GoodTypeId = 247
  1609. service.AddSigleDialysisBeforePre(before)
  1610. }
  1611. if item.Injector > 0 {
  1612. before := &models.DialysisBeforePrepare{
  1613. UserOrgId: id,
  1614. PatientId: item.PatientId,
  1615. RecordDate: item.RecordDate,
  1616. Count: 1,
  1617. Ctime: item.RecordDate,
  1618. Mtime: item.RecordDate,
  1619. Creater: item.Creater,
  1620. Modifier: item.Creater,
  1621. Status: 1,
  1622. }
  1623. before.GoodId = item.Injector
  1624. before.GoodTypeId = 251
  1625. service.AddSigleDialysisBeforePre(before)
  1626. }
  1627. if item.Bloodlines > 0 {
  1628. before := &models.DialysisBeforePrepare{
  1629. UserOrgId: id,
  1630. PatientId: item.PatientId,
  1631. RecordDate: item.RecordDate,
  1632. Count: 1,
  1633. Ctime: item.RecordDate,
  1634. Mtime: item.RecordDate,
  1635. Creater: item.Creater,
  1636. Modifier: item.Creater,
  1637. Status: 1,
  1638. }
  1639. before.GoodId = item.Bloodlines
  1640. before.GoodTypeId = 249
  1641. service.AddSigleDialysisBeforePre(before)
  1642. }
  1643. if item.TubingHemodialysis > 0 {
  1644. before := &models.DialysisBeforePrepare{
  1645. UserOrgId: id,
  1646. PatientId: item.PatientId,
  1647. RecordDate: item.RecordDate,
  1648. Count: 1,
  1649. Ctime: item.RecordDate,
  1650. Mtime: item.RecordDate,
  1651. Creater: item.Creater,
  1652. Modifier: item.Creater,
  1653. Status: 1,
  1654. }
  1655. before.GoodId = item.TubingHemodialysis
  1656. before.GoodTypeId = 250
  1657. service.AddSigleDialysisBeforePre(before)
  1658. }
  1659. if item.Package > 0 {
  1660. before := &models.DialysisBeforePrepare{
  1661. UserOrgId: id,
  1662. PatientId: item.PatientId,
  1663. RecordDate: item.RecordDate,
  1664. Count: 1,
  1665. Ctime: item.RecordDate,
  1666. Mtime: item.RecordDate,
  1667. Creater: item.Creater,
  1668. Modifier: item.Creater,
  1669. Status: 1,
  1670. }
  1671. before.GoodId = item.Package
  1672. before.GoodTypeId = 252
  1673. service.AddSigleDialysisBeforePre(before)
  1674. }
  1675. if item.ALiquid > 0 {
  1676. before := &models.DialysisBeforePrepare{
  1677. UserOrgId: id,
  1678. PatientId: item.PatientId,
  1679. RecordDate: item.RecordDate,
  1680. Count: 1,
  1681. Ctime: item.RecordDate,
  1682. Mtime: item.RecordDate,
  1683. Creater: item.Creater,
  1684. Modifier: item.Creater,
  1685. Status: 1,
  1686. }
  1687. before.GoodId = item.ALiquid
  1688. before.GoodTypeId = 255
  1689. service.AddSigleDialysisBeforePre(before)
  1690. }
  1691. }
  1692. } else if id == 9883 {
  1693. for _, item := range prescriptions {
  1694. if item.Niprocart > 0 {
  1695. before := &models.DialysisBeforePrepare{
  1696. UserOrgId: id,
  1697. PatientId: item.PatientId,
  1698. RecordDate: item.RecordDate,
  1699. Count: 1,
  1700. Ctime: item.RecordDate,
  1701. Mtime: item.RecordDate,
  1702. Creater: item.Creater,
  1703. Modifier: item.Creater,
  1704. Status: 1,
  1705. }
  1706. before.GoodId = item.Niprocart
  1707. before.GoodTypeId = 267
  1708. service.AddSigleDialysisBeforePre(before)
  1709. }
  1710. if item.Jms > 0 {
  1711. before := &models.DialysisBeforePrepare{
  1712. UserOrgId: id,
  1713. PatientId: item.PatientId,
  1714. RecordDate: item.RecordDate,
  1715. Count: 1,
  1716. Ctime: item.RecordDate,
  1717. Mtime: item.RecordDate,
  1718. Creater: item.Creater,
  1719. Modifier: item.Creater,
  1720. Status: 1,
  1721. }
  1722. before.GoodId = item.Jms
  1723. before.GoodTypeId = 259
  1724. service.AddSigleDialysisBeforePre(before)
  1725. }
  1726. if item.FistulaNeedleSet > 0 {
  1727. before := &models.DialysisBeforePrepare{
  1728. UserOrgId: id,
  1729. PatientId: item.PatientId,
  1730. RecordDate: item.RecordDate,
  1731. Count: 1,
  1732. Ctime: item.RecordDate,
  1733. Mtime: item.RecordDate,
  1734. Creater: item.Creater,
  1735. Modifier: item.Creater,
  1736. Status: 1,
  1737. }
  1738. before.GoodId = item.FistulaNeedleSet
  1739. before.GoodTypeId = 259
  1740. service.AddSigleDialysisBeforePre(before)
  1741. }
  1742. if item.FistulaNeedleSet16 > 0 {
  1743. before := &models.DialysisBeforePrepare{
  1744. UserOrgId: id,
  1745. PatientId: item.PatientId,
  1746. RecordDate: item.RecordDate,
  1747. Count: 1,
  1748. Ctime: item.RecordDate,
  1749. Mtime: item.RecordDate,
  1750. Creater: item.Creater,
  1751. Modifier: item.Creater,
  1752. Status: 1,
  1753. }
  1754. before.GoodId = item.FistulaNeedleSet16
  1755. before.GoodTypeId = 259
  1756. service.AddSigleDialysisBeforePre(before)
  1757. }
  1758. if item.Hemoperfusion > 0 {
  1759. before := &models.DialysisBeforePrepare{
  1760. UserOrgId: id,
  1761. PatientId: item.PatientId,
  1762. RecordDate: item.RecordDate,
  1763. Count: 1,
  1764. Ctime: item.RecordDate,
  1765. Mtime: item.RecordDate,
  1766. Creater: item.Creater,
  1767. Modifier: item.Creater,
  1768. Status: 1,
  1769. }
  1770. before.GoodId = item.Hemoperfusion
  1771. before.GoodTypeId = 261
  1772. service.AddSigleDialysisBeforePre(before)
  1773. }
  1774. if item.DialyserSterilised > 0 {
  1775. before := &models.DialysisBeforePrepare{
  1776. UserOrgId: id,
  1777. PatientId: item.PatientId,
  1778. RecordDate: item.RecordDate,
  1779. Count: 1,
  1780. Ctime: item.RecordDate,
  1781. Mtime: item.RecordDate,
  1782. Creater: item.Creater,
  1783. Modifier: item.Creater,
  1784. Status: 1,
  1785. }
  1786. before.GoodId = item.DialyserSterilised
  1787. before.GoodTypeId = 260
  1788. service.AddSigleDialysisBeforePre(before)
  1789. }
  1790. if item.Filtryzer > 0 {
  1791. before := &models.DialysisBeforePrepare{
  1792. UserOrgId: id,
  1793. PatientId: item.PatientId,
  1794. RecordDate: item.RecordDate,
  1795. Count: 1,
  1796. Ctime: item.RecordDate,
  1797. Mtime: item.RecordDate,
  1798. Creater: item.Creater,
  1799. Modifier: item.Creater,
  1800. Status: 1,
  1801. }
  1802. before.GoodId = item.Filtryzer
  1803. before.GoodTypeId = 260
  1804. service.AddSigleDialysisBeforePre(before)
  1805. }
  1806. if item.Dialyzers > 0 {
  1807. before := &models.DialysisBeforePrepare{
  1808. UserOrgId: id,
  1809. PatientId: item.PatientId,
  1810. RecordDate: item.RecordDate,
  1811. Count: 1,
  1812. Ctime: item.RecordDate,
  1813. Mtime: item.RecordDate,
  1814. Creater: item.Creater,
  1815. Modifier: item.Creater,
  1816. Status: 1,
  1817. }
  1818. before.GoodId = item.Dialyzers
  1819. before.GoodTypeId = 260
  1820. service.AddSigleDialysisBeforePre(before)
  1821. }
  1822. if item.Injector > 0 {
  1823. before := &models.DialysisBeforePrepare{
  1824. UserOrgId: id,
  1825. PatientId: item.PatientId,
  1826. RecordDate: item.RecordDate,
  1827. Count: 1,
  1828. Ctime: item.RecordDate,
  1829. Mtime: item.RecordDate,
  1830. Creater: item.Creater,
  1831. Modifier: item.Creater,
  1832. Status: 1,
  1833. }
  1834. before.GoodId = item.Injector
  1835. before.GoodTypeId = 264
  1836. service.AddSigleDialysisBeforePre(before)
  1837. }
  1838. if item.Bloodlines > 0 {
  1839. before := &models.DialysisBeforePrepare{
  1840. UserOrgId: id,
  1841. PatientId: item.PatientId,
  1842. RecordDate: item.RecordDate,
  1843. Count: 1,
  1844. Ctime: item.RecordDate,
  1845. Mtime: item.RecordDate,
  1846. Creater: item.Creater,
  1847. Modifier: item.Creater,
  1848. Status: 1,
  1849. }
  1850. before.GoodId = item.Bloodlines
  1851. before.GoodTypeId = 262
  1852. service.AddSigleDialysisBeforePre(before)
  1853. }
  1854. if item.TubingHemodialysis > 0 {
  1855. before := &models.DialysisBeforePrepare{
  1856. UserOrgId: id,
  1857. PatientId: item.PatientId,
  1858. RecordDate: item.RecordDate,
  1859. Count: 1,
  1860. Ctime: item.RecordDate,
  1861. Mtime: item.RecordDate,
  1862. Creater: item.Creater,
  1863. Modifier: item.Creater,
  1864. Status: 1,
  1865. }
  1866. before.GoodId = item.TubingHemodialysis
  1867. before.GoodTypeId = 263
  1868. service.AddSigleDialysisBeforePre(before)
  1869. }
  1870. if item.Package > 0 {
  1871. before := &models.DialysisBeforePrepare{
  1872. UserOrgId: id,
  1873. PatientId: item.PatientId,
  1874. RecordDate: item.RecordDate,
  1875. Count: 1,
  1876. Ctime: item.RecordDate,
  1877. Mtime: item.RecordDate,
  1878. Creater: item.Creater,
  1879. Modifier: item.Creater,
  1880. Status: 1,
  1881. }
  1882. before.GoodId = item.Package
  1883. before.GoodTypeId = 265
  1884. service.AddSigleDialysisBeforePre(before)
  1885. }
  1886. if item.ALiquid > 0 {
  1887. before := &models.DialysisBeforePrepare{
  1888. UserOrgId: id,
  1889. PatientId: item.PatientId,
  1890. RecordDate: item.RecordDate,
  1891. Count: 1,
  1892. Ctime: item.RecordDate,
  1893. Mtime: item.RecordDate,
  1894. Creater: item.Creater,
  1895. Modifier: item.Creater,
  1896. Status: 1,
  1897. }
  1898. before.GoodId = item.ALiquid
  1899. before.GoodTypeId = 268
  1900. service.AddSigleDialysisBeforePre(before)
  1901. }
  1902. }
  1903. }
  1904. }
  1905. }
  1906. func (c *PublicApiController) HandleHIS() {
  1907. his, _ := service.GetAllHisInfo(9919)
  1908. for _, item := range his {
  1909. fsn := strings.Split(item.FeedetlSn, "-")
  1910. item.FeedetlSn = fsn[0] + "-" + fsn[1] + "-" + strconv.FormatInt(item.ID, 10)
  1911. fmt.Println(item.FeedetlSn)
  1912. service.UpDateHis2(item)
  1913. }
  1914. }
  1915. func (c *PublicApiController) HandleOrder() {
  1916. orders, _ := service.GetAllHisOrder(10106)
  1917. record, _ := service.FindFapiaoByIsUse(10106)
  1918. last_order, _ := service.GetAllHisOrderTwo(10106)
  1919. if record.ID > 0 {
  1920. for index, item := range orders {
  1921. item.FaPiaoCode = record.FapiaoCode
  1922. var zero string
  1923. max_number, _ := strconv.ParseInt(last_order.FaPiaoNumber, 10, 64)
  1924. number, _ := strconv.ParseInt(record.FapiaoNumber, 10, 64)
  1925. number = number + max_number
  1926. if number+int64(index) >= 1000 {
  1927. zero = "0000" + strconv.FormatInt(number+int64(index), 10)
  1928. } else if number+int64(index) >= 10000 {
  1929. zero = "000" + strconv.FormatInt(number+int64(index), 10)
  1930. } else if number+int64(index) >= 100000 {
  1931. zero = "00" + strconv.FormatInt(number+int64(index), 10)
  1932. } else if number+int64(index) >= 1000000 {
  1933. zero = "0" + strconv.FormatInt(number+int64(index), 10)
  1934. } else {
  1935. zero = strconv.FormatInt(number+int64(index), 10)
  1936. }
  1937. item.FaPiaoNumber = zero
  1938. item.FaPiaoBatchnumberId = record.ID
  1939. service.SaveOrder(item)
  1940. }
  1941. }
  1942. }
  1943. func Mkdir(dir string) {
  1944. // 创建文件夹
  1945. exist, err := PathExists(dir)
  1946. if err != nil {
  1947. fmt.Println(err.Error())
  1948. } else {
  1949. if exist {
  1950. fmt.Println(dir + "文件夹已存在!")
  1951. } else {
  1952. // 文件夹名称,权限
  1953. err := os.Mkdir(dir, os.ModePerm)
  1954. if err != nil {
  1955. fmt.Println(dir+"文件夹创建失败:", err.Error())
  1956. } else {
  1957. fmt.Println(dir + "文件夹创建成功!")
  1958. }
  1959. }
  1960. }
  1961. }
  1962. func PathExists(path string) (bool, error) {
  1963. _, err := os.Stat(path)
  1964. if err == nil {
  1965. return true, nil
  1966. }
  1967. if os.IsNotExist(err) {
  1968. return false, nil
  1969. }
  1970. return false, err
  1971. }
  1972. func (c *PublicApiController) Handle10215() {
  1973. //projects,_ := service.GetAllInfo(10215,2284)
  1974. //
  1975. //for _, item := range projects{
  1976. // service.UpdateStatus(item.ID, item.PrescriptionId)
  1977. //}
  1978. //projects_two,_ := service.GetAllInfo(10215,2277)
  1979. //
  1980. //for _, item := range projects_two{
  1981. // service.UpdateStatus(item.ID, item.PrescriptionId)
  1982. //}
  1983. //service.GetAllInfo(10215,2284)
  1984. //service.GetAllInfo(10215,2277)
  1985. his, _ := service.GetAllPT(10215)
  1986. for _, item := range his {
  1987. //
  1988. //pro := &models.HisPrescriptionProjectTemplate{
  1989. // ProjectId: 1750,
  1990. // Price: 6.00,
  1991. // UserOrgId: 10215,
  1992. // Status: 1,
  1993. // Ctime: time.Now().Unix(),
  1994. // Mtime: time.Now().Unix(),
  1995. // PatientId: item.PatientId,
  1996. // RecordDate: 0,
  1997. // Count: 1,
  1998. // FeedetlSn: "",
  1999. // MedListCodg: "",
  2000. // SingleDose: "1",
  2001. // DeliveryWay: "",
  2002. // ExecutionFrequency: "",
  2003. // Day: "1",
  2004. // Remark: "",
  2005. // Unit: "",
  2006. // Type: 2,
  2007. // PrescriptionId: info.ID,
  2008. // FrequencyType: 1,
  2009. // DayCount: 0,
  2010. // WeekDay: "",
  2011. //}
  2012. //service.CreateHisPrescriptionProjectTemplate(pro)
  2013. //
  2014. //pro2 := &models.HisPrescriptionProjectTemplate{
  2015. // ProjectId: 2462,
  2016. // Price: 4.94,
  2017. // UserOrgId: 10215,
  2018. // Status: 1,
  2019. // Ctime: time.Now().Unix(),
  2020. // Mtime: time.Now().Unix(),
  2021. // PatientId: item.PatientId,
  2022. // RecordDate: 0,
  2023. // Count: 1,
  2024. // FeedetlSn: "",
  2025. // MedListCodg: "",
  2026. // SingleDose: "1",
  2027. // DeliveryWay: "",
  2028. // ExecutionFrequency: "",
  2029. // Day: "1",
  2030. // Remark: "",
  2031. // Unit: "",
  2032. // Type: 3,
  2033. // PrescriptionId: info.ID,
  2034. // FrequencyType: 1,
  2035. // DayCount: 0,
  2036. // WeekDay: "",
  2037. //}
  2038. //service.CreateHisPrescriptionProjectTemplate(pro2)
  2039. //
  2040. //
  2041. infos, _ := service.GetAllPTInfo(10215, item.ID)
  2042. // // fmt.Println(infos)
  2043. for _, subItem := range infos {
  2044. if len(subItem.HisPrescriptionAdviceTemplate) > 0 && len(subItem.HisPrescriptionProjectTemplate) == 0 {
  2045. for _, ssubItem := range subItem.HisPrescriptionAdviceTemplate {
  2046. //if ssubItem.DrugId == 1234 {
  2047. // pro := &models.HisPrescriptionProjectTemplate{
  2048. // ProjectId: 2326,
  2049. // Price: 0.86,
  2050. // UserOrgId: ssubItem.UserOrgId,
  2051. // Status: 1,
  2052. // Ctime: time.Now().Unix(),
  2053. // Mtime: time.Now().Unix(),
  2054. // PatientId: ssubItem.PatientId,
  2055. // RecordDate: ssubItem.AdviceDate,
  2056. // Count: 1,
  2057. // FeedetlSn: "",
  2058. // MedListCodg: "",
  2059. // SingleDose: "1",
  2060. // DeliveryWay: "",
  2061. // ExecutionFrequency: "",
  2062. // Day: "1",
  2063. // Remark: "",
  2064. // Unit: "",
  2065. // Type: 3,
  2066. // PrescriptionId: info.ID,
  2067. // FrequencyType: ssubItem.FrequencyType,
  2068. // DayCount: ssubItem.DayCount,
  2069. // WeekDay: ssubItem.WeekDay,
  2070. // }
  2071. // service.CreateHisPrescriptionProjectTemplate(pro)
  2072. //
  2073. //}
  2074. if ssubItem.DrugId == 1288 {
  2075. info := &models.HisPrescriptionInfoTemplate{
  2076. UserOrgId: item.UserOrgId,
  2077. RecordDate: 0,
  2078. PatientId: item.PatientId,
  2079. Status: 1,
  2080. Ctime: time.Now().Unix(),
  2081. Mtime: time.Now().Unix(),
  2082. Type: 2,
  2083. Creator: 0,
  2084. Modifier: 0,
  2085. PType: 0,
  2086. PTemplateId: item.ID,
  2087. MedType: "14",
  2088. }
  2089. service.CreateHisPrescriptionInfoTemplate(info)
  2090. pro2 := &models.HisPrescriptionProjectTemplate{
  2091. ProjectId: 1727,
  2092. Price: 2.50,
  2093. UserOrgId: ssubItem.UserOrgId,
  2094. Status: 1,
  2095. Ctime: time.Now().Unix(),
  2096. Mtime: time.Now().Unix(),
  2097. PatientId: ssubItem.PatientId,
  2098. RecordDate: ssubItem.AdviceDate,
  2099. Count: "1",
  2100. FeedetlSn: "",
  2101. MedListCodg: "",
  2102. SingleDose: "1",
  2103. DeliveryWay: "",
  2104. ExecutionFrequency: "",
  2105. Day: "1",
  2106. Remark: "",
  2107. Unit: "",
  2108. Type: 2,
  2109. PrescriptionId: info.ID,
  2110. FrequencyType: ssubItem.FrequencyType,
  2111. DayCount: ssubItem.DayCount,
  2112. WeekDay: ssubItem.WeekDay,
  2113. }
  2114. service.CreateHisPrescriptionProjectTemplate(pro2)
  2115. //pro := &models.HisPrescriptionProjectTemplate{
  2116. // ProjectId: 2326,
  2117. // Price: 0.86,
  2118. // UserOrgId: ssubItem.UserOrgId,
  2119. // Status: 1,
  2120. // Ctime: time.Now().Unix(),
  2121. // Mtime: time.Now().Unix(),
  2122. // PatientId: ssubItem.PatientId,
  2123. // RecordDate: ssubItem.AdviceDate,
  2124. // Count: 1,
  2125. // FeedetlSn: "",
  2126. // MedListCodg: "",
  2127. // SingleDose: "1",
  2128. // DeliveryWay: "",
  2129. // ExecutionFrequency: "",
  2130. // Day: "1",
  2131. // Remark: "",
  2132. // Unit: "",
  2133. // Type: 3,
  2134. // PrescriptionId: info.ID,
  2135. // FrequencyType: ssubItem.FrequencyType,
  2136. // DayCount: ssubItem.DayCount,
  2137. // WeekDay: ssubItem.WeekDay,
  2138. //}
  2139. //service.CreateHisPrescriptionProjectTemplate(pro)
  2140. }
  2141. //if ssubItem.DrugId == 1306 {
  2142. //
  2143. // pro := &models.HisPrescriptionProjectTemplate{
  2144. // ProjectId: 2325,
  2145. // Price: 1.11,
  2146. // UserOrgId: ssubItem.UserOrgId,
  2147. // Status: 1,
  2148. // Ctime: time.Now().Unix(),
  2149. // Mtime: time.Now().Unix(),
  2150. // PatientId: ssubItem.PatientId,
  2151. // RecordDate: ssubItem.AdviceDate,
  2152. // Count: 1,
  2153. // FeedetlSn: "",
  2154. // MedListCodg: "",
  2155. // SingleDose: "1",
  2156. // DeliveryWay: "",
  2157. // ExecutionFrequency: "",
  2158. // Day: "1",
  2159. // Remark: "",
  2160. // Unit: "",
  2161. // Type: 3,
  2162. // PrescriptionId: info.ID,
  2163. // FrequencyType: ssubItem.FrequencyType,
  2164. // DayCount: ssubItem.DayCount,
  2165. // WeekDay: ssubItem.WeekDay,
  2166. // }
  2167. // service.CreateHisPrescriptionProjectTemplate(pro)
  2168. //
  2169. // pro2 := &models.HisPrescriptionProjectTemplate{
  2170. // ProjectId: 1727,
  2171. // Price: 2.50,
  2172. // UserOrgId: ssubItem.UserOrgId,
  2173. // Status: 1,
  2174. // Ctime: time.Now().Unix(),
  2175. // Mtime: time.Now().Unix(),
  2176. // PatientId: ssubItem.PatientId,
  2177. // RecordDate: ssubItem.AdviceDate,
  2178. // Count: 1,
  2179. // FeedetlSn: "",
  2180. // MedListCodg: "",
  2181. // SingleDose: "1",
  2182. // DeliveryWay: "",
  2183. // ExecutionFrequency: "",
  2184. // Day: "1",
  2185. // Remark: "",
  2186. // Unit: "",
  2187. // Type: 2,
  2188. // PrescriptionId: info.ID,
  2189. // FrequencyType: ssubItem.FrequencyType,
  2190. // DayCount: ssubItem.DayCount,
  2191. // WeekDay: ssubItem.WeekDay,
  2192. // }
  2193. // service.CreateHisPrescriptionProjectTemplate(pro2)
  2194. //
  2195. //}
  2196. //if ssubItem.DrugId == 1291 {
  2197. //
  2198. // pro := &models.HisPrescriptionProjectTemplate{
  2199. // ProjectId: 2322,
  2200. // Price: 0.68,
  2201. // UserOrgId: ssubItem.UserOrgId,
  2202. // Status: 1,
  2203. // Ctime: time.Now().Unix(),
  2204. // Mtime: time.Now().Unix(),
  2205. // PatientId: ssubItem.PatientId,
  2206. // RecordDate: ssubItem.AdviceDate,
  2207. // Count: 1,
  2208. // FeedetlSn: "",
  2209. // MedListCodg: "",
  2210. // SingleDose: "1",
  2211. // DeliveryWay: "",
  2212. // ExecutionFrequency: "",
  2213. // Day: "1",
  2214. // Remark: "",
  2215. // Unit: "",
  2216. // Type: 3,
  2217. // PrescriptionId: info.ID,
  2218. // FrequencyType: ssubItem.FrequencyType,
  2219. // DayCount: ssubItem.DayCount,
  2220. // WeekDay: ssubItem.WeekDay,
  2221. // }
  2222. // service.CreateHisPrescriptionProjectTemplate(pro)
  2223. //
  2224. // pro2 := &models.HisPrescriptionProjectTemplate{
  2225. // ProjectId: 1727,
  2226. // Price: 2.50,
  2227. // UserOrgId: ssubItem.UserOrgId,
  2228. // Status: 1,
  2229. // Ctime: time.Now().Unix(),
  2230. // Mtime: time.Now().Unix(),
  2231. // PatientId: ssubItem.PatientId,
  2232. // RecordDate: ssubItem.AdviceDate,
  2233. // Count: 1,
  2234. // FeedetlSn: "",
  2235. // MedListCodg: "",
  2236. // SingleDose: "1",
  2237. // DeliveryWay: "",
  2238. // ExecutionFrequency: "",
  2239. // Day: "1",
  2240. // Remark: "",
  2241. // Unit: "",
  2242. // Type: 2,
  2243. // PrescriptionId: info.ID,
  2244. // FrequencyType: ssubItem.FrequencyType,
  2245. // DayCount: ssubItem.DayCount,
  2246. // WeekDay: ssubItem.WeekDay,
  2247. // }
  2248. // service.CreateHisPrescriptionProjectTemplate(pro2)
  2249. //}
  2250. }
  2251. }
  2252. }
  2253. }
  2254. }
  2255. func (c *PublicApiController) HandleExportAllData() {
  2256. orders, _ := service.GetHisOrderDetail9504()
  2257. c.ServeSuccessJSON(map[string]interface{}{
  2258. "order": orders,
  2259. })
  2260. }
  2261. func (c *PublicApiController) HandleExportData10138() {
  2262. orders, _ := service.GetHisOrderDetail10138()
  2263. c.ServeSuccessJSON(map[string]interface{}{
  2264. "order": orders,
  2265. })
  2266. }
  2267. func (c *PublicApiController) HandleData10265() {
  2268. orders, _ := service.GetHisOrder10265()
  2269. for _, items := range orders {
  2270. if items.AdviceId == 0 && items.ProjectId > 0 {
  2271. p, _ := service.GetHisPrescriptionProjectByIDTwo(items.ProjectId)
  2272. if p.Type == 2 {
  2273. if p.HisProject.CostClassify == 3 {
  2274. items.MedChrgitmType = "04"
  2275. }
  2276. if p.HisProject.CostClassify == 2 {
  2277. items.MedChrgitmType = "05"
  2278. }
  2279. if p.HisProject.CostClassify == 8 {
  2280. items.MedChrgitmType = "03"
  2281. }
  2282. //p.HisProject.CostClassify == 8
  2283. } else {
  2284. items.MedChrgitmType = "08"
  2285. }
  2286. }
  2287. service.SaveOrderInfo(items)
  2288. }
  2289. }
  2290. func (c *PublicApiController) HandleData10265two() {
  2291. orders, _ := service.GetHisOrder10265two()
  2292. for _, items := range orders {
  2293. if items.AdviceId == 0 && items.ProjectId > 0 {
  2294. p, _ := service.GetHisPrescriptionProjectByIDTwoone(items.ProjectId)
  2295. if p.Type == 2 {
  2296. if p.HisProject.MedicalCoverage == 1 {
  2297. items.ChrgitmLv = "01"
  2298. } else if p.HisProject.MedicalCoverage == 2 {
  2299. items.ChrgitmLv = "02"
  2300. } else {
  2301. items.ChrgitmLv = "03"
  2302. }
  2303. } else {
  2304. if p.GoodInfo.MedicalInsuranceLevel == 1 {
  2305. items.ChrgitmLv = "01"
  2306. } else if p.GoodInfo.MedicalInsuranceLevel == 2 {
  2307. items.ChrgitmLv = "02"
  2308. } else {
  2309. items.ChrgitmLv = "03"
  2310. }
  2311. }
  2312. }
  2313. if items.AdviceId > 0 && items.ProjectId == 0 {
  2314. info, _ := service.GetHisDoctorAdviceInfo(items.AdviceId)
  2315. if info.Drug.MedicalInsuranceLevel == 1 {
  2316. items.ChrgitmLv = "01"
  2317. } else if info.Drug.MedicalInsuranceLevel == 2 {
  2318. items.ChrgitmLv = "02"
  2319. } else {
  2320. items.ChrgitmLv = "03"
  2321. }
  2322. }
  2323. service.SaveOrderInfo(items)
  2324. }
  2325. }
  2326. //func (c *PublicApiController) HandleOrderInfoData() {
  2327. // orders, _ := service.GetHisOrderInfoDetail()
  2328. // c.ServeSuccessJSON(map[string]interface{}{
  2329. // "info": orders,
  2330. // })
  2331. //}
  2332. //
  2333. //func (c *PublicApiController)HandleOrderInfoData10138(){
  2334. // start_time := c.GetString("start_time")
  2335. // end_time := c.GetString("end_time")
  2336. // timeLayout := "2006-01-02"
  2337. // loc, _ := time.LoadLocation("Local")
  2338. // startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2339. // if err != nil {
  2340. //
  2341. // }
  2342. // startRecordDateTime := startTime.Unix()
  2343. // endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2344. // if err != nil {
  2345. //
  2346. // }
  2347. // endRecordDateTime := endTime.Unix()
  2348. // orders, _ := service.GetHisAllPatientOrder(startRecordDateTime,endRecordDateTime)
  2349. // for _, item := range orders{
  2350. // for _, subItem := range item.HisOrder10138{
  2351. // info, _ := service.GetHisOrderInfoDetail10138(subItem.Number)
  2352. // subItem.VmHisOrderInfo9504 = info
  2353. // }
  2354. // }
  2355. // c.ServeSuccessJSON(map[string]interface{}{
  2356. // "info": orders,
  2357. // })
  2358. //
  2359. //}