public void deletePractice(OrganisationVo orgToDelete) throws ForeignKeyViolationException { if(orgToDelete == null) throw new RuntimeException("Cannot delete null OrganisationVo"); DomainFactory factory = getDomainFactory(); Organisation doOrganisation = OrganisationVoAssembler.extractOrganisation(factory, orgToDelete); if (doOrganisation.getLocationSites().size() > 0) { throw new ForeignKeyViolationException("There are Surgeries associated with this Practice. Cannot delete."); } factory.delete(doOrganisation); }
public OrganisationVo deleteLocSite(LocSiteVo locSiteToDelete) throws ForeignKeyViolationException { if(locSiteToDelete == null) throw new RuntimeException("Cannot delete null LocSiteVo"); DomainFactory factory = getDomainFactory(); LocSite doLocSite = LocSiteVoAssembler.extractLocSite(factory, locSiteToDelete); if(doLocSite==null) return null; Organisation doParentOrganisation = doLocSite.getParentOrganisation(); if (doParentOrganisation != null) doParentOrganisation.getLocationSites().remove(doLocSite); //WDEV-12000 else return null; factory.delete(doLocSite); return OrganisationVoAssembler.create(doParentOrganisation); }
/** * Move an existing organisation to a new location */ @SuppressWarnings("unchecked") public void moveOrganisation(ims.core.vo.OrganisationVo orgToMove, ims.core.vo.OrganisationVo currentParent, ims.core.vo.OrganisationVo destParent) throws StaleObjectException { DomainFactory factory = getDomainFactory(); Organisation doOrgToMove = OrganisationVoAssembler.extractOrganisation(factory, orgToMove); Organisation doOrgCurrentParent = OrganisationVoAssembler.extractOrganisation(factory, currentParent); Organisation doOrgDestParent = OrganisationVoAssembler.extractOrganisation(factory, destParent); if (doOrgCurrentParent != null) { doOrgToMove.setParentOrganisation(null); doOrgCurrentParent.getRelatedOrganisations().remove(doOrgToMove); } if (doOrgDestParent != null) { doOrgToMove.setParentOrganisation(doOrgDestParent); doOrgDestParent.getRelatedOrganisations().add(doOrgToMove); } doOrgToMove.setUpperNames(); factory.save(doOrgToMove); //WDEV-10574 REMOTE_LOC_CACHE.clear(); }
public void deleteOrganisation(OrganisationVo orgToDelete) throws ForeignKeyViolationException { DomainFactory factory = getDomainFactory(); Organisation doOrganisation = OrganisationVoAssembler.extractOrganisation(factory, orgToDelete); Organisation doParentOrg = doOrganisation.getParentOrganisation(); if (doParentOrg != null) { doParentOrg.getRelatedOrganisations().remove(doOrganisation); } // WDEV - 12551 - Display an appropriate message // when deleting fails try { factory.delete(doOrganisation); } catch (Exception ex) { throw new ForeignKeyViolationException("Organization is in use and can not be deleted."); } }
public OrganisationVo getOrg(OrganisationRefVo voOrgRef) { if(voOrgRef == null || voOrgRef.getID_Organisation() == null) { throw new DomainRuntimeException("Invalid record"); } DomainFactory factory = getDomainFactory(); Organisation domainObject = (Organisation)factory.getDomainObject(voOrgRef); return OrganisationVoAssembler.create(domainObject); }
public OrganisationVo saveOrg(OrganisationVo orgVo) throws StaleObjectException, UniqueKeyViolationException { if (!orgVo.isValidated()) throw new DomainRuntimeException("Org has not been validated"); DomainFactory factory = getDomainFactory(); Organisation doOrg = OrganisationVoAssembler.extractOrganisation(factory, orgVo); if (doOrg == null) throw new StaleObjectException(doOrg); doOrg.setUpperNames(); try { factory.save(doOrg); } catch (UnqViolationUncheckedException e) { String dupMessage = Keywords.checkDuplicateTaxonomy(factory, doOrg, "codeMappings", orgVo.getCodeMappings(), "getName"); if(dupMessage != null) throw new UniqueKeyViolationException(dupMessage); for (int i = 0; i < orgVo.getLocationSites().size(); i++) { LocSiteVo lsv = orgVo.getLocationSites().get(i); LocSite lsd = LocSiteVoAssembler.extractLocSite(factory, lsv); dupMessage = Keywords.checkDuplicateTaxonomy(factory, lsd, "codeMappings", lsv.getCodeMappings(), "getName"); if(dupMessage != null) throw new UniqueKeyViolationException(dupMessage); } throw new UniqueKeyViolationException("An Record with this name already exists, Please change", e); } return OrganisationVoAssembler.create(doOrg); }
public OrganisationVo getPractice(OrganisationRefVo practiceRef) { if(practiceRef == null || practiceRef.getID_Organisation() == null) { throw new DomainRuntimeException("Invalid record"); } DomainFactory factory = getDomainFactory(); Organisation domainObject = (Organisation)factory.getDomainObject(Organisation.class, practiceRef.getID_Organisation()); return OrganisationVoAssembler.create(domainObject); }
/** * List Organisations */ public ims.core.vo.OrganisationVoCollection listOrganisation(ims.core.vo.OrganisationVo organisation, Boolean excludeGPs, Boolean activeOnly) { List<?> orgs = listOrganisations(organisation, excludeGPs, activeOnly); //WDEV-20044 OrganisationVoCollection voCollOrgs = OrganisationVoAssembler.createOrganisationVoCollectionFromOrganisation(orgs); return voCollOrgs; }
public ims.core.vo.OrganisationVo saveOrganisation(ims.core.vo.OrganisationVo organisation) throws UniqueKeyViolationException, StaleObjectException { DomainFactory factory = getDomainFactory(); HashMap<?,?> map = new HashMap<Object, Object>(); Organisation doOrg = OrganisationVoAssembler.extractOrganisation(factory, organisation,map); if (!(organisation.getTypeIsNotNull() && organisation.getType().equals(OrganisationType.GPP))) { // uniqueness constraint removed form the database - must be implemented in code. if (checkOrganisationNameisUnique(organisation.getName(), organisation) != null) { throw new UniqueKeyViolationException("A record with the same name already exists, Please change"); } } try { doOrg.setUpperNames(); factory.save(doOrg); //WDEV-10574 REMOTE_LOC_CACHE.clear(); } catch (UnqViolationUncheckedException e) { String dupMessage = Keywords.checkDuplicateTaxonomy(factory, doOrg, "codeMappings", organisation.getCodeMappings(), "getName"); if(dupMessage != null) throw new UniqueKeyViolationException(dupMessage); //WDEV-12600 - Check if the child location don't contain duplicate mappings if (organisation.getRelatedOrganisationsIsNotNull()) { checkChildsForDuplicateTaxonoy(organisation.getRelatedOrganisations(), map, factory); } //WDEV-12600 - Check if the child location don't contain duplicate mappings if (organisation.getLocationSitesIsNotNull()) { checkChildsForDuplicateTaxonoy(organisation.getLocationSites(), map, factory); } throw new UniqueKeyViolationException("A record with the same details already exists, Please change", e); } return OrganisationVoAssembler.create(doOrg); }
public OrganisationVo getOrganisation(Integer id) { DomainFactory factory = getDomainFactory(); return OrganisationVoAssembler.create((Organisation) factory.getDomainObject(Organisation.class, id)); }
public OrganisationVo getOrganisationByTaxonomyType(String extId, TaxonomyType taxonomyType) { return OrganisationVoAssembler.create(getDomOrganisationByTaxonomyType(extId, taxonomyType)); }
public OrganisationVoCollection listPCTs(String value, Boolean activeOnly) { DomainFactory factory = getDomainFactory(); String hql = " from Organisation o "; ArrayList<String> markers = new ArrayList<String>(); ArrayList<Serializable> values = new ArrayList<Serializable>(); StringBuffer condStr = new StringBuffer(); String andStr = " "; List orgs = null; condStr.append(andStr + " o.type.id = " + OrganisationType.NHS_PCT.getID()); andStr = " and "; if (activeOnly != null && activeOnly.booleanValue()) { condStr.append(andStr + " o.isActive = :isActive"); markers.add("isActive"); values.add(activeOnly); andStr = " and "; } if (null!=value && value.length() > 0) { condStr.append(andStr); condStr.append(" o.upperName like :OrgName"); markers.add("OrgName"); values.add(value.toUpperCase() + "%"); andStr = " and "; } hql += " where "; hql += condStr.toString(); orgs = factory.find(hql, markers, values); OrganisationVoCollection voCollOrgs = OrganisationVoAssembler.createOrganisationVoCollectionFromOrganisation(orgs); voCollOrgs.sort(); return voCollOrgs; }
/** * list Practices by either Practice name or Partial Address */ public ims.core.vo.OrganisationVoCollection listPractices(ims.core.vo.OrganisationVo organisationFilter) { DomainFactory factory = getDomainFactory(); ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); String hql = " from Organisation org "; StringBuffer condStr = new StringBuffer(); String andStr = " "; condStr.append(andStr + " org.type = :orgType"); markers.add("orgType"); values.add(getDomLookup(OrganisationType.GPP)); if (organisationFilter.getName() != null && organisationFilter.getName().length() > 0) { condStr.append(" and upper(org.name) like :practiceName"); markers.add("practiceName"); values.add("%" + organisationFilter.getName().toUpperCase() + "%"); } else if (organisationFilter.getAddress() != null) { if (organisationFilter.getAddress().getLine1() != null && organisationFilter.getAddress().getLine1().length() > 0) { condStr.append(" and upper(org.address.line1) like :partialAddress"); condStr.append(" or upper(org.address.line2) like :partialAddress"); condStr.append(" or upper(org.address.line3) like :partialAddress"); condStr.append(" or upper(org.address.line4) like :partialAddress"); condStr.append(" or upper(org.address.line5) like :partialAddress"); markers.add("partialAddress"); values.add("%" + organisationFilter.getAddress().getLine1().toUpperCase() + "%"); } } hql += " where " + condStr.toString(); List orgs = factory.find(hql,markers,values); return OrganisationVoAssembler.createOrganisationVoCollectionFromOrganisation(orgs).sort(); }
public OrganisationVo saveOrg(OrganisationVo orgVo) throws StaleObjectException, UniqueKeyViolationException { if (!orgVo.isValidated()) throw new DomainRuntimeException("Org has not been validated"); DomainFactory factory = getDomainFactory(); Organisation doOrg = OrganisationVoAssembler.extractOrganisation(factory, orgVo); if (doOrg == null) throw new StaleObjectException(doOrg); doOrg.setUpperNames(); try { factory.save(doOrg); } catch (UnqViolationUncheckedException e) { String dupMessage = Keywords.checkDuplicateTaxonomy(factory, doOrg, "codeMappings", orgVo.getCodeMappings(), "getName"); if(dupMessage != null) throw new UniqueKeyViolationException(dupMessage); for (int i = 0; i < orgVo.getLocationSites().size(); i++) { LocSiteVo lsv = orgVo.getLocationSites().get(i); LocSite lsd = LocSiteVoAssembler.extractLocSite(factory, lsv); dupMessage = Keywords.checkDuplicateTaxonomy(factory, lsd, "codeMappings", lsv.getCodeMappings(), "getName"); if(dupMessage != null) throw new UniqueKeyViolationException(dupMessage); } throw new UniqueKeyViolationException("An Record with this name already exists, Please change", e); } //WDEV-19576 Practice Master File HL7 message OrganisationVo assembledOrg = OrganisationVoAssembler.create(doOrg); triggerGPPracticeMasterFileEvent(assembledOrg); return assembledOrg; }