How create an EHR directly with a status?

Hey guys,
I’m barely new to openEHR and trying to create a new EHR with a Status inside the body. I took the following body from the official docs: EHR API (openehr.org):

{
  "_type": "EHR_STATUS",
  "archetype_node_id": "openEHR-EHR-EHR_STATUS.generic.v1",
  "name": {
    "value": "EHR Status"
  },
  "subject": {
    "external_ref": {
      "id": {
        "_type": "GENERIC_ID",
        "value": "ins01",
        "scheme": "id_scheme"
      },
      "namespace": "examples",
      "type": "PERSON"
    }
  },
  "is_modifiable": true,
  "is_queryable": true
}

If I’m using this twice, it gives me a
Specified party has already an EHR set (partyId=cdde0910-561b-4da2-b6ff-ae703e92105a) which is, i guess, because I did not change the id ins01. But what exactly is this id? Do I have to change it for every new EHR? Furthermore, I have data for different purposes like testing, training, … What is the right place to encode this information. Namespace?

Yes - the external_ref is the real-world identifier for this patient e.g a hospital number or a national ID like the NHS Number.

Remember the the EHR in openEHR is the root container for a single patient, so you are essentially creating that root container for patient with external identifier value = ‘99999999901’ and labelling scheme with some sort of namespace

"external_ref": {
      "id": {
        "_type": "GENERIC_ID",
        "value": "99999999901",
        "scheme": "uk_nhs_nhs_number"
      },
      "namespace": "examples",
      "type": "PERSON"
    }

Once the EHR is created you will be able to retrieve their ehr_id (it is in the Response ETag header) and it is the ehr_id that you use to post a composition data instance to that person’s record.

To answer your other question re Testing / training etc.

Typically define a few 'known dummy patients (and that means an EHR object of each patient) for testing and training, or safer, have whole different CDR domains for this purpose. We use Postman collections and different postman environments to quickly jump between different CDR instances and CDR products.

Hi @ian.mcnicoll - thank you so much for your detailed reply! This has helped me a lot.

I have one more question about this. Let’s say I want to initially assign groups to my EHRs at creation without a separate CDR, which I can include in later queries. Is it possible to set the namespace without an external ID?

No you need an externalId but you could use different namespaces for each of these groups, as a way of partitioning them. The namespace is available when querying.