Java Code Examples for ims.domain.exceptions.UniqueKeyViolationException

The following are top voted examples for showing how to use ims.domain.exceptions.UniqueKeyViolationException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: AvoinApotti   File: OcsIfInboundImpl.java   Source Code and License 6 votes vote down vote up
public void saveLocation(IfLocParentVo location) throws StaleObjectException, UniqueKeyViolationException
{
	if (!location.isValidated())
		throw new DomainRuntimeException("Location not Validated.");

	DomainFactory factory = getDomainFactory();

	Location doLocation = IfLocParentVoAssembler.extractLocation(factory, location);

	try
	{
		factory.save(doLocation);
	}
	catch (UnqViolationUncheckedException e)
	{
		String dupMessage = Keywords.checkDuplicateTaxonomy(factory, doLocation, "codeMappings", location.getCodeMappings(), "getName");
		if(dupMessage != null)
			throw new UniqueKeyViolationException(dupMessage);

		throw new UniqueKeyViolationException("An Location with this name already exists, Please change", e);			
	}
	return;		
}
 
Example 2
Project: AvoinApotti   File: OPDEDClinicNotesImpl.java   Source Code and License 6 votes vote down vote up
public void saveOPDEDVo(ims.generalmedical.vo.OPDErectDysfxnVo voOPDED) throws StaleObjectException, UniqueKeyViolationException
{
	// Ensure the value object has been validated
	if (!voOPDED.isValidated())
		throw new DomainRuntimeException("OPD Erectile Dysfunction has not been validated");

	DomainFactory factory = getDomainFactory();
	if (voOPDED.getID_OPDErectDysfxn() == null)//Inserting a record
	{
		StringBuffer hql = new StringBuffer();
		hql.append("from OPDErectDysfxn as o where o.careContext.id = :CCID and o.isRIE is null");
		java.util.List list = getDomainFactory().find(hql.toString(), "CCID",voOPDED.getCareContext().getID_CareContext());
		if (list == null || list.size() > 0)
			throw new UniqueKeyViolationException(" The screen will be refreshed");
	}
	OPDErectDysfxn doOPDED = OPDErectDysfxnVoAssembler.extractOPDErectDysfxn(factory, voOPDED);
	factory.save(doOPDED);
	return;
}
 
Example 3
Project: AvoinApotti   File: ServiceImpl.java   Source Code and License 6 votes vote down vote up
public void removeServiceActivity(ims.core.vo.ServiceActivityVo voServiceActivity) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.ForeignKeyViolationException, ims.domain.exceptions.UniqueKeyViolationException
{
	DomainFactory factory = getDomainFactory();

	ServiceActivity doServiceActivity = ServiceActivityVoAssembler.extractServiceActivity(factory, voServiceActivity);
	try
	{
		factory.delete(doServiceActivity);
	}
	catch (DomainRuntimeException e) // SN: catching
										// DomainRuntimeException here as
										// this is what Hib is returning
										// with e.getCause() =
										// ConstrainViolationException
	{
		throw new UniqueKeyViolationException(e.getMessage());
	}
}
 
Example 4
Project: AvoinApotti   File: OPDFertilityCLinicImpl.java   Source Code and License 6 votes vote down vote up
public void saveOPDFertClinicVo(OPDFertClinicVo voOPDFertClinic) throws StaleObjectException, UniqueKeyViolationException 
{
	// Ensure the value object has been validated
	if (!voOPDFertClinic.isValidated())
		throw new DomainRuntimeException("OPD Fertility Clinic has not been validated");
	
	DomainFactory factory = getDomainFactory();
	if (voOPDFertClinic.getID_OPDFertClinic() == null)//Inserting a record
	{
		StringBuffer hql = new StringBuffer();
		hql.append("from OPDFertClinic as o where o.careContext.id = :CCID and o.isRIE is null");
		java.util.List list = getDomainFactory().find(hql.toString(), "CCID",voOPDFertClinic.getCareContext().getID_CareContext());
		if (list == null || list.size() > 0)
			throw new UniqueKeyViolationException("A record exists for this Care Context, the screen will be refreshed");
	}
	OPDFertClinic doOPDFertClinic = OPDFertClinicVoAssembler.extractOPDFertClinic(factory, voOPDFertClinic);
	factory.save(doOPDFertClinic);
	
}
 
Example 5
Project: AvoinApotti   File: OPDMedExamImpl.java   Source Code and License 6 votes vote down vote up
/**
* Save the MedExamGeneralVo
 * @throws UniqueKeyViolationException 
*/
public void saveMedExamGeneralVo(ims.generalmedical.vo.MedExamGeneralVo voMedExamGeneral) throws StaleObjectException, UniqueKeyViolationException
{
	// Ensure the value object has been validated
	if (!voMedExamGeneral.isValidated())
		throw new DomainRuntimeException("OPD Medical Exam has not been validated");
	
	DomainFactory factory = getDomainFactory();
	if (voMedExamGeneral.getID_ExamGen() == null)//Inserting a record
	{
		StringBuffer hql = new StringBuffer();
		hql.append("from ExamGen as e where e.careContext.id = :CCID and e.isRIE is null");
		java.util.List list = getDomainFactory().find(hql.toString(), "CCID",voMedExamGeneral.getCareContext().getID_CareContext());
		if (list == null || list.size() > 0)
			throw new UniqueKeyViolationException("A record exists for this Care Context, the screen will be refreshed");
	}
	ExamGen doMedExamGeneral = MedExamGeneralVoAssembler.extractExamGen(factory, voMedExamGeneral);
	factory.save(doMedExamGeneral);
	
	return;
}
 
Example 6
Project: AvoinApotti   File: MedSystemreviewImpl.java   Source Code and License 6 votes vote down vote up
public void saveProblemsAdmis(MedicalProbOnAdmisVoCollection problemColl)throws StaleObjectException, UniqueKeyViolationException 
{

	if(problemColl == null)
		return;
	DomainFactory factory = getDomainFactory();
	if(problemColl != null)
		for(int i=0; i<problemColl.size(); i++)
		{
			MedicalProbOnAdmisVo voMedicalProbOnAdmis = problemColl.get(i);
			PatientProblem doMedicalProbOnAdmis = MedicalProbOnAdmisVoAssembler.extractPatientProblem(factory, voMedicalProbOnAdmis);
			doMedicalProbOnAdmis.setIsRIE(Boolean.TRUE);  //wdev-13525
			
			factory.save(doMedicalProbOnAdmis);
							
			
		}
	
}
 
Example 7
Project: AvoinApotti   File: Logic.java   Source Code and License 6 votes vote down vote up
public boolean populateActivityFunctionDataFromScreen(ServiceVo voService) throws UniqueKeyViolationException
{
	boolean ret = false;
	if (checkForErrorsOnActivityFunction())
	{
		// update taxonomy contexts for last selected function and activity
		saveServiceActivityTaxonomy(voService);
		saveServiceFunctionTaxonomy(voService);

		// add/remove activities
		ret = saveServiceActivity();
		if (!ret)
			return ret;

		ret = saveServiceFunction();

		return ret;
	}

	return false;
}
 
Example 8
Project: AvoinApotti   File: AllergiesImpl.java   Source Code and License 6 votes vote down vote up
public PatientNoAllergyInfoVo savePatientNoAllergyInfo(PatientNoAllergyInfoVo patientNoAllergyInfo) throws StaleObjectException, UniqueKeyViolationException 
{
	if(!patientNoAllergyInfo.isValidated())
	{
		throw new CodingRuntimeException("PatientNoAllergyInfoVo Value Object Alert has not been validated");
	}
	
	DomainFactory factory = getDomainFactory();
	PatientNoAllergyInfo doPatientNoAllergyInfo = PatientNoAllergyInfoVoAssembler.extractPatientNoAllergyInfo(factory, patientNoAllergyInfo);
		
	try
	{
		factory.save(doPatientNoAllergyInfo);
	} 
	catch(UnqViolationUncheckedException e)
	{		
		PatientNoAllergyInfo noAllergyInfo = PatientNoAllergyInfo.getPatientNoAllergyInfoFromPatient(factory, patientNoAllergyInfo.getPatient().getID_Patient());
		if (noAllergyInfo != null && noAllergyInfo.getId() != null && !(noAllergyInfo.getId().equals(patientNoAllergyInfo.getID_PatientNoAllergyInfo())))
		{
			throw new UniqueKeyViolationException("A No Known Allergy record already exists for this patient. Duplicates not allowed.", e);					
		}

		throw (e);
	}
	return (PatientNoAllergyInfoVoAssembler.create(doPatientNoAllergyInfo));		
}
 
