encounter mapping

This commit is contained in:
vanilia
2025-11-20 14:16:08 +07:00
parent 9a056701c6
commit 46d0c17669
12 changed files with 714 additions and 40 deletions

No files matched your search

@@ -1,6 +1,7 @@
package patient
import (
"errors"
"strconv"
pl "simrs-vx/pkg/logger"
@@ -38,6 +39,19 @@ func Create(input e.CreateDto) (*d.Data, error) {
pl.SetLogInfo(&event, input, "started", "create")
mwRunner := newMiddlewareRunner(&event)
// check if user has employee position
if !input.AuthInfo.HasEmployeePosition() {
event.Status = "failed"
event.ErrInfo = pl.ErrorInfo{
Code: "auth-forbidden",
Detail: "user has no employee position",
Raw: errors.New("authentication failed"),
}
return nil, pl.SetLogError(&event, input)
}
input.RegisteredBy_User_Name = &input.AuthInfo.User_Name
err := dg.I.Transaction(func(tx *gorm.DB) error {
mwRunner.setMwType(pu.MWTPre)
// Run pre-middleware