bl_service.go 49KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  1. package service
  2. import (
  3. "fmt"
  4. "github.com/jinzhu/gorm"
  5. "strconv"
  6. "strings"
  7. "time"
  8. )
  9. type HisOrder struct {
  10. ID int64 `gorm:"column:id" json:"id" form:"id"`
  11. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  12. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  13. SettleAccountsDate int64 `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
  14. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  15. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  16. Status int64 `gorm:"column:status" json:"status" form:"status"`
  17. Number string `gorm:"column:number" json:"number" form:"number"`
  18. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  19. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  20. MdtrtId string `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
  21. XtHisPatient XtHisPatient `gorm:"ForeignKey:MdtrtId;AssociationForeignKey:Number" json:"his_patient"`
  22. }
  23. func (HisOrder) TableName() string {
  24. return "his_order"
  25. }
  26. type XtHisPatient struct {
  27. ID int64 `gorm:"column:id" json:"id" form:"id"`
  28. BalanceAccountsType int64 `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
  29. MedicalInsuranceNumber string `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
  30. Name string `gorm:"column:name" json:"name" form:"name"`
  31. Gender int64 `gorm:"column:gender" json:"gender" form:"gender"`
  32. IdType int64 `gorm:"column:id_type" json:"id_type" form:"id_type"`
  33. MedicalTreatmentType int64 `gorm:"column:medical_treatment_type" json:"medical_treatment_type" form:"medical_treatment_type"`
  34. Birthday int64 `gorm:"column:birthday" json:"birthday" form:"birthday"`
  35. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  36. Age int64 `gorm:"column:age" json:"age" form:"age"`
  37. PhoneNumber string `gorm:"column:phone_number" json:"phone_number" form:"phone_number"`
  38. IdCardNo string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
  39. RegisterType int64 `gorm:"column:register_type" json:"register_type" form:"register_type"`
  40. AdminUserId int64 `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
  41. Departments int64 `gorm:"column:departments" json:"departments" form:"departments"`
  42. IsNeedCostOfProduction int64 `gorm:"column:is_need_cost_of_production" json:"is_need_cost_of_production" form:"is_need_cost_of_production"`
  43. RegisterCost float64 `gorm:"column:register_cost" json:"register_cost" form:"register_cost"`
  44. TreatmentCost float64 `gorm:"column:treatment_cost" json:"treatment_cost" form:"treatment_cost"`
  45. CostOfProduction float64 `gorm:"column:cost_of_production" json:"cost_of_production" form:"cost_of_production"`
  46. Total float64 `gorm:"column:total" json:"total" form:"total"`
  47. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  48. Status int64 `gorm:"column:status" json:"status" form:"status"`
  49. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  50. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  51. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  52. Number string `gorm:"column:number" json:"number" form:"number"`
  53. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  54. IsReturn int64 `gorm:"column:is_return" json:"is_return" form:"is_return"`
  55. Phone string `gorm:"column:phone" json:"phone" form:"phone"`
  56. SocialType int64 `gorm:"column:social_type" json:"social_type" form:"social_type"`
  57. IdCardType int64 `gorm:"column:id_card_type" json:"id_card_type" form:"id_card_type"`
  58. PType string `gorm:"column:p_type" json:"p_type" form:"p_type"`
  59. Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
  60. SickType int64 `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
  61. }
  62. func (XtHisPatient) TableName() string {
  63. return "his_patient"
  64. }
  65. type HisPrescription struct {
  66. ID int64 `gorm:"column:id" json:"id" form:"id"`
  67. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  68. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  69. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  70. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  71. Status int64 `gorm:"column:status" json:"status" form:"status"`
  72. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  73. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  74. Number string `gorm:"column:number" json:"number" form:"number"`
  75. Type int64 `gorm:"column:type" json:"type" form:"type"`
  76. Doctor string `gorm:"column:doctor" json:"doctor" form:"doctor"`
  77. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  78. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  79. OrderStatus int64 `gorm:"column:order_status" json:"order_status" form:"order_status"`
  80. PreTime int64 `gorm:"column:pre_time" json:"pre_time" form:"pre_time"`
  81. BatchNumber string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
  82. PrescriptionNumber string `gorm:"column:prescription_number" json:"prescription_number" form:"prescription_number"`
  83. HisOrder HisOrder `gorm:"ForeignKey:Number;AssociationForeignKey:BatchNumber" json:"order"`
  84. Total string `gorm:"-" json:"total" form:"total"`
  85. PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
  86. MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
  87. }
  88. func (HisPrescription) TableName() string {
  89. return "his_prescription"
  90. }
  91. type CmSample struct {
  92. HospitalBarcode string `gorm:"column:hospital_barcode" json:"hospital_barcode" form:"hospital_barcode"`
  93. Hospsamplenumber string `gorm:"column:hospsamplenumber" json:"hospsamplenumber" form:"hospsamplenumber"`
  94. Pno string `gorm:"column:pno" json:"pno" form:"pno"`
  95. Ptype string `gorm:"column:ptype" json:"ptype" form:"ptype"`
  96. Bedno string `gorm:"column:bedno" json:"bedno" form:"bedno"`
  97. Pname string `gorm:"column:pname" json:"pname" form:"pname"`
  98. Psex string `gorm:"column:psex" json:"psex" form:"psex"`
  99. Page string `gorm:"column:page" json:"page" form:"page"`
  100. Pageunit string `gorm:"column:pageunit" json:"pageunit" form:"pageunit"`
  101. Ptel string `gorm:"column:ptel" json:"ptel" form:"ptel"`
  102. Stature string `gorm:"column:stature" json:"stature" form:"stature"`
  103. Avoirdupois string `gorm:"column:avoirdupois" json:"avoirdupois" form:"avoirdupois"`
  104. Gravweek string `gorm:"column:gravweek" json:"gravweek" form:"gravweek"`
  105. Collectiongravday string `gorm:"column:collectiongravday" json:"collectiongravday" form:"collectiongravday"`
  106. Birthday time.Time `gorm:"column:birthday" json:"birthday" form:"birthday"`
  107. Departname string `gorm:"column:departname" json:"departname" form:"departname"`
  108. Docname string `gorm:"column:docname" json:"docname" form:"docname"`
  109. Doctortel string `gorm:"column:doctortel" json:"doctortel" form:"doctortel"`
  110. Diagnosis string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
  111. Stype string `gorm:"column:stype" json:"stype" form:"stype"`
  112. Samstate string `gorm:"column:samstate" json:"samstate" form:"samstate"`
  113. Desccode string `gorm:"column:desccode" json:"desccode" form:"desccode"`
  114. Descr string `gorm:"column:descr" json:"descr" form:"descr"`
  115. Sampletime time.Time `gorm:"column:sampletime" json:"sampletime" form:"sampletime"`
  116. Senddate time.Time `gorm:"column:senddate" json:"senddate" form:"senddate"`
  117. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  118. Idcard string `gorm:"column:idcard" json:"idcard" form:"idcard"`
  119. CardClass string `gorm:"column:cardclass" json:"cardclass" form:"cardclass"`
  120. }
  121. func (CmSample) TableName() string {
  122. return "cm_sample"
  123. }
  124. type CmLisitems struct {
  125. ItemCode string `gorm:"column:item_code" json:"item_code" form:"item_code"`
  126. ItemName string `gorm:"column:item_name" json:"item_name" form:"item_name"`
  127. Testmethod string `gorm:"column:testmethod" json:"testmethod" form:"testmethod"`
  128. Iscompound string `gorm:"column:iscmpound" json:"iscmpound" form:"iscmpound"`
  129. DepartmentName string `gorm:"column:department_name" json:"department_name" form:"department_name"`
  130. }
  131. func (CmLisitems) TableName() string {
  132. return "v_cm_listtems"
  133. }
  134. type HisLabelPrintInfo struct {
  135. ID int64 `gorm:"column:id" json:"id" form:"id"`
  136. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  137. Number string `gorm:"column:number" json:"number" form:"number"`
  138. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  139. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  140. DoctorId int64 `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
  141. Status int64 `gorm:"column:status" json:"status" form:"status"`
  142. ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
  143. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  144. IsPrint int64 `gorm:"column:is_print" json:"is_print" form:"is_print"`
  145. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  146. ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
  147. PProjectId int64 `gorm:"column:p_project_id" json:"p_project_id" form:"p_project_id"`
  148. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  149. DoctorName string `gorm:"column:doctor_name" json:"doctor_name" form:"doctor_name"`
  150. PatientName string `gorm:"column:patient_name" json:"patient_name" form:"patient_name"`
  151. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  152. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  153. HisPrescriptionProject HisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:PProjectId" json:"project"`
  154. }
  155. func (HisLabelPrintInfo) TableName() string {
  156. return "his_label_print_info"
  157. }
  158. type LisSyncProcessStatusInfo struct {
  159. ID int64 `gorm:"column:id" json:"id" form:"id"`
  160. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  161. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  162. Status int64 `gorm:"column:status" json:"status" form:"status"`
  163. LastId int64 `gorm:"column:last_id" json:"last_id" form:"last_id"`
  164. OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
  165. IsInsert int64 `gorm:"column:is_insert" json:"is_insert" form:"is_insert"`
  166. IsResult int64 `gorm:"column:is_result" json:"is_result" form:"is_result"`
  167. ResultDate int64 `gorm:"column:result_date" json:"result_date" form:"result_date"`
  168. }
  169. func (LisSyncProcessStatusInfo) TableName() string {
  170. return "lis_sync_process_status_info"
  171. }
  172. type CmResult struct {
  173. Barcode string `gorm:"column:barcode" json:"barcode" form:"barcode"`
  174. Itemcode string `gorm:"column:itemcode" json:"itemcode" form:"itemcode"`
  175. Itemname string `gorm:"column:itemname" json:"itemname" form:"itemname"`
  176. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  177. Result string `gorm:"column:result" json:"result" form:"result"`
  178. Refrange string `gorm:"column:refrange" json:"refrange" form:"refrange"`
  179. Ts string `gorm:"column:ts" json:"ts" form:"ts"`
  180. Jyys string `gorm:"column:jyys" json:"jyys" form:"jyys"`
  181. Shys string `gorm:"column:shys" json:"shys" form:"shys"`
  182. Hycode string `gorm:"column:hycode" json:"hycode" form:"hycode"`
  183. Reptype string `gorm:"column:reptype" json:"reptype" form:"reptype"`
  184. TJH string `gorm:"column:tjh" json:"tjh" form:"tjh"`
  185. Repdate time.Time `gorm:"column:repdate" json:"repdate" form:"repdate"`
  186. Groupname string `gorm:"column:groupname" json:"groupname" form:"groupname"`
  187. Groupcode string `gorm:"column:groupcode" json:"groupcode" form:"groupcode"`
  188. Brkb string `gorm:"column:brkb" json:"brkb" form:"brkb"`
  189. Mic string `gorm:"column:mic" json:"mic" form:"mic"`
  190. Yjjy string `gorm:"column:yjjy" json:"yjjy" form:"yjjy"`
  191. Name string `gorm:"column:name" json:"name" form:"name"`
  192. }
  193. func (CmResult) TableName() string {
  194. return "v_cm_result"
  195. }
  196. type LisSyncResultStatusInfo struct {
  197. ID int64 `gorm:"column:id" json:"id" form:"id"`
  198. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  199. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  200. Status int64 `gorm:"column:status" json:"status" form:"status"`
  201. LastId int64 `gorm:"column:last_id" json:"last_id" form:"last_id"`
  202. OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
  203. IsResult int64 `gorm:"column:is_result" json:"is_result" form:"is_result"`
  204. ResultDate int64 `gorm:"column:result_date" json:"result_date" form:"result_date"`
  205. }
  206. func (LisSyncResultStatusInfo) TableName() string {
  207. return "lis_sync_result_status_info"
  208. }
  209. func GetLastSyncRecord(org_id int64) (record LisSyncProcessStatusInfo, err error) {
  210. err = readMiddleDb.Model(&LisSyncProcessStatusInfo{}).Where("org_id = ? AND status = 1", org_id).Last(&record).Error
  211. return
  212. }
  213. func GetLastSyncResultRecord(org_id int64) (record LisSyncResultStatusInfo, err error) {
  214. err = readDb.Model(&LisSyncResultStatusInfo{}).Where("org_id = ? AND status = 1", org_id).Last(&record).Error
  215. return
  216. }
  217. func GetResultRecord() (record []CmResult, err error) {
  218. err = dataBase.Model(&CmResult{}).Order("barcode asc").Limit(1).Find(&record).Error
  219. return
  220. }
  221. func GetResultRecordByID(id int64) (record []*CmResult, err error) {
  222. err = readDb.Model(&CmResult{}).Where("barcode > ?", id).Order("barcode desc").Find(&record).Error
  223. return
  224. }
  225. func GetSaveResultRecord(record LisSyncResultStatusInfo) (err error) {
  226. err = dataBase.Save(record).Error
  227. return
  228. }
  229. func GetLisDataById(org_id int64, last_id int64) (list []*HisLabelPrintInfo, err error) {
  230. //err = readDb.Model(&HisLabelPrintInfo{}).Where("id > ? AND user_org_id = ? AND status = 1", last_id, org_id).Find(&list).Error
  231. err = readDb.Model(&HisLabelPrintInfo{}).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  232. return db.Preload("HisPrescription", func(db *gorm.DB) *gorm.DB {
  233. return db.Preload("HisOrder", func(db *gorm.DB) *gorm.DB {
  234. return db.Preload("XtHisPatient", func(db *gorm.DB) *gorm.DB {
  235. return db.Where("status = 1")
  236. }).Where("status = 1")
  237. }).Where("status = 1")
  238. }).Where("status = 1")
  239. }).Where("id > ? AND user_org_id = ? AND status = 1", last_id, org_id).Limit(100).Find(&list).Error
  240. return
  241. }
  242. func GetAllLisData(org_id int64) (list []*HisLabelPrintInfo, err error) {
  243. err = readDb.Model(&HisLabelPrintInfo{}).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  244. return db.Preload("HisPrescription", func(db *gorm.DB) *gorm.DB {
  245. return db.Preload("HisOrder", func(db *gorm.DB) *gorm.DB {
  246. return db.Preload("XtHisPatient", func(db *gorm.DB) *gorm.DB {
  247. return db.Where("status = 1")
  248. }).Where("status = 1")
  249. }).Where("status = 1")
  250. }).Where("status = 1")
  251. }).Where("user_org_id = ? AND status = 1", org_id).Limit(100).Find(&list).Error
  252. return
  253. }
  254. func GetAllLisResultData(org_id int64) (list []*CmResult, err error) {
  255. err = readDb.Model(&CmResult{}).Where("user_org_id = ? AND status = 1 ", org_id).Find(&list).Error
  256. return
  257. }
  258. func GetLisResultDataByRecord(org_id int64) (list []*CmResult, err error) {
  259. err = readDb.Model(&CmResult{}).Where("user_org_id = ? AND status = 1", org_id).Find(&list).Error
  260. return
  261. }
  262. //插入中间件逻辑
  263. func GetDataInsertDB(org_id int64) {
  264. record, _ := GetLastSyncRecord(org_id)
  265. if record.ID == 0 {
  266. var cms_arr []CmSample
  267. list, _ := GetAllLisData(org_id)
  268. //插入中间库中
  269. for _, item := range list {
  270. fmt.Println(item.HisPrescriptionProject)
  271. if item.ItemId > 0 {
  272. var cms CmSample
  273. cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
  274. cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
  275. cms.Ptype = "门诊"
  276. cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
  277. if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
  278. cms.Psex = "男"
  279. } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
  280. cms.Psex = "女"
  281. }
  282. cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
  283. cms.Pageunit = "岁"
  284. cms.Departname = "肾病学专业"
  285. role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
  286. cms.Docname = role.UserName
  287. diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
  288. //var config []*models.HisXtDiagnoseConfig
  289. var name string
  290. for _, item := range diagnosis_ids {
  291. id, _ := strconv.ParseInt(item, 10, 64)
  292. diagnosisConfig, _ := FindDiagnoseById(id)
  293. if len(name) == 0 {
  294. name = diagnosisConfig.ClassName
  295. } else {
  296. name = name + "," + diagnosisConfig.ClassName
  297. }
  298. }
  299. cms.Diagnosis = name
  300. cms.Stype = ""
  301. cms.Samstate = ""
  302. cms.Desccode = strconv.FormatInt(item.ID, 10)
  303. cms.Descr = item.ProjectName
  304. data, _ := strconv.ParseInt(strconv.FormatInt(item.Ctime, 10), 10, 64)
  305. datatime := time.Unix(data/1000, 0)
  306. cms.Sampletime = datatime
  307. cms.Senddate = time.Now()
  308. cms_arr = append(cms_arr, cms)
  309. } else {
  310. var cms CmSample
  311. cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
  312. cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
  313. cms.Ptype = "门诊"
  314. cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
  315. if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
  316. cms.Psex = "男"
  317. } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
  318. cms.Psex = "女"
  319. }
  320. cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
  321. cms.Pageunit = "岁"
  322. cms.Departname = "肾病学专业"
  323. role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
  324. cms.Docname = role.UserName
  325. diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
  326. //var config []*models.HisXtDiagnoseConfig
  327. var name string
  328. for _, item := range diagnosis_ids {
  329. id, _ := strconv.ParseInt(item, 10, 64)
  330. diagnosisConfig, _ := FindDiagnoseById(id)
  331. if len(name) == 0 {
  332. name = diagnosisConfig.ClassName
  333. } else {
  334. name = name + "," + diagnosisConfig.ClassName
  335. }
  336. }
  337. cms.Diagnosis = name
  338. cms.Stype = ""
  339. cms.Samstate = ""
  340. cms.Desccode = strconv.FormatInt(item.ID, 10)
  341. cms.Descr = item.ProjectName
  342. tm := time.Unix(item.Ctime, 0)
  343. //data, _ := strconv.ParseInt(strconv.FormatInt(item.Ctime, 10), 10, 64)
  344. //datatime := time.Unix(data/1000, 0)
  345. cms.Sampletime = tm
  346. cms.Senddate = time.Now()
  347. cms_arr = append(cms_arr, cms)
  348. }
  349. }
  350. //插入到中间库
  351. for _, item := range cms_arr {
  352. if len(item.Pno) > 0 {
  353. blDb.Save(item)
  354. }
  355. }
  356. //插入一条插入中间库记录数据
  357. var info LisSyncProcessStatusInfo
  358. info.Ctime = time.Now().Unix()
  359. info.Status = 1
  360. info.Mtime = time.Now().Unix()
  361. info.OrgId = org_id
  362. info.IsInsert = 1
  363. info.IsResult = 0
  364. info.LastId = list[len(list)-1].ID
  365. info.ResultDate = 0
  366. writeMiddleDb.Save(&info)
  367. } else {
  368. var cms_arr []CmSample
  369. if record.LastId != 0 {
  370. list, _ := GetLisDataById(org_id, record.LastId)
  371. //插入中间库中
  372. for _, item := range list {
  373. if item.ItemId > 0 {
  374. fmt.Println()
  375. //teams, _ := GetProjectTeamList(org_id, item.ItemId, item.PrescriptionId)
  376. //for _, subItem := range teams {
  377. var cms CmSample
  378. cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
  379. //cms.Hospsamplenumber = strconv.FormatInt(item.ID, 10)
  380. cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
  381. cms.Ptype = "门诊"
  382. cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
  383. if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
  384. cms.Psex = "男"
  385. } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
  386. cms.Psex = "女"
  387. }
  388. cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
  389. cms.Pageunit = "岁"
  390. cms.Departname = "肾病学专业"
  391. role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
  392. cms.Docname = role.UserName
  393. diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
  394. //var config []*models.HisXtDiagnoseConfig
  395. var name string
  396. for _, item := range diagnosis_ids {
  397. id, _ := strconv.ParseInt(item, 10, 64)
  398. diagnosisConfig, _ := FindDiagnoseById(id)
  399. if len(name) == 0 {
  400. name = diagnosisConfig.ClassName
  401. } else {
  402. name = name + "," + diagnosisConfig.ClassName
  403. }
  404. }
  405. cms.Diagnosis = name
  406. cms.Stype = ""
  407. cms.Samstate = ""
  408. cms.Desccode = strconv.FormatInt(item.ID, 10)
  409. cms.Descr = item.ProjectName
  410. //data, _ := strconv.ParseInt(strconv.FormatInt(item.Ctime, 10), 10, 64)
  411. //datatime := time.Unix(data/1000, 0)
  412. //cms.Sampletime = datatime
  413. tm := time.Unix(item.Ctime, 0)
  414. cms.Sampletime = tm
  415. cms.Senddate = time.Now()
  416. cms_arr = append(cms_arr, cms)
  417. } else {
  418. var cms CmSample
  419. cms.HospitalBarcode = strconv.FormatInt(item.ID, 10)
  420. //cms.Hospsamplenumber = strconv.FormatInt(item.ID, 10)
  421. cms.Pno = item.HisPrescriptionProject.HisPrescription.HisOrder.MdtrtId
  422. cms.Ptype = "门诊"
  423. cms.Pname = item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Name
  424. if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 1 {
  425. cms.Psex = "男"
  426. } else if item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Gender == 2 {
  427. cms.Psex = "女"
  428. }
  429. cms.Page = strconv.FormatInt(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Age, 10)
  430. cms.Pageunit = "岁"
  431. cms.Departname = "肾病学专业"
  432. role, _ := GetAdminUserInfoByID(org_id, item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Doctor)
  433. cms.Docname = role.UserName
  434. diagnosis_ids := strings.Split(item.HisPrescriptionProject.HisPrescription.HisOrder.XtHisPatient.Diagnosis, ",")
  435. var name string
  436. for _, item := range diagnosis_ids {
  437. id, _ := strconv.ParseInt(item, 10, 64)
  438. diagnosisConfig, _ := FindDiagnoseById(id)
  439. if len(name) == 0 {
  440. name = diagnosisConfig.ClassName
  441. } else {
  442. name = name + "," + diagnosisConfig.ClassName
  443. }
  444. }
  445. cms.Diagnosis = name
  446. cms.Stype = ""
  447. cms.Samstate = ""
  448. cms.Desccode = strconv.FormatInt(item.ID, 10)
  449. cms.Descr = item.ProjectName
  450. tm := time.Unix(item.Ctime, 0)
  451. cms.Sampletime = tm
  452. cms.Senddate = time.Now()
  453. cms_arr = append(cms_arr, cms)
  454. }
  455. }
  456. //插入一条插入中间库记录数据
  457. for _, item := range cms_arr {
  458. if len(item.Pno) > 0 {
  459. blDb.Save(item)
  460. }
  461. }
  462. //插入一条插入中间库记录数据
  463. var info LisSyncProcessStatusInfo
  464. info.Ctime = time.Now().Unix()
  465. info.Status = 1
  466. info.Mtime = time.Now().Unix()
  467. info.OrgId = org_id
  468. info.IsInsert = 1
  469. info.IsResult = 0
  470. info.LastId = list[len(list)-1].ID
  471. info.ResultDate = 0
  472. writeMiddleDb.Save(&info)
  473. }
  474. }
  475. }
  476. //获取lis返回检验检查结果数据
  477. func GetResultDataInsertDB(org_id int64) (result []*CmResult) {
  478. record, _ := GetLastSyncResultRecord(org_id)
  479. if record.ID == 0 {
  480. list, err := GetResultRecord()
  481. if err == nil {
  482. fmt.Println(list)
  483. //插入一条查询检验检查结果记录状态数据
  484. var info LisSyncResultStatusInfo
  485. info.Ctime = time.Now().Unix()
  486. info.Status = 1
  487. info.Mtime = time.Now().Unix()
  488. info.OrgId = org_id
  489. info.IsResult = 1
  490. code, _ := strconv.ParseInt(list[0].Barcode, 10, 64)
  491. info.LastId = code
  492. info.ResultDate = time.Now().Unix()
  493. writeMiddleDb.Save(&info)
  494. //插入到系统检验检查数据
  495. //for _, item := range list{}
  496. //for _, item := range list {
  497. //
  498. // project_id := int64(0)
  499. // if len(item.Barcode) > 0 {
  500. // project_id, _ = GetGzjhProjectID(org_id, item.Groupname)
  501. // } else {
  502. // continue
  503. // }
  504. // printInfo, _ := GetHisLabelPrintInfoById(item.Barcode)
  505. //
  506. // item_id, _ := GetItemID(org_id, item.Groupname, item.Itemname, project_id)
  507. //
  508. // tx := writeMiddleDb.Begin()
  509. // var inspection models.MiddleInspection
  510. // var inspection_reference models.MiddleInspectionReference
  511. //
  512. // recordDateStr := ""
  513. //
  514. // if len(item.Repdate) == 0 {
  515. // recordDateStr = time.Now().Format("2006-01-02 15:04")
  516. // }
  517. //
  518. // inspect_date := item.Repdate
  519. // date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", recordDateStr)
  520. // record_date, _ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
  521. // var total int
  522. // var RangeOptions string
  523. // var RangeMin string
  524. // var RangeMax string
  525. // // 判断检查类型
  526. // var ItemType int
  527. // if strings.Contains(item.Refrange, "[") && strings.Contains(item.Refrange, "]") {
  528. // ItemType = 1
  529. //
  530. // } else {
  531. // ItemType = 2
  532. //
  533. // }
  534. //
  535. // if ItemType == 1 {
  536. // item.Refrange = strings.Trim(item.Refrange, "[")
  537. // item.Refrange = strings.Trim(item.Refrange, "]")
  538. // Range := strings.Split(item.Refrange, "-")
  539. // RangeMin = Range[0]
  540. // RangeMax = Range[1]
  541. // } else {
  542. // RangeOptions = item.Refrange
  543. // }
  544. //
  545. // err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
  546. // if inspection_reference.ID > 0 {
  547. // ItemType = inspection_reference.RangeType
  548. // }
  549. // if total <= 0 {
  550. // inspection_reference.OrgId = org_id
  551. // inspection_reference.ProjectName = item.Groupname
  552. // inspection_reference.Project = item.Groupname
  553. // inspection_reference.ProjectId = project_id
  554. // inspection_reference.ItemName = item.Itemname
  555. // inspection_reference.ItemNameAddition = item.Barcode
  556. // inspection_reference.ItemId = item_id
  557. // inspection_reference.RangeType = ItemType
  558. // inspection_reference.RangeMin = RangeMin
  559. // inspection_reference.RangeMax = RangeMax
  560. // inspection_reference.RangeOptions = RangeOptions
  561. // inspection_reference.Unit = item.Unit
  562. // inspection_reference.Status = 1
  563. // inspection_reference.CreatedTime = time.Now().Unix()
  564. // inspection_reference.UpdatedTime = time.Now().Unix()
  565. // inspection_reference.InspectDate = inspect_date
  566. // inspection_reference.UTime = inspect_date
  567. // err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
  568. // if err != nil {
  569. // tx.Rollback()
  570. // }
  571. // }
  572. //
  573. // var itotal int
  574. // err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date, printInfo.PatientId).Find(&inspection).Count(&itotal).Error
  575. // if itotal <= 0 {
  576. // //item.Result = strings.Replace(item.Result, "&gt;", ">", -1)
  577. // //item.Result = strings.Replace(item.Result, "&lt;", "<", -1)
  578. // inspection.PatientId = printInfo.PatientId
  579. // inspection.OrgId = org_id
  580. // inspection.ProjectId = project_id
  581. // inspection.ItemName = inspection_reference.ItemName
  582. // inspection.ProjectName = inspection_reference.ProjectName
  583. // inspection.InspectType = ItemType
  584. // inspection.ItemId = item_id
  585. // inspection.InspectValue = item.Result
  586. // inspection.InspectDate = inspect_date
  587. // inspection.RecordDate = record_date.Unix()
  588. // inspection.Status = 1
  589. // inspection.CreatedTime = time.Now().Unix()
  590. // inspection.UpdatedTime = time.Now().Unix()
  591. // inspection.UTime = inspect_date
  592. // inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
  593. // err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
  594. // if err != nil {
  595. // tx.Rollback()
  596. // }
  597. // }
  598. //
  599. // tx.Commit()
  600. //
  601. //}
  602. }
  603. } else {
  604. if record.LastId != 0 {
  605. list, err := GetResultRecordByID(record.LastId)
  606. fmt.Println(list)
  607. //插入中间库中
  608. //插入一条插入中间库记录数据
  609. if err == nil {
  610. //插入一条查询检验检查结果记录状态数据
  611. var info LisSyncResultStatusInfo
  612. info.Ctime = time.Now().Unix()
  613. info.Status = 1
  614. info.Mtime = time.Now().Unix()
  615. info.OrgId = org_id
  616. info.IsResult = 1
  617. code, _ := strconv.ParseInt(list[0].Barcode, 10, 64)
  618. info.LastId = code
  619. info.ResultDate = time.Now().Unix()
  620. writeMiddleDb.Save(&info)
  621. //插入到系统检验检查数据
  622. //for _, item := range list {
  623. //
  624. // project_id := int64(0)
  625. // if len(item.Barcode) > 0 {
  626. // project_id, _ = GetGzjhProjectID(org_id, item.Groupname)
  627. // } else {
  628. // continue
  629. // }
  630. // printInfo, _ := GetHisLabelPrintInfoById(item.Barcode)
  631. //
  632. // item_id, _ := GetItemID(org_id, item.Groupname, item.Itemname, project_id)
  633. //
  634. // tx := writeMiddleDb.Begin()
  635. // var inspection models.MiddleInspection
  636. // var inspection_reference models.MiddleInspectionReference
  637. //
  638. // recordDateStr := ""
  639. //
  640. // if len(item.Repdate) == 0 {
  641. // recordDateStr = time.Now().Format("2006-01-02 15:04")
  642. // }
  643. //
  644. // inspect_date := item.Repdate
  645. // date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", recordDateStr)
  646. // record_date, _ := utils.ParseTimeStringToTime("2006-01-02", date.Format("2006-01-02"))
  647. // var total int
  648. // var RangeOptions string
  649. // var RangeMin string
  650. // var RangeMax string
  651. // // 判断检查类型
  652. // var ItemType int
  653. // if strings.Contains(item.Refrange, "[") && strings.Contains(item.Refrange, "]") {
  654. // ItemType = 1
  655. //
  656. // } else {
  657. // ItemType = 2
  658. //
  659. // }
  660. //
  661. // if ItemType == 1 {
  662. // item.Refrange = strings.Trim(item.Refrange, "[")
  663. // item.Refrange = strings.Trim(item.Refrange, "]")
  664. // Range := strings.Split(item.Refrange, "-")
  665. // RangeMin = Range[0]
  666. // RangeMax = Range[1]
  667. // } else {
  668. // RangeOptions = item.Refrange
  669. // }
  670. //
  671. // err = readMiddleDb.Model(&models.MiddleInspectionReference{}).Where("org_id = ? and project_id = ? and item_id = ? and status = 1", org_id, project_id, item_id).Find(&inspection_reference).Count(&total).Error
  672. // if inspection_reference.ID > 0 {
  673. // ItemType = inspection_reference.RangeType
  674. // }
  675. // if total <= 0 {
  676. // inspection_reference.OrgId = org_id
  677. // inspection_reference.ProjectName = item.Groupname
  678. // inspection_reference.Project = item.Groupname
  679. // inspection_reference.ProjectId = project_id
  680. // inspection_reference.ItemName = item.Itemname
  681. // inspection_reference.ItemNameAddition = item.Barcode
  682. // inspection_reference.ItemId = item_id
  683. // inspection_reference.RangeType = ItemType
  684. // inspection_reference.RangeMin = RangeMin
  685. // inspection_reference.RangeMax = RangeMax
  686. // inspection_reference.RangeOptions = RangeOptions
  687. // inspection_reference.Unit = item.Unit
  688. // inspection_reference.Status = 1
  689. // inspection_reference.CreatedTime = time.Now().Unix()
  690. // inspection_reference.UpdatedTime = time.Now().Unix()
  691. // inspection_reference.InspectDate = inspect_date
  692. // inspection_reference.UTime = inspect_date
  693. // err = tx.Model(&models.MiddleInspectionReference{}).Create(&inspection_reference).Error
  694. // if err != nil {
  695. // tx.Rollback()
  696. // }
  697. // }
  698. //
  699. // var itotal int
  700. // err = readMiddleDb.Model(&models.MiddleInspection{}).Where("org_id = ? and project_id = ? and item_id = ? and record_date = ? and patient_id = ? and status = 1", org_id, project_id, item_id, record_date, printInfo.PatientId).Find(&inspection).Count(&itotal).Error
  701. // if itotal <= 0 {
  702. // //item.Result = strings.Replace(item.Result, "&gt;", ">", -1)
  703. // //item.Result = strings.Replace(item.Result, "&lt;", "<", -1)
  704. // inspection.PatientId = printInfo.PatientId
  705. // inspection.OrgId = org_id
  706. // inspection.ProjectId = project_id
  707. // inspection.ItemName = inspection_reference.ItemName
  708. // inspection.ProjectName = inspection_reference.ProjectName
  709. // inspection.InspectType = ItemType
  710. // inspection.ItemId = item_id
  711. // inspection.InspectValue = item.Result
  712. // inspection.InspectDate = inspect_date
  713. // inspection.RecordDate = record_date.Unix()
  714. // inspection.Status = 1
  715. // inspection.CreatedTime = time.Now().Unix()
  716. // inspection.UpdatedTime = time.Now().Unix()
  717. // inspection.UTime = inspect_date
  718. // inspection.HisUserId = strconv.FormatInt(printInfo.PatientId, 10)
  719. // err = tx.Model(&models.MiddleInspection{}).Create(&inspection).Error
  720. // if err != nil {
  721. // tx.Rollback()
  722. // }
  723. // }
  724. //
  725. // tx.Commit()
  726. //
  727. //}
  728. }
  729. }
  730. }
  731. return
  732. }
  733. func GetAdminUserInfoByID(org_id int64, admin_user_id int64) (role UserAdminRole, err error) {
  734. err = readUserDb.Model(&UserAdminRole{}).Where("org_id = ? AND status = 1 AND admin_user_id = ?", org_id, admin_user_id).First(&role).Error
  735. return
  736. }
  737. type UserAdminRole struct {
  738. ID int64 `gorm:"column:id" json:"id" form:"id"`
  739. AdminUserId int64 `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
  740. OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
  741. AppId int64 `gorm:"column:app_id" json:"app_id" form:"app_id"`
  742. RoleId int64 `gorm:"column:role_id" json:"role_id" form:"role_id"`
  743. UserName string `gorm:"column:user_name" json:"user_name" form:"user_name"`
  744. Avatar string `gorm:"column:avatar" json:"avatar" form:"avatar"`
  745. UserType int64 `gorm:"column:user_type" json:"user_type" form:"user_type"`
  746. UserTitle int64 `gorm:"column:user_title" json:"user_title" form:"user_title"`
  747. Intro string `gorm:"column:intro" json:"intro" form:"intro"`
  748. Status int64 `gorm:"column:status" json:"status" form:"status"`
  749. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  750. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  751. UserTitleName string `gorm:"column:user_title_name" json:"user_title_name" form:"user_title_name"`
  752. RoleIds string `gorm:"column:role_ids" json:"role_ids" form:"role_ids"`
  753. Message string `gorm:"column:message" json:"message" form:"message"`
  754. Sex int64 `gorm:"column:sex" json:"sex" form:"sex"`
  755. Birthday int64 `gorm:"column:birthday" json:"birthday" form:"birthday"`
  756. Sort int64 `gorm:"column:sort" json:"sort" form:"sort"`
  757. IsSort int64 `gorm:"column:is_sort" json:"is_sort" form:"is_sort"`
  758. Department string `gorm:"column:department" json:"department" form:"department"`
  759. DepartmentId int64 `gorm:"column:department_id" json:"department_id" form:"department_id"`
  760. Age int64 `gorm:"column:age" json:"age" form:"age"`
  761. Nation string `gorm:"column:nation" json:"nation" form:"nation"`
  762. CardType int64 `gorm:"column:card_type" json:"card_type" form:"card_type"`
  763. IdCard string `gorm:"column:id_card" json:"id_card" form:"id_card"`
  764. Education int64 `gorm:"column:education" json:"education" form:"education"`
  765. StudyMajorName string `gorm:"column:study_major_name" json:"study_major_name" form:"study_major_name"`
  766. WorkMajorName string `gorm:"column:work_major_name" json:"work_major_name" form:"work_major_name"`
  767. RoleType int64 `gorm:"column:role_type" json:"role_type" form:"role_type"`
  768. MedicalCode string `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
  769. DoctorCode string `gorm:"column:doctor_code" json:"doctor_code" form:"doctor_code"`
  770. Licensing int64 `gorm:"column:licensing" json:"licensing" form:"licensing"`
  771. JobNumber string `gorm:"column:job_number" json:"job_number" form:"job_number"`
  772. PrescriptionQualificationIdentification int64 `gorm:"column:prescription_qualification_identification" json:"prescription_qualification_identification" form:"prescription_qualification_identification"`
  773. IdentificationOutpatients int64 `gorm:"column:identification_outpatients" json:"identification_outpatients" form:"identification_outpatients"`
  774. StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
  775. MedicalRangeCode int64 `gorm:"column:medical_range_code" json:"medical_range_code" form:"medical_range_code"`
  776. MedicalLevel int64 `gorm:"column:medical_level" json:"medical_level" form:"medical_level"`
  777. MedicalTypeJob int64 `gorm:"column:medical_type_job" json:"medical_type_job" form:"medical_type_job"`
  778. PharmacistRegistrationNumber string `gorm:"column:pharmacist_registration_number" json:"pharmacist_registration_number" form:"pharmacist_registration_number"`
  779. DoctorRangeCode int64 `gorm:"column:doctor_range_code" json:"doctor_range_code" form:"doctor_range_code"`
  780. DoctorLevel int64 `gorm:"column:doctor_level" json:"doctor_level" form:"doctor_level"`
  781. DoctorTypeJob int64 `gorm:"column:doctor_type_job" json:"doctor_type_job" form:"doctor_type_job"`
  782. DoctorNumber string `gorm:"column:doctor_number" json:"doctor_number" form:"doctor_number"`
  783. OutpatientIllnessCategory string `gorm:"column:outpatient_illness_category" json:"outpatient_illness_category" form:"outpatient_illness_category"`
  784. IsActive int64 `gorm:"column:is_active" json:"is_active" form:"is_active"`
  785. ActiveStatus int64 `gorm:"column:active_status" json:"active_status" form:"active_status"`
  786. }
  787. func (UserAdminRole) TableName() string {
  788. return "sgj_user_admin_role"
  789. }
  790. func FindDiagnoseById(id int64) (*HisXtDiagnoseConfig, error) {
  791. dealer := &HisXtDiagnoseConfig{}
  792. err := readDb.Model(&HisXtDiagnoseConfig{}).Where("id = ? AND status = 1", id).First(&dealer).Error
  793. return dealer, err
  794. }
  795. type HisXtDiagnoseConfig struct {
  796. ID int64 `gorm:"column:id" json:"id" form:"id"`
  797. ClassName string `gorm:"column:class_name" json:"class_name" form:"class_name"`
  798. Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
  799. Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
  800. ContentCode string `gorm:"column:content_code" json:"content_code" form:"content_code"`
  801. CountryCode string `gorm:"column:country_code" json:"country_code" form:"country_code"`
  802. CountryContentName string `gorm:"column:country_content_name" json:"country_content_name" form:"country_content_name"`
  803. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  804. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  805. Status int64 `gorm:"column:status" json:"status" form:"status"`
  806. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  807. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  808. }
  809. func (HisXtDiagnoseConfig) TableName() string {
  810. return "his_xt_diagnose_config"
  811. }
  812. type VMHisProjectTeam struct {
  813. ID int64 `gorm:"column:id" json:"id" form:"id"`
  814. ProjectTeam string `gorm:"column:project_team" json:"project_team" form:"project_team"`
  815. Price float64 `gorm:"column:price" json:"price" form:"price"`
  816. Pinyin string `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
  817. Wubi string `gorm:"column:wubi" json:"wubi" form:"wubi"`
  818. TubeColor int64 `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
  819. TeamType int64 `gorm:"column:team_type" json:"team_type" form:"team_type"`
  820. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  821. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  822. Status int64 `gorm:"column:status" json:"status" form:"status"`
  823. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  824. UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
  825. ProjectId string `gorm:"column:project_id" json:"project_id" form:"project_id"`
  826. VMItemProjectList []*VMItemProjectList `gorm:"-" json:"list" form:"list"`
  827. ItemId string `gorm:"column:item_id" json:"item_id" form:"item_id"`
  828. }
  829. func (VMHisProjectTeam) TableName() string {
  830. return "xt_his_project_team"
  831. }
  832. type VMItemProjectList struct {
  833. ID int64 `gorm:"column:id" json:"id" form:"id"`
  834. Number int64 `gorm:"column:number" json:"number" form:"number"`
  835. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  836. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  837. Status int64 `gorm:"column:status" json:"status" form:"status"`
  838. CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
  839. UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
  840. TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
  841. Type int64 `gorm:"column:type" json:"type" form:"type"`
  842. VMHisProject VMHisProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
  843. }
  844. func (VMItemProjectList) TableName() string {
  845. return "xt_his_project_list"
  846. }
  847. type VMHisProject struct {
  848. ID int64 `gorm:"column:id" json:"id" form:"id"`
  849. ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
  850. Price float64 `gorm:"column:price" json:"price" form:"price"`
  851. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  852. CostClassify int64 `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
  853. StatisticalClassification int64 `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
  854. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  855. Status int64 `gorm:"column:status" json:"status" form:"status"`
  856. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  857. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  858. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  859. NumberDays string `gorm:"column:number_days" json:"number_days" form:"number_days"`
  860. MedicalCode string `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
  861. }
  862. func (VMHisProject) TableName() string {
  863. return "xt_his_project"
  864. }
  865. type HisPrescriptionProject struct {
  866. ID int64 `gorm:"column:id" json:"id" form:"id"`
  867. ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
  868. Price float64 `gorm:"column:price" json:"price" form:"price"`
  869. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  870. Status int64 `gorm:"column:status" json:"status" form:"status"`
  871. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  872. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  873. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  874. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  875. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  876. PrescriptionId int64 `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
  877. Count int64 `gorm:"column:count" json:"count" form:"count"`
  878. FeedetlSn string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
  879. MedListCodg string `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
  880. SingleDose string `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
  881. DeliveryWay string `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
  882. ExecutionFrequency string `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
  883. Day string `gorm:"column:day" json:"day" form:"day"`
  884. VMHisProject VMHisProject `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
  885. Remark string `gorm:"column:remark" json:"remark" form:"remark"`
  886. Unit string `gorm:"column:unit" json:"unit" form:"unit"`
  887. Type int64 `gorm:"column:type" json:"type" form:"type"`
  888. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  889. ExecutionTime int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
  890. ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
  891. ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
  892. CheckTime int64 `gorm:"column:check_time" json:"check_time" form:"check_time"`
  893. CheckState int64 `gorm:"column:check_state" json:"check_state" form:"check_state"`
  894. Checker int64 `gorm:"column:checker" json:"checker" form:"checker"`
  895. StartTime int64 `gorm:"column:start_time" json:"start_time" form:"start_time"`
  896. TeamId int64 `gorm:"column:team_id" json:"team_id" form:"team_id"`
  897. FrequencyType int64 `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
  898. DayCount int64 `gorm:"column:day_count" json:"day_count" form:"day_count"`
  899. WeekDay string `gorm:"column:week_day" json:"week_day" form:"week_day"`
  900. HisPrescription HisPrescription `gorm:"ForeignKey:ID;AssociationForeignKey:PrescriptionId" json:"his_prescription"`
  901. }
  902. func (HisPrescriptionProject) TableName() string {
  903. return "his_prescription_project"
  904. }
  905. func GetProjectTeamList(orgid int64, id int64, p_id int64) (project []*HisPrescriptionProject, err error) {
  906. err = readDb.Model(&HisPrescriptionProject{}).Where("user_org_id = ? AND status = 1 AND team_id = ? AND prescription_id = ?", orgid, id, p_id).Find(&project).Error
  907. return
  908. }
  909. func GetHisLabelPrintInfoById(id string) (info HisLabelPrintInfo, err error) {
  910. err = readDb.Model(&HisLabelPrintInfo{}).Where("id = ?", id).First(&info).Error
  911. return
  912. }