Example 9
Project: AvoinApotti   File: GlossaryAdminImpl.java   Source Code and License 6 votes vote down vote up
public GlossaryVo saveGlossary(GlossaryVo voGlossary) throws DomainInterfaceException, StaleObjectException, UniqueKeyViolationException 
{
	if (voGlossary == null)
		throw new CodingRuntimeException("Invalid argument: GlossaryVo is null");
	if (!voGlossary.isValidated())
		throw new DomainRuntimeException("Glossary VO not validated.");

	DomainFactory factory = getDomainFactory();
	Glossary domGlossary = GlossaryVoAssembler.extractGlossary(factory,voGlossary);
	try
	{
		factory.save(domGlossary);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("Text already exists within the system for this Glossary.", e);
	}

	return GlossaryVoAssembler.create(domGlossary);
}
 
Example 10
Project: AvoinApotti   File: HydrotherapyImpl.java   Source Code and License 6 votes vote down vote up
public void saveHydroTherapy(HydrotherapyVo voHydrotherapy) throws StaleObjectException, UniqueKeyViolationException 
{
	if(!voHydrotherapy.isValidated())
		throw new DomainRuntimeException("This HydroTherapy has not been validated");

	//if a new Hydrotherapy record is created check if already exists a Hydrotherapy record for selected clinical contact in the database
	//must exist only one Hydrotherapy record per clinical contact
	if(voHydrotherapy.getID_Hydrotherapy() == null)
	{
		if(voHydrotherapy.getClinicalContactIsNotNull())
		{
			HydrotherapyVo tempvo = getHydroTherapy(voHydrotherapy.getClinicalContact(), false);
			if(tempvo != null)
				throw new DomainRuntimeException("A Hydrotherapy record already exists for selected Clinical Contact.");
		}
	}
	
	DomainFactory factory = getDomainFactory();
	Hydrotherapy doHydro = HydrotherapyVoAssembler.extractHydrotherapy(factory, voHydrotherapy);
	factory.save(doHydro);
	
}
 
Example 11
Project: AvoinApotti   File: CorrespondenceHeadersAdminImpl.java   Source Code and License 6 votes vote down vote up
public ims.correspondence.vo.TemplateCategoryVo saveTemplateCategories(ims.correspondence.vo.TemplateCategoryVo voTemplateCategory) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.ForeignKeyViolationException, ims.domain.exceptions.UniqueKeyViolationException 
{
	if (voTemplateCategory == null)
		throw new CodingRuntimeException("Invalid Argument: Template Category is null");
	if (!voTemplateCategory.isValidated())
		throw new DomainRuntimeException("TemplateCategoryVo not validated.");
	
	DomainFactory factory = getDomainFactory();
	
	
	TemplateCategory domTemplCategory = TemplateCategoryVoAssembler.extractTemplateCategory(factory, voTemplateCategory);

	try
	{
		factory.save(domTemplCategory);
	}
	catch (UnqViolationUncheckedException ue)
	{
		throw new UniqueKeyViolationException(ue.getMessage());
	}
	
	return TemplateCategoryVoAssembler.create(domTemplCategory);

	
}
 
Example 12
Project: AvoinApotti   File: GlossaryAdminConfigurationImpl.java   Source Code and License 6 votes vote down vote up
public ims.correspondence.vo.GlossaryVo saveGlossary(ims.correspondence.vo.GlossaryVo voGlossary) throws ims.domain.exceptions.DomainInterfaceException, ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.UniqueKeyViolationException
{
	if (voGlossary == null)
		throw new CodingRuntimeException("Invalid argument: GlossaryVo is null");
	if (!voGlossary.isValidated())
		throw new DomainRuntimeException("Glossary VO not validated.");

	DomainFactory factory = getDomainFactory();
	Glossary domGlossary = GlossaryVoAssembler.extractGlossary(factory,voGlossary);
	try
	{
		factory.save(domGlossary);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("Text already exists within the system for this Glossary.", e);
	}

	return GlossaryVoAssembler.create(domGlossary);
}
 
Example 13
Project: AvoinApotti   File: GlossaryAdminConfigurationImpl.java   Source Code and License 6 votes vote down vote up
public ims.correspondence.vo.GlossaryProfileVo saveGlossaryProfile(ims.correspondence.vo.GlossaryProfileVo voGlossaryProfile) throws ims.domain.exceptions.DomainInterfaceException, ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.UniqueKeyViolationException
{
	if (voGlossaryProfile ==null)
		throw new CodingRuntimeException("Invalid argument: GlossaryProfileVo is null)");
		
	if (!voGlossaryProfile.isValidated())
		throw new DomainRuntimeException("GlossaryProfileVo has not been validated");
	
	DomainFactory factory = getDomainFactory();
	GlossaryProfile domGlossaryProfile = GlossaryProfileVoAssembler.extractGlossaryProfile(factory, voGlossaryProfile);

	try
	{
		factory.save(domGlossaryProfile);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("Profile already exists within the system for this user.", e);
	}

	return GlossaryProfileVoAssembler.create(domGlossaryProfile);
}
 
Example 14
Project: AvoinApotti   File: NoLetterRequiredAdminImpl.java   Source Code and License 6 votes vote down vote up
public ims.correspondence.vo.NoLetterIsRequiredVo saveNoLetterIsRequired(ims.correspondence.vo.NoLetterIsRequiredVo voNoLetterIsRequired) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.UniqueKeyViolationException 
{
	if (!voNoLetterIsRequired.isValidated())
	{
		throw new CodingRuntimeException("NoLetter is required record has not been validated");
	}
			
	DomainFactory factory = getDomainFactory();				
	NoLetterIsRequired domNLR =  NoLetterIsRequiredVoAssembler.extractNoLetterIsRequired(factory, voNoLetterIsRequired);
	try
	{
		factory.save(domNLR);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("No Letter required already exists within the system. Please try again to update.", e);
	}
	
	return NoLetterIsRequiredVoAssembler.create(domNLR);
}
 
Example 15
Project: AvoinApotti   File: StrengtheningProgramImpl.java   Source Code and License 6 votes vote down vote up
/**
 * save StrenghteningProgram
 * @throws UniqueKeyViolationException 
 */
public ims.therapies.vo.StrengtheningProgramVo saveStrenghteningProgram(ims.therapies.vo.StrengtheningProgramVo voStrenghteningProgram) throws ims.domain.exceptions.StaleObjectException, UniqueKeyViolationException
{
	if (voStrenghteningProgram == null)
		throw new RuntimeException("Cannot save null StrengtheningProgramVo.");
	if (voStrenghteningProgram.isValidated() == false)
		throw new CodingRuntimeException("StrengtheningProgramVo is not validated");

	DomainFactory factory = getDomainFactory();
	if (voStrenghteningProgram.getID_StrengtheningProgram() == null)//Inserting a record
	{
		StrengtheningProgramVo voSP = getStrengthProgByClinicalContact(voStrenghteningProgram.getClinicalContact());
		if(voSP != null)
			throw new UniqueKeyViolationException("A record exists for this clinical contact, the screen will be refreshed");
	}
	StrengtheningProgram doStregtheningProgram = StrengtheningProgramVoAssembler.extractStrengtheningProgram(factory, voStrenghteningProgram);
	factory.save(doStregtheningProgram);
	return StrengtheningProgramVoAssembler.create(doStregtheningProgram);
}
 
Example 16
Project: AvoinApotti   File: DemographicsImpl.java   Source Code and License 6 votes vote down vote up
/**
 * Get's a specific Patient
 * @throws  
 * @throws UniqueKeyViolationException 
 */
public ims.core.vo.Patient getPatient(PatientShort patient) throws StaleObjectException
{
	if (ConfigFlag.DOM.PATIENT_SEARCH_TYPE.getValue().equals("LOCAL"))
		return getLocalPatient(patient);
	else if (ConfigFlag.DOM.PATIENT_SEARCH_TYPE.getValue().equals("DTO"))
	{
		try
		{
			return getDTOPatient(patient);
		}
		catch (UniqueKeyViolationException e)
		{
			throw new DomainRuntimeException(e);
		}
	}

	return null;
}
 
