Skip to content

Commit

Permalink
Add support for PHM metadata (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
petechd authored Jan 27, 2023
1 parent b16f19e commit b1bcd0f
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions authentication/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,26 @@ 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":
"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":

return true
}
return false
Expand Down Expand Up @@ -627,7 +633,12 @@ func GetRequiredMetadata(launcherSchema surveys.LauncherSchema) ([]Metadata, str
defaults := GetDefaultValues()

for i, value := range schema.Metadata {
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"
Expand Down Expand Up @@ -759,6 +770,10 @@ 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["FIRST_NAME"] = "John"
defaults["TEST_QUESTIONS"] = "F"


return defaults
}

0 comments on commit b1bcd0f

Please sign in to comment.