Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,24 @@ public sealed class MimeTypeTerminologyService : CustomValueSetTerminologyServic
private const string MIMETYPE_SYSTEM = "urn:ietf:bcp:13";
public const string MIMETYPE_VALUESET_R4_AND_UP = "http://hl7.org/fhir/ValueSet/mimetypes";
public const string MIMETYPE_VALUESET_STU3 = "http://www.rfc-editor.org/bcp/bcp13.txt";
private const string XML_CODE = "xml";
private const string JSON_CODE = "json";
private const string TTL_CODE = "ttl";

public MimeTypeTerminologyService() : base("MIME type", MIMETYPE_SYSTEM, [MIMETYPE_VALUESET_STU3, MIMETYPE_VALUESET_R4_AND_UP])
{
}

//mime-type format: type "/" [tree "."] subtype ["+" suffix]* [";" parameter];
//FHIR also allows for the following codes: xml, json, ttl
override protected bool ValidateCodeType(string code)
{
//This is a temporary fix until we support additional bindings.
if (code == XML_CODE || code == JSON_CODE || code == TTL_CODE)
{
return true;
}

var entries = code.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
return entries.Length == 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ public async Task MimeTypeValidationTest()
result.Parameter.Should().Contain(p => p.Name == "result")
.Subject.Value.Should().BeEquivalentTo(new FhirBoolean(true));

parameters = new ValidateCodeParameters()
.WithValueSet(MIMETYPEVS)
.WithCode(code: "json")
.Build();

result = await _service.ValueSetValidateCode(parameters);
result.Parameter.Should().Contain(p => p.Name == "result")
.Subject.Value.Should().BeEquivalentTo(new FhirBoolean(true));

parameters = new ValidateCodeParameters()
.WithValueSet(ADMINGENDERVS)
.WithCode(code: "application/json", context: "context")
Expand All @@ -61,6 +70,11 @@ public async Task MimeTypeValidationTest()

validateCode = async () => await _service.ValueSetValidateCode(parameters);
await validateCode.Should().ThrowAsync<FhirOperationException>().WithMessage("Unknown system 'http://hl7.org/fhir/administrative-gender'");



validateCode = async () => await _service.ValueSetValidateCode(parameters);
await validateCode.Should().ThrowAsync<FhirOperationException>().WithMessage("Unknown system 'http://hl7.org/fhir/administrative-gender'");
}

[DataRow(MIMETYPE_VERSIONED_VS)]
Expand Down