001package org.hl7.fhir.convertors.conv10_40.resources10_40;
002
003import org.hl7.fhir.convertors.context.ConversionContext10_40;
004import org.hl7.fhir.convertors.conv10_40.datatypes10_40.Reference10_40;
005import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.Address10_40;
006import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.CodeableConcept10_40;
007import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.ContactPoint10_40;
008import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.HumanName10_40;
009import org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40.Identifier10_40;
010import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.Boolean10_40;
011import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.String10_40;
012import org.hl7.fhir.exceptions.FHIRException;
013
014public class Organization10_40 {
015
016  public static org.hl7.fhir.r4.model.Organization convertOrganization(org.hl7.fhir.dstu2.model.Organization src) throws FHIRException {
017    if (src == null || src.isEmpty())
018      return null;
019    org.hl7.fhir.r4.model.Organization tgt = new org.hl7.fhir.r4.model.Organization();
020    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt);
021    for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier())
022      tgt.addIdentifier(Identifier10_40.convertIdentifier(t));
023    if (src.hasActiveElement())
024      tgt.setActiveElement(Boolean10_40.convertBoolean(src.getActiveElement()));
025    if (src.hasType())
026      tgt.addType(CodeableConcept10_40.convertCodeableConcept(src.getType()));
027    if (src.hasNameElement())
028      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
029    for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom())
030      tgt.addTelecom(ContactPoint10_40.convertContactPoint(t));
031    for (org.hl7.fhir.dstu2.model.Address t : src.getAddress()) tgt.addAddress(Address10_40.convertAddress(t));
032    if (src.hasPartOf())
033      tgt.setPartOf(Reference10_40.convertReference(src.getPartOf()));
034    for (org.hl7.fhir.dstu2.model.Organization.OrganizationContactComponent t : src.getContact())
035      tgt.addContact(convertOrganizationContactComponent(t));
036    return tgt;
037  }
038
039  public static org.hl7.fhir.dstu2.model.Organization convertOrganization(org.hl7.fhir.r4.model.Organization src) throws FHIRException {
040    if (src == null || src.isEmpty())
041      return null;
042    org.hl7.fhir.dstu2.model.Organization tgt = new org.hl7.fhir.dstu2.model.Organization();
043    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyDomainResource(src, tgt);
044    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
045      tgt.addIdentifier(Identifier10_40.convertIdentifier(t));
046    if (src.hasActiveElement())
047      tgt.setActiveElement(Boolean10_40.convertBoolean(src.getActiveElement()));
048    if (src.hasType())
049      tgt.setType(CodeableConcept10_40.convertCodeableConcept(src.getTypeFirstRep()));
050    if (src.hasNameElement())
051      tgt.setNameElement(String10_40.convertString(src.getNameElement()));
052    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
053      tgt.addTelecom(ContactPoint10_40.convertContactPoint(t));
054    for (org.hl7.fhir.r4.model.Address t : src.getAddress()) tgt.addAddress(Address10_40.convertAddress(t));
055    if (src.hasPartOf())
056      tgt.setPartOf(Reference10_40.convertReference(src.getPartOf()));
057    for (org.hl7.fhir.r4.model.Organization.OrganizationContactComponent t : src.getContact())
058      tgt.addContact(convertOrganizationContactComponent(t));
059    return tgt;
060  }
061
062  public static org.hl7.fhir.dstu2.model.Organization.OrganizationContactComponent convertOrganizationContactComponent(org.hl7.fhir.r4.model.Organization.OrganizationContactComponent src) throws FHIRException {
063    if (src == null || src.isEmpty())
064      return null;
065    org.hl7.fhir.dstu2.model.Organization.OrganizationContactComponent tgt = new org.hl7.fhir.dstu2.model.Organization.OrganizationContactComponent();
066    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
067    if (src.hasPurpose())
068      tgt.setPurpose(CodeableConcept10_40.convertCodeableConcept(src.getPurpose()));
069    if (src.hasName())
070      tgt.setName(HumanName10_40.convertHumanName(src.getName()));
071    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom())
072      tgt.addTelecom(ContactPoint10_40.convertContactPoint(t));
073    if (src.hasAddress())
074      tgt.setAddress(Address10_40.convertAddress(src.getAddress()));
075    return tgt;
076  }
077
078  public static org.hl7.fhir.r4.model.Organization.OrganizationContactComponent convertOrganizationContactComponent(org.hl7.fhir.dstu2.model.Organization.OrganizationContactComponent src) throws FHIRException {
079    if (src == null || src.isEmpty())
080      return null;
081    org.hl7.fhir.r4.model.Organization.OrganizationContactComponent tgt = new org.hl7.fhir.r4.model.Organization.OrganizationContactComponent();
082    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyBackboneElement(src,tgt);
083    if (src.hasPurpose())
084      tgt.setPurpose(CodeableConcept10_40.convertCodeableConcept(src.getPurpose()));
085    if (src.hasName())
086      tgt.setName(HumanName10_40.convertHumanName(src.getName()));
087    for (org.hl7.fhir.dstu2.model.ContactPoint t : src.getTelecom())
088      tgt.addTelecom(ContactPoint10_40.convertContactPoint(t));
089    if (src.hasAddress())
090      tgt.setAddress(Address10_40.convertAddress(src.getAddress()));
091    return tgt;
092  }
093}