@Override public SpecimenRequirement createSpecimenRequirement(SpecimenRequirementDetail detail) { SpecimenRequirement requirement = new SpecimenRequirement(); OpenSpecimenException ose = new OpenSpecimenException(ErrorType.USER_ERROR); requirement.setId(detail.getId()); requirement.setName(detail.getName()); requirement.setLineage(Specimen.NEW); setCode(detail, requirement, ose); setLabelFormat(detail, requirement, ose); setLabelAutoPrintMode(detail, requirement, ose); setSpecimenClass(detail, requirement, ose); setSpecimenType(detail, requirement, ose); setAnatomicSite(detail, requirement, ose); setLaterality(detail, requirement, ose); setPathologyStatus(detail, requirement, ose); setStorageType(detail, requirement, ose); setInitialQty(detail, requirement, ose); setConcentration(detail, requirement, ose); setCollector(detail, requirement, ose); setCollectionProcedure(detail, requirement, ose); setCollectionContainer(detail, requirement, ose); setReceiver(detail, requirement, ose); setCpe(detail, requirement, ose); requirement.setSortOrder(detail.getSortOrder()); requirement.setActivityStatus(Status.ACTIVITY_STATUS_ACTIVE.getStatus()); ose.checkAndThrow(); setSpecimenPoolReqs(detail, requirement, ose); return requirement; }
@Override public SpecimenRequirement createDerived(DerivedSpecimenRequirement req) { OpenSpecimenException ose = new OpenSpecimenException(ErrorType.USER_ERROR); Long parentId = req.getParentSrId(); if (parentId == null) { ose.addError(PARENT_REQ_REQUIRED); throw ose; } SpecimenRequirement parent = daoFactory.getSpecimenRequirementDao().getById(parentId); if (parent == null) { ose.addError(SrErrorCode.PARENT_NOT_FOUND); throw ose; } SpecimenRequirement derived = parent.copy(); derived.setLabelFormat(null); derived.setLineage(Specimen.DERIVED); setSpecimenClass(req.getSpecimenClass(), derived, ose); setSpecimenType(req.getSpecimenClass(), req.getType(), derived, ose); setInitialQty(req.getQuantity(), derived, ose); setStorageType(req.getStorageType(), derived, ose); setConcentration(req.getConcentration(), derived, ose); setPathologyStatus(req.getPathology(), derived, ose); setLabelFormat(req.getLabelFmt(), derived, ose); setLabelAutoPrintMode(req.getLabelAutoPrintMode(), derived, ose); setCode(req.getCode(), derived, ose); derived.setName(req.getName()); ose.checkAndThrow(); derived.setParentSpecimenRequirement(parent); return derived; }
@Override public SpecimenRequirement createForUpdate(String lineage, SpecimenRequirementDetail req) { SpecimenRequirement sr = new SpecimenRequirement(); OpenSpecimenException ose = new OpenSpecimenException(ErrorType.USER_ERROR); sr.setName(req.getName()); sr.setSortOrder(req.getSortOrder()); // // Specimen class and type are set here so that properties dependent on these can // be calculated and set appropriately. // setSpecimenClass(req, sr, ose); setSpecimenType(req, sr, ose); setInitialQty(req, sr, ose); setStorageType(req, sr, ose); setLabelFormat(req, sr, ose); setLabelAutoPrintMode(req, sr, ose); setCode(req, sr, ose); setConcentration(req, sr, ose); if (!lineage.equals(Specimen.ALIQUOT)) { setPathologyStatus(req, sr, ose); } if (!lineage.equals(Specimen.NEW)) { return sr; } setAnatomicSite(req, sr, ose); setLaterality(req, sr, ose); setCollector(req, sr, ose); setCollectionProcedure(req, sr, ose); setCollectionContainer(req, sr, ose); setReceiver(req, sr, ose); ose.checkAndThrow(); return sr; }