Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support additional metadata for health schemas #47

Merged
merged 4 commits into from
Mar 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 35 additions & 26 deletions authentication/auth.go
Original file line number Diff line number Diff line change
@@ -124,25 +124,29 @@ type Metadata struct {
func isSurveyMetadata(key string) bool {
switch key {
case
"case_ref",
"case_type",
"display_address",
"employment_date",
"form_type",
"period_id",
"period_str",
"ref_p_end_date",
"ref_p_start_date",
"ru_name",
"ru_ref",
"trad_as",
"user_id",
"qid",
"PARTICIPANT_ID",
"FIRST_NAME",
"BLOOD_TEST_BARCODE",
"SWAB_TEST_BARCODE",
"TEST_QUESTIONS":
"case_ref",
"case_type",
"display_address",
"employment_date",
"form_type",
"period_id",
"period_str",
"ref_p_end_date",
"ref_p_start_date",
"ru_name",
"ru_ref",
"trad_as",
"user_id",
"qid",
"PARTICIPANT_ID",
"FIRST_NAME",
"BLOOD_TEST_BARCODE",
"SWAB_TEST_BARCODE",
"TEST_QUESTIONS",
"WINDOW_START_DATE",
"WINDOW_END_DATE",
"PORTAL_ID",
"PARTICIPANT_WINDOW_ID":

return true
}
@@ -634,11 +638,11 @@ func GetRequiredMetadata(launcherSchema surveys.LauncherSchema) ([]Metadata, str

for i, value := range schema.Metadata {

if strings.Contains(value.Name, "BARCODE") {
schema.Metadata[i].Default = "BAR" + fmt.Sprintf("%08d", rand.Int63n(1e8))
} else {
schema.Metadata[i].Default = defaults[value.Name]
}
if strings.Contains(value.Name, "BARCODE") {
schema.Metadata[i].Default = "BAR" + fmt.Sprintf("%08d", rand.Int63n(1e8))
} else {
schema.Metadata[i].Default = defaults[value.Name]
}

if value.Validator == "boolean" {
schema.Metadata[i].Default = "false"
@@ -745,6 +749,8 @@ func GetDefaultValues() map[string]string {
defaults := make(map[string]string)
collectionExerciseSid, _ := uuid.NewV4()

var PARTICIPANT_ID = "ABC-" + fmt.Sprintf("%011d", rand.Int63n(1e11))

defaults["collection_exercise_sid"] = collectionExerciseSid.String()
defaults["qid"] = fmt.Sprintf("%016d", rand.Int63n(1e16))
defaults["version"] = "v2"
@@ -770,10 +776,13 @@ func GetDefaultValues() map[string]string {
defaults["postcode"] = "PE12 4GH"
defaults["display_address"] = "68 Abingdon Road, Goathill"
defaults["country"] = "E"
defaults["PARTICIPANT_ID"] = "ABC-" + fmt.Sprintf("%011d", rand.Int63n(1e11))
defaults["PARTICIPANT_ID"] = PARTICIPANT_ID
defaults["FIRST_NAME"] = "John"
defaults["TEST_QUESTIONS"] = "F"

defaults["WINDOW_START_DATE"] = "2023-03-01"
defaults["WINDOW_END_DATE"] = "2023-03-31"
defaults["PORTAL_ID"] = fmt.Sprintf("%07d", rand.Int63n(1e7))
defaults["PARTICIPANT_WINDOW_ID"] = PARTICIPANT_ID + "-" + fmt.Sprintf("%03d", rand.Int63n(1e3))

return defaults
}