@@ -40,6 +40,15 @@ import {
4040 validateMustSupport ,
4141} from "../../profile-helpers" ;
4242
43+ export type USCorePatientProfile_RaceExtracted = Partial < Pick < USCoreRaceExtensionProfileFlat , "ombCategory" | "detailed" | "text" > > ;
44+ export type USCorePatientProfile_RaceVFlat = Pick < USCoreRaceExtensionProfileFlat , "ombCategory" | "detailed" | "text" > ;
45+
46+ export type USCorePatientProfile_EthnicityExtracted = Partial < Pick < USCoreEthnicityExtensionProfileFlat , "ombCategory" | "detailed" | "text" > > ;
47+ export type USCorePatientProfile_EthnicityVFlat = Pick < USCoreEthnicityExtensionProfileFlat , "ombCategory" | "detailed" | "text" > ;
48+
49+ export type USCorePatientProfile_TribalAffiliationExtracted = Partial < Pick < USCoreTribalAffiliationExtensionProfileFlat , "tribalAffiliation" | "isEnrolled" > > ;
50+ export type USCorePatientProfile_TribalAffiliationVFlat = Pick < USCoreTribalAffiliationExtensionProfileFlat , "tribalAffiliation" | "isEnrolled" > ;
51+
4352export type USCorePatientProfileRaw = {
4453 identifier : Identifier [ ] ;
4554 name : HumanName [ ] ;
@@ -129,17 +138,23 @@ export class USCorePatientProfile {
129138 return this
130139 }
131140
132- public getRace ( mode : 'flat' ) : USCoreRaceExtensionProfileFlat | undefined ;
141+ public getRace ( mode : 'flat' ) : USCorePatientProfile_RaceExtracted | undefined ;
142+ public getRace ( mode : 'vflat' ) : USCorePatientProfile_RaceVFlat | undefined ;
133143 public getRace ( mode : 'profile' ) : USCoreRaceExtensionProfile | undefined ;
134144 public getRace ( mode : 'raw' ) : Extension | undefined ;
135- public getRace ( ) : USCoreRaceExtensionProfileFlat | undefined ;
136- public getRace ( mode : 'flat' | 'profile' | 'raw' = 'flat' ) : USCoreRaceExtensionProfileFlat | USCoreRaceExtensionProfile | Extension | undefined {
145+ public getRace ( ) : USCorePatientProfile_RaceExtracted | undefined ;
146+ public getRace ( mode : 'flat' | 'vflat' | ' profile' | 'raw' = 'flat' ) : USCorePatientProfile_RaceExtracted | USCorePatientProfile_RaceVFlat | USCoreRaceExtensionProfile | Extension | undefined {
137147 const ext = this . resource . extension ?. find ( e => e . url === "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race" )
138148 if ( ! ext ) return undefined
139149 if ( mode === 'raw' ) return ext
140150 if ( mode === 'profile' ) return USCoreRaceExtensionProfile . apply ( ext )
141151 const config = [ { name : "ombCategory" , valueField : "valueCoding" , isArray : false } , { name : "detailed" , valueField : "valueCoding" , isArray : true } , { name : "text" , valueField : "valueString" , isArray : false } ]
142- return extractComplexExtension < USCoreRaceExtensionProfileFlat > ( ext , config )
152+ if ( mode === 'vflat' ) {
153+ const { errors } = USCoreRaceExtensionProfile . apply ( ext ) . validate ( )
154+ if ( errors . length > 0 ) throw new Error ( errors . join ( "; " ) )
155+ return extractComplexExtension < USCorePatientProfile_RaceVFlat > ( ext , config )
156+ }
157+ return extractComplexExtension < USCorePatientProfile_RaceExtracted > ( ext , config )
143158 }
144159
145160 public setEthnicity ( input : USCoreEthnicityExtensionProfileFlat | USCoreEthnicityExtensionProfile | Extension ) : this {
@@ -154,17 +169,23 @@ export class USCorePatientProfile {
154169 return this
155170 }
156171
157- public getEthnicity ( mode : 'flat' ) : USCoreEthnicityExtensionProfileFlat | undefined ;
172+ public getEthnicity ( mode : 'flat' ) : USCorePatientProfile_EthnicityExtracted | undefined ;
173+ public getEthnicity ( mode : 'vflat' ) : USCorePatientProfile_EthnicityVFlat | undefined ;
158174 public getEthnicity ( mode : 'profile' ) : USCoreEthnicityExtensionProfile | undefined ;
159175 public getEthnicity ( mode : 'raw' ) : Extension | undefined ;
160- public getEthnicity ( ) : USCoreEthnicityExtensionProfileFlat | undefined ;
161- public getEthnicity ( mode : 'flat' | 'profile' | 'raw' = 'flat' ) : USCoreEthnicityExtensionProfileFlat | USCoreEthnicityExtensionProfile | Extension | undefined {
176+ public getEthnicity ( ) : USCorePatientProfile_EthnicityExtracted | undefined ;
177+ public getEthnicity ( mode : 'flat' | 'vflat' | ' profile' | 'raw' = 'flat' ) : USCorePatientProfile_EthnicityExtracted | USCorePatientProfile_EthnicityVFlat | USCoreEthnicityExtensionProfile | Extension | undefined {
162178 const ext = this . resource . extension ?. find ( e => e . url === "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity" )
163179 if ( ! ext ) return undefined
164180 if ( mode === 'raw' ) return ext
165181 if ( mode === 'profile' ) return USCoreEthnicityExtensionProfile . apply ( ext )
166182 const config = [ { name : "ombCategory" , valueField : "valueCoding" , isArray : false } , { name : "detailed" , valueField : "valueCoding" , isArray : true } , { name : "text" , valueField : "valueString" , isArray : false } ]
167- return extractComplexExtension < USCoreEthnicityExtensionProfileFlat > ( ext , config )
183+ if ( mode === 'vflat' ) {
184+ const { errors } = USCoreEthnicityExtensionProfile . apply ( ext ) . validate ( )
185+ if ( errors . length > 0 ) throw new Error ( errors . join ( "; " ) )
186+ return extractComplexExtension < USCorePatientProfile_EthnicityVFlat > ( ext , config )
187+ }
188+ return extractComplexExtension < USCorePatientProfile_EthnicityExtracted > ( ext , config )
168189 }
169190
170191 public setTribalAffiliation ( input : USCoreTribalAffiliationExtensionProfileFlat | USCoreTribalAffiliationExtensionProfile | Extension ) : this {
@@ -179,17 +200,23 @@ export class USCorePatientProfile {
179200 return this
180201 }
181202
182- public getTribalAffiliation ( mode : 'flat' ) : USCoreTribalAffiliationExtensionProfileFlat | undefined ;
203+ public getTribalAffiliation ( mode : 'flat' ) : USCorePatientProfile_TribalAffiliationExtracted | undefined ;
204+ public getTribalAffiliation ( mode : 'vflat' ) : USCorePatientProfile_TribalAffiliationVFlat | undefined ;
183205 public getTribalAffiliation ( mode : 'profile' ) : USCoreTribalAffiliationExtensionProfile | undefined ;
184206 public getTribalAffiliation ( mode : 'raw' ) : Extension | undefined ;
185- public getTribalAffiliation ( ) : USCoreTribalAffiliationExtensionProfileFlat | undefined ;
186- public getTribalAffiliation ( mode : 'flat' | 'profile' | 'raw' = 'flat' ) : USCoreTribalAffiliationExtensionProfileFlat | USCoreTribalAffiliationExtensionProfile | Extension | undefined {
207+ public getTribalAffiliation ( ) : USCorePatientProfile_TribalAffiliationExtracted | undefined ;
208+ public getTribalAffiliation ( mode : 'flat' | 'vflat' | ' profile' | 'raw' = 'flat' ) : USCorePatientProfile_TribalAffiliationExtracted | USCorePatientProfile_TribalAffiliationVFlat | USCoreTribalAffiliationExtensionProfile | Extension | undefined {
187209 const ext = this . resource . extension ?. find ( e => e . url === "http://hl7.org/fhir/us/core/StructureDefinition/us-core-tribal-affiliation" )
188210 if ( ! ext ) return undefined
189211 if ( mode === 'raw' ) return ext
190212 if ( mode === 'profile' ) return USCoreTribalAffiliationExtensionProfile . apply ( ext )
191213 const config = [ { name : "tribalAffiliation" , valueField : "valueCodeableConcept" , isArray : false } , { name : "isEnrolled" , valueField : "valueBoolean" , isArray : false } ]
192- return extractComplexExtension < USCoreTribalAffiliationExtensionProfileFlat > ( ext , config )
214+ if ( mode === 'vflat' ) {
215+ const { errors } = USCoreTribalAffiliationExtensionProfile . apply ( ext ) . validate ( )
216+ if ( errors . length > 0 ) throw new Error ( errors . join ( "; " ) )
217+ return extractComplexExtension < USCorePatientProfile_TribalAffiliationVFlat > ( ext , config )
218+ }
219+ return extractComplexExtension < USCorePatientProfile_TribalAffiliationExtracted > ( ext , config )
193220 }
194221
195222 public setSex ( value : USCoreIndividualSexExtensionProfile | Extension | Coding ) : this {
0 commit comments