
001package ca.uhn.fhir.model.dstu2.composite; 002 003/* 004 * #%L 005 * HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) 006 * %% 007 * Copyright (C) 2014 - 2022 Smile CDR, Inc. 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023import java.util.List; 024 025import ca.uhn.fhir.model.api.IElement; 026import ca.uhn.fhir.model.api.annotation.Child; 027import ca.uhn.fhir.model.api.annotation.DatatypeDef; 028import ca.uhn.fhir.model.base.composite.BaseNarrativeDt; 029import ca.uhn.fhir.model.dstu2.valueset.NarrativeStatusEnum; 030import ca.uhn.fhir.model.primitive.BoundCodeDt; 031import ca.uhn.fhir.model.primitive.CodeDt; 032import ca.uhn.fhir.model.primitive.XhtmlDt; 033 034/** 035 * HAPI/FHIR <b>Narrative</b> Datatype 036 * (A human-readable formatted text, including images) 037 * 038 * <p> 039 * <b>Definition:</b> 040 * A human-readable formatted text, including images 041 * </p> 042 * 043 * <p> 044 * <b>Requirements:</b> 045 * 046 * </p> 047 */ 048@DatatypeDef(name="Narrative") 049public class NarrativeDt extends BaseNarrativeDt { 050 051 @Child(name="status", type=CodeDt.class, order=0, min=1, max=1) 052 private BoundCodeDt<NarrativeStatusEnum> myStatus; 053 054 @Child(name="div", type=XhtmlDt.class, order=1, min=1, max=1) 055 private XhtmlDt myDiv; 056 057 public NarrativeDt() { 058 // nothing 059 } 060 061 public NarrativeDt(XhtmlDt theDiv, NarrativeStatusEnum theStatus) { 062 setDiv(theDiv); 063 setStatus(theStatus); 064 } 065 066 @Override 067 public boolean isEmpty() { 068 return ca.uhn.fhir.util.ElementUtil.isEmpty( myStatus, myDiv ); 069 } 070 071 072 @Override 073 public <T extends IElement> List<T> getAllPopulatedChildElementsOfType(Class<T> theType) { 074 return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements( theType, myStatus, myDiv ); 075 } 076 077 /** 078 * Gets the value(s) for <b>status</b> (generated | extensions | additional). 079 * creating it if it does 080 * not exist. Will not return <code>null</code>. 081 * 082 * <p> 083 * <b>Definition:</b> 084 * The status of the narrative - whether it's entirely generated (from just the defined data or the extensions too), or whether a human authored it and it may contain additional data 085 * </p> 086 */ 087 public BoundCodeDt<NarrativeStatusEnum> getStatusElement() { 088 return getStatus(); 089 } 090 091 /** 092 * Gets the value(s) for <b>status</b> (generated | extensions | additional). 093 * creating it if it does 094 * not exist. Will not return <code>null</code>. 095 * 096 * <p> 097 * <b>Definition:</b> 098 * The status of the narrative - whether it's entirely generated (from just the defined data or the extensions too), or whether a human authored it and it may contain additional data 099 * </p> 100 */ 101 @Override 102 public BoundCodeDt<NarrativeStatusEnum> getStatus() { 103 if (myStatus == null) { 104 myStatus = new BoundCodeDt<NarrativeStatusEnum>(NarrativeStatusEnum.VALUESET_BINDER); 105 } 106 return myStatus; 107 } 108 109 /** 110 * Sets the value(s) for <b>status</b> (generated | extensions | additional) 111 * 112 * <p> 113 * <b>Definition:</b> 114 * The status of the narrative - whether it's entirely generated (from just the defined data or the extensions too), or whether a human authored it and it may contain additional data 115 * </p> 116 */ 117 public void setStatus(BoundCodeDt<NarrativeStatusEnum> theValue) { 118 myStatus = theValue; 119 } 120 121 /** 122 * Sets the value(s) for <b>status</b> (generated | extensions | additional) 123 * 124 * <p> 125 * <b>Definition:</b> 126 * The status of the narrative - whether it's entirely generated (from just the defined data or the extensions too), or whether a human authored it and it may contain additional data 127 * </p> 128 */ 129 public void setStatus(NarrativeStatusEnum theValue) { 130 getStatus().setValueAsEnum(theValue); 131 } 132 133 134 /** 135 * Gets the value(s) for <b>div</b> (Limited xhtml content). 136 * creating it if it does 137 * not exist. Will not return <code>null</code>. 138 * 139 * <p> 140 * <b>Definition:</b> 141 * The actual narrative content, a stripped down version of XHTML 142 * </p> 143 */ 144 public XhtmlDt getDivElement() { 145 return getDiv(); 146 } 147 148 /** 149 * Gets the value(s) for <b>div</b> (Limited xhtml content). 150 * creating it if it does 151 * not exist. Will not return <code>null</code>. 152 * 153 * <p> 154 * <b>Definition:</b> 155 * The actual narrative content, a stripped down version of XHTML 156 * </p> 157 */ 158 @Override 159 public XhtmlDt getDiv() { 160 if (myDiv == null) { 161 myDiv = new XhtmlDt(); 162 } 163 return myDiv; 164 } 165 166 /** 167 * Sets the value(s) for <b>div</b> (Limited xhtml content) 168 * 169 * <p> 170 * <b>Definition:</b> 171 * The actual narrative content, a stripped down version of XHTML 172 * </p> 173 */ 174 public void setDiv(XhtmlDt theValue) { 175 myDiv = theValue; 176 } 177 178 /** 179 * Sets the value using a textual DIV (or simple text block which will be 180 * converted to XHTML) 181 */ 182 public void setDiv(String theTextDiv) { 183 myDiv = new XhtmlDt(theTextDiv); 184 } 185 186 187 188 189}