vm_service.go 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package service
  2. import (
  3. "Xcx_New/models"
  4. "strconv"
  5. )
  6. func CreateVMOrgPatient(patients *models.VMOrgPatients) {
  7. writeDb.Model(&models.VMOrgPatients{}).Create(&patients)
  8. var lapseto models.PatientLapseto
  9. lapseto.PatientId = patients.ID
  10. lapseto.LapsetoType = patients.Lapseto
  11. lapseto.CreatedTime = patients.CreatedTime
  12. lapseto.UpdatedTime = patients.CreatedTime
  13. lapseto.Status = 1
  14. lapseto.LapsetoTime = patients.CreatedTime
  15. writeDb.Create(&lapseto)
  16. if len(patients.ContagionIds) > 0 {
  17. var diseases models.InfectiousDiseases
  18. diseases.PatientId = patients.ID
  19. diseases.Status = 1
  20. diseases.UpdatedTime = patients.UpdatedTime
  21. diseases.CreatedTime = patients.CreatedTime
  22. id, _ := strconv.ParseInt(patients.ContagionIds, 10, 64)
  23. diseases.DiseaseId = id
  24. writeDb.Create(&diseases)
  25. }
  26. }
  27. func CreateVMOrgNewPatient(patientsNew *models.XtPatientsNew) {
  28. writeDb.Model(&models.XtPatientsNew{}).Create(&patientsNew)
  29. }
  30. func CreateVMZone(zone *models.VMDeviceZone) {
  31. writeDb.Model(&models.VMDeviceZone{}).Create(&zone)
  32. }
  33. func CreateVMGroup(group *models.VMDeviceGroup) {
  34. writeDb.Model(&models.VMDeviceGroup{}).Create(&group)
  35. }
  36. func CreateVMDeviceNumber(number *models.VMDeviceNumber) {
  37. writeDb.Model(&models.VMDeviceNumber{}).Create(&number)
  38. }
  39. func CreateVMSch(sch *models.VMSchedule) {
  40. writeDb.Model(&models.VMSchedule{}).Create(&sch)
  41. }
  42. func CreateVMSchMode(schMode *models.VMPatientScheduleTemplateMode) {
  43. writeDb.Model(&models.VMPatientScheduleTemplateMode{}).Create(&schMode)
  44. }
  45. func CreateVMSchTemplateId(schTemplateId *models.VMPatientScheduleTemplateId) {
  46. writeDb.Model(&models.VMPatientScheduleTemplateId{}).Create(&schTemplateId)
  47. }
  48. func CreateVMSchTemplate(schTemplate *models.VMPatientScheduleTemplateItem) {
  49. writeDb.Model(&models.VMPatientScheduleTemplateItem{}).Create(&schTemplate)
  50. }
  51. func CreateVMPrescription(sys *models.SystemPrescription) {
  52. writeDb.Model(&models.SystemPrescription{}).Create(&sys)
  53. }
  54. func CreatedDeviceMode(mode *models.VMDeviceMode) {
  55. UserWriteDB().Model(&models.VMDeviceMode{}).Create(&mode)
  56. }
  57. func GetFirstDeviceMode(orgid int64) (models.VMDeviceMode, error) {
  58. mode := models.VMDeviceMode{}
  59. err = UserReadDB().Where("user_org_id = ? and status =1", orgid).First(&mode).Error
  60. return mode, err
  61. }
  62. func GetFirstBedNumber(orgid int64) (models.VMDeviceNumber, error) {
  63. number := models.VMDeviceNumber{}
  64. err := XTReadDB().Where("org_id = ? and status =1", orgid).First(&number).Error
  65. return number, err
  66. }
  67. func CreateDeviceAddMacher(addmacher *models.VmDeviceAddmacher) {
  68. UserWriteDB().Model(&models.VmDeviceAddmacher{}).Create(&addmacher)
  69. }
  70. func GetLastMacher(orgid int64) (models.VmDeviceAddmacher, error) {
  71. addmacher := models.VmDeviceAddmacher{}
  72. err := UserReadDB().Where("user_org_id = ? and status =1", orgid).First(&addmacher).Error
  73. return addmacher, err
  74. }
  75. func CreatedTreateMode(treatmentmode *models.VmDeviceTreatmentmode) {
  76. XTWriteDB().Model(&models.VmDeviceTreatmentmode{}).Create(&treatmentmode)
  77. }
  78. func CreateVMPrintTemplate(template *models.VMGobalTemplate) (err error) {
  79. err = writeDb.Model(&models.VMGobalTemplate{}).Create(template).Error
  80. return
  81. }