medicine_id into medicine_code in several medications related
This commit is contained in:
@@ -8,8 +8,6 @@ import (
|
||||
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
|
||||
up "simrs-vx/internal/use-case/main-use-case/pharmacist"
|
||||
|
||||
dg "github.com/karincake/apem/db-gorm-pg"
|
||||
d "github.com/karincake/dodol"
|
||||
|
||||
@@ -313,13 +311,18 @@ func Complete(input e.ReadDetailDto) (*d.Data, error) {
|
||||
return pl.SetLogError(&event, input)
|
||||
}
|
||||
|
||||
pharmacist_id, err := up.GetIdByUserId(&input.AuthInfo.User_Id, &event, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
if input.AuthInfo.Pharmachist_Code == nil {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
Code: "auth-noPharmacist",
|
||||
Detail: "user position is not allowed, only pharmacist can do actioncomplete medication",
|
||||
Raw: errors.New("authentication failed"),
|
||||
}
|
||||
return pl.SetLogError(&event, input)
|
||||
}
|
||||
|
||||
data.Status_Code = erc.DSCDone
|
||||
data.Pharmacist_Id = pharmacist_id
|
||||
data.Pharmacist_Code = input.AuthInfo.Pharmachist_Code
|
||||
if err := tx.Save(&data).Error; err != nil {
|
||||
event.Status = "failed"
|
||||
event.ErrInfo = pl.ErrorInfo{
|
||||
|
||||
@@ -30,7 +30,7 @@ func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Medication) {
|
||||
|
||||
data.Encounter_Id = inputSrc.Encounter_Id
|
||||
data.IssuedAt = inputSrc.IssuedAt
|
||||
data.Pharmacist_Id = inputSrc.Pharmacist_Id
|
||||
data.Pharmacist_Code = inputSrc.Pharmacist_Code
|
||||
data.Status_Code = inputSrc.Status_Code
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user