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