/** * Populating QPD-3 demographics fields * * @param CMbObject $object Object * @param string $mb_field Field spec * @param string $hl7_field The number of a field * @param null $mapTo Map to table HL7 * * @return array */ function setDemographicsFields(CMbObject $object, $mb_field, $hl7_field, $mapTo = null) { if (!$object->{$mb_field}) { return; } $seg = null; switch ($object->_class) { case "CPatient": $seg = "PID"; break; case "CSejour": $seg = "PV1"; break; default: } if (!$seg) { return; } $value = $mapTo ? CHL7v2TableEntry::mapTo($mapTo, $object->{$mb_field}) : $object->{$mb_field}; $spec = $object->_specs[$mb_field]; if ($spec instanceof CDateSpec || $spec instanceof CBirthDateSpec) { $value = CHL7v2::getDate($value); } return array("@{$seg}.{$hl7_field}", $value); }