To create the Extension, simply PUT or POST the StructureDefinition with Extension type to the /fhir/StructureDefinition endpoint.
PUT /fhir/StructureDefinition/insurance-plan{"abstract":false,"url":"http://my.company/StructureDefinition/insurance-plan","id":"insurance-plan","name":"InsurancePlanReference","context": [ {"type":"element","expression":"Coverage" } ],"status":"active","kind":"complex-type","type":"Extension","baseDefinition":"http://hl7.org/fhir/StructureDefinition/Extension","version":"0.0.1","differential": {"element": [ {"id":"Extension","max":"1","min":0,"path":"Extension","short":"Reference to the insurance plan" }, {"id":"Extension.url","max":"1","min":1,"path":"Extension.url","fixedUri":"http://my.company/StructureDefinition/insurance-plan" }, {"id":"Extension.value[x]","max":"1","min":1,"path":"Extension.value[x]","type": [ {"code":"Reference","targetProfile": ["http://hl7.org/fhir/StructureDefinition/InsurancePlan" ] } ] } ] },"resourceType":"StructureDefinition","derivation":"constraint"}
When StructureDefinition is created, you can inspect it in the "Fhir Packages" Aidbox UI page.
We can use the defined extension like this:
PUT /fhir/Coverage/my-coverageextension:- url:http://my.company/StructureDefinition/insurance-planvalueReference:reference:InsurancePlan/ip1payor:- reference:Patient/pt1beneficiary:reference:Patient/pt1status:active