def test_parse_fields(self): # note: this method seems not to work without segment definition, and also for MSH segment field = 'PID|xxx|yyy^zz' fields = parse_fields(field) for field in fields: self.assertEqual(field.classname, 'Field') self.assertEqual(fields[0].to_er7(), 'PID') self.assertEqual(fields[1].to_er7(), 'xxx')
def test_parse_fields_custom_encoding_chars(self): fields = 'xxx@yyy$zz' f = parse_fields(fields, encoding_chars=self._get_custom_encoding_chars()) self.assertEqual( f[0].to_er7(encoding_chars=self._get_custom_encoding_chars()), 'xxx') self.assertEqual(f[1].children[0].to_er7(), 'yyy')
def test_parse_fields_custom_encoding_chars(self): fields = 'xxx@yyy$zz' f = parse_fields(fields, encoding_chars=self._get_custom_encoding_chars()) self.assertEqual(f[0].to_er7(encoding_chars=self._get_custom_encoding_chars()), 'xxx') self.assertEqual(f[1].children[0].to_er7(), 'yyy')
def test_parse_null_fields(self): fields = 'PID|||' f = parse_fields(fields) self.assertEqual(len(f), 4)
def test_parse_fields_multiple_instances(self): field = '||@PID.3.1^aaaa^[email protected]^F' f = parse_fields(field, name_prefix='PID') self.assertEqual(len(f), 2) # only the valued field is recognized self.assertEqual(f[0].cx_1.to_er7(), '@PID.3.1')