FileDocCategorySizeDatePackage
PatientManagementDelegate.javaAPI DocExample768Mon Nov 24 10:30:48 GMT 2003com.oreilly.patterns.chapter9.standalone

PatientManagementDelegate.java

// Example 9-1: A business delegate

package com.oreilly.patterns.chapter9.standalone;

import com.oreilly.patterns.chapter7.PatientDTO;
import com.oreilly.patterns.chapter7.InvalidPatientException;
import com.oreilly.patterns.chapter8.PatientDAO;

public class PatientManagementDelegate {

  public static PatientDTO createNewPatient(PatientDTO patient)
    throws InvalidPatientException{

    if(patient == null|| patient.getFirstName() == null 
        || patient.getLastName() == null) 
          throw new InvalidPatientException(
            "Patient Records Require Full Name");

    PatientDAO pDAO = PatientDAOFactory.getPatientDAO();
    PatientDTO newPatientRecord = pDAO.createPatient(patient);

    return newPatientRecord;
  }
}