@@ -227,20 +227,29 @@ function buildNewRxMedication(doc, medicationRequestResource) {
227227 // loop through the coding values and find the ndc code and the rxnorm code
228228 let medicationCodingList =
229229 getDrugCodeableConceptFromMedicationRequest ( medicationRequestResource ) ?. coding ;
230+
231+ var drugDisplay = 'undefined' ;
230232 for ( let i = 0 ; i < medicationCodingList . length ; i ++ ) {
231233 const coding = medicationCodingList [ i ] ;
232234 const system = coding . system . toLowerCase ( ) ;
233235
236+ // get the display from first drug coding that contains a display value
237+ if ( coding . display && drugDisplay == 'undefined' ) {
238+ drugDisplay = coding . display ;
239+ }
240+
234241 if ( system . endsWith ( 'ndc' ) ) {
235242 // Medication Drug Code
236- xmlAddTextNode ( doc , medicationPrescribed , 'DrugDescription' , coding . display ) ;
237243 var productCode = doc . createElement ( 'ProductCode' ) ;
238244 xmlAddTextNode ( doc , productCode , 'Code' , coding . code ) ;
239245 xmlAddTextNode ( doc , productCode , 'Qualifier' , 'ND' ) ; // National Drug Code (NDC)
240246 drugCoded . appendChild ( productCode ) ;
241247 }
242248 }
243249
250+ // set the drug description
251+ xmlAddTextNode ( doc , medicationPrescribed , 'DrugDescription' , drugDisplay ) ;
252+
244253 medicationPrescribed . appendChild ( drugCoded ) ;
245254
246255 // Medication Quantity
0 commit comments