class PatientInfoTransformer {

    public List<String> toHL7(PatientInfo patientInfo) {
        if (patientInfo == null) {
            return Collections.emptyList();
        }
        
        List<String> hl7Strings = new ArrayList<String>();
        for (Map.Entry<Integer, PIDTransformer> entry : pidTransformers.entrySet()) {
            String pidNoStr = PID_PREFIX + entry.getKey();
            List<String> repetitions = entry.getValue().toHL7(patientInfo);
            if (repetitions != null) {
                for (String repetition : repetitions) {
                    hl7Strings.add(pidNoStr + '|' + repetition);
                }
            }
        }
        
        return hl7Strings;
    }

}