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