001package org.hl7.fhir.convertors.conv40_50.resources40_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext40_50;
004import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.*;
005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Boolean40_50;
006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Date40_50;
007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50;
008import org.hl7.fhir.exceptions.FHIRException;
009
010/*
011  Copyright (c) 2011+, HL7, Inc.
012  All rights reserved.
013  
014  Redistribution and use in source and binary forms, with or without modification, 
015  are permitted provided that the following conditions are met:
016  
017   * Redistributions of source code must retain the above copyright notice, this 
018     list of conditions and the following disclaimer.
019   * Redistributions in binary form must reproduce the above copyright notice, 
020     this list of conditions and the following disclaimer in the documentation 
021     and/or other materials provided with the distribution.
022   * Neither the name of HL7 nor the names of its contributors may be used to 
023     endorse or promote products derived from this software without specific 
024     prior written permission.
025  
026  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
027  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
028  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
029  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
030  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
031  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
032  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
033  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
034  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
035  POSSIBILITY OF SUCH DAMAGE.
036  
037*/
038// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
039public class RelatedPerson40_50 {
040
041  public static org.hl7.fhir.r5.model.RelatedPerson convertRelatedPerson(org.hl7.fhir.r4.model.RelatedPerson src) throws FHIRException {
042    if (src == null)
043      return null;
044    org.hl7.fhir.r5.model.RelatedPerson tgt = new org.hl7.fhir.r5.model.RelatedPerson();
045    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
046    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
047      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
048    if (src.hasActive())
049      tgt.setActiveElement(Boolean40_50.convertBoolean(src.getActiveElement()));
050    if (src.hasPatient())
051      tgt.setPatient(Reference40_50.convertReference(src.getPatient()));
052    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRelationship())
053      tgt.addRelationship(CodeableConcept40_50.convertCodeableConcept(t));
054    for (org.hl7.fhir.r4.model.HumanName t : src.getName()) tgt.addName(HumanName40_50.convertHumanName(t));
055    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
056      tgt.addTelecom(ContactPoint40_50.convertContactPoint(t));
057    if (src.hasGender())
058      tgt.setGenderElement(Enumerations40_50.convertAdministrativeGender(src.getGenderElement()));
059    if (src.hasBirthDate())
060      tgt.setBirthDateElement(Date40_50.convertDate(src.getBirthDateElement()));
061    for (org.hl7.fhir.r4.model.Address t : src.getAddress()) tgt.addAddress(Address40_50.convertAddress(t));
062    for (org.hl7.fhir.r4.model.Attachment t : src.getPhoto()) tgt.addPhoto(Attachment40_50.convertAttachment(t));
063    if (src.hasPeriod())
064      tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod()));
065    for (org.hl7.fhir.r4.model.RelatedPerson.RelatedPersonCommunicationComponent t : src.getCommunication())
066      tgt.addCommunication(convertRelatedPersonCommunicationComponent(t));
067    return tgt;
068  }
069
070  public static org.hl7.fhir.r4.model.RelatedPerson convertRelatedPerson(org.hl7.fhir.r5.model.RelatedPerson src) throws FHIRException {
071    if (src == null)
072      return null;
073    org.hl7.fhir.r4.model.RelatedPerson tgt = new org.hl7.fhir.r4.model.RelatedPerson();
074    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
075    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
076      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
077    if (src.hasActive())
078      tgt.setActiveElement(Boolean40_50.convertBoolean(src.getActiveElement()));
079    if (src.hasPatient())
080      tgt.setPatient(Reference40_50.convertReference(src.getPatient()));
081    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getRelationship())
082      tgt.addRelationship(CodeableConcept40_50.convertCodeableConcept(t));
083    for (org.hl7.fhir.r5.model.HumanName t : src.getName()) tgt.addName(HumanName40_50.convertHumanName(t));
084    for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom())
085      tgt.addTelecom(ContactPoint40_50.convertContactPoint(t));
086    if (src.hasGender())
087      tgt.setGenderElement(Enumerations40_50.convertAdministrativeGender(src.getGenderElement()));
088    if (src.hasBirthDate())
089      tgt.setBirthDateElement(Date40_50.convertDate(src.getBirthDateElement()));
090    for (org.hl7.fhir.r5.model.Address t : src.getAddress()) tgt.addAddress(Address40_50.convertAddress(t));
091    for (org.hl7.fhir.r5.model.Attachment t : src.getPhoto()) tgt.addPhoto(Attachment40_50.convertAttachment(t));
092    if (src.hasPeriod())
093      tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod()));
094    for (org.hl7.fhir.r5.model.RelatedPerson.RelatedPersonCommunicationComponent t : src.getCommunication())
095      tgt.addCommunication(convertRelatedPersonCommunicationComponent(t));
096    return tgt;
097  }
098
099  public static org.hl7.fhir.r5.model.RelatedPerson.RelatedPersonCommunicationComponent convertRelatedPersonCommunicationComponent(org.hl7.fhir.r4.model.RelatedPerson.RelatedPersonCommunicationComponent src) throws FHIRException {
100    if (src == null)
101      return null;
102    org.hl7.fhir.r5.model.RelatedPerson.RelatedPersonCommunicationComponent tgt = new org.hl7.fhir.r5.model.RelatedPerson.RelatedPersonCommunicationComponent();
103    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
104    if (src.hasLanguage())
105      tgt.setLanguage(CodeableConcept40_50.convertCodeableConcept(src.getLanguage()));
106    if (src.hasPreferred())
107      tgt.setPreferredElement(Boolean40_50.convertBoolean(src.getPreferredElement()));
108    return tgt;
109  }
110
111  public static org.hl7.fhir.r4.model.RelatedPerson.RelatedPersonCommunicationComponent convertRelatedPersonCommunicationComponent(org.hl7.fhir.r5.model.RelatedPerson.RelatedPersonCommunicationComponent src) throws FHIRException {
112    if (src == null)
113      return null;
114    org.hl7.fhir.r4.model.RelatedPerson.RelatedPersonCommunicationComponent tgt = new org.hl7.fhir.r4.model.RelatedPerson.RelatedPersonCommunicationComponent();
115    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
116    if (src.hasLanguage())
117      tgt.setLanguage(CodeableConcept40_50.convertCodeableConcept(src.getLanguage()));
118    if (src.hasPreferred())
119      tgt.setPreferredElement(Boolean40_50.convertBoolean(src.getPreferredElement()));
120    return tgt;
121  }
122}