示例#1
0
  /**
   * @notice In Fhir model, {@link Patient} has a collection of names, while in this extension
   *     table, {@link PersonComplement}, there is only one name for each {@link Person}.
   */
  @Override
  public IResourceEntity constructEntityFromResource(IResource resource) {
    super.constructEntityFromResource(resource);
    if (resource instanceof Patient) {
      Patient patient = (Patient) resource;

      Iterator<HumanNameDt> iterator = patient.getName().iterator();
      // while(iterator.hasNext()){
      if (iterator.hasNext()) {
        HumanNameDt next = iterator.next();
        this.givenName1 =
            next.getGiven()
                .get(0)
                .getValue(); // the next method was not advancing to the next element, then the need
        // to use the get(index) method
        if (next.getGiven().size()
            > 1) // TODO add unit tests, to assure this won't be changed to hasNext
        this.givenName2 = next.getGiven().get(1).getValue();
        Iterator<StringDt> family = next.getFamily().iterator();
        this.familyName = "";
        while (family.hasNext()) {
          this.familyName = this.familyName.concat(family.next().getValue() + " ");
        }
        if (next.getSuffix().iterator().hasNext())
          this.suffixName = next.getSuffix().iterator().next().getValue();
        if (next.getPrefix().iterator().hasNext())
          this.prefixName = next.getPrefix().iterator().next().getValue();
      }
      // }

      this.active = patient.getActive();
      // MARITAL STATUS
      //
      //	this.maritalStatus.setId(OmopConceptMapping.getInstance().get(OmopConceptMapping.MARITAL_STATUS, patient.getMaritalStatus().getText()));
    } else {
      ourLog.error(
          "There was not possible to construct the entity ? using the resource ?. It should be used the resource ?.",
          this.getClass().getSimpleName(),
          resource.getResourceName(),
          getResourceType());
    }
    return this;
  }
 private String getConditionalUrl(IResource resource, IdentifierDt identifier) {
   return resource.getResourceName()
       + "?identifier=".concat(identifier.getSystem()).concat("%7C").concat(identifier.getValue());
 }