I’m developing a form that collects data about family units. One section requires scanning an Argentinian document’s QR code.
The decoded text follows this format: Of.Ident@Surname@Name@Sex@Document@Date of birth@Date of expiry.
I’m aiming to extract the individual’s sex using regular expressions and then accumulate this data to determine the number of males and females within each family. Any insights or suggestions on how to effectively achieve this would be greatly appreciated.
The Sex seems coded as one @digit@ (or @letter@), so this might be the only place to locate this token in the whole string. Can you confirm this?
Update: So you might use a calculation like this: if( contains(…, “@FemaleCode@”), “F”, if(contains(…, “@MaleCode@”), “M”, “Diverse”) ). See ODK XForms Specification.
Or see Xiphware below, as an even more flexible search solution.
You could possibly use a regex pick out the specific character field and check if its, say, ‘F’, to determine the sex (presumably if its not ‘F’ then it must be ‘M’?..)
However, it is probably more generally useful to extract specific fields in the ‘@’ delimited string - in this case you want the 4th - which you can do using (sub) string functions. Have a play with this:
Note, if all the fields are actually fixed width, then you can simplify this expression a lot to extract the specific nth-index character itself, using substr().
Yes, the format has changed due to the document’s recent issuance. A sample decoded QR code string might look like this: 00000010532@VILLAREAL@MARIA VICTORIA@F@99999999@A@01/11/1969@31/10/2009.