public_api_controller.go 53KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035
  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. }
  65. func (c *PublicApiController) GetDoctorAdviceConfig() {
  66. drugs, _, _ := service.GetPublicDrugDics()
  67. drugways, _, _ := service.GetPublicDrugWayDics()
  68. efs, _, _ := service.GetPublicExecutionFrequencyDics()
  69. c.ServeSuccessJSON(map[string]interface{}{
  70. "drugs": drugs,
  71. "drugways": drugways,
  72. "efs": efs,
  73. })
  74. }
  75. func (c *PublicApiController) GetServerTime() {
  76. timeNow := time.Now()
  77. timeNowStamp := timeNow.Unix()
  78. timeNowStr := timeNow.Format("2006-01-02 15:04:05")
  79. c.ServeSuccessJSON(map[string]interface{}{
  80. "time": timeNowStr,
  81. "timestamp": timeNowStamp,
  82. })
  83. }
  84. func (c *PublicApiController) AppRelease() {
  85. // appId := c.GetString("appid")
  86. version := c.GetString("version")
  87. appType, _ := c.GetInt64("app_type", 0)
  88. appVersion, err := service.GetAppVersionByAppType(appType)
  89. if err != nil {
  90. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  91. return
  92. }
  93. if appVersion == nil {
  94. c.ServeSuccessJSON(map[string]interface{}{
  95. "version": nil,
  96. "state": 2,
  97. })
  98. return
  99. }
  100. state := strings.Compare(version, appVersion.Version)
  101. // state := 1
  102. if state < 0 {
  103. c.ServeSuccessJSON(map[string]interface{}{
  104. "version": appVersion,
  105. "state": appVersion.Status,
  106. })
  107. return
  108. }
  109. c.ServeSuccessJSON(map[string]interface{}{
  110. "version": nil,
  111. "state": 2,
  112. })
  113. return
  114. }
  115. func (this *PublicApiController) GetJson() {
  116. type Global struct {
  117. DeviceSN string
  118. Version string
  119. Timestamp string
  120. InterfaceSource string
  121. }
  122. type RBPResultModel struct {
  123. Sys string
  124. Dia string
  125. HR string
  126. MeasureTime string
  127. }
  128. type ScannerResultModel struct {
  129. Code string
  130. }
  131. type IDCardResultModel struct {
  132. IDCardNo string
  133. UserName string
  134. Age string
  135. Female string
  136. Male string
  137. SocialSecurityNo string
  138. }
  139. type JsonTemp struct {
  140. Global Global
  141. RBPResultModel RBPResultModel
  142. ScannerResultModel ScannerResultModel
  143. IDCardResultModel IDCardResultModel
  144. }
  145. var person JsonTemp
  146. err3 := json.Unmarshal([]byte(this.GetString("params")), &person)
  147. fmt.Println(err3)
  148. fmt.Println(person.Global)
  149. //temp := JsonTemp{
  150. // Global:Global{
  151. // DeviceSN:"1122",
  152. // Version:"1122",
  153. // Timestamp:"1222",
  154. // InterfaceSource:"1233",
  155. // },
  156. // RBPResultModel: RBPResultModel{
  157. // Sys:"12",
  158. // Dia:"22",
  159. // HR:"23",
  160. // MeasureTime:"123",
  161. // },
  162. // ScannerResultModel:ScannerResultModel{
  163. // Code:"1233",
  164. // },
  165. // IDCardResultModel:IDCardResultModel{
  166. // IDCardNo:"123",
  167. // UserName:"123",
  168. // Age:"123",
  169. // Female:"123",
  170. // Male:"123",
  171. // SocialSecurityNo:"123",
  172. // },
  173. //}
  174. //
  175. //jsonBytes, err := json.Marshal(temp)
  176. //if err != nil {
  177. // fmt.Println(err)
  178. //}
  179. //fmt.Println(string(jsonBytes))
  180. }
  181. func (c *PublicApiController) HandleData() {
  182. //service.HandleData()
  183. org_app, _ := service.GetAllAppOrg()
  184. //org_role, _ := service.GetAllRole()
  185. //
  186. //var org_ids []int64
  187. for _, apps := range org_app {
  188. xt_org_app, _ := service.GetAppByType(int64(apps.OrgId), 3)
  189. //org_app_6, _ := service.GetAppByType(int64(apps.OrgId), 6)
  190. //org_app_7, _ := service.GetAppByType(int64(apps.OrgId), 7)
  191. //org_app_8, _ := service.GetAppByType(int64(apps.OrgId), 8)
  192. //org_app_9, _ := service.GetAppByType(int64(apps.OrgId), 9)
  193. //org_app_10, _ := service.GetAppByType(int64(apps.OrgId), 10)
  194. //org_app_11, _ := service.GetAppByType(int64(apps.OrgId), 11)
  195. //org_app_12, _ := service.GetAppByType(int64(apps.OrgId), 12)
  196. //org_app_13, _ := service.GetAppByType(int64(apps.OrgId), 13)
  197. //org_app_14, _ := service.GetAppByType(int64(apps.OrgId), 14)
  198. //org_app_15, _ := service.GetAppByType(int64(apps.OrgId), 15)
  199. //org_app_16, _ := service.GetAppByType(int64(apps.OrgId), 16)
  200. //org_app_17, _ := service.GetAppByType(int64(apps.OrgId), 17)
  201. org_app_18, _ := service.GetAppByType(int64(apps.OrgId), 18)
  202. var xt_temp_org_app *models.OrgApp
  203. //var mall_temp_org_app *models.OrgApp
  204. if xt_org_app == nil || xt_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  205. app, _ := service.GetOrgAppA(0, 3)
  206. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  207. if org == nil || org.Id == 0 {
  208. continue
  209. }
  210. app.Id = 0
  211. app.OrgId = apps.OrgId
  212. app.Creator = int(org.Creator)
  213. app.Number = 0
  214. app.Status = 1
  215. app.ModifyTime = time.Now().Unix()
  216. app.CreateTime = time.Now().Unix()
  217. service.CreateOrgApp(app)
  218. xt_temp_org_app = app
  219. } else {
  220. xt_temp_org_app = xt_org_app
  221. }
  222. //if scrm_org_app == nil || scrm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  223. //
  224. // app, _ := service.GetOrgAppA(0, 1)
  225. // //org, _ := service.GetOrgById(int64(12))
  226. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  227. // if org == nil || org.Id == 0 {
  228. // continue
  229. // }
  230. //
  231. //
  232. // app.OrgId = apps.OrgId
  233. // app.Id = 0
  234. //
  235. // app.Creator = int(org.Creator)
  236. // app.Number = 0
  237. // app.Status = 1
  238. // app.ModifyTime = time.Now().Unix()
  239. // app.CreateTime = time.Now().Unix()
  240. // service.CreateOrgApp(app)
  241. //
  242. //}
  243. //
  244. //if cdm_org_app == nil || cdm_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  245. // app, _ := service.GetOrgAppA(0, 4)
  246. // //org, _ := service.GetOrgById(int64(12))
  247. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  248. // if org == nil || org.Id == 0 {
  249. // continue
  250. // }
  251. //
  252. //
  253. // app.OrgId = apps.OrgId
  254. // app.Creator = int(org.Creator)
  255. // app.Number = 0
  256. // app.Id = 0
  257. //
  258. // app.Status = 1
  259. // app.ModifyTime = time.Now().Unix()
  260. // app.CreateTime = time.Now().Unix()
  261. // service.CreateOrgApp(app)
  262. //}
  263. //
  264. //if mall_org_app == nil || mall_org_app.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  265. // app, _ := service.GetOrgAppA(0, 5)
  266. // //org, _ := service.GetOrgById(int64(12))
  267. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  268. //
  269. // if org == nil || org.Id == 0 {
  270. // continue
  271. // }
  272. //
  273. // app.OrgId = apps.OrgId
  274. // app.Creator = int(org.Creator)
  275. // app.Number = 0
  276. // app.Id = 0
  277. //
  278. // app.Status = 1
  279. // app.ModifyTime = time.Now().Unix()
  280. // app.CreateTime = time.Now().Unix()
  281. // service.CreateOrgApp(app)
  282. // mall_temp_org_app = app
  283. //} else {
  284. // mall_temp_org_app = mall_org_app
  285. //}
  286. //
  287. //if org_app_16 == nil || org_app_16.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  288. // app, _ := service.GetOrgAppA(0, 16)
  289. // //org, _ := service.GetOrgById(int64(12))
  290. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  291. // if org == nil || org.Id == 0 {
  292. // continue
  293. // }
  294. //
  295. // app.OrgId = apps.OrgId
  296. // app.Creator = int(org.Creator)
  297. // app.Number = 11
  298. // app.Id = 0
  299. // app.Status = 1
  300. // app.ModifyTime = time.Now().Unix()
  301. // app.CreateTime = time.Now().Unix()
  302. // app.Pid = xt_temp_org_app.Id
  303. // service.CreateOrgApp(app)
  304. //
  305. //}
  306. //
  307. //if org_app_17 == nil || org_app_17.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  308. // app, _ := service.GetOrgAppA(0, 17)
  309. // //org, _ := service.GetOrgById(int64(12))
  310. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  311. // if org == nil || org.Id == 0 {
  312. // continue
  313. // }
  314. //
  315. // app.OrgId = apps.OrgId
  316. // app.Creator = int(org.Creator)
  317. // app.Number = 12
  318. // app.Id = 0
  319. // app.Status = 1
  320. // app.ModifyTime = time.Now().Unix()
  321. // app.CreateTime = time.Now().Unix()
  322. // app.Pid = xt_temp_org_app.Id
  323. // service.CreateOrgApp(app)
  324. //
  325. //}
  326. if org_app_18 == nil || org_app_18.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  327. app, _ := service.GetOrgAppA(0, 18)
  328. //org, _ := service.GetOrgById(int64(12))
  329. org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  330. if org == nil || org.Id == 0 {
  331. continue
  332. }
  333. app.OrgId = apps.OrgId
  334. app.Creator = int(org.Creator)
  335. app.Number = 5
  336. app.Id = 0
  337. app.Status = 1
  338. app.ModifyTime = time.Now().Unix()
  339. app.CreateTime = time.Now().Unix()
  340. app.Pid = xt_temp_org_app.Id
  341. service.CreateOrgApp(app)
  342. }
  343. //if org_app_7 == nil || org_app_7.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  344. // app, _ := service.GetOrgAppA(0, 7)
  345. // //org, _ := service.GetOrgById(int64(12))
  346. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  347. // if org == nil || org.Id == 0 {
  348. // continue
  349. // }
  350. //
  351. //
  352. // app.OrgId = apps.OrgId
  353. // app.Creator = int(org.Creator)
  354. // app.Number = 2
  355. // app.Status = 2
  356. // app.Id = 0
  357. //
  358. // app.ModifyTime = time.Now().Unix()
  359. // app.CreateTime = time.Now().Unix()
  360. // app.Pid = xt_temp_org_app.Id
  361. //
  362. // service.CreateOrgApp(app)
  363. //}
  364. //if org_app_8 == nil || org_app_8.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  365. // app, _ := service.GetOrgAppA(0, 8)
  366. // //org, _ := service.GetOrgById(int64(12))
  367. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  368. // if org == nil || org.Id == 0 {
  369. // continue
  370. // }
  371. //
  372. //
  373. // app.OrgId = apps.OrgId
  374. // app.Creator = int(org.Creator)
  375. // app.Number = 3
  376. // app.Id = 0
  377. //
  378. // app.Pid = mall_temp_org_app.Id
  379. //
  380. // app.Status = 1
  381. // app.ModifyTime = time.Now().Unix()
  382. // app.CreateTime = time.Now().Unix()
  383. // service.CreateOrgApp(app)
  384. //}
  385. //if org_app_9 == nil || org_app_9.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  386. // app, _ := service.GetOrgAppA(0, 9)
  387. // //org, _ := service.GetOrgById(int64(12))
  388. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  389. // if org == nil || org.Id == 0 {
  390. // continue
  391. // }
  392. //
  393. //
  394. // app.OrgId = apps.OrgId
  395. // app.Pid = xt_temp_org_app.Id
  396. //
  397. // app.Creator = int(org.Creator)
  398. // app.Number = 4
  399. // app.Id = 0
  400. //
  401. // app.Status = 1
  402. // app.ModifyTime = time.Now().Unix()
  403. // app.CreateTime = time.Now().Unix()
  404. // service.CreateOrgApp(app)
  405. //
  406. //}
  407. //if org_app_10 == nil || org_app_10.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  408. // app, _ := service.GetOrgAppA(0, 10)
  409. // //org, _ := service.GetOrgById(int64(12))
  410. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  411. // if org == nil || org.Id == 0 {
  412. // continue
  413. // }
  414. //
  415. //
  416. // app.OrgId = apps.OrgId
  417. // app.Creator = int(org.Creator)
  418. // app.Pid = xt_temp_org_app.Id
  419. //
  420. // app.Number = 5
  421. // app.Id = 0
  422. //
  423. // app.Status = 1
  424. // app.ModifyTime = time.Now().Unix()
  425. // app.CreateTime = time.Now().Unix()
  426. // service.CreateOrgApp(app)
  427. //}
  428. //if org_app_11 == nil || org_app_11.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  429. // app, _ := service.GetOrgAppA(0, 11)
  430. // //org, _ := service.GetOrgById(int64(12))
  431. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  432. // if org == nil || org.Id == 0 {
  433. // continue
  434. // }
  435. //
  436. //
  437. // app.OrgId = apps.OrgId
  438. // app.Creator = int(org.Creator)
  439. // app.Pid = xt_temp_org_app.Id
  440. // app.Id = 0
  441. //
  442. // app.Number = 6
  443. // app.Status = 1
  444. // app.ModifyTime = time.Now().Unix()
  445. // app.CreateTime = time.Now().Unix()
  446. // service.CreateOrgApp(app)
  447. //}
  448. //if org_app_12 == nil || org_app_12.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  449. // app, _ := service.GetOrgAppA(0, 12)
  450. // //org, _ := service.GetOrgById(int64(12))
  451. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  452. // if org == nil || org.Id == 0 {
  453. // continue
  454. // }
  455. //
  456. //
  457. // app.OrgId = apps.OrgId
  458. // app.Creator = int(org.Creator)
  459. // app.Pid = xt_temp_org_app.Id
  460. // app.Number = 7
  461. // app.Status = 1
  462. // app.Id = 0
  463. //
  464. // app.ModifyTime = time.Now().Unix()
  465. // app.CreateTime = time.Now().Unix()
  466. // service.CreateOrgApp(app)
  467. //}
  468. //if org_app_13 == nil || org_app_13.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  469. // app, _ := service.GetOrgAppA(0, 13)
  470. // //org, _ := service.GetOrgById(int64(12))
  471. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  472. // if org == nil || org.Id == 0 {
  473. // continue
  474. // }
  475. //
  476. //
  477. // app.OrgId = apps.OrgId
  478. // app.Creator = int(org.Creator)
  479. // app.Pid = xt_temp_org_app.Id
  480. // app.Number = 8
  481. // app.Id = 0
  482. // app.Status = 1
  483. // app.ModifyTime = time.Now().Unix()
  484. // app.CreateTime = time.Now().Unix()
  485. // service.CreateOrgApp(app)
  486. //}
  487. //if org_app_14 == nil || org_app_14.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  488. // app, _ := service.GetOrgAppA(0, 14)
  489. // //org, _ := service.GetOrgById(int64(12))
  490. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  491. // if org == nil || org.Id == 0 {
  492. // continue
  493. // }
  494. //
  495. //
  496. // app.OrgId = apps.OrgId
  497. // app.Creator = int(org.Creator)
  498. // app.Pid = xt_temp_org_app.Id
  499. // app.Id = 0
  500. // app.Number = 9
  501. // app.Status = 1
  502. // app.ModifyTime = time.Now().Unix()
  503. // app.CreateTime = time.Now().Unix()
  504. // service.CreateOrgApp(app)
  505. //}
  506. //if org_app_15 == nil || org_app_15.Id == 0 { //判断之前是否有创建该app类型,如果没有则插入数据
  507. // app, _ := service.GetOrgAppA(0, 15)
  508. // //org, _ := service.GetOrgById(int64(12))
  509. // org, _ := service.GetOrgByIdB(int64(apps.OrgId))
  510. // if org == nil || org.Id == 0 {
  511. // continue
  512. // }
  513. //
  514. // app.OrgId = apps.OrgId
  515. // app.Creator = int(org.Creator)
  516. // app.Pid = xt_temp_org_app.Id
  517. // app.Number = 10
  518. // app.Status = 1
  519. // app.Id = 0
  520. // app.ModifyTime = time.Now().Unix()
  521. // app.CreateTime = time.Now().Unix()
  522. // service.CreateOrgApp(app)
  523. //}
  524. }
  525. //for _, role := range org_role {
  526. // org_ids = append(org_ids, role.OrgId)
  527. //}
  528. //
  529. //
  530. ////创建内置角色
  531. //InitRoleAndPurviews(org_ids)
  532. //var org_id int = 0
  533. //管理员
  534. //app_roles := service.GetAllUserRoleByUserTypeOne(org_id)
  535. //for _, item := range app_roles{
  536. // var ids string
  537. // if len(item.RoleIds) == 0{
  538. // ids = strconv.FormatInt( item.RoleId,10)
  539. // }else{
  540. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  541. // }
  542. // service.UpdateRoleIds(item.Id, ids)
  543. //}
  544. //护士医生
  545. //app_roles2 := service.GetAllUserRoleByUserTypeOther()
  546. // for _, item := range app_roles2{
  547. // var ids string
  548. // if len(item.RoleIds) == 0{
  549. // ids = strconv.FormatInt( item.RoleId,10)
  550. // }else{
  551. // ids = item.RoleIds + ","+strconv.FormatInt( item.RoleId,10)
  552. // }
  553. // if item.UserType == 2{
  554. // role := service.FindRoleByUserTypeOne(item.OrgId)
  555. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  556. //
  557. // } else if item.UserType == 3{
  558. // role := service.FindRoleByUserTypeTwo(item.OrgId)
  559. // ids = ids +"," + strconv.FormatInt(role.Id,10)
  560. // }
  561. // service.UpdateRoleIds(item.Id, ids)
  562. // }
  563. //c.ServeSuccessJSON(map[string]interface{}{
  564. // "msg": "ok",
  565. //})
  566. }
  567. func (c *PublicApiController) HandleGroupNo() {
  568. //service.GetAllPatientChargeDetails(10138, 1634054400)
  569. //pts, _ := service.GetHisPrescriptionTemplateTwo()
  570. //for _, item := range pts {
  571. // if len(item.HisPrescriptionAdviceTemplate) > 0 {
  572. // for index, subItem := range item.HisPrescriptionAdviceTemplate {
  573. // subItem.Groupno = int64(index + 1)
  574. // service.SaveAdviceTemplate(subItem)
  575. // }
  576. // }
  577. //}
  578. }
  579. func InitRoleAndPurviews(org_ids []int64) {
  580. roles := LoadRoleConfig("./role.json").Roles
  581. for _, org_id := range org_ids {
  582. app, _ := service.GetOrgAppB(org_id, 3)
  583. role, _ := service.GetSystemRole(org_id)
  584. if app == nil || app.Id == 0 {
  585. continue
  586. }
  587. if len(role) == 0 {
  588. for _, item := range roles {
  589. role := &models.Role{
  590. RoleName: item.RoleName,
  591. RoleIntro: item.RoleIntroduction,
  592. Creator: 0,
  593. OrgId: org_id,
  594. AppId: app.Id,
  595. IsSuperAdmin: false,
  596. Status: 1,
  597. CreateTime: time.Now().Unix(),
  598. ModifyTime: time.Now().Unix(),
  599. Number: item.Number,
  600. IsSystem: item.IsSystem,
  601. }
  602. err := service.CreateOrgRoleB(role)
  603. if err == nil {
  604. purview := &models.RolePurview{
  605. RoleId: role.Id,
  606. OrgId: org_id,
  607. AppId: role.AppId,
  608. PurviewIds: item.PurviewIds,
  609. Status: 1,
  610. CreateTime: time.Now().Unix(),
  611. ModifyTime: time.Now().Unix(),
  612. }
  613. func_purview := &models.SgjUserRoleFuncPurview{
  614. RoleId: role.Id,
  615. OrgId: org_id,
  616. AppId: role.AppId,
  617. PurviewIds: item.FuncIds,
  618. Status: 1,
  619. Ctime: time.Now().Unix(),
  620. Mtime: time.Now().Unix(),
  621. }
  622. service.CreateRolePurviewB(purview)
  623. service.CreateFuncRolePurviewB(func_purview)
  624. }
  625. }
  626. }
  627. }
  628. }
  629. type RoleConfig struct {
  630. Roles []*models.VMUserRoleAndPurview "json:roles"
  631. }
  632. func LoadRoleConfig(dataFile string) *RoleConfig {
  633. var config RoleConfig
  634. _, filename, _, _ := runtime.Caller(1)
  635. datapath := path.Join(path.Dir(filename), dataFile)
  636. config_file, err := os.Open(datapath)
  637. if err != nil {
  638. emit("Failed to open config file '%s': %s\n", datapath, err)
  639. return &config
  640. }
  641. fi, _ := config_file.Stat()
  642. buffer := make([]byte, fi.Size())
  643. _, err = config_file.Read(buffer)
  644. buffer, err = StripComments(buffer) //去掉注释
  645. if err != nil {
  646. emit("Failed to strip comments from json: %s\n", err)
  647. return &config
  648. }
  649. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  650. err = json.Unmarshal(buffer, &config) //解析json格式数据
  651. if err != nil {
  652. emit("Failed unmarshalling json: %s\n", err)
  653. return &config
  654. }
  655. return &config
  656. }
  657. type GoodTypesConfig struct {
  658. GoodTypes []*models.VMGoodsType "json:list"
  659. }
  660. func LoadGoodTypeConfig(dataFile string) *GoodTypesConfig {
  661. var config GoodTypesConfig
  662. _, filename, _, _ := runtime.Caller(1)
  663. datapath := path.Join(path.Dir(filename), dataFile)
  664. config_file, err := os.Open(datapath)
  665. if err != nil {
  666. emit("Failed to open config file '%s': %s\n", datapath, err)
  667. return &config
  668. }
  669. fi, _ := config_file.Stat()
  670. buffer := make([]byte, fi.Size())
  671. _, err = config_file.Read(buffer)
  672. buffer, err = StripComments(buffer) //去掉注释
  673. if err != nil {
  674. emit("Failed to strip comments from json: %s\n", err)
  675. return &config
  676. }
  677. buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
  678. err = json.Unmarshal(buffer, &config) //解析json格式数据
  679. if err != nil {
  680. emit("Failed unmarshalling json: %s\n", err)
  681. return &config
  682. }
  683. return &config
  684. }
  685. func (c *PublicApiController) HandleStockData() {
  686. org, _ := service.FindAllOrgByImportType()
  687. for _, item := range org {
  688. if item.Id != 3907 || item.Id != 9779 || item.Id != 9883 {
  689. goodTypes := &models.GoodsType{
  690. TypeCode: "14000000",
  691. TypeName: "穿刺针",
  692. Remark: "",
  693. Ctime: time.Now().Unix(),
  694. Mtime: time.Now().Unix(),
  695. Creater: 0,
  696. Modifier: 0,
  697. OrgId: item.Id,
  698. Status: 1,
  699. Type: 1,
  700. Number: 1,
  701. }
  702. service.AddSigleGoodType(goodTypes)
  703. goodTypes1 := &models.GoodsType{
  704. TypeCode: "14000001",
  705. TypeName: "透析器",
  706. Remark: "",
  707. Ctime: time.Now().Unix(),
  708. Mtime: time.Now().Unix(),
  709. Creater: 0,
  710. Modifier: 0,
  711. OrgId: item.Id,
  712. Status: 1,
  713. Type: 1,
  714. Number: 2,
  715. }
  716. service.AddSigleGoodType(goodTypes1)
  717. goodTypes2 := &models.GoodsType{
  718. TypeCode: "14000002",
  719. TypeName: "灌流器",
  720. Remark: "",
  721. Ctime: time.Now().Unix(),
  722. Mtime: time.Now().Unix(),
  723. Creater: 0,
  724. Modifier: 0,
  725. OrgId: item.Id,
  726. Status: 1,
  727. Type: 1,
  728. Number: 3,
  729. }
  730. service.AddSigleGoodType(goodTypes2)
  731. goodTypes3 := &models.GoodsType{
  732. TypeCode: "14000003",
  733. TypeName: "血路管",
  734. Remark: "",
  735. Ctime: time.Now().Unix(),
  736. Mtime: time.Now().Unix(),
  737. Creater: 0,
  738. Modifier: 0,
  739. OrgId: item.Id,
  740. Status: 1,
  741. Type: 1,
  742. Number: 4,
  743. }
  744. service.AddSigleGoodType(goodTypes3)
  745. goodTypes4 := &models.GoodsType{
  746. TypeCode: "14000004",
  747. TypeName: "血滤补液管",
  748. Remark: "",
  749. Ctime: time.Now().Unix(),
  750. Mtime: time.Now().Unix(),
  751. Creater: 0,
  752. Modifier: 0,
  753. OrgId: item.Id,
  754. Status: 1,
  755. Type: 1,
  756. Number: 5,
  757. }
  758. service.AddSigleGoodType(goodTypes4)
  759. goodTypes5 := &models.GoodsType{
  760. TypeCode: "14000005",
  761. TypeName: "注射器",
  762. Remark: "",
  763. Ctime: time.Now().Unix(),
  764. Mtime: time.Now().Unix(),
  765. Creater: 0,
  766. Modifier: 0,
  767. OrgId: item.Id,
  768. Status: 1,
  769. Type: 1,
  770. Number: 6,
  771. }
  772. service.AddSigleGoodType(goodTypes5)
  773. goodTypes6 := &models.GoodsType{
  774. TypeCode: "14000006",
  775. TypeName: "护理包(内瘘穿刺包)",
  776. Remark: "",
  777. Ctime: time.Now().Unix(),
  778. Mtime: time.Now().Unix(),
  779. Creater: 0,
  780. Modifier: 0,
  781. OrgId: item.Id,
  782. Status: 1,
  783. Type: 1,
  784. Number: 7,
  785. }
  786. service.AddSigleGoodType(goodTypes6)
  787. goodTypes7 := &models.GoodsType{
  788. TypeCode: "14000007",
  789. TypeName: "细菌过滤器",
  790. Remark: "",
  791. Ctime: time.Now().Unix(),
  792. Mtime: time.Now().Unix(),
  793. Creater: 0,
  794. Modifier: 0,
  795. OrgId: item.Id,
  796. Status: 1,
  797. Type: 1,
  798. Number: 8,
  799. }
  800. service.AddSigleGoodType(goodTypes7)
  801. goodTypes8 := &models.GoodsType{
  802. TypeCode: "14000008",
  803. TypeName: "血液透析干粉",
  804. Remark: "",
  805. Ctime: time.Now().Unix(),
  806. Mtime: time.Now().Unix(),
  807. Creater: 0,
  808. Modifier: 0,
  809. OrgId: item.Id,
  810. Status: 1,
  811. Type: 1,
  812. Number: 9,
  813. }
  814. service.AddSigleGoodType(goodTypes8)
  815. goodTypes9 := &models.GoodsType{
  816. TypeCode: "14000009",
  817. TypeName: "A液",
  818. Remark: "",
  819. Ctime: time.Now().Unix(),
  820. Mtime: time.Now().Unix(),
  821. Creater: 0,
  822. Modifier: 0,
  823. OrgId: item.Id,
  824. Status: 1,
  825. Type: 1,
  826. Number: 10,
  827. }
  828. service.AddSigleGoodType(goodTypes9)
  829. goodTypes10 := &models.GoodsType{
  830. TypeCode: "14000010",
  831. TypeName: "B液",
  832. Remark: "",
  833. Ctime: time.Now().Unix(),
  834. Mtime: time.Now().Unix(),
  835. Creater: 0,
  836. Modifier: 0,
  837. OrgId: item.Id,
  838. Status: 1,
  839. Type: 1,
  840. Number: 11,
  841. }
  842. service.AddSigleGoodType(goodTypes10)
  843. goodTypes11 := &models.GoodsType{
  844. TypeCode: "14000011",
  845. TypeName: "导管包",
  846. Remark: "",
  847. Ctime: time.Now().Unix(),
  848. Mtime: time.Now().Unix(),
  849. Creater: 0,
  850. Modifier: 0,
  851. OrgId: item.Id,
  852. Status: 1,
  853. Type: 1,
  854. Number: 12,
  855. }
  856. service.AddSigleGoodType(goodTypes11)
  857. goodTypes12 := &models.GoodsType{
  858. TypeCode: "14000012",
  859. TypeName: "血液透析导管",
  860. Remark: "",
  861. Ctime: time.Now().Unix(),
  862. Mtime: time.Now().Unix(),
  863. Creater: 0,
  864. Modifier: 0,
  865. OrgId: item.Id,
  866. Status: 1,
  867. Type: 1,
  868. Number: 13,
  869. }
  870. service.AddSigleGoodType(goodTypes12)
  871. }
  872. }
  873. }
  874. func (c *PublicApiController) HandleComData() {
  875. org_ids := []int64{3907, 9779, 9883}
  876. for _, id := range org_ids {
  877. //查处所有处方记录
  878. prescriptions, _ := service.FindAllPrescription(id)
  879. if id == 3907 {
  880. for _, item := range prescriptions {
  881. if item.Niprocart > 0 {
  882. before := &models.DialysisBeforePrepare{
  883. UserOrgId: id,
  884. PatientId: item.PatientId,
  885. RecordDate: item.RecordDate,
  886. Count: 1,
  887. Ctime: item.RecordDate,
  888. Mtime: item.RecordDate,
  889. Creater: item.Creater,
  890. Modifier: item.Creater,
  891. Status: 1,
  892. }
  893. before.GoodId = item.Niprocart
  894. before.GoodTypeId = 241
  895. service.AddSigleDialysisBeforePre(before)
  896. }
  897. if item.Jms > 0 {
  898. before := &models.DialysisBeforePrepare{
  899. UserOrgId: id,
  900. PatientId: item.PatientId,
  901. RecordDate: item.RecordDate,
  902. Count: 1,
  903. Ctime: item.RecordDate,
  904. Mtime: item.RecordDate,
  905. Creater: item.Creater,
  906. Modifier: item.Creater,
  907. Status: 1,
  908. }
  909. before.GoodId = item.Jms
  910. before.GoodTypeId = 233
  911. service.AddSigleDialysisBeforePre(before)
  912. }
  913. if item.FistulaNeedleSet > 0 {
  914. before := &models.DialysisBeforePrepare{
  915. UserOrgId: id,
  916. PatientId: item.PatientId,
  917. RecordDate: item.RecordDate,
  918. Count: 1,
  919. Ctime: item.RecordDate,
  920. Mtime: item.RecordDate,
  921. Creater: item.Creater,
  922. Modifier: item.Creater,
  923. Status: 1,
  924. }
  925. before.GoodId = item.FistulaNeedleSet
  926. before.GoodTypeId = 233
  927. service.AddSigleDialysisBeforePre(before)
  928. }
  929. if item.FistulaNeedleSet16 > 0 {
  930. before := &models.DialysisBeforePrepare{
  931. UserOrgId: id,
  932. PatientId: item.PatientId,
  933. RecordDate: item.RecordDate,
  934. Count: 1,
  935. Ctime: item.RecordDate,
  936. Mtime: item.RecordDate,
  937. Creater: item.Creater,
  938. Modifier: item.Creater,
  939. Status: 1,
  940. }
  941. before.GoodId = item.FistulaNeedleSet16
  942. before.GoodTypeId = 233
  943. service.AddSigleDialysisBeforePre(before)
  944. }
  945. if item.Hemoperfusion > 0 {
  946. before := &models.DialysisBeforePrepare{
  947. UserOrgId: id,
  948. PatientId: item.PatientId,
  949. RecordDate: item.RecordDate,
  950. Count: 1,
  951. Ctime: item.RecordDate,
  952. Mtime: item.RecordDate,
  953. Creater: item.Creater,
  954. Modifier: item.Creater,
  955. Status: 1,
  956. }
  957. before.GoodId = item.Hemoperfusion
  958. before.GoodTypeId = 235
  959. service.AddSigleDialysisBeforePre(before)
  960. }
  961. if item.DialyserSterilised > 0 {
  962. before := &models.DialysisBeforePrepare{
  963. UserOrgId: id,
  964. PatientId: item.PatientId,
  965. RecordDate: item.RecordDate,
  966. Count: 1,
  967. Ctime: item.RecordDate,
  968. Mtime: item.RecordDate,
  969. Creater: item.Creater,
  970. Modifier: item.Creater,
  971. Status: 1,
  972. }
  973. before.GoodId = item.DialyserSterilised
  974. before.GoodTypeId = 234
  975. service.AddSigleDialysisBeforePre(before)
  976. }
  977. if item.Filtryzer > 0 {
  978. before := &models.DialysisBeforePrepare{
  979. UserOrgId: id,
  980. PatientId: item.PatientId,
  981. RecordDate: item.RecordDate,
  982. Count: 1,
  983. Ctime: item.RecordDate,
  984. Mtime: item.RecordDate,
  985. Creater: item.Creater,
  986. Modifier: item.Creater,
  987. Status: 1,
  988. }
  989. before.GoodId = item.Filtryzer
  990. before.GoodTypeId = 234
  991. service.AddSigleDialysisBeforePre(before)
  992. }
  993. if item.Dialyzers > 0 {
  994. before := &models.DialysisBeforePrepare{
  995. UserOrgId: id,
  996. PatientId: item.PatientId,
  997. RecordDate: item.RecordDate,
  998. Count: 1,
  999. Ctime: item.RecordDate,
  1000. Mtime: item.RecordDate,
  1001. Creater: item.Creater,
  1002. Modifier: item.Creater,
  1003. Status: 1,
  1004. }
  1005. before.GoodId = item.Dialyzers
  1006. before.GoodTypeId = 234
  1007. service.AddSigleDialysisBeforePre(before)
  1008. }
  1009. if item.Injector > 0 {
  1010. before := &models.DialysisBeforePrepare{
  1011. UserOrgId: id,
  1012. PatientId: item.PatientId,
  1013. RecordDate: item.RecordDate,
  1014. Count: 1,
  1015. Ctime: item.RecordDate,
  1016. Mtime: item.RecordDate,
  1017. Creater: item.Creater,
  1018. Modifier: item.Creater,
  1019. Status: 1,
  1020. }
  1021. before.GoodId = item.Injector
  1022. before.GoodTypeId = 238
  1023. service.AddSigleDialysisBeforePre(before)
  1024. }
  1025. if item.Bloodlines > 0 {
  1026. before := &models.DialysisBeforePrepare{
  1027. UserOrgId: id,
  1028. PatientId: item.PatientId,
  1029. RecordDate: item.RecordDate,
  1030. Count: 1,
  1031. Ctime: item.RecordDate,
  1032. Mtime: item.RecordDate,
  1033. Creater: item.Creater,
  1034. Modifier: item.Creater,
  1035. Status: 1,
  1036. }
  1037. before.GoodId = item.Bloodlines
  1038. before.GoodTypeId = 236
  1039. service.AddSigleDialysisBeforePre(before)
  1040. }
  1041. if item.TubingHemodialysis > 0 {
  1042. before := &models.DialysisBeforePrepare{
  1043. UserOrgId: id,
  1044. PatientId: item.PatientId,
  1045. RecordDate: item.RecordDate,
  1046. Count: 1,
  1047. Ctime: item.RecordDate,
  1048. Mtime: item.RecordDate,
  1049. Creater: item.Creater,
  1050. Modifier: item.Creater,
  1051. Status: 1,
  1052. }
  1053. before.GoodId = item.TubingHemodialysis
  1054. before.GoodTypeId = 237
  1055. service.AddSigleDialysisBeforePre(before)
  1056. }
  1057. if item.Package > 0 {
  1058. before := &models.DialysisBeforePrepare{
  1059. UserOrgId: id,
  1060. PatientId: item.PatientId,
  1061. RecordDate: item.RecordDate,
  1062. Count: 1,
  1063. Ctime: item.RecordDate,
  1064. Mtime: item.RecordDate,
  1065. Creater: item.Creater,
  1066. Modifier: item.Creater,
  1067. Status: 1,
  1068. }
  1069. before.GoodId = item.Package
  1070. before.GoodTypeId = 239
  1071. service.AddSigleDialysisBeforePre(before)
  1072. }
  1073. if item.ALiquid > 0 {
  1074. before := &models.DialysisBeforePrepare{
  1075. UserOrgId: id,
  1076. PatientId: item.PatientId,
  1077. RecordDate: item.RecordDate,
  1078. Count: 1,
  1079. Ctime: item.RecordDate,
  1080. Mtime: item.RecordDate,
  1081. Creater: item.Creater,
  1082. Modifier: item.Creater,
  1083. Status: 1,
  1084. }
  1085. before.GoodId = item.ALiquid
  1086. before.GoodTypeId = 242
  1087. service.AddSigleDialysisBeforePre(before)
  1088. }
  1089. }
  1090. } else if id == 9779 {
  1091. for _, item := range prescriptions {
  1092. if item.Niprocart > 0 {
  1093. before := &models.DialysisBeforePrepare{
  1094. UserOrgId: id,
  1095. PatientId: item.PatientId,
  1096. RecordDate: item.RecordDate,
  1097. Count: 1,
  1098. Ctime: item.RecordDate,
  1099. Mtime: item.RecordDate,
  1100. Creater: item.Creater,
  1101. Modifier: item.Creater,
  1102. Status: 1,
  1103. }
  1104. before.GoodId = item.Niprocart
  1105. before.GoodTypeId = 254
  1106. service.AddSigleDialysisBeforePre(before)
  1107. }
  1108. if item.Jms > 0 {
  1109. before := &models.DialysisBeforePrepare{
  1110. UserOrgId: id,
  1111. PatientId: item.PatientId,
  1112. RecordDate: item.RecordDate,
  1113. Count: 1,
  1114. Ctime: item.RecordDate,
  1115. Mtime: item.RecordDate,
  1116. Creater: item.Creater,
  1117. Modifier: item.Creater,
  1118. Status: 1,
  1119. }
  1120. before.GoodId = item.Jms
  1121. before.GoodTypeId = 246
  1122. service.AddSigleDialysisBeforePre(before)
  1123. }
  1124. if item.FistulaNeedleSet > 0 {
  1125. before := &models.DialysisBeforePrepare{
  1126. UserOrgId: id,
  1127. PatientId: item.PatientId,
  1128. RecordDate: item.RecordDate,
  1129. Count: 1,
  1130. Ctime: item.RecordDate,
  1131. Mtime: item.RecordDate,
  1132. Creater: item.Creater,
  1133. Modifier: item.Creater,
  1134. Status: 1,
  1135. }
  1136. before.GoodId = item.FistulaNeedleSet
  1137. before.GoodTypeId = 246
  1138. service.AddSigleDialysisBeforePre(before)
  1139. }
  1140. if item.FistulaNeedleSet16 > 0 {
  1141. before := &models.DialysisBeforePrepare{
  1142. UserOrgId: id,
  1143. PatientId: item.PatientId,
  1144. RecordDate: item.RecordDate,
  1145. Count: 1,
  1146. Ctime: item.RecordDate,
  1147. Mtime: item.RecordDate,
  1148. Creater: item.Creater,
  1149. Modifier: item.Creater,
  1150. Status: 1,
  1151. }
  1152. before.GoodId = item.FistulaNeedleSet16
  1153. before.GoodTypeId = 246
  1154. service.AddSigleDialysisBeforePre(before)
  1155. }
  1156. if item.Hemoperfusion > 0 {
  1157. before := &models.DialysisBeforePrepare{
  1158. UserOrgId: id,
  1159. PatientId: item.PatientId,
  1160. RecordDate: item.RecordDate,
  1161. Count: 1,
  1162. Ctime: item.RecordDate,
  1163. Mtime: item.RecordDate,
  1164. Creater: item.Creater,
  1165. Modifier: item.Creater,
  1166. Status: 1,
  1167. }
  1168. before.GoodId = item.Hemoperfusion
  1169. before.GoodTypeId = 248
  1170. service.AddSigleDialysisBeforePre(before)
  1171. }
  1172. if item.DialyserSterilised > 0 {
  1173. before := &models.DialysisBeforePrepare{
  1174. UserOrgId: id,
  1175. PatientId: item.PatientId,
  1176. RecordDate: item.RecordDate,
  1177. Count: 1,
  1178. Ctime: item.RecordDate,
  1179. Mtime: item.RecordDate,
  1180. Creater: item.Creater,
  1181. Modifier: item.Creater,
  1182. Status: 1,
  1183. }
  1184. before.GoodId = item.DialyserSterilised
  1185. before.GoodTypeId = 247
  1186. service.AddSigleDialysisBeforePre(before)
  1187. }
  1188. if item.Filtryzer > 0 {
  1189. before := &models.DialysisBeforePrepare{
  1190. UserOrgId: id,
  1191. PatientId: item.PatientId,
  1192. RecordDate: item.RecordDate,
  1193. Count: 1,
  1194. Ctime: item.RecordDate,
  1195. Mtime: item.RecordDate,
  1196. Creater: item.Creater,
  1197. Modifier: item.Creater,
  1198. Status: 1,
  1199. }
  1200. before.GoodId = item.Filtryzer
  1201. before.GoodTypeId = 247
  1202. service.AddSigleDialysisBeforePre(before)
  1203. }
  1204. if item.Dialyzers > 0 {
  1205. before := &models.DialysisBeforePrepare{
  1206. UserOrgId: id,
  1207. PatientId: item.PatientId,
  1208. RecordDate: item.RecordDate,
  1209. Count: 1,
  1210. Ctime: item.RecordDate,
  1211. Mtime: item.RecordDate,
  1212. Creater: item.Creater,
  1213. Modifier: item.Creater,
  1214. Status: 1,
  1215. }
  1216. before.GoodId = item.Dialyzers
  1217. before.GoodTypeId = 247
  1218. service.AddSigleDialysisBeforePre(before)
  1219. }
  1220. if item.Injector > 0 {
  1221. before := &models.DialysisBeforePrepare{
  1222. UserOrgId: id,
  1223. PatientId: item.PatientId,
  1224. RecordDate: item.RecordDate,
  1225. Count: 1,
  1226. Ctime: item.RecordDate,
  1227. Mtime: item.RecordDate,
  1228. Creater: item.Creater,
  1229. Modifier: item.Creater,
  1230. Status: 1,
  1231. }
  1232. before.GoodId = item.Injector
  1233. before.GoodTypeId = 251
  1234. service.AddSigleDialysisBeforePre(before)
  1235. }
  1236. if item.Bloodlines > 0 {
  1237. before := &models.DialysisBeforePrepare{
  1238. UserOrgId: id,
  1239. PatientId: item.PatientId,
  1240. RecordDate: item.RecordDate,
  1241. Count: 1,
  1242. Ctime: item.RecordDate,
  1243. Mtime: item.RecordDate,
  1244. Creater: item.Creater,
  1245. Modifier: item.Creater,
  1246. Status: 1,
  1247. }
  1248. before.GoodId = item.Bloodlines
  1249. before.GoodTypeId = 249
  1250. service.AddSigleDialysisBeforePre(before)
  1251. }
  1252. if item.TubingHemodialysis > 0 {
  1253. before := &models.DialysisBeforePrepare{
  1254. UserOrgId: id,
  1255. PatientId: item.PatientId,
  1256. RecordDate: item.RecordDate,
  1257. Count: 1,
  1258. Ctime: item.RecordDate,
  1259. Mtime: item.RecordDate,
  1260. Creater: item.Creater,
  1261. Modifier: item.Creater,
  1262. Status: 1,
  1263. }
  1264. before.GoodId = item.TubingHemodialysis
  1265. before.GoodTypeId = 250
  1266. service.AddSigleDialysisBeforePre(before)
  1267. }
  1268. if item.Package > 0 {
  1269. before := &models.DialysisBeforePrepare{
  1270. UserOrgId: id,
  1271. PatientId: item.PatientId,
  1272. RecordDate: item.RecordDate,
  1273. Count: 1,
  1274. Ctime: item.RecordDate,
  1275. Mtime: item.RecordDate,
  1276. Creater: item.Creater,
  1277. Modifier: item.Creater,
  1278. Status: 1,
  1279. }
  1280. before.GoodId = item.Package
  1281. before.GoodTypeId = 252
  1282. service.AddSigleDialysisBeforePre(before)
  1283. }
  1284. if item.ALiquid > 0 {
  1285. before := &models.DialysisBeforePrepare{
  1286. UserOrgId: id,
  1287. PatientId: item.PatientId,
  1288. RecordDate: item.RecordDate,
  1289. Count: 1,
  1290. Ctime: item.RecordDate,
  1291. Mtime: item.RecordDate,
  1292. Creater: item.Creater,
  1293. Modifier: item.Creater,
  1294. Status: 1,
  1295. }
  1296. before.GoodId = item.ALiquid
  1297. before.GoodTypeId = 255
  1298. service.AddSigleDialysisBeforePre(before)
  1299. }
  1300. }
  1301. } else if id == 9883 {
  1302. for _, item := range prescriptions {
  1303. if item.Niprocart > 0 {
  1304. before := &models.DialysisBeforePrepare{
  1305. UserOrgId: id,
  1306. PatientId: item.PatientId,
  1307. RecordDate: item.RecordDate,
  1308. Count: 1,
  1309. Ctime: item.RecordDate,
  1310. Mtime: item.RecordDate,
  1311. Creater: item.Creater,
  1312. Modifier: item.Creater,
  1313. Status: 1,
  1314. }
  1315. before.GoodId = item.Niprocart
  1316. before.GoodTypeId = 267
  1317. service.AddSigleDialysisBeforePre(before)
  1318. }
  1319. if item.Jms > 0 {
  1320. before := &models.DialysisBeforePrepare{
  1321. UserOrgId: id,
  1322. PatientId: item.PatientId,
  1323. RecordDate: item.RecordDate,
  1324. Count: 1,
  1325. Ctime: item.RecordDate,
  1326. Mtime: item.RecordDate,
  1327. Creater: item.Creater,
  1328. Modifier: item.Creater,
  1329. Status: 1,
  1330. }
  1331. before.GoodId = item.Jms
  1332. before.GoodTypeId = 259
  1333. service.AddSigleDialysisBeforePre(before)
  1334. }
  1335. if item.FistulaNeedleSet > 0 {
  1336. before := &models.DialysisBeforePrepare{
  1337. UserOrgId: id,
  1338. PatientId: item.PatientId,
  1339. RecordDate: item.RecordDate,
  1340. Count: 1,
  1341. Ctime: item.RecordDate,
  1342. Mtime: item.RecordDate,
  1343. Creater: item.Creater,
  1344. Modifier: item.Creater,
  1345. Status: 1,
  1346. }
  1347. before.GoodId = item.FistulaNeedleSet
  1348. before.GoodTypeId = 259
  1349. service.AddSigleDialysisBeforePre(before)
  1350. }
  1351. if item.FistulaNeedleSet16 > 0 {
  1352. before := &models.DialysisBeforePrepare{
  1353. UserOrgId: id,
  1354. PatientId: item.PatientId,
  1355. RecordDate: item.RecordDate,
  1356. Count: 1,
  1357. Ctime: item.RecordDate,
  1358. Mtime: item.RecordDate,
  1359. Creater: item.Creater,
  1360. Modifier: item.Creater,
  1361. Status: 1,
  1362. }
  1363. before.GoodId = item.FistulaNeedleSet16
  1364. before.GoodTypeId = 259
  1365. service.AddSigleDialysisBeforePre(before)
  1366. }
  1367. if item.Hemoperfusion > 0 {
  1368. before := &models.DialysisBeforePrepare{
  1369. UserOrgId: id,
  1370. PatientId: item.PatientId,
  1371. RecordDate: item.RecordDate,
  1372. Count: 1,
  1373. Ctime: item.RecordDate,
  1374. Mtime: item.RecordDate,
  1375. Creater: item.Creater,
  1376. Modifier: item.Creater,
  1377. Status: 1,
  1378. }
  1379. before.GoodId = item.Hemoperfusion
  1380. before.GoodTypeId = 261
  1381. service.AddSigleDialysisBeforePre(before)
  1382. }
  1383. if item.DialyserSterilised > 0 {
  1384. before := &models.DialysisBeforePrepare{
  1385. UserOrgId: id,
  1386. PatientId: item.PatientId,
  1387. RecordDate: item.RecordDate,
  1388. Count: 1,
  1389. Ctime: item.RecordDate,
  1390. Mtime: item.RecordDate,
  1391. Creater: item.Creater,
  1392. Modifier: item.Creater,
  1393. Status: 1,
  1394. }
  1395. before.GoodId = item.DialyserSterilised
  1396. before.GoodTypeId = 260
  1397. service.AddSigleDialysisBeforePre(before)
  1398. }
  1399. if item.Filtryzer > 0 {
  1400. before := &models.DialysisBeforePrepare{
  1401. UserOrgId: id,
  1402. PatientId: item.PatientId,
  1403. RecordDate: item.RecordDate,
  1404. Count: 1,
  1405. Ctime: item.RecordDate,
  1406. Mtime: item.RecordDate,
  1407. Creater: item.Creater,
  1408. Modifier: item.Creater,
  1409. Status: 1,
  1410. }
  1411. before.GoodId = item.Filtryzer
  1412. before.GoodTypeId = 260
  1413. service.AddSigleDialysisBeforePre(before)
  1414. }
  1415. if item.Dialyzers > 0 {
  1416. before := &models.DialysisBeforePrepare{
  1417. UserOrgId: id,
  1418. PatientId: item.PatientId,
  1419. RecordDate: item.RecordDate,
  1420. Count: 1,
  1421. Ctime: item.RecordDate,
  1422. Mtime: item.RecordDate,
  1423. Creater: item.Creater,
  1424. Modifier: item.Creater,
  1425. Status: 1,
  1426. }
  1427. before.GoodId = item.Dialyzers
  1428. before.GoodTypeId = 260
  1429. service.AddSigleDialysisBeforePre(before)
  1430. }
  1431. if item.Injector > 0 {
  1432. before := &models.DialysisBeforePrepare{
  1433. UserOrgId: id,
  1434. PatientId: item.PatientId,
  1435. RecordDate: item.RecordDate,
  1436. Count: 1,
  1437. Ctime: item.RecordDate,
  1438. Mtime: item.RecordDate,
  1439. Creater: item.Creater,
  1440. Modifier: item.Creater,
  1441. Status: 1,
  1442. }
  1443. before.GoodId = item.Injector
  1444. before.GoodTypeId = 264
  1445. service.AddSigleDialysisBeforePre(before)
  1446. }
  1447. if item.Bloodlines > 0 {
  1448. before := &models.DialysisBeforePrepare{
  1449. UserOrgId: id,
  1450. PatientId: item.PatientId,
  1451. RecordDate: item.RecordDate,
  1452. Count: 1,
  1453. Ctime: item.RecordDate,
  1454. Mtime: item.RecordDate,
  1455. Creater: item.Creater,
  1456. Modifier: item.Creater,
  1457. Status: 1,
  1458. }
  1459. before.GoodId = item.Bloodlines
  1460. before.GoodTypeId = 262
  1461. service.AddSigleDialysisBeforePre(before)
  1462. }
  1463. if item.TubingHemodialysis > 0 {
  1464. before := &models.DialysisBeforePrepare{
  1465. UserOrgId: id,
  1466. PatientId: item.PatientId,
  1467. RecordDate: item.RecordDate,
  1468. Count: 1,
  1469. Ctime: item.RecordDate,
  1470. Mtime: item.RecordDate,
  1471. Creater: item.Creater,
  1472. Modifier: item.Creater,
  1473. Status: 1,
  1474. }
  1475. before.GoodId = item.TubingHemodialysis
  1476. before.GoodTypeId = 263
  1477. service.AddSigleDialysisBeforePre(before)
  1478. }
  1479. if item.Package > 0 {
  1480. before := &models.DialysisBeforePrepare{
  1481. UserOrgId: id,
  1482. PatientId: item.PatientId,
  1483. RecordDate: item.RecordDate,
  1484. Count: 1,
  1485. Ctime: item.RecordDate,
  1486. Mtime: item.RecordDate,
  1487. Creater: item.Creater,
  1488. Modifier: item.Creater,
  1489. Status: 1,
  1490. }
  1491. before.GoodId = item.Package
  1492. before.GoodTypeId = 265
  1493. service.AddSigleDialysisBeforePre(before)
  1494. }
  1495. if item.ALiquid > 0 {
  1496. before := &models.DialysisBeforePrepare{
  1497. UserOrgId: id,
  1498. PatientId: item.PatientId,
  1499. RecordDate: item.RecordDate,
  1500. Count: 1,
  1501. Ctime: item.RecordDate,
  1502. Mtime: item.RecordDate,
  1503. Creater: item.Creater,
  1504. Modifier: item.Creater,
  1505. Status: 1,
  1506. }
  1507. before.GoodId = item.ALiquid
  1508. before.GoodTypeId = 268
  1509. service.AddSigleDialysisBeforePre(before)
  1510. }
  1511. }
  1512. }
  1513. }
  1514. }
  1515. func (c *PublicApiController) HandleHIS() {
  1516. his, _ := service.GetAllHisInfo(9919)
  1517. for _, item := range his {
  1518. fsn := strings.Split(item.FeedetlSn, "-")
  1519. item.FeedetlSn = fsn[0] + "-" + fsn[1] + "-" + strconv.FormatInt(item.ID, 10)
  1520. fmt.Println(item.FeedetlSn)
  1521. service.UpDateHis2(item)
  1522. }
  1523. }
  1524. //func (c *PublicApiController)HandleOrder(){
  1525. // //orders, _ := service.GetAllHisOrder()
  1526. //
  1527. //
  1528. // order, _ := service.GetLastHisOrder()
  1529. //
  1530. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  1531. //
  1532. //
  1533. // //fmt.Println(fpNumber)
  1534. //
  1535. // //for index, item := range orders {
  1536. // // item.FaPiaoCode ="144072080589"
  1537. // // var zero string
  1538. // // if 1520 + int64(index) >= 1000{
  1539. // // zero = "0000" + strconv.FormatInt(1520 + int64(index),10)
  1540. // // }else if 1520 + int64(index) >= 10000{
  1541. // // zero = "000" + strconv.FormatInt(1520 + int64(index),10)
  1542. // // } else if 1520 + int64(index) >= 100000{
  1543. // // zero = "00" +strconv.FormatInt(1520 + int64(index),10)
  1544. // // } else if 1520 + int64(index) >= 1000000{
  1545. // // zero = "0" +strconv.FormatInt(1520 + int64(index),10)
  1546. // // }else {
  1547. // // zero = strconv.FormatInt(1520 + int64(index),10)
  1548. // // }
  1549. // // item.FaPiaoNumber = zero
  1550. // // service.SaveOrder(item)
  1551. // //}
  1552. //}
  1553. func Mkdir(dir string) {
  1554. // 创建文件夹
  1555. exist, err := PathExists(dir)
  1556. if err != nil {
  1557. fmt.Println(err.Error())
  1558. } else {
  1559. if exist {
  1560. fmt.Println(dir + "文件夹已存在!")
  1561. } else {
  1562. // 文件夹名称,权限
  1563. err := os.Mkdir(dir, os.ModePerm)
  1564. if err != nil {
  1565. fmt.Println(dir+"文件夹创建失败:", err.Error())
  1566. } else {
  1567. fmt.Println(dir + "文件夹创建成功!")
  1568. }
  1569. }
  1570. }
  1571. }
  1572. func PathExists(path string) (bool, error) {
  1573. _, err := os.Stat(path)
  1574. if err == nil {
  1575. return true, nil
  1576. }
  1577. if os.IsNotExist(err) {
  1578. return false, nil
  1579. }
  1580. return false, err
  1581. }
  1582. func (c *PublicApiController) Handle10215() {
  1583. //projects,_ := service.GetAllInfo(10215,2284)
  1584. //
  1585. //for _, item := range projects{
  1586. // service.UpdateStatus(item.ID, item.PrescriptionId)
  1587. //}
  1588. //projects_two,_ := service.GetAllInfo(10215,2277)
  1589. //
  1590. //for _, item := range projects_two{
  1591. // service.UpdateStatus(item.ID, item.PrescriptionId)
  1592. //}
  1593. //service.GetAllInfo(10215,2284)
  1594. //service.GetAllInfo(10215,2277)
  1595. his, _ := service.GetAllPT(10215)
  1596. for _, item := range his {
  1597. info := &models.HisPrescriptionInfoTemplate{
  1598. UserOrgId: item.UserOrgId,
  1599. RecordDate: 0,
  1600. PatientId: item.PatientId,
  1601. Status: 1,
  1602. Ctime: time.Now().Unix(),
  1603. Mtime: time.Now().Unix(),
  1604. Type: 2,
  1605. Creator: 0,
  1606. Modifier: 0,
  1607. PType: 0,
  1608. PTemplateId: item.ID,
  1609. MedType: "14",
  1610. }
  1611. service.CreateHisPrescriptionInfoTemplate(info)
  1612. pro := &models.HisPrescriptionProjectTemplate{
  1613. ProjectId: 1750,
  1614. Price: 6.00,
  1615. UserOrgId: 10215,
  1616. Status: 1,
  1617. Ctime: time.Now().Unix(),
  1618. Mtime: time.Now().Unix(),
  1619. PatientId: item.PatientId,
  1620. RecordDate: 0,
  1621. Count: 1,
  1622. FeedetlSn: "",
  1623. MedListCodg: "",
  1624. SingleDose: "1",
  1625. DeliveryWay: "",
  1626. ExecutionFrequency: "",
  1627. Day: "1",
  1628. Remark: "",
  1629. Unit: "",
  1630. Type: 2,
  1631. PrescriptionId: info.ID,
  1632. FrequencyType: 1,
  1633. DayCount: 0,
  1634. WeekDay: "",
  1635. }
  1636. service.CreateHisPrescriptionProjectTemplate(pro)
  1637. pro2 := &models.HisPrescriptionProjectTemplate{
  1638. ProjectId: 2462,
  1639. Price: 4.94,
  1640. UserOrgId: 10215,
  1641. Status: 1,
  1642. Ctime: time.Now().Unix(),
  1643. Mtime: time.Now().Unix(),
  1644. PatientId: item.PatientId,
  1645. RecordDate: 0,
  1646. Count: 1,
  1647. FeedetlSn: "",
  1648. MedListCodg: "",
  1649. SingleDose: "1",
  1650. DeliveryWay: "",
  1651. ExecutionFrequency: "",
  1652. Day: "1",
  1653. Remark: "",
  1654. Unit: "",
  1655. Type: 3,
  1656. PrescriptionId: info.ID,
  1657. FrequencyType: 1,
  1658. DayCount: 0,
  1659. WeekDay: "",
  1660. }
  1661. service.CreateHisPrescriptionProjectTemplate(pro2)
  1662. //
  1663. //
  1664. infos, _ := service.GetAllPTInfo(10215, item.ID)
  1665. // // fmt.Println(infos)
  1666. for _, subItem := range infos {
  1667. if len(subItem.HisPrescriptionAdviceTemplate) > 0 && len(subItem.HisPrescriptionProjectTemplate) == 0 {
  1668. for _, ssubItem := range subItem.HisPrescriptionAdviceTemplate {
  1669. if ssubItem.DrugId == 1234 {
  1670. pro := &models.HisPrescriptionProjectTemplate{
  1671. ProjectId: 2326,
  1672. Price: 0.86,
  1673. UserOrgId: ssubItem.UserOrgId,
  1674. Status: 1,
  1675. Ctime: time.Now().Unix(),
  1676. Mtime: time.Now().Unix(),
  1677. PatientId: ssubItem.PatientId,
  1678. RecordDate: ssubItem.AdviceDate,
  1679. Count: 1,
  1680. FeedetlSn: "",
  1681. MedListCodg: "",
  1682. SingleDose: "1",
  1683. DeliveryWay: "",
  1684. ExecutionFrequency: "",
  1685. Day: "1",
  1686. Remark: "",
  1687. Unit: "",
  1688. Type: 3,
  1689. PrescriptionId: info.ID,
  1690. FrequencyType: ssubItem.FrequencyType,
  1691. DayCount: ssubItem.DayCount,
  1692. WeekDay: ssubItem.WeekDay,
  1693. }
  1694. service.CreateHisPrescriptionProjectTemplate(pro)
  1695. }
  1696. if ssubItem.DrugId == 1288 {
  1697. pro := &models.HisPrescriptionProjectTemplate{
  1698. ProjectId: 2326,
  1699. Price: 0.86,
  1700. UserOrgId: ssubItem.UserOrgId,
  1701. Status: 1,
  1702. Ctime: time.Now().Unix(),
  1703. Mtime: time.Now().Unix(),
  1704. PatientId: ssubItem.PatientId,
  1705. RecordDate: ssubItem.AdviceDate,
  1706. Count: 1,
  1707. FeedetlSn: "",
  1708. MedListCodg: "",
  1709. SingleDose: "1",
  1710. DeliveryWay: "",
  1711. ExecutionFrequency: "",
  1712. Day: "1",
  1713. Remark: "",
  1714. Unit: "",
  1715. Type: 3,
  1716. PrescriptionId: info.ID,
  1717. FrequencyType: ssubItem.FrequencyType,
  1718. DayCount: ssubItem.DayCount,
  1719. WeekDay: ssubItem.WeekDay,
  1720. }
  1721. service.CreateHisPrescriptionProjectTemplate(pro)
  1722. }
  1723. if ssubItem.DrugId == 1306 {
  1724. pro := &models.HisPrescriptionProjectTemplate{
  1725. ProjectId: 2325,
  1726. Price: 1.11,
  1727. UserOrgId: ssubItem.UserOrgId,
  1728. Status: 1,
  1729. Ctime: time.Now().Unix(),
  1730. Mtime: time.Now().Unix(),
  1731. PatientId: ssubItem.PatientId,
  1732. RecordDate: ssubItem.AdviceDate,
  1733. Count: 1,
  1734. FeedetlSn: "",
  1735. MedListCodg: "",
  1736. SingleDose: "1",
  1737. DeliveryWay: "",
  1738. ExecutionFrequency: "",
  1739. Day: "1",
  1740. Remark: "",
  1741. Unit: "",
  1742. Type: 3,
  1743. PrescriptionId: info.ID,
  1744. FrequencyType: ssubItem.FrequencyType,
  1745. DayCount: ssubItem.DayCount,
  1746. WeekDay: ssubItem.WeekDay,
  1747. }
  1748. service.CreateHisPrescriptionProjectTemplate(pro)
  1749. pro2 := &models.HisPrescriptionProjectTemplate{
  1750. ProjectId: 1727,
  1751. Price: 2.50,
  1752. UserOrgId: ssubItem.UserOrgId,
  1753. Status: 1,
  1754. Ctime: time.Now().Unix(),
  1755. Mtime: time.Now().Unix(),
  1756. PatientId: ssubItem.PatientId,
  1757. RecordDate: ssubItem.AdviceDate,
  1758. Count: 1,
  1759. FeedetlSn: "",
  1760. MedListCodg: "",
  1761. SingleDose: "1",
  1762. DeliveryWay: "",
  1763. ExecutionFrequency: "",
  1764. Day: "1",
  1765. Remark: "",
  1766. Unit: "",
  1767. Type: 2,
  1768. PrescriptionId: info.ID,
  1769. FrequencyType: ssubItem.FrequencyType,
  1770. DayCount: ssubItem.DayCount,
  1771. WeekDay: ssubItem.WeekDay,
  1772. }
  1773. service.CreateHisPrescriptionProjectTemplate(pro2)
  1774. }
  1775. if ssubItem.DrugId == 1291 {
  1776. pro := &models.HisPrescriptionProjectTemplate{
  1777. ProjectId: 2322,
  1778. Price: 0.68,
  1779. UserOrgId: ssubItem.UserOrgId,
  1780. Status: 1,
  1781. Ctime: time.Now().Unix(),
  1782. Mtime: time.Now().Unix(),
  1783. PatientId: ssubItem.PatientId,
  1784. RecordDate: ssubItem.AdviceDate,
  1785. Count: 1,
  1786. FeedetlSn: "",
  1787. MedListCodg: "",
  1788. SingleDose: "1",
  1789. DeliveryWay: "",
  1790. ExecutionFrequency: "",
  1791. Day: "1",
  1792. Remark: "",
  1793. Unit: "",
  1794. Type: 3,
  1795. PrescriptionId: info.ID,
  1796. FrequencyType: ssubItem.FrequencyType,
  1797. DayCount: ssubItem.DayCount,
  1798. WeekDay: ssubItem.WeekDay,
  1799. }
  1800. service.CreateHisPrescriptionProjectTemplate(pro)
  1801. pro2 := &models.HisPrescriptionProjectTemplate{
  1802. ProjectId: 1727,
  1803. Price: 2.50,
  1804. UserOrgId: ssubItem.UserOrgId,
  1805. Status: 1,
  1806. Ctime: time.Now().Unix(),
  1807. Mtime: time.Now().Unix(),
  1808. PatientId: ssubItem.PatientId,
  1809. RecordDate: ssubItem.AdviceDate,
  1810. Count: 1,
  1811. FeedetlSn: "",
  1812. MedListCodg: "",
  1813. SingleDose: "1",
  1814. DeliveryWay: "",
  1815. ExecutionFrequency: "",
  1816. Day: "1",
  1817. Remark: "",
  1818. Unit: "",
  1819. Type: 2,
  1820. PrescriptionId: info.ID,
  1821. FrequencyType: ssubItem.FrequencyType,
  1822. DayCount: ssubItem.DayCount,
  1823. WeekDay: ssubItem.WeekDay,
  1824. }
  1825. service.CreateHisPrescriptionProjectTemplate(pro2)
  1826. }
  1827. }
  1828. }
  1829. }
  1830. }
  1831. }