## addPreferredPharmacyToPatient() function

Adds or updates a preferred pharmacy extension on a Patient. If the pharmacy already exists, updates its type. Otherwise, adds a new extension. If isPrimary is true, other pharmacies are set to 'preferred'.

**Signature:**

```typescript
export declare function addPreferredPharmacyToPatient(patient: Patient, orgRef: Reference<Organization>, isPrimary: boolean, preferenceTypeSystem?: string): Patient;
```

## Parameters

| Parameter                | Type                       | Description                                                                                                                                                       |
|--------------------------|----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| patient                  | Patient                    | The Patient resource to modify (will be mutated).                                                                                                              |
| orgRef                   | Reference<Organization>    | Reference to the Organization resource.                                                                                                                        |
| isPrimary                | boolean                    | Whether to set this as the primary pharmacy.                                                                                                                   |
| preferenceTypeSystem     | string                     | _(Optional)_ Optional coding system URL for pharmacy preference type. Defaults to [PHARMACY_PREFERENCE_TYPE_SYSTEM](/content/docs/sdk/core.pharmacy_preference_type_system/index.html). |

**Returns:**

Patient

The modified Patient resource.
