Add MCU prefix for MCU registrations
This commit is contained in:
@@ -144,7 +144,7 @@ func registerPatientInTransaction(ctx context.Context, tx *sql.Tx, params Regist
|
||||
now := time.Now().In(jakarta)
|
||||
nowText := now.Format("2006-01-02 15:04:05")
|
||||
regDate := params.RegistrationDate.Format("2006-01-02")
|
||||
prefix := "P" + params.RegistrationDate.Format("0601")
|
||||
prefix := registrationIDPrefix(params.RegistrationType, params.RegistrationDate)
|
||||
regID, err := nextRegistrationID(ctx, tx, prefix)
|
||||
if err != nil {
|
||||
return RegistrationOutcome{}, err
|
||||
@@ -489,6 +489,14 @@ func nextRegistrationID(ctx context.Context, tx *sql.Tx, prefix string) (string,
|
||||
return fmt.Sprintf("%s%05d", prefix, number+1), nil
|
||||
}
|
||||
|
||||
func registrationIDPrefix(registrationType int64, registrationDate time.Time) string {
|
||||
prefix := "P"
|
||||
if registrationType == 2 {
|
||||
prefix = "MCU"
|
||||
}
|
||||
return prefix + registrationDate.Format("0601")
|
||||
}
|
||||
|
||||
func registrationOutcome(statusCode int, success bool, status, message string, data any) RegistrationOutcome {
|
||||
return RegistrationOutcome{HTTPStatus: statusCode, Success: success, Status: status, Message: message, Data: data}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user