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