Example 17
Project: AvoinApotti   File: DemographicsImpl.java   Source Code and License 6 votes vote down vote up
public Patient savePatient(Patient patient, Boolean fromInterface) throws UniqueKeyViolationException, StaleObjectException, DomainInterfaceException, IndexOutOfBoundsException
{
	DomainFactory factory = getDomainFactory();
	factory.setDirtyCheck(true);
	if (!patient.isValidated())
	{
		throw new DomainRuntimeException("Patient VO has not been validated!");
	}
	patient.getName().setUppers();
	if (patient.getOtherNames() != null)
	{
		for (int i = 0; i < patient.getOtherNames().size(); i++)
		{
			patient.getOtherNames().get(i).setUppers();
		}
	}
	return this.savePatientRecord(factory, patient, 1, fromInterface);
}
 
Example 18
Project: AvoinApotti   File: Logic.java   Source Code and License 6 votes vote down vote up
private void save(OrganisationVo voOrg, LocSiteVo voLocSite, LocMostVo voLoc) throws UniqueKeyViolationException, StaleObjectException 
{
	if (voOrg != null)
	{	
		domain.saveOrganisation(voOrg);
	}
	else if (voLocSite != null)
	{	
		//wdev-12855
		if(form.getLocalContext().getEditObject() instanceof LocSiteVo && ((LocSiteVo)form.getLocalContext().getEditObject()).getID_LocationIsNotNull() && voLocSite.getVersion_Location() != ((LocSiteVo)form.getLocalContext().getEditObject()).getVersion_Location())
			throw new StaleObjectException(null);
		
		domain.saveLocationSite(voLocSite);
	}
	else if (voLoc != null)
	{
		//wdev-12855
		if(form.getLocalContext().getEditObject() instanceof LocMostVo && ((LocMostVo)form.getLocalContext().getEditObject()).getID_LocationIsNotNull() && voLoc.getVersion_Location() != ((LocMostVo)form.getLocalContext().getEditObject()).getVersion_Location())
			throw new StaleObjectException(null);
		domain.saveLocation(voLoc);
	}
	form.getLocalContext().setSavingRootOrg(null);
}
 
Example 19
Project: AvoinApotti   File: AlertsImpl.java   Source Code and License 6 votes vote down vote up
public PatientNoAlertInfoVo savePatientCoreClinicalData(PatientNoAlertInfoVo patientNoAlertInfo) throws StaleObjectException, UniqueKeyViolationException 
{
	if(!patientNoAlertInfo.isValidated())
	{
		throw new CodingRuntimeException("PatientNoAlertInfoVo Value Object Alert has not been validated");
	}

	DomainFactory factory = getDomainFactory();
	PatientNoAlertInfo doPatientNoAlertInfo = PatientNoAlertInfoVoAssembler.extractPatientNoAlertInfo(factory, patientNoAlertInfo);
		
	try
	{
		factory.save(doPatientNoAlertInfo);
	} 
	catch(UnqViolationUncheckedException e)
	{		
		PatientNoAlertInfo noAlertInfo = PatientNoAlertInfo.getPatientNoAlertInfoFromPatient(factory, patientNoAlertInfo.getPatient().getID_Patient());
		if (noAlertInfo != null && noAlertInfo.getId() != null && !(noAlertInfo.getId().equals(patientNoAlertInfo.getID_PatientNoAlertInfo())))
		{
			throw new UniqueKeyViolationException(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue(), e);					
		}

		throw (e);
	}
	return (PatientNoAlertInfoVoAssembler.create(doPatientNoAlertInfo));		
}
 
Example 20
Project: AvoinApotti   File: TrackingConfigurationImpl.java   Source Code and License 6 votes vote down vote up
public TrackingConfigurationVo save(TrackingConfigurationVo trackingConfigToSave) throws StaleObjectException, UniqueKeyViolationException
{
	
	if (trackingConfigToSave == null )

		throw new CodingRuntimeException("Cannot save TrackingConfiguration if null or get TrackingConfiguration on null ID . ");
		
	if (!trackingConfigToSave.isValidated())
		throw new CodingRuntimeException("TrackingConfigurationVo not Validated");
	try
	{
		DomainFactory factory = getDomainFactory();
		TrackingConfiguration trackingConfig = TrackingConfigurationVoAssembler.extractTrackingConfiguration(factory,trackingConfigToSave);

		factory.save(trackingConfig);
		
		return TrackingConfigurationVoAssembler.create(trackingConfig);
	}
	catch (UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("This Configuration Already Exist!", e);
	}
	
}
 
Example 21
Project: AvoinApotti   File: TargetConfigurationImpl.java   Source Code and License 6 votes vote down vote up
public TargetConfigurationVo save(TargetConfigurationVo record) throws StaleObjectException, UniqueKeyViolationException 
{	
	if(!record.isValidated())
		throw new CodingRuntimeException("Record not validated");
	
	if (record.getStatusIsNotNull() &&
			record.getStatus().equals(PreActiveActiveInactiveStatus.ACTIVE))
	{
		if (checkForUniq(record).size() > 0)
			throw new UniqueKeyViolationException("TargetName must be unique!");
	}
	
	DomainFactory factory = getDomainFactory();
	Target domainRecord = TargetConfigurationVoAssembler.extractTarget(factory, record);		
	
	domainRecord.setUpperName(domainRecord.getName());
	factory.save(domainRecord);
		
	return TargetConfigurationVoAssembler.create(domainRecord);
}
 
Example 22
Project: AvoinApotti   File: AlertsCcImpl.java   Source Code and License 6 votes vote down vote up
public ims.core.vo.PatientNoAlertInfoForTriageVo savePatientNoAlertInfo(ims.core.vo.PatientNoAlertInfoForTriageVo patientNoAlertInfo) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.UniqueKeyViolationException
{
	if(patientNoAlertInfo == null)
		throw new CodingRuntimeException("Cannot save a null PatientNoAlertInfo.");
	
	if(!patientNoAlertInfo.isValidated())
		throw new CodingRuntimeException("PatientNoAlertInfo is not validated");
	
	DomainFactory factory = getDomainFactory();
	
	PatientNoAlertInfo doPatientNoAlertInfo = PatientNoAlertInfoForTriageVoAssembler.extractPatientNoAlertInfo(factory, patientNoAlertInfo);
	
	try
	{
		factory.save(doPatientNoAlertInfo);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
	}
	
	return PatientNoAlertInfoForTriageVoAssembler.create(doPatientNoAlertInfo);
}
 
Example 23
Project: AvoinApotti   File: SecurityLevelConfigImpl.java   Source Code and License 6 votes vote down vote up
/**
* saveSecurityLevel
*/
public void saveSecurityLevel(ims.ocrr.vo.SecurityLevelConfigVo voSecurityLevel) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.UniqueKeyViolationException
{
	if (voSecurityLevel == null)
		throw new CodingRuntimeException("voSecurityLevel is null in method saveSecurityLevel");
	if (!voSecurityLevel.isValidated())
		throw new CodingRuntimeException("voSecurityLevel has not been validated in method saveSecurityLevel");
			
	try
	{
		getDomainFactory().save(SecurityLevelConfigVoAssembler.extractSecurityLevel(getDomainFactory(), voSecurityLevel));
	}
	catch (UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("A record with the same name already exists, Please Change.");
	}
}
 
Example 24
Project: AvoinApotti   File: TaxonomyLoaderHelper.java   Source Code and License 6 votes vote down vote up
private OrgVo savePracticeVo(OrgVo vo) throws DomainInterfaceException, StaleObjectException, UniqueKeyViolationException 
{
	//WDEV-17409
	String[] err = vo.validate();
	if (err != null && err.length > 0) 
	{
		String concat = "";
		for (int i = 0; i < err.length; i++) 
		{
			concat = concat + " " + err[i] + " ";
		}
		throw new DomainRuntimeException(concat);
	} else 
	{
			return domainTaxonomy.savePracticeRecord(vo);
	}
}
 
Example 25
Project: AvoinApotti   File: DailyPatternandShiftsImpl.java   Source Code and License 6 votes vote down vote up
/**
* save 
 * @throws UniqueKeyViolationException 
*/
public ims.clinicaladmin.vo.DailyPatternConfigVo save(ims.clinicaladmin.vo.DailyPatternConfigVo record) throws ims.domain.exceptions.StaleObjectException, UniqueKeyViolationException
{
	if(record == null)
		throw new DomainRuntimeException("Invalid record");
	if(!record.isValidated())
		throw new CodingRuntimeException("Record not validated");
	
	DomainFactory factory = getDomainFactory();
	DailyPattern domainRecord = DailyPatternConfigVoAssembler.extractDailyPattern(factory, record);		
	try
	{
		factory.save(domainRecord);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("A Daily Pattern record of this type already exists. Duplicates not allowed.", e);
	}
	
	return DailyPatternConfigVoAssembler.create(domainRecord);
}
 
