public static org.opencds.vmr.v1_0.schema.BodySite pushOut(BodySite source) {
    if (source == null) return null;
    org.opencds.vmr.v1_0.schema.BodySite target = new org.opencds.vmr.v1_0.schema.BodySite();
    if (source.getBodySiteCode() != null)
      target.setBodySiteCode(MappingUtility.cDInternal2CD(source.getBodySiteCode()));
    if (source.getLaterality() != null)
      target.setLaterality(MappingUtility.cDInternal2CD(source.getLaterality()));

    return target;
  }
  /**
   * Populate internal vMR object from corresponding external vMR object
   *
   * @param source external vMR object
   * @param mu MappingUtility instance
   * @return populated internal vMR structure; null if provided source parameter is null
   */
  public static BodySite pullIn(org.opencds.vmr.v1_0.schema.BodySite source, MappingUtility mu) {

    if (source == null) return null;

    BodySite target = new BodySite();
    if (source.getBodySiteCode() != null)
      target.setBodySiteCode(MappingUtility.cD2CDInternal(source.getBodySiteCode()));
    if (source.getLaterality() != null)
      target.setLaterality(MappingUtility.cD2CDInternal(source.getLaterality()));

    return target;
  }
  /**
   * @param source
   * @param target
   * @param subjectPersonId
   * @param focalPersonId
   * @param factLists
   * @throws ImproperUsageException
   * @throws DataFormatException
   * @throws InvalidDataException
   */
  public static void pullIn(
      org.opencds.vmr.v1_0.schema.ScheduledProcedure source,
      ScheduledProcedure target,
      String subjectPersonId,
      String focalPersonId,
      FactLists factLists)
      throws ImproperUsageException, DataFormatException, InvalidDataException {

    String _METHODNAME = "pullIn(): ";

    if (source == null) {
      return;
    }

    try {
      ProcedureBaseMapper.pullIn(source, target, subjectPersonId, focalPersonId, factLists);
    } catch (ImproperUsageException u) {
      String errStr = _METHODNAME + "Caught unexpected ImproperUsageException: " + u.getMessage();
      logger.error(errStr, u);
      throw new RuntimeException(errStr);
    }

    if (source.getProcedureTime() != null)
      target.setProcedureTime(MappingUtility.iVLTS2IVLDateInternal(source.getProcedureTime()));

    factLists.internalScheduledProcedureList.add(target);

    // pull in nested RelatedEntities and RelatedClinicalStatements
    NestedObjectsMapper.pullInClinicalStatementNestedObjects(
        source, target.getId(), subjectPersonId, focalPersonId, factLists);

    return;
  }
  /**
   * Populate external vMR object from corresponding internal vMR object; if supplied source
   * parameter is null, simply returns
   *
   * @param source
   * @param target
   * @param organizedResults
   * @return
   * @throws ImproperUsageException
   * @throws DataFormatException
   * @throws InvalidDataException
   */
  public static org.opencds.vmr.v1_0.schema.ScheduledProcedure pushOut(
      ScheduledProcedure source,
      org.opencds.vmr.v1_0.schema.ScheduledProcedure target,
      OrganizedResults organizedResults)
      throws ImproperUsageException, DataFormatException, InvalidDataException {

    String _METHODNAME = "pushOut(): ";

    if (source == null) return null;

    target = new org.opencds.vmr.v1_0.schema.ScheduledProcedure();

    try {
      ProcedureBaseMapper.pushOut(source, target);
    } catch (ImproperUsageException u) {
      String errStr = _METHODNAME + "Caught unexpected ImproperUsageException: " + u.getMessage();
      logger.error(errStr, u);
      throw new RuntimeException(errStr);
    }

    if (source.getProcedureTime() != null)
      target.setProcedureTime(MappingUtility.iVLDateInternal2IVLTS(source.getProcedureTime()));

    // look for and add any nested RelatedClinicalStatements and nested RelatedEntities
    target =
        NestedObjectsMapper.pushOutClinicalStatementNestedObjects(source, target, organizedResults);

    if (organizedResults.getOutput().getScheduledProcedures() == null) {
      organizedResults
          .getOutput()
          .setScheduledProcedures(
              new org.opencds.vmr.v1_0.schema.EvaluatedPerson.ClinicalStatements
                  .ScheduledProcedures());
    }

    return target;
  }