@Test public void testAdmitNullPatient() { eventHandler.handle((AdmitPatientEvent)null); }
@Override public void handle(final AdmitPatientEvent event) { if (event == null) { return; } final String patientId = event.getPatientId(); ExternalPatient patient = findPatient(patientId); if (patient == null) { final PatientDetails patientDetails = event.getPatientDetails(); if (patientDetails == null) { throw new NullPointerException("Patient [" + patientId + "] does not exist; details not provided for a new patient creation!"); } patient = new ExternalPatientImpl(); patient.setExternalId(patientId); patient.setName(patientDetails.getName()); patient.setAddress(patientDetails.getAddress()); patient.setGender(patientDetails.getGender()); getHibernateTemplate().save(patient); } final ExternalCentralCase centralCase = new ExternalCentralCaseImpl(); centralCase.setEffective(Intervals.infiniteFrom(event.getWhen())); centralCase.setPatient(patient); centralCase.setOutpatient(event.getCentralCaseDetails().isOutpatient()); centralCase.setCuringCareProfessional(findMedicalStaff(event.getCentralCaseDetails().getCuringCareProfessionalId())); centralCase.setSupervisoryCareProfessional(findMedicalStaff(event.getCentralCaseDetails().getSupervisoryCareProfessionalId())); centralCase.setRoomAndBed(event.getCentralCaseDetails().getRoomAndBed()); final Serializable centralCaseId = getHibernateTemplate().save(centralCase); centralCase.setExternalId(String.valueOf(centralCaseId)); final ExternalEpisode episode = new ExternalEpisodeImpl(); episode.setCentralCase(centralCase); final ExternalCareProvider careProvider = findExternalEntity( event.getCareProviderId(), externalCareProvider, ExternalCareProvider.class); if (careProvider == null) { throw new IllegalArgumentException("Care provider [" + event.getCareProviderId() + "] does not exist!"); } episode.setCareProvider(careProvider); episode.setEffective(Intervals.infiniteFrom(event.getWhen())); final Serializable episodeId = getHibernateTemplate().save(episode); episode.setExternalId(String.valueOf(episodeId)); final ExternalEncounter encounter = new ExternalEncounterImpl(); encounter.setType(ExternalEncounterType.ADMISSION); encounter.setWhen(event.getWhen()); encounter.setEpisode(episode); final Serializable encounterId = getHibernateTemplate().save(encounter); encounter.setExternalId(String.valueOf(encounterId)); }
DataChangeEventHandler extends HibernateDaoSupport implements EventHandler { @Override public void handle(final AdmitPatientEvent event) { if (event == null) { return; } final String patientId = event.getPatientId(); ExternalPatient patient = findPatient(patientId); if (patient == null) { final PatientDetails patientDetails = event.getPatientDetails(); if (patientDetails == null) { throw new NullPointerException("Patient [" + patientId + "] does not exist; details not provided for a new patient creation!"); } patient = new ExternalPatientImpl(); patient.setExternalId(patientId); patient.setName(patientDetails.getName()); patient.setAddress(patientDetails.getAddress()); patient.setGender(patientDetails.getGender()); getHibernateTemplate().save(patient); } final ExternalCentralCase centralCase = new ExternalCentralCaseImpl(); centralCase.setEffective(Intervals.infiniteFrom(event.getWhen())); centralCase.setPatient(patient); centralCase.setOutpatient(event.getCentralCaseDetails().isOutpatient()); centralCase.setCuringCareProfessional(findMedicalStaff(event.getCentralCaseDetails().getCuringCareProfessionalId())); centralCase.setSupervisoryCareProfessional(findMedicalStaff(event.getCentralCaseDetails().getSupervisoryCareProfessionalId())); centralCase.setRoomAndBed(event.getCentralCaseDetails().getRoomAndBed()); final Serializable centralCaseId = getHibernateTemplate().save(centralCase); centralCase.setExternalId(String.valueOf(centralCaseId)); final ExternalEpisode episode = new ExternalEpisodeImpl(); episode.setCentralCase(centralCase); final ExternalCareProvider careProvider = findExternalEntity( event.getCareProviderId(), externalCareProvider, ExternalCareProvider.class); if (careProvider == null) { throw new IllegalArgumentException("Care provider [" + event.getCareProviderId() + "] does not exist!"); } episode.setCareProvider(careProvider); episode.setEffective(Intervals.infiniteFrom(event.getWhen())); final Serializable episodeId = getHibernateTemplate().save(episode); episode.setExternalId(String.valueOf(episodeId)); final ExternalEncounter encounter = new ExternalEncounterImpl(); encounter.setType(ExternalEncounterType.ADMISSION); encounter.setWhen(event.getWhen()); encounter.setEpisode(episode); final Serializable encounterId = getHibernateTemplate().save(encounter); encounter.setExternalId(String.valueOf(encounterId)); } }
DataChangeEventHandler extends HibernateDaoSupport implements EventHandler { @Override public void handle(final AdmitPatientEvent event) { if (event == null) { return; } final String patientId = event.getPatientId(); ExternalPatient patient = findPatient(patientId); if (patient == null) { final PatientDetails patientDetails = event.getPatientDetails(); if (patientDetails == null) { throw new NullPointerException("Patient [" + patientId + "] does not exist; details not provided for a new patient creation!"); } patient = new ExternalPatientImpl(); patient.setExternalId(patientId); patient.setName(patientDetails.getName()); patient.setAddress(patientDetails.getAddress()); patient.setGender(patientDetails.getGender()); getHibernateTemplate().save(patient); } final ExternalCentralCase centralCase = new ExternalCentralCaseImpl(); centralCase.setEffective(Intervals.infiniteFrom(event.getWhen())); centralCase.setPatient(patient); centralCase.setOutpatient(event.getCentralCaseDetails().isOutpatient()); centralCase.setCuringCareProfessional(findMedicalStaff(event.getCentralCaseDetails().getCuringCareProfessionalId())); centralCase.setSupervisoryCareProfessional(findMedicalStaff(event.getCentralCaseDetails().getSupervisoryCareProfessionalId())); centralCase.setRoomAndBed(event.getCentralCaseDetails().getRoomAndBed()); final Serializable centralCaseId = getHibernateTemplate().save(centralCase); centralCase.setExternalId(String.valueOf(centralCaseId)); final ExternalEpisode episode = new ExternalEpisodeImpl(); episode.setCentralCase(centralCase); final ExternalCareProvider careProvider = findExternalEntity( event.getCareProviderId(), externalCareProvider, ExternalCareProvider.class); if (careProvider == null) { throw new IllegalArgumentException("Care provider [" + event.getCareProviderId() + "] does not exist!"); } episode.setCareProvider(careProvider); episode.setEffective(Intervals.infiniteFrom(event.getWhen())); final Serializable episodeId = getHibernateTemplate().save(episode); episode.setExternalId(String.valueOf(episodeId)); final ExternalEncounter encounter = new ExternalEncounterImpl(); encounter.setType(ExternalEncounterType.ADMISSION); encounter.setWhen(event.getWhen()); encounter.setEpisode(episode); final Serializable encounterId = getHibernateTemplate().save(encounter); encounter.setExternalId(String.valueOf(encounterId)); }  }
DataChangeEventHandler extends HibernateDaoSupport implements EventHandler { @Override public void handle(final AdmitPatientEvent event) { if (event == null) { return; } final String patientId = event.getPatientId(); ExternalPatient patient = findPatient(patientId); if (patient == null) { final PatientDetails patientDetails = event.getPatientDetails(); if (patientDetails == null) { throw new NullPointerException("Patient [" + patientId + "] does not exist; details not provided for a new patient creation!"); } patient = new ExternalPatientImpl(); patient.setExternalId(patientId); patient.setName(patientDetails.getName()); patient.setAddress(patientDetails.getAddress()); patient.setGender(patientDetails.getGender()); getHibernateTemplate().save(patient); } final ExternalCentralCase centralCase = new ExternalCentralCaseImpl(); centralCase.setEffective(Intervals.infiniteFrom(event.getWhen())); centralCase.setPatient(patient); centralCase.setOutpatient(event.getCentralCaseDetails().isOutpatient()); centralCase.setCuringCareProfessional(findMedicalStaff(event.getCentralCaseDetails().getCuringCareProfessionalId())); centralCase.setSupervisoryCareProfessional(findMedicalStaff(event.getCentralCaseDetails().getSupervisoryCareProfessionalId())); centralCase.setRoomAndBed(event.getCentralCaseDetails().getRoomAndBed()); final Serializable centralCaseId = getHibernateTemplate().save(centralCase); centralCase.setExternalId(String.valueOf(centralCaseId)); final ExternalEpisode episode = new ExternalEpisodeImpl(); episode.setCentralCase(centralCase); final ExternalCareProvider careProvider = findExternalEntity( event.getCareProviderId(), externalCareProvider, ExternalCareProvider.class); if (careProvider == null) { throw new IllegalArgumentException("Care provider [" + event.getCareProviderId() + "] does not exist!"); } episode.setCareProvider(careProvider); episode.setEffective(Intervals.infiniteFrom(event.getWhen())); final Serializable episodeId = getHibernateTemplate().save(episode); episode.setExternalId(String.valueOf(episodeId)); final ExternalEncounter encounter = new ExternalEncounterImpl(); encounter.setType(ExternalEncounterType.ADMISSION); encounter.setWhen(event.getWhen()); encounter.setEpisode(episode); final Serializable encounterId = getHibernateTemplate().save(encounter); encounter.setExternalId(String.valueOf(encounterId)); }  @Override void handle(final AdmitPatientEvent event); @Override void handle(final DischargePatientEvent event); }
DataChangeEventHandler extends HibernateDaoSupport implements EventHandler { @Override public void handle(final AdmitPatientEvent event) { if (event == null) { return; } final String patientId = event.getPatientId(); ExternalPatient patient = findPatient(patientId); if (patient == null) { final PatientDetails patientDetails = event.getPatientDetails(); if (patientDetails == null) { throw new NullPointerException("Patient [" + patientId + "] does not exist; details not provided for a new patient creation!"); } patient = new ExternalPatientImpl(); patient.setExternalId(patientId); patient.setName(patientDetails.getName()); patient.setAddress(patientDetails.getAddress()); patient.setGender(patientDetails.getGender()); getHibernateTemplate().save(patient); } final ExternalCentralCase centralCase = new ExternalCentralCaseImpl(); centralCase.setEffective(Intervals.infiniteFrom(event.getWhen())); centralCase.setPatient(patient); centralCase.setOutpatient(event.getCentralCaseDetails().isOutpatient()); centralCase.setCuringCareProfessional(findMedicalStaff(event.getCentralCaseDetails().getCuringCareProfessionalId())); centralCase.setSupervisoryCareProfessional(findMedicalStaff(event.getCentralCaseDetails().getSupervisoryCareProfessionalId())); centralCase.setRoomAndBed(event.getCentralCaseDetails().getRoomAndBed()); final Serializable centralCaseId = getHibernateTemplate().save(centralCase); centralCase.setExternalId(String.valueOf(centralCaseId)); final ExternalEpisode episode = new ExternalEpisodeImpl(); episode.setCentralCase(centralCase); final ExternalCareProvider careProvider = findExternalEntity( event.getCareProviderId(), externalCareProvider, ExternalCareProvider.class); if (careProvider == null) { throw new IllegalArgumentException("Care provider [" + event.getCareProviderId() + "] does not exist!"); } episode.setCareProvider(careProvider); episode.setEffective(Intervals.infiniteFrom(event.getWhen())); final Serializable episodeId = getHibernateTemplate().save(episode); episode.setExternalId(String.valueOf(episodeId)); final ExternalEncounter encounter = new ExternalEncounterImpl(); encounter.setType(ExternalEncounterType.ADMISSION); encounter.setWhen(event.getWhen()); encounter.setEpisode(episode); final Serializable encounterId = getHibernateTemplate().save(encounter); encounter.setExternalId(String.valueOf(encounterId)); }  @Override void handle(final AdmitPatientEvent event); @Override void handle(final DischargePatientEvent event);  }