public_api_controller.go 71KB

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