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