public MemberOfStaffVo saveMosVo(MemberOfStaffVo voMos) throws StaleObjectException, DomainInterfaceException, UniqueKeyViolationException { if (!voMos.isValidated()) throw new DomainRuntimeException("Member of staff has not been validated"); DomainFactory factory = getDomainFactory(); Hcp doHcp = null; voMos.getName().setUppers(); if (voMos.getHcpIsNotNull()) { //Ensure the HCP is pointing back to the same MOS, ie the 1-1 bidirectional must be correct. voMos.getHcp().setMos(voMos); //WDEV-3653 added checks for getHcpTypeIsNotNull if (voMos.getHcp().getHcpTypeIsNotNull()&&voMos.getHcp().getHcpType().equals(HcpDisType.MEDICAL)) doHcp = MedicVoAssembler.extractMedic(factory, (MedicVo) voMos.getHcp()); else if (voMos.getHcp().getHcpTypeIsNotNull()&&voMos.getHcp().getHcpType().equals(HcpDisType.NURSING)) doHcp = NurseVoAssembler.extractNurse(factory, (NurseVo) voMos.getHcp()); else if (voMos.getHcp().getHcpTypeIsNotNull()&&voMos.getHcp().getHcpType().equals(HcpDisType.THERAPY)) doHcp = TherapistVoAssembler.extractTherapist(factory, (TherapistVo) voMos.getHcp()); else doHcp = HcpAssembler.extractHcp(factory, voMos.getHcp()); //If we're adding a new MemberOfStaff, but the Associated hcp already exists if (null == voMos.getID_MemberOfStaff() && doHcp.getId() != null) { throw new DomainInterfaceException("Hcp is already associated with another Member Of Staff"); } if (null == doHcp.isIsActive() && doHcp.isIsActive() == null) // wdev-3819 doHcp.setIsActive(Boolean.TRUE); } if (null == voMos.getID_MemberOfStaff() && !voMos.getIsActiveIsNotNull()) // wdev-3819 voMos.setIsActive(Boolean.TRUE); MemberOfStaff domMemberOfStaff = MemberOfStaffVoAssembler.extractMemberOfStaff(factory, voMos); domMemberOfStaff.setHcp(doHcp); domMemberOfStaff.getCodeMappings().clear(); List mappings = TaxonomyMapAssembler.extractTaxonomyMapList(factory, voMos.getCodeMappings()); domMemberOfStaff.setCodeMappings(mappings); domMemberOfStaff.getCommChannels().clear(); List commChannels = CommChannelVoAssembler.extractCommunicationChannelList(factory,voMos.getCommChannels()); domMemberOfStaff.setCommChannels(commChannels); try { //clearMosTaxonomyMaps(voMos,factory); factory.save(domMemberOfStaff); } catch (UnqViolationUncheckedException e) { String dupMessage = Keywords.checkDuplicateTaxonomy(factory, domMemberOfStaff, "codeMappings", voMos.getCodeMappings(), "getName"); if(dupMessage != null) throw new UniqueKeyViolationException(dupMessage); throw(e); } /*catch (ForeignKeyViolationException e) { // TODO Auto-generated catch block e.printStackTrace(); }*/ //JME: 20060814 : WDEV-1231 this.clearMosAndHcp(); return MemberOfStaffVoAssembler.create(domMemberOfStaff); }
public MemberOfStaffVo saveMosVo(MemberOfStaffVo voMos) throws StaleObjectException, DomainInterfaceException, UniqueKeyViolationException { if (!voMos.isValidated()) throw new DomainRuntimeException("Member of staff has not been validated"); DomainFactory factory = getDomainFactory(); Hcp doHcp = null; voMos.getName().setUppers(); if (voMos.getHcpIsNotNull()) { //Ensure the HCP is pointing back to the same MOS, ie the 1-1 bidirectional must be correct. voMos.getHcp().setMos(voMos); //WDEV-3653 added checks for getHcpTypeIsNotNull if (voMos.getHcp().getHcpTypeIsNotNull()&&voMos.getHcp().getHcpType().equals(HcpDisType.MEDICAL)) doHcp = MedicVoAssembler.extractMedic(factory, (MedicVo) voMos.getHcp()); else if (voMos.getHcp().getHcpTypeIsNotNull()&&voMos.getHcp().getHcpType().equals(HcpDisType.NURSING)) doHcp = NurseVoAssembler.extractNurse(factory, (NurseVo) voMos.getHcp()); else if (voMos.getHcp().getHcpTypeIsNotNull()&&voMos.getHcp().getHcpType().equals(HcpDisType.THERAPY)) doHcp = TherapistVoAssembler.extractTherapist(factory, (TherapistVo) voMos.getHcp()); else doHcp = HcpAssembler.extractHcp(factory, voMos.getHcp()); //If we're adding a new MemberOfStaff, but the Associated hcp already exists if (null == voMos.getID_MemberOfStaff() && doHcp.getId() != null) { throw new DomainInterfaceException("Hcp is already associated with another Member Of Staff"); } if (null == doHcp.isIsActive() && doHcp.isIsActive() == null) // wdev-3819 doHcp.setIsActive(Boolean.TRUE); } if (null == voMos.getID_MemberOfStaff() && !voMos.getIsActiveIsNotNull()) // wdev-3819 voMos.setIsActive(Boolean.TRUE); MemberOfStaff domMemberOfStaff = MemberOfStaffVoAssembler.extractMemberOfStaff(factory, voMos); domMemberOfStaff.setHcp(doHcp); domMemberOfStaff.getCodeMappings().clear(); List mappings = TaxonomyMapAssembler.extractTaxonomyMapList(factory, voMos.getCodeMappings()); domMemberOfStaff.setCodeMappings(mappings); domMemberOfStaff.getCommChannels().clear(); List commChannels = CommChannelVoAssembler.extractCommunicationChannelList(factory,voMos.getCommChannels()); domMemberOfStaff.setCommChannels(commChannels); try { //clearMosTaxonomyMaps(voMos,factory); factory.save(domMemberOfStaff); } catch (UnqViolationUncheckedException e) { String dupMessage = Keywords.checkDuplicateTaxonomy(factory, domMemberOfStaff, "codeMappings", voMos.getCodeMappings(), "getName"); if(dupMessage != null) throw new UniqueKeyViolationException(dupMessage); throw(e); } /*catch (ForeignKeyViolationException e) { // TODO Auto-generated catch block e.printStackTrace(); }*/ //JME: 20060814 : WDEV-1231 this.clearMosAndHcp(); //WDEV-19576 MOS Master File HL7 message MemberOfStaffVo assembledMos = MemberOfStaffVoAssembler.create(domMemberOfStaff); triggerMOSMasterFileEvent(assembledMos); return assembledMos; }