Search dates by range in MedicnalProductAuthorization

Hi,

I’m working with a resource called MedicnalProductAuthorization. Within there is a ‘validityPeriod’. which looks like this:

...
"validityPeriod": {
        "start": "2022-03-17T08:34:57.991+00:002",
        "end": "2022-03-25T08:34:57.991+00:00"
      },
...

I am supposed to perform a search on this resource in following manner. While performing ‘create’ of Authorization, it is possible just to input a ‘start’ date, so some of the resources my look like this:

...
"validityPeriod": {
        "start": "2022-03-17T08:34:57.991+00:002"
      },
...

On FE there will be a date picker for ‘start’ and ‘end’ date. Assuming that ‘start’ is before ‘end’, my search needs to return something like on the image above (sorry about ugliness):

On the image above in cases where “En” is not shown, that means that ‘end’ is null and those resources should be included into search (CASE 6 and CASE2)

At the moment there are two search parameters for dates. They search ‘equal of after’ by the start date AND ‘equal or before’ by the end date:

Start date:

{
  "resourceType": "SearchParameter",
  "name": "Search MedicinalProductAuthorization validity period start",
  "description": "Search MedicinalProductAuthorization validity period start",
  "url": "http://fhir.by/SearchParameter/medicinal-product-authorization-validity-period-start-search-parameter",
  "status": "active",
  "code": "start-validity-period",
  "base": [ "MedicinalProductAuthorization" ],
  "type" : "date",
  "expression": "MedicinalProductAuthorization.validityPeriod.start",
  "xpathUsage": "normal",
  "comparator" : ["eq",
    "ne",
    "gt",
    "ge",
    "lt",
    "le",
    "sa",
    "eb",
    "ap"]
}

and for ‘end’ date:

{
  "resourceType": "SearchParameter",
  "name": "Search MedicinalProductAuthorization validity period end",
  "description": "Search MedicinalProductAuthorization validity period end",
  "url": "http://fhir.by/SearchParameter/medicinal-product-authorization-validity-period-end-search-parameter",
  "status": "active",
  "code": "end-validity-period",
  "base": [ "MedicinalProductAuthorization" ],
  "type" : "date",
  "expression": "MedicinalProductAuthorization.validityPeriod.end",
  "xpathUsage": "normal",
  "comparator" : ["eq",
    "ne",
    "gt",
    "ge",
    "lt",
    "le",
    "sa",
    "eb",
    "ap"]
}

In my java code, since we are using IGenericClient, I’m referencing those SP as follows:

public DaoConstants{
   public static final String SP_AUTHORIZATION_START_VALIDITY_PERIOD =
        "packagedMedicinalProduct.marketingAuthorization.start-validity-period";
    public static final String SP_AUTHORIZATION_END_VALIDITY_PERIOD =
        "packagedMedicinalProduct.marketingAuthorization.end-validity-period";

  public static final DateClientParam AUTHORIZATION_START_VALIDITY_PERIOD =
        new DateClientParam(SP_AUTHORIZATION_START_VALIDITY_PERIOD);
    public static final DateClientParam AUTHORIZATION_END_VALIDITY_PERIOD =
        new DateClientParam(SP_AUTHORIZATION_END_VALIDITY_PERIOD);
}

Part with “packagedMedicinalProduct.marketingAuthorization.” is just telling FHIR (when doing indexing of SP where to apply these SP). Relationship of our business objects is: MedicinalProduct (it has ‘packagedMedicinalProduct’ which contain references to MedicinalProductPackaged) → MedicinalProductPackaged (it has ‘marketingAuthorization’ which has references to MedicinalProductAuthorization).

I have a DTO for validityPeriod:

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ValidityPeriod {

  /** Date from. */
  @DateTimeFormat(iso = ISO.DATE)
  @JsonAlias("start")
  private Date startDate;

  /** Date to. */
  @DateTimeFormat(iso = ISO.DATE)
  @JsonAlias("end")
  private Date endDate;

}

What now is being sent is like this:

http://localhost:8091/fhir/MedicinalProduct?packagedMedicinalProduct.marketingAuthorization.start-validity-period=ge2022-02-28&packagedMedicinalProduct.marketingAuthorization.end-validity-period=le2022-03-26

I see that on SearchParameter - FHIR v5.0.0 there are ‘multipleAnd’ and ‘multipleOr’. Does anyone can give me piece of advice on how to define SP for CASE1-6 and how to reference them in code? Maybe to use _filter?

I expect you need a search parameter defined against the range, rather than just the start or end. There’s no mechanism to say: “date is missing OR date > x” unless you use _filter - and that’s not widely supported. (You might give some feedback via a ChangeRequest to the work group that having a search parameter on the range is needed/useful.)

Okay Loyd, we’ll check other options. Can you tell me what is a ChangeRequest?

At the bottom of every page in a FHIR spec is a “Propose a change” link. You’ll need to do a one-time (free) registration to prove you’re a human being. After that, you can request changes at will :slight_smile:

1 Like