Example 26
Project: AvoinApotti   File: SystemReviewConfigurationImpl.java   Source Code and License 6 votes vote down vote up
public SystemReviewForPresentingProblemConfigVo save(SystemReviewForPresentingProblemConfigVo record)	throws StaleObjectException, UniqueKeyViolationException 
{
	if(	record == null)
		throw new DomainRuntimeException(" SystemReviewForPresentingProblemConfigVo has not be validated.");
	
	DomainFactory factory = getDomainFactory();	
	SystemReviewForPresentingProblemConfig doSystemReviewForPresentingProblemConfig = SystemReviewForPresentingProblemConfigVoAssembler.extractSystemReviewForPresentingProblemConfig(factory, record);
	
	try
	{
		factory.save(doSystemReviewForPresentingProblemConfig);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException();
	}
	
	return SystemReviewForPresentingProblemConfigVoAssembler.create(doSystemReviewForPresentingProblemConfig);
}
 
Example 27
Project: AvoinApotti   File: TumourCategoryGroupSitesImpl.java   Source Code and License 6 votes vote down vote up
public TumourCategoryVo saveCategory(TumourCategoryVo record) throws StaleObjectException, UniqueKeyViolationException
{
	if (record == null)
		throw new DomainRuntimeException("Invalid record");

	if (!record.isValidated())
		throw new CodingRuntimeException("Record not validated");

	DomainFactory factory = getDomainFactory();
	TumourCategory domainRecord = TumourCategoryVoAssembler.extractTumourCategory(factory, record);

	try
	{
		factory.save(domainRecord);
	}
	catch (UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException(e);
	}

	return TumourCategoryVoAssembler.create(domainRecord);
}
 
Example 28
Project: AvoinApotti   File: M02VoMapper.java   Source Code and License 6 votes vote down vote up
private OrganisationVo saveOrganisation(OrganisationVo orgVo) throws HL7Exception,StaleObjectException
	{
		String[] errors = orgVo.validate();
		if (errors != null)
		{
			throw new HL7Exception("Validation errors before save of GP Practice Org. " + VoMapper.toDisplayString(errors));				
		}			
		try
		{
			orgVo = orgLoc.saveOrganisation(orgVo);
		}
//		catch (StaleObjectException e)
//		{
//			LOG.error("GP Practice has been modified by another user/process - please try again");
//			throw new HL7Exception("LocationSite has been modified by another user/process - please try again", e);
//		}
		catch (UniqueKeyViolationException e)
		{
			LOG.error("UniqueKeyViolationException occurred saving GP Practice " + e.getMessage(), e);
			throw new HL7Exception("UniqueKeyViolationException occurred saveLocationSite " + e.getMessage(), e);
		}
		return orgVo;
	}
 
Example 29
Project: AvoinApotti   File: TumourCategoryGroupSitesImpl.java   Source Code and License 6 votes vote down vote up
public TumourGroupVo saveGroup(TumourGroupVo voGroup, TumourCategoryVersionGroupsLiteVo version) throws StaleObjectException, UniqueKeyViolationException
{
	if (voGroup == null || version == null)
		throw new DomainRuntimeException("Invalid record to save");
	
	if (!voGroup.isValidated() || !version.isValidated())
		throw new DomainRuntimeException("Record to save not validated");
	
	TumourCategoryVersionGroups domVersion = (TumourCategoryVersionGroups) getDomainFactory().getDomainObject(version);
	TumourGroup domGroup = TumourGroupVoAssembler.extractTumourGroup(getDomainFactory(), voGroup);
	
	if (voGroup.getID_TumourGroupIsNotNull())
	{
		// Actually an edit - no need to save at version level
		getDomainFactory().save(domGroup);
		
		return TumourGroupVoAssembler.create(domGroup);
	}
	
	// A new group is created - we need to save the group at Version level
	domVersion.getGroups().add(domGroup);
	
	getDomainFactory().save(domVersion);

	return TumourGroupVoAssembler.create(domGroup);
}
 
Example 30
Project: AvoinApotti   File: TumourCategoryGroupSitesImpl.java   Source Code and License 6 votes vote down vote up
public TumourSiteVo saveSite(TumourSiteVo record, TumourGroupListVo voGroup) throws StaleObjectException, UniqueKeyViolationException
{
	if (record == null || voGroup == null)
		throw new DomainRuntimeException("Invalid record to save");
	
	if (!record.isValidated() || !voGroup.isValidated())
		throw new DomainRuntimeException("Record to save not validated");
	
	TumourGroup domGroup = (TumourGroup) getDomainFactory().getDomainObject(voGroup);
	TumourSite domSite = TumourSiteVoAssembler.extractTumourSite(getDomainFactory(), record);
	
	if (record.getID_TumourSiteIsNotNull())
	{
		// Actually an edit - no need to save at group level
		getDomainFactory().save(domSite);
		
		return TumourSiteVoAssembler.create(domSite);
	}
	
	// A new site record is created - we need to save at group level
	domGroup.getSites().add(domSite);
	
	getDomainFactory().save(domGroup);

	return TumourSiteVoAssembler.create(domSite);
}
 
Example 31
Project: AvoinApotti   File: UserAssessmentNewImpl.java   Source Code and License 6 votes vote down vote up
public UserAssessmentVo saveAssessment(UserAssessmentVo assessment)	throws DomainInterfaceException, StaleObjectException, UniqueKeyViolationException 
{
	if(assessment.isValidated() == false)
		throw new DomainRuntimeException("UserAssessmentVo not validated");
	
	DomainFactory factory = getDomainFactory();
	UserAssessment obj = UserAssessmentVoAssembler.extractUserAssessment(factory, assessment);
	
	try
	{
		factory.save(obj);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException("Already exists a question with this taxonomy code.", e);
	}
	
	return UserAssessmentVoAssembler.create(obj);
}
 
Example 32
Project: AvoinApotti   File: AttendanceKPIConfigurationImpl.java   Source Code and License 6 votes vote down vote up
public ims.emergency.vo.AttendanceKPIConfigVo saveAttendanceKPIConfig(ims.emergency.vo.AttendanceKPIConfigVo record) throws ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.UniqueKeyViolationException
{
	if (record == null)
		throw new CodingRuntimeException("Cannot save null AttendanceKPIConfigVo");

	DomainFactory factory = getDomainFactory();
			
	AttendanceKPIConfig doAttendanceKPIConfig = AttendanceKPIConfigVoAssembler.extractAttendanceKPIConfig(factory, record);

	try
	{
		factory.save(doAttendanceKPIConfig);
	}
	catch(UnqViolationUncheckedException e)
	{
		throw new UniqueKeyViolationException();
	}

	return AttendanceKPIConfigVoAssembler.create(doAttendanceKPIConfig);
}
 
Example 33
Project: AvoinApotti   File: RACPCSummaryImpl.java   Source Code and License 5 votes vote down vote up
public RACPCSummaryVo saveRACPCSummary(RACPCSummaryVo summary) throws DomainInterfaceException, StaleObjectException, UniqueKeyViolationException 
{
	if(summary == null)
		throw new CodingRuntimeException("Cannot save a null RACPCSummaryVo");
	
	if(!summary.isValidated())
		throw new CodingRuntimeException("RACPCSummaryVo is not validated");
	
	DomainFactory factory = getDomainFactory();
	RACPCSummary doSummary = RACPCSummaryVoAssembler.extractRACPCSummary(factory, summary);
	
	factory.save(doSummary);
	
	return RACPCSummaryVoAssembler.create(doSummary);
}
 
Example 34
Project: AvoinApotti   File: Logic.java   Source Code and License 5 votes vote down vote up
/**
 * @param voOrg
 */
