app_version.go 92KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391
  1. package service
  2. import (
  3. "XT_New/models"
  4. "fmt"
  5. "github.com/jinzhu/gorm"
  6. "time"
  7. )
  8. func GetAppVersionByAppType(apptype int64) (*models.AppVersion, error) {
  9. var version models.AppVersion
  10. err := readDb.Model(&models.AppVersion{}).Where("app_type=?", apptype).First(&version).Error
  11. if err == gorm.ErrRecordNotFound {
  12. return nil, nil
  13. }
  14. if err != nil {
  15. return nil, err
  16. }
  17. return &version, nil
  18. }
  19. func GetAllAppOrg() ([]*models.OrgApp, error) {
  20. var app []*models.OrgApp
  21. err := readUserDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id > 0").Group("org_id").Find(&app).Error
  22. if err == gorm.ErrRecordNotFound {
  23. return nil, nil
  24. }
  25. if err != nil {
  26. return nil, err
  27. }
  28. return app, nil
  29. }
  30. func GetSystemApp() ([]*models.OrgApp, error) {
  31. var app []*models.OrgApp
  32. err := readDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id = 0 ").Find(&app).Error
  33. if err == gorm.ErrRecordNotFound {
  34. return nil, nil
  35. }
  36. if err != nil {
  37. return nil, err
  38. }
  39. return app, nil
  40. }
  41. func GetApp() ([]*models.OrgApp, error) {
  42. var app []*models.OrgApp
  43. err := readDb.Model(&models.OrgApp{}).Where("status = 1 AND org_id = 0").Find(&app).Error
  44. if err == gorm.ErrRecordNotFound {
  45. return nil, nil
  46. }
  47. if err != nil {
  48. return nil, err
  49. }
  50. return app, nil
  51. }
  52. func GetAppByType(orgID int64, app_type int) (*models.OrgApp, error) {
  53. var apps models.OrgApp
  54. err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
  55. if err != nil {
  56. return nil, err
  57. }
  58. return &apps, nil
  59. }
  60. func CreateOrgApp(app *models.OrgApp) {
  61. writeUserDb.Create(&app)
  62. }
  63. func GetAllUserRole(org_id int64) (appRole []*models.App_Role) {
  64. if org_id == 0 {
  65. readUserDb.Model(&models.App_Role{}).Where("status = 1").Find(&appRole)
  66. } else {
  67. readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? ", org_id).Find(&appRole)
  68. }
  69. return
  70. }
  71. func GetAllUserRoleByUserTypeOne(org_id int) (appRole []*models.App_Role) {
  72. readUserDb.Model(&models.App_Role{}).Where("status = 1 AND user_type = 1").Find(&appRole)
  73. return
  74. }
  75. func GetAllUserRoleByUserTypeOther() (appRole []*models.App_Role) {
  76. //app, _ := GetOrgApp(int64(org_id), 3)
  77. //if org_id == 0 {
  78. readUserDb.Model(&models.App_Role{}).Where("status = 1 AND user_type > 1").Find(&appRole)
  79. //
  80. //} else {
  81. // readUserDb.Model(&models.App_Role{}).Where("status = 1 AND org_id = ? AND user_type > 1 AND app_id = ? ", org_id, app.Id).Find(&appRole)
  82. //
  83. //}
  84. return
  85. }
  86. func FindRoleByUserTypeOne(org_id int64) (role models.Role) {
  87. readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id = ? AND is_system = 2 AND role_name = '医生'", org_id).First(&role)
  88. return
  89. }
  90. func FindRoleByUserTypeTwo(org_id int64) (role models.Role) {
  91. readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id = ? AND is_system = 3 AND role_name = '护士'", org_id).First(&role)
  92. return
  93. }
  94. func GetAllRole() ([]*models.Role, error) {
  95. var app []*models.Role
  96. err := readUserDb.Model(&models.Role{}).Where("status = 1 AND org_id > 0").Group("org_id").Find(&app).Error
  97. if err == gorm.ErrRecordNotFound {
  98. return nil, nil
  99. }
  100. if err != nil {
  101. return nil, err
  102. }
  103. return app, nil
  104. }
  105. func UpdateRoleIds(id int64, ids string) {
  106. writeUserDb.Model(&models.App_Role{}).Where("status = 1 AND id = ?", id).Updates(map[string]interface{}{"role_ids": ids, "mtime": time.Now().Unix()})
  107. }
  108. func GetOrgAppA(orgID int64, app_type int) (*models.OrgApp, error) {
  109. var apps models.OrgApp
  110. err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
  111. if err != nil {
  112. return nil, err
  113. }
  114. return &apps, nil
  115. }
  116. func GetOrgByIdB(orgID int64) (*models.Org, error) {
  117. var org models.Org
  118. err := readUserDb.Model(&models.Org{}).Where("id = ?", orgID).First(&org).Error
  119. if err != nil {
  120. if err == gorm.ErrRecordNotFound {
  121. return nil, nil
  122. } else {
  123. return nil, err
  124. }
  125. }
  126. return &org, nil
  127. }
  128. func GetOrgAppB(orgID int64, app_type int) (*models.OrgApp, error) {
  129. var apps models.OrgApp
  130. err := readUserDb.Where("app_type = ? AND org_id = ? AND status = 1", app_type, orgID).First(&apps).Error
  131. if err != nil {
  132. return nil, err
  133. }
  134. return &apps, nil
  135. }
  136. func CreateOrgRoleB(role *models.Role) (err error) {
  137. err = writeUserDb.Create(&role).Error
  138. return
  139. }
  140. func CreateRolePurviewB(purview *models.RolePurview) (err error) {
  141. err = writeUserDb.Create(&purview).Error
  142. return
  143. }
  144. func CreateFuncRolePurviewB(purview *models.SgjUserRoleFuncPurview) (err error) {
  145. err = writeUserDb.Create(&purview).Error
  146. return
  147. }
  148. func GetSystemRole(orgID int64) ([]*models.Role, error) {
  149. var roles []*models.Role
  150. err := readUserDb.Where(" org_id = ? AND status = 1 AND is_system > 1", orgID).First(&roles).Error
  151. if err != nil {
  152. return nil, err
  153. }
  154. return roles, nil
  155. }
  156. func HandleData() {
  157. var pe []*models.PredialysisEvaluation
  158. //readDb.Model(&models.DialysisPrescription{}).Where("user_org_id = 12 AND record_date <= 1587571200").Find(&prescription)
  159. //for _, item := range prescription {
  160. // 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})
  161. //}
  162. readDb.Model(&models.PredialysisEvaluation{}).Where("status = 1 AND user_org_id = 9538 AND dialysis_order_id > 0").Find(&pe)
  163. for _, item := range pe {
  164. var sch models.Schedule
  165. 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
  166. if err == nil {
  167. if sch.ID > 0 {
  168. order := &models.DialysisOrder{
  169. DialysisDate: sch.ScheduleDate,
  170. UserOrgId: 9538,
  171. PatientId: sch.PatientId,
  172. Stage: 2,
  173. BedID: sch.BedId,
  174. StartNurse: 554,
  175. FinishNurse: 554,
  176. Status: 1,
  177. CreatedTime: sch.ScheduleDate,
  178. UpdatedTime: sch.ScheduleDate,
  179. StartTime: sch.ScheduleDate,
  180. EndTime: sch.ScheduleDate,
  181. PunctureNurse: 554,
  182. Creator: 554,
  183. Modifier: 554,
  184. FinishCreator: 554,
  185. FinishModifier: 554,
  186. SchedualType: sch.ScheduleType,
  187. }
  188. writeDb.Create(&order)
  189. }
  190. }
  191. }
  192. }
  193. func FindAllOrgByImportType() (org []*models.Org, err error) {
  194. err = readUserDb.Model(&models.Org{}).Where("status =1 AND import = 0").Find(&org).Error
  195. return
  196. }
  197. func FindAllPrescription(org_id int64) (prescription []*models.DialysisPrescription, err error) {
  198. err = readDb.Model(&models.DialysisPrescription{}).Where("user_org_id=? AND status= 1 AND record_date >= 1593446400", org_id).Find(&prescription).Error
  199. return
  200. }
  201. func AddSigleDialysisBeforePre(before *models.DialysisBeforePrepare) {
  202. writeDb.Create(&before)
  203. }
  204. func GetAllHisDoctorInfo(org_id int64) (his []*models.HisDoctorAdviceInfo, err error) {
  205. err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
  206. return
  207. }
  208. func GetAllHisInfo(org_id int64) (his []*models.HisPrescriptionProject, err error) {
  209. err = readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
  210. return
  211. }
  212. func UpDateHis(his *models.HisDoctorAdviceInfo) {
  213. writeDb.Save(&his)
  214. }
  215. func UpDateHis2(his *models.HisPrescriptionProject) {
  216. writeDb.Save(&his)
  217. }
  218. func GetAllHisOrder(org_id int64) (his []*models.HisOrder, err error) {
  219. 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
  220. return
  221. }
  222. func GetAllHisOrderTwo(org_id int64) (his models.HisOrder, err error) {
  223. 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
  224. return
  225. }
  226. func GetLastHisOrder() (his models.HisOrder, err error) {
  227. err = readDb.Model(&models.HisOrder{}).Where("user_org_id = 10106 AND status = 1 AND order_status = 2").Last(&his).Error
  228. return
  229. }
  230. type HisPrescriptionAdviceTemplate struct {
  231. ID int64 `gorm:"column:id" json:"id" form:"id"`
  232. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  233. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  234. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  235. AdviceType int64 `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
  236. AdviceDate int64 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
  237. StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
  238. AdviceName string `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
  239. AdviceDesc string `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
  240. ReminderDate int64 `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
  241. SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  242. SingleDoseUnit string `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
  243. PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
  244. PrescribingNumberUnit string `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
  245. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  246. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  247. AdviceDoctor int64 `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
  248. Status int64 `gorm:"column:status" json:"status" form:"status"`
  249. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  250. UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
  251. AdviceAffirm string `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
  252. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  253. StopTime int64 `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
  254. StopReason string `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
  255. StopDoctor int64 `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
  256. StopState int64 `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
  257. ParentId int64 `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
  258. ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
  259. ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
  260. ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
  261. Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
  262. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  263. DialysisOrderId int64 `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
  264. CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
  265. CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
  266. DrugSpec float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
  267. DrugSpecUnit string `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
  268. Groupno int64 `gorm:"column:groupno" json:"groupno" form:"groupno"`
  269. RemindType int64 `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
  270. FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
  271. DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
  272. WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
  273. TemplateId string `gorm:"column:template_id" json:"template_id" form:"template_id"`
  274. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  275. DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
  276. Price float64 `gorm:"column:price" json:"price" form:"price"`
  277. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  278. MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
  279. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  280. Day int64 `gorm:"column:day" json:"day" form:"day"`
  281. Diagnosis int64 `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
  282. HospApprFlag int64 `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
  283. LmtUsedFlag int64 `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
  284. }
  285. func (HisPrescriptionAdviceTemplate) TableName() string {
  286. return "his_prescription_advice_template"
  287. }
  288. type HisPrescriptionInfoTemplateTwo struct {
  289. ID int64 `gorm:"column:id" json:"id" form:"id"`
  290. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  291. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  292. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  293. Status int64 `gorm:"column:status" json:"status" form:"status"`
  294. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  295. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  296. Type int64 `gorm:"column:type" json:"type" form:"type"`
  297. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  298. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  299. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  300. PTemplateId int64 `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
  301. HisPrescriptionAdviceTemplate []HisPrescriptionAdviceTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
  302. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  303. }
  304. func (HisPrescriptionInfoTemplateTwo) TableName() string {
  305. return "his_prescription_info_template"
  306. }
  307. func GetHisPrescriptionTemplateTwo() (prescription []*HisPrescriptionInfoTemplateTwo, err error) {
  308. err = readDb.Model(&HisPrescriptionInfoTemplateTwo{}).
  309. Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
  310. return db.Where("status = 1")
  311. }).
  312. Where("status = 1 ").
  313. Find(&prescription).Error
  314. return
  315. }
  316. func SaveAdviceTemplate(advice HisPrescriptionAdviceTemplate) {
  317. writeDb.Save(&advice)
  318. }
  319. func GetAllPT(org_id int64) (his []*models.HisPrescriptionTemplate, err error) {
  320. err = readDb.Model(&models.HisPrescriptionTemplate{}).Where("user_org_id = ? AND status = 1", org_id).Find(&his).Error
  321. return
  322. }
  323. type HisPrescriptionProjectTemplate struct {
  324. ID int64 `gorm:"column:id" json:"id" form:"id"`
  325. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  326. Price float64 `gorm:"column:price" json:"price" form:"price"`
  327. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  328. Status int64 `gorm:"column:status" json:"status" form:"status"`
  329. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  330. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  331. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  332. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  333. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  334. Count string `gorm:"column:count" json:"count" form:"count"`
  335. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  336. MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
  337. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  338. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  339. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  340. Day string `gorm:"column:day" json:"day" form:"day"`
  341. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  342. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  343. Type int64 `gorm:"column:type" json:"type" form:"type"`
  344. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  345. FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
  346. DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
  347. WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
  348. }
  349. func (HisPrescriptionProjectTemplate) TableName() string {
  350. return "his_prescription_project_template"
  351. }
  352. type HisPrescriptionInfoTemplateTHree struct {
  353. ID int64 `gorm:"column:id" json:"id" form:"id"`
  354. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  355. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  356. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  357. Status int64 `gorm:"column:status" json:"status" form:"status"`
  358. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  359. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  360. Type int64 `gorm:"column:type" json:"type" form:"type"`
  361. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  362. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  363. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  364. PTemplateId int64 `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
  365. HisPrescriptionAdviceTemplate []HisPrescriptionAdviceTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
  366. HisPrescriptionProjectTemplate []HisPrescriptionProjectTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
  367. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  368. }
  369. func (HisPrescriptionInfoTemplateTHree) TableName() string {
  370. return "his_prescription_info_template"
  371. }
  372. func GetAllPTInfo(org_id int64, p_template_id int64) (his []*HisPrescriptionInfoTemplateTHree, err error) {
  373. err = readDb.Model(&HisPrescriptionInfoTemplateTHree{}).Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
  374. return db.Where("status = 1")
  375. }).Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
  376. return db.Where("status = 1")
  377. }).Where("user_org_id = ? AND status = 1 AND p_template_id = ?", org_id, p_template_id).Find(&his).Error
  378. return
  379. }
  380. func GetAllInfo(org_id int64, project_id int64) (his []*HisPrescriptionProjectTemplate, err error) {
  381. err = readDb.Model(&HisPrescriptionProjectTemplate{}).Where("user_org_id = ? AND status = 1 AND project_id = ? ", org_id, project_id).Find(&his).Error
  382. return
  383. }
  384. func UpdateStatus(project_id int64, p_id int64) {
  385. writeDb.Model(&HisPrescriptionProjectTemplate{}).Where("id = ?", project_id).Updates(map[string]interface{}{"status": 0})
  386. writeDb.Model(&HisPrescriptionInfoTemplateTwo{}).Where("id = ?", p_id).Updates(map[string]interface{}{"status": 0})
  387. }
  388. func SaveOrder(order *models.HisOrder) {
  389. writeDb.Save(&order)
  390. }
  391. func GetAllPrivateHis(org_id int64) (his []*models.HisPatient) {
  392. readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND balance_accounts_type = 2 AND status = 1", org_id).Find(&his)
  393. return
  394. }
  395. func SaveHis(his *models.HisPatient) {
  396. writeDb.Save(his)
  397. return
  398. }
  399. func GetAllProjectPrescription() (pre []*models.HisPrescription) {
  400. readDb.Model(&models.HisPrescription{}).Where("user_org_id = 10215 AND status = 1 AND type = 2 AND order_status = 1 AND record_date >= 1659283200").Find(&pre)
  401. return
  402. }
  403. func GetAllProject(id int64) (pre []*models.HisPrescriptionProject) {
  404. readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id = 10215 AND status = 1 AND project_id = 1735 AND prescription_id = ?", id).Find(&pre)
  405. return
  406. }
  407. //func GetHisOrderDetailByNumberTwo(order_number string, org_id int64) (order []*HisOrderInfo, err error) {
  408. // readDb.Model(&models.Patients{})
  409. //
  410. // err = readDb.Model(&HisOrderInfo{}).Where("order_number = ? AND status = 1", order_number).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  411. // return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("VMHisPrescriptionTwo", "status = 1 AND user_org_id = ?", org_id).Preload("VMHisProject", "status = 1 AND user_org_id = ?", org_id).Preload("VMGoodInfo", "status = 1 AND org_id = ?", org_id)
  412. // }).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  413. // return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("VMHisPrescriptionTwo", "status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status = 1 AND org_id = ?", org_id)
  414. // }).Find(&order).Error
  415. // return
  416. //}
  417. type HisOrderTen struct {
  418. ID int64 `gorm:"column:id" json:"id" form:"id"`
  419. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  420. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  421. SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
  422. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  423. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  424. Status int64 `gorm:"column:status" json:"status" form:"status"`
  425. Number string `gorm:"column:number" json:"number" form:"number"`
  426. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  427. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  428. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  429. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  430. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  431. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  432. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  433. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  434. MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
  435. SetlId string `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
  436. PsnNo string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
  437. PsnName string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
  438. PsnCertType string `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
  439. Certno string `gorm:"column:certno" json:"certno" form:"certno"`
  440. Gend string `gorm:"column:gend" json:"gend" form:"gend"`
  441. Naty string `gorm:"column:naty" json:"naty" form:"naty"`
  442. Brdy time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
  443. Age float64 `gorm:"column:age" json:"age" form:"age"`
  444. Insutype string `gorm:"column:insutype" json:"insutype" form:"insutype"`
  445. PsnType string `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
  446. CvlservFlag string `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
  447. SetlTime string `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
  448. MdtrtCertType string `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
  449. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  450. MedfeeSumamt float64 `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
  451. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  452. OverlmtSelfPay float64 `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
  453. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  454. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  455. ActPayDedc float64 `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
  456. HifpPay float64 `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
  457. CvlservPay float64 `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
  458. PoolPropSelfpay float64 `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
  459. HifesPay float64 `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
  460. HifmiPay float64 `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
  461. HifobPay float64 `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
  462. MafPay float64 `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
  463. OthPay float64 `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
  464. FundPaySumamt float64 `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
  465. PsnPartAmt float64 `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
  466. AcctPay float64 `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
  467. PsnCashPay float64 `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
  468. HospPartAmt float64 `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
  469. Balc float64 `gorm:"column:balc" json:"balc" form:"balc"`
  470. AcctMulaidPay float64 `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
  471. MedinsSetlId string `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
  472. ClrOptins string `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
  473. ClrWay string `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
  474. ClrType string `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
  475. SetlDetail string `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
  476. IsMedicineInsurance int64 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
  477. PayWay int64 `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
  478. PayPrice float64 `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
  479. PayCardNo string `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
  480. DiscountPrice float64 `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
  481. PreferentialPrice float64 `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
  482. RealityPrice float64 `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
  483. FoundPrice float64 `gorm:"column:found_price" json:"found_price" form:"found_price"`
  484. MedicalInsurancePrice float64 `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
  485. PrivatePrice float64 `gorm:"column:private_price" json:"private_price" form:"private_price"`
  486. DepartmentName string `gorm:"-" json:"department_name" form:"department_name"`
  487. DoctorName string `gorm:"-" json:"doctor_name" form:"doctor_name"`
  488. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  489. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  490. Decimal float64 `gorm:"column:decimal" json:"decimal" form:"decimal"`
  491. VmHisOrderInfo9504 []*VmHisOrderInfo9504 `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"info"`
  492. //HisPrescriptionTen []*HisPrescriptionTen `gorm:"ForeignKey:BatchNumber;AssociationForeignKey:Number" json:"info"`
  493. Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
  494. }
  495. func (HisOrderTen) TableName() string {
  496. return "his_order"
  497. }
  498. type HisPrescriptionTen struct {
  499. ID int64 `gorm:"column:id" json:"id" form:"id"`
  500. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  501. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  502. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  503. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  504. Status int64 `gorm:"column:status" json:"status" form:"status"`
  505. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  506. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  507. Number string `gorm:"column:number" json:"number" form:"number"`
  508. Type int64 `gorm:"column:type" json:"type" form:"type"`
  509. Doctor string `gorm:"column:doctor" json:"doctor" form:"doctor"`
  510. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  511. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  512. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  513. PreTime int64 `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
  514. BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
  515. PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
  516. Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
  517. HisDoctorAdviceInfoTen []*HisDoctorAdviceInfoTen `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
  518. HisPrescriptionProjectTen []*HisPrescriptionProjectTen `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
  519. Total string `gorm:"-" json:"total" form:"total"`
  520. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  521. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  522. IsMedicine int64 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
  523. }
  524. func (HisPrescriptionTen) TableName() string {
  525. return "his_prescription"
  526. }
  527. func GetHisOrderDetailThree() (order []*HisOrderTen, err error) {
  528. err = readDb.Model(&HisOrderTen{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  529. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  530. return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
  531. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  532. return db.Where("status = 1").Preload("Drug", "status = 1")
  533. })
  534. }).Where("setl_time >= '2023-01-01 00:00:00' AND setl_time <= '2023-03-31 23:59:59' AND status = 1 AND order_status =2 AND user_org_id = 10215").Find(&order).Order("patient_id").Error
  535. return
  536. }
  537. type HisDoctorAdviceInfoTen struct {
  538. ID int64 `gorm:"column:id" json:"id" form:"id"`
  539. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  540. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  541. AdviceDate int64 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
  542. AdviceName string `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
  543. AdviceDesc string `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
  544. SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  545. SingleDoseUnit string `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
  546. PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
  547. PrescribingNumberUnit string `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
  548. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  549. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  550. Status int64 `gorm:"column:status" json:"status" form:"status"`
  551. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  552. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  553. DrugSpec float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
  554. DrugSpecUnit string `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
  555. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  556. Price float64 `gorm:"column:price" json:"price" form:"price"`
  557. DrugId int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
  558. Drug Drug `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
  559. IsMedicine int64 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
  560. ExecutionFrequencyId int64 `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
  561. IsSelfDrug int64 `gorm:"column:is_self_drug" json:"is_self_drug" form:"is_self_drug"`
  562. }
  563. func (HisDoctorAdviceInfoTen) TableName() string {
  564. return "his_doctor_advice_info"
  565. }
  566. type HisPrescriptionProjectTen struct {
  567. ID int64 `gorm:"column:id" json:"id" form:"id"`
  568. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  569. Price float64 `gorm:"column:price" json:"price" form:"price"`
  570. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  571. Status int64 `gorm:"column:status" json:"status" form:"status"`
  572. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  573. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  574. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  575. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  576. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  577. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  578. Count string `gorm:"column:count" json:"count" form:"count"`
  579. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  580. MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
  581. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  582. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  583. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  584. Day string `gorm:"column:day" json:"day" form:"day"`
  585. VMHisProject VMHisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
  586. VMGoodInfo VMGoodInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
  587. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  588. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  589. Type int64 `gorm:"column:type" json:"type" form:"type"`
  590. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  591. ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
  592. ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
  593. ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
  594. CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
  595. CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
  596. Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
  597. StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
  598. TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
  599. FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
  600. DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
  601. WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
  602. ExecutionFrequencyId int64 `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
  603. }
  604. func (HisPrescriptionProjectTen) TableName() string {
  605. return "his_prescription_project"
  606. }
  607. func GetHisPatient11111(orgid int64) (paitent []*models.HisHospitalCheckRecord, err error) {
  608. err = XTReadDB().Model(&paitent).Where("user_org_id = ? and status = 1 AND in_hosptial_time >= '2023-10-01 00:00:00' AND in_hosptial_time <= '2023-10-31 23:59:59'", orgid).Find(&paitent).Error
  609. return paitent, err
  610. }
  611. func SaveHP(paitent *models.HisHospitalCheckRecord) {
  612. writeDb.Save(&paitent)
  613. }
  614. func Savehis(paitent *models.HisPatient) {
  615. writeDb.Save(&paitent)
  616. }
  617. type HisOrder9504 struct {
  618. ID int64 `gorm:"column:id" json:"id" form:"id"`
  619. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  620. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  621. SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
  622. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  623. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  624. Status int64 `gorm:"column:status" json:"status" form:"status"`
  625. Number string `gorm:"column:number" json:"number" form:"number"`
  626. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  627. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  628. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  629. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  630. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  631. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  632. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  633. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  634. MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
  635. SetlId string `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
  636. PsnNo string `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
  637. PsnName string `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
  638. PsnCertType string `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
  639. Certno string `gorm:"column:certno" json:"certno" form:"certno"`
  640. Gend string `gorm:"column:gend" json:"gend" form:"gend"`
  641. Naty string `gorm:"column:naty" json:"naty" form:"naty"`
  642. Brdy time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
  643. Age float64 `gorm:"column:age" json:"age" form:"age"`
  644. Insutype string `gorm:"column:insutype" json:"insutype" form:"insutype"`
  645. PsnType string `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
  646. CvlservFlag string `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
  647. SetlTime string `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
  648. MdtrtCertType string `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
  649. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  650. MedfeeSumamt float64 `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
  651. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  652. OverlmtSelfPay float64 `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
  653. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  654. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  655. ActPayDedc float64 `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
  656. HifpPay float64 `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
  657. CvlservPay float64 `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
  658. PoolPropSelfpay float64 `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
  659. HifesPay float64 `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
  660. HifmiPay float64 `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
  661. HifobPay float64 `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
  662. MafPay float64 `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
  663. OthPay float64 `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
  664. FundPaySumamt float64 `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
  665. PsnPartAmt float64 `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
  666. AcctPay float64 `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
  667. PsnCashPay float64 `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
  668. HospPartAmt float64 `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
  669. Balc float64 `gorm:"column:balc" json:"balc" form:"balc"`
  670. AcctMulaidPay float64 `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
  671. MedinsSetlId string `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
  672. ClrOptins string `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
  673. ClrWay string `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
  674. ClrType string `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
  675. SetlDetail string `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
  676. IsMedicineInsurance int64 `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
  677. PayWay int64 `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
  678. PayPrice float64 `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
  679. PayCardNo string `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
  680. DiscountPrice float64 `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
  681. PreferentialPrice float64 `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
  682. RealityPrice float64 `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
  683. FoundPrice float64 `gorm:"column:found_price" json:"found_price" form:"found_price"`
  684. MedicalInsurancePrice float64 `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
  685. PrivatePrice float64 `gorm:"column:private_price" json:"private_price" form:"private_price"`
  686. DepartmentName string `gorm:"-" json:"department_name" form:"department_name"`
  687. DoctorName string `gorm:"-" json:"doctor_name" form:"doctor_name"`
  688. SettleStartTime int64 `gorm:"settle_start_time" json:"settle_start_time" form:"settle_start_time"`
  689. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  690. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  691. Decimal float64 `gorm:"column:decimal" json:"decimal" form:"decimal"`
  692. VmHisOrderInfo9504 []*VmHisOrderInfo9504 `gorm:"ForeignKey:OrderNumber;AssociationForeignKey:Number" json:"info"`
  693. Patients Patients `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
  694. }
  695. func (HisOrder9504) TableName() string {
  696. return "his_order"
  697. }
  698. type VmHisOrderInfo9504 struct {
  699. ID int64 `gorm:"column:id" json:"id" form:"id"`
  700. OrderNumber string `gorm:"column:order_number" json:"order_number" form:"order_number"`
  701. UploadDate int64 `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
  702. AdviceId int64 `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
  703. DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  704. Cnt float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
  705. Pric float64 `gorm:"column:pric" json:"pric" form:"pric"`
  706. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  707. PricUplmtAmt float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  708. SelfpayProp float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
  709. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  710. OverlmtAmt float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
  711. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  712. BasMednFlag string `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
  713. MedChrgitmType string `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
  714. HiNegoDrugFlag string `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  715. Status int64 `gorm:"column:status" json:"status" form:"status"`
  716. Memo string `gorm:"column:memo" json:"memo" form:"memo"`
  717. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  718. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  719. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  720. DrtReimFlag string `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
  721. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  722. ListSpItemFlag string `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
  723. ChldMedcFlag string `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
  724. LmtUsedFlag string `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
  725. ChrgitmLv string `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
  726. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  727. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  728. OrderId int64 `gorm:"column:order_id" json:"order_id" form:"order_id"`
  729. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  730. Type int64 `gorm:"column:type" json:"type" form:"type"`
  731. ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
  732. SettleType int64 `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
  733. HisPrescriptionProjectTen HisPrescriptionProjectTen `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
  734. HisDoctorAdviceInfoTen HisDoctorAdviceInfoTen `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advices"`
  735. }
  736. func (VmHisOrderInfo9504) TableName() string {
  737. return "his_order_info"
  738. }
  739. type VmHisOrderInfo95042 struct {
  740. ID int64 `gorm:"column:id" json:"id" form:"id"`
  741. OrderNumber string `gorm:"column:order_number" json:"order_number" form:"order_number"`
  742. UploadDate int64 `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
  743. AdviceId int64 `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
  744. DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  745. Cnt float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
  746. Pric float64 `gorm:"column:pric" json:"pric" form:"pric"`
  747. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  748. PricUplmtAmt float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  749. SelfpayProp float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
  750. FulamtOwnpayAmt float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  751. OverlmtAmt float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
  752. PreselfpayAmt float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
  753. BasMednFlag string `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
  754. MedChrgitmType string `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
  755. HiNegoDrugFlag string `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  756. Status int64 `gorm:"column:status" json:"status" form:"status"`
  757. Memo string `gorm:"column:memo" json:"memo" form:"memo"`
  758. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  759. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  760. InscpScpAmt float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
  761. DrtReimFlag string `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
  762. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  763. ListSpItemFlag string `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
  764. ChldMedcFlag string `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
  765. LmtUsedFlag string `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
  766. ChrgitmLv string `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
  767. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  768. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  769. OrderId int64 `gorm:"column:order_id" json:"order_id" form:"order_id"`
  770. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  771. Type int64 `gorm:"column:type" json:"type" form:"type"`
  772. ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
  773. SettleType int64 `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
  774. }
  775. func (VmHisOrderInfo95042) TableName() string {
  776. return "his_order_info"
  777. }
  778. func GetHisOrderDetail9504() (order []*HisOrder9504, err error) {
  779. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  780. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  781. return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
  782. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  783. return db.Where("status = 1").Preload("Drug", "status = 1")
  784. })
  785. }).Where("settle_accounts_date >= 1640966400 AND settle_accounts_date <= 1661875200 AND status = 1 AND order_status =2 AND user_org_id = 9504").Find(&order).Order("setl_time").Error
  786. return
  787. }
  788. func GetHisOrderDetail10188() (order []*HisOrder9504, err error) {
  789. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  790. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  791. return db.Where("status = 1").Preload("VMHisProject", "status = 1").Preload("VMGoodInfo", "status = 1")
  792. })
  793. }).Where("settle_accounts_date >= 1654012800 AND settle_accounts_date <= 1661875200 AND status = 1 AND order_status =2 AND user_org_id = 10188").Find(&order).Order("setl_time").Error
  794. return
  795. }
  796. //func GetHisOrderDetail10138() (order []*HisOrder9504, err error) {
  797. // err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  798. // return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  799. // return db.Where("status = 1").Preload("VMHisProject", "status = 1")
  800. // })
  801. // }).Where("settle_accounts_date >= 1640966400 AND settle_accounts_date <= 1648656000 AND status = 1 AND order_status =2 AND user_org_id = 10138").Find(&order).Order("setl_time").Error
  802. // return
  803. //}
  804. func GetHisOrderDetail10138() (order []*HisOrderTen, err error) {
  805. err = readDb.Model(&HisOrderTen{}).Preload("HisPrescriptionTen", func(db *gorm.DB) *gorm.DB {
  806. return db.Where("status = 1 AND order_status = 2").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  807. return db.Where("status = 1").Preload("VMHisProject")
  808. })
  809. }).Where("setl_time >= '2022-01-01 00:00:00' AND setl_time <= '2022-12-31 23:00:00' AND status = 1 AND order_status =2 AND user_org_id = 10215 and insutype = 310").Find(&order).Error
  810. return
  811. }
  812. func GetHisOrderDetail10265() (order_infos []*VmHisOrderInfo9504, err error) {
  813. err = readDb.Model(&VmHisOrderInfo9504{}).Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  814. return db.Preload("VMHisProject").Preload("VMGoodInfo", "status = 1")
  815. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  816. return db.Where("status = 1").Preload("Drug", "status = 1")
  817. }).Where(" status = 1 AND user_org_id = 10265 AND order_number = '2022090814370516482'").Find(&order_infos).Error
  818. return
  819. }
  820. func GetHisOrder10265() (order_infos []*VmHisOrderInfo9504, err error) {
  821. err = readDb.Model(&VmHisOrderInfo95042{}).Where(" status = 1 AND user_org_id = 10265 AND order_number = '2023031016334716192' AND project_id > 0").Find(&order_infos).Error
  822. return
  823. }
  824. func GetHisOrder10265two() (order_infos []*VmHisOrderInfo9504, err error) {
  825. err = readDb.Model(&VmHisOrderInfo95042{}).Where(" status = 1 AND user_org_id = 10265 AND order_number = '2023031016334716192'").Find(&order_infos).Error
  826. return
  827. }
  828. func SaveOrderInfo(info *VmHisOrderInfo9504) {
  829. writeDb.Save(&info)
  830. }
  831. func GetHisOrderDetail10106(start_time int64, end_time int64) (order []*HisOrder9504, err error) {
  832. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  833. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  834. return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
  835. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  836. return db.Where("status = 1").Preload("Drug")
  837. })
  838. }).Where("settle_accounts_date >= ? AND settle_accounts_date <= ? AND status = 1 AND order_status =2 AND user_org_id = 10106", start_time, end_time).Find(&order).Order("setl_time").Error
  839. return
  840. }
  841. func GetHisOrderDetail10318(start_time int64, end_time int64) (order []*HisOrder9504, err error) {
  842. err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
  843. return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
  844. return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
  845. }).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
  846. return db.Where("status = 1").Preload("Drug")
  847. })
  848. }).Where("settle_accounts_date >= ? AND settle_accounts_date <= ? AND status = 1 AND order_status =2 AND user_org_id = 10318", start_time, end_time).Find(&order).Order("setl_time").Error
  849. return
  850. }
  851. func GetLongSolution() {
  852. records, _ := GetAllSchedules()
  853. fmt.Println(records)
  854. for _, item := range records {
  855. var DialysisMachineName string
  856. //1.透析器 2.灌流器 3.透析器/灌流器
  857. so, _ := GetDialysisSolutionTwo(item.UserOrgId, item.PatientId, item.ModeId)
  858. filedRecordOne, _ := FindFiledBy(item.UserOrgId, "透析器")
  859. filedRecordTwo, _ := FindFiledBy(item.UserOrgId, "灌流器")
  860. filedRecordThree, _ := FindFiledBy(item.UserOrgId, "透析器/灌流器")
  861. if filedRecordOne.IsShow == 1 {
  862. DialysisMachineName = so.DialysisDialyszers
  863. }
  864. if filedRecordThree.IsShow == 1 {
  865. if len(DialysisMachineName) > 0 {
  866. DialysisMachineName = DialysisMachineName + "," + so.DialyzerPerfusionApparatus
  867. } else {
  868. DialysisMachineName = so.DialyzerPerfusionApparatus
  869. }
  870. }
  871. if filedRecordTwo.IsShow == 1 {
  872. if len(DialysisMachineName) > 0 {
  873. DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
  874. } else {
  875. DialysisMachineName = so.DialysisIrrigation
  876. }
  877. }
  878. item.DialysisMachineName = DialysisMachineName
  879. UpdateSch(item)
  880. }
  881. }
  882. func GetAllSchMode() (modes []*models.PatientScheduleTemplateMode, getModesErr error) {
  883. getModesErr = readDb.Model(&models.PatientScheduleTemplateMode{}).Where("mode <> 0 AND status = 1 ").Find(&modes).Error
  884. return
  885. }
  886. type DialysisSolutionTwo struct {
  887. ID int64 `gorm:"column:id" json:"id" form:"id"`
  888. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  889. }
  890. func (DialysisSolutionTwo) TableName() string {
  891. return "xt_dialysis_solution"
  892. }
  893. type Schedule struct {
  894. ID int64 `gorm:"column:id" json:"id" form:"id"`
  895. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  896. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  897. Status int64 `gorm:"column:status" json:"status" form:"status"`
  898. ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
  899. ModeId int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
  900. DialysisMachineName string `gorm:"column:dialysis_machine_name" json:"dialysis_machine_name" form:"dialysis_machine_name"`
  901. }
  902. func (Schedule) TableName() string {
  903. return "xt_schedule"
  904. }
  905. func GetAllSchedules() ([]Schedule, error) {
  906. var record []Schedule
  907. err := readDb.Model(&Schedule{}).Where("user_org_id = 10290 AND status = 1 AND schedule_date > 1672934400").Find(&record).Error
  908. if err != nil {
  909. if err == gorm.ErrRecordNotFound {
  910. return nil, nil
  911. } else {
  912. return nil, err
  913. }
  914. }
  915. return record, nil
  916. }
  917. func FindFiledBy(org_id int64, name string) (filedConfig models.FiledConfig, err error) {
  918. err = readDb.Model(&models.FiledConfig{}).Where("org_id =? AND module = 1 AND filed_name_cn= ?", org_id, name).First(&filedConfig).Error
  919. return
  920. }
  921. // 透析方案
  922. func GetDialysisSolutionTwo(orgID int64, patientID int64, mode_id int64) (models.DialysisSolution, error) {
  923. var record models.DialysisSolution
  924. err := readDb.Model(&models.DialysisSolution{}).Where("patient_id = ? and user_org_id = ? and status = 1 AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
  925. return record, err
  926. }
  927. func UpdateSch(sch Schedule) (err error) {
  928. err = writeDb.Model(&Schedule{}).Where("status=1 AND id = ?", sch.ID).Updates(map[string]interface{}{"dialysis_machine_name": sch.DialysisMachineName}).Error
  929. return
  930. }
  931. func SaveSch(sch *models.Schedule) (err error) {
  932. err = writeDb.Save(&sch).Error
  933. return
  934. }
  935. func SaveSchTwo(sch models.Schedule, sch_two models.Schedule) (err error) {
  936. //err = writeDb.Save(&sch).Error
  937. err = writeDb.Model(&Schedule{}).Where("status=1 AND id = ?", sch.ID).Updates(map[string]interface{}{"status": 0}).Error
  938. err = writeDb.Model(&Schedule{}).Where("status=1 AND id = ?", sch_two.ID).Updates(map[string]interface{}{"status": 0}).Error
  939. return
  940. }
  941. func GetDrugstwo(orgId int64) (drugs []*XtBaseDrugtwo, err error) {
  942. err = readDb.Model(&XtBaseDrugtwo{}).Where("org_id = ? AND status = 1", orgId).Find(&drugs).Error
  943. return
  944. }
  945. func GetGoodInfotwo(orgId int64) (drugs []*XtGoodInformation, err error) {
  946. err = readDb.Model(&XtGoodInformation{}).Where("org_id = ? AND status = 1", orgId).Find(&drugs).Error
  947. return
  948. }
  949. func Getprojecttwo(orgId int64) (drugs []*XtHisProject, err error) {
  950. err = readDb.Model(&XtHisProject{}).Where("user_org_id = ? AND status = 1", orgId).Find(&drugs).Error
  951. return
  952. }
  953. func SaveDrugtwo(drugs *XtBaseDrugtwo) error {
  954. err := XTWriteDB().Save(&drugs).Error
  955. return err
  956. }
  957. func SaveGoodtwo(drugs *XtGoodInformation) error {
  958. err := XTWriteDB().Save(&drugs).Error
  959. return err
  960. }
  961. func SaveProject(drugs *XtHisProject) error {
  962. err := XTWriteDB().Save(&drugs).Error
  963. return err
  964. }
  965. type XtGoodInformation struct {
  966. ID int64 `gorm:"column:id" json:"id" form:"id"`
  967. GoodCode string `gorm:"column:good_code" json:"good_code" form:"good_code"`
  968. SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
  969. GoodTypeId int64 `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
  970. GoodUnit int64 `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
  971. BuyPrice float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
  972. SellPrice float64 `gorm:"column:sell_price" json:"sell_price" form:"sell_price"`
  973. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  974. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  975. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  976. Manufacturer int64 `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
  977. Dealer int64 `gorm:"column:dealer" json:"dealer" form:"dealer"`
  978. ExpiryDateWarnDayCount int64 `gorm:"column:expiry_date_warn_day_count" json:"expiry_date_warn_day_count" form:"expiry_date_warn_day_count"`
  979. StockWarnCount int64 `gorm:"column:stock_warn_count" json:"stock_warn_count" form:"stock_warn_count"`
  980. IsReuse int64 `gorm:"column:is_reuse" json:"is_reuse" form:"is_reuse"`
  981. Status int64 `gorm:"column:status" json:"status" form:"status"`
  982. FilmArea string `gorm:"column:film_area" json:"film_area" form:"film_area"`
  983. IsUse int64 `gorm:"column:is_use" json:"is_use" form:"is_use"`
  984. FilmMaterialQuality string `gorm:"column:film_material_quality" json:"film_material_quality" form:"film_material_quality"`
  985. OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
  986. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  987. Creater int64 `gorm:"column:creater" json:"creater" form:"creater"`
  988. GoodName string `gorm:"column:good_name" json:"good_name" form:"good_name"`
  989. Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
  990. Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
  991. GoodKind int64 `gorm:"column:good_kind" json:"good_kind" form:"good_kind"`
  992. MedicalInsuranceLevel int64 `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
  993. RetailPrice float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
  994. MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
  995. IsSpecialDiseases int64 `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
  996. IsRecord int64 `gorm:"column:is_record" json:"is_record" form:"is_record"`
  997. StatisticsCategory int64 `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
  998. GoodStatus string `gorm:"column:good_status" json:"good_status" form:"good_status"`
  999. DefaultCount int64 `gorm:"column:default_count" json:"default_count" form:"default_count"`
  1000. IsDefault int64 `gorm:"column:is_default" json:"is_default" form:"is_default"`
  1001. IsChargeUse int64 `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
  1002. IsChargePredict int64 `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
  1003. IsStatisticsWork int64 `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
  1004. Sign int64 `gorm:"column:sign" json:"sign" form:"sign"`
  1005. Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
  1006. IsDoctorUse int64 `gorm:"column:is_doctor_use" json:"is_doctor_use" form:"is_doctor_use"`
  1007. Agent string `gorm:"column:agent" json:"agent" form:"agent"`
  1008. GoodNumber string `gorm:"column:good_number" json:"good_number" form:"good_number"`
  1009. CommdityCode string `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
  1010. SocialSecurityDirectoryCode string `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
  1011. ProductionType string `gorm:"column:production_type" json:"production_type" form:"production_type"`
  1012. SpecialMedical string `gorm:"column:special_medical" json:"special_medical" form:"special_medical"`
  1013. IsMark int64 `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
  1014. Total float64 `gorm:"column:total" json:"total" form:"total"`
  1015. MinNumber int64 `gorm:"column:min_number" json:"min_number" form:"min_number"`
  1016. PackingUnit string `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
  1017. PackingPrice float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
  1018. DefaultCountUnit string `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
  1019. MinUnit string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
  1020. RegisterNumber string `gorm:"column:register_number" json:"register_number" form:"register_number"`
  1021. ProvincesCode string `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
  1022. IsUser int64 `gorm:"column:is_user" json:"is_user" form:"is_user"`
  1023. Number string `gorm:"column:number" json:"number" form:"number"`
  1024. IsWarehouse int64 `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
  1025. BatchRetaiPrice float64 `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
  1026. SumCount int64 `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
  1027. SumInCount int64 `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
  1028. TotalCount int64 `gorm:"column:total_count" json:"total_count" form:"total_count"`
  1029. SumOutCount int64 `gorm:"column:sum_out_count" json:"sum_out_count" form:"sum_out_count"`
  1030. SumCancelCount int64 `gorm:"column:sum_cancel_count" json:"sum_cancel_count" form:"sum_cancel_count"`
  1031. IsPrint int64 `gorm:"column:is_print" json:"is_print" form:"is_print"`
  1032. FirstLetter string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
  1033. ZuobiaoId string `gorm:"column:zuobiao_id" json:"zuobiao_id" form:"zuobiao_id"`
  1034. Bck01b string `gorm:"column:bck01b" json:"bck01b" form:"bck01b"`
  1035. Bby01 string `gorm:"column:bby01" json:"bby01" form:"bby01"`
  1036. }
  1037. func (XtGoodInformation) TableName() string {
  1038. return "xt_good_information"
  1039. }
  1040. type XtBaseDrugtwo struct {
  1041. ID int64 `gorm:"column:id" json:"id" form:"id"`
  1042. DrugName string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
  1043. Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
  1044. Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
  1045. DrugAlias string `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
  1046. DrugAliasPinyin string `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
  1047. DrugAliasWubi string `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
  1048. DrugCategory int64 `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
  1049. DrugSpec string `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
  1050. DrugType int64 `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
  1051. DrugStockLimit string `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
  1052. DrugOriginPlace string `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
  1053. DrugDosageForm int64 `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
  1054. MedicalInsuranceLevel int64 `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
  1055. MaxUnit string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
  1056. MinUnit string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
  1057. UnitMatrixing string `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
  1058. RetailPrice float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
  1059. LastPrice float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
  1060. DrugControl int64 `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
  1061. Number string `gorm:"column:number" json:"number" form:"number"`
  1062. DrugClassify string `gorm:"column:drug_classify" json:"drug_classify" form:"drug_classify"`
  1063. DrugDose float64 `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
  1064. DrugDoseUnit int64 `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
  1065. MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
  1066. Manufacturer int64 `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
  1067. PharmacologyCategory int64 `gorm:"column:pharmacology_category" json:"pharmacology_category" form:"pharmacology_category"`
  1068. StatisticsCategory int64 `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
  1069. Code string `gorm:"column:code" json:"code" form:"code"`
  1070. IsSpecialDiseases int64 `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
  1071. IsRecord int64 `gorm:"column:is_record" json:"is_record" form:"is_record"`
  1072. Agent string `gorm:"column:agent" json:"agent" form:"agent"`
  1073. DrugStatus string `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
  1074. LimitRemark string `gorm:"column:limit_remark" json:"limit_remark" form:"limit_remark"`
  1075. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  1076. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  1077. SingleDose float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  1078. PrescribingNumber float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
  1079. Label int64 `gorm:"column:label" json:"label" form:"label"`
  1080. Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
  1081. IsUseDoctorAdvice int64 `gorm:"column:is_use_doctor_advice" json:"is_use_doctor_advice" form:"is_use_doctor_advice"`
  1082. IsDefault int64 `gorm:"column:is_default" json:"is_default" form:"is_default"`
  1083. IsChargePredict int64 `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
  1084. IsStatisticsWork int64 `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
  1085. IsChargeUse int64 `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
  1086. Status int64 `gorm:"column:status" json:"status" form:"status"`
  1087. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  1088. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  1089. OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
  1090. DrugCode string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
  1091. Dealer int64 `gorm:"column:dealer" json:"dealer" form:"dealer"`
  1092. DoseCode string `gorm:"column:dose_code" json:"dose_code" form:"dose_code"`
  1093. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  1094. DrugRemark string `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
  1095. SocialSecurityDirectoryCode string `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
  1096. IsMark int64 `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
  1097. PrescriptionMark int64 `gorm:"column:prescription_mark" json:"prescription_mark" form:"prescription_mark"`
  1098. HospApprFlag int64 `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
  1099. LmtUsedFlag int64 `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
  1100. Total float64 `gorm:"column:total" json:"total" form:"total"`
  1101. PrescribingNumberUnit string `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
  1102. MinNumber int64 `gorm:"column:min_number" json:"min_number" form:"min_number"`
  1103. Dose string `gorm:"column:dose" json:"dose" form:"dose"`
  1104. DoseUnit string `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
  1105. DrugDay string `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
  1106. MinPrice float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
  1107. ProvincesCode string `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
  1108. IsUser int64 `gorm:"column:is_user" json:"is_user" form:"is_user"`
  1109. SumCount int64 `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
  1110. BatchRetaiPrice float64 `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
  1111. SumInCount int64 `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
  1112. IsPharmacy int64 `gorm:"column:is_pharmacy" json:"is_pharmacy" form:"is_pharmacy"`
  1113. TotalCount int64 `gorm:"column:total_count" json:"total_count" form:"total_count"`
  1114. DrugStockLimitCount int64 `gorm:"column:drug_stock_limit_count" json:"drug_stock_limit_count" form:"drug_stock_limit_count"`
  1115. SumOutCount int64 `gorm:"column:sum_out_count" json:"sum_out_count" form:"sum_out_count"`
  1116. SumCancelCount int64 `gorm:"column:sum_cancel_count" json:"sum_cancel_count" form:"sum_cancel_count"`
  1117. FirstLetter string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
  1118. ZuobiaoId string `gorm:"column:zuobiao_id" json:"zuobiao_id" form:"zuobiao_id"`
  1119. Bby01 string `gorm:"column:bby01" json:"bby01" form:"bby01"`
  1120. Bck01b string `gorm:"column:bck01b" json:"bck01b" form:"bck01b"`
  1121. }
  1122. func (XtBaseDrugtwo) TableName() string {
  1123. return "xt_base_drug"
  1124. }
  1125. type XtHisProject struct {
  1126. ID int64 `gorm:"column:id" json:"id" form:"id"`
  1127. ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
  1128. Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
  1129. Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
  1130. Price float64 `gorm:"column:price" json:"price" form:"price"`
  1131. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  1132. CostClassify int64 `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
  1133. ExecutiveSection int64 `gorm:"column:executive_section" json:"executive_section" form:"executive_section"`
  1134. MedicalCoverage int64 `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
  1135. StatisticalClassification int64 `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
  1136. DiseaseDirectory int64 `gorm:"column:disease_directory" json:"disease_directory" form:"disease_directory"`
  1137. IsRecord int64 `gorm:"column:is_record" json:"is_record" form:"is_record"`
  1138. MedicalCode string `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
  1139. TubeColor int64 `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
  1140. MedicalStatus int64 `gorm:"column:medical_status" json:"medical_status" form:"medical_status"`
  1141. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  1142. Sign int64 `gorm:"column:sign" json:"sign" form:"sign"`
  1143. DefaultNumber string `gorm:"column:default_number" json:"default_number" form:"default_number"`
  1144. IsDefault int64 `gorm:"column:is_default" json:"is_default" form:"is_default"`
  1145. IsCharge int64 `gorm:"column:is_charge" json:"is_charge" form:"is_charge"`
  1146. IsEstimate int64 `gorm:"column:is_estimate" json:"is_estimate" form:"is_estimate"`
  1147. IsWorkload int64 `gorm:"column:is_workload" json:"is_workload" form:"is_workload"`
  1148. Sort string `gorm:"column:sort" json:"sort" form:"sort"`
  1149. DoctorAdvice int64 `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
  1150. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  1151. Status int64 `gorm:"column:status" json:"status" form:"status"`
  1152. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  1153. UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
  1154. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  1155. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  1156. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  1157. NumberDays string `gorm:"column:number_days" json:"number_days" form:"number_days"`
  1158. Total string `gorm:"column:total" json:"total" form:"total"`
  1159. IsMark int64 `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
  1160. SpecailProject int64 `gorm:"column:specail_project" json:"specail_project" form:"specail_project"`
  1161. SocialSecurityDirectoryCode string `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
  1162. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  1163. Category int64 `gorm:"column:category" json:"category" form:"category"`
  1164. IsPrint int64 `gorm:"column:is_print" json:"is_print" form:"is_print"`
  1165. FirstLetter string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
  1166. ZuobiaoId string `gorm:"column:zuobiao_id" json:"zuobiao_id" form:"zuobiao_id"`
  1167. Bck01b string `gorm:"column:bck01b" json:"bck01b" form:"bck01b"`
  1168. Bby01 string `gorm:"column:bby01" json:"bby01" form:"bby01"`
  1169. }
  1170. func (XtHisProject) TableName() string {
  1171. return "xt_his_project"
  1172. }
  1173. func Saved(drug models.BaseDrugLib) {
  1174. writeDb.Create(&drug)
  1175. }
  1176. func Savegd(good GoodInfotwo) {
  1177. writeDb.Create(&good)
  1178. }
  1179. type GoodInfotwo struct {
  1180. ID int64 `gorm:"column:id" json:"id" form:"id"`
  1181. GoodCode string `gorm:"column:good_code" json:"good_code" form:"good_code"`
  1182. SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
  1183. GoodTypeId int64 `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
  1184. GoodUnit int64 `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
  1185. BuyPrice float64 `gorm:"column:buy_price" json:"buy_price" form:"buy_price"`
  1186. SellPrice float64 `gorm:"column:sell_price" json:"sell_price" form:"sell_price"`
  1187. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  1188. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  1189. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  1190. Manufacturer int64 `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
  1191. Dealer int64 `gorm:"column:dealer" json:"dealer" form:"dealer"`
  1192. ExpiryDateWarnDayCount int64 `gorm:"column:expiry_date_warn_day_count" json:"expiry_date_warn_day_count" form:"expiry_date_warn_day_count"`
  1193. StockWarnCount int64 `gorm:"column:stock_warn_count" json:"stock_warn_count" form:"stock_warn_count"`
  1194. IsReuse int64 `gorm:"column:is_reuse" json:"is_reuse" form:"is_reuse"`
  1195. Status int64 `gorm:"column:status" json:"status" form:"status"`
  1196. FilmArea string `gorm:"column:film_area" json:"film_area" form:"film_area"`
  1197. IsUse int64 `gorm:"column:is_use" json:"is_use" form:"is_use"`
  1198. FilmMaterialQuality string `gorm:"column:film_material_quality" json:"film_material_quality" form:"film_material_quality"`
  1199. OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
  1200. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  1201. Creater int64 `gorm:"column:creater" json:"creater" form:"creater"`
  1202. GoodName string `gorm:"column:good_name" json:"good_name" form:"good_name"`
  1203. Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
  1204. Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
  1205. GoodKind int64 `gorm:"column:good_kind" json:"good_kind" form:"good_kind"`
  1206. MedicalInsuranceLevel int64 `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
  1207. RetailPrice float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
  1208. MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
  1209. ProvincesCode string `gorm:"column:provinces_code" json:"provinces_code" form:"provinces_code"`
  1210. FirstLetter string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
  1211. IsSpecialDiseases int64 `gorm:"column:is_special_diseases" json:"is_special_diseases" form:"is_special_diseases"`
  1212. IsRecord int64 `gorm:"column:is_record" json:"is_record" form:"is_record"`
  1213. StatisticsCategory int64 `gorm:"column:statistics_category" json:"statistics_category" form:"statistics_category"`
  1214. GoodStatus string `gorm:"column:good_status" json:"good_status" form:"good_status"`
  1215. DefaultCount int64 `gorm:"column:default_count" json:"default_count" form:"default_count"`
  1216. Sign int64 `gorm:"column:sign" json:"sign" form:"sign"`
  1217. IsDefault int64 `gorm:"column:is_default" json:"is_default" form:"is_default"`
  1218. IsChargeUse int64 `gorm:"column:is_charge_use" json:"is_charge_use" form:"is_charge_use"`
  1219. IsChargePredict int64 `gorm:"column:is_charge_predict" json:"is_charge_predict" form:"is_charge_predict"`
  1220. IsStatisticsWork int64 `gorm:"column:is_statistics_work" json:"is_statistics_work" form:"is_statistics_work"`
  1221. Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
  1222. IsDoctorUse int64 `gorm:"column:is_doctor_use" json:"is_doctor_use" form:"is_doctor_use"`
  1223. Agent string `gorm:"column:agent" json:"agent" form:"agent"`
  1224. GoodNumber string `gorm:"column:good_number" json:"good_number" form:"good_number"`
  1225. CommdityCode string `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
  1226. SocialSecurityDirectoryCode string `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
  1227. ProductionType string `gorm:"column:production_type" json:"production_type" form:"production_type"`
  1228. SpecialMedical string `gorm:"column:special_medical" json:"special_medical" form:"special_medical"`
  1229. IsMark int64 `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
  1230. MinNumber int64 `gorm:"column:min_number" json:"min_number" form:"min_number"`
  1231. PackingUnit string `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
  1232. PackingPrice float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
  1233. DefaultCountUnit string `gorm:"column:default_count_unit" json:"default_count_unit" form:"default_count_unit"`
  1234. MinUnit string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
  1235. Total float64 `gorm:"column:total" json:"total" form:"total"`
  1236. RegisterNumber string `gorm:"column:register_number" json:"register_number" form:"register_number"`
  1237. IsUser int64 `gorm:"column:is_user" json:"is_user" form:"is_user"`
  1238. Number string `gorm:"column:number" json:"number" form:"number"`
  1239. IsWarehouse int64 `gorm:"column:is_warehouse" json:"is_warehouse" form:"is_warehouse"`
  1240. SumCount int64 `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
  1241. BatchRetaiPrice float64 `gorm:"column:batch_retai_price" json:"batch_retai_price" form:"batch_retai_price"`
  1242. SumInCount int64 `gorm:"column:sum_in_count" json:"sum_in_count" form:"sum_in_count"`
  1243. Bbx01 int64 `gorm:"column:bbx01" json:"bbx01" form:"bbx01"`
  1244. Bby01 int64 `gorm:"column:bby01" json:"bby01" form:"bby01"`
  1245. }
  1246. func (GoodInfotwo) TableName() string {
  1247. return "xt_good_information"
  1248. }
  1249. func GetHisPatient4444555() (paitent []*models.HisPatient, err error) {
  1250. err = XTReadDB().Model(&paitent).Where("user_org_id = 10485 and status = 1 AND record_date >= 1696089600").Find(&paitent).Error
  1251. return paitent, err
  1252. }
  1253. func UpDateNumber(id int64, number string) {
  1254. writeDb.Model(&models.GoodInfo{}).Where("id = ?", id).Updates(map[string]interface{}{"number": number})
  1255. }