app_version.go 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. package service
  2. import (
  3. "XT_New/models"
  4. "github.com/jinzhu/gorm"
  5. "time"
  6. )
  7. func GetAppVersionByAppType(apptype int64) (*models.AppVersion, error) {
  8. var version models.AppVersion
  9. err := readDb.Model(&models.AppVersion{}).Where("app_type=?", apptype).First(&version).Error
  10. if err == gorm.ErrRecordNotFound {
  11. return nil, nil
  12. }
  13. if err != nil {
  14. return nil, err
  15. }
  16. return &version, nil
  17. }
  18. func GetAllAppOrg() ([]*models.OrgApp, error) {
  19. var app []*models.OrgApp
  20. err := readUserDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id > 0").Group("org_id").Find(&app).Error
  21. if err == gorm.ErrRecordNotFound {
  22. return nil, nil
  23. }
  24. if err != nil {
  25. return nil, err
  26. }
  27. return app, nil
  28. }
  29. func GetSystemApp() ([]*models.OrgApp, error) {
  30. var app []*models.OrgApp
  31. err := readDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id = 0 ").Find(&app).Error
  32. if err == gorm.ErrRecordNotFound {
  33. return nil, nil
  34. }
  35. if err != nil {
  36. return nil, err
  37. }
  38. return app, nil
  39. }
  40. func GetApp() ([]*models.OrgApp, error) {
  41. var app []*models.OrgApp
  42. err := readDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id = 0").Find(&app).Error
  43. if err == gorm.ErrRecordNotFound {
  44. return nil, nil
  45. }
  46. if err != nil {
  47. return nil, err
  48. }
  49. return app, nil
  50. }
  51. func GetAppByType(orgID int64, app_type int) (*models.OrgApp, error) {
  52. var apps models.OrgApp
  53. err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
  54. if err != nil {
  55. return nil, err
  56. }
  57. return &apps, nil
  58. }
  59. func CreateOrgApp(app *models.OrgApp) {
  60. writeUserDb.Create(&app)
  61. }
  62. func GetAllUserRole(org_id int64) (appRole []*models.App_Role) {
  63. if org_id == 0 {
  64. readUserDb.Model(&models.App_Role{}).Where("status = 1").Find(&appRole)
  65. } else {
  66. readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? ", org_id).Find(&appRole)
  67. }
  68. return
  69. }
  70. func GetAllUserRoleByUserTypeOne(org_id int) (appRole []*models.App_Role) {
  71. readUserDb.Model(&models.App_Role{}).Where("status = 1 AND user_type = 1").Find(&appRole)
  72. return
  73. }
  74. func GetAllUserRoleByUserTypeOther() (appRole []*models.App_Role) {
  75. //app, _ := GetOrgApp(int64(org_id), 3)
  76. //if org_id == 0 {
  77. readUserDb.Model(&models.App_Role{}).Where("status = 1 AND user_type > 1").Find(&appRole)
  78. //
  79. //} else {
  80. // readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? AND user_type > 1 AND app_id = ? ", org_id, app.Id).Find(&appRole)
  81. //
  82. //}
  83. return
  84. }
  85. func FindRoleByUserTypeOne(org_id int64) (role models.Role) {
  86. readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id = ? AND is_system = 2 AND role_name = '医生'", org_id).First(&role)
  87. return
  88. }
  89. func FindRoleByUserTypeTwo(org_id int64) (role models.Role) {
  90. readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id = ? AND is_system = 3 AND role_name = '护士'", org_id).First(&role)
  91. return
  92. }
  93. func GetAllRole() ([]*models.Role, error) {
  94. var app []*models.Role
  95. err := readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id > 0").Group("org_id").Find(&app).Error
  96. if err == gorm.ErrRecordNotFound {
  97. return nil, nil
  98. }
  99. if err != nil {
  100. return nil, err
  101. }
  102. return app, nil
  103. }
  104. func UpdateRoleIds(id int64, ids string) {
  105. writeUserDb.Model(&models.App_Role{}).Where("status = 1 AND id = ?", id).Updates(map[string]interface{}{"role_ids": ids, "mtime": time.Now().Unix()})
  106. }
  107. func GetOrgAppA(orgID int64, app_type int) (*models.OrgApp, error) {
  108. var apps models.OrgApp
  109. err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
  110. if err != nil {
  111. return nil, err
  112. }
  113. return &apps, nil
  114. }
  115. func GetOrgByIdB(orgID int64) (*models.Org, error) {
  116. var org models.Org
  117. err := readUserDb.Model(&models.Org{}).Where("id = ?", orgID).First(&org).Error
  118. if err != nil {
  119. if err == gorm.ErrRecordNotFound {
  120. return nil, nil
  121. } else {
  122. return nil, err
  123. }
  124. }
  125. return &org, nil
  126. }
  127. func GetOrgAppB(orgID int64, app_type int) (*models.OrgApp, error) {
  128. var apps models.OrgApp
  129. err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
  130. if err != nil {
  131. return nil, err
  132. }
  133. return &apps, nil
  134. }
  135. func CreateOrgRoleB(role *models.Role) (err error) {
  136. err = writeUserDb.Create(&role).Error
  137. return
  138. }
  139. func CreateRolePurviewB(purview *models.RolePurview) (err error) {
  140. err = writeUserDb.Create(&purview).Error
  141. return
  142. }
  143. func CreateFuncRolePurviewB(purview *models.SgjUserRoleFuncPurview) (err error) {
  144. err = writeUserDb.Create(&purview).Error
  145. return
  146. }
  147. func GetSystemRole(orgID int64) ([]*models.Role, error) {
  148. var roles []*models.Role
  149. err := readUserDb.Where(" org_id = ? AND status = 1 AND is_system > 1", orgID).First(&roles).Error
  150. if err != nil {
  151. return nil, err
  152. }
  153. return roles, nil
  154. }
  155. func HandleData() {
  156. var pe []*models.PredialysisEvaluation
  157. //readDb.Model(&models.DialysisPrescription{}).Where("user_org_id = 12 AND record_date <= 1587571200").Find(&prescription)
  158. //for _, item := range prescription {
  159. // writeDb.Model(&models.AssessmentAfterDislysis{}).Where("user_org_id =12 AND assessment_date = ?", item.RecordDate).Updates(map[string]interface{}{"mtime": time.Now().Unix(), "actual_ultrafiltration": item.Ultrafiltration})
  160. //}
  161. readDb.Model(&models.PredialysisEvaluation{}).Where("status = 1 AND user_org_id = 9538 AND dialysis_order_id > 0").Find(&pe)
  162. for _, item := range pe {
  163. var sch models.Schedule
  164. err := readDb.Model(&models.Schedule{}).Where("status = 1 AND schedule_date = ? AND patient_id = ? AND user_org_id = 9538", item.AssessmentDate, item.PatientId).First(&sch).Error
  165. if err == nil {
  166. if sch.ID > 0 {
  167. order := &models.DialysisOrder{
  168. DialysisDate: sch.ScheduleDate,
  169. UserOrgId: 9538,
  170. PatientId: sch.PatientId,
  171. Stage: 2,
  172. BedID: sch.BedId,
  173. StartNurse: 554,
  174. FinishNurse: 554,
  175. Status: 1,
  176. CreatedTime: sch.ScheduleDate,
  177. UpdatedTime: sch.ScheduleDate,
  178. StartTime: sch.ScheduleDate,
  179. EndTime: sch.ScheduleDate,
  180. PunctureNurse: 554,
  181. Creator: 554,
  182. Modifier: 554,
  183. FinishCreator: 554,
  184. FinishModifier: 554,
  185. SchedualType: sch.ScheduleType,
  186. }
  187. writeDb.Create(&order)
  188. }
  189. }
  190. }
  191. }
  192. func FindAllOrgByImportType() (org []*models.Org, err error) {
  193. err = readUserDb.Model(&models.Org{}).Where("status =1 AND import = 0").Find(&org).Error
  194. return
  195. }
  196. func FindAllPrescription(org_id int64) (prescription []*models.DialysisPrescription, err error) {
  197. err = readDb.Model(&models.DialysisPrescription{}).Where("user_org_id=? AND status= 1 AND record_date >= 1593446400", org_id).Find(&prescription).Error
  198. return
  199. }
  200. func AddSigleDialysisBeforePre(before *models.DialysisBeforePrepare) {
  201. writeDb.Create(&before)
  202. }
  203. func GetAllHisDoctorInfo(org_id int64) (his []*models.HisDoctorAdviceInfo, err error) {
  204. err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
  205. return
  206. }
  207. func GetAllHisInfo(org_id int64) (his []*models.HisPrescriptionProject, err error) {
  208. err = readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
  209. return
  210. }
  211. func UpDateHis(his *models.HisDoctorAdviceInfo) {
  212. writeDb.Save(&his)
  213. }
  214. func UpDateHis2(his *models.HisPrescriptionProject) {
  215. writeDb.Save(&his)
  216. }
  217. func GetAllHisOrder(org_id int64) (his []*models.HisOrder, err error) {
  218. err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1 AND order_status = 2 AND fa_piao_code == '' AND fa_piao_number == '' ", org_id).Find(&his).Error
  219. return
  220. }
  221. func GetAllHisOrderTwo(org_id int64) (his models.HisOrder, err error) {
  222. err = readDb.Model(&models.HisOrder{}).Where("user_org_id = ? AND status = 1 AND order_status = 2 AND fa_piao_code <> '' AND fa_piao_number <> '' ", org_id).Last(&his).Error
  223. return
  224. }
  225. func GetLastHisOrder() (his models.HisOrder, err error) {
  226. err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 10106 AND status = 1 AND order_status = 2").Last(&his).Error
  227. return
  228. }
  229. type HisPrescriptionAdviceTemplate struct {
  230. ID int64 `gorm:"column:id" json:"id" form:"id"`
  231. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  232. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  233. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  234. AdviceType int64 `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
  235. AdviceDate int64 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
  236. StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
  237. AdviceName string `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
  238. AdviceDesc string `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
  239. ReminderDate int64 `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
  240. SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  241. SingleDoseUnit string `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
  242. PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
  243. PrescribingNumberUnit string `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
  244. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  245. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  246. AdviceDoctor int64 `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
  247. Status int64 `gorm:"column:status" json:"status" form:"status"`
  248. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  249. UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
  250. AdviceAffirm string `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
  251. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  252. StopTime int64 `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
  253. StopReason string `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
  254. StopDoctor int64 `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
  255. StopState int64 `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
  256. ParentId int64 `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
  257. ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
  258. ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
  259. ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
  260. Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
  261. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  262. DialysisOrderId int64 `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
  263. CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
  264. CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
  265. DrugSpec float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
  266. DrugSpecUnit string `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
  267. Groupno int64 `gorm:"column:groupno" json:"groupno" form:"groupno"`
  268. RemindType int64 `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
  269. FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
  270. DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
  271. WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
  272. TemplateId string `gorm:"column:template_id" json:"template_id" form:"template_id"`
  273. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  274. DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
  275. Price float64 `gorm:"column:price" json:"price" form:"price"`
  276. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  277. MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
  278. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  279. Day int64 `gorm:"column:day" json:"day" form:"day"`
  280. Diagnosis int64 `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
  281. HospApprFlag int64 `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
  282. LmtUsedFlag int64 `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
  283. }
  284. func (HisPrescriptionAdviceTemplate) TableName() string {
  285. return "his_prescription_advice_template"
  286. }
  287. type HisPrescriptionInfoTemplateTwo struct {
  288. ID int64 `gorm:"column:id" json:"id" form:"id"`
  289. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  290. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  291. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  292. Status int64 `gorm:"column:status" json:"status" form:"status"`
  293. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  294. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  295. Type int64 `gorm:"column:type" json:"type" form:"type"`
  296. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  297. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  298. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  299. PTemplateId int64 `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
  300. HisPrescriptionAdviceTemplate []HisPrescriptionAdviceTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
  301. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  302. }
  303. func (HisPrescriptionInfoTemplateTwo) TableName() string {
  304. return "his_prescription_info_template"
  305. }
  306. func GetHisPrescriptionTemplateTwo() (prescription []*HisPrescriptionInfoTemplateTwo, err error) {
  307. err = readDb.Model(&HisPrescriptionInfoTemplateTwo{}).
  308. Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
  309. return db.Where("status = 1")
  310. }).
  311. Where("status = 1 ").
  312. Find(&prescription).Error
  313. return
  314. }
  315. func SaveAdviceTemplate(advice HisPrescriptionAdviceTemplate) {
  316. writeDb.Save(&advice)
  317. }
  318. func GetAllPT(org_id int64) (his []*models.HisPrescriptionTemplate, err error) {
  319. err = readDb.Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
  320. return
  321. }
  322. type HisPrescriptionProjectTemplate struct {
  323. ID int64 `gorm:"column:id" json:"id" form:"id"`
  324. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  325. Price float64 `gorm:"column:price" json:"price" form:"price"`
  326. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  327. Status int64 `gorm:"column:status" json:"status" form:"status"`
  328. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  329. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  330. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  331. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  332. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  333. Count string `gorm:"column:count" json:"count" form:"count"`
  334. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  335. MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
  336. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  337. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  338. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  339. Day string `gorm:"column:day" json:"day" form:"day"`
  340. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  341. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  342. Type int64 `gorm:"column:type" json:"type" form:"type"`
  343. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  344. FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
  345. DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
  346. WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
  347. }
  348. func (HisPrescriptionProjectTemplate) TableName() string {
  349. return "his_prescription_project_template"
  350. }
  351. type HisPrescriptionInfoTemplateTHree struct {
  352. ID int64 `gorm:"column:id" json:"id" form:"id"`
  353. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  354. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  355. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  356. Status int64 `gorm:"column:status" json:"status" form:"status"`
  357. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  358. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  359. Type int64 `gorm:"column:type" json:"type" form:"type"`
  360. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  361. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  362. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  363. PTemplateId int64 `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
  364. HisPrescriptionAdviceTemplate []HisPrescriptionAdviceTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
  365. HisPrescriptionProjectTemplate []HisPrescriptionProjectTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
  366. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  367. }
  368. func (HisPrescriptionInfoTemplateTHree) TableName() string {
  369. return "his_prescription_info_template"
  370. }
  371. func GetAllPTInfo(org_id int64, p_template_id int64) (his []*HisPrescriptionInfoTemplateTHree, err error) {
  372. err = readDb.Model(&HisPrescriptionInfoTemplateTHree{}).Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
  373. return db.Where("status = 1")
  374. }).Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
  375. return db.Where("status = 1")
  376. }).Where("user_org_id = ? AND status = 1 AND p_template_id = ?", org_id, p_template_id).Find(&his).Error
  377. return
  378. }
  379. func GetAllInfo(org_id int64, project_id int64) (his []*HisPrescriptionProjectTemplate, err error) {
  380. err = readDb.Model(&HisPrescriptionProjectTemplate{}).Where("user_org_id = ? AND status = 1 AND project_id = ? ", org_id, project_id).Find(&his).Error
  381. return
  382. }
  383. func UpdateStatus(project_id int64, p_id int64) {
  384. writeDb.Model(&HisPrescriptionProjectTemplate{}).Where("id = ?", project_id).Updates(map[string]interface{}{"status": 0})
  385. writeDb.Model(&HisPrescriptionInfoTemplateTwo{}).Where("id = ?", p_id).Updates(map[string]interface{}{"status": 0})
  386. }
  387. func SaveOrder(order *models.HisOrder) {
  388. writeDb.Save(&order)
  389. }