001package org.hl7.fhir.convertors.conv10_40.datatypes10_40.complextypes10_40;
002
003import org.hl7.fhir.convertors.context.ConversionContext10_40;
004import org.hl7.fhir.convertors.conv10_40.datatypes10_40.primitivetypes10_40.String10_40;
005import org.hl7.fhir.exceptions.FHIRException;
006
007public class CodeableConcept10_40 {
008  public static org.hl7.fhir.r4.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.dstu2.model.CodeableConcept src) throws FHIRException {
009    if (src == null || src.isEmpty()) return null;
010    org.hl7.fhir.r4.model.CodeableConcept tgt = new org.hl7.fhir.r4.model.CodeableConcept();
011    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
012    for (org.hl7.fhir.dstu2.model.Coding t : src.getCoding()) tgt.addCoding(Coding10_40.convertCoding(t));
013    if (src.hasTextElement()) tgt.setTextElement(String10_40.convertString(src.getTextElement()));
014    return tgt;
015  }
016
017  public static org.hl7.fhir.dstu2.model.CodeableConcept convertCodeableConcept(org.hl7.fhir.r4.model.CodeableConcept src) throws FHIRException {
018    if (src == null || src.isEmpty()) return null;
019    org.hl7.fhir.dstu2.model.CodeableConcept tgt = new org.hl7.fhir.dstu2.model.CodeableConcept();
020    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
021    for (org.hl7.fhir.r4.model.Coding t : src.getCoding()) tgt.addCoding(Coding10_40.convertCoding(t));
022    if (src.hasTextElement()) tgt.setTextElement(String10_40.convertString(src.getTextElement()));
023    return tgt;
024  }
025
026  public static org.hl7.fhir.r4.model.UsageContext convertCodeableConceptToUsageContext(org.hl7.fhir.dstu2.model.CodeableConcept t) throws FHIRException {
027    org.hl7.fhir.r4.model.UsageContext result = new org.hl7.fhir.r4.model.UsageContext();
028    result.setValue(convertCodeableConcept(t));
029    return result;
030  }
031
032  static public boolean hasConcept(org.hl7.fhir.r4.model.CodeableConcept cc, String system, String code) {
033    for (org.hl7.fhir.r4.model.Coding c : cc.getCoding()) {
034      if (system.equals(c.getSystem()) && code.equals(c.getCode())) return true;
035    }
036    return false;
037  }
038
039  static public boolean hasConcept(org.hl7.fhir.dstu2.model.CodeableConcept cc, String system, String code) {
040    for (org.hl7.fhir.dstu2.model.Coding c : cc.getCoding()) {
041      if (system.equals(c.getSystem()) && code.equals(c.getCode())) return true;
042    }
043    return false;
044  }
045}