001/*- 002 * #%L 003 * Smile CDR - CDR 004 * %% 005 * Copyright (C) 2016 - 2024 Smile CDR, Inc. 006 * %% 007 * All rights reserved. 008 * #L% 009 */ 010package ca.cdr.api.model.json; 011 012import com.fasterxml.jackson.annotation.JsonProperty; 013import com.nimbusds.jose.shaded.gson.annotations.SerializedName; 014import io.swagger.v3.oas.annotations.media.Schema; 015import jakarta.annotation.Nullable; 016 017import java.io.Serializable; 018import java.util.Objects; 019import java.util.StringJoiner; 020 021/** 022 * This structure represents an entry that captures a single entry in fhirContext, 023 * which can be either be a reference only (ex: "PractitionerRole/123") 024 * or a reference/role pair (ex: "List/123", "role": "https://example.org/med-list-at-home"). 025 * A reference is commonly to a FHIR resource and a role is an optional property 026 * with a URI identifying the role. The entire fhirContext is encoded in the access token and used 027 * by the relevant Smart application. 028 * @see <a href='http://hl7.org/fhir/smart-app-launch/scopes-and-launch-context.html#launch-context-arrives-with-your-access_token'>http://hl7.org/fhir/smart-app-launch/scopes-and-launch-context.html#launch-context-arrives-with-your-access_token</a> 029 */ 030@Schema( 031 name = "FhirContextEntry", 032 description = "This structure represents an entry that captures a single entry in fhirContext, " 033 + "which can be either be a reference only (ex: \"PractitionerRole/123\") " 034 + "or a reference/role pair (ex: \"List/123\", \"role\": \"https://example.org/med-list-at-home\"). " 035 + "A reference is commonly to a FHIR resource and a role is an optional property " 036 + "with a URI identifying the role. The entire fhirContext is encoded in the access token and used " 037 + "by the relevant Smart application.") 038public class SmartFhirContextEntryJson implements Serializable, IModelJson { 039 @JsonProperty("reference") 040 @SerializedName("reference") 041 @Schema(description = "The reference to a resource, e.g. 'PractitionerRole/123'") 042 private String myReference; 043 044 @JsonProperty("role") 045 @SerializedName("role") 046 @Nullable 047 @Schema(description = "The role, e.g. 'https://example.org/med-list-at-home'") 048 private String myRole; 049 050 public SmartFhirContextEntryJson() {} 051 052 public static SmartFhirContextEntryJson withReferenceOnly(String theReference) { 053 return new SmartFhirContextEntryJson(theReference, null); 054 } 055 056 public static SmartFhirContextEntryJson withReferenceAndRole(String theReference, String theRole) { 057 return new SmartFhirContextEntryJson(theReference, theRole); 058 } 059 060 private SmartFhirContextEntryJson(String theReference, @Nullable String theRole) { 061 myReference = theReference; 062 myRole = theRole; 063 } 064 065 public String getReference() { 066 return myReference; 067 } 068 069 public void setReference(String theReference) { 070 myReference = theReference; 071 } 072 073 public String getRole() { 074 return myRole; 075 } 076 077 public void setRole(@Nullable String theRole) { 078 myRole = theRole; 079 } 080 081 @Override 082 public boolean equals(Object theO) { 083 if (this == theO) { 084 return true; 085 } 086 if (theO == null || getClass() != theO.getClass()) { 087 return false; 088 } 089 SmartFhirContextEntryJson that = (SmartFhirContextEntryJson) theO; 090 return Objects.equals(myReference, that.myReference) && Objects.equals(myRole, that.myRole); 091 } 092 093 @Override 094 public int hashCode() { 095 return Objects.hash(myReference, myRole); 096 } 097 098 @Override 099 public String toString() { 100 return new StringJoiner(", ", SmartFhirContextEntryJson.class.getSimpleName() + "[", "]") 101 .add("myReference='" + myReference + "'") 102 .add("myRole='" + myRole + "'") 103 .toString(); 104 } 105}