private boolean saveSupplier(OrgShortVo voOrg) 
{
	String[] arrErrors = null;
	
	if(voOrg != null)
		arrErrors = voOrg.validate();
	
	if(arrErrors != null)
	{
		engine.showErrors(arrErrors);
		return false;
	}

	try {
			if(voOrg != null)
			{				
				form.getLocalContext().setSupplier(domain.saveOrganisationShort(voOrg));
			}
		}
	catch (StaleObjectException e) 
	{
		engine.showMessage(ims.configuration.gen.ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
		open();
		return false;
	} 
	catch (UniqueKeyViolationException e1) 
	{
		engine.showMessage(e1.getMessage());
		return false;
	} 
	
	return true;
}
 
Example 35
Project: AvoinApotti   File: TumourDetailsImpl.java   Source Code and License 5 votes vote down vote up
/**
 * Domain Interface function used to save Primary Tumour Details records
 * 
 * Will return the saved record
 */
public PrimaryTumourDetailsVo saveTumourDetails(PrimaryTumourDetailsVo tumourDetails, PrimaryTumourDetailsRefVo currentEditableRecord) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException
{
	if(tumourDetails == null)
		throw new CodingRuntimeException("Invalid record");

	if(!tumourDetails.isValidated())
		throw new CodingRuntimeException("Record not validated");
	
	DomainFactory factory = getDomainFactory();

	// Set is current to false to current Primary Tumour Details record
	if (currentEditableRecord != null && currentEditableRecord.getID_PrimaryTumourDetailsIsNotNull()
			&& !currentEditableRecord.getID_PrimaryTumourDetails().equals(tumourDetails.getID_PrimaryTumourDetails()))
	{
		PrimaryTumourDetails currentEditableDomainObject = (PrimaryTumourDetails) getDomainFactory().getDomainObject(PrimaryTumourDetails.class, currentEditableRecord.getID_PrimaryTumourDetails());
		
		currentEditableDomainObject.setIsCurrent(Boolean.FALSE);
		
		factory.save(currentEditableDomainObject);
	}
		
	PrimaryTumourDetails domainRecord = PrimaryTumourDetailsVoAssembler.extractPrimaryTumourDetails(factory, tumourDetails);		
	
	factory.save(domainRecord);		
	
	return PrimaryTumourDetailsVoAssembler.create(domainRecord);
}
 
Example 36
Project: AvoinApotti   File: DischargeSummaryWardPacuImpl.java   Source Code and License 5 votes vote down vote up
public DischargeSummaryPacuAndWardVo saveDischargeSummaryWardAndPacu(DischargeSummaryPacuAndWardVo dischargeSummary) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException
{
	if (dischargeSummary == null)
		throw new CodingRuntimeException("Logical error - discharge summary is null in domain.save");
	
	if (!dischargeSummary.isValidated())
		throw new CodingRuntimeException("Logical error - Validate the Vo before saving");
	
	DomainFactory factory = getDomainFactory();
	DischargeSummaryPacuAndWard domDischargeSummary = DischargeSummaryPacuAndWardVoAssembler.extractDischargeSummaryPacuAndWard(factory, dischargeSummary);
	
	factory.save(domDischargeSummary);
	
	return DischargeSummaryPacuAndWardVoAssembler.create(domDischargeSummary);
}
 
Example 37
Project: AvoinApotti   File: Logic.java   Source Code and License 5 votes vote down vote up
private void removeFunction()
{
	if (form.getLocalContext().getSelectedRecordIsNotNull() && form.getLocalContext().getSelectedRecordFunctionIsNotNull())
	{
		try
		{
			try
			{
				try
				{
					domain.removeServiceFunction(form.getLocalContext().getSelectedRecordFunction());
					updateServiceEntry(form.treService().getSelectedNode().getParent());
					form.treService().setValue(null);
				}
				catch (UniqueKeyViolationException de)
				{
					if (form.getLocalContext().getSelectedRecordFunction().getFunctionIsNotNull())
						engine.showMessage("Cannot remove " + ConfigFlag.UI.DISPLAY_NAME_FUNCTION.getValue(true) + " : " + (form.getLocalContext().getSelectedRecordFunction().getFunctionIsNotNull() ? form.getLocalContext().getSelectedRecordFunction().getFunction().toString() : "") + ". It is already used in a Location.");
					else
						engine.showMessage("Cannot remove this" + ConfigFlag.UI.DISPLAY_NAME_FUNCTION.getValue(true) + " as it is already used in a location.");
					setScreenViewMode();
				}
			}
			catch (StaleObjectException se)
			{
				engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
				open();
			}
		}
		catch (ForeignKeyViolationException e)
		{
			engine.showMessage(e.getMessage());
			setScreenViewMode();
		}
	}
}
 
Example 38
Project: AvoinApotti   File: ClinicalCodingImpl.java   Source Code and License 5 votes vote down vote up
public ProblemConfigVo saveConfigVo(ProblemConfigVo voProblemConfig) throws StaleObjectException, UniqueKeyViolationException 
{
	if (!voProblemConfig.isValidated())
	{
		throw new DomainRuntimeException("This ProblemConfigVo has not be validated.");
	}
	
	DomainFactory factory = getDomainFactory();			
	ClinicalProblem domProblem = ProblemConfigVoAssembler.extractClinicalProblem(factory, voProblemConfig);
	
	domProblem.setKeywords(Keywords.setupKeyWords(domProblem.getKeywords(), domProblem.getPCName()));
	try
	{
		factory.save(domProblem);
	}
	catch(UnqViolationUncheckedException e)
	{
		//check which constraint was violated (name/taxononmy map)

		//name
		ClinicalProblem prob = ClinicalProblem.getClinicalProblemFromPCName(factory, voProblemConfig.getPCName());
		if (prob != null && prob.getId() != null && !(prob.getId().equals(voProblemConfig.getID_ClinicalProblem())))
		{
			throw new UniqueKeyViolationException("Problem record called \"" + voProblemConfig.getPCName() + "\" already exists. Duplicates not allowed.", e);					
		}
		
		//taxonomy map
		String dupMessage = Keywords.checkDuplicateTaxonomy(factory, domProblem, voProblemConfig.getTaxonomyMap(), "getPCName");
		if(dupMessage != null)
			throw new UniqueKeyViolationException(dupMessage);
		
		throw (e);
	}
	return ProblemConfigVoAssembler.create(domProblem);
}
 
Example 39
Project: AvoinApotti   File: SecurityTokenAdminImpl.java   Source Code and License 5 votes vote down vote up
public String getSecurityToken(String username, String password) throws DomainInterfaceException, StaleObjectException,	UniqueKeyViolationException 
{
	if(username == null || username.length() == 0)
		throw new DomainInterfaceException("Can not generate security token for empty username.");
	
	if(password == null || password.length() == 0)
		throw new DomainInterfaceException("Can not generate security token for empty password.");
	
	DomainFactory factory = getDomainFactory();
	
	SecurityTokenVo st= new SecurityTokenVo();
	SecurityParamVoCollection params = new SecurityParamVoCollection();
	
	SecurityParamVo sp1 = new SecurityParamVo();
	sp1.setItem("username");
	sp1.setValue(username);
	params.add(sp1);
	
	SecurityParamVo sp2 = new SecurityParamVo();
	sp2.setItem("password");
	sp2.setValue(password);
	params.add(sp2);
	
	st.setParams(params);
	
	String securityToken = UUID.randomUUID().toString();
	st.setTokenID(securityToken);
	st.setExpirationTimeStamp(new DateTime().addMinutes(10));
	
	SecurityToken stDom = SecurityTokenVoAssembler.extractSecurityToken(factory, st);
	
	factory.save(stDom);
	
	return securityToken;
}
 
Example 40
Project: AvoinApotti   File: ICPConfigImpl.java   Source Code and License 5 votes vote down vote up
/**
 * Function used to add an ICP Phase to an ICP Stage
 */
@SuppressWarnings("unchecked")
public ICPPhaseVo addPhase(ICPPhaseVo phase, ICPStageShortVo stage) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException, UnqViolationUncheckedException
{
	// Check for parameters
	if (stage == null)
		throw new DomainRuntimeException("Logical error - Can not add an ICP Phase to a null ICP Stage");

	if (phase == null)
		throw new DomainRuntimeException("Logical error - Can not add a null ICP Phase to an ICP Stage");

	// Check VO for validation
	if (!stage.isValidated() || !phase.isValidated())
		throw new DomainRuntimeException("Logical error - ICP Phase Vo and ICP Stage Vo must be validated before save");

	// Get domain factory
	DomainFactory factory = getDomainFactory();

	// Extract ICP Phase domain object
	ICPPhase domainICPPhase = ICPPhaseVoAssembler.extractICPPhase(factory, phase);

	// Extract ICP Stage domain object
	ICPStage domainICPStage = ICPStageShortVoAssembler.extractICPStage(factory, stage);

	domainICPStage.getPhases().add(domainICPPhase);

	// Save ICP domain object
	factory.save(domainICPStage);

	// Return the saved phase
	return ICPPhaseVoAssembler.create(domainICPPhase);
}
 
Example 41
Project: AvoinApotti   File: CorrespondenceDetailImpl.java   Source Code and License 5 votes vote down vote up
public CorrespondenceDetailsVo saveCorrespondenceDetails(CorrespondenceDetailsVo voDocDetail, LookupInstVo pasEventType) throws DomainInterfaceException, StaleObjectException, UniqueKeyViolationException 
{

	if (!voDocDetail.isValidated())
	{
		throw new DomainRuntimeException("CorrespondenceDetailsVo not validated.");
	}

	DomainFactory factory = getDomainFactory();
	CorrespondenceDetails domDocDetails = null;
	
	domDocDetails = CorrespondenceDetailsVoAssembler.extractCorrespondenceDetails(factory,voDocDetail);
	
	try
	{
		factory.save(domDocDetails);
	}
	catch (UnqViolationUncheckedException e) 
	{
		throw new UniqueKeyViolationException("A Correspondence details already exists for the chosen PASEvent. Duplicates not allowed.", e);
	}
	
	saveCurrentDocStatus(voDocDetail,pasEventType);
	
	return CorrespondenceDetailsVoAssembler.create(domDocDetails);
	
}
 
Example 42
Project: AvoinApotti   File: Logic.java   Source Code and License 5 votes vote down vote up
private boolean saveDiagnosisRecord(PatientDiagnosisEDischargeVo voPatientDiagnosis) throws PresentationLogicException
{
	String[] errors = voPatientDiagnosis.validate();
	if (errors != null)
	{
		engine.showErrors(errors);
		return false;
	}

	try
	{
		voPatientDiagnosis = domain.saveDiagnosisVo(voPatientDiagnosis, null);
	}
	catch (StaleObjectException sox)
	{
		engine.showMessage(ims.configuration.gen.ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
		form.getLocalContext().setSelectedPatientDiagnosisVo(null);
		form.setMode(FormMode.VIEW);
		enableDisableDiagnosisInstanceControls(false);
		open();
		return false;
	}
	catch (UniqueKeyViolationException ue)
	{
		engine.showMessage(ue.getMessage());
		return false;
	}
	catch (DomainInterfaceException e)
	{
		engine.showErrors(new String[] { e.getMessage() });
		return false;
	}
	form.getLocalContext().setSelectedPatientDiagnosisVo(voPatientDiagnosis);

	form.getLocalContext().setLastEvent(EDischargeLastEvent.EDISCHARGE_SAVE);

	return true;
}
 
Example 43
Project: AvoinApotti   File: CorrespondenceDetailsImpl.java   Source Code and License 5 votes vote down vote up
public CorrespondenceDetailsVo saveCorrespondenceDetails(CorrespondenceDetailsVo voDocDetail, LookupInstVo pasEventType) throws DomainInterfaceException, StaleObjectException, UniqueKeyViolationException 
{

	if (!voDocDetail.isValidated())
	{
		throw new DomainRuntimeException("CorrespondenceDetailsVo not validated.");
	}

	DomainFactory factory = getDomainFactory();
	CorrespondenceDetails domDocDetails = null;
	
	domDocDetails = CorrespondenceDetailsVoAssembler.extractCorrespondenceDetails(factory,voDocDetail);
	
	try
	{
		factory.save(domDocDetails);
	}
	catch (UnqViolationUncheckedException e) 
	{
		throw new UniqueKeyViolationException("A Correspondence details already exists for the chosen PASEvent. Duplicates not allowed.", e);
	}
	
	saveCurrentDocStatus(voDocDetail,pasEventType);
	
	return CorrespondenceDetailsVoAssembler.create(domDocDetails);
	
}
 
Example 44
Project: AvoinApotti   File: PainBodyChartImpl.java   Source Code and License 5 votes vote down vote up
/**
 * save the PainAssessment Record
 * @throws UniqueKeyViolationException 
 * @throws DomainInterfaceException 
 * **/
public AssessmentHeaderInfo saveRecord(ims.nursing.vo.PainAssessment painAssessment, AssessmentHeaderInfo assessment, AssessmentComponent component) throws StaleObjectException, UniqueKeyViolationException, DomainInterfaceException 
{
	if(painAssessment != null && !painAssessment.isValidated())
		throw new DomainRuntimeException("The PainAssessment has not been validated");
					
	if (assessment != null && component != null)
	{
		if(!assessment.isValidated())
			throw new DomainRuntimeException("The AssessmentHeaderInfo has not been validated");
	
		if(!component.isValidated())
			throw new DomainRuntimeException("The AssessmentComponent has not been validated");
	
		return (savePainAssessmentComponent(assessment, component, painAssessment.getClinicalContact()));
	}
	else
	{
		DomainFactory factory = getDomainFactory();

		ims.nursing.assessmenttools.domain.objects.PainAssessment domPainAssess = PainAssessmentAssembler.extractPainAssessment(factory, painAssessment);
		try
		{				
			factory.save(domPainAssess);
			ims.nursing.vo.PainAssessment voPain = PainAssessmentAssembler.create(domPainAssess);
			return null;
		}
		catch (DomainException e) 
		{
			throw new DomainRuntimeException("DomainException occurred saving Skin Assessment.\r\n" + e.getMessage(), e);
		}
	}		
}
 
Example 45
Project: AvoinApotti   File: DirectoryOfServiceAdminImpl.java   Source Code and License 5 votes vote down vote up
public DirectoryOfServiceVo saveDirectoryOfService(DirectoryOfServiceVo directoryOfService) throws StaleObjectException, UniqueKeyViolationException
{
	if(directoryOfService == null)
		throw new CodingRuntimeException("directoryOfService param is null in method saveDirectoryOfService");
	
	if(!directoryOfService.isValidated())
		throw new DomainRuntimeException("ActivitySchedVo not validated");
	
	DomainFactory factory = getDomainFactory();
	
	//TODO this implementation is not ideal - the recordExistForDoSIdAndIsActive should really take the record id attemptimg to be saved if applicable(update) as a param
	//instead of calling getDirectoryofServiceFromdos_unq1 to check that the conflict is not with this record itself(update)		
	if(DirectoryofService.recordExistForDoSIdAndIsActive(factory, directoryOfService.getDoSId(), directoryOfService.getIsActive()))
	{
		if(directoryOfService.getID_DirectoryofServiceIsNotNull())
		{
			DirectoryofService doConflictingDos = DirectoryofService.getDirectoryofServiceFromdos_unq1(factory,directoryOfService.getDoSId(), directoryOfService.getIsActive());
			if(!doConflictingDos.getId().equals(directoryOfService.getID_DirectoryofService()))
				throw new UniqueKeyViolationException("An " + (directoryOfService.getIsActive() ? "active" : "inactive") + " Directory Of Service with this ID already exists");
		}
		else
			throw new UniqueKeyViolationException("An " + (directoryOfService.getIsActive() ? "active" : "inactive") + " Directory Of Service with this ID already exists");
	}
		
	DirectoryofService doDirService = DirectoryOfServiceVoAssembler.extractDirectoryofService(factory, directoryOfService);
	factory.save(doDirService);
	
	return DirectoryOfServiceVoAssembler.create(doDirService);
}
 
Example 46
Project: AvoinApotti   File: MNAInputImpl.java   Source Code and License 5 votes vote down vote up
public MnaEnhancedVo saveAll(MnaEnhancedVo mnaEnhancedRecordVo,	CareContextShortVo careContext) throws DomainInterfaceException,StaleObjectException, UniqueKeyViolationException {
	// Ensure the Value Object was validated
	if (!mnaEnhancedRecordVo.isValidated())
		throw new DomainRuntimeException("This MnaEnhanced VO has not been validated");

	VitalSignsVo vs = null;
	if(mnaEnhancedRecordVo.getVsRecord() != null){
		vs = insertMetricsRecord(mnaEnhancedRecordVo.getVsRecord());
		if(vs!=null)
			mnaEnhancedRecordVo.getMnaRecord().setMetrics(vs.getMetrics());
	}
	
	mnaEnhancedRecordVo.getMnaRecord().validate();
	
	MiniNutritionalAssessment mna = saveRecord(mnaEnhancedRecordVo.getMnaRecord());
	AssessmentHeaderInfo headerInfo = null;
	
	if(mnaEnhancedRecordVo.getVsRecord() != null)
		insertMetricsRecord(mnaEnhancedRecordVo.getVsRecord());
	if(mnaEnhancedRecordVo.getAedRecord() != null)
	{
		mnaEnhancedRecordVo.getAedRecord().setMiniNutritionalAssessment(mna);
		mnaEnhancedRecordVo.getAedRecord().validate();
		headerInfo = saveEatingAssessmentComponent(mnaEnhancedRecordVo.getAshRecord(), mnaEnhancedRecordVo.getAedRecord(), careContext);
	}
	
	mnaEnhancedRecordVo.setMnaRecord(mna);
	mnaEnhancedRecordVo.setAshRecord(headerInfo);
	
	return mnaEnhancedRecordVo;
	
}
 
Example 47
Project: AvoinApotti   File: ActivityImpl.java   Source Code and License 5 votes vote down vote up
public CodingAlertConfigurationVo saveAlert(CodingAlertConfigurationVo alertVo) throws ims.domain.exceptions.StaleObjectException, UniqueKeyViolationException
{
	if (!alertVo.isValidated())
	{
		throw new DomainRuntimeException("Alert has not been validated");
	}
	
	alertVo.setActivity(saveActivity(alertVo.getActivity()));
	DomainFactory factory = getDomainFactory();
	CodingAlertConfiguration doCodingAlertConfiguration = CodingAlertConfigurationVoAssembler.extractCodingAlertConfiguration(factory, alertVo);
	
	factory.save(doCodingAlertConfiguration); 
	return CodingAlertConfigurationVoAssembler.create(doCodingAlertConfiguration);
}
 
Example 48
Project: AvoinApotti   File: DemographicsImpl.java   Source Code and License 5 votes vote down vote up
private ims.core.vo.Patient replicatePatient(ims.core.vo.Patient voPatient) throws StaleObjectException, UniqueKeyViolationException, DomainInterfaceException
{
	voPatient.getName().setUppers();
	if (voPatient.getIsActive() == null)
		voPatient.setIsActive(Boolean.TRUE);

	voPatient.getName().setUppers();
	if (voPatient.getOtherNames() != null)
	{
		for (int i = 0; i < voPatient.getOtherNames().size(); i++)
		{
			voPatient.getOtherNames().get(i).setUppers();
		}
	}
	if (voPatient.getIdentifiers() != null)
	{
		for (int i = 0; i < voPatient.getIdentifiers().size(); i++)
		{
			PatientId patId = voPatient.getIdentifiers().get(i);
			//WDEV-10116
			String val = patId.getIdValue().trim();
			if(!ConfigFlag.DOM.CASE_SENSITIVE_PATID.getValue())
			{
				val = val.toUpperCase();
			}
			patId.setValue(val);
		}			
	}
	if (voPatient.getIsActive() == null)
		voPatient.setIsActive(Boolean.TRUE);

	// WDEV-6633 - call this method as it handles duplicate NHS numbers
	return savePatientRecord(getDomainFactory(), voPatient, 0, false, true);
}
 
Example 49
Project: AvoinApotti   File: FitForSurgeryAssessmentImpl.java   Source Code and License 5 votes vote down vote up
public FitForSurgeryAssesmentVo save(FitForSurgeryAssesmentVo record) throws DomainInterfaceException, StaleObjectException, UniqueKeyViolationException 
{
	if (record == null)
		throw new CodingRuntimeException("record is null in method save");
	
	if (!record.isValidated())
		throw new CodingRuntimeException("record has not been validated in method save");
	
	DomainFactory factory = getDomainFactory();
	FitForSurgeryAssesment domFitForSurgery = FitForSurgeryAssesmentVoAssembler.extractFitForSurgeryAssesment(factory, record);
	factory.save(domFitForSurgery);
	
	FitForSurgeryAssesmentVo fitForSurgery = FitForSurgeryAssesmentVoAssembler.create(domFitForSurgery);
	OutpatientPreAssessmentVo outPatient = getOutPatientPreassessment(record.getCareContext());
	
	if(outPatient == null)
	{
		outPatient = new OutpatientPreAssessmentVo();
		outPatient.setCareContext(record.getCareContext());
	}
	outPatient.setFitForSurgeryAssesment(fitForSurgery);
	
	OutpatientPreAssessment domOutpatient = OutpatientPreAssessmentVoAssembler.extractOutpatientPreAssessment(factory, outPatient);
	factory.save(domOutpatient);
	
	//Update the CatsReferral.sSuitableForSurgery attribute
	//WDEV-11692
	updateSuitableForSurgery(outPatient.getCareContext(), record.getFitForSurgery(), (record.getOPDAppt() != null && record.getOPDAppt().getSession() != null) ? record.getOPDAppt().getSession().getSchLocation() : null);

	return fitForSurgery;
}
 
Example 50
Project: AvoinApotti   File: ClinicalCodingImpl.java   Source Code and License 5 votes vote down vote up
public DiagnosisVo saveDiagnosisVo(DiagnosisVo voDiagnosisVo) throws StaleObjectException, UniqueKeyViolationException 
{
	if (!voDiagnosisVo.isValidated())
	{
		throw new DomainRuntimeException("This DiagnosisVo has not been validated");
	}
	
	DomainFactory factory = getDomainFactory();			
	Diagnosis domDiagnosis = DiagnosisVoAssembler.extractDiagnosis(factory, voDiagnosisVo);

	domDiagnosis.setKeywords(Keywords.setupKeyWords(domDiagnosis.getKeywords(), domDiagnosis.getDiagnosisName()));
	try
	{
		factory.save(domDiagnosis);
	}
	catch(UnqViolationUncheckedException e)
	{		
		//check which constraint was violated (name/taxononmy map)

		//name
		Diagnosis diag = Diagnosis.getDiagnosisFromDiagnosisName(factory, voDiagnosisVo.getDiagnosisName());
		if (diag != null && diag.getId() != null && !(diag.getId().equals(voDiagnosisVo.getID_Diagnosis())))
		{
			throw new UniqueKeyViolationException("Diagnosis record called \"" + voDiagnosisVo.getDiagnosisName() + "\" already exists. Duplicates not allowed.", e);	
		}

		//taxonomy map
		String dupMessage = Keywords.checkDuplicateTaxonomy(factory, domDiagnosis, voDiagnosisVo.getTaxonomyMap(), "getDiagnosisName");
		if(dupMessage != null)
			throw new UniqueKeyViolationException(dupMessage);
					
		throw (e);
	}
	return DiagnosisVoAssembler.create(domDiagnosis);
}
 
Example 51
Project: AvoinApotti   File: ICPConfigImpl.java   Source Code and License 5 votes vote down vote up
/**
 * Function used to inactivate an ICP Phase
 */
@SuppressWarnings("unchecked")
public ICPPhaseVo inactivateICPPhase(ICPPhase icpPhase) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException, UnqViolationUncheckedException
{
	final int INACTIVE_STATUS = -618;

	// Check parameters
	if (icpPhase == null)
		return null;

	// Get domain factory
	DomainFactory factory = getDomainFactory();

	// Modify the status for phase and actions
	Iterator<ICPAction> iterator = icpPhase.getActions().iterator();

	while (iterator.hasNext())
	{
		// Inactivate action
		inactivateICPAction(iterator.next());
	}

	icpPhase.setStatus(factory.getLookupInstance(INACTIVE_STATUS));

	// Save ICP Phase - We need to save, the function might be called by
	// itself
	factory.save(icpPhase);

	return ICPPhaseVoAssembler.create(icpPhase);
}
 
Example 52
Project: AvoinApotti   File: SupportNetworkProfessionalServicesImpl.java   Source Code and License 5 votes vote down vote up
public PatientNoSupportNetworkServicesInfoVo savePatientNoSupportNetworkServicesInfo(PatientNoSupportNetworkServicesInfoVo voPatientNoSupportNetworkServicesInfo) throws DomainInterfaceException, StaleObjectException, UniqueKeyViolationException 
{
	DomainFactory factory = getDomainFactory();		
	PatientNoSupportNetworkServicesInfo doPatientNoSupportNetworkServicesInfo = PatientNoSupportNetworkServicesInfoVoAssembler.extractPatientNoSupportNetworkServicesInfo(factory, voPatientNoSupportNetworkServicesInfo);			
	factory.save(doPatientNoSupportNetworkServicesInfo);
	return (PatientNoSupportNetworkServicesInfoVoAssembler.create(doPatientNoSupportNetworkServicesInfo));		
}
 
Example 53
Project: AvoinApotti   File: PlinthWorkImpl.java   Source Code and License 5 votes vote down vote up
public void savePlinthWork(PlinthWorkVo voPlinthWork) throws StaleObjectException, UniqueKeyViolationException
{
	if(voPlinthWork == null)
		throw new DomainRuntimeException("Cannot save null Plinth Work");
	
	// Ensure the value object has been validated
	if (!voPlinthWork.isValidated())
		throw new DomainRuntimeException("Plinth Work has not been validated");

	DomainFactory factory = getDomainFactory();
	PlinthWork doPlinthWork = PlinthWorkVoAssembler.extractPlinthWork(factory, voPlinthWork);
	
	factory.save(doPlinthWork);

}
 
Example 54
Project: AvoinApotti   File: PatientMergeImpl.java   Source Code and License 5 votes vote down vote up
private PatientIdCollection mergePatientIdentifiers(DomainFactory factory, Patient srcPat, Patient destPat) throws SQLException, DomainInterfaceException, StaleObjectException, UniqueKeyViolationException
{
	ims.core.vo.Patient sourcePatient = PatientAssembler.create(srcPat);
	PatientIdCollection sourceIds = (PatientIdCollection) sourcePatient.getIdentifiers().clone();

	srcPat.getIdentifiers().clear();  // Source identifiers moved to destination
	factory.save(srcPat);  // Need to save source pat with no ids before assigning to destination as otherwise, hibernate complains

	//add (source) identifiers to new (destination) patient
	for(int i=0;i<sourceIds.size();i++)
	{
		PatientId id = (PatientId) sourceIds.get(i).clone();

		// wdev-6169 Do not move the nhsn over if it's the same as the nhsn for the destination patient
		if (id.getType().getId() == PatIdType.NHSN.getID())
		{
			if (getNHSN(destPat.getIdentifiers()).equals(id.getValue()))
				continue;

			// wdev-6148 If moving an NHSN value over and it is verified, set it to unverified
			id.setVerified(false);
		}
		
		// wdev-10710 Only merge the PATNUM identifier if the source is NOT an ICABDummy Patient
		if (id.getType().getId() == PatIdType.PATNUM.getID())
		{
			if (sourcePatient.getNameIsNotNull() && sourcePatient.getName().getSurnameIsNotNull() &&
					sourcePatient.getName().getSurname().equals(DUMMY_PATIENT))
				continue;  // Do no insert them
		}

		
		id.setMerged(true);
		destPat.getIdentifiers().add(PatientIdAssembler.extractPatientId(factory,id));
	}

	
	return sourceIds;
}
 
Example 55
Project: AvoinApotti   File: DiagnosisListImpl.java   Source Code and License 5 votes vote down vote up
public ims.core.vo.DiagnosisVo saveDiagnosisVo(ims.core.vo.DiagnosisVo voDiagnosisVo) throws StaleObjectException, UniqueKeyViolationException																							
{
	if (!voDiagnosisVo.isValidated())
	{
		throw new DomainRuntimeException("This DiagnosisVo has not been validated");
	}
	
	DomainFactory factory = getDomainFactory();			
	Diagnosis domDiagnosis = DiagnosisVoAssembler.extractDiagnosis(factory, voDiagnosisVo);

	domDiagnosis.setKeywords(Keywords.setupKeyWords(domDiagnosis.getKeywords(), domDiagnosis.getDiagnosisName()));
	try
	{
		factory.save(domDiagnosis);
	}
	catch(UnqViolationUncheckedException e)
	{		
		//check which constraint was violated (name/taxononmy map)

		//name
		Diagnosis diag = Diagnosis.getDiagnosisFromDiagnosisName(factory, voDiagnosisVo.getDiagnosisName());
		if (diag != null && diag.getId() != null && !(diag.getId().equals(voDiagnosisVo.getID_Diagnosis())))
		{
			throw new UniqueKeyViolationException("Diagnosis record called \"" + voDiagnosisVo.getDiagnosisName() + "\" already exists. Duplicates not allowed.", e);	
		}

		//taxonomy map
		String dupMessage = Keywords.checkDuplicateTaxonomy(factory, domDiagnosis, voDiagnosisVo.getTaxonomyMap(), "getDiagnosisName");
		if(dupMessage != null)
			throw new UniqueKeyViolationException(dupMessage);
					
		throw (e);
	}
	return DiagnosisVoAssembler.create(domDiagnosis);
}
 
Example 56
Project: AvoinApotti   File: SECSConfigImpl.java   Source Code and License 5 votes vote down vote up
public SECSVo saveSECS(SECSVo voSecs) throws StaleObjectException,UniqueKeyViolationException
{
	if(voSecs == null)
		throw new CodingRuntimeException("voSecs parameter is null in method saveSECS");
	if(!voSecs.isValidated())
		throw new CodingRuntimeException("voSecs has not been validated");
	
	
	DomainFactory factory = getDomainFactory();
	//wdev-13392
	if(voSecs.getID_SECS() == null)
	{
		
		SECSVoCollection list = getSecsConfiguration();
		if(list != null && list.size() > 0)
		{
			throw new UniqueKeyViolationException("A SECS Configuration already exists.");
			
		}
	
	}
	//---------------
	
	SECS doSecs = SECSVoAssembler.extractSECS(factory, voSecs);
	factory.save(doSecs);
	
	return SECSVoAssembler.create(doSecs);
}
 
Example 57
Project: AvoinApotti   File: DemographicsComponentImpl.java   Source Code and License 5 votes vote down vote up
/**
* Get's a specific Patient
 * @throws UniqueKeyViolationException 
*/
public ims.core.vo.Patient getPatient(PatientShort patient) throws StaleObjectException, UniqueKeyViolationException
{
	ims.core.domain.Demographics impl = (ims.core.domain.Demographics) getDomainImpl(DemographicsImpl.class);
	
	return impl.getPatient(patient);
}
 
Example 58
Project: AvoinApotti   File: ClinicalCodingImpl.java   Source Code and License 5 votes vote down vote up
public AllergenVo saveAllergenVo(AllergenVo allergenVo) throws StaleObjectException, UniqueKeyViolationException
{
	AllergenDetails detVo = new AllergenDetails(allergenVo.getID_Allergen(), allergenVo.getVersion_Allergen());
	detVo.setAllergenName(allergenVo.getAllergenName());
	detVo.setAllergenType(allergenVo.getAllergenType());
	detVo.setIsActive(allergenVo.getIsActive());
	detVo.setIsRIE(allergenVo.getIsRIE());
	String[] arrErrors = detVo.validate();
	if( arrErrors != null)
	{
		throw new DomainRuntimeException("Error saving Allergen - Allergen not vlaidated correctly");
	}
	return  saveAllergenDetails(detVo);
}
 
Example 59
Project: AvoinApotti   File: Logic.java   Source Code and License 5 votes vote down vote up
private boolean save() 
{
	if (!validateTimePeriods())
		return false;
	
	populateDataFromScreen();
	
	DailyPatternConfigVo voPattern = form.getLocalContext().getSelectedDailyPatternConfigVo();
	
	String[] errors = voPattern.validate();
	if (errors != null)
	{
		engine.showErrors(errors);
		return false;
	}
	
	try
	{
		voPattern = domain.save(voPattern);
	}
	catch (StaleObjectException sox)
	{
		engine.showMessage(ims.configuration.gen.ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue());
		open();
		return false;
	} 
	catch (UniqueKeyViolationException e) 
	{
		engine.showMessage(e.getMessage());
		return false;
	}
	return true;
}
 
Example 60
Project: AvoinApotti   File: HCGCcImpl.java   Source Code and License 5 votes vote down vote up
public HCGTestsVo save(HCGTestsVo hcgToSave) throws StaleObjectException, UniqueKeyViolationException
{
	if (hcgToSave == null)
		throw new CodingRuntimeException("Cannot save null HCGTest ");

	if (!hcgToSave.isValidated())
		throw new DomainRuntimeException("HCGTest Not Validated.");

	DomainFactory factory = getDomainFactory();
	HCGTests domainHCG = HCGTestsVoAssembler.extractHCGTests(factory, hcgToSave);

	factory.save(domainHCG);

	return HCGTestsVoAssembler.create(domainHCG);
}