001package org.hl7.fhir.r5.utils;
002
003import org.hl7.fhir.r5.context.IWorkerContext;
004import org.hl7.fhir.r5.model.MarkdownType;
005import org.hl7.fhir.r5.model.StringType;
006import org.hl7.fhir.utilities.Utilities;
007import org.hl7.fhir.utilities.VersionUtilities;
008
009
010public class PublicationHacker {
011
012  // this routine fixes up broken binding descriptions from past FHIR publications. All of them will be or are fixed in a later version, 
013  // but fixing old versions is procedurally very difficult. Hence, these work around fixes here
014  
015  public static MarkdownType fixBindingDescriptions(IWorkerContext context, MarkdownType md) {
016    MarkdownType ret = null;
017  
018    // ServiceRequest.code
019    if (md.getValue().contains("LOINC is  (preferred)[http://build.fhir.org/terminologies.html#preferred]")) {
020      ret = md.copy();
021      ret.setValue(md.getValue().replace("LOINC is  (preferred)[http://build.fhir.org/terminologies.html#preferred]", "LOINC is [preferred]("+Utilities.pathURL(VersionUtilities.getSpecUrl(context.getVersion()), "terminologies.html#preferred)")));
022    }
023    if (md.getValue().contains("[here](valueset-diagnostic-requests.html)")) {
024      if (ret == null) {
025        ret = md.copy();
026      }
027      ret.setValue(md.getValue().replace("[here](valueset-diagnostic-requests.html)", "here"));
028    }       
029    return ret == null ? md : ret;
030  }
031
032}