001package org.hl7.fhir.convertors.conv30_50.resources30_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_50;
004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.*;
005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Attachment30_50;
006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50;
007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50;
008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Period30_50;
009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.*;
010import org.hl7.fhir.dstu3.model.ContactDetail;
011import org.hl7.fhir.dstu3.model.Contributor.ContributorType;
012import org.hl7.fhir.exceptions.FHIRException;
013
014public class Library30_50 {
015
016  public static org.hl7.fhir.dstu3.model.Library convertLibrary(org.hl7.fhir.r5.model.Library src) throws FHIRException {
017    if (src == null)
018      return null;
019    org.hl7.fhir.dstu3.model.Library tgt = new org.hl7.fhir.dstu3.model.Library();
020    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
021    if (src.hasUrl())
022      tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
023    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
024      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
025    if (src.hasVersion())
026      tgt.setVersionElement(String30_50.convertString(src.getVersionElement()));
027    if (src.hasName())
028      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
029    if (src.hasTitle())
030      tgt.setTitleElement(String30_50.convertString(src.getTitleElement()));
031    if (src.hasStatus())
032      tgt.setStatusElement(Enumerations30_50.convertPublicationStatus(src.getStatusElement()));
033    if (src.hasExperimental())
034      tgt.setExperimentalElement(Boolean30_50.convertBoolean(src.getExperimentalElement()));
035    if (src.hasType())
036      tgt.setType(CodeableConcept30_50.convertCodeableConcept(src.getType()));
037    if (src.hasDate())
038      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
039    if (src.hasPublisher())
040      tgt.setPublisherElement(String30_50.convertString(src.getPublisherElement()));
041    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
042      tgt.addContact(ContactDetail30_50.convertContactDetail(t));
043    if (src.hasDescription())
044      tgt.setDescriptionElement(MarkDown30_50.convertMarkdown(src.getDescriptionElement()));
045    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
046      tgt.addUseContext(UsageContext30_50.convertUsageContext(t));
047    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
048      tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept(t));
049    if (src.hasPurpose())
050      tgt.setPurposeElement(MarkDown30_50.convertMarkdown(src.getPurposeElement()));
051    if (src.hasUsage())
052      tgt.setUsageElement(String30_50.convertString(src.getUsageElement()));
053    if (src.hasCopyright())
054      tgt.setCopyrightElement(MarkDown30_50.convertMarkdown(src.getCopyrightElement()));
055    if (src.hasApprovalDate())
056      tgt.setApprovalDateElement(Date30_50.convertDate(src.getApprovalDateElement()));
057    if (src.hasLastReviewDate())
058      tgt.setLastReviewDateElement(Date30_50.convertDate(src.getLastReviewDateElement()));
059    if (src.hasEffectivePeriod())
060      tgt.setEffectivePeriod(Period30_50.convertPeriod(src.getEffectivePeriod()));
061    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getTopic())
062      tgt.addTopic(CodeableConcept30_50.convertCodeableConcept(t));
063    for (org.hl7.fhir.r5.model.ContactDetail t : src.getAuthor()) {
064      org.hl7.fhir.dstu3.model.Contributor c = new org.hl7.fhir.dstu3.model.Contributor();
065      c.setType(ContributorType.AUTHOR);
066      c.addContact(ContactDetail30_50.convertContactDetail(t));
067      tgt.addContributor(c);
068    }
069    for (org.hl7.fhir.r5.model.ContactDetail t : src.getEditor()) {
070      org.hl7.fhir.dstu3.model.Contributor c = new org.hl7.fhir.dstu3.model.Contributor();
071      c.setType(ContributorType.EDITOR);
072      c.addContact(ContactDetail30_50.convertContactDetail(t));
073      tgt.addContributor(c);
074    }
075    for (org.hl7.fhir.r5.model.ContactDetail t : src.getReviewer()) {
076      org.hl7.fhir.dstu3.model.Contributor c = new org.hl7.fhir.dstu3.model.Contributor();
077      c.setType(ContributorType.REVIEWER);
078      c.addContact(ContactDetail30_50.convertContactDetail(t));
079      tgt.addContributor(c);
080    }
081    for (org.hl7.fhir.r5.model.ContactDetail t : src.getEndorser()) {
082      org.hl7.fhir.dstu3.model.Contributor c = new org.hl7.fhir.dstu3.model.Contributor();
083      c.setType(ContributorType.ENDORSER);
084      c.addContact(ContactDetail30_50.convertContactDetail(t));
085      tgt.addContributor(c);
086    }
087    for (org.hl7.fhir.r5.model.RelatedArtifact t : src.getRelatedArtifact())
088      tgt.addRelatedArtifact(RelatedArtifact30_50.convertRelatedArtifact(t));
089    for (org.hl7.fhir.r5.model.ParameterDefinition t : src.getParameter())
090      tgt.addParameter(ParameterDefinition30_50.convertParameterDefinition(t));
091    for (org.hl7.fhir.r5.model.DataRequirement t : src.getDataRequirement())
092      tgt.addDataRequirement(DataRequirement30_50.convertDataRequirement(t));
093    for (org.hl7.fhir.r5.model.Attachment t : src.getContent()) tgt.addContent(Attachment30_50.convertAttachment(t));
094    return tgt;
095  }
096
097  public static org.hl7.fhir.r5.model.Library convertLibrary(org.hl7.fhir.dstu3.model.Library src) throws FHIRException {
098    if (src == null)
099      return null;
100    org.hl7.fhir.r5.model.Library tgt = new org.hl7.fhir.r5.model.Library();
101    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
102    if (src.hasUrl())
103      tgt.setUrlElement(Uri30_50.convertUri(src.getUrlElement()));
104    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
105      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
106    if (src.hasVersion())
107      tgt.setVersionElement(String30_50.convertString(src.getVersionElement()));
108    if (src.hasName())
109      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
110    if (src.hasTitle())
111      tgt.setTitleElement(String30_50.convertString(src.getTitleElement()));
112    if (src.hasStatus())
113      tgt.setStatusElement(Enumerations30_50.convertPublicationStatus(src.getStatusElement()));
114    if (src.hasExperimental())
115      tgt.setExperimentalElement(Boolean30_50.convertBoolean(src.getExperimentalElement()));
116    if (src.hasType())
117      tgt.setType(CodeableConcept30_50.convertCodeableConcept(src.getType()));
118    if (src.hasDate())
119      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
120    if (src.hasPublisher())
121      tgt.setPublisherElement(String30_50.convertString(src.getPublisherElement()));
122    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
123      tgt.addContact(ContactDetail30_50.convertContactDetail(t));
124    if (src.hasDescription())
125      tgt.setDescriptionElement(MarkDown30_50.convertMarkdown(src.getDescriptionElement()));
126    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
127      tgt.addUseContext(UsageContext30_50.convertUsageContext(t));
128    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
129      tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept(t));
130    if (src.hasPurpose())
131      tgt.setPurposeElement(MarkDown30_50.convertMarkdown(src.getPurposeElement()));
132    if (src.hasUsage())
133      tgt.setUsageElement(String30_50.convertString(src.getUsageElement()));
134    if (src.hasCopyright())
135      tgt.setCopyrightElement(MarkDown30_50.convertMarkdown(src.getCopyrightElement()));
136    if (src.hasApprovalDate())
137      tgt.setApprovalDateElement(Date30_50.convertDate(src.getApprovalDateElement()));
138    if (src.hasLastReviewDate())
139      tgt.setLastReviewDateElement(Date30_50.convertDate(src.getLastReviewDateElement()));
140    if (src.hasEffectivePeriod())
141      tgt.setEffectivePeriod(Period30_50.convertPeriod(src.getEffectivePeriod()));
142    for (org.hl7.fhir.dstu3.model.Contributor t : src.getContributor()) {
143      if (t.getType() == ContributorType.AUTHOR)
144        for (ContactDetail c : t.getContact()) tgt.addAuthor(ContactDetail30_50.convertContactDetail(c));
145      if (t.getType() == ContributorType.EDITOR)
146        for (ContactDetail c : t.getContact()) tgt.addEditor(ContactDetail30_50.convertContactDetail(c));
147      if (t.getType() == ContributorType.REVIEWER)
148        for (ContactDetail c : t.getContact()) tgt.addReviewer(ContactDetail30_50.convertContactDetail(c));
149      if (t.getType() == ContributorType.ENDORSER)
150        for (ContactDetail c : t.getContact()) tgt.addEndorser(ContactDetail30_50.convertContactDetail(c));
151    }
152    for (org.hl7.fhir.dstu3.model.RelatedArtifact t : src.getRelatedArtifact())
153      tgt.addRelatedArtifact(RelatedArtifact30_50.convertRelatedArtifact(t));
154    for (org.hl7.fhir.dstu3.model.ParameterDefinition t : src.getParameter())
155      tgt.addParameter(ParameterDefinition30_50.convertParameterDefinition(t));
156    for (org.hl7.fhir.dstu3.model.DataRequirement t : src.getDataRequirement())
157      tgt.addDataRequirement(DataRequirement30_50.convertDataRequirement(t));
158    for (org.hl7.fhir.dstu3.model.Attachment t : src.getContent()) tgt.addContent(Attachment30_50.convertAttachment(t));
159    return tgt;
160  }
161}