Exemplo n.º 1
0
 /**
  * Assumes a UID must be unique as this is only looking for a listOfSubjects PRE FILTERED based on
  * a studies list of subjects to be changed
  */
 public LinkSubjectStudy getSubjectByUIDFromExistList(
     List<LinkSubjectStudy> listOfSubjects, String subjectUID) {
   for (LinkSubjectStudy potentialSubject : listOfSubjects) {
     if (potentialSubject.getSubjectUID().equals(subjectUID)) {
       return potentialSubject;
     }
   }
   return null;
 }
Exemplo n.º 2
0
  /*
   * (non-Javadoc)
   *
   * @see au.org.theark.core.web.form.AbstractDetailForm#onSave(org.apache.wicket.markup.html.form.Form, org.apache.wicket.ajax.AjaxRequestTarget)
   */
  @Override
  protected void onSave(Form<ContactVO> containerForm, AjaxRequestTarget target) {
    // Persist the phone number to the backend, associate the person in context with the phone
    // object
    Long personSessionId =
        (Long)
            SecurityUtils.getSubject()
                .getSession()
                .getAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID);
    // Get the person and set it on the Phone object.
    try {
      boolean saveOk = true;
      Person person = studyService.getPerson(personSessionId);
      containerForm.getModelObject().getPhoneVo().getPhone().setPerson(person);

      /*
      // Make the area code mandatory only for landline phone (home/work) entries
      String phType = containerForm.getModelObject().getPhone().getPhoneType().getName().toLowerCase();

      if (!phType.equals("mobile")) {
      	// must be landline
      	if (containerForm.getModelObject().getPhone().getAreaCode() == null || containerForm.getModelObject().getPhone().getAreaCode().length() < 1) {
      		this.error("An area code must be entered for landline numbers");
      		saveOk = false;
      	}
      }
      */
      if (saveOk) {
        // Ok to save...
        String personType =
            (String)
                SecurityUtils.getSubject()
                    .getSession()
                    .getAttribute(au.org.theark.core.Constants.PERSON_TYPE);

        if (personType != null
            && personType.equalsIgnoreCase(
                au.org.theark.core.Constants.PERSON_CONTEXT_TYPE_SUBJECT)) {
          Long studyId =
              (Long)
                  SecurityUtils.getSubject()
                      .getSession()
                      .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID);
          Study study = iArkCommonService.getStudy(studyId);
          LinkSubjectStudy subjectInContext =
              iArkCommonService.getSubject(
                  personSessionId, study); // This is fetched basically to display the
          // info
          // message along with the Subject UID or Contact ID
          if (containerForm.getModelObject().getPhoneVo().getPhone().getId() == null) {
            studyService.create(containerForm.getModelObject().getPhoneVo().getPhone());
            this.info(
                "Phone number was added and linked to Subject UID: "
                    + subjectInContext.getSubjectUID());
          } else {
            studyService.update(containerForm.getModelObject().getPhoneVo().getPhone());
            this.info(
                "Phone number was updated and linked to Subject UID: "
                    + subjectInContext.getSubjectUID());
          }
        } else if (personType != null
            && personType.equalsIgnoreCase(
                au.org.theark.core.Constants.PERSON_CONTEXT_TYPE_CONTACT)) {
          // TODO: Contact Interface implementation
        }

        processErrors(target);
        onSavePostProcess(target);
      } else {

        processErrors(target);
      }
    } catch (ArkUniqueException aue) {
      this.error(aue.getMessage());
    } catch (EntityNotFoundException e) {
      this.error("The Subject/Participant is not available in the system anymore");
    } catch (ArkSystemException e) {
      this.error("A System Exception has occured please contact Support.");
    }
  }
Exemplo n.º 3
0
  public VelocityContext getBioCollectionLabelContext(BioCollection bioCollection) {
    VelocityContext velocityContext = new VelocityContext();
    LinkSubjectStudy linkSubjectStudy = null;
    try {
      linkSubjectStudy =
          iArkCommonService.getSubjectByUID(
              bioCollection.getLinkSubjectStudy().getSubjectUID(), bioCollection.getStudy());
    } catch (EntityNotFoundException e) {
      log.error(e.getMessage());
    }

    try {
      bioCollection = iBioCollectionDao.getBioCollection(bioCollection.getId());
    } catch (EntityNotFoundException e) {
      log.error(e.getMessage());
    }

    String subjectUid = linkSubjectStudy.getSubjectUID();

    // ArkFunction arkFunction =
    // iArkCommonService.getArkFunctionByName(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_LIMS_COLLECTION);
    ArkFunction arkFunction =
        iArkCommonService.getArkFunctionByName(
            au.org.theark.core.Constants.FUNCTION_KEY_VALUE_LIMS_CUSTOM_FIELD);

    // Custom field name "FAMILYID"
    BioCollectionCustomFieldData bioCollectionCustomFieldData =
        iBioCollectionDao.getBioCollectionCustomFieldData(bioCollection, arkFunction, "FAMILYID");
    String familyId = bioCollectionCustomFieldData.getTextDataValue();

    // Custom field name "ASRBNO"
    bioCollectionCustomFieldData =
        iBioCollectionDao.getBioCollectionCustomFieldData(bioCollection, arkFunction, "ASRBNO");
    String asrbno = bioCollectionCustomFieldData.getTextDataValue();

    String collectionDate = new String();
    if (bioCollection.getCollectionDate() != null) {
      collectionDate = simpleDateFormat.format(bioCollection.getCollectionDate());
    }
    String refDoctor = new String();
    if (bioCollection.getRefDoctor() != null) {
      refDoctor = bioCollection.getRefDoctor();
    }
    String dateOfBirth = new String();
    if (bioCollection.getLinkSubjectStudy().getPerson().getDateOfBirth() != null) {
      dateOfBirth =
          simpleDateFormat.format(bioCollection.getLinkSubjectStudy().getPerson().getDateOfBirth());
    }
    String sex = new String();
    if (bioCollection.getLinkSubjectStudy().getPerson().getGenderType() != null) {
      sex = bioCollection.getLinkSubjectStudy().getPerson().getGenderType().getName();
    }
    String collectionID = bioCollection.getBiocollectionUid();
    String subjectFirstName = linkSubjectStudy.getPerson().getFirstName();
    String subjectLastName = linkSubjectStudy.getPerson().getLastName();
    String initials = subjectFirstName.charAt(0) + "" + subjectLastName.charAt(0);

    velocityContext.put("initials", initials);
    velocityContext.put("firstName", subjectFirstName);
    velocityContext.put("lastName", subjectLastName);
    velocityContext.put("collectionID", collectionID);
    velocityContext.put("subjectUid", subjectUid);
    velocityContext.put("familyId", familyId);
    velocityContext.put("asrbno", asrbno);
    velocityContext.put("collectionDate", collectionDate);
    velocityContext.put("refDoctor", refDoctor);
    velocityContext.put("dateOfBirth", dateOfBirth);
    velocityContext.put("sex", sex);

    return velocityContext;
  }