001package org.hl7.fhir.r5.model;
002
003import java.util.ArrayList;
004import java.util.Date;
005import java.util.List;
006
007import org.hl7.fhir.utilities.npm.NpmPackage;
008
009public class PackageInformation {
010  private String id;
011  private String version;
012  private Date date;
013
014  private String name;
015  private String canonical;
016  private String web;
017
018  private List<String> dependencies = new ArrayList<>();
019  private String fhirVersion;
020
021  public PackageInformation(String id, String version, String fhirVersion, Date date, String name, String canonical, String web) {
022    super();
023    this.id = id;
024    this.version = version;
025    this.date = date;
026    this.name = name;
027    this.canonical = canonical;
028    this.web = web;
029    this.fhirVersion = fhirVersion;
030  }
031
032  public PackageInformation(String src, String fhirVersion, Date date) {
033    super();
034    this.id = src;
035    this.date = date;
036    this.fhirVersion = fhirVersion;
037  }
038
039  public PackageInformation(NpmPackage pi) {
040    super();
041    this.id = pi.name();
042    this.version = pi.version();
043    this.date = pi.dateAsDate();
044    this.name = pi.title();
045    this.canonical = pi.canonical();
046    this.web = pi.getWebLocation();
047    this.fhirVersion = pi.fhirVersion();
048    dependencies.addAll(pi.dependencies());
049  }
050
051  public PackageInformation(String id, String version, String fhirVersion, Date date) {
052    super();
053    this.id = id;
054    this.version = version;
055    this.fhirVersion = fhirVersion;
056    this.date = date;
057  }
058
059  public String getId() {
060    return id;
061  }
062
063  public String getVersion() {
064    return version;
065  }
066
067  public Date getDate() {
068    return date;
069  }
070
071  public String getName() {
072    return name;
073  }
074
075  public String getCanonical() {
076    return canonical;
077  }
078
079  public String getWeb() {
080    return web;
081  }
082
083  public List<String> getDependencies() {
084    return dependencies;
085  }
086
087  public boolean isExamplesPackage() {
088    boolean b = id.startsWith("hl7.fhir.") && id.endsWith(".examples");
089    return b;
090  }
091
092  public boolean isHTO() {
093    boolean b = id.startsWith("hl7.terminology.r");
094    return b;
095  }
096
097  public String getVID() {
098    return id+"#"+version;
099  }
100
101  public String getFhirVersion() {
102    return fhirVersion;
103  }
104
105  public String toString() {
106    return getVID();
107  